From db8d3da1a539f11007538e5e2404680e0b4ac966 Mon Sep 17 00:00:00 2001 From: 0xvpr Date: Sun, 11 Feb 2024 03:50:25 -0500 Subject: [PATCH] hacks functions exported to asm --- README.md | 13 +- compile_flags.txt | 3 - src/events.asm.bak | 242 ++++++++++++++++++++++++++ src/events.c | 18 +- src/hack_god_mode.asm | 0 src/hacks.asm | 384 ++++++++++++++++++++++++++++++++++++++++++ src/hacks.c | 55 ------ src/health_detour.asm | 17 -- 8 files changed, 637 insertions(+), 95 deletions(-) create mode 100644 src/events.asm.bak delete mode 100644 src/hack_god_mode.asm create mode 100644 src/hacks.asm delete mode 100644 src/health_detour.asm diff --git a/README.md b/README.md index 3994155..da2de8a 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,9 @@


-### Timeline -- Project started: 08/18/2021 -- Switch from C to CPP: 08/18/2021 -- Project completed: 08/19/2021 -- Switch from CPP to C: 08/20/2021 -- Project revisited: 12/09/2021 -- Project revisited: 12/07/2022 -- Project revisited: 05/26/2023 - ## Overview & Demonstration -The main purpose of this project was to get familiar with the C language while also -familiarizing myself with the Directx9c API. +The main purpose of this repository was to see if I could write cheats +in pure assembly. Demonstration of God Mode, Disable Alarms, and Disable Enemies. diff --git a/compile_flags.txt b/compile_flags.txt index cc7dc88..8c5fbcf 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,8 +1,5 @@ -std=c99 --target=i686-pc-windows-gnu --I/usr/lib/gcc/i686-w64-mingw32/9.3-win32/include --I/usr/lib/gcc/i686-w64-mingw32/9.3-win32/include-fixed --I/usr/lib/gcc/i686-w64-mingw32/9.3-win32/../../../../i686-w64-mingw32/include -Iinclude -Wall -Wextra diff --git a/src/events.asm.bak b/src/events.asm.bak new file mode 100644 index 0000000..dddca47 --- /dev/null +++ b/src/events.asm.bak @@ -0,0 +1,242 @@ +section .text + +extern _GetAsyncKeyState@4 + +extern _g_hack_menu +extern _g_maximized +extern _g_resolution +extern _g_coordinates + +extern _hack_test +extern _hack_no_clip +extern _hack_god_mode +extern _hack_ghost_mode +extern _hack_super_weapons +extern _hack_disable_alarms +extern _hack_disable_enemies +extern _hack_unlock_all_doors + +global _events_handle_keyboard +_events_handle_keyboard: + push ebx ; 10001bc0: _events_handle_keyboard + sub esp, 0x18 ; 10001bc0: 53 + mov dword [esp], 0x61 ; 10001bc1: 83 ec 18 + mov ebx, _GetAsyncKeyState@4 ; 10001bc4: c7 04 24 61 00 00 00 + call ebx ; 10001bcb: 8b 1d e8 70 00 10 + sub esp, 0x4 ; 10001bd1: ff d3 + test al, 0x1 ; 10001bd3: 83 ec 04 + jne god_mode ; 10001bd6: a8 01 + mov dword [esp], 0x62 ; 10001bd8: 0f 85 ca 00 00 00 + call ebx ; 10001bde: c7 04 24 62 00 00 00 + sub esp,0x4 ; 10001be5: ff d3 + test al,0x1 ; 10001be7: 83 ec 04 + jne ghost_mode ; 10001bea: a8 01 + mov dword [esp],0x63 ; 10001bec: 0f 85 e4 00 00 00 + call ebx ; 10001bf2: c7 04 24 63 00 00 00 + sub esp,0x4 ; 10001bf9: ff d3 + test al,0x1 ; 10001bfb: 83 ec 04 + jne super_weapons ; 10001bfe: a8 01 + mov dword [esp],0x64 ; 10001c00: 0f 85 fe 00 00 00 + call ebx ; 10001c06: c7 04 24 64 00 00 00 + sub esp,0x4 ; 10001c0d: ff d3 + test al,0x1 ; 10001c0f: 83 ec 04 + jne disable_alarms ; 10001c12: a8 01 + mov dword [esp],0x65 ; 10001c14: 0f 85 18 01 00 00 + call ebx ; 10001c1a: c7 04 24 65 00 00 00 + sub esp,0x4 ; 10001c21: ff d3 + test al,0x1 ; 10001c23: 83 ec 04 + jne disable_enemies ; 10001c26: a8 01 + mov dword [esp],0x66 ; 10001c28: 0f 85 32 01 00 00 + call ebx ; 10001c2e: c7 04 24 66 00 00 00 + sub esp,0x4 ; 10001c35: ff d3 + test al,0x1 ; 10001c37: 83 ec 04 + jne unlock_all_doors ; 10001c3a: a8 01 + mov dword [esp],0x67 ; 10001c3c: 0f 85 4c 01 00 00 + call ebx ; 10001c42: c7 04 24 67 00 00 00 + sub esp,0x4 ; 10001c49: ff d3 + test al,0x1 ; 10001c4b: 83 ec 04 + jne _events_handle_keyboard+0x1e7 ; 10001c4e: a8 01 + mov ecx,dword [_g_maximized] ; 10001c50: 0f 85 51 01 00 00 +menu_up: + test ecx,ecx ; 10001c56: 8b 0d 10 30 00 10 + jne _events_handle_keyboard+0x1fa ; 10001c5c: 85 c9 + mov dword [esp],0x71 ; 10001c5e: 0f 85 56 01 00 00 + call ebx ; 10001c64: c7 04 24 71 00 00 00 + sub esp,0x4 ; 10001c6b: ff d3 + test al,0x1 ; 10001c6d: 83 ec 04 + je _events_handle_keyboard+0xc6 ; 10001c70: a8 01 + mov edx,dword [_g_maximized] ; 10001c72: 74 12 + xor eax,eax ; 10001c74: 8b 15 10 30 00 10 + test edx,edx ; 10001c7a: 31 c0 + sete al ; 10001c7c: 85 d2 + mov [_g_maximized],eax ; 10001c7e: 0f 94 c0 + mov dword [esp],0x24 ; 10001c81: a3 10 30 00 10 + call ebx ; 10001c86: c7 04 24 24 00 00 00 + mov ebx,eax ; 10001c8d: ff d3 + sub esp,0x4 ; 10001c8f: 89 c3 + xor eax,eax ; 10001c91: 83 ec 04 + test bx,bx ; 10001c94: 31 c0 + jne _events_handle_keyboard+0x280 ; 10001c96: 66 85 db + add esp,0x18 ; 10001c99: 0f 85 a1 01 00 00 + pop ebx ; 10001c9f: 83 c4 18 + ret ; 10001ca2: 5b + lea esi,[esi+0x0] ; 10001ca3: c3 + mov edx,dword [_g_hack_menu+0x44*0] ; 10001ca4: 8d 74 26 00 +god_mode: + xor eax,eax ; 10001ca8: 8b 15 14 30 00 10 + test edx,edx ; 10001cae: 31 c0 + sete al ; 10001cb0: 85 d2 + mov dword [esp],eax ; 10001cb2: 0f 94 c0 + mov dword [_g_hack_menu+0x44*0],eax ; 10001cb5: 89 04 24 + call _hack_god_mode ; 10001cb8: a3 14 30 00 10 + mov dword [esp],0x62 ; 10001cbd: e8 6e 02 00 00 + call ebx ; 10001cc2: c7 04 24 62 00 00 00 + sub esp,0x4 ; 10001cc9: ff d3 + test al,0x1 ; 10001ccb: 83 ec 04 + je _events_handle_keyboard+0x32 ; 10001cce: a8 01 + mov ecx,dword [_g_hack_menu+0x44*1] ; 10001cd0: 0f 84 1c ff ff ff +ghost_mode: + xor eax,eax ; 10001cd6: 8b 0d 58 30 00 10 + test ecx,ecx ; 10001cdc: 31 c0 + sete al ; 10001cde: 85 c9 + mov dword [esp],eax ; 10001ce0: 0f 94 c0 + mov [_g_hack_menu+0x44*1],eax ; 10001ce3: 89 04 24 + call _hack_ghost_mode ; 10001ce6: a3 58 30 00 10 + mov dword [esp],0x63 ; 10001ceb: e8 90 02 00 00 + call ebx ; 10001cf0: c7 04 24 63 00 00 00 + sub esp,0x4 ; 10001cf7: ff d3 + test al,0x1 ; 10001cf9: 83 ec 04 + je _events_handle_keyboard+0x46 ; 10001cfc: a8 01 + mov edx,dword [_g_hack_menu+0x44*2] ; 10001cfe: 0f 84 02 ff ff ff +super_weapons: + xor eax,eax ; 10001d04: 8b 15 9c 30 00 10 + test edx,edx ; 10001d0a: 31 c0 + sete al ; 10001d0c: 85 d2 + mov dword [esp],eax ; 10001d0e: 0f 94 c0 + mov [_g_hack_menu+0x44*2],eax ; 10001d11: 89 04 24 + call _hack_super_weapons ; 10001d14: a3 9c 30 00 10 + mov dword [esp],0x64 ; 10001d19: e8 42 03 00 00 + call ebx ; 10001d1e: c7 04 24 64 00 00 00 + sub esp,0x4 ; 10001d25: ff d3 + test al,0x1 ; 10001d27: 83 ec 04 + je _events_handle_keyboard+0x5a ; 10001d2a: a8 01 + mov ecx,dword [_g_hack_menu+0x44*3] ; 10001d2c: 0f 84 e8 fe ff ff +disable_alarms: + xor eax,eax ; 10001d32: 8b 0d e0 30 00 10 + test ecx,ecx ; 10001d38: 31 c0 + sete al ; 10001d3a: 85 c9 + mov dword [esp],eax ; 10001d3c: 0f 94 c0 + mov [_g_hack_menu+0x44*3],eax ; 10001d3f: 89 04 24 + call _hack_disable_alarms ; 10001d42: a3 e0 30 00 10 + mov dword [esp],0x65 ; 10001d47: e8 a4 05 00 00 + call ebx ; 10001d4c: c7 04 24 65 00 00 00 + sub esp,0x4 ; 10001d53: ff d3 + test al,0x1 ; 10001d55: 83 ec 04 + je _events_handle_keyboard+0x6e ; 10001d58: a8 01 + mov edx,dword [_g_hack_menu+0x44*4] ; 10001d5a: 0f 84 ce fe ff ff +disable_enemies: + xor eax,eax ; 10001d60: 8b 15 24 31 00 10 + test edx,edx ; 10001d66: 31 c0 + sete al ; 10001d68: 85 d2 + mov dword [esp],eax ; 10001d6a: 0f 94 c0 + mov [_g_hack_menu+0x44*4],eax ; 10001d6d: 89 04 24 + call _hack_disable_enemies ; 10001d70: a3 24 31 00 10 + mov dword [esp],0x66 ; 10001d75: e8 c6 05 00 00 + call ebx ; 10001d7a: c7 04 24 66 00 00 00 + sub esp,0x4 ; 10001d81: ff d3 + test al,0x1 ; 10001d83: 83 ec 04 + je _events_handle_keyboard+0x82 ; 10001d86: a8 01 + call _hack_unlock_all_doors ; 10001d88: 0f 84 b4 fe ff ff +unlock_all_doors: + mov dword [esp],0x67 ; 10001d8e: e8 3d 0b 00 00 + call ebx ; 10001d93: c7 04 24 67 00 00 00 + sub esp,0x4 ; 10001d9a: ff d3 + test al,0x1 ; 10001d9c: 83 ec 04 + je menu_up ; 10001d9f: a8 01 + call _hack_test ; 10001da1: 0f 84 af fe ff ff + mov ecx,dword [_g_maximized] ; 10001da7: e8 74 0e 00 00 + test ecx,ecx ; 10001dac: 8b 0d 10 30 00 10 + je _events_handle_keyboard+0xa4 ; 10001db2: 85 c9 + mov dword [esp],0x25 ; 10001db4: 0f 84 aa fe ff ff + call ebx ; 10001dba: c7 04 24 25 00 00 00 + sub esp,0x4 ; 10001dc1: ff d3 + test al,0x1 ; 10001dc3: 83 ec 04 + jne _events_handle_keyboard+0x350 ; 10001dc6: a8 01 + mov dword [esp],0x27 ; 10001dc8: 0f 85 42 01 00 00 + call ebx ; 10001dce: c7 04 24 27 00 00 00 + sub esp,0x4 ; 10001dd5: ff d3 + test al,0x1 ; 10001dd7: 83 ec 04 + jne _events_handle_keyboard+0x320 ; 10001dda: a8 01 + mov dword [esp],0x26 ; 10001ddc: 0f 85 fe 00 00 00 + call ebx ; 10001de2: c7 04 24 26 00 00 00 + sub esp,0x4 ; 10001de9: ff d3 + test al,0x1 ; 10001deb: 83 ec 04 + jne _events_handle_keyboard+0x300 ; 10001dee: a8 01 + mov dword [esp],0x28 ; 10001df0: 0f 85 ca 00 00 00 + call ebx ; 10001df6: c7 04 24 28 00 00 00 + sub esp,0x4 ; 10001dfd: ff d3 + test al,0x1 ; 10001dff: 83 ec 04 + jne _events_handle_keyboard+0x2d0 ; 10001e02: a8 01 + mov ecx,dword [_g_maximized] ; 10001e04: 0f 85 86 00 00 00 + test ecx,ecx ; 10001e0a: 8b 0d 10 30 00 10 + je _events_handle_keyboard+0xa4 ; 10001e10: 85 c9 + mov dword [esp],0x72 ; 10001e12: 0f 84 4c fe ff ff + call ebx ; 10001e18: c7 04 24 72 00 00 00 + sub esp,0x4 ; 10001e1f: ff d3 + test al,0x1 ; 10001e21: 83 ec 04 + je _events_handle_keyboard+0xa4 ; 10001e24: a8 01 + mov dword [_g_coordinates],0x19001e ; 10001e26: 0f 84 38 fe ff ff + ; 10001e2c: c7 05 ac 31 00 10 1e + jmp _events_handle_keyboard+0xa4 ; 10001e33: 00 19 00 + lea esi,[esi+0x0] ; 10001e36: e9 29 fe ff ff + nop ; 10001e3b: 8d 74 26 00 + mov dword [esp],0x0 ; 10001e3f: 90 + call _hack_god_mode ; 10001e40: c7 04 24 00 00 00 00 + mov dword [esp],0x0 ; 10001e47: e8 e4 00 00 00 + call _hack_ghost_mode ; 10001e4c: c7 04 24 00 00 00 00 + mov dword [esp],0x0 ; 10001e53: e8 28 01 00 00 + call _hack_super_weapons ; 10001e58: c7 04 24 00 00 00 00 + mov dword [esp],0x0 ; 10001e5f: e8 fc 01 00 00 + call _hack_disable_alarms ; 10001e64: c7 04 24 00 00 00 00 + mov dword [esp],0x0 ; 10001e6b: e8 80 04 00 00 + call _hack_disable_enemies ; 10001e70: c7 04 24 00 00 00 00 + add esp,0x18 ; 10001e77: e8 c4 04 00 00 + mov eax,0x1 ; 10001e7c: 83 c4 18 + pop ebx ; 10001e7f: b8 01 00 00 00 + ret ; 10001e84: 5b + lea esi,[esi+0x0] ; 10001e85: c3 + lea esi,[esi+0x0] ; 10001e86: 8d b4 26 00 00 00 00 + movzx eax,word [_g_resolution+0x2] ; 10001e8d: 8d 76 00 + movzx ecx,word [_g_coordinates+0x2] ; 10001e90: 0f b7 05 0e 30 00 10 + sub eax,0x78 ; 10001e97: 0f b7 0d ae 31 00 10 + mov edx,ecx ; 10001e9e: 83 e8 78 + cmp ecx,eax ; 10001ea1: 89 ca + jge _events_handle_keyboard+0x24a ; 10001ea3: 39 c1 + add edx,0x5 ; 10001ea5: 0f 8d 5f ff ff ff + mov word [_g_coordinates+0x2],dx ; 10001eab: 83 c2 05 + jmp _events_handle_keyboard+0x24a ; 10001eae: 66 89 15 ae 31 00 10 + lea esi,[esi+0x0] ; 10001eb5: e9 50 ff ff ff + movzx ecx,word [_g_coordinates+0x2] ; 10001eba: 8d b6 00 00 00 00 + cmp cx,0x1e ; 10001ec0: 0f b7 0d ae 31 00 10 + jbe _events_handle_keyboard+0x236 ; 10001ec7: 66 83 f9 1e + sub ecx,0x5 ; 10001ecb: 0f 86 25 ff ff ff + mov word [_g_coordinates+0x2],cx ; 10001ed1: 83 e9 05 + jmp _events_handle_keyboard+0x236 ; 10001ed4: 66 89 0d ae 31 00 10 + movzx eax,word [_g_resolution] ; 10001edb: e9 16 ff ff ff + movzx ecx,word [_g_coordinates] ; 10001ee0: 0f b7 05 0c 30 00 10 + sub eax,0xaf ; 10001ee7: 0f b7 0d ac 31 00 10 + mov edx,ecx ; 10001eee: 2d af 00 00 00 + cmp ecx,eax ; 10001ef3: 89 ca + jge _events_handle_keyboard+0x222 ; 10001ef5: 39 c1 + add edx,0x5 ; 10001ef7: 0f 8d e5 fe ff ff + mov word [_g_coordinates],dx ; 10001efd: 83 c2 05 + jmp _events_handle_keyboard+0x222 ; 10001f00: 66 89 15 ac 31 00 10 + lea esi,[esi+0x0] ; 10001f07: e9 d6 fe ff ff + movzx eax,word [_g_coordinates] ; 10001f0c: 8d 74 26 00 + cmp ax,0x23 ; 10001f10: 0f b7 05 ac 31 00 10 + jbe _events_handle_keyboard+0x20e ; 10001f17: 66 83 f8 23 + sub eax,0x5 ; 10001f1b: 0f 86 ad fe ff ff + mov [_g_coordinates],ax ; 10001f21: 83 e8 05 + jmp _events_handle_keyboard+0x20e ; 10001f24: 66 a3 ac 31 00 10 + nop ; 10001f2a: e9 9f fe ff ff + ; 10001f2f: 90 diff --git a/src/events.c b/src/events.c index a0b6174..6f8029e 100644 --- a/src/events.c +++ b/src/events.c @@ -15,51 +15,51 @@ extern HackMenu g_hack_menu[MAX_MENU_ITEMS]; int events_handle_keyboard(void) { - /* Toggle GodMode */ + /*[> Toggle GodMode <]*/ if (GetAsyncKeyState(VK_NUMPAD1) & 1) { g_hack_menu[GOD_MODE].bEnabled = !g_hack_menu[GOD_MODE].bEnabled; hack_god_mode(g_hack_menu[GOD_MODE].bEnabled); } - /* Toggle GhostMode */ + /*[> Toggle GhostMode <]*/ if (GetAsyncKeyState(VK_NUMPAD2) & 1) { g_hack_menu[GHOST_MODE].bEnabled = !g_hack_menu[GHOST_MODE].bEnabled; hack_ghost_mode(g_hack_menu[GHOST_MODE].bEnabled); } - /* Toggle Super Weapons */ + /*[> Toggle Super Weapons <]*/ if (GetAsyncKeyState(VK_NUMPAD3) & 1) { g_hack_menu[SUPER_WEAPONS].bEnabled = !g_hack_menu[SUPER_WEAPONS].bEnabled; hack_super_weapons(g_hack_menu[SUPER_WEAPONS].bEnabled); } - /* Disable All Alarms */ + /*[> Disable All Alarms <]*/ if (GetAsyncKeyState(VK_NUMPAD4) & 1) { g_hack_menu[DISABLE_ALARMS].bEnabled = !g_hack_menu[DISABLE_ALARMS].bEnabled; hack_disable_alarms(g_hack_menu[DISABLE_ALARMS].bEnabled); } - /* Toggle DisableEnemies */ + /*[> Toggle DisableEnemies <]*/ if (GetAsyncKeyState(VK_NUMPAD5) & 1) { g_hack_menu[DISABLE_ENEMIES].bEnabled = !g_hack_menu[DISABLE_ENEMIES].bEnabled; - /*n_entities_changed = */ + /*[>n_entities_changed = <]*/ hack_disable_enemies(g_hack_menu[DISABLE_ENEMIES].bEnabled); } - /* Unlock All Doors */ + /*[> Unlock All Doors <]*/ if (GetAsyncKeyState(VK_NUMPAD6) & 1) { //g_hack_menu[UNLOCK_ALL_DOORS].bEnabled = !g_hack_menu[UNLOCK_ALL_DOORS].bEnabled; - /*total_doors_unlocked = */ + /*[>total_doors_unlocked = <]*/ hack_unlock_all_doors(); } - /* Unlock All Doors */ + /*[> Unlock All Doors <]*/ if (GetAsyncKeyState(VK_NUMPAD7) & 1) { hack_test(); diff --git a/src/hack_god_mode.asm b/src/hack_god_mode.asm deleted file mode 100644 index e69de29..0000000 diff --git a/src/hacks.asm b/src/hacks.asm new file mode 100644 index 0000000..217a037 --- /dev/null +++ b/src/hacks.asm @@ -0,0 +1,384 @@ +; ----------------------------------------------------------------------------- +; Definitions +; ----------------------------------------------------------------------------- + +TYPE_PLAYER EQU 0x110E8B50 +OFFSET_HEALTH EQU 0x003F07C8 +OFFSET_VISIBILITY EQU 0x0027F12C +OFFSET_NOISE EQU 0x00417E5D +OFFSET_ALARMS EQU 0x0009BC61 + +; ----------------------------------------------------------------------------- +; External Variables +; ----------------------------------------------------------------------------- + +extern _g_module_base_addr + +; ----------------------------------------------------------------------------- +; External Functions +; ----------------------------------------------------------------------------- + +extern _VirtualProtect@16 + +extern _memory_patch +extern _memory_detour + +; ----------------------------------------------------------------------------- +; Executable Code +; ----------------------------------------------------------------------------- +section .text +global _hack_god_mode +global _hack_ghost_mode +global _hack_disable_alarms + +health_original: + sub eax, edx + mov dword [ebx], eax + mov ebx, eax + +health_detour: + cmp dword [edi], TYPE_PLAYER + je skip_player + xor eax, eax + mov eax, eax + mov dword [ebx], eax + mov ebx, eax +skip_player: + mov eax, dword [esp + 0x14] + pop esi + mov dword [eax], ebx + pop ebx + pop ecx + ret 0x8 + +visibility_original: + mov eax, dword [esi + 0x1518] + +noise_original: + cmp edi, eax + +noise_patch: + cmp eax, eax + +alarm_original: + jne $ + 0x33b + +alarm_patch: + jmp $ + 0x33b + nop + +_hack_god_mode: ; 0001f30: <_hack_god_mode>: + sub esp,0x1c ; 0001f30: 83 ec 1c + mov eax,OFFSET_HEALTH ; 0001f33: a1 e0 31 00 10 + mov edx,dword [esp+0x20] ; 0001f38: 8b 54 24 20 + add eax,dword [_g_module_base_addr] ; 0001f3c: 03 05 04 30 00 10 + test edx,edx ; 0001f42: 85 d2 + mov dword [esp+0x8],0x6 ; 0001f44: c7 44 24 08 06 00 00 + ; 0001f4b: 00 + je god_mode_disabled ; 0001f4c: 74 1a +god_mode_enabled: + mov dword [esp+0x4], health_detour ; 0001f4e: c7 44 24 04 e0 13 00 + ; 0001f55: 10 + mov dword [esp],eax ; 0001f56: 89 04 24 + call _memory_detour ; 0001f59: e8 a9 f7 ff ff + add esp,0x1c ; 0001f5e: 83 c4 1c + ret ; 0001f61: c3 + lea esi,[esi+0x0] ; 0001f62: 8d b6 00 00 00 00 +god_mode_disabled: + mov dword [esp+0x4], health_original ; 0001f68: c7 44 24 04 d4 40 00 + ; 0001f6f: 10 + mov dword [esp],eax ; 0001f70: 89 04 24 + call _memory_patch ; 0001f73: e8 27 f7 ff ff + add esp,0x1c ; 0001f78: 83 c4 1c + ret ; 0001f7b: c3 + lea esi,[esi+0x0] ; 0001f7c: 8d 74 26 00 + nop + nop + +_hack_ghost_mode: ; 10001f80 <_hack_ghost_mode>: + push ebp ; 10001f80: 55 + push edi ; 10001f81: 57 + push esi ; 10001f82: 56 + push ebx ; 10001f83: 53 + sub esp,0x2c ; 10001f84: 83 ec 2c + mov ebx,dword [_g_module_base_addr] ; 10001f87: 8b 1d 04 30 00 10 + mov esi, OFFSET_VISIBILITY ; 10001f8d: 8b 35 e8 31 00 10 + mov eax,dword [esp+0x40] ; 10001f93: 8b 44 24 40 + add esi,ebx ; 10001f97: 01 de + add ebx, OFFSET_NOISE ; 10001f99: 03 1d e4 31 00 10 + test eax,eax ; 10001f9f: 85 c0 + je ghost_mode_disabled ; 10001fa1: 74 7d +ghost_mode_enabled: + lea ebp,[esp+0x1c] ; 10001fa3: 8d 6c 24 1c + mov dword [esp+0xc],ebp ; 10001fa7: 89 6c 24 0c + mov dword [esp],esi ; 10001fab: 89 34 24 + mov dword [esp+0x8],0x80 ; 10001fae: c7 44 24 08 80 00 00 + ; 10001fb5: 00 + mov dword [esp+0x4],0x6 ; 10001fb6: c7 44 24 04 06 00 00 + ; 10001fbd: 00 + mov edi,_VirtualProtect@16 ; 10001fbe: 8b 3d d0 70 00 10 + mov dword [esp+0x1c],0x0 ; 10001fc4: c7 44 24 1c 00 00 00 + ; 10001fcb: 00 + call edi ; 10001fcc: ff d7 + sub esp,0x10 ; 10001fce: 83 ec 10 + mov edx,dword [esp+0x1c] ; 10001fd1: 8b 54 24 1c + mov dword [esi],0x90909090 ; 10001fd5: c7 06 90 90 90 90 + mov dword [esi+0x4],0x5d99090 ; 10001fdb: c7 46 04 90 90 d9 05 + mov dword [esp+0xc],ebp ; 10001fe2: 89 6c 24 0c + mov dword [esp+0x8],edx ; 10001fe6: 89 54 24 08 + mov dword [esp],esi ; 10001fea: 89 34 24 + mov dword [esp+0x4],0x6 ; 10001fed: c7 44 24 04 06 00 00 + ; 10001ff4: 00 + call edi ; 10001ff5: ff d7 + sub esp,0x10 ; 10001ff7: 83 ec 10 + mov dword [esp],ebx ; 10001ffa: 89 1c 24 + mov dword [esp+0x8],0x2 ; 10001ffd: c7 44 24 08 02 00 00 + ; 10002004: 00 + mov dword [esp+0x4],noise_patch ; 10002005: c7 44 24 04 c8 40 00 + ; 1000200c: 10 + call _memory_patch ; 1000200d: e8 8d f6 ff ff + add esp,0x2c ; 10002012: 83 c4 2c + pop ebx ; 10002015: 5b + pop esi ; 10002016: 5e + pop edi ; 10002017: 5f + pop ebp ; 10002018: 5d + ret ; 10002019: c3 + lea esi,[esi] ; 1000201a: 8d b6 00 00 00 00 + nop + nop + nop + nop +ghost_mode_disabled: + mov dword [esp],esi ; 10002020: 89 34 24 + mov dword [esp+0x8],0x6 ; 10002023: c7 44 24 08 06 00 00 + ; 1000202a: 00 + mov dword [esp+0x4],visibility_original ; 1000202b: c7 44 24 04 cc 40 00 + ; 10002032: 10 + call _memory_patch ; 10002033: e8 67 f6 ff ff + mov dword [esp],ebx ; 10002038: 89 1c 24 + mov dword [esp+0x8],0x2 ; 1000203b: c7 44 24 08 02 00 00 + ; 10002042: 00 + mov dword [esp+0x4],noise_original ; 10002043: c7 44 24 04 ca 40 00 + ; 1000204a: 10 + call _memory_patch ; 1000204b: e8 4f f6 ff ff + add esp,0x2c ; 10002050: 83 c4 2c + pop ebx ; 10002053: 5b + pop esi ; 10002054: 5e + pop edi ; 10002055: 5f + pop ebp ; 10002056: 5d + ret ; 10002057: c3 + lea esi,[esi+0x0] ; 10002058: 8d b4 26 00 00 00 00 + nop + nop + nop + nop + +;_hack_super_weapons ; 10002060 <_hack_super_weapons>: +; push ebp ; 10002060: 55 +; push edi ; 10002061: 57 +; push esi ; 10002062: 56 +; push ebx ; 10002063: 53 +; sub esp,0x3c ; 10002064: 83 ec 3c +; mov eax,[_g_module_base_addr] ; 10002067: a1 04 30 00 10 +; mov ebx,DWORD PTR ds:0x100031b0 ; 1000206c: 8b 1d b0 31 00 10 +; mov esi,DWORD PTR ds:0x100031b4 ; 10002072: 8b 35 b4 31 00 10 +; add ebx,eax ; 10002078: 01 c3 +; mov DWORD PTR [esp+0x1c],ebx ; 1000207a: 89 5c 24 1c +; mov ebx,DWORD PTR ds:0x100031b8 ; 1000207e: 8b 1d b8 31 00 10 +; add esi,eax ; 10002084: 01 c6 +; add ebx,eax ; 10002086: 01 c3 +; mov DWORD PTR [esp+0x20],esi ; 10002088: 89 74 24 20 +; mov DWORD PTR [esp+0x24],ebx ; 1000208c: 89 5c 24 24 +; mov ecx,DWORD PTR ds:0x100031d8 ; 10002090: 8b 0d d8 31 00 10 +; mov ebp,DWORD PTR ds:0x100031d4 ; 10002096: 8b 2d d4 31 00 10 +; mov edx,DWORD PTR ds:0x100031d0 ; 1000209c: 8b 15 d0 31 00 10 +; mov edi,DWORD PTR ds:0x100031cc ; 100020a2: 8b 3d cc 31 00 10 +; mov esi,DWORD PTR ds:0x100031bc ; 100020a8: 8b 35 bc 31 00 10 +; mov ebx,DWORD PTR ds:0x100031c0 ; 100020ae: 8b 1d c0 31 00 10 +; add edx,eax ; 100020b4: 01 c2 +; add ecx,eax ; 100020b6: 01 c1 +; add ebp,eax ; 100020b8: 01 c5 +; add edi,eax ; 100020ba: 01 c7 +; add esi,eax ; 100020bc: 01 c6 +; add ebx,eax ; 100020be: 01 c3 +; add eax,DWORD PTR ds:0x100031c4 ; 100020c0: 03 05 c4 31 00 10 +; cmp DWORD PTR [esp+0x50],0x0 ; 100020c6: 83 7c 24 50 00 +; mov DWORD PTR [esp+0x2c],eax ; 100020cb: 89 44 24 2c +; mov DWORD PTR [esp+0x28],edx ; 100020cf: 89 54 24 28 +; je 100021d8 <_hack_super_weapons+0x178> ; 100020d3: 0f 84 ff 00 00 00 +; mov DWORD PTR [esp],ecx ; 100020d9: 89 0c 24 +; mov DWORD PTR [esp+0x4],0x2 ; 100020dc: c7 44 24 04 02 00 00 +; ; 100020e3: 00 +; call 10001637 <_memory_nop> ; 100020e4: e8 4e f5 ff ff +; mov eax,DWORD PTR [esp+0x28] ; 100020e9: 8b 44 24 28 +; mov DWORD PTR [esp+0x8],0xe ; 100020ed: c7 44 24 08 0e 00 00 +; ; 100020f4: 00 +; mov DWORD PTR [esp],eax ; 100020f5: 89 04 24 +; mov DWORD PTR [esp+0x4],0x10004088 ; 100020f8: c7 44 24 04 88 40 00 +; ; 100020ff: 10 +; call 1000169f <_memory_patch> ; 10002100: e8 9a f5 ff ff +; mov DWORD PTR [esp],ebp ; 10002105: 89 2c 24 +; mov DWORD PTR [esp+0x8],0xe ; 10002108: c7 44 24 08 0e 00 00 +; ; 1000210f: 00 +; mov DWORD PTR [esp+0x4],0x100040a8 ; 10002110: c7 44 24 04 a8 40 00 +; ; 10002117: 10 +; call 1000169f <_memory_patch> ; 10002118: e8 82 f5 ff ff +; mov DWORD PTR [esp],edi ; 1000211d: 89 3c 24 +; mov DWORD PTR [esp+0x4],0x2 ; 10002120: c7 44 24 04 02 00 00 +; ; 10002127: 00 +; call 10001637 <_memory_nop> ; 10002128: e8 0a f5 ff ff +; mov ecx,DWORD PTR [esp+0x1c] ; 1000212d: 8b 4c 24 1c +; mov DWORD PTR [esp+0x8],0x6 ; 10002131: c7 44 24 08 06 00 00 +; ; 10002138: 00 +; mov DWORD PTR [esp],ecx ; 10002139: 89 0c 24 +; mov DWORD PTR [esp+0x4],0x10004020 ; 1000213c: c7 44 24 04 20 40 00 +; ; 10002143: 10 +; call 1000169f <_memory_patch> ; 10002144: e8 56 f5 ff ff +; mov ebp,DWORD PTR [esp+0x20] ; 10002149: 8b 6c 24 20 +; mov DWORD PTR [esp+0x8],0x6 ; 1000214d: c7 44 24 08 06 00 00 +; ; 10002154: 00 +; mov DWORD PTR [esp],ebp ; 10002155: 89 2c 24 +; mov DWORD PTR [esp+0x4],0x10004026 ; 10002158: c7 44 24 04 26 40 00 +; ; 1000215f: 10 +; call 1000169f <_memory_patch> ; 10002160: e8 3a f5 ff ff +; mov edx,DWORD PTR [esp+0x24] ; 10002165: 8b 54 24 24 +; mov DWORD PTR [esp+0x8],0x6 ; 10002169: c7 44 24 08 06 00 00 +; ; 10002170: 00 +; mov DWORD PTR [esp],edx ; 10002171: 89 14 24 +; mov DWORD PTR [esp+0x4],0x1000402c ; 10002174: c7 44 24 04 2c 40 00 +; ; 1000217b: 10 +; call 1000169f <_memory_patch> ; 1000217c: e8 1e f5 ff ff +; mov DWORD PTR [esp],esi ; 10002181: 89 34 24 +; mov DWORD PTR [esp+0x8],0x6 ; 10002184: c7 44 24 08 06 00 00 +; ; 1000218b: 00 +; mov DWORD PTR [esp+0x4],0x10004032 ; 1000218c: c7 44 24 04 32 40 00 +; ; 10002193: 10 +; call 1000169f <_memory_patch> ; 10002194: e8 06 f5 ff ff +; mov DWORD PTR [esp],ebx ; 10002199: 89 1c 24 +; mov DWORD PTR [esp+0x8],0x6 ; 1000219c: c7 44 24 08 06 00 00 +; ; 100021a3: 00 +; mov DWORD PTR [esp+0x4],0x10004038 ; 100021a4: c7 44 24 04 38 40 00 +; ; 100021ab: 10 +; call 1000169f <_memory_patch> ; 100021ac: e8 ee f4 ff ff +; mov esi,DWORD PTR [esp+0x2c] ; 100021b1: 8b 74 24 2c +; mov DWORD PTR [esp+0x8],0x6 ; 100021b5: c7 44 24 08 06 00 00 +; ; 100021bc: 00 +; mov DWORD PTR [esp],esi ; 100021bd: 89 34 24 +; mov DWORD PTR [esp+0x4],0x1000403e ; 100021c0: c7 44 24 04 3e 40 00 +; ; 100021c7: 10 +; call 1000169f <_memory_patch> ; 100021c8: e8 d2 f4 ff ff +; add esp,0x3c ; 100021cd: 83 c4 3c +; pop ebx ; 100021d0: 5b +; pop esi ; 100021d1: 5e +; pop edi ; 100021d2: 5f +; pop ebp ; 100021d3: 5d +; ret ; 100021d4: c3 +; lea esi,[esi+0x0] ; 100021d5: 8d 76 00 +; mov DWORD PTR [esp],ecx ; 100021d8: 89 0c 24 +; mov DWORD PTR [esp+0x8],0x2 ; 100021db: c7 44 24 08 02 00 00 +; ; 100021e2: 00 +; mov DWORD PTR [esp+0x4],0x100040c6 ; 100021e3: c7 44 24 04 c6 40 00 +; ; 100021ea: 10 +; call 1000169f <_memory_patch> ; 100021eb: e8 af f4 ff ff +; mov eax,DWORD PTR [esp+0x28] ; 100021f0: 8b 44 24 28 +; mov DWORD PTR [esp+0x8],0xe ; 100021f4: c7 44 24 08 0e 00 00 +; ; 100021fb: 00 +; mov DWORD PTR [esp],eax ; 100021fc: 89 04 24 +; mov DWORD PTR [esp+0x4],0x10004098 ; 100021ff: c7 44 24 04 98 40 00 +; ; 10002206: 10 +; call 1000169f <_memory_patch> ; 10002207: e8 93 f4 ff ff +; mov DWORD PTR [esp],ebp ; 1000220c: 89 2c 24 +; mov DWORD PTR [esp+0x8],0xe ; 1000220f: c7 44 24 08 0e 00 00 +; ; 10002216: 00 +; mov DWORD PTR [esp+0x4],0x100040b8 ; 10002217: c7 44 24 04 b8 40 00 +; ; 1000221e: 10 +; call 1000169f <_memory_patch> ; 1000221f: e8 7b f4 ff ff +; mov DWORD PTR [esp],edi ; 10002224: 89 3c 24 +; mov DWORD PTR [esp+0x8],0x2 ; 10002227: c7 44 24 08 02 00 00 +; ; 1000222e: 00 +; mov DWORD PTR [esp+0x4],0x10004084 ; 1000222f: c7 44 24 04 84 40 00 +; ; 10002236: 10 +; call 1000169f <_memory_patch> ; 10002237: e8 63 f4 ff ff +; mov ecx,DWORD PTR [esp+0x1c] ; 1000223c: 8b 4c 24 1c +; mov DWORD PTR [esp+0x8],0x6 ; 10002240: c7 44 24 08 06 00 00 +; ; 10002247: 00 +; mov DWORD PTR [esp],ecx ; 10002248: 89 0c 24 +; mov DWORD PTR [esp+0x4],0x10004060 ; 1000224b: c7 44 24 04 60 40 00 +; ; 10002252: 10 +; call 1000169f <_memory_patch> ; 10002253: e8 47 f4 ff ff +; mov ebp,DWORD PTR [esp+0x20] ; 10002258: 8b 6c 24 20 +; mov DWORD PTR [esp+0x8],0x6 ; 1000225c: c7 44 24 08 06 00 00 +; ; 10002263: 00 +; mov DWORD PTR [esp],ebp ; 10002264: 89 2c 24 +; mov DWORD PTR [esp+0x4],0x10004066 ; 10002267: c7 44 24 04 66 40 00 +; ; 1000226e: 10 +; call 1000169f <_memory_patch> ; 1000226f: e8 2b f4 ff ff +; mov edx,DWORD PTR [esp+0x24] ; 10002274: 8b 54 24 24 +; mov DWORD PTR [esp+0x8],0x6 ; 10002278: c7 44 24 08 06 00 00 +; ; 1000227f: 00 +; mov DWORD PTR [esp],edx ; 10002280: 89 14 24 +; mov DWORD PTR [esp+0x4],0x1000406c ; 10002283: c7 44 24 04 6c 40 00 +; ; 1000228a: 10 +; call 1000169f <_memory_patch> ; 1000228b: e8 0f f4 ff ff +; mov DWORD PTR [esp],esi ; 10002290: 89 34 24 +; mov DWORD PTR [esp+0x8],0x6 ; 10002293: c7 44 24 08 06 00 00 +; ; 1000229a: 00 +; mov DWORD PTR [esp+0x4],0x10004072 ; 1000229b: c7 44 24 04 72 40 00 +; ; 100022a2: 10 +; call 1000169f <_memory_patch> ; 100022a3: e8 f7 f3 ff ff +; mov DWORD PTR [esp],ebx ; 100022a8: 89 1c 24 +; mov DWORD PTR [esp+0x8],0x6 ; 100022ab: c7 44 24 08 06 00 00 +; ; 100022b2: 00 +; mov DWORD PTR [esp+0x4],0x10004078 ; 100022b3: c7 44 24 04 78 40 00 +; ; 100022ba: 10 +; call 1000169f <_memory_patch> ; 100022bb: e8 df f3 ff ff +; mov edi,DWORD PTR [esp+0x2c] ; 100022c0: 8b 7c 24 2c +; mov DWORD PTR [esp+0x8],0x6 ; 100022c4: c7 44 24 08 06 00 00 +; ; 100022cb: 00 +; mov DWORD PTR [esp],edi ; 100022cc: 89 3c 24 +; mov DWORD PTR [esp+0x4],0x1000407e ; 100022cf: c7 44 24 04 7e 40 00 +; ; 100022d6: 10 +; call 1000169f <_memory_patch> ; 100022d7: e8 c3 f3 ff ff +; add esp,0x3c ; 100022dc: 83 c4 3c +; pop ebx ; 100022df: 5b +; pop esi ; 100022e0: 5e +; pop edi ; 100022e1: 5f +; pop ebp ; 100022e2: 5d +; ret ; 100022e3: c3 +; lea esi,[esi+eiz*1+0x0] ; 100022e4: 8d b4 26 00 00 00 00 +; lea esi,[esi+eiz*1+0x0] ; 100022eb: 8d 74 26 00 +; nop ; 100022ef: 90 + +_hack_disable_alarms: ; 100022f0: <_hack_disable_alarms> + sub esp,0x1c ; 100022f0: 83 ec 1c + mov eax, OFFSET_ALARMS ; 100022f3: a1 dc 31 00 10 + mov edx,dword [esp+0x20] ; 100022f8: 8b 54 24 20 + add eax,dword [_g_module_base_addr] ; 100022fc: 03 05 04 30 00 10 + test edx,edx ; 10002302: 85 d2 + mov dword [esp+0x8],0x6 ; 10002304: c7 44 24 08 06 00 00 + ; 1000230b: 00 + je alarms_disabled ; 1000230c: 74 1a +alarms_enabled: + mov dword [esp+0x4],alarm_patch ; 1000230e: c7 44 24 04 00 40 00 + ; 10002315: 10 + mov dword [esp],eax ; 10002316: 89 04 24 + call _memory_patch ; 10002319: e8 81 f3 ff ff + add esp,0x1c ; 1000231e: 83 c4 1c + ret ; 10002321: c3 + lea esi,[esi] ; 10002322: 8d b6 00 00 00 00 + nop + nop + nop + nop +alarms_disabled: + mov dword [esp+0x4],alarm_original ; 10002328: c7 44 24 04 08 40 00 + ; 1000232f: 10 + mov dword [esp],eax ; 10002330: 89 04 24 + call _memory_patch ; 10002333: e8 67 f3 ff ff + add esp,0x1c ; 10002338: 83 c4 1c + ret ; 1000233b: c3 + lea esi,[esi] ; 1000233c: 8d 74 26 00 + nop + nop + nop + nop diff --git a/src/hacks.c b/src/hacks.c index e4c5ef5..d164042 100644 --- a/src/hacks.c +++ b/src/hacks.c @@ -10,47 +10,6 @@ extern uintptr_t g_module_base_addr; -__attribute__((always_inline)) -void hack_god_mode(int bEnabled) -{ - void* const health_addr = (void *)(g_module_base_addr + offsets_health_base); - - if (bEnabled) - { - memory_detour(health_addr, health_detour, sizeof(patch_health_original)); - } - else - { - memory_patch(health_addr, patch_health_original, sizeof(patch_health_original)); - } -} - -__attribute__((always_inline)) -void hack_ghost_mode(int bEnabled) -{ - void* const visibility_addr = (void *)(g_module_base_addr + offsets_invisibility_base); - void* const noise_addr = (void *)(g_module_base_addr + offsets_noise_base); - - // TODO: Add third op for slider - - if (bEnabled) - { - DWORD old_protect = 0; - VirtualProtect(visibility_addr, sizeof(patch_visibility_original), PAGE_EXECUTE_WRITECOPY, &old_protect); - *((uint64_t *)visibility_addr) = 0x05D9909090909090; - VirtualProtect(visibility_addr, sizeof(patch_visibility_original), old_protect, &old_protect); - - /*memory_nop(visibility_addr, sizeof(patch_visibility_original));*/ - memory_patch(noise_addr, patch_noise_patch, sizeof(patch_noise_patch)); - } - else - { - memory_patch(visibility_addr, patch_visibility_original, sizeof(patch_visibility_original)); - memory_patch(noise_addr, patch_noise_original, sizeof(patch_noise_original)); - } - -} - void hack_super_weapons(int bEnabled) { void* const main_ammo_addr = (void *)(g_module_base_addr + offsets_main_ammo_base); @@ -99,20 +58,6 @@ void hack_super_weapons(int bEnabled) } -void hack_disable_alarms(int bEnabled) -{ - void* const alarm_addr = (char *)(g_module_base_addr + offsets_alarm_base); - - if (bEnabled) - { - memory_patch(alarm_addr, patch_alarm_patch, sizeof(patch_alarm_patch)); - } - else - { - memory_patch(alarm_addr, patch_alarm_original, sizeof(patch_alarm_original)); - } -} - unsigned int hack_disable_enemies(int bEnabled) { GameWorld* gameWorld = (GameWorld *)memory_find_dynamic_address(g_module_base_addr + offsets_game_world_base, diff --git a/src/health_detour.asm b/src/health_detour.asm deleted file mode 100644 index 867160d..0000000 --- a/src/health_detour.asm +++ /dev/null @@ -1,17 +0,0 @@ -section .text - -global _health_detour - -_health_detour: - cmp dword [edi], 0x110E8B50 - je $ + 0x08 - xor eax, eax - mov eax, eax - mov dword [ebx], eax - mov ebx, eax - mov eax, dword [esp + 0x14] - pop esi - mov dword [eax], ebx - pop ebx - pop ecx - ret 0x8