-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheqclientmod.cpp
More file actions
123 lines (108 loc) · 3.56 KB
/
Copy patheqclientmod.cpp
File metadata and controls
123 lines (108 loc) · 3.56 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
// eqclientmod
// hacks/mods for everquest client in a planted dll
// solar@heliacal.net
#include "eqclientmod.h"
#include "Personalities/personality.h"
#include "common.h"
#include "util.h"
#include "eq_titanium.h"
//extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
//extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
#ifdef BUILD_VERSION
extern "C" __declspec(dllexport) const char *EQCLIENTMOD_BUILD_VERSION = BUILD_VERSION;
#endif
void *Entry_Trampoline;
int tramplen = 0;
DWORD entryPoint;
void Payload2()
{
//Log("Payload2");
// restore original entry point code
Patch((void *)entryPoint, Entry_Trampoline, tramplen);
LoadCommon();
#ifdef TIMER_HACK
extern void LoadTimerHack();
LoadTimerHack();
#endif
#ifdef GAMMA_HACK
extern void LoadGammaHack();
LoadGammaHack();
#endif
#ifdef QEYNOS_CITIZEN_FEMALE_MODEL_HACK
extern void LoadQeynosCitizenFemaleModelHack();
LoadQeynosCitizenFemaleModelHack();
#endif
#ifdef SLEEP_REMOVER_HACK
extern void LoadSleepRemoverHack();
LoadSleepRemoverHack();
#endif
#ifdef PROGRAM_LAUNCH_HACK
extern void LoadProgramLaunchHack();
LoadProgramLaunchHack();
#endif
#ifdef ZONE_VERSION_HACK
extern void LoadZoneVersionHack();
LoadZoneVersionHack();
#endif
#ifdef DEV_HACK
extern void LoadDevHack();
LoadDevHack();
#endif
#ifdef WINDOW_TITLE_HACK
extern void LoadWindowTitleHack();
LoadWindowTitleHack();
#endif
#ifdef FOV_HACK
extern void LoadFoVHack();
LoadFoVHack();
#endif
#ifdef BORDERLESS_WINDOW_HACK
extern void LoadBorderlessWindowHack();
LoadBorderlessWindowHack();
#endif
// continue from normal program entry point, this never returns
((void (*)())entryPoint)();
}
bool Payload()
{
// make sure we're loading into eqgame.exe
HMODULE callerModule = GetModuleHandleA(0);
char lpFilename[260];
GetModuleFileNameA(callerModule, lpFilename, 260);
if (!(lpFilename && strlen(lpFilename) >= 10 && !strncmp(lpFilename + strlen(lpFilename) - 10, "eqgame.exe", 10)))
{
Log("eqclientmod loaded but process file name is not eqgame.exe, skipping eqgame hacks.");
return FALSE;
}
if (strncmp((const char *)Offset_WindowNameString, "EverQuest", 9))
{
Log("This doesn't look like the process we expect, skipping eqgame hacks.");
return FALSE;
}
hEQGameEXE = callerModule;
// This dll expects to be wrapping a dll that the parent module imports from and we're being loaded by the windows dynamic linker before the program starts executing.
// By detouring the entry point, we can run anything we want at the start of the program once it's actually ready to run. We can do that here too but we're inside DllMain().
DWORD entryPointRVA = (DWORD)FindEntryPoint(callerModule);
entryPoint = (DWORD)callerModule + entryPointRVA;
for (; tramplen < 5; tramplen += InstructionLength((BYTE *)entryPoint + tramplen));
Log("eqclientmod: Detouring entry point of %s at %08X + %08X = %08X trampoline bytes = %d", lpFilename, (DWORD)callerModule, entryPointRVA, (DWORD)callerModule + entryPointRVA, tramplen);
Entry_Trampoline = DetourWithTrampoline((void *)entryPoint, Payload2, tramplen);
return TRUE;
}
bool DllPersonalityInit(); // the dll whose personality we take on can be changed
BOOL WINAPI DllMain(HMODULE hinstDLL, DWORD r, LPVOID)
{
if (r == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(hinstDLL);
if (!DllPersonalityInit()) return FALSE;
if (Payload())
{
// prevent self from being unloaded
HMODULE hThisModule;
hThisModule = LoadLibrary(PERSONALITY_DLL);
//GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_PIN, PERSONALITY_DLL, &hThisModule);
}
}
return TRUE;
}