-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathed6inf.cpp
More file actions
246 lines (193 loc) · 5.55 KB
/
ed6inf.cpp
File metadata and controls
246 lines (193 loc) · 5.55 KB
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#pragma comment(linker,"/SECTION:.text,ERW /MERGE:.rdata=.text /MERGE:.data=.text")
#pragma comment(linker,"/SECTION:indexmoe,ERW /MERGE:.text=indexmoe")
//#pragma comment(lib,"akimisc.lib")
#define USE_NT_VER 1
#define CONSOLE_DEBUG 0
#define ENABLE_LOG 0
#include "ed6inf.h"
//#include "my_commsrc.h"
#include "MyLibrary.cpp"
#if 0
#if D3D8_VERSION
#pragma comment(linker,"/ENTRY:DllMain")
#pragma comment(linker, "/EXPORT:Direct3DCreate8=__Direct3DCreate8,@4")
FARPROC pDirect3DCreate8;
bool Load()
{
// if (Nt_IsPathExists(L".\\dsound.dll") && Nt_IsPathExists(L".\\d3d8.dll"))
// {
// MessageBoxW(NULL, L"不要同时使用dsound.dll和d3d8.dll!", L"d3d8.dll", MB_ICONSTOP);
// //return false;
// }
ULONG Length;
NTSTATUS Status;
HMODULE hModule;
WCHAR szPath[MAX_NTPATH];
UNICODE_STRING DllPath;
Length = Nt_GetSystemDirectory(szPath, countof(szPath));
StrCopyW(szPath + Length, L"d3d8.dll");
DllPath.Buffer = szPath;
DllPath.Length = (Length + CONST_STRLEN(L"d3d8.dll")) * sizeof(WCHAR);
DllPath.MaximumLength = DllPath.Length;
Status = LdrLoadDll(NULL, 0, &DllPath, (PVOID *)&hModule);
if (!NT_SUCCESS(Status))
return FALSE;
LdrAddRefDll(GET_MODULE_HANDLE_EX_FLAG_PIN, hModule);
pDirect3DCreate8 = Nt_GetProcAddress(hModule, "Direct3DCreate8");
if (pDirect3DCreate8 == NULL)
return FALSE;
return TRUE;
}
extern "C" __declspec(naked) void __cdecl _Direct3DCreate8(void)
{
if (pDirect3DCreate8 == NULL)
{
if (!Load())
{
__asm xor eax,eax;
__asm retn;
}
}
if (!bIsInit)
{
Init();
bIsInit = true;
}
__asm JMP pDirect3DCreate8;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG Reason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
switch (Reason)
{
case DLL_PROCESS_ATTACH:
LdrDisableThreadCalloutsForDll(hInstance);
MyLib_Initialize();
//Load();
#if CONSOLE_DEBUG
AllocConsole();
#endif
break;
case DLL_PROCESS_DETACH:
MyLib_UnInitialize();
break;
}
return TRUE;
}
#elif DSOUND_VERSION
#pragma comment(linker,"/ENTRY:DllMain")
#pragma comment(linker, "/EXPORT:DirectSoundCreate=__DirectSoundCreate,@1")
FARPROC pDirectSoundCreate;
bool Load()
{
// if (Nt_IsPathExists(L".\\dsound.dll") && Nt_IsPathExists(L".\\d3d8.dll"))
// {
// MessageBoxW(NULL, L"不要同时使用dsound.dll和d3d8.dll!", L"dsound.dll", MB_ICONSTOP);
// //return false;
// }
ULONG Length;
NTSTATUS Status;
HMODULE hModule;
WCHAR szPath[MAX_NTPATH];
UNICODE_STRING DllPath;
Length = Nt_GetSystemDirectory(szPath, countof(szPath));
StrCopyW(szPath + Length, L"dsound.dll");
DllPath.Buffer = szPath;
DllPath.Length = (Length + CONST_STRLEN(L"dsound.dll")) * sizeof(WCHAR);
DllPath.MaximumLength = DllPath.Length;
Status = LdrLoadDll(NULL, 0, &DllPath, (PVOID *)&hModule);
if (!NT_SUCCESS(Status))
return FALSE;
LdrAddRefDll(GET_MODULE_HANDLE_EX_FLAG_PIN, hModule);
//pDirectSoundCreate = Nt_GetProcAddress(hModule, "DirectSoundCreate");
pDirectSoundCreate = Nt_GetProcAddress(hModule, (LPCSTR)1);
if (pDirectSoundCreate == NULL)
return FALSE;
return TRUE;
}
extern "C" __declspec(naked) void __cdecl _DirectSoundCreate(void)
{
if (pDirectSoundCreate == NULL)
{
if (!Load())
{
__asm xor eax,eax;
__asm retn;
}
}
if (!bIsInit)
{
Init();
bIsInit = true;
}
__asm JMP pDirectSoundCreate;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, ULONG Reason, LPVOID lpReserved)
{
UNREFERENCED_PARAMETER(lpReserved);
switch (Reason)
{
case DLL_PROCESS_ATTACH:
LdrDisableThreadCalloutsForDll(hInstance);
MyLib_Initialize();
//Load();
#if CONSOLE_DEBUG
AllocConsole();
#endif
break;
case DLL_PROCESS_DETACH:
MyLib_UnInitialize();
break;
}
return TRUE;
}
#else
#endif
#endif
/*
#if ED6EX_VERSION
#pragma comment(linker, "/EXPORT:DirectInput8Create=dinput8.DirectInput8Create")
#pragma comment(linker, "/EXPORT:Direct3DCreate8=d3d8.Direct3DCreate8")
#elif D3D8_VERSION
#pragma comment(linker, "/EXPORT:Direct3DCreate8=system32\\d3d8.Direct3DCreate8")
#elif DINPUT8_VERSION
#pragma comment(linker, "/EXPORT:DirectInput8Create=system32\\dinput8.DirectInput8Create")
#endif
*/
//HMODULE hModuleSelf;
BOOL WINAPI DllMain(PVOID BaseAddress, ULONG Reason, PVOID Reserved);
#include "xxoo.hpp"
BOOL Initialize(PVOID BaseAddress)
{
ml::MlInitialize();
LdrDisableThreadCalloutsForDll(BaseAddress);
SetExeDirectoryAsCurrent();
#if CONSOLE_DEBUG
AllocConsole();
#endif
//static BOOL bIsInit = False;
if (!Hooked)
{
Init();
//bIsInit = TRUE;
}
return TRUE;
}
BOOL UnInitialize(PVOID BaseAddress)
{
return FALSE;
}
BOOL WINAPI DllMain(PVOID BaseAddress, ULONG Reason, PVOID Reserved)
{
UNREFERENCED_PARAMETER(Reserved);
switch (Reason)
{
case DLL_PROCESS_ATTACH:
return Initialize(BaseAddress) || UnInitialize(BaseAddress);
case DLL_PROCESS_DETACH:
UnInitialize(BaseAddress);
break;
}
return TRUE;
}
//#endif