-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame_executable_patcher.html
292 lines (246 loc) · 9.37 KB
/
game_executable_patcher.html
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<h1>GIANTS Engine game executable patcher</h1>
<hr>
<div id="container_fontRenderer">
<h2>Farming Simulator 2008/2009/2011/2013, Demolition Company & Ski Region Simulator 2012 FontRenderer Scaling Patch:</h1>
<table><thead>
<tr>
<td align='right'><b>Executable:</b></td>
<td><input type="file" id="fileInput_fontRenderer"/><br></td>
</tr>
<tr>
<td align='right'><b>Screen width (e.g 1920):</b></td>
<td><input type="text" id="width_fontRenderer" value="640"></td>
</tr>
<tr>
<td align='right'><b>Screen height (e.g 1080):</b></td>
<td><input type="text" id="height_fontRenderer" value="480"></td>
</tr>
<tr>
<td></td>
<td><button id="patch_fontRenderer" disabled>Patch (FarmingSimulator(2008|2009|2011|2013)|DemolitionCompany|SkiRegionSimulator2012)game.exe</button></td>
</tr>
</thead></table>
<br>
</div>
<hr>
<div id="container_CRC">
<h2>Farming Simulator 2011 dataS.gar CRC Patch:</h1>
<table><thead>
<tr>
<td align='right'><b>Executable:</b></td>
<td><input type="file" id="fileInput_CRC"/><br></td>
</tr>
<tr>
<td></td>
<td><button id="patch_CRC" disabled>Patch (FarmingSimulator2011)game.exe</button></td>
</tr>
</thead></table>
<br>
</div>
<hr>
<div id="container_DLC">
<h2>Farming Simulator 2011/2013, Demolition Company & Ski Region Simulator 2012 DLC Patch:</h1>
<table><thead>
<tr>
<td align='right'><b>Executable:</b></td>
<td><input type="file" id="fileInput_DLC"/><br></td>
</tr>
<tr>
<td></td>
<td><button id="patch_DLC" disabled>Patch (FarmingSimulator(2011|2013)|DemolitionCompany|SkiRegionSimulator2012)game.exe</button></td>
</tr>
</thead></table>
<br>
</div>
<hr>
<a href="http://biskupova.televiziastb.sk/">Morc</a> @ <a href="http://370.network">370network</a> & <a href="https://komeo.xyz/ls2009mods">LS 2009 Mods Archive</a>
<script>
// GIANTS Engine Patcher
// second revision of a javascript based patcher
// Richard Gráčik @ 370network ([email protected])
// LS Mods Community (https://komeo.xyz/ls2009mods)
// 29.01.2025 - initial patcher, LS2009 FontRenderer scaling patch
// 30.01.2025 - LS2011 dataS.gar CRC check patch
// 31.01.2025 - LS2011/SRS2012 DLC patch
// 05.02.2025 - DC DLC patch
// 06.02.2025 - LS2013 64bit FontRenderer patch, LS2013 64bit DLC patch
function hex(inputArray)
{
var hexString = '';
for (var i = 0; i < inputArray.length; i++) {
hexString += inputArray[i].toString(16).toUpperCase();
}
return hexString;
}
function findBytes(buffer, sequence) {
for (var i = 0; i < buffer.length - sequence.length + 1; i++) {
var match = true;
for (let j = 0; j < sequence.length; j++) {
if (buffer[i + j] !== sequence[j]) {
match = false;
break;
}
}
if (match)
return i;
}
return -1;
}
document.getElementById("fileInput_fontRenderer").addEventListener("change", (event) => {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = (e) => {
var arrayBuffer = e.target.result;
var gameExecutable = new Uint8Array(arrayBuffer);
var patchButton = document.getElementById("patch_fontRenderer");
var widthInput = document.getElementById("width_fontRenderer");
var heightInput = document.getElementById("height_fontRenderer");
patchButton.disabled = false;
patchButton.onclick = () => {
var widthOffset0811 = findBytes(gameExecutable, [0xC7, 0x06, 0x80, 0x02, 0x00, 0x00]);
var heightOffset0811 = findBytes(gameExecutable, [0xC7, 0x46, 0x04, 0xE0, 0x01, 0x00, 0x00]);
var widthOffset13_32bit = findBytes(gameExecutable, [0xC7, 0x03, 0x80, 0x02, 0x00, 0x00]);
var heightOffset13_32bit = findBytes(gameExecutable, [0xC7, 0x43, 0x04, 0xE0, 0x01, 0x00, 0x00]);
var widthOffset13_64bit = findBytes(gameExecutable, [0xC7, 0x07, 0x80, 0x02, 0x00, 0x00]);
var heightOffset13_64bit = findBytes(gameExecutable, [0xC7, 0x47, 0x04, 0xE0, 0x01, 0x00, 0x00]);
var game = "";
if (widthOffset0811 != -1 && heightOffset0811 != -1)
{
var widthPatchBase = [0xC7, 0x06];
var heightPatchBase = [0xC7, 0x46, 0x04];
var widthOffset = widthOffset0811;
var heightOffset = heightOffset0811;
game = "LS2008-2011,DC,SRS2012";
}
else if (widthOffset13_32bit != -1 && heightOffset13_32bit != -1)
{
var widthPatchBase = [0xC7, 0x03];
var heightPatchBase = [0xC7, 0x43, 0x04];
var widthOffset = widthOffset13_32bit;
var heightOffset = heightOffset13_32bit;
game = "LS2013_32bit";
}
else if (widthOffset13_64bit != -1 && heightOffset13_64bit != -1)
{
var widthPatchBase = [0xC7, 0x07];
var heightPatchBase = [0xC7, 0x47, 0x04];
var widthOffset = widthOffset13_64bit;
var heightOffset = heightOffset13_64bit;
game = "LS2013_64bit";
}
if (game == "")
alert(`Failed to find offsets, is your game executable already patched?`);
else
{
var widthPatchRes = [(widthInput.value >> 24) & 0xFF,(widthInput.value >> 16) & 0xFF, (widthInput.value >> 8) & 0xFF, widthInput.value & 0xFF];
var heightPatchRes = [(heightInput.value >> 24) & 0xFF,(heightInput.value >> 16) & 0xFF, (heightInput.value >> 8) & 0xFF, heightInput.value & 0xFF];
var widthPatch = widthPatchBase.concat(widthPatchRes.reverse());
var heightPatch = heightPatchBase.concat(heightPatchRes.reverse());
for (var i = 0; i < widthPatch.length; i++) {
gameExecutable[widthOffset + i] = widthPatch[i];
}
for (var i = 0; i < heightPatch.length; i++) {
gameExecutable[heightOffset + i] = heightPatch[i];
}
var patchedExecutable = new Blob([gameExecutable], { type: file.type });
var link = document.createElement("a");
link.textContent = "Click here if the patched executable didn't start downloading";
link.href = URL.createObjectURL(patchedExecutable);
link.download = `patched_${file.name}`;
document.getElementById("container_fontRenderer").appendChild(link);
link.click();
alert(`Found game: ${game}\nNew computed width: ${hex(widthPatchRes)}\nNew computed height: ${hex(heightPatchRes)}\nFontRenderer_00: ${widthOffset}\nFontRenderer_04: ${heightOffset}\nSuccess!`);
}
};
};
reader.readAsArrayBuffer(file);
});
document.getElementById("fileInput_CRC").addEventListener("change", (event) => {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = (e) => {
var arrayBuffer = e.target.result;
var gameExecutable = new Uint8Array(arrayBuffer);
var patchButton = document.getElementById("patch_CRC");
patchButton.disabled = false;
patchButton.onclick = () => {
var crcOffset = findBytes(gameExecutable, [0x68, 0xC0, 0x86, 0x5F, 0x00, 0x53]);
if (crcOffset == -1)
alert(`Failed to find offsets, is your game executable already patched?`);
else
{
for (var i = 0; i < 0x15; i++) {
gameExecutable[crcOffset + i] = 0x90;
}
var patchedExecutable = new Blob([gameExecutable], { type: file.type });
var link = document.createElement("a");
link.textContent = "Click here if the patched executable didn't start downloading";
link.href = URL.createObjectURL(patchedExecutable);
link.download = `patched_${file.name}`;
document.getElementById("container_CRC").appendChild(link);
link.click();
alert(`CopyProtection_00: ${crcOffset}\nSuccess!`);
}
};
};
reader.readAsArrayBuffer(file);
});
document.getElementById("fileInput_DLC").addEventListener("change", (event) => {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = (e) => {
var arrayBuffer = e.target.result;
var gameExecutable = new Uint8Array(arrayBuffer);
var patchButton = document.getElementById("patch_DLC");
patchButton.disabled = false;
patchButton.onclick = () => {
var LSSRSdlcOffset = findBytes(gameExecutable, [0x88, 0x5E, 0x44, 0x89, 0x5E, 0x48, 0x89, 0x5E, 0x4C]);
var DCdlcOffset = findBytes(gameExecutable, [0xF0, 0xFF, 0x88, 0x5E, 0x44]);
var LS201332bitdlcOffset = findBytes(gameExecutable, [0xC6, 0x46, 0x44, 0x00, 0xC7]);
var LS201364bitdlcOffset = findBytes(gameExecutable, [0xC6, 0x44, 0x24, 0x60, 0x00]);
var game = "";
if (LSSRSdlcOffset != -1)
{
var dlcPatch = [0x88, 0x4E, 0x44, 0x89, 0x4E, 0x48, 0x89, 0x4E, 0x4C];
var dlcOffset = LSSRSdlcOffset;
game = "LS2011,SRS2012";
}
else if (DCdlcOffset != -1)
{
var dlcPatch = [0xF0, 0xFF, 0x88, 0x4E, 0x44];
var dlcOffset = DCdlcOffset;
game = "DC";
}
else if (LS201332bitdlcOffset != -1)
{
var dlcPatch = [0xC6, 0x46, 0x44, 0xFF, 0xC7];
var dlcOffset = LS201332bitdlcOffset;
game = "LS2013_32bit";
}
else if (LS201364bitdlcOffset != -1)
{
var dlcPatch = [0xC6, 0x44, 0x24, 0x60, 0xFF];
var dlcOffset = LS201364bitdlcOffset;
game = "LS2013_64bit";
}
if (game == "")
alert(`Failed to find offsets, is your game executable already patched?`);
else
{
for (var i = 0; i < dlcPatch.length; i++) {
gameExecutable[dlcOffset + i] = dlcPatch[i];
}
var patchedExecutable = new Blob([gameExecutable], { type: file.type });
var link = document.createElement("a");
link.textContent = "Click here if the patched executable didn't start downloading";
link.href = URL.createObjectURL(patchedExecutable);
link.download = `patched_${file.name}`;
document.getElementById("container_DLC").appendChild(link);
link.click();
alert(`Found game: ${game}\nActivation_00: ${dlcOffset}\nSuccess!`);
}
};
};
reader.readAsArrayBuffer(file);
});
</script>