1 | #include <string.h>
|
---|
2 |
|
---|
3 | #include "Daodan.h"
|
---|
4 | #include "Daodan_Patch.h"
|
---|
5 | #include "Daodan_Utility.h"
|
---|
6 | #include "Daodan_Win32.h"
|
---|
7 | #include "Daodan_Cheater.h"
|
---|
8 | #include "Daodan_Persistence.h"
|
---|
9 | #include "Daodan_BSL.h"
|
---|
10 | #include "Daodan_Console.h"
|
---|
11 |
|
---|
12 | #include "Flatline_BSL.h"
|
---|
13 | #include "Flatline_Hooks.h"
|
---|
14 | #include "Daodan_WindowHack.h"
|
---|
15 |
|
---|
16 | #include "Oni.h"
|
---|
17 | #include "Oni_Persistence.h"
|
---|
18 |
|
---|
19 | #include "BFW_Utility.h"
|
---|
20 |
|
---|
21 | #include "oni_gl.h"
|
---|
22 | #include "daodan_gl.h"
|
---|
23 |
|
---|
24 | #include "inifile.h"
|
---|
25 |
|
---|
26 | HMODULE DDrDLLModule;
|
---|
27 | HMODULE DDrONiModule;
|
---|
28 |
|
---|
29 | bool patch_fonttexturecache = true;
|
---|
30 | bool patch_largetextures = true;
|
---|
31 | bool patch_levelplugins = true;
|
---|
32 | bool patch_pathfinding = true;
|
---|
33 | bool patch_projaware = true;
|
---|
34 | bool patch_directinput = true;
|
---|
35 | bool patch_wpfadetime = true;
|
---|
36 | bool patch_kickguns = false;
|
---|
37 | bool patch_cooldowntimer = true;
|
---|
38 | bool patch_throwtest = false;
|
---|
39 | bool patch_alttab = true;
|
---|
40 | bool patch_particledisablebit = false;
|
---|
41 | bool patch_multibyte = false;
|
---|
42 | bool patch_cheattable = true;
|
---|
43 | bool patch_argb8888 = true;
|
---|
44 | bool patch_killvtune = true;
|
---|
45 | bool patch_getcmdline = true;
|
---|
46 | bool patch_disablecmdline = true;
|
---|
47 |
|
---|
48 | bool patch_safeprintf = true;
|
---|
49 | bool patch_daodandisplayenum = true;
|
---|
50 | bool patch_usegettickcount = true;
|
---|
51 | bool patch_cheatsenabled = true;
|
---|
52 | bool patch_usedaodangl = true;
|
---|
53 | bool patch_windowhack = false;
|
---|
54 | bool patch_daodaninit = true;
|
---|
55 | bool patch_bsl = true;
|
---|
56 | bool patch_cheater = true;
|
---|
57 | bool patch_newweapon = true;
|
---|
58 | bool opt_usedaodanbsl = true;
|
---|
59 | bool opt_border = true;
|
---|
60 | bool opt_shadow = false;
|
---|
61 | bool opt_topmost = false;
|
---|
62 |
|
---|
63 | bool DDrPatch_Init()
|
---|
64 | {
|
---|
65 | DDrStartupMessage("patching engine");
|
---|
66 |
|
---|
67 | // Font texture cache doubled
|
---|
68 | if (patch_fonttexturecache)
|
---|
69 | {
|
---|
70 | DDrPatch_Byte(OniExe + 0x00020ea7, 0x20);
|
---|
71 | DDrPatch_Byte(OniExe + 0x00020f4a, 0x40);
|
---|
72 | }
|
---|
73 |
|
---|
74 | // Now supports textures up to 512x512
|
---|
75 | if (patch_largetextures)
|
---|
76 | DDrPatch_Byte (OniExe + 0x00005251, 0x10);
|
---|
77 |
|
---|
78 | // Non-"_Final" levels are now valid
|
---|
79 | if (patch_levelplugins)
|
---|
80 | DDrPatch_Byte (OniExe + 0x000206a8, 0x01);
|
---|
81 |
|
---|
82 | // Pathfinding grid cache size x8
|
---|
83 | if (patch_pathfinding)
|
---|
84 | {
|
---|
85 | const char pathfinding[2] = {0x90 , 0xE9 };
|
---|
86 | DDrPatch_Byte (OniExe + 0x0010b03b, 0x20);
|
---|
87 | DDrPatch_Byte (OniExe + 0x0010b04c, 0x20);
|
---|
88 |
|
---|
89 | //other stuff
|
---|
90 | DDrPatch_Const(0x440789, pathfinding);
|
---|
91 | }
|
---|
92 |
|
---|
93 | // Projectile awareness fixed
|
---|
94 | if (patch_projaware)
|
---|
95 | {
|
---|
96 | DDrPatch_Byte (OniExe + 0x0009c07c, 0x6c);
|
---|
97 | DDrPatch_Byte (OniExe + 0x0009c080, 0x70);
|
---|
98 | DDrPatch_Byte (OniExe + 0x0009c084, 0x74);
|
---|
99 | DDrPatch_Byte (OniExe + 0x0009c110, 0x6c);
|
---|
100 | }
|
---|
101 |
|
---|
102 | // Forced DirectInput (for Windows NT)
|
---|
103 | if (patch_directinput)
|
---|
104 | DDrPatch_Byte (OniExe + 0x00002e6d, 0xeb);
|
---|
105 |
|
---|
106 | if (patch_wpfadetime)
|
---|
107 | {
|
---|
108 | // Makes wp_fadetime actually have a function
|
---|
109 | const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
|
---|
110 | DDrPatch_Const (OniExe + 0x0011a889, fadetime_patch);
|
---|
111 | DDrPatch_Byte (OniExe + 0x0011a560, 0x31);
|
---|
112 |
|
---|
113 | // Sets the fadetime to 4800 by default
|
---|
114 | DDrPatch_Int16 ((OniExe + 0x0011ab0e), 0x12c0);
|
---|
115 | }
|
---|
116 |
|
---|
117 | // FIXME: add switches
|
---|
118 | //pathfinding fix
|
---|
119 |
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 | // Hackish fix for Konoko not kicking guns
|
---|
124 | // Don't use this, it breaks stairs.
|
---|
125 | if (patch_kickguns)
|
---|
126 | {
|
---|
127 | const char kickgun_patch[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0xC7, 0x05, 0x1C, 0xC9, 0x5E, 0x00, 0x70, 0xB8, 0x43, 0x00, 0xC7, 0x05, 0x20, 0xC9, 0x5E, 0x00, 0x20, 0xBE, 0x43 };
|
---|
128 | DDrPatch_Const (OniExe + 0x000dc420, kickgun_patch);
|
---|
129 | }
|
---|
130 |
|
---|
131 | // Cooldown timer exploit fix ^_^
|
---|
132 | if (patch_cooldowntimer)
|
---|
133 | {
|
---|
134 | const char cooldown_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
|
---|
135 | DDrPatch_Const (OniExe + 0x0011a825, cooldown_patch);
|
---|
136 | }
|
---|
137 |
|
---|
138 | if (patch_throwtest)
|
---|
139 | {
|
---|
140 | const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
|
---|
141 | DDrPatch_Const(OniExe + 0x000dc190, throwtest_patch);
|
---|
142 | }
|
---|
143 |
|
---|
144 | // Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the Windows key but has the possible side effect of allowing the screensaver to enable itself in-game.
|
---|
145 | if (patch_alttab)
|
---|
146 | {
|
---|
147 | DDrPatch_Byte ((void*)UUrPlatform_Initialize, 0xC3);
|
---|
148 | DDrPatch_Byte ((void*)UUrPlatform_Terminate, 0xC3);
|
---|
149 | }
|
---|
150 |
|
---|
151 | // Unlocks particle action disabling/enabling bits for all events. (Will be controlled by a command line switch when I figure out how to do that without Win32 hacks.)
|
---|
152 | if (patch_particledisablebit)
|
---|
153 | DDrPatch_Int16 (OniExe + 0x001b184, 0x9090);
|
---|
154 |
|
---|
155 | // Multi-byte patch (multiple language support)
|
---|
156 | if (!patch_multibyte)
|
---|
157 | {
|
---|
158 | DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb);
|
---|
159 | DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb);
|
---|
160 | DDrPatch_Byte (OniExe + 0x0002dbe2, 0xeb);
|
---|
161 | DDrPatch_Byte (OniExe + 0x0002dec3, 0xeb);
|
---|
162 | DDrPatch_Byte (OniExe + 0x0002e2ab, 0xeb);
|
---|
163 | DDrPatch_Byte (OniExe + 0x0002e2c4, 0xeb);
|
---|
164 | DDrPatch_Byte (OniExe + 0x0002e379, 0xeb);
|
---|
165 | DDrPatch_Byte (OniExe + 0x0002e48c, 0xeb);
|
---|
166 | DDrPatch_Byte (OniExe + 0x0002e4d0, 0xeb);
|
---|
167 | DDrPatch_Byte (OniExe + 0x0002e4f4, 0xeb);
|
---|
168 | DDrPatch_Byte (OniExe + 0x0002e646, 0xeb);
|
---|
169 | DDrPatch_Byte (OniExe + 0x0002e695, 0xeb);
|
---|
170 | DDrPatch_Byte (OniExe + 0x0002e944, 0xeb);
|
---|
171 | DDrPatch_Byte (OniExe + 0x0002e95d, 0xeb);
|
---|
172 | DDrPatch_Byte (OniExe + 0x0002e98e, 0xeb);
|
---|
173 | DDrPatch_Byte (OniExe + 0x0002e9dc, 0xeb);
|
---|
174 | }
|
---|
175 |
|
---|
176 | // Cheat table patch
|
---|
177 | if (patch_cheattable)
|
---|
178 | {
|
---|
179 | DDrPatch_Int32 (0x004f616b, (int)&DDr_CheatTable[0].name);
|
---|
180 | DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
|
---|
181 | }
|
---|
182 |
|
---|
183 | // ARGB8888 textures
|
---|
184 | if (patch_argb8888)
|
---|
185 | {
|
---|
186 | DDrPatch_Byte (OniExe + 0x00135af0, 0x07);
|
---|
187 | DDrPatch_Byte (OniExe + 0x00135af4, 0x0B);
|
---|
188 | }
|
---|
189 |
|
---|
190 | //Test newweap patch
|
---|
191 | if (patch_newweapon) {
|
---|
192 |
|
---|
193 | //Makes it always say "Recieved weapon_name."
|
---|
194 | //Needs check for loc_4DFC66
|
---|
195 | //DDrPatch_NOOP( OniExe + 0x000E4DF8,2);
|
---|
196 |
|
---|
197 | //Adds Weapon name and ammo meter to pickup autoprompt
|
---|
198 | DDrPatch_NOOP( OniExe + 0x000FAC73, 9);
|
---|
199 | DDrPatch_NOOP( OniExe + 0x000FAC80, 5);
|
---|
200 | DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message);
|
---|
201 |
|
---|
202 | //Moves location of colors
|
---|
203 | //DDrPatch_Int32( 0x0042E3D5, (int)&DDrDSayColors );
|
---|
204 | //DDrPatch_Int32( 0x0042E3DA, (int)&DDrDSayColors );
|
---|
205 | }
|
---|
206 |
|
---|
207 | // Disable loading the vtuneapi.dll
|
---|
208 | if (patch_killvtune)
|
---|
209 | DDrPatch_Byte (OniExe + 0x00026340, 0xC3);
|
---|
210 |
|
---|
211 | // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
|
---|
212 | if (patch_getcmdline)
|
---|
213 | DDrPatch_NOOP (OniExe + 0x000d3280, 51);
|
---|
214 |
|
---|
215 | // Disable Oni's command line parser so it doesn't interfere with ours
|
---|
216 | if (patch_disablecmdline)
|
---|
217 | DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
|
---|
218 |
|
---|
219 | if (patch_bsl)
|
---|
220 | {
|
---|
221 | //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
|
---|
222 |
|
---|
223 | //TODO: fix moonshadow.
|
---|
224 | Character * Chr = 0;
|
---|
225 | int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
|
---|
226 | const char regen_patch[] =
|
---|
227 | {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP
|
---|
228 | 0x90, 0x90, // test al, al -> NOOP
|
---|
229 | 0x90, 0x90, // jz short loc_51BB98 -> NOOP
|
---|
230 | 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8]
|
---|
231 | // -> mov eax, [esi+Character.RegenHax]
|
---|
232 | 0x85, 0xC0, // test eax, eax
|
---|
233 | 0x74, 0x21 // jnz 0x21 -> jz 0x21
|
---|
234 | };
|
---|
235 | DDrPatch_Const(0x0051BB64, regen_patch);
|
---|
236 | }
|
---|
237 | DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook);
|
---|
238 | DDrPatch_Int32( 0x004B24D2, FLrSpawnHack);
|
---|
239 | DDrPatch_NOOP(0x004C26CB, 6);
|
---|
240 | DDrPatch_MakeCall( 0x004C26CB, FLrHook_DoorOpen);
|
---|
241 |
|
---|
242 | return true;
|
---|
243 | }
|
---|
244 |
|
---|
245 | enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
|
---|
246 |
|
---|
247 | bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
|
---|
248 | {
|
---|
249 | if (newsection)
|
---|
250 | {
|
---|
251 | if (!_stricmp(section, "options"))
|
---|
252 | ini_section = s_options;
|
---|
253 | else if (!_stricmp(section, "patch"))
|
---|
254 | ini_section = s_patch;
|
---|
255 | else if (!_stricmp(section, "bsl"))
|
---|
256 | ini_section = s_bsl;
|
---|
257 | else if (!_stricmp(section, "language"))
|
---|
258 | ini_section = s_language;
|
---|
259 | else
|
---|
260 | {
|
---|
261 | ini_section = s_unknown;
|
---|
262 | DDrStartupMessage("unrecognised section \"%s\"", section);
|
---|
263 | }
|
---|
264 | }
|
---|
265 |
|
---|
266 | switch (ini_section)
|
---|
267 | {
|
---|
268 | case s_options:
|
---|
269 | if (!_stricmp(name, "usedaodanbsl"))
|
---|
270 | opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
271 | else if (!_stricmp(name, "border"))
|
---|
272 | opt_border = !_stricmp(inifile_cleanstr(value), "true");
|
---|
273 | else if (!_stricmp(name, "shadow"))
|
---|
274 | opt_shadow = !_stricmp(inifile_cleanstr(value), "true");
|
---|
275 | else if (!_stricmp(name, "topmost"))
|
---|
276 | opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
|
---|
277 | else if (!_stricmp(name, "multibyte"))
|
---|
278 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
279 | else if (!_stricmp(name, "debug"))
|
---|
280 | AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true");
|
---|
281 | else if (!_stricmp(name, "debugfiles"))
|
---|
282 | BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
283 | else if (!_stricmp(name, "findsounds"))
|
---|
284 | SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true");
|
---|
285 | else if (!_stricmp(name, "ignore_private_data"))
|
---|
286 | opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true");
|
---|
287 | else if (!_stricmp(name, "sound"))
|
---|
288 | opt_sound = !_stricmp(inifile_cleanstr(value), "true");
|
---|
289 | else if (!_stricmp(name, "switch"))
|
---|
290 | M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
|
---|
291 | //else if (!_stricmp(name, "devmode"))
|
---|
292 | //turn_dev_mode_on = !_stricmp(inifile_cleanstr(value), "true");
|
---|
293 | else
|
---|
294 | DDrStartupMessage("unrecognised option \"%s\"", name);
|
---|
295 | break;
|
---|
296 | case s_patch:
|
---|
297 | if (!_stricmp(name, "fonttexturecache"))
|
---|
298 | patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true");
|
---|
299 | else if (!_stricmp(name, "largetextures"))
|
---|
300 | patch_largetextures = !_stricmp(inifile_cleanstr(value), "true");
|
---|
301 | else if (!_stricmp(name, "levelplugins"))
|
---|
302 | patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true");
|
---|
303 | else if (!_stricmp(name, "pathfinding"))
|
---|
304 | patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true");
|
---|
305 | else if (!_stricmp(name, "projaware"))
|
---|
306 | patch_projaware = !_stricmp(inifile_cleanstr(value), "true");
|
---|
307 | else if (!_stricmp(name, "directinput"))
|
---|
308 | patch_directinput = !_stricmp(inifile_cleanstr(value), "true");
|
---|
309 | else if (!_stricmp(name, "wpfadetime"))
|
---|
310 | patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true");
|
---|
311 | else if (!_stricmp(name, "kickguns"))
|
---|
312 | patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
|
---|
313 | else if (!_stricmp(name, "cooldowntimer"))
|
---|
314 | patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true");
|
---|
315 | else if (!_stricmp(name, "throwtest"))
|
---|
316 | patch_throwtest = !_stricmp(inifile_cleanstr(value), "true");
|
---|
317 | else if (!_stricmp(name, "alttab"))
|
---|
318 | patch_alttab = !_stricmp(inifile_cleanstr(value), "true");
|
---|
319 | else if (!_stricmp(name, "particledisablebit"))
|
---|
320 | patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
321 | else if (!_stricmp(name, "multibyte"))
|
---|
322 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
323 | else if (!_stricmp(name, "cheattable"))
|
---|
324 | patch_cheattable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
325 | else if (!_stricmp(name, "argb8888"))
|
---|
326 | patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true");
|
---|
327 | else if (!_stricmp(name, "killvtune"))
|
---|
328 | patch_killvtune = !_stricmp(inifile_cleanstr(value), "true");
|
---|
329 | else if (!_stricmp(name, "getcmdline"))
|
---|
330 | patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
331 | else if (!_stricmp(name, "disablecmdline"))
|
---|
332 | patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
333 | else if (!_stricmp(name, "safeprintf"))
|
---|
334 | patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true");
|
---|
335 | else if (!_stricmp(name, "daodandisplayenum"))
|
---|
336 | patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true");
|
---|
337 | else if (!_stricmp(name, "usegettickcount"))
|
---|
338 | patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true");
|
---|
339 | else if (!_stricmp(name, "cheatsenabled"))
|
---|
340 | patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
|
---|
341 | else if (!_stricmp(name, "usedaodangl"))
|
---|
342 | patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
343 | else if (!_stricmp(name, "windowhack"))
|
---|
344 | patch_windowhack = !_stricmp(inifile_cleanstr(value), "true");
|
---|
345 | else if (!_stricmp(name, "daodaninit"))
|
---|
346 | patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
347 | else if (!_stricmp(name, "bsl"))
|
---|
348 | patch_bsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
349 | else if (!_stricmp(name, "cheater"))
|
---|
350 | patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
|
---|
351 | else if (!_stricmp(name, "newweap"))
|
---|
352 | patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
|
---|
353 | else
|
---|
354 | DDrStartupMessage("unrecognised patch \"%s\"", name);
|
---|
355 | break;
|
---|
356 | case s_language:
|
---|
357 | if (!_stricmp(name, "savepoint"))
|
---|
358 | {
|
---|
359 | char* str = _strdup(value);
|
---|
360 | DDrPatch_Int32(OniExe + 0x000fd730, (int)str);
|
---|
361 | DDrPatch_Int32(OniExe + 0x000fd738, (int)str);
|
---|
362 | }
|
---|
363 | else if (!_stricmp(name, "syndicatewarehouse"))
|
---|
364 | {
|
---|
365 | char* str = _strdup(value);
|
---|
366 | DDrPatch_Int32(OniExe + 0x000fd71a, (int)str);
|
---|
367 | DDrPatch_Int32(OniExe + 0x0010ef75, (int)str);
|
---|
368 | }
|
---|
369 | else if (!_stricmp(name, "damn"))
|
---|
370 | DDrPatch__strdup(OniExe + 0x0010fb6e, value);
|
---|
371 | else if (!_stricmp(name, "blam"))
|
---|
372 | DDrPatch__strdup(OniExe + 0x0010fb73, value);
|
---|
373 | else if (!_stricmp(name, "shapeshifter_on"))
|
---|
374 | DDr_CheatTable[0].message_on = _strdup(value);
|
---|
375 | else if (!_stricmp(name, "shapeshifter_off"))
|
---|
376 | DDr_CheatTable[0].message_off = _strdup(value);
|
---|
377 | else if (!_stricmp(name, "liveforever_on"))
|
---|
378 | DDr_CheatTable[1].message_on = _strdup(value);
|
---|
379 | else if (!_stricmp(name, "liveforever_off"))
|
---|
380 | DDr_CheatTable[1].message_off = _strdup(value);
|
---|
381 | else if (!_stricmp(name, "touchofdeath_on"))
|
---|
382 | DDr_CheatTable[2].message_on = _strdup(value);
|
---|
383 | else if (!_stricmp(name, "touchofdeath_off"))
|
---|
384 | DDr_CheatTable[2].message_off = _strdup(value);
|
---|
385 | else if (!_stricmp(name, "canttouchthis_on"))
|
---|
386 | DDr_CheatTable[3].message_on = _strdup(value);
|
---|
387 | else if (!_stricmp(name, "canttouchthis_off"))
|
---|
388 | DDr_CheatTable[3].message_off = _strdup(value);
|
---|
389 | else if (!_stricmp(name, "fatloot_on"))
|
---|
390 | DDr_CheatTable[4].message_on = _strdup(value);
|
---|
391 | else if (!_stricmp(name, "glassworld_on"))
|
---|
392 | DDr_CheatTable[5].message_on = _strdup(value);
|
---|
393 | else if (!_stricmp(name, "glassworld_off"))
|
---|
394 | DDr_CheatTable[5].message_off = _strdup(value);
|
---|
395 | else if (!_stricmp(name, "winlevel_on"))
|
---|
396 | DDr_CheatTable[6].message_on = _strdup(value);
|
---|
397 | else if (!_stricmp(name, "loselevel_on"))
|
---|
398 | DDr_CheatTable[7].message_on = _strdup(value);
|
---|
399 | else if (!_stricmp(name, "bighead_on"))
|
---|
400 | DDr_CheatTable[8].message_on = _strdup(value);
|
---|
401 | else if (!_stricmp(name, "bighead_off"))
|
---|
402 | DDr_CheatTable[8].message_off = _strdup(value);
|
---|
403 | else if (!_stricmp(name, "minime_on"))
|
---|
404 | DDr_CheatTable[9].message_on = _strdup(value);
|
---|
405 | else if (!_stricmp(name, "minime_off"))
|
---|
406 | DDr_CheatTable[9].message_off = _strdup(value);
|
---|
407 | else if (!_stricmp(name, "superammo_on"))
|
---|
408 | DDr_CheatTable[10].message_on = _strdup(value);
|
---|
409 | else if (!_stricmp(name, "superammo_off"))
|
---|
410 | DDr_CheatTable[10].message_off = _strdup(value);
|
---|
411 | else if (!_stricmp(name, "devmode_on"))
|
---|
412 | {
|
---|
413 | char* str = _strdup(value);
|
---|
414 | DDr_CheatTable[11].message_on = str;
|
---|
415 | DDr_CheatTable[cheat_x].message_on = str;
|
---|
416 | }
|
---|
417 | else if (!_stricmp(name, "devmode_off"))
|
---|
418 | {
|
---|
419 | char* str = _strdup(value);
|
---|
420 | DDr_CheatTable[11].message_off = str;
|
---|
421 | DDr_CheatTable[cheat_x].message_off = str;
|
---|
422 | }
|
---|
423 | else if (!_stricmp(name, "reservoirdogs_on"))
|
---|
424 | DDr_CheatTable[12].message_on = _strdup(value);
|
---|
425 | else if (!_stricmp(name, "reservoirdogs_off"))
|
---|
426 | DDr_CheatTable[12].message_off = _strdup(value);
|
---|
427 | else if (!_stricmp(name, "roughjustice_on"))
|
---|
428 | DDr_CheatTable[13].message_on = _strdup(value);
|
---|
429 | else if (!_stricmp(name, "roughjustice_off"))
|
---|
430 | DDr_CheatTable[13].message_off = _strdup(value);
|
---|
431 | else if (!_stricmp(name, "chenille_on"))
|
---|
432 | DDr_CheatTable[14].message_on = _strdup(value);
|
---|
433 | else if (!_stricmp(name, "chenille_off"))
|
---|
434 | DDr_CheatTable[14].message_off = _strdup(value);
|
---|
435 | else if (!_stricmp(name, "behemoth_on"))
|
---|
436 | DDr_CheatTable[15].message_on = _strdup(value);
|
---|
437 | else if (!_stricmp(name, "behemoth_off"))
|
---|
438 | DDr_CheatTable[15].message_off = _strdup(value);
|
---|
439 | else if (!_stricmp(name, "elderrune_on"))
|
---|
440 | DDr_CheatTable[16].message_on = _strdup(value);
|
---|
441 | else if (!_stricmp(name, "elderrune_off"))
|
---|
442 | DDr_CheatTable[16].message_off = _strdup(value);
|
---|
443 | else if (!_stricmp(name, "moonshadow_on"))
|
---|
444 | DDr_CheatTable[17].message_on = _strdup(value);
|
---|
445 | else if (!_stricmp(name, "moonshadow_off"))
|
---|
446 | DDr_CheatTable[17].message_off = _strdup(value);
|
---|
447 | else if (!_stricmp(name, "munitionfrenzy_on"))
|
---|
448 | DDr_CheatTable[18].message_on = _strdup(value);
|
---|
449 | else if (!_stricmp(name, "fistsoflegend_on"))
|
---|
450 | DDr_CheatTable[19].message_on = _strdup(value);
|
---|
451 | else if (!_stricmp(name, "fistsoflegend_off"))
|
---|
452 | DDr_CheatTable[19].message_off = _strdup(value);
|
---|
453 | else if (!_stricmp(name, "killmequick_on"))
|
---|
454 | DDr_CheatTable[20].message_on = _strdup(value);
|
---|
455 | else if (!_stricmp(name, "killmequick_off"))
|
---|
456 | DDr_CheatTable[20].message_off = _strdup(value);
|
---|
457 | else if (!_stricmp(name, "carousel_on"))
|
---|
458 | DDr_CheatTable[21].message_on = _strdup(value);
|
---|
459 | else if (!_stricmp(name, "carousel_off"))
|
---|
460 | DDr_CheatTable[21].message_off = _strdup(value);
|
---|
461 | else
|
---|
462 | DDrStartupMessage("unrecognised language item \"%s\"", name);
|
---|
463 | break;
|
---|
464 | case s_bsl:
|
---|
465 | default:
|
---|
466 | break;
|
---|
467 | }
|
---|
468 |
|
---|
469 | return true;
|
---|
470 | }
|
---|
471 |
|
---|
472 | void DDrConfig()
|
---|
473 | {
|
---|
474 |
|
---|
475 | if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
|
---|
476 | {
|
---|
477 | FILE* fp;
|
---|
478 | DDrStartupMessage("daodan.ini doesn't exist, creating");
|
---|
479 | fp = fopen("daodan.ini", "w");
|
---|
480 | if (fp)
|
---|
481 | {
|
---|
482 | fputs("[Options]\n", fp);
|
---|
483 | fclose(fp);
|
---|
484 | }
|
---|
485 | }
|
---|
486 |
|
---|
487 | DDrStartupMessage("parsing daodan.ini...");
|
---|
488 | if (!inifile_read("daodan.ini", DDrIniCallback))
|
---|
489 | DDrStartupMessage("error reading daodan.ini, check your syntax!");
|
---|
490 | DDrStartupMessage("finished parsing");
|
---|
491 | }
|
---|
492 |
|
---|
493 | void ONICALL DDrGame_Init()
|
---|
494 | {
|
---|
495 | if (opt_usedaodanbsl)
|
---|
496 | SLrDaodan_Initalize();
|
---|
497 | }
|
---|
498 |
|
---|
499 | void DDrException() {
|
---|
500 | int* i = 0;
|
---|
501 | *i = 1;
|
---|
502 | }
|
---|
503 | #include <stdio.h>
|
---|
504 |
|
---|
505 | //this was broken
|
---|
506 | FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
|
---|
507 | FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
|
---|
508 | {
|
---|
509 |
|
---|
510 | FILE *v4; // eax@1
|
---|
511 | FILE *result; // eax@4
|
---|
512 | char v6[512]; // [sp+0h] [bp-100h]@1
|
---|
513 | FILE* UUgError_WarningFile = *_UUgError_WarningFile;
|
---|
514 | sprintf_s(
|
---|
515 | v6, 512,
|
---|
516 | "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
|
---|
517 | errornum,
|
---|
518 | filename,
|
---|
519 | linenumber,
|
---|
520 | message);
|
---|
521 |
|
---|
522 | if ( UUgError_WarningFile
|
---|
523 | || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
|
---|
524 | {
|
---|
525 | oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
|
---|
526 | oni_fflush(UUgError_WarningFile);
|
---|
527 | }
|
---|
528 | //oni_fprintf(stdout, v6);
|
---|
529 | //sprintf(&v6, "%s", message);
|
---|
530 | *_UUgError_WarningFile = UUgError_WarningFile;
|
---|
531 | result = UUgError_WarningFile;
|
---|
532 | return result;
|
---|
533 | }
|
---|
534 |
|
---|
535 | void __cdecl DDrMain(int argc, char* argv[])
|
---|
536 | {
|
---|
537 | int i;
|
---|
538 | char* section;
|
---|
539 | char* option;
|
---|
540 | bool falseoption;
|
---|
541 |
|
---|
542 | DDrStartupMessage("daodan attached!");
|
---|
543 |
|
---|
544 | opt_ignore_private_data = false;
|
---|
545 | opt_sound = true;
|
---|
546 |
|
---|
547 | DDrConfig();
|
---|
548 | DDrStartupMessage("parsing command line...");
|
---|
549 | for (i = 1; i < argc; i ++)
|
---|
550 | {
|
---|
551 | if (argv[i][0] == '-')
|
---|
552 | {
|
---|
553 | section = argv[i] + 1;
|
---|
554 | if ((option = strchr(argv[i], '.')))
|
---|
555 | {
|
---|
556 | *option = '\0';
|
---|
557 | falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
|
---|
558 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
559 | DDrIniCallback(section, true, option + 1, argv[++i]);
|
---|
560 | else
|
---|
561 | DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
|
---|
562 | *option = '.';
|
---|
563 | }
|
---|
564 | else
|
---|
565 | {
|
---|
566 | falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
|
---|
567 | ini_section = s_options;
|
---|
568 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
569 | DDrIniCallback(NULL, false, section, argv[++i]);
|
---|
570 | else
|
---|
571 | DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
|
---|
572 | }
|
---|
573 | }
|
---|
574 | else
|
---|
575 | {
|
---|
576 | DDrStartupMessage("parse error \"%s\"", argv[i]);
|
---|
577 | break;
|
---|
578 | }
|
---|
579 | }
|
---|
580 | DDrStartupMessage("finished parsing");
|
---|
581 | DDrPatch_Init();
|
---|
582 |
|
---|
583 | // Safe startup message printer
|
---|
584 | if (patch_safeprintf)
|
---|
585 | DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
|
---|
586 |
|
---|
587 | // Daodan device mode enumeration function
|
---|
588 | if (patch_daodandisplayenum)
|
---|
589 | DDrPatch_MakeJump(gl_enumerate_valid_display_modes, daodan_enumerate_valid_display_modes);
|
---|
590 |
|
---|
591 | // Performance patch
|
---|
592 | if (patch_usegettickcount)
|
---|
593 | {
|
---|
594 | DDrPatch_MakeJump(UUrMachineTime_High, DDrMachineTime_High);
|
---|
595 | DDrPatch_MakeJump(UUrMachineTime_High_Frequency, DDrMachineTime_High_Frequency);
|
---|
596 | DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
|
---|
597 | }
|
---|
598 |
|
---|
599 | // Cheats always enabled
|
---|
600 | if (patch_cheatsenabled)
|
---|
601 | DDrPatch_MakeJump(ONrPersist_GetWonGame, DDrPersist_GetWonGame);
|
---|
602 |
|
---|
603 | // Windowed mode
|
---|
604 | if (patch_usedaodangl)
|
---|
605 | {
|
---|
606 | DDrPatch_NOOP((char*)0x004032B7, 6);
|
---|
607 | DDrPatch_MakeCall((char*)0x004032B7, LIiP_SetCursorPosHook);
|
---|
608 |
|
---|
609 | DDrPatch_NOOP((char*)0x00403349, 6);
|
---|
610 | DDrPatch_MakeCall((char*)0x00403349, LIiP_SetCursorPosHook);
|
---|
611 | DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
|
---|
612 | DDrPatch_MakeJump(gl_platform_initialize, daodangl_platform_initialize);
|
---|
613 | }
|
---|
614 | // Hacked windowed mode (for when daodangl isn't working properly)
|
---|
615 | else if (patch_windowhack)
|
---|
616 | DDrWindowHack_Install();
|
---|
617 |
|
---|
618 | if (patch_daodaninit)
|
---|
619 | DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init);
|
---|
620 |
|
---|
621 | // Patches for existing BSL functions
|
---|
622 | if (patch_bsl)
|
---|
623 | SLrDaodan_Patch();
|
---|
624 |
|
---|
625 | if (patch_cheater)
|
---|
626 | {
|
---|
627 | DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
|
---|
628 | DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
|
---|
629 | #if 0
|
---|
630 | DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
|
---|
631 | #endif
|
---|
632 | DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
|
---|
633 | }
|
---|
634 |
|
---|
635 | //DDrPatch_MakeJump(0x004378c0, DDrException);
|
---|
636 | DDrPatch_MakeJump(0x004245A0, DDrPrintWarning);
|
---|
637 | //init_daodan_gl();
|
---|
638 |
|
---|
639 | ONiMain(argc, argv);
|
---|
640 | }
|
---|
641 | /*
|
---|
642 | void DDrWrongExe()
|
---|
643 | {
|
---|
644 | switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
|
---|
645 | "Click OK for more information. To continue using Oni without the patch, replace the downloaded binkw32.dll with the original.", "Daodan", MB_OKCANCEL | MB_ICONERROR))
|
---|
646 | {
|
---|
647 | case IDOK:
|
---|
648 | {
|
---|
649 | STARTUPINFO si;
|
---|
650 | PROCESS_INFORMATION pi;
|
---|
651 | FillMemory(&si, 0, sizeof(si));
|
---|
652 | FillMemory(&pi, 0, sizeof(pi));
|
---|
653 | si.cb = sizeof(si);
|
---|
654 | if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
---|
655 | MessageBox(NULL, "", "", 0);
|
---|
656 | CloseHandle(pi.hProcess);
|
---|
657 | CloseHandle(pi.hThread);
|
---|
658 | }
|
---|
659 | default:
|
---|
660 | ExitProcess(0);
|
---|
661 | }
|
---|
662 | }
|
---|
663 | */
|
---|
664 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
---|
665 | {
|
---|
666 | switch (fdwReason)
|
---|
667 | {
|
---|
668 | case DLL_PROCESS_ATTACH:
|
---|
669 | DDrDLLModule = hinstDLL;
|
---|
670 | DDrONiModule = GetModuleHandle(NULL);
|
---|
671 |
|
---|
672 | if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
|
---|
673 | DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
|
---|
674 | else
|
---|
675 | ExitProcess(0);
|
---|
676 | break;
|
---|
677 | }
|
---|
678 | return TRUE;
|
---|
679 | }
|
---|