Textractor_test/texthook/texthook.h

57 lines
1.4 KiB
C
Raw Permalink Normal View History

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.
2018-08-25 00:50:20 +08:00
#include "types.h"
2018-08-23 23:53:23 +08:00
2020-03-18 03:53:46 +08:00
// Artikash 6/17/2019 TODO: These have the wrong values on x64
/** jichi 12/24/2014
* @param addr function address
* @param frame real address of the function, supposed to be the same as addr
* @param stack address of current stack - 4
* @return If success, which is reverted
*/
inline std::atomic<bool (*)(LPVOID addr, DWORD frame, DWORD stack)> trigger_fun = nullptr;
2018-08-23 23:53:23 +08:00
// 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
{
public:
HookParam hp;
union
{
uint64_t address;
void* location;
}; // Absolute address
bool Insert(HookParam hp, DWORD set_flag);
void Clear();
private:
void Read();
2018-08-26 03:45:25 +08:00
bool InsertHookCode();
bool InsertReadCode();
2018-12-21 00:46:11 +08:00
void Send(uintptr_t dwDatabase);
int GetLength(uintptr_t base, uintptr_t in); // jichi 12/25/2013: Return 0 if failed
2019-03-28 11:35:22 +08:00
int HookStrlen(BYTE* data);
2018-08-26 03:45:25 +08:00
void RemoveHookCode();
void RemoveReadCode();
2018-11-11 12:29:12 +08:00
2019-10-04 04:00:19 +08:00
volatile DWORD useCount;
HANDLE readerThread, readerEvent;
2018-12-27 02:07:59 +08:00
bool err;
BYTE trampoline[x64 ? 140 : 40];
2018-08-23 23:53:23 +08:00
};
enum { MAX_HOOK = 2500, HOOK_BUFFER_SIZE = MAX_HOOK * sizeof(TextHook), HOOK_SECTION_SIZE = HOOK_BUFFER_SIZE * 2 };
2018-08-23 23:53:23 +08:00
// EOF