-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.h
174 lines (169 loc) · 4.99 KB
/
Function.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#pragma once
#include <Windows.h>
#include <winternl.h>
extern "C" PPEB GetPEB();
namespace Function
{
typedef LPVOID(WINAPI* tVirtualAlloc)(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD flAllocationType,
DWORD flProtect
);
typedef BOOL(WINAPI* tVirtualProtect)(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD flNewProtect,
PDWORD lpflOldProtect
);
typedef HANDLE(WINAPI* tCreateFileA)(
LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile
);
typedef BOOL(WINAPI* tReadFile)(
HANDLE hFile,
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
typedef BOOL(WINAPI* tCloseHandle)(
HANDLE hObject
);
typedef DWORD(WINAPI* tGetFileSize)(
HANDLE hFile,
LPDWORD lpFileSizeHigh
);
typedef DWORD(WINAPI* tGetFileAttributesA)(
LPCSTR lpFileName
);
typedef DWORD(WINAPI* tSearchPathA)(
LPCSTR lpPath,
LPCSTR lpFileName,
LPCSTR lpExtension,
DWORD nBufferLength,
LPSTR lpBuffer,
LPSTR* lpFilePart
);
typedef BOOL (WINAPI* tFreeLibrary)(
HMODULE hLibModule
);
typedef HMODULE(WINAPI* tLoadLibraryA)(
LPCSTR lpLibFileName
);
typedef DWORD(WINAPI* tSearchPathW)(
LPCWSTR lpPath,
LPCWSTR lpFileName,
LPCWSTR lpExtension,
DWORD nBufferLength,
LPWSTR lpBuffer,
LPWSTR* lpFilePart
);
typedef DWORD(WINAPI* tGetModuleFileNameW)(
HMODULE hModule,
LPWSTR lpFilename,
DWORD nSize
);
typedef BOOL(WINAPI* tSetConsoleTitleW)(
LPWSTR lpConsoleTitle
);
typedef BOOL(WINAPI* tVirtualFree)(
LPVOID lpAddress,
SIZE_T dwSize,
DWORD dwFreeType
);
typedef DWORD(WINAPI* tGetEnvironmentVariableW)(
_In_opt_ LPCWSTR lpName,
_Out_writes_to_opt_(nSize, return +1) LPWSTR lpBuffer,
_In_ DWORD nSize
);
typedef HANDLE(WINAPI* tCreateFileW)(
_In_ LPCWSTR lpFileName,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwShareMode,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
_In_ DWORD dwCreationDisposition,
_In_ DWORD dwFlagsAndAttributes,
_In_opt_ HANDLE hTemplateFile
);
typedef HANDLE(WINAPI* tCreateFileMappingW)(
_In_ HANDLE hFile,
_In_opt_ LPSECURITY_ATTRIBUTES lpFileMappingAttributes,
_In_ DWORD flProtect,
_In_ DWORD dwMaximumSizeHigh,
_In_ DWORD dwMaximumSizeLow,
_In_opt_ LPCWSTR lpName
);
typedef LPVOID(WINAPI* tMapViewOfFile)(
_In_ HANDLE hFileMappingObject,
_In_ DWORD dwDesiredAccess,
_In_ DWORD dwFileOffsetHigh,
_In_ DWORD dwFileOffsetLow,
_In_ SIZE_T dwNumberOfBytesToMap
);
typedef HMODULE(WINAPI* tGetModuleHandleW)(
_In_opt_ LPCWSTR lpModuleName
);
typedef VOID(WINAPI* tSleep)(
_In_ DWORD dwMilliseconds
);
typedef BOOL(WINAPI* tCopyFileW)(
_In_ LPCWSTR lpExistingFileName,
_In_ LPCWSTR lpNewFileName,
_In_ BOOL bFailIfExists
);
typedef BOOL(WINAPI* tCreateDirectoryW)(
_In_ LPCWSTR lpPathName,
_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
typedef HANDLE(WINAPI* tGetCurrentProcess)(
VOID
);
typedef FARPROC(WINAPI* tGetProcAddress)(
_In_ HMODULE hModule,
_In_ LPCSTR lpProcName
);
typedef DWORD(WINAPI* tGetFileAttributesW)(
_In_ LPCWSTR lpFileName
);
namespace call {
extern Function::tVirtualFree virtualFree;
extern Function::tCloseHandle closehandle;
extern Function::tCreateFileA createFileA;
extern Function::tVirtualAlloc virtualAlloc;
extern Function::tGetFileSize getFileSize;
extern Function::tReadFile readFile;
extern Function::tVirtualProtect virtualProtect;
extern Function::tGetFileAttributesA getFileAttributesA;
extern Function::tSearchPathA searchPathA;
extern Function::tFreeLibrary freeLibrary;
extern Function::tLoadLibraryA loadLibraryA;
extern Function::tSearchPathW searchPathW;
extern Function::tGetModuleFileNameW getModuleFileNameW;
extern Function::tSetConsoleTitleW setConsoleTitleW;
extern Function::tGetEnvironmentVariableW getEnvironmentVariableW;
extern Function::tCreateFileW createFileW;
extern Function::tCreateFileMappingW createFileMappingW;
extern Function::tMapViewOfFile mapViewOfFile;
extern Function::tGetModuleHandleW getModuleHandleW;
extern Function::tSleep sleep;
extern Function::tCopyFileW copyFileW;
extern Function::tCreateDirectoryW createDirectoryW;
extern Function::tGetCurrentProcess getCurrentProcess;
extern Function::tGetProcAddress getProcAddress;
extern Function::tGetFileAttributesW getFileAttributesW;
}
bool Init_Setup();
void* Memcpy(void* dst, const void* src, unsigned int cnt);
int _strcmp(const char* str1, const char* str2);
int wstrcmp(const wchar_t* str1, const wchar_t* str2);
int _strlen(const wchar_t* str1);
void GetLowerLetters(WCHAR* input);
void* pGetProcAddress(void* moduleHandle, const char* functionName);
void* pGetModuleHandle(const wchar_t* moduleName);
};