god, "unsigned __int64" was a mouthful

This commit is contained in:
Akash Mozumdar 2018-09-20 21:59:07 -04:00
parent 28172e2cea
commit e2f83d47b9
8 changed files with 21 additions and 20 deletions

View File

@ -168,7 +168,7 @@ namespace Host
HMODULE textHooker = LoadLibraryExW(ITH_DLL, nullptr, DONT_RESOLVE_DLL_REFERENCES);
wchar_t textHookerPath[MAX_PATH];
unsigned int textHookerPathSize = GetModuleFileNameW(textHooker, textHookerPath, MAX_PATH) * 2 + 2;
DWORD textHookerPathSize = GetModuleFileNameW(textHooker, textHookerPath, MAX_PATH) * 2 + 2;
FreeLibrary(textHooker);
if (HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId))
@ -215,13 +215,13 @@ namespace Host
WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr);
}
void RemoveHook(DWORD pid, unsigned __int64 addr)
void RemoveHook(DWORD pid, uint64_t addr)
{
auto info = RemoveHookCmd(addr);
WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr);
}
HookParam GetHookParam(DWORD pid, unsigned __int64 addr)
HookParam GetHookParam(DWORD pid, uint64_t addr)
{
LOCK(hostMutex);
HookParam ret = {};
@ -238,7 +238,7 @@ namespace Host
HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); }
std::wstring GetHookName(DWORD pid, unsigned __int64 addr)
std::wstring GetHookName(DWORD pid, uint64_t addr)
{
if (pid == 0) return L"Console";
LOCK(hostMutex);

View File

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

View File

@ -8,3 +8,4 @@
#include <functional>
#include <thread>
#include <mutex>
#include <cstdint>

View File

@ -11,7 +11,7 @@ struct HookParam
typedef bool(*filter_fun_t)(LPVOID str, DWORD *len, HookParam *hp, BYTE index); // jichi 10/24/2014: Add filter function. Return true if skip the text
typedef bool(*hook_fun_t)(DWORD esp, HookParam *hp); // jichi 10/24/2014: Add generic hook function, return false if stop execution.
unsigned __int64 address; // absolute or relative address
uint64_t address; // absolute or relative address
int offset, // offset of the data in the memory
index, // deref_offset1
split, // offset of the split character
@ -31,12 +31,12 @@ struct HookParam
struct ThreadParam // From hook, used internally by host as well
{
DWORD pid; // jichi: 5/11/2014: The process ID
unsigned __int64 hook; // Artikash 6/6/2018: The insertion address of the hook
unsigned __int64 retn; // jichi 5/11/2014: The return address of the hook
unsigned __int64 spl; // jichi 5/11/2014: the processed split value of the hook paramete
uint64_t hook; // Artikash 6/6/2018: The insertion address of the hook
uint64_t retn; // jichi 5/11/2014: The return address of the hook
uint64_t spl; // jichi 5/11/2014: the processed split value of the hook paramete
};
// Artikash 5/31/2018: required for unordered_map to work with struct key
template <> struct std::hash<ThreadParam> { size_t operator()(const ThreadParam& tp) const { return std::hash<__int64>()((tp.pid + tp.hook) ^ (tp.retn + tp.spl)); } };
template <> struct std::hash<ThreadParam> { size_t operator()(const ThreadParam& tp) const { return std::hash<int64_t>()((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
@ -49,9 +49,9 @@ struct InsertHookCmd // From host
struct RemoveHookCmd // From host
{
RemoveHookCmd(unsigned __int64 address) : address(address) {};
RemoveHookCmd(uint64_t address) : address(address) {};
int command = HOST_COMMAND_REMOVE_HOOK;
unsigned __int64 address;
uint64_t address;
};
struct ConsoleOutputNotif // From hook
@ -63,9 +63,9 @@ struct ConsoleOutputNotif // From hook
struct HookRemovedNotif // From hook
{
HookRemovedNotif(unsigned __int64 address) : address(address) {};
HookRemovedNotif(uint64_t address) : address(address) {};
int command = HOST_NOTIFICATION_RMVHOOK;
unsigned __int64 address;
uint64_t address;
};
#define LOCK(mutex) std::lock_guard<std::recursive_mutex> lock(mutex)

View File

@ -80,7 +80,7 @@ void NewHook(const HookParam &hp, LPCSTR lpname, DWORD flag)
else ConsoleOutput("NextHooker: too many hooks: can't insert");
}
void RemoveHook(unsigned __int64 addr)
void RemoveHook(uint64_t addr)
{
for (int i = 0; i < MAX_HOOK; i++)
if (abs((long long)(::hookman[i].hp.address - addr)) < 9)

View File

@ -9,7 +9,7 @@
#include "pipe.h"
void NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
void RemoveHook(unsigned __int64 addr);
void RemoveHook(uint64_t addr);
void SwitchTrigger(DWORD on);
// EOF

View File

@ -90,7 +90,7 @@ void ConsoleOutput(LPCSTR text)
WriteFile(::hookPipe, &info, strlen(text) + sizeof(info), DUMMY, nullptr);
}
void NotifyHookRemove(unsigned __int64 addr)
void NotifyHookRemove(uint64_t addr)
{
auto info = HookRemovedNotif(addr);
WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr);

View File

@ -4,5 +4,5 @@
#include "types.h"
void CreatePipe();
void NotifyHookRemove(unsigned __int64 addr);
void NotifyHookRemove(uint64_t addr);
void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text