source: Daodan/MSVC/Daodan.c@ 568

Last change on this file since 568 was 567, checked in by gumby, 14 years ago

Daodan MSVC

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