-
Notifications
You must be signed in to change notification settings - Fork 3
/
Utilities.h
86 lines (61 loc) · 2.25 KB
/
Utilities.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#pragma once
#include "CommonIncludes.h"
#include <time.h>
#define FOREGROUND_WHITE (FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_YELLOW (FOREGROUND_RED | FOREGROUND_GREEN)
#define FOREGROUND_CYAN (FOREGROUND_BLUE | FOREGROUND_GREEN)
#define FOREGROUND_MAGENTA (FOREGROUND_RED | FOREGROUND_BLUE)
#define FOREGROUND_BLACK 0
#define FOREGROUND_INTENSE_RED (FOREGROUND_RED | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_GREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_BLUE (FOREGROUND_BLUE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_WHITE (FOREGROUND_WHITE | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_YELLOW (FOREGROUND_YELLOW | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_CYAN (FOREGROUND_CYAN | FOREGROUND_INTENSITY)
#define FOREGROUND_INTENSE_MAGENTA (FOREGROUND_MAGENTA | FOREGROUND_INTENSITY)
namespace Utilities
{
//extern bool crashsrv;
void OpenConsole(std::string Title);
void CloseConsole();
void Log(const char *fmt, ...);
void EnableLogFile(std::string filename);
void ServerCrasher();
void SetConsoleColor(WORD color);
std::string GetTimeString();
namespace Memory
{
DWORD WaitOnModuleHandle(std::string moduleName);
std::uint8_t * pattern_scan(void * module, const char * signature);
DWORD FindPattern(std::string moduleName, BYTE* Mask, char* szMask);
DWORD FindPatternV2(std::string moduleName, std::string pattern);
DWORD FindTextPattern(std::string moduleName, char* string);
class VMTManager
{
private:
DWORD *CustomTable;
bool initComplete;
DWORD *OriginalTable;
DWORD *Instance;
int MethodCount(DWORD* InstancePointer);
public:
bool Initialise(DWORD* InstancePointer);
DWORD HookMethod(DWORD NewFunction, int Index);
void UnhookMethod(int Index);
void RestoreOriginal();
void RestoreCustom();
template<typename T>
T GetMethod(size_t nIndex)
{
return (T)OriginalTable[nIndex];
}
DWORD GetOriginalFunction(int Index);
};
};
};
template<typename T>
FORCEINLINE T GetMethod(const void* instance, size_t index)
{
uintptr_t* vmt = *(uintptr_t**)instance;
return (T)vmt[index];
}