Skip to content

Commit

Permalink
[H2Guerilla] Fix help pop-up.
Browse files Browse the repository at this point in the history
Adding version information resulted in the help menu getting replaced with the window menu due to the number of elements changing.
  • Loading branch information
num0005 committed Jul 23, 2018
1 parent 30e0529 commit e933690
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
14 changes: 14 additions & 0 deletions H2Codez/H2Guerilla/H2Guerilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ void __fastcall guerilla_wide_string__append__hook(int this_ptr, int _, int this
Sleep(500);
}

int WINAPI GetMenuItemCountHook(
HMENU hMenu
)
{
// hide the version element from guerilla.
if (hMenu == main_menu)
return 5;
else
return GetMenuItemCount(hMenu);
}

void H2GuerrilaPatches::update_field_display()
{
CheckItem(SHOW_HIDDEN_FIELDS, show_hidden_fields);
Expand Down Expand Up @@ -196,6 +207,9 @@ void H2GuerrilaPatches::Init()
WriteValue(0x00901920, ARRAYSIZE(scenario_types));
WritePointer(0x00901924, scenario_types);

// fix "help" menu getting replaced by "window" menu
PatchAbsCall(0x00686D0A, GetMenuItemCountHook);

#pragma endregion

#pragma region Hooks
Expand Down
35 changes: 35 additions & 0 deletions H2Codez/util/Patches.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,38 @@ inline void WriteCall(void *address, void *function_ptr)
{
WriteCall(reinterpret_cast<DWORD>(address), reinterpret_cast<DWORD>(function_ptr));
}



/*
Patches an absolute call
*/
inline void PatchAbsCall(DWORD call_addr, DWORD new_function_ptr)
{
WriteCall(call_addr, new_function_ptr);
NopFill(call_addr + 5, 1);
}

/*
Patches an absolute call
*/
inline void PatchAbsCall(void *call_addr, void *new_function_ptr)
{
PatchAbsCall(reinterpret_cast<DWORD>(call_addr), reinterpret_cast<DWORD>(new_function_ptr));
}

/*
Patches an absolute call
*/
inline void PatchAbsCall(DWORD call_addr, void *new_function_ptr)
{
PatchAbsCall(call_addr, reinterpret_cast<DWORD>(new_function_ptr));
}

/*
Patches an absolute call
*/
inline void PatchAbsCall(void *call_addr, DWORD new_function_ptr)
{
PatchAbsCall(reinterpret_cast<DWORD>(call_addr), new_function_ptr);
}

0 comments on commit e933690

Please sign in to comment.