This commit is contained in:
Akash Mozumdar 2018-08-23 12:18:03 -04:00
parent 446ff71464
commit 389db72dd2
5 changed files with 15 additions and 15 deletions

View File

@ -124,13 +124,13 @@ namespace Host
return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr);
} }
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr) DLLEXPORT bool RemoveHook(DWORD pid, unsigned __int64 addr)
{ {
auto info = RemoveHookCmd(addr); auto info = RemoveHookCmd(addr);
return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr);
} }
DLLEXPORT HookParam GetHookParam(DWORD pid, DWORD addr) DLLEXPORT HookParam GetHookParam(DWORD pid, unsigned __int64 addr)
{ {
HOST_LOCK; HOST_LOCK;
HookParam ret = {}; HookParam ret = {};
@ -139,14 +139,14 @@ namespace Host
MutexLocker locker(pr.sectionMutex); MutexLocker locker(pr.sectionMutex);
const TextHook* hooks = (const TextHook*)pr.sectionMap; const TextHook* hooks = (const TextHook*)pr.sectionMap;
for (int i = 0; i < MAX_HOOK; ++i) for (int i = 0; i < MAX_HOOK; ++i)
if ((DWORD)hooks[i].Address() == addr) if (hooks[i].Address() == addr)
ret = hooks[i].hp; ret = hooks[i].hp;
return ret; return ret;
} }
DLLEXPORT HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); } DLLEXPORT HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); }
DLLEXPORT std::wstring GetHookName(DWORD pid, DWORD addr) DLLEXPORT std::wstring GetHookName(DWORD pid, unsigned __int64 addr)
{ {
if (pid == 0) return L"Console"; if (pid == 0) return L"Console";
HOST_LOCK; HOST_LOCK;
@ -156,7 +156,7 @@ namespace Host
MutexLocker locker(pr.sectionMutex); MutexLocker locker(pr.sectionMutex);
const TextHook* hooks = (const TextHook*)pr.sectionMap; const TextHook* hooks = (const TextHook*)pr.sectionMap;
for (int i = 0; i < MAX_HOOK; ++i) for (int i = 0; i < MAX_HOOK; ++i)
if ((DWORD)hooks[i].Address() == addr) if (hooks[i].Address() == addr)
{ {
buffer.resize(hooks[i].NameLength()); buffer.resize(hooks[i].NameLength());
ReadProcessMemory(pr.processHandle, hooks[i].Name(), &buffer[0], hooks[i].NameLength(), nullptr); ReadProcessMemory(pr.processHandle, hooks[i].Name(), &buffer[0], hooks[i].NameLength(), nullptr);

View File

@ -20,10 +20,10 @@ namespace Host
DLLEXPORT bool DetachProcess(DWORD pid); DLLEXPORT bool DetachProcess(DWORD pid);
DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = ""); DLLEXPORT bool InsertHook(DWORD pid, HookParam hp, std::string name = "");
DLLEXPORT bool RemoveHook(DWORD pid, DWORD addr); DLLEXPORT bool RemoveHook(DWORD pid, unsigned __int64 addr);
DLLEXPORT HookParam GetHookParam(DWORD pid, DWORD addr); DLLEXPORT HookParam GetHookParam(DWORD pid, unsigned __int64 addr);
DLLEXPORT HookParam GetHookParam(ThreadParam tp); DLLEXPORT HookParam GetHookParam(ThreadParam tp);
DLLEXPORT std::wstring GetHookName(DWORD pid, DWORD addr); DLLEXPORT std::wstring GetHookName(DWORD pid, unsigned __int64 addr);
DLLEXPORT TextThread* GetThread(ThreadParam tp); DLLEXPORT TextThread* GetThread(ThreadParam tp);
DLLEXPORT void AddConsoleOutput(std::wstring text); DLLEXPORT void AddConsoleOutput(std::wstring text);

View File

@ -109,7 +109,7 @@ DWORD NewHook(const HookParam &hp, LPCSTR lpname, DWORD flag)
} }
return 0; return 0;
} }
DWORD RemoveHook(DWORD addr) DWORD RemoveHook(unsigned __int64 addr)
{ {
for (int i = 0; i < MAX_HOOK; i++) for (int i = 0; i < MAX_HOOK; i++)
if (::hookman[i].Address() == addr) { if (::hookman[i].Address() == addr) {

View File

@ -9,11 +9,10 @@
void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text
void NotifyHookInsert(HookParam hp, LPCSTR name); void NotifyHookInsert(HookParam hp, LPCSTR name);
void NotifyHookRemove(DWORD addr); void NotifyHookRemove(unsigned __int64 addr);
DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE); DWORD NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
DWORD RemoveHook(DWORD addr); DWORD RemoveHook(unsigned __int64 addr);
DWORD SwitchTrigger(DWORD on); DWORD SwitchTrigger(DWORD on);
DWORD GetFunctionAddr(const char *name, DWORD *addr, DWORD *base, DWORD *size, LPWSTR *base_name);
// 10/14/2014 jichi: disable GDI hooks // 10/14/2014 jichi: disable GDI hooks
void EnableGDIHooks(); void EnableGDIHooks();

View File

@ -21,7 +21,7 @@ DWORD DUMMY[100];
void CreatePipe() void CreatePipe()
{ {
std::thread([]() CreateThread(nullptr, 0, [](LPVOID unused)
{ {
enum { STANDARD_WAIT = 50 }; enum { STANDARD_WAIT = 50 };
while (::running) while (::running)
@ -86,7 +86,8 @@ void CreatePipe()
CloseHandle(hostPipe); CloseHandle(hostPipe);
} }
FreeLibraryAndExitThread(GetModuleHandleW(ITH_DLL), 0); FreeLibraryAndExitThread(GetModuleHandleW(ITH_DLL), 0);
}).detach(); return (DWORD)0;
}, nullptr, 0, nullptr);
} }
void ConsoleOutput(LPCSTR text) void ConsoleOutput(LPCSTR text)
@ -107,7 +108,7 @@ void NotifyHookInsert(HookParam hp, LPCSTR name)
//return; //return;
} }
void NotifyHookRemove(DWORD addr) void NotifyHookRemove(unsigned __int64 addr)
{ {
auto info = HookRemovedNotif(addr); auto info = HookRemovedNotif(addr);
WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr); WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr);