Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
num0005 committed Oct 24, 2017
1 parent 8d3320a commit 895b20b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion H2Codez/H2Codez.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor\h2guerilla.exe</LocalDebuggerCommand>
<LocalDebuggerCommand>C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor\h2sapien.exe</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>C:\Program Files %28x86%29\Microsoft Games\Halo 2 Map Editor</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
Expand Down
22 changes: 22 additions & 0 deletions H2Codez/H2Sapien.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ create_main_window create_main_window_orginal;
typedef bool(__fastcall *load_main_window)(int thisptr, int unused, int a2, int a3, int a4, int *a5);
load_main_window load_main_window_orginal;

typedef int (WINAPI *LoadStringW_Typedef)(HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int cchBufferMax);
LoadStringW_Typedef LoadStringW_Orginal;

bool fake;
int WINAPI LoadStringW_Hook(HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int cchBufferMax)
{
if (uID == 421 || uID == 430 || uID == 431 || uID == 633 || uID == 763 || uID == 768 || uID == 4550 || uID == 4690 || uID == 4745) {
fake = !fake;
}

if (uID == 4745) {
fake = !fake;
}
return LoadStringW_Orginal(hInstance, uID, lpBuffer, cchBufferMax);
}

bool __fastcall load_main_window_hook(int thisptr, int unused, int a2, int a3, int a4, int *a5)
{
int menu_ptr = thisptr + 12;
Expand All @@ -29,6 +45,9 @@ void H2SapienPatches::Init()
#pragma region Patches
// stop the default menu overwriting our custom one
NopFill(0x47AD09, 0x15);

BYTE patch_can_display_tag[] = { 0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3 }; // mov eax, 1; retn
WriteBytesASM(0x630200, patch_can_display_tag, sizeof(patch_can_display_tag));
#pragma endregion

#pragma region Hooks
Expand All @@ -42,6 +61,9 @@ void H2SapienPatches::Init()
load_main_window_orginal = CAST_PTR(load_main_window,0x47ACE0);
DetourAttach(&(PVOID&)load_main_window_orginal, load_main_window_hook);

LoadStringW_Orginal = LoadStringW;
DetourAttach(&(PVOID&)LoadStringW_Orginal, LoadStringW_Hook);

DetourTransactionCommit();
#pragma endregion
}

0 comments on commit 895b20b

Please sign in to comment.