From 042404afb401c100264858ba5962c1a05549c090 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 25 Jul 2024 01:33:36 -0500 Subject: [PATCH 1/8] Common - Check extension hash --- addons/common/config.cpp | 23 ++++++++++++++++ addons/common/functions/fnc_checkFiles.sqf | 25 +++++++++++++++++ tools/getExtensionHash.py | 32 ++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tools/getExtensionHash.py diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 144e7d96c61..e4727d3b011 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -77,3 +77,26 @@ class ACE_Tests { mapConfigs = QPATHTOF(dev\test_mapConfigs.sqf); cfgPatches = QPATHTOF(dev\test_cfgPatches.sqf); }; + +class ACE_ExtensionsHashes { + class ace_advanced_ballistics { + dll = "bbfbd04bced4e4766298903944ff2d0e3da7586a"; + dll_x64 = "95bdf812ebb52d4e87c4b1b980dfa785d4f980a7"; + }; + class ace_artillerytables { + dll = "f6db1088a08e1c98f3718159a653df3ba11df773"; + dll_x64 = "d3f76b3b95ffe9c6ab6ded137ae41edcab81a9f0"; + }; + class ace_break_line { + dll = "c1f0b83ced1f36849c8aaf23f27c889d7d7e1344"; + dll_x64 = "8622873962f4c4d3bbe05891242f21ba69845d11"; + }; + class ace_clipboard { + dll = "cde2eceb8bac3a119c53a957e332f1a2f9cd8dcb"; + dll_x64 = "d5e8660018b9c9e870a0d4e6005a65afe48b00d3"; + }; + class ace_fcs { + dll = "58b36db51209f61f2b63fc2469b1c74efd581012"; + dll_x64 = "4db527f03bbe71d5004647ad6b12d0263b0c3af9"; + }; +}; diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index 7b90a1b0a85..3299e90b94f 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -145,6 +145,31 @@ if (isArray (configFile >> "ACE_Extensions" >> "extensions")) then { WARNING("extensions[] array no longer supported"); }; + +if (hasInterface && {_platform == "windows"}) then { + if (isFilePatchingEnabled) exitWith {}; + { + private _extName = configName _x; + private _extensionType = "dll"; + if (productVersion select 7 == "x64") then { _extensionType = format ["%1_x64", _extensionType]; }; + private _expectedHash = getText (_x >> _extensionType); + + private _extensionHash = ""; + { + if ((_x getOrDefault ["name", ""]) == _extName) exitWith { + _extensionHash = _x getOrDefault ["hash", ""]; + }; + } forEach allExtensions; + + if (_extensionHash != _expectedHash) then { + private _errorMsg = format ["Extension %1 wrong version [%2 vs %3].", _extName, _extensionHash, _expectedHash]; + ERROR(_errorMsg); + ["[ACE] ERROR", _errorMsg] call FUNC(errorMessage); + }; + } forEach ("true" configClasses (configFile >> "ACE_ExtensionsHashes")); +}; + + /////////////// // Check server version/addons /////////////// diff --git a/tools/getExtensionHash.py b/tools/getExtensionHash.py new file mode 100644 index 00000000000..307538b413b --- /dev/null +++ b/tools/getExtensionHash.py @@ -0,0 +1,32 @@ +import pathlib +import os +import hashlib + +addon_base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + +extensions = {} + +for file in os.listdir(addon_base_path): + path = pathlib.Path(file) + extension_type = "dll" + if path.suffix == ".dll": + key = path.stem + if key.endswith("_x64"): + key = key.removesuffix("_x64") + extension_type += "_x64" + + with open(file, 'rb') as file_read: + sha1 = hashlib.sha1() + data = file_read.read() + sha1.update(data) + arr = extensions.get(key, {}) + arr[extension_type] = sha1.hexdigest() + extensions[key] = arr + +print(f"class ACE_ExtensionsHashes {{") +for key, values in extensions.items(): + print(f" class {key} {{") + for type, hash in values.items(): + print(f" {type} = \"{hash}\";") + print(f" }};") +print(f"}};") From 247495ed2c8f6878dba5d05953bce952e7b4a7fe Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sat, 17 Aug 2024 13:22:01 -0500 Subject: [PATCH 2/8] auto gen hashes on make --- addons/common/ACE_ExtensionsHashes.hpp | 6 ++++++ addons/common/config.cpp | 23 +---------------------- extension/Makefile.toml | 10 +++++++++- tools/.vscode/tasks.json | 8 ++++---- tools/getExtensionHash.py | 24 ++++++++++++++---------- 5 files changed, 34 insertions(+), 37 deletions(-) create mode 100644 addons/common/ACE_ExtensionsHashes.hpp diff --git a/addons/common/ACE_ExtensionsHashes.hpp b/addons/common/ACE_ExtensionsHashes.hpp new file mode 100644 index 00000000000..794f9925ef6 --- /dev/null +++ b/addons/common/ACE_ExtensionsHashes.hpp @@ -0,0 +1,6 @@ +class ACE_ExtensionsHashes { + class ace { + dll = "b2e646f865f48811192bde4877a210a85f05b473"; + dll_x64 = "6b32d7f9a3aaa027af2bc6cb0b7c61371bdf6706"; + }; +}; diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 3a48f350d50..f94b1d376cd 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -76,25 +76,4 @@ class ACE_Tests { cfgPatches = QPATHTOF(dev\test_cfgPatches.sqf); }; -class ACE_ExtensionsHashes { - class ace_advanced_ballistics { - dll = "bbfbd04bced4e4766298903944ff2d0e3da7586a"; - dll_x64 = "95bdf812ebb52d4e87c4b1b980dfa785d4f980a7"; - }; - class ace_artillerytables { - dll = "f6db1088a08e1c98f3718159a653df3ba11df773"; - dll_x64 = "d3f76b3b95ffe9c6ab6ded137ae41edcab81a9f0"; - }; - class ace_break_line { - dll = "c1f0b83ced1f36849c8aaf23f27c889d7d7e1344"; - dll_x64 = "8622873962f4c4d3bbe05891242f21ba69845d11"; - }; - class ace_clipboard { - dll = "cde2eceb8bac3a119c53a957e332f1a2f9cd8dcb"; - dll_x64 = "d5e8660018b9c9e870a0d4e6005a65afe48b00d3"; - }; - class ace_fcs { - dll = "58b36db51209f61f2b63fc2469b1c74efd581012"; - dll_x64 = "4db527f03bbe71d5004647ad6b12d0263b0c3af9"; - }; -}; +#include "ACE_ExtensionsHashes.hpp" diff --git a/extension/Makefile.toml b/extension/Makefile.toml index 3002e34dccf..22f16e3ee18 100644 --- a/extension/Makefile.toml +++ b/extension/Makefile.toml @@ -55,5 +55,13 @@ dependencies = ["build_x32_release"] [tasks.debug] dependencies = ["move_x32_debug", "move_x64_debug"] -[tasks.release] +[tasks.updateSigs] +script_runner = "python" +script_extension = "py" +script_runner_args = ["../tools/getExtensionHash.py"] +script = ''' +''' dependencies = ["move_x32_release", "move_x64_release"] + +[tasks.release] +dependencies = ["updateSigs"] diff --git a/tools/.vscode/tasks.json b/tools/.vscode/tasks.json index 86ba973164a..96b82a3941f 100644 --- a/tools/.vscode/tasks.json +++ b/tools/.vscode/tasks.json @@ -117,9 +117,9 @@ "kind": "build", "isDefault": true } - } + }, { - "label": "Extension: x64", + "label": "Extension: make move_x64_release", "command": "cargo", "options": { "cwd": "${workspaceFolder}" @@ -131,9 +131,9 @@ "group": { "kind": "build" } - } + }, { - "label": "Extension: Release", + "label": "Extension: make release", "command": "cargo", "options": { "cwd": "${workspaceFolder}" diff --git a/tools/getExtensionHash.py b/tools/getExtensionHash.py index 307538b413b..fa990218c44 100644 --- a/tools/getExtensionHash.py +++ b/tools/getExtensionHash.py @@ -7,15 +7,15 @@ extensions = {} for file in os.listdir(addon_base_path): - path = pathlib.Path(file) + path = pathlib.Path(addon_base_path, file) extension_type = "dll" if path.suffix == ".dll": key = path.stem if key.endswith("_x64"): key = key.removesuffix("_x64") extension_type += "_x64" - - with open(file, 'rb') as file_read: + print(f"looking at {path}") + with open(path, 'rb') as file_read: sha1 = hashlib.sha1() data = file_read.read() sha1.update(data) @@ -23,10 +23,14 @@ arr[extension_type] = sha1.hexdigest() extensions[key] = arr -print(f"class ACE_ExtensionsHashes {{") -for key, values in extensions.items(): - print(f" class {key} {{") - for type, hash in values.items(): - print(f" {type} = \"{hash}\";") - print(f" }};") -print(f"}};") +file_out = pathlib.Path(addon_base_path, "addons", "common", "ACE_ExtensionsHashes.hpp") +with open(file_out, 'w') as file_write: + print(f"class ACE_ExtensionsHashes {{", file=file_write) + for key, values in extensions.items(): + print(f" class {key} {{", file=file_write) + for type, hash in values.items(): + print(f" {type} = \"{hash}\";", file=file_write) + print(f" }};", file=file_write) + print(f"}};", file=file_write) + +print(f"Wrote {len(extensions)} to {file_out}") From 80893ff1b9cab426faacc3a04405e7e541e004b0 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Sun, 18 Aug 2024 14:08:20 -0500 Subject: [PATCH 3/8] Update ACE_ExtensionsHashes.hpp --- addons/common/ACE_ExtensionsHashes.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/ACE_ExtensionsHashes.hpp b/addons/common/ACE_ExtensionsHashes.hpp index 794f9925ef6..f0b693cbe41 100644 --- a/addons/common/ACE_ExtensionsHashes.hpp +++ b/addons/common/ACE_ExtensionsHashes.hpp @@ -1,6 +1,6 @@ class ACE_ExtensionsHashes { class ace { - dll = "b2e646f865f48811192bde4877a210a85f05b473"; - dll_x64 = "6b32d7f9a3aaa027af2bc6cb0b7c61371bdf6706"; + dll = "eba921ad7b49cdfad1d5d44c0fbe9e0cbc9056dd"; + dll_x64 = "35140862f100f0a0b588096d017d8fbe313ce25e"; }; }; From 450f6b2f003ca256e37e10caaf8afeaca0d84728 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 8 Oct 2024 22:00:29 -0500 Subject: [PATCH 4/8] Update ACE_ExtensionsHashes.hpp --- addons/common/ACE_ExtensionsHashes.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/ACE_ExtensionsHashes.hpp b/addons/common/ACE_ExtensionsHashes.hpp index f0b693cbe41..74fe4defab1 100644 --- a/addons/common/ACE_ExtensionsHashes.hpp +++ b/addons/common/ACE_ExtensionsHashes.hpp @@ -1,6 +1,6 @@ class ACE_ExtensionsHashes { class ace { - dll = "eba921ad7b49cdfad1d5d44c0fbe9e0cbc9056dd"; - dll_x64 = "35140862f100f0a0b588096d017d8fbe313ce25e"; + dll = "b83c2c9c7c989eaf888c885d13a2fdf4a61d1c5f"; + dll_x64 = "356a61c4bd2aa13556a8ba0b467c819b3b438d6c"; }; }; From 628d57e6bc488435c567707895b7ea2550d9dbf2 Mon Sep 17 00:00:00 2001 From: johnb432 <58661205+johnb432@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:08:34 +0200 Subject: [PATCH 5/8] Add `hasInterface` for version check --- addons/common/functions/fnc_checkFiles.sqf | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index 15eb886cdcc..f77366ea6f0 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -101,34 +101,27 @@ if (_oldCompats isNotEqualTo []) then { /////////////// // Check extensions /////////////// -private _platform = toLowerANSI (productVersion select 6); +if (hasInterface) then { + private _platform = toLowerANSI (productVersion select 6); -if (_platform in ["linux", "osx"]) then { - // Linux and OSX client ports do not support extensions at all - if (hasInterface) then { + // Check for presence + if (_platform in ["linux", "osx"]) exitWith { + // Linux and OSX client ports do not support extensions at all WARNING("Operating system does not support extensions"); - } else { - INFO("Operating system does not support extensions"); }; -} else { + ("ace" callExtension ["version", []]) params [["_versionEx", "", [""]], ["_returnCode", -1, [-1]]]; if (_returnCode != 0 || {_versionEx == ""}) then { private _errorMsg = format ["Extension not found. [Return Code: %1]", _returnCode]; ERROR(_errorMsg); - - if (hasInterface) then { - ["[ACE] ERROR", _errorMsg] call FUNC(errorMessage); - }; + ["[ACE] ERROR", _errorMsg] call FUNC(errorMessage); } else { _versionEx = _versionEx select [0, 8]; // git hash INFO_1("Extension [Version: %1]",_versionEx); }; -}; - - -if (hasInterface && {_platform == "windows"}) then { + // Check for correct hash if (isFilePatchingEnabled) exitWith {}; { private _extName = configName _x; @@ -151,7 +144,6 @@ if (hasInterface && {_platform == "windows"}) then { } forEach ("true" configClasses (configFile >> "ACE_ExtensionsHashes")); }; - /////////////// // Check server version/addons /////////////// From c3cd83b1e2fb74f3b48e029057c21b4b98d24f36 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 2 Jan 2025 16:21:05 -0600 Subject: [PATCH 6/8] add setting --- addons/common/functions/fnc_checkFiles.sqf | 38 ++++++++++++---------- addons/common/initSettings.inc.sqf | 9 +++++ addons/common/stringtable.xml | 3 ++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index 38891d91eec..46870f70ac3 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -137,26 +137,28 @@ if (hasInterface) then { }; // Check for correct hash - if (isFilePatchingEnabled) exitWith {}; - { - private _extName = configName _x; - private _extensionType = "dll"; - if (productVersion select 7 == "x64") then { _extensionType = format ["%1_x64", _extensionType]; }; - private _expectedHash = getText (_x >> _extensionType); - - private _extensionHash = ""; + if (GVAR(checkExtensions)) then { { - if ((_x getOrDefault ["name", ""]) == _extName) exitWith { - _extensionHash = _x getOrDefault ["hash", ""]; - }; - } forEach allExtensions; + private _extName = configName _x; + private _extensionType = "dll"; + if (productVersion select 7 == "x64") then { _extensionType = format ["%1_x64", _extensionType]; }; + private _expectedHash = getText (_x >> _extensionType); + + private _extensionHash = ""; + { + if ((_x getOrDefault ["name", ""]) == _extName) exitWith { + _extensionHash = _x getOrDefault ["hash", ""]; + }; + } forEach allExtensions; + TRACE_3("",_extName,_expectedHash,_extensionHash); - if (_extensionHash != _expectedHash) then { - private _errorMsg = format ["Extension %1 wrong version [%2 vs %3].", _extName, _extensionHash, _expectedHash]; - ERROR(_errorMsg); - ["[ACE] ERROR", _errorMsg] call FUNC(errorMessage); - }; - } forEach ("true" configClasses (configFile >> "ACE_ExtensionsHashes")); + if (_extensionHash != _expectedHash) then { + private _errorMsg = format ["Extension %1 wrong version [%2 vs %3].", _extName, _extensionHash, _expectedHash]; + ERROR(_errorMsg); + ["[ACE] ERROR", _errorMsg] call FUNC(errorMessage); + }; + } forEach ("true" configClasses (configFile >> "ACE_ExtensionsHashes")); + }; }; /////////////// diff --git a/addons/common/initSettings.inc.sqf b/addons/common/initSettings.inc.sqf index 4b3a2fd9c9d..dce467d4585 100644 --- a/addons/common/initSettings.inc.sqf +++ b/addons/common/initSettings.inc.sqf @@ -29,6 +29,15 @@ private _categorySway = [_category, LSTRING(subcategory_sway)]; 1 ] call CBA_fnc_addSetting; +[ + QGVAR(checkExtensions), + "CHECKBOX", + [LSTRING(checkExtensions_DisplayName)], + _category, + false, + true +] call CBA_fnc_addSetting; + [ QGVAR(settingFeedbackIcons), "LIST", diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 6e5f7421139..ae466576d89 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -409,6 +409,9 @@ 检查 PBO PBO-k ellenőrzése + + Check Extensions + What addons are allowed regardless? Jaké addony jsou povoleny? From bbe16107c5a950723a4446641abb52b3d32b08e3 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Fri, 3 Jan 2025 22:55:37 -0300 Subject: [PATCH 7/8] Update addons/common/initSettings.inc.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/initSettings.inc.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/initSettings.inc.sqf b/addons/common/initSettings.inc.sqf index dce467d4585..a0a495b094e 100644 --- a/addons/common/initSettings.inc.sqf +++ b/addons/common/initSettings.inc.sqf @@ -35,7 +35,7 @@ private _categorySway = [_category, LSTRING(subcategory_sway)]; [LSTRING(checkExtensions_DisplayName)], _category, false, - true + 1 ] call CBA_fnc_addSetting; [ From ef2fa9522669a64107b8da47aa498b63a03baba7 Mon Sep 17 00:00:00 2001 From: Grim <69561145+LinkIsGrim@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:58:43 -0300 Subject: [PATCH 8/8] save allExtensions return Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/functions/fnc_checkFiles.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/common/functions/fnc_checkFiles.sqf b/addons/common/functions/fnc_checkFiles.sqf index 46870f70ac3..8ae67eb04a0 100644 --- a/addons/common/functions/fnc_checkFiles.sqf +++ b/addons/common/functions/fnc_checkFiles.sqf @@ -138,6 +138,8 @@ if (hasInterface) then { // Check for correct hash if (GVAR(checkExtensions)) then { + private _allExtensions = allExtensions; + { private _extName = configName _x; private _extensionType = "dll"; @@ -149,7 +151,7 @@ if (hasInterface) then { if ((_x getOrDefault ["name", ""]) == _extName) exitWith { _extensionHash = _x getOrDefault ["hash", ""]; }; - } forEach allExtensions; + } forEach _allExtensions; TRACE_3("",_extName,_expectedHash,_extensionHash); if (_extensionHash != _expectedHash) then {