ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan.c
(Generate patch)

Comparing Daodan/src/Daodan.c (file contents):
Revision 451 by rossy, Sun Jul 26 12:04:44 2009 UTC vs.
Revision 466 by rossy, Sat Oct 17 11:49:49 2009 UTC

# Line 38 | Line 38 | bool patch_particledisablebit = false;
38   bool patch_multibyte = false;
39   bool patch_cheattable = true;
40   bool patch_argb8888 = true;
41 + bool patch_killvtune = true;
42 + bool patch_getcmdline = true;
43 + bool patch_disablecmdline = true;
44  
45   bool patch_safeprintf = true;
46   bool patch_daodandisplayenum = true;
# Line 47 | Line 50 | bool patch_usedaodangl = false;
50   bool patch_windowhack = true;
51   bool patch_daodaninit = true;
52   bool patch_bsl = true;
53 + bool patch_cheater = true;
54  
55   bool opt_usedaodanbsl = true;
56  
# Line 160 | Line 164 | bool DDrPatch_Init()
164                  DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on);
165          }
166          
167 +        // ARGB8888 textures
168          if (patch_argb8888)
169          {
170                  DDrPatch_Byte  (OniExe + 0x00135af0, 0x07);
171                  DDrPatch_Byte  (OniExe + 0x00135af4, 0x0B);
172          }
173          
174 +        // Disable loading the vtuneapi.dll
175 +        if (patch_killvtune)
176 +                DDrPatch_Byte  (OniExe + 0x00026340, 0xC3);
177 +        
178 +        // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
179 +        if (patch_getcmdline)
180 +                DDrPatch_NOOP  (OniExe + 0x000d3280, 51);
181 +        
182 +        // Disable Oni's command line parser so it doesn't interfere with ours
183 +        if (patch_disablecmdline)
184 +                DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366);
185 +        
186          return true;
187   }
188  
# Line 186 | Line 203 | bool DDrIniCallback(char* section, bool
203                  else
204                  {
205                          ini_section = s_unknown;
206 <                        DDrStartupMessage("unrecognised ini section \"%s\"", section);
206 >                        DDrStartupMessage("unrecognised section \"%s\"", section);
207                  }
208          }
209          
# Line 195 | Line 212 | bool DDrIniCallback(char* section, bool
212                  case s_options:
213                          if (!stricmp(name, "usedaodanbsl"))
214                                  opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true");
215 +                        else if (!stricmp(name, "debug"))
216 +                                AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true");
217 +                        else if (!stricmp(name, "debugfiles"))
218 +                                BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true");
219 +                        else if (!stricmp(name, "findsounds"))
220 +                                SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true");
221 +                        else if (!stricmp(name, "ignore_private_data"))
222 +                                opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true");
223 +                        else if (!stricmp(name, "sound"))
224 +                                opt_sound = !stricmp(inifile_cleanstr(value), "true");
225 +                        else if (!stricmp(name, "switch"))
226 +                                M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true");
227 +                        else
228 +                                DDrStartupMessage("unrecognised option \"%s\"", name);
229                          break;
230                  case s_patch:
231                          if (!stricmp(name, "fonttexturecache"))
# Line 227 | Line 258 | bool DDrIniCallback(char* section, bool
258                                  patch_cheattable = !stricmp(inifile_cleanstr(value), "true");
259                          else if (!stricmp(name, "argb8888"))
260                                  patch_argb8888 = !stricmp(inifile_cleanstr(value), "true");
261 +                        else if (!stricmp(name, "killvtune"))
262 +                                patch_killvtune = !stricmp(inifile_cleanstr(value), "true");
263 +                        else if (!stricmp(name, "getcmdline"))
264 +                                patch_getcmdline = !stricmp(inifile_cleanstr(value), "true");
265 +                        else if (!stricmp(name, "disablecmdline"))
266 +                                patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true");
267                          else if (!stricmp(name, "safeprintf"))
268                                  patch_safeprintf = !stricmp(inifile_cleanstr(value), "true");
269                          else if (!stricmp(name, "daodandisplayenum"))
# Line 243 | Line 280 | bool DDrIniCallback(char* section, bool
280                                  patch_daodaninit = !stricmp(inifile_cleanstr(value), "true");
281                          else if (!stricmp(name, "bsl"))
282                                  patch_bsl = !stricmp(inifile_cleanstr(value), "true");
283 +                        else if (!stricmp(name, "cheater"))
284 +                                patch_cheater = !stricmp(inifile_cleanstr(value), "true");
285                          else
286                                  DDrStartupMessage("unrecognised patch \"%s\"", name);
287                          break;
# Line 305 | Line 344 | bool DDrIniCallback(char* section, bool
344                          {
345                                  char* str = strdup(value);
346                                  DDr_CheatTable[11].message_on = str;
347 <                                DDr_CheatTable[cheat_devmodex].message_on = str;
347 >                                DDr_CheatTable[cheat_x].message_on = str;
348                          }
349                          else if (!stricmp(name, "devmode_off"))
350                          {
351                                  char* str = strdup(value);
352                                  DDr_CheatTable[11].message_off = str;
353 <                                DDr_CheatTable[cheat_devmodex].message_off = str;
353 >                                DDr_CheatTable[cheat_x].message_off = str;
354                          }
355                          else if (!stricmp(name, "reservoirdogs_on"))
356                                  DDr_CheatTable[12].message_on = strdup(value);
# Line 390 | Line 429 | void ONICALL DDrGame_Init()
429   void __cdecl DDrMain(int argc, char* argv[])
430   {
431          DDrStartupMessage("daodan attached!");
432 +        
433 +        opt_ignore_private_data = false;
434 +        opt_sound = true;
435 +        
436          DDrConfig();
437 +        DDrStartupMessage("parsing command line...");
438 +        int i;
439 +        char* section;
440 +        char* option;
441 +        bool falseoption;
442 +        for (i = 1; i < argc; i ++)
443 +        {
444 +                if (argv[i][0] == '-')
445 +                {
446 +                        section = argv[i] + 1;
447 +                        if ((option = strchr(argv[i], '.')))
448 +                        {
449 +                                *option = '\0';
450 +                                falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
451 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
452 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), argv[++i]);
453 +                                else
454 +                                        DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
455 +                                *option = '.';
456 +                        }
457 +                        else
458 +                        {
459 +                                falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
460 +                                ini_section = s_options;
461 +                                if (i < (argc - 1) && argv[i + 1][0] != '-')
462 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), argv[++i]);
463 +                                else
464 +                                        DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
465 +                        }
466 +                }
467 +                else
468 +                {
469 +                        DDrStartupMessage("parse error \"%s\"", argv[i]);
470 +                        break;
471 +                }
472 +        }
473 +        DDrStartupMessage("finished parsing");
474          DDrPatch_Init();
475          
476          // Safe startup message printer
# Line 431 | Line 511 | void __cdecl DDrMain(int argc, char* arg
511          if (patch_bsl)
512                  SLrDaodan_Patch();
513          
514 +        if (patch_cheater)
515 +        {
516 +                DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater);
517 +                DDrPatch_Int16(OniExe + 0x000deb45, 0x5590);
518 +                DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames);
519 +                DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad);
520 +        }
521 +        
522          init_daodan_gl();
523          
524          ONiMain(argc, argv);
525   }
526 <
526 > /*
527 > void DDrWrongExe()
528 > {
529 >        switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
530 >                "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))
531 >        {
532 >                case IDOK:
533 >                        {
534 >                                STARTUPINFO si;
535 >                                PROCESS_INFORMATION pi;
536 >                                FillMemory(&si, 0, sizeof(si));
537 >                                FillMemory(&pi, 0, sizeof(pi));
538 >                                si.cb = sizeof(si);
539 >                                if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
540 >                                        MessageBox(NULL, "", "", 0);
541 >                                CloseHandle(pi.hProcess);
542 >                                CloseHandle(pi.hThread);
543 >                        }
544 >                default:
545 >                        ExitProcess(0);
546 >        }
547 > }
548 > */
549   BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
550   {
551          switch (fdwReason)
# Line 444 | Line 554 | BOOL WINAPI DllMain(HINSTANCE hinstDLL,
554                          DDrDLLModule = hinstDLL;
555                          DDrONiModule = GetModuleHandle(NULL);
556                          
557 <                        DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
558 <                        
557 >                        if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852)
558 >                                DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain);
559 >                        else
560 >                                ExitProcess(0);
561                          break;
562          }
563          return TRUE;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)