-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathFunctions.cpp
189 lines (154 loc) · 4.14 KB
/
Functions.cpp
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include "Warcraft.h"
void HideDll(HMODULE hModule)
{
DWORD dwPEB_LDR_DATA = NULL;
_asm
{
pushad;
pushfd;
mov eax, fs:[30h]
mov eax, [eax+0Ch]
mov dwPEB_LDR_DATA, eax
//InLoadOrderModuleList:
mov esi, [eax+0Ch]
mov edx, [eax+10h]
LoopInLoadOrderModuleList:
lodsd
mov esi, eax
mov ecx, [eax+18h]
cmp ecx, hModule
jne SkipA
mov ebx, [eax]
mov ecx, [eax+4]
mov [ecx], ebx
mov [ebx+4], ecx
jmp InMemoryOrderModuleList
SkipA:
cmp edx, esi
jne LoopInLoadOrderModuleList
InMemoryOrderModuleList:
mov eax, dwPEB_LDR_DATA
mov esi, [eax+14h]
mov edx, [eax+18h]
LoopInMemoryOrderModuleList:
lodsd
mov esi, eax
mov ecx, [eax+10h]
cmp ecx, hModule
jne SkipB
mov ebx, [eax]
mov ecx, [eax+4]
mov [ecx], ebx
mov [ebx+4], ecx
jmp InInitializationOrderModuleList
SkipB:
cmp edx, esi
jne LoopInMemoryOrderModuleList
InInitializationOrderModuleList:
mov eax, dwPEB_LDR_DATA
mov esi, [eax+1Ch]
mov edx, [eax+20h]
LoopInInitializationOrderModuleList:
lodsd
mov esi, eax
mov ecx, [eax+08h]
cmp ecx, hModule
jne SkipC
mov ebx, [eax]
mov ecx, [eax+4]
mov [ecx], ebx
mov [ebx+4], ecx
jmp Finished
SkipC:
cmp edx, esi
jne LoopInInitializationOrderModuleList
Finished:
popfd;
popad;
}
}
void Patch(DWORD dwBaseAddress, char *szData, int iSize)
{
DWORD dwOldProtection = NULL;
VirtualProtect((LPVOID)dwBaseAddress, iSize, PAGE_EXECUTE_READWRITE, &dwOldProtection);
CopyMemory((LPVOID)dwBaseAddress, szData, iSize);
VirtualProtect((LPVOID)dwBaseAddress, iSize, dwOldProtection, NULL);
}
void PlantDetourCall(BYTE *bSource, BYTE *bDestination, int iLength)
{
DWORD dwOldProtection = NULL;
BYTE *bJump = (BYTE *)malloc(iLength + 5);
VirtualProtect(bSource, iLength, PAGE_EXECUTE_READWRITE, &dwOldProtection);
memcpy(bJump + 3, bSource, iLength);
bJump[0] = 0x58;
bJump[1] = 0x59;
bJump[2] = 0x50;
bJump[iLength + 3] = 0xE9;
*(DWORD *)(bJump + iLength + 4) = (DWORD)((bSource + iLength) - (bJump + iLength + 3)) - 5;
bSource[0] = 0xE8;
*(DWORD *)(bSource + 1) = (DWORD)(bDestination - (bSource)) - 5;
for (int i = 5; i < iLength; i++)
bSource[i] = 0x90;
VirtualProtect(bSource, iLength, dwOldProtection, NULL);
}
void PlantDetourJump(BYTE *bSource, BYTE *bDestination, int iLength)
{
DWORD dwOldProtection = NULL;
BYTE *bJump = (BYTE *)malloc(iLength + 5);
VirtualProtect(bSource, iLength, PAGE_EXECUTE_READWRITE, &dwOldProtection);
memcpy(bJump, bSource, iLength);
bJump[iLength] = 0xE9;
*(DWORD *)(bJump + iLength) = (DWORD)((bSource + iLength) - (bJump + iLength)) - 5;
bSource[0] = 0xE9;
*(DWORD *)(bSource + 1) = (DWORD)(bDestination - bSource) - 5;
for (int i = 5; i < iLength; i++)
bSource[i] = 0x90;
VirtualProtect(bSource, iLength, dwOldProtection, NULL);
}
void SettingInitialize()
{
if (FileExists(".\\Xenon.ini"))
return;
SettingSet("Bypass -ah in DotA", "1");
SettingSet("Enable Trade / Resource View", "1");
SettingSet("Make Units Clickable", "1");
SettingSet("Reveal Illusions", "1");
SettingSet("Reveal Invisibles", "1");
SettingSet("Reveal Units on Main Map", "1");
SettingSet("Reveal Units on Mini Map", "1");
SettingSet("Show Enemies Ping Signals", "1");
SettingSet("Show Missiles", "1");
SettingSet("Show Rally Points", "1");
SettingSet("Show Runes", "1");
SettingSet("Show Skills / Cooldowns", "1");
SettingSet("Color Invisibles", "1");
SettingSet("Damage Notifier", "1");
SettingSet("Game Start Notifier", "1");
SettingSet("Gray HP Under Fog", "1");
SettingSet("Instant Game Start", "0");
SettingSet("Mana Bar", "1");
SettingSet("Roshan Notifier", "1");
SettingSet("Rune Notifier", "1");
SettingSet("SafeClick", "1");
SettingSet("Show AS & MS in Number", "1");
SettingSet("Show HP & MP Regen", "1");
}
void SettingSet(char *szKey, char *szValue)
{
WritePrivateProfileString("Xenon", szKey, szValue, ".\\Xenon.ini");
}
bool SettingGet(char *szKey)
{
return GetPrivateProfileInt("Xenon", szKey, 0, ".\\Xenon.ini") == 1;
}
bool FileExists(char *szFile)
{
FILE *pFile;
fopen_s(&pFile, szFile, "r");
if (pFile != NULL)
{
fclose(pFile);
return true;
}
return false;
}