2018-08-23 23:53:23 +08: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-25 00:50:20 +08:00
|
|
|
#include "types.h"
|
2018-08-23 23:53:23 +08:00
|
|
|
|
|
|
|
extern int currentHook;
|
|
|
|
extern DWORD trigger;
|
|
|
|
|
|
|
|
// jichi 9/25/2013: This class will be used by NtMapViewOfSectionfor
|
|
|
|
// interprocedure communication, where constructor/destructor will NOT work.
|
2018-08-24 03:25:33 +08:00
|
|
|
|
2018-08-23 23:53:23 +08:00
|
|
|
class TextHook
|
|
|
|
{
|
2018-08-26 03:45:25 +08:00
|
|
|
bool InsertHookCode();
|
|
|
|
bool InsertReadCode();
|
|
|
|
bool UnsafeInsertHookCode();
|
2018-08-23 23:53:23 +08:00
|
|
|
DWORD UnsafeSend(DWORD dwDataBase, DWORD dwRetn);
|
2018-08-26 03:45:25 +08:00
|
|
|
void RemoveHookCode();
|
|
|
|
void RemoveReadCode();
|
|
|
|
void SetHookName(LPCSTR name);
|
2018-08-23 23:53:23 +08:00
|
|
|
public:
|
2018-08-24 03:25:33 +08:00
|
|
|
HookParam hp;
|
2018-08-23 23:53:23 +08:00
|
|
|
LPSTR hook_name;
|
|
|
|
int name_length;
|
2018-08-27 03:14:45 +08:00
|
|
|
BYTE trampoline[120];
|
2018-08-23 23:53:23 +08:00
|
|
|
|
2018-08-26 03:45:25 +08:00
|
|
|
bool InsertHook();
|
|
|
|
void InitHook(const HookParam &hp, LPCSTR name = 0, WORD set_flag = 0);
|
2018-08-23 23:53:23 +08:00
|
|
|
DWORD Send(DWORD dwDataBase, DWORD dwRetn);
|
2018-08-26 03:45:25 +08:00
|
|
|
void ClearHook();
|
2018-08-23 23:53:23 +08:00
|
|
|
int GetLength(DWORD base, DWORD in); // jichi 12/25/2013: Return 0 if failed
|
|
|
|
};
|
|
|
|
|
2018-08-26 03:45:25 +08:00
|
|
|
enum { MAX_HOOK = 300 };
|
2018-08-23 23:53:23 +08:00
|
|
|
enum { HOOK_SECTION_SIZE = MAX_HOOK * sizeof(TextHook) * 2, HOOK_BUFFER_SIZE = MAX_HOOK * sizeof(TextHook) };
|
|
|
|
|
2018-08-26 03:45:25 +08:00
|
|
|
extern TextHook *hookman;
|
2018-08-23 23:53:23 +08:00
|
|
|
|
2018-08-26 03:45:25 +08:00
|
|
|
extern bool running;
|
2018-08-23 23:53:23 +08:00
|
|
|
|
2018-08-26 03:45:25 +08:00
|
|
|
extern HANDLE hookPipe, hmMutex;
|
2018-08-23 23:53:23 +08:00
|
|
|
|
|
|
|
// EOF
|