From e2464653c7a4ca4a5fa555334be4664826731458 Mon Sep 17 00:00:00 2001 From: Daniel Seiller Date: Wed, 20 Nov 2019 20:51:38 +0100 Subject: [PATCH] remove hook wrappers and directly call Hook::addr() at the start of MainLoop(), add console redirection --- ScrapHacks/ScrapHack/ScrapHack.cpp | 36 +++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/ScrapHacks/ScrapHack/ScrapHack.cpp b/ScrapHacks/ScrapHack/ScrapHack.cpp index 986bd15..5c7237d 100644 --- a/ScrapHacks/ScrapHack/ScrapHack.cpp +++ b/ScrapHacks/ScrapHack/ScrapHack.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -18,15 +17,18 @@ using namespace std; #include "Hook.h" #include "VMT_Hook.h" #include "D3D8_Hook.h" - +#include "REPL.h" +bool do_sleep=true; HMODULE hD3D8Dll = 0; bool initialized = false; bool running = true; +bool redirect_console = false; HMODULE mod = 0; void DllUnload(HMODULE); -void hook_exit(); +int hooked_console(const char *); +void H_Exit(); size_t size_ht(HashTable *ht) { @@ -119,9 +121,13 @@ size_t dump_ht(HashTable *ht) void MainLoop(HMODULE mod) { Sleep(100); - hook_exit(); + Hook::addr(reinterpret_cast(P_SCRAP_EXIT), H_Exit); + Hook::addr(reinterpret_cast(P_D3DCHECK),hook_d3d8); + Hook::addr(reinterpret_cast(P_CON_HANDLER), hooked_console); + overlay=true; cout << "[*] Starting main Loop" << endl; cout << endl; + cout << "[F2 ] Redirect game console to ScapHacks console" << endl; cout << "[F3 ] Unload ScrapHacks" << endl; cout << "[F5 ] Show Overlay" << endl; cout << "[F6 ] Show Alarm status" << endl; @@ -134,11 +140,14 @@ void MainLoop(HMODULE mod) while (running) { Sleep(100); - while (key_down('F')) { scrap_exec("dbg.brake()"); } + if (key_down_norepeat(VK_F2)) + { + redirect_console = !redirect_console; + } if (key_down_norepeat(VK_F3)) { break; @@ -148,6 +157,7 @@ void MainLoop(HMODULE mod) { overlay = !overlay; } + if (key_down_norepeat(VK_F6)) { @@ -193,33 +203,19 @@ void InitConsole() SetupConsole(me); } -void handle_command(const char *cmd) -{ - cout << "CMD: " << cmd << endl; - scrap_log(0x00ff00, "HAXX: "); - scrap_log(0x00ff00, cmd); - scrap_log(0x00ff00, "\n"); - return; -} - int hooked_console(const char *cmd) { typedef int(_cdecl * t_func)(const char *); - shared_ptr hook = Hook::get(hooked_console); if (cmd[0] == '$') { handle_command(++cmd); return 0; } + shared_ptr hook = Hook::get(hooked_console); int ret = hook->func(cmd); return ret; } -void hook_console() -{ - Hook::addr(reinterpret_cast(P_CON_HANDLER), hooked_console); -} - void H_Exit() { typedef void(_cdecl * t_func)(void);