From 8878022696c6e7499030d31025842d9d48969bd8 Mon Sep 17 00:00:00 2001 From: 0xvpr Date: Sun, 11 Feb 2024 05:49:59 -0500 Subject: [PATCH] events converted to asm with bugs --- src/events.asm | 291 +++++++++++++++++++++++++++++++++++++++++ src/events.asm.bak | 242 ---------------------------------- src/events.c | 128 ------------------ src/hook_end_scene.asm | 24 ---- src/main_thread.asm | 51 ++++++-- 5 files changed, 331 insertions(+), 405 deletions(-) create mode 100644 src/events.asm delete mode 100644 src/events.asm.bak delete mode 100644 src/events.c delete mode 100644 src/hook_end_scene.asm diff --git a/src/events.asm b/src/events.asm new file mode 100644 index 0000000..d839659 --- /dev/null +++ b/src/events.asm @@ -0,0 +1,291 @@ +; --------------------------------------------------------------------------- ; +; Exported Functions ; +; --------------------------------------------------------------------------- ; + +global _events_handle_keyboard + +; --------------------------------------------------------------------------- ; +; External Variables ; +; --------------------------------------------------------------------------- ; + +extern _g_hack_menu +extern _g_maximized +extern _g_resolution +extern _g_coordinates + +; --------------------------------------------------------------------------- ; +; External Functions ; +; --------------------------------------------------------------------------- ; + +extern _GetAsyncKeyState@4 + +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 + +; --------------------------------------------------------------------------- ; +; Executable Code ; +; --------------------------------------------------------------------------- ; + +section .text +_events_handle_keyboard: ; 10001d60: <_events_handle_keyboard> + push ebx ; 10001d60: 53 + sub esp,0x18 ; 10001d61: 83 ec 18 + mov dword [esp],0x61 ; 10001d64: c7 04 24 61 00 00 00 + mov ebx, _GetAsyncKeyState@4 ; 10001d6b: 8b 1d e8 70 00 10 + call ebx ; 10001d71: ff d3 + sub esp,0x4 ; 10001d73: 83 ec 04 + test al,0x1 ; 10001d76: a8 01 + jne numpad_1 ; 10001d78: 0f 85 ca 00 00 00 + mov dword [esp],0x62 ; 10001d7e: c7 04 24 62 00 00 00 + call ebx ; 10001d85: ff d3 + sub esp,0x4 ; 10001d87: 83 ec 04 + test al,0x1 ; 10001d8a: a8 01 + jne numpad_2 ; 10001d8c: 0f 85 e4 00 00 00 +numpad_3_check: + mov dword [esp],0x63 ; 10001d92: c7 04 24 63 00 00 00 + call ebx ; 10001d99: ff d3 + sub esp,0x4 ; 10001d9b: 83 ec 04 + test al,0x1 ; 10001d9e: a8 01 + jne numpad_3 ; 10001da0: 0f 85 fe 00 00 00 +numpad_4_check: + mov dword [esp],0x64 ; 10001da6: c7 04 24 64 00 00 00 + call ebx ; 10001dad: ff d3 + sub esp,0x4 ; 10001daf: 83 ec 04 + test al,0x1 ; 10001db2: a8 01 + jne numpad_4 ; 10001db4: 0f 85 18 01 00 00 +numpad_5_check: + mov dword [esp],0x65 ; 10001dba: c7 04 24 65 00 00 00 + call ebx ; 10001dc1: ff d3 + sub esp,0x4 ; 10001dc3: 83 ec 04 + test al,0x1 ; 10001dc6: a8 01 + jne numpad_5 ; 10001dc8: 0f 85 32 01 00 00 +numpad_6_check: + mov dword [esp],0x66 ; 10001dce: c7 04 24 66 00 00 00 + call ebx ; 10001dd5: ff d3 + sub esp,0x4 ; 10001dd7: 83 ec 04 + test al,0x1 ; 10001dda: a8 01 + jne numpad_6 ; 10001ddc: 0f 85 4c 01 00 00 +numpad_7_check: + mov dword [esp],0x67 ; 10001de2: c7 04 24 67 00 00 00 + call ebx ; 10001de9: ff d3 + sub esp,0x4 ; 10001deb: 83 ec 04 + test al,0x1 ; 10001dee: a8 01 + jne numpad_7 ; 10001df0: 0f 85 51 01 00 00 +menu_max_q: + mov ecx, dword [_g_maximized] ; 10001df6: 8b 0d 10 30 00 10 + test ecx,ecx ; 10001dfc: 85 c9 + jne menu_minimized ; 10001dfe: 0f 85 56 01 00 00 +menu_maximized: + mov dword [esp],0x71 ; 10001e04: c7 04 24 71 00 00 00 + call ebx ; 10001e0b: ff d3 + sub esp,0x4 ; 10001e0d: 83 ec 04 + test al,0x1 ; 10001e10: a8 01 + je home_key ; 10001e12: 74 12 + mov edx,dword [_g_maximized] ; 10001e14: 8b 15 10 30 00 10 + xor eax,eax ; 10001e1a: 31 c0 + test edx,edx ; 10001e1c: 85 d2 + sete al ; 10001e1e: 0f 94 c0 + mov dword [_g_maximized],eax ; 10001e21: a3 10 30 00 10 +home_key: + mov dword [esp],0x24 ; 10001e26: c7 04 24 24 00 00 00 + call ebx ; 10001e2d: ff d3 + mov ebx,eax ; 10001e2f: 89 c3 + sub esp,0x4 ; 10001e31: 83 ec 04 + xor eax,eax ; 10001e34: 31 c0 + test bx,bx ; 10001e36: 66 85 db + jne unload ; 10001e39: 0f 85 a1 01 00 00 + add esp,0x18 ; 10001e3f: 83 c4 18 + pop ebx ; 10001e42: 5b + ret ; 10001e43: c3 + lea esi,[esi+0x0] ; 10001e44: 8d 74 26 00 + nop + nop + nop + nop +numpad_1: + mov edx, dword [_g_hack_menu+0x44*0] ; 10001e48: 8b 15 14 30 00 10 + xor eax,eax ; 10001e4e: 31 c0 + test edx,edx ; 10001e50: 85 d2 + sete al ; 10001e52: 0f 94 c0 + mov dword [esp],eax ; 10001e55: 89 04 24 + mov [_g_hack_menu+0x44*0],eax ; 10001e58: a3 14 30 00 10 + call _hack_god_mode ; 10001e5d: e8 b6 f5 ff ff + mov dword [esp],0x62 ; 10001e62: c7 04 24 62 00 00 00 + call ebx ; 10001e69: ff d3 + sub esp,0x4 ; 10001e6b: 83 ec 04 + test al,0x1 ; 10001e6e: a8 01 + je numpad_3_check ; 10001e70: 0f 84 1c ff ff ff +numpad_2: + mov ecx, dword [_g_hack_menu+0x44*1] ; 10001e76: 8b 0d 58 30 00 10 + xor eax,eax ; 10001e7c: 31 c0 + test ecx,ecx ; 10001e7e: 85 c9 + sete al ; 10001e80: 0f 94 c0 + mov dword [esp],eax ; 10001e83: 89 04 24 + mov [_g_hack_menu+0x44*1],eax ; 10001e86: a3 58 30 00 10 + call _hack_ghost_mode ; 10001e8b: e8 d4 f5 ff ff + mov dword [esp],0x63 ; 10001e90: c7 04 24 63 00 00 00 + call ebx ; 10001e97: ff d3 + sub esp,0x4 ; 10001e99: 83 ec 04 + test al,0x1 ; 10001e9c: a8 01 + je numpad_4_check ; 10001e9e: 0f 84 02 ff ff ff +numpad_3: + mov edx, dword [_g_hack_menu+0x44*2] ; 10001ea4: 8b 15 9c 30 00 10 + xor eax,eax ; 10001eaa: 31 c0 + test edx,edx ; 10001eac: 85 d2 + sete al ; 10001eae: 0f 94 c0 + mov dword [esp],eax ; 10001eb1: 89 04 24 + mov [_g_hack_menu+0x44*2],eax ; 10001eb4: a3 9c 30 00 10 + call _hack_super_weapons ; 10001eb9: e8 12 02 00 00 + mov dword [esp],0x64 ; 10001ebe: c7 04 24 64 00 00 00 + call ebx ; 10001ec5: ff d3 + sub esp,0x4 ; 10001ec7: 83 ec 04 + test al,0x1 ; 10001eca: a8 01 + je numpad_5_check ; 10001ecc: 0f 84 e8 fe ff ff +numpad_4: + mov ecx, dword [_g_hack_menu+0x44*3] ; 10001ed2: 8b 0d e0 30 00 10 + xor eax,eax ; 10001ed8: 31 c0 + test ecx,ecx ; 10001eda: 85 c9 + sete al ; 10001edc: 0f 94 c0 + mov dword [esp],eax ; 10001edf: 89 04 24 + mov [_g_hack_menu+0x44*3],eax ; 10001ee2: a3 e0 30 00 10 + call _hack_disable_alarms ; 10001ee7: e8 54 f6 ff ff + mov dword [esp],0x65 ; 10001eec: c7 04 24 65 00 00 00 + call ebx ; 10001ef3: ff d3 + sub esp,0x4 ; 10001ef5: 83 ec 04 + test al,0x1 ; 10001ef8: a8 01 + je numpad_6_check ; 10001efa: 0f 84 ce fe ff ff +numpad_5: + mov edx, dword [_g_hack_menu+0x44*4] ; 10001f00: 8b 15 24 31 00 10 + xor eax,eax ; 10001f06: 31 c0 + test edx,edx ; 10001f08: 85 d2 + sete al ; 10001f0a: 0f 94 c0 + mov dword [esp],eax ; 10001f0d: 89 04 24 + mov [_g_hack_menu+0x44*4],eax ; 10001f10: a3 24 31 00 10 + call _hack_disable_enemies ; 10001f15: e8 46 04 00 00 + mov dword [esp],0x66 ; 10001f1a: c7 04 24 66 00 00 00 + call ebx ; 10001f21: ff d3 + sub esp,0x4 ; 10001f23: 83 ec 04 + test al,0x1 ; 10001f26: a8 01 + je numpad_7_check ; 10001f28: 0f 84 b4 fe ff ff +numpad_6: + call _hack_unlock_all_doors ; 10001f2e: e8 bd 09 00 00 + mov dword [esp],0x67 ; 10001f33: c7 04 24 67 00 00 00 + call ebx ; 10001f3a: ff d3 + sub esp,0x4 ; 10001f3c: 83 ec 04 + test al,0x1 ; 10001f3f: a8 01 + je menu_max_q ; 10001f41: 0f 84 af fe ff ff +numpad_7: + call _hack_test ; 10001f47: e8 f4 0c 00 00 + mov ecx, dword [_g_maximized] ; 10001f4c: 8b 0d 10 30 00 10 + test ecx,ecx ; 10001f52: 85 c9 + je menu_maximized ; 10001f54: 0f 84 aa fe ff ff +menu_minimized: + mov dword [esp],0x25 ; 10001f5a: c7 04 24 25 00 00 00 + call ebx ; 10001f61: ff d3 + sub esp,0x4 ; 10001f63: 83 ec 04 + test al,0x1 ; 10001f66: a8 01 + jne arrow_left ; 10001f68: 0f 85 42 01 00 00 +arrow_right_check: + mov dword [esp],0x27 ; 10001f6e: c7 04 24 27 00 00 00 + call ebx ; 10001f75: ff d3 + sub esp,0x4 ; 10001f77: 83 ec 04 + test al,0x1 ; 10001f7a: a8 01 + jne arrow_right ; 10001f7c: 0f 85 fe 00 00 00 +arrow_up_check: + mov dword [esp],0x26 ; 10001f82: c7 04 24 26 00 00 00 + call ebx ; 10001f89: ff d3 + sub esp,0x4 ; 10001f8b: 83 ec 04 + test al,0x1 ; 10001f8e: a8 01 + jne arrow_up ; 10001f90: 0f 85 ca 00 00 00 +arrow_down_check: + mov dword [esp],0x28 ; 10001f96: c7 04 24 28 00 00 00 + call ebx ; 10001f9d: ff d3 + sub esp,0x4 ; 10001f9f: 83 ec 04 + test al,0x1 ; 10001fa2: a8 01 + jne coordinate_check_y ; 10001fa4: 0f 85 86 00 00 00 +f3_check: + mov ecx,dword [_g_maximized] ; 10001faa: 8b 0d 10 30 00 10 + test ecx,ecx ; 10001fb0: 85 c9 + je menu_maximized ; 10001fb2: 0f 84 4c fe ff ff + mov dword [esp],0x72 ; 10001fb8: c7 04 24 72 00 00 00 + call ebx ; 10001fbf: ff d3 + sub esp,0x4 ; 10001fc1: 83 ec 04 + test al,0x1 ; 10001fc4: a8 01 + je menu_maximized ; 10001fc6: 0f 84 38 fe ff ff + mov dword [_g_coordinates],0x19001e ; 10001fcc: c7 05 ac 31 00 10 1e + ; 10001fd3: 00 19 00 + jmp menu_maximized ; 10001fd6: e9 29 fe ff ff + lea esi,[esi+0x0] ; 10001fdb: 8d 74 26 00 + nop ; 10001fdf: 90 + nop ; 10001fdf: 90 + nop ; 10001fdf: 90 + nop ; 10001fdf: 90 + nop ; 10001fdf: 90 +unload: + mov dword [esp],0x0 ; 10001fe0: c7 04 24 00 00 00 00 + call _hack_god_mode ; 10001fe7: e8 2c f4 ff ff + mov dword [esp],0x0 ; 10001fec: c7 04 24 00 00 00 00 + call _hack_ghost_mode ; 10001ff3: e8 6c f4 ff ff + mov dword [esp],0x0 ; 10001ff8: c7 04 24 00 00 00 00 + call _hack_super_weapons ; 10001fff: e8 cc 00 00 00 + mov dword [esp],0x0 ; 10002004: c7 04 24 00 00 00 00 + call _hack_disable_alarms ; 1000200b: e8 30 f5 ff ff + mov dword [esp],0x0 ; 10002010: c7 04 24 00 00 00 00 + call _hack_disable_enemies ; 10002017: e8 44 03 00 00 + add esp,0x18 ; 1000201c: 83 c4 18 + mov eax,0x1 ; 1000201f: b8 01 00 00 00 + pop ebx ; 10002024: 5b + ret ; 10002025: c3 + lea esi,[esi+0x0] ; 10002026: 8d b4 26 00 00 00 00 + nop + nop + nop + nop + lea esi,[esi+0x0] ; 1000202d: 8d 76 00 +coordinate_check_y: + movzx eax, word [_g_resolution+0x2] ; 10002030: 0f b7 05 0e 30 00 10 + movzx ecx, word [_g_coordinates+0x2] ; 10002037: 0f b7 0d ae 31 00 10 + sub eax,0x78 ; 1000203e: 83 e8 78 + mov edx,ecx ; 10002041: 89 ca + cmp ecx,eax ; 10002043: 39 c1 + jge f3_check ; 10002045: 0f 8d 5f ff ff ff + add edx,0x5 ; 1000204b: 83 c2 05 + mov word [_g_coordinates+0x2],dx ; 1000204e: 66 89 15 ae 31 00 10 + jmp f3_check ; 10002055: e9 50 ff ff ff + lea esi,[esi+0x0] ; 1000205a: 8d b6 00 00 00 00 +arrow_up: + movzx ecx,word [_g_coordinates+0x2] ; 10002060: 0f b7 0d ae 31 00 10 + cmp cx,0x1e ; 10002067: 66 83 f9 1e + jbe arrow_down_check ; 1000206b: 0f 86 25 ff ff ff + sub ecx,0x5 ; 10002071: 83 e9 05 + mov word [_g_coordinates+0x2],cx ; 10002074: 66 89 0d ae 31 00 10 + jmp arrow_down_check ; 1000207b: e9 16 ff ff ff +arrow_right: + movzx eax,word [_g_resolution] ; 10002080: 0f b7 05 0c 30 00 10 + movzx ecx,word [_g_coordinates] ; 10002087: 0f b7 0d ac 31 00 10 + sub eax,0xaf ; 1000208e: 2d af 00 00 00 + mov edx,ecx ; 10002093: 89 ca + cmp ecx,eax ; 10002095: 39 c1 + jge arrow_up_check ; 10002097: 0f 8d e5 fe ff ff + add edx,0x5 ; 1000209d: 83 c2 05 + mov word [_g_coordinates],dx ; 100020a0: 66 89 15 ac 31 00 10 + jmp arrow_up_check ; 100020a7: e9 d6 fe ff ff + lea esi,[esi+0x0] ; 100020ac: 8d 74 26 00 + nop + nop + nop + nop +arrow_left: + movzx eax,word [_g_coordinates] ; 100020b0: 0f b7 05 ac 31 00 10 + cmp ax,0x23 ; 100020b7: 66 83 f8 23 + jbe arrow_right_check ; 100020bb: 0f 86 ad fe ff ff + sub eax,0x5 ; 100020c1: 83 e8 05 + mov word [_g_coordinates],ax ; 100020c4: 66 a3 ac 31 00 10 + jmp arrow_right_check ; 100020ca: e9 9f fe ff ff + nop ; 100020cf: 90 diff --git a/src/events.asm.bak b/src/events.asm.bak deleted file mode 100644 index dddca47..0000000 --- a/src/events.asm.bak +++ /dev/null @@ -1,242 +0,0 @@ -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 deleted file mode 100644 index 6f8029e..0000000 --- a/src/events.c +++ /dev/null @@ -1,128 +0,0 @@ -#include "events.h" - -#include "hacks.h" -#include "render.h" - -#include - -extern uintptr_t module_base_addr; - -extern int g_maximized; - -extern Resolution g_resolution; -extern Coordinates g_coordinates; -extern HackMenu g_hack_menu[MAX_MENU_ITEMS]; - -int events_handle_keyboard(void) -{ - /*[> 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 <]*/ - 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 <]*/ - 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 <]*/ - 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 <]*/ - if (GetAsyncKeyState(VK_NUMPAD5) & 1) - { - g_hack_menu[DISABLE_ENEMIES].bEnabled = !g_hack_menu[DISABLE_ENEMIES].bEnabled; - /*[>n_entities_changed = <]*/ - hack_disable_enemies(g_hack_menu[DISABLE_ENEMIES].bEnabled); - } - - /*[> 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 = <]*/ - hack_unlock_all_doors(); - } - - /*[> Unlock All Doors <]*/ - if (GetAsyncKeyState(VK_NUMPAD7) & 1) - { - hack_test(); - } - - // Control Menu Position - if (g_maximized) // When maximized - { - if ((GetAsyncKeyState(VK_LEFT) & 1) > 0) - { - if (g_coordinates.x > 35) - { - g_coordinates.x -= 5; - } - } - - if ((GetAsyncKeyState(VK_RIGHT) & 1) > 0) - { - if (g_coordinates.x < g_resolution.x - 175) - { - g_coordinates.x += 5; - } - } - - if ((GetAsyncKeyState(VK_UP) & 1) > 0) - { - if (g_coordinates.y > 30) - { - g_coordinates.y -= 5; - } - } - - if ((GetAsyncKeyState(VK_DOWN) & 1) > 0) - { - if (g_coordinates.y < g_resolution.y - 120) - { - g_coordinates.y += 5; - } - } - - } - - if (g_maximized && (GetAsyncKeyState(VK_F3) & 1) > 0) - { - g_coordinates.x = 30; - g_coordinates.y = 25; - } - - if (GetAsyncKeyState(VK_F2) & 1) - { - g_maximized = !g_maximized; - } - - if (GetAsyncKeyState(VK_HOME)) - { - hack_god_mode(0); - hack_ghost_mode(0); - hack_super_weapons(0); - hack_disable_alarms(0); - hack_disable_enemies(0); - - return 1; - } - - return 0; -} diff --git a/src/hook_end_scene.asm b/src/hook_end_scene.asm deleted file mode 100644 index 2eb8a92..0000000 --- a/src/hook_end_scene.asm +++ /dev/null @@ -1,24 +0,0 @@ -extern _oEndScene -extern _render_menu@4 - -section .text -global _hook_end_scene - -_hook_end_scene: - push dword [ esp + 0x4 ] - call _render_menu@4 - jmp [_oEndScene] - ;push ebx - ;sub esp,0x18 - ;mov ebx, dword [esp+0x20] - ;mov dword [esp],ebx - ;call _render_menu@4 - ;sub esp,0x4 - ;mov dword [esp+0x20],ebx - ;add esp,0x18 - ;pop ebx - ;jmp dword [_oEndScene] - ;xchg esi,esi - ;xchg esi,esi - ;nop - ;nop diff --git a/src/main_thread.asm b/src/main_thread.asm index 6f769df..4cb4761 100644 --- a/src/main_thread.asm +++ b/src/main_thread.asm @@ -1,23 +1,52 @@ -section .data -global _oEndScene +; --------------------------------------------------------------------------- ; +; Exported Functions ; +; --------------------------------------------------------------------------- ; + +global _MainThread@4 + +; --------------------------------------------------------------------------- ; +; Exported Variables ; +; --------------------------------------------------------------------------- ; + global _g_module_base_addr -_g_module_base_addr: - dd 0 -_oEndScene: - dd 0 +; --------------------------------------------------------------------------- ; +; Imported Functions ; +; --------------------------------------------------------------------------- ; + +extern _GetD3D9Device@8 -section .text -extern _FreeLibraryAndExitThread@8 extern _VirtualFree@12 extern _GetModuleHandleA@4 -extern _GetD3D9Device@8 +extern _FreeLibraryAndExitThread@8 + extern _events_handle_keyboard + extern _memory_tramp_hook extern _memory_patch -extern _hook_end_scene -global _MainThread@4 +extern _render_menu@4 + +; --------------------------------------------------------------------------- ; +; Variables ; +; --------------------------------------------------------------------------- ; + +section .data +_g_module_base_addr: + dd 0 +_oEndScene: + dd 0 + +; --------------------------------------------------------------------------- ; +; Executable Code ; +; --------------------------------------------------------------------------- ; + +section .text +_hook_end_scene: + push dword [ esp + 0x4 ] + call _render_menu@4 + jmp [_oEndScene] + _MainThread@4: ; 10002480: <_MainThread@4>: push edi ; 10002480: 57 push esi ; 10002481: 56