From 62b5f5fe8f788629c95cbd2375a0d9845decb4c1 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 20 Jul 2018 17:18:27 -0400 Subject: [PATCH] start implementing hostinterop --- GUI/HostInterop/HostInterop.h | Bin 468 -> 2098 bytes oldgui/command.cpp | 2 +- oldgui/main.cpp | 2 +- oldgui/window.cpp | 2 +- texthook/host.cc | 8 ++++---- texthook/host.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/GUI/HostInterop/HostInterop.h b/GUI/HostInterop/HostInterop.h index ce127d23ed0c4e692501128e708d8b5f0d5e1df5..617c60f162c2ba46a86fc6549acbfabf96fa4dfa 100644 GIT binary patch literal 2098 zcmb`I%}?7v5XI-}O8p;JvJpK>Kv4vg`Cx^jv@WgBh*9JqpR@ju|klbd(m=bA;B6-vx*rol7 zUISK+VkYux+xfZ1KVene3*Hye<2GJ1-d1*P6XNxVrkuWU7pH=i9`|655@2v$uZfG+ zmQjTX*M5!Y$eG;`ZHztG7vc=yuy1d9yG<;Pt(7C}cQr~zB-L+%?UG12e9FXMOiLIR zpr$)E<27tPf-2ny30`B{1wnd_iLbrtu~Ya-{~?$KsO|OuU-?zOu0(3<#MP=&%IiJ< zPcc(x)sDPPJ#qaGhU#?=yE#wlr=@+Mk4~u1z8%|FYIMOpP$|{S**(;`Yh64Z$8(HL z6+MnQsfR`{!f6-0$2ci3^@RG&Rc=$}5RH8OJocp~G?2-{w5HkVqf<9N6|th}ByU%C zok7K0$coUZ`{9hpCD=DGR`q>)s`DVTbbc<_Go|j@>&!Q0mUet=&(c^*Ph2mvNd@cg>YgPR@jP?@tod!t;JOsRyW<`nh^fXLyCS`s!RIUxt+5 lE*#r1UXGzF(Ddw6`K=@P>GW?mK1avq%esxJSE%}4`~|!bO)vle delta 22 acmdlaaD{opF-E>x25Sah1}=tLFbM!jg#>~C diff --git a/oldgui/command.cpp b/oldgui/command.cpp index 3b791f8..4fad94a 100644 --- a/oldgui/command.cpp +++ b/oldgui/command.cpp @@ -41,7 +41,7 @@ DWORD ProcessCommand(const std::wstring& cmd, DWORD pid) { HookParam hp = {}; if (Parse(m[1].str(), hp)) - InsertHook(pid, &hp); + InsertHook(pid, hp); } else if (regex_match(cmd, m, wregex(L":(?:h|help)", wregex::icase))) { diff --git a/oldgui/main.cpp b/oldgui/main.cpp index a884736..bc72605 100644 --- a/oldgui/main.cpp +++ b/oldgui/main.cpp @@ -149,7 +149,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if (StartHost()) { SetUnhandledExceptionFilter(UnhandledExcept); - GetHostHookManager(&man); + man = GetHostHookManager(); pfman = new ProfileManager(); DefaultSettings(); LoadSettings(); diff --git a/oldgui/window.cpp b/oldgui/window.cpp index 81d9a5e..ba0abc1 100644 --- a/oldgui/window.cpp +++ b/oldgui/window.cpp @@ -488,7 +488,7 @@ void RegisterProcess(DWORD pid) { for (auto i = pf->Hooks().begin(); i != pf->Hooks().end(); ++i) { - InsertHook(pid, &i->get()->HP(), toMultiByteString(i->get()->Name())); + InsertHook(pid, i->get()->HP(), toMultiByteString(i->get()->Name())); } } } diff --git a/texthook/host.cc b/texthook/host.cc index 5e5393b..7391c47 100644 --- a/texthook/host.cc +++ b/texthook/host.cc @@ -117,19 +117,19 @@ DLLEXPORT bool DetachProcessById(DWORD processId) return WriteFile(man->GetHostPipe(processId), &command, sizeof(command), &unused, nullptr); } -DLLEXPORT void GetHostHookManager(HookManager** hookman) +DLLEXPORT HookManager* GetHostHookManager() { - *hookman = man; + return man; } -DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name) +DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name) { HANDLE commandPipe = man->GetHostPipe(pid); if (commandPipe == nullptr) return false; BYTE buffer[PIPE_BUFFER_SIZE] = {}; *(DWORD*)buffer = HOST_COMMAND_NEW_HOOK; - *(HookParam*)(buffer + sizeof(DWORD)) = *hp; + *(HookParam*)(buffer + sizeof(DWORD)) = hp; if (name.size()) strcpy((char*)buffer + sizeof(DWORD) + sizeof(HookParam), name.c_str()); DWORD unused; return WriteFile(commandPipe, buffer, sizeof(DWORD) + sizeof(HookParam) + name.size(), &unused, nullptr); diff --git a/texthook/host.h b/texthook/host.h index 3919943..876d0b2 100644 --- a/texthook/host.h +++ b/texthook/host.h @@ -12,10 +12,10 @@ DLLEXPORT void OpenHost(); DLLEXPORT bool StartHost(); DLLEXPORT void CloseHost(); -DLLEXPORT void GetHostHookManager(HookManager **hookman); +DLLEXPORT HookManager* GetHostHookManager(); DLLEXPORT bool InjectProcessById(DWORD pid, DWORD timeout = 5000); DLLEXPORT bool DetachProcessById(DWORD pid); -DLLEXPORT bool InsertHook(DWORD pid, const HookParam *hp, std::string name = ""); +DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = ""); DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr); // EOF