This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFFXIITZAFPSU.cpp
More file actions
197 lines (167 loc) · 14.8 KB
/
FFXIITZAFPSU.cpp
File metadata and controls
197 lines (167 loc) · 14.8 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
#include "pch.h"
#include "md5.h" //Credit to Frank Thilo
#include "Utility.h"
#define overlayName L"FFXII FPS UNLOCKER OVERLAY"
bool InjectDLL(HANDLE& hProcess, const std::string& DLLPath)
{
long DSize = DLLPath.length() + 1;
LPVOID Alloc = VirtualAllocEx(hProcess, NULL, DSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (Alloc == NULL)
{
printf("[!]Fail to allocate memory in Target Process.\n");
return false;
}
printf("Allocating memory in Targer Process.\n");
int DidWrite = WriteProcessMemory(hProcess, Alloc, DLLPath.c_str(), DSize, 0);
if (DidWrite == 0)
{
printf("Fail to write in Target Process memory.\n");
return false;
}
printf("Creating Remote Thread in Target Process\n");
DWORD dWord;
LPTHREAD_START_ROUTINE addrLoadLibrary = (LPTHREAD_START_ROUTINE)GetProcAddress(LoadLibrary(L"kernel32"), "LoadLibraryA");
HANDLE ThreadReturn = CreateRemoteThread(hProcess, NULL, 0, addrLoadLibrary, Alloc, 0, &dWord);
WaitForSingleObject(ThreadReturn, INFINITE);
if (ThreadReturn == NULL)
{
printf("Failed to create Remote Thread\n");
return false;
}
if ((hProcess != NULL) && (Alloc != NULL) && (DidWrite != ERROR_INVALID_HANDLE) && (ThreadReturn != NULL))
{
printf("DLL Successfully Injected\n");
CloseHandle(ThreadReturn);
return true;
}
return false;
}
int main()
{
const char dllRel[] = "XIIHook.dll";
char dllPath[MAX_PATH];
GetFullPathNameA(dllRel, MAX_PATH, dllPath, nullptr);
//Process handles
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
HWND FFXIIWND = findXII();
HANDLE hProcess;
DWORD pId;
//Wait until the game it open before applying hacks and memory changes
while (!FFXIIWND)
{
SetConTAttribute(hConsole, cc_WARN, "Could not find FFXII, make sure the game is open!\nChecking again...\n");
FFXIIWND = findXII();
Sleep(3000);
}
SetConTAttribute(hConsole, cc_NORM);
//Attempt to open the process
GetWindowThreadProcessId(FFXIIWND, &pId);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
//Check the MD5 of the file; warn the user if it is awry; if it is a known MD5 of a stolen copy, report to the user that the program will not function at all.
std::ifstream gameExecutable;
std::string sMD5;
char executableFullPath[MAX_PATH];
long fSize;
GetModuleFileNameExA(hProcess, NULL, executableFullPath, MAX_PATH);
gameExecutable.open(executableFullPath, std::ios::binary | std::ios::in); gameExecutable.seekg(0, std::ios::end);
fSize = gameExecutable.tellg(); gameExecutable.seekg(0, std::ios::beg);
char* executableData = new char[fSize];
gameExecutable.read(executableData, fSize);
sMD5 = md5(executableData, fSize);
std::transform(sMD5.begin(), sMD5.end(), sMD5.begin(), ::toupper);
SetConTAttribute(hConsole, cc_WARN, "File MD5: ");
SetConTAttribute(hConsole, cc_VERBOSE, "%s\n", sMD5.c_str());
if (sMD5 == "D032914AC59BAFDD62F038832CC14525") //The MD5 of FFXII_TZA.exe from CPY
{
std::string yarrthatsmyshanty[] = {
"Yar! That\'s be me shanty!\n",
"Yar har har!\n",
"Being a pirate\'s alright to be!\n",
"Do what\'cha want \'cause a pirate is free!\n",
"You should be ashamed of yourself!\n", //Hehe Turok joke
"Take what you want, give nothing back!\n",
"Do what \'cha want \'cause a pirate is free!\n",
"If ye can’t trust a pirate, ye damn well can’t trust a merchant either!\n",
"Not all treasure is silver & gold!\n",
"Yar har fiddle dee dee\n",
"Yohoho that be a pirate\'s life for me!\n",
"I love this shanty!\n",
"Where there is a sea, there are pirates.\n",
"If ye thinks he be ready to sail a beauty, ye bett\'r be willin’ to sink with \'er!\n",
"Ahh shiver me timbers!\n",
"Keep calm and say Arrr\n",
"Avast thur be somethin\' awry...\n",
"All hands hoay; for today we\'ve a new crewmate!\n",
"Shiver me timbers- you\'re dancing the hempen jig!\n",
"I expected nothing more than hornswaggle matey!\n",
"\'es a landlubber, I swea\'!\n",
"Ah blimey cap\'n, we\'ve been caught!\n",
"Yarr today you feed the fish.\n",
"Heave ho! You can do better than that!\n",
"Yerr... not much old salt in ye...\n",
"Damned scallywag!\n",
"Cap\'n we\'ve been scuttled!\n",
"Yer\' sharkbait y\'hea?\n",
"Yo ho ho today ye\' walk the plank.\n",
"Yar har fiddle dee dee\nBeing a pirate is alright to be\nDo what \'cha want \'cause a pirate is free!\nYou are a pirate!\n"
};
size_t nShanties = yarrthatsmyshanty->size();
int cShanty;
int rError; //Fake error
srand(time(NULL)); Sleep(rand() % 2 * nShanties); srand(time(NULL)); //Randomness
rError = rand() % (999999999 - 100000000) + 9999999;
for (int i = 0; i < 8; i++) { rError += rand() % 99999999; srand(time(NULL)); }
cShanty = rand() % nShanties - 1;
SetConTAttribute(hConsole, cc_WARN, "\n\nError: "); //"Error" = warn
SetConTAttribute(hConsole, cc_ERROR, "0x%d\n", rError);
printf("0x%d\n", rError);
Sleep(rand() % 1333);
SetConTAttribute(hConsole, cc_FUN, "\n%s\n", yarrthatsmyshanty[cShanty].c_str());
for (;;) { Sleep(1); } //Infinite loop
}
//FFXII_TZA.exe from Steam
else if (sMD5 != "F88350D39C8EDEECC3728A4ABC89289C")
SetConTAttribute(hConsole, cc_VERBOSE, "Your file seems to be patched or updated. You may experience problems; if you experience issues please post them here: https://github.com/Drahsid/FFXIITZA-FPS-Unlocker/issues\n");
SetConTAttribute(hConsole, cc_VERBOSE, "Found FFXII Window at PID: %lu!\n", pId);
if (!hProcess) SetConTAttribute(hConsole, cc_ERROR, "Failed to open process...\n");
else
{
SetConTAttribute(hConsole, cc_VERBOSE);
//Overwriting instructions
/*if (!WriteProcessMemory(hProcess, (LPVOID)mouseUnlockPtr, "\x90\x90\x90\x90\x90\x90\x90\x90", 8, NULL))
failedToErase(0, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)mouseUnlockPtr0, "\x90\x90\x90\x90\x90\x90\x90\x90", 8, NULL))
failedToErase(1, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)igmUnlockPtr, "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90", 10, NULL))
failedToErase(2, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)igmUnlockPtr0, "\x90\x90\x90\x90\x90\x90\x90\x90", 8, NULL))
failedToErase(3, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)igmUnlockPtr1, "\x90\x90\x90\x90\x90\x90\x90\x90", 8, NULL))
failedToErase(5, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)igmUnlockPtr2, "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90", 10, NULL))
failedToErase(6, hConsole);
if (!WriteProcessMemory(hProcess, (LPVOID)fovUnlockPtr, "\x90\x90\x90\x90\x90\x90\x90", 7, NULL))
failedToErase(7, hConsole);*/
/*
nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop
movss xmm7, 0x01e160bc
nop, nop
This will be hard to find again
if (!WriteProcessMemory(hProcess, (LPVOID)actionAoeFixPtr, "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\xF3\x0F\x10\x3C\x25\xBC\x60\xE1\x01\x90\x90", 23, NULL))
failedToErase(9, hConsole);*/
/*
lea eax, [rcx+340h]
mov 0x1e160d4, eax
nop
if (!WriteProcessMemory(hProcess, (LPVOID)setAnimationRatePtr, "\x8D\x81\x40\x03\x00\x00\xA3\xD4\x60\xE1\x01\x00\x00\x00\x00\x90", 16, NULL));
failedToErase(10, hConsole);*/
if (!InjectDLL(hProcess, dllPath)) {
printf("Injection failure!\n");
for (;;) {}
}
CloseHandle(hProcess);
printf("Injection successful. This window will close itself in 10 seconds.\n");
Sleep(10000);
}
return 0;
}