diff --git a/res/resource.rc b/res/resource.rc index 6f770be..e8de039 100644 --- a/res/resource.rc +++ b/res/resource.rc @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,1,0,0 - PRODUCTVERSION 1,1,0,0 + FILEVERSION 1,1,1,0 + PRODUCTVERSION 1,1,1,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -79,12 +79,12 @@ BEGIN BEGIN VALUE "CompanyName", "Tosox" VALUE "FileDescription", "Always displays the HP bars for vehicles" - VALUE "FileVersion", "1.1.0" + VALUE "FileVersion", "1.1.1" VALUE "InternalName", "PersistentVehicleHPBars" VALUE "LegalCopyright", "Copyright © 2026" VALUE "OriginalFilename", "PersistentVehicleHPBars.dll" VALUE "ProductName", "PersistentVehicleHPBars" - VALUE "ProductVersion", "1.1.0" + VALUE "ProductVersion", "1.1.1" END END BLOCK "VarFileInfo" diff --git a/src/dllmain.cpp b/src/dllmain.cpp index c3c365d..a214a77 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -6,12 +6,16 @@ namespace { constexpr const char* kVehicleDecoratorUpdatePattern = "55 8B EC 83 E4 F8 6A FF 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 64 89 25 00 00 00 00 " "83 EC 24 53 55 56 57 8B E9 8B 85 80 00 00 00 85 C0 74 41 8B 48 54 85 C9 74 3A"; + constexpr const char* kVehicleDecoratorVeterancyHidePattern = + "53 EB 08 8D 8D 88 00 00 00 6A 01 8B 01 8B 50 04 FF D2 89 5C 24 20 89 5C 24 24"; constexpr std::ptrdiff_t kVehicleHealthWidgetOffset = 0x88; constexpr std::size_t kWidgetSetVisibleVTableIndex = 1; + constexpr unsigned char kVehicleDecoratorVeterancyHideOriginalBytes[] = { 0x53, 0xEB, 0x08 }; + constexpr unsigned char kVehicleDecoratorVeterancyHidePatchedBytes[] = { 0x90, 0xEB, 0x0F }; using VehicleDecoratorUpdateFn = void(__thiscall*)(void*); - using WidgetSetVisibleFn = void(__thiscall*)(void*, int); + using WidgetSetVisibleFn = void(__thiscall*)(void*, bool); VehicleDecoratorUpdateFn oFnVehicleDecoratorUpdate = nullptr; @@ -26,7 +30,7 @@ namespace { } auto* const setVisible = reinterpret_cast(vtable[kWidgetSetVisibleVTableIndex]); - setVisible(widget, visible ? 1 : 0); + setVisible(widget, visible); } void __fastcall HookedVehicleDecoratorUpdate(void* _this, void* edx) { @@ -37,23 +41,35 @@ namespace { } bool SetupHook() { + const auto tVehicleDecoratorVeterancyHideResult = ModSDK::Memory::FindPattern("WW2Mod.dll", kVehicleDecoratorVeterancyHidePattern); + if (!tVehicleDecoratorVeterancyHideResult.has_value()) { + ModSDK::Dialogs::ShowError("Failed to find VehicleDecorator::Update (veterancy hide site)"); + return false; + } + + auto* const tVehicleDecoratorVeterancyHide = reinterpret_cast(tVehicleDecoratorVeterancyHideResult.value()); + ModSDK::Memory::PatchMemory( + tVehicleDecoratorVeterancyHide, + kVehicleDecoratorVeterancyHidePatchedBytes, + sizeof(kVehicleDecoratorVeterancyHidePatchedBytes)); + const auto tVehicleDecoratorUpdateResult = ModSDK::Memory::FindPattern("WW2Mod.dll", kVehicleDecoratorUpdatePattern); if (!tVehicleDecoratorUpdateResult.has_value()) { - ModSDK::Dialogs::ShowError("Failed to find VehicleDecorator::Update"); + ModSDK::Dialogs::ShowError("Failed to find VehicleDecorator::Update"); return false; } - const auto tVehicleDecoratorUpdate = reinterpret_cast(tVehicleDecoratorUpdateResult.value()); + const auto tVehicleDecoratorUpdate = reinterpret_cast(tVehicleDecoratorUpdateResult.value()); if (!ModSDK::Hooks::CreateHook( tVehicleDecoratorUpdate, reinterpret_cast(&HookedVehicleDecoratorUpdate), reinterpret_cast(&oFnVehicleDecoratorUpdate))) { - ModSDK::Dialogs::ShowError("Failed to create VehicleDecorator::Update hook"); + ModSDK::Dialogs::ShowError("Failed to create VehicleDecorator::Update hook"); return false; } if (!ModSDK::Hooks::EnableHook(tVehicleDecoratorUpdate)) { - ModSDK::Dialogs::ShowError("Failed to enable VehicleDecorator::Update hook"); + ModSDK::Dialogs::ShowError("Failed to enable VehicleDecorator::Update hook"); return false; } @@ -73,9 +89,9 @@ namespace { const CoHModSDKModuleV1 kModule = { .abiVersion = COHMODSDK_ABI_VERSION, .size = sizeof(CoHModSDKModuleV1), - .modId = "de.tosox.vehiclehpbars", + .modId = "de.tosox.persistentvehiclehpbars", .name = "Persistent Vehicle HP Bars", - .version = "1.1.0", + .version = "1.1.1", .author = "Tosox", .OnInitialize = &OnInitialize, .OnModsLoaded = &OnModsLoaded,