forked from alimb2/Ayyware-Full-Fixed-Updated-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utilities.h
96 lines (75 loc) · 2.68 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
87
88
89
90
91
92
93
94
95
96
/*
Syn's AyyWare Framework
*/
#pragma once
// Includes
#include "CommonIncludes.h"
#include <time.h>
// Colors for the console
//Define extra colours
#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)
// Utilities Namespace
// Purpose: Contains misc functionality for memory related functionality
namespace Utilities
{
// Debug console controls
void OpenConsole(std::string Title);
void CloseConsole();
void Log(const char *fmt, ...);
void EnableLogFile(std::string filename);
void SetConsoleColor(WORD color);
// Misc Shizz
std::string GetTimeString();
// Memory utils
// Purpose: Provides memeory related functionality (pattern scanning ect)
namespace Memory
{
// Waits for a module to be available, before returning it's base address
DWORD WaitOnModuleHandle(std::string moduleName);
// Attempts to locate the given signature and mask in a memory range
// Returns the address at which it has been found
DWORD FindPattern(std::string moduleName, BYTE* Mask, char* szMask);
DWORD FindPatternV2(std::string moduleName, std::string pattern);
// Attempts to locate the given text in a memory range
// Returns the address at which it has been found
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); // Pass a &class
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];
}