-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhook_scanner.hpp
58 lines (51 loc) · 1.14 KB
/
hook_scanner.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#define SCAN_BYTES_COUNT 0x10
static const wchar_t* modules[] =
{
L"kernel32.dll",
L"ntdll.dll"
};
static const char* to_hk_scan[] =
{
"NtQueryObject",
"LdrGetProcedureAddress",
"LdrLoadDll",
"LdrUnloadDll",
"RtlFreeHeap",
"RtlAllocateHeap",
"NtAllocateVirtualMemory",
"NtFreeVirtualMemory",
"memmove",
"NtOpenFile",
"NtSetInformationFile",
"NtClose",
"NtSetInformationFile",
"NtQueryInformationFile",
"NtReadFile",
"LdrLockLoaderLock",
"LdrUnlockLoaderLock",
"memset",
"RtlRbRemoveNode",
"NtCreateThreadEx",
"NtQuerySystemInformation",
"LoadLibraryExW",
"LoadLibraryA",
"FreeLibrary",
"GetLastError",
};
enum class HOOK_RESTORE_MODE
{
HRM_RESTORE_ORIG,
HRM_RESTORE_HOOK
};
struct HOOK_SCAN_DATA
{
BYTE orig_bytes[SCAN_BYTES_COUNT] = { 0 };
BYTE remote_bytes[SCAN_BYTES_COUNT] = { 0 };
std::string func_name = { 0 };
void* func_addr = 0;
bool hooked = false;
};
bool HookScanAndPatch(std::vector<HOOK_SCAN_DATA>* hk_vec, HANDLE h_proc);
bool CompareFuncs(std::vector<HOOK_SCAN_DATA>* hk_vec);
bool RestoreHookedFuncs(std::vector<HOOK_SCAN_DATA>* hk_vec, HANDLE h_proc, HOOK_RESTORE_MODE mode);