forked from Public-Mirror/Textractor
god, "unsigned __int64" was a mouthful
This commit is contained in:
parent
28172e2cea
commit
e2f83d47b9
@ -168,7 +168,7 @@ namespace Host
|
|||||||
|
|
||||||
HMODULE textHooker = LoadLibraryExW(ITH_DLL, nullptr, DONT_RESOLVE_DLL_REFERENCES);
|
HMODULE textHooker = LoadLibraryExW(ITH_DLL, nullptr, DONT_RESOLVE_DLL_REFERENCES);
|
||||||
wchar_t textHookerPath[MAX_PATH];
|
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);
|
FreeLibrary(textHooker);
|
||||||
|
|
||||||
if (HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId))
|
if (HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId))
|
||||||
@ -215,13 +215,13 @@ namespace Host
|
|||||||
WriteFile(processRecordsByIds[pid].hostPipe, &info, sizeof(info), DUMMY, nullptr);
|
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);
|
auto info = RemoveHookCmd(addr);
|
||||||
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)
|
HookParam GetHookParam(DWORD pid, uint64_t addr)
|
||||||
{
|
{
|
||||||
LOCK(hostMutex);
|
LOCK(hostMutex);
|
||||||
HookParam ret = {};
|
HookParam ret = {};
|
||||||
@ -238,7 +238,7 @@ namespace Host
|
|||||||
|
|
||||||
HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.pid, tp.hook); }
|
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";
|
if (pid == 0) return L"Console";
|
||||||
LOCK(hostMutex);
|
LOCK(hostMutex);
|
||||||
|
@ -19,11 +19,11 @@ namespace Host
|
|||||||
void DetachProcess(DWORD pid);
|
void DetachProcess(DWORD pid);
|
||||||
|
|
||||||
void InsertHook(DWORD pid, HookParam hp, std::string name = "");
|
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);
|
HookParam GetHookParam(ThreadParam tp);
|
||||||
std::wstring GetHookName(DWORD pid, unsigned __int64 addr);
|
std::wstring GetHookName(DWORD pid, uint64_t addr);
|
||||||
|
|
||||||
TextThread* GetThread(ThreadParam tp);
|
TextThread* GetThread(ThreadParam tp);
|
||||||
void AddConsoleOutput(std::wstring text);
|
void AddConsoleOutput(std::wstring text);
|
||||||
|
@ -8,3 +8,4 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <cstdint>
|
||||||
|
@ -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(*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.
|
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
|
int offset, // offset of the data in the memory
|
||||||
index, // deref_offset1
|
index, // deref_offset1
|
||||||
split, // offset of the split character
|
split, // offset of the split character
|
||||||
@ -31,12 +31,12 @@ struct HookParam
|
|||||||
struct ThreadParam // From hook, used internally by host as well
|
struct ThreadParam // From hook, used internally by host as well
|
||||||
{
|
{
|
||||||
DWORD pid; // jichi: 5/11/2014: The process ID
|
DWORD pid; // jichi: 5/11/2014: The process ID
|
||||||
unsigned __int64 hook; // Artikash 6/6/2018: The insertion address of the hook
|
uint64_t hook; // Artikash 6/6/2018: The insertion address of the hook
|
||||||
unsigned __int64 retn; // jichi 5/11/2014: The return address of the hook
|
uint64_t 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 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
|
// 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; }
|
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
|
struct InsertHookCmd // From host
|
||||||
@ -49,9 +49,9 @@ struct InsertHookCmd // From host
|
|||||||
|
|
||||||
struct RemoveHookCmd // From host
|
struct RemoveHookCmd // From host
|
||||||
{
|
{
|
||||||
RemoveHookCmd(unsigned __int64 address) : address(address) {};
|
RemoveHookCmd(uint64_t address) : address(address) {};
|
||||||
int command = HOST_COMMAND_REMOVE_HOOK;
|
int command = HOST_COMMAND_REMOVE_HOOK;
|
||||||
unsigned __int64 address;
|
uint64_t address;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConsoleOutputNotif // From hook
|
struct ConsoleOutputNotif // From hook
|
||||||
@ -63,9 +63,9 @@ struct ConsoleOutputNotif // From hook
|
|||||||
|
|
||||||
struct HookRemovedNotif // From hook
|
struct HookRemovedNotif // From hook
|
||||||
{
|
{
|
||||||
HookRemovedNotif(unsigned __int64 address) : address(address) {};
|
HookRemovedNotif(uint64_t address) : address(address) {};
|
||||||
int command = HOST_NOTIFICATION_RMVHOOK;
|
int command = HOST_NOTIFICATION_RMVHOOK;
|
||||||
unsigned __int64 address;
|
uint64_t address;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOCK(mutex) std::lock_guard<std::recursive_mutex> lock(mutex)
|
#define LOCK(mutex) std::lock_guard<std::recursive_mutex> lock(mutex)
|
||||||
|
@ -80,7 +80,7 @@ void NewHook(const HookParam &hp, LPCSTR lpname, DWORD flag)
|
|||||||
else ConsoleOutput("NextHooker: too many hooks: can't insert");
|
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++)
|
for (int i = 0; i < MAX_HOOK; i++)
|
||||||
if (abs((long long)(::hookman[i].hp.address - addr)) < 9)
|
if (abs((long long)(::hookman[i].hp.address - addr)) < 9)
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "pipe.h"
|
#include "pipe.h"
|
||||||
|
|
||||||
void NewHook(const HookParam &hp, LPCSTR name, DWORD flag = HOOK_ENGINE);
|
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);
|
void SwitchTrigger(DWORD on);
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -90,7 +90,7 @@ void ConsoleOutput(LPCSTR text)
|
|||||||
WriteFile(::hookPipe, &info, strlen(text) + sizeof(info), DUMMY, nullptr);
|
WriteFile(::hookPipe, &info, strlen(text) + sizeof(info), DUMMY, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyHookRemove(unsigned __int64 addr)
|
void NotifyHookRemove(uint64_t addr)
|
||||||
{
|
{
|
||||||
auto info = HookRemovedNotif(addr);
|
auto info = HookRemovedNotif(addr);
|
||||||
WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr);
|
WriteFile(::hookPipe, &info, sizeof(info), DUMMY, nullptr);
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
void CreatePipe();
|
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
|
void ConsoleOutput(LPCSTR text); // jichi 12/25/2013: Used to return length of sent text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user