2018-08-23 11:53:23 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// texthook.h
|
|
|
|
// 8/24/2013 jichi
|
|
|
|
// Branch: IHF_DLL/IHF_CLIENT.h, rev 133
|
|
|
|
//
|
|
|
|
// 8/24/2013 TODO:
|
|
|
|
// - Clean up this file
|
|
|
|
// - Reduce global variables. Use namespaces or singleton classes instead.
|
|
|
|
#include "common.h"
|
2018-08-24 12:50:20 -04:00
|
|
|
#include "types.h"
|
2018-08-23 11:53:23 -04:00
|
|
|
|
2018-11-10 23:29:12 -05:00
|
|
|
void SetTrigger();
|
2018-08-23 11:53:23 -04:00
|
|
|
|
|
|
|
// jichi 9/25/2013: This class will be used by NtMapViewOfSectionfor
|
|
|
|
// interprocedure communication, where constructor/destructor will NOT work.
|
2018-08-23 15:25:33 -04:00
|
|
|
|
2018-08-23 11:53:23 -04:00
|
|
|
class TextHook
|
|
|
|
{
|
2018-12-06 01:52:41 -05:00
|
|
|
public:
|
|
|
|
HookParam hp;
|
2018-12-20 02:48:21 -05:00
|
|
|
union
|
|
|
|
{
|
|
|
|
uint64_t address;
|
|
|
|
void* location;
|
|
|
|
}; // Absolute address
|
2018-12-06 01:52:41 -05:00
|
|
|
|
|
|
|
bool Insert(HookParam hp, DWORD set_flag);
|
2019-06-10 01:49:11 -04:00
|
|
|
void Clear(bool markRemoved = false);
|
2018-12-06 01:52:41 -05:00
|
|
|
|
|
|
|
private:
|
2019-06-09 00:48:30 -04:00
|
|
|
void Read();
|
2018-08-25 15:45:25 -04:00
|
|
|
bool InsertHookCode();
|
|
|
|
bool InsertReadCode();
|
2018-12-20 11:46:11 -05:00
|
|
|
void Send(uintptr_t dwDatabase);
|
|
|
|
int GetLength(uintptr_t base, uintptr_t in); // jichi 12/25/2013: Return 0 if failed
|
2019-03-27 23:35:22 -04:00
|
|
|
int HookStrlen(BYTE* data);
|
2018-08-25 15:45:25 -04:00
|
|
|
void RemoveHookCode();
|
|
|
|
void RemoveReadCode();
|
2018-11-10 23:29:12 -05:00
|
|
|
|
2018-12-01 15:53:54 -05:00
|
|
|
HANDLE readerThread, readerEvent;
|
2018-12-26 13:07:59 -05:00
|
|
|
bool err;
|
2019-06-09 00:48:30 -04:00
|
|
|
BYTE trampoline[x64 ? 140 : 40];
|
2018-08-23 11:53:23 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-11-10 23:29:12 -05:00
|
|
|
enum { MAX_HOOK = 300, HOOK_BUFFER_SIZE = MAX_HOOK * sizeof(TextHook), HOOK_SECTION_SIZE = HOOK_BUFFER_SIZE * 2 };
|
2018-08-23 11:53:23 -04:00
|
|
|
|
|
|
|
// EOF
|