diff --git a/host/host.cc b/host/host.cc index 27e3536..20958c6 100644 --- a/host/host.cc +++ b/host/host.cc @@ -6,6 +6,7 @@ #include "const.h" #include "defs.h" #include "../vnrhook/hijack/texthook.h" +#include // A2W namespace { @@ -21,7 +22,6 @@ namespace ThreadEventCallback OnCreate, OnRemove; ProcessEventCallback OnAttach, OnDetach; - bool operator==(const ThreadParam& one, const ThreadParam& two) { return one.pid == two.pid && one.hook == two.hook && one.retn == two.retn && one.spl == two.spl; } std::unordered_map textThreadsByParams; std::unordered_map processRecordsByIds; @@ -201,22 +201,22 @@ namespace Host return false; } - bool DetachProcess(DWORD processId) + void DetachProcess(DWORD processId) { int command = HOST_COMMAND_DETACH; - return WriteFile(processRecordsByIds[processId].hostPipe, &command, sizeof(command), DUMMY, nullptr); + WriteFile(processRecordsByIds[processId].hostPipe, &command, sizeof(command), DUMMY, nullptr); } - bool InsertHook(DWORD pid, HookParam hp, std::string name) + void InsertHook(DWORD pid, HookParam hp, std::string name) { auto info = InsertHookCmd(hp, name); - return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); + WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); } - bool RemoveHook(DWORD pid, unsigned __int64 addr) + void RemoveHook(DWORD pid, unsigned __int64 addr) { auto info = RemoveHookCmd(addr); - return WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); + WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr); } HookParam GetHookParam(DWORD pid, unsigned __int64 addr) diff --git a/host/host.h b/host/host.h index d2eb9cb..6c5e9f8 100644 --- a/host/host.h +++ b/host/host.h @@ -14,11 +14,13 @@ namespace Host { void Start(ProcessEventCallback onAttach, ProcessEventCallback onDetach, ThreadEventCallback onCreate, ThreadEventCallback onRemove); void Close(); - bool InjectProcess(DWORD pid, DWORD timeout = 5000); - bool DetachProcess(DWORD pid); - bool InsertHook(DWORD pid, HookParam hp, std::string name = ""); - bool RemoveHook(DWORD pid, unsigned __int64 addr); + bool InjectProcess(DWORD pid, DWORD timeout = 5000); + void DetachProcess(DWORD pid); + + void InsertHook(DWORD pid, HookParam hp, std::string name = ""); + void RemoveHook(DWORD pid, unsigned __int64 addr); + HookParam GetHookParam(DWORD pid, unsigned __int64 addr); HookParam GetHookParam(ThreadParam tp); std::wstring GetHookName(DWORD pid, unsigned __int64 addr); diff --git a/include/common.h b/include/common.h index 360cf5d..1600942 100644 --- a/include/common.h +++ b/include/common.h @@ -2,7 +2,6 @@ #define WIN32_LEAN_AND_MEAN #include -#include // A2W #include #include #include diff --git a/include/types.h b/include/types.h index f47f4a6..2c87630 100644 --- a/include/types.h +++ b/include/types.h @@ -30,7 +30,6 @@ struct HookParam HANDLE readerHandle; // Artikash 8/4/2018: handle for reader thread }; - struct ThreadParam // From hook, used internally by host as well { DWORD pid; // jichi: 5/11/2014: The process ID @@ -40,6 +39,7 @@ struct ThreadParam // From hook, used internally by host as well }; // Artikash 5/31/2018: required for unordered_map to work with struct key template <> struct std::hash { size_t operator()(const ThreadParam& tp) const { return std::hash<__int64>()((tp.pid + tp.hook) ^ (tp.retn + tp.spl)); } }; +static bool operator==(const ThreadParam& one, const ThreadParam& two) { return one.pid == two.pid && one.hook == two.hook && one.retn == two.retn && one.spl == two.spl; } struct InsertHookCmd // From host {