Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common - Check extensions hash #10144

Merged
merged 13 commits into from
Jan 13, 2025
23 changes: 23 additions & 0 deletions addons/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
};
25 changes: 25 additions & 0 deletions addons/common/functions/fnc_checkFiles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,31 @@ if (isArray (configFile >> "ACE_Extensions" >> "extensions")) then {
WARNING("extensions[] array no longer supported");
};


if (hasInterface && {_platform == "windows"}) then {
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
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
///////////////
Expand Down
32 changes: 32 additions & 0 deletions tools/getExtensionHash.py
Original file line number Diff line number Diff line change
@@ -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"}};")