| 6 |
|
#include "Daodan_Win32.h" |
| 7 |
|
#include "Daodan_Cheater.h" |
| 8 |
|
#include "Daodan_Persistence.h" |
| 9 |
+ |
#include "Daodan_BSL.h" |
| 10 |
|
|
| 11 |
|
#include "Daodan_WindowHack.h" |
| 12 |
|
|
| 35 |
|
bool patch_throwtest = false; |
| 36 |
|
bool patch_alttab = true; |
| 37 |
|
bool patch_particledisablebit = false; |
| 38 |
< |
bool patch_multibyte = true; |
| 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; |
| 48 |
|
bool patch_cheatsenabled = true; |
| 49 |
|
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 |
|
|
| 57 |
|
bool DDrPatch_Init() |
| 58 |
|
{ |
| 137 |
|
DDrPatch_Int16 (OniExe + 0x001b184, 0x9090); |
| 138 |
|
|
| 139 |
|
// Multi-byte patch (multiple language support) |
| 140 |
< |
if (patch_multibyte) |
| 140 |
> |
if (!patch_multibyte) |
| 141 |
|
{ |
| 142 |
|
DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb); |
| 143 |
|
DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb); |
| 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 |
|
|
| 189 |
< |
enum {s_unknown, s_patch, s_language} ini_section; |
| 189 |
> |
enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section; |
| 190 |
|
|
| 191 |
|
bool DDrIniCallback(char* section, bool newsection, char* name, char* value) |
| 192 |
|
{ |
| 193 |
|
if (newsection) |
| 194 |
|
{ |
| 195 |
< |
if (!stricmp(section, "patch")) |
| 195 |
> |
if (!stricmp(section, "options")) |
| 196 |
> |
ini_section = s_options; |
| 197 |
> |
else if (!stricmp(section, "patch")) |
| 198 |
|
ini_section = s_patch; |
| 199 |
+ |
else if (!stricmp(section, "bsl")) |
| 200 |
+ |
ini_section = s_bsl; |
| 201 |
|
else if (!stricmp(section, "language")) |
| 202 |
|
ini_section = s_language; |
| 203 |
|
else |
| 204 |
|
{ |
| 205 |
|
ini_section = s_unknown; |
| 206 |
< |
DDrStartupMessage("unrecognised ini section \"%s\"", section); |
| 206 |
> |
DDrStartupMessage("unrecognised section \"%s\"", section); |
| 207 |
|
} |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
switch (ini_section) |
| 211 |
|
{ |
| 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")) |
| 232 |
< |
patch_fonttexturecache = !stricmp(value, "true"); |
| 232 |
> |
patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true"); |
| 233 |
|
else if (!stricmp(name, "largetextures")) |
| 234 |
< |
patch_largetextures = !stricmp(value, "true"); |
| 234 |
> |
patch_largetextures = !stricmp(inifile_cleanstr(value), "true"); |
| 235 |
|
else if (!stricmp(name, "levelplugins")) |
| 236 |
< |
patch_levelplugins = !stricmp(value, "true"); |
| 236 |
> |
patch_levelplugins = !stricmp(inifile_cleanstr(value), "true"); |
| 237 |
|
else if (!stricmp(name, "pathfinding")) |
| 238 |
< |
patch_pathfinding = !stricmp(value, "true"); |
| 238 |
> |
patch_pathfinding = !stricmp(inifile_cleanstr(value), "true"); |
| 239 |
|
else if (!stricmp(name, "projaware")) |
| 240 |
< |
patch_projaware = !stricmp(value, "true"); |
| 240 |
> |
patch_projaware = !stricmp(inifile_cleanstr(value), "true"); |
| 241 |
|
else if (!stricmp(name, "directinput")) |
| 242 |
< |
patch_directinput = !stricmp(value, "true"); |
| 242 |
> |
patch_directinput = !stricmp(inifile_cleanstr(value), "true"); |
| 243 |
|
else if (!stricmp(name, "wpfadetime")) |
| 244 |
< |
patch_wpfadetime = !stricmp(value, "true"); |
| 244 |
> |
patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true"); |
| 245 |
|
else if (!stricmp(name, "kickguns")) |
| 246 |
< |
patch_kickguns = !stricmp(value, "true"); |
| 246 |
> |
patch_kickguns = !stricmp(inifile_cleanstr(value), "true"); |
| 247 |
|
else if (!stricmp(name, "cooldowntimer")) |
| 248 |
< |
patch_cooldowntimer = !stricmp(value, "true"); |
| 248 |
> |
patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true"); |
| 249 |
|
else if (!stricmp(name, "throwtest")) |
| 250 |
< |
patch_throwtest = !stricmp(value, "true"); |
| 250 |
> |
patch_throwtest = !stricmp(inifile_cleanstr(value), "true"); |
| 251 |
|
else if (!stricmp(name, "alttab")) |
| 252 |
< |
patch_alttab = !stricmp(value, "true"); |
| 252 |
> |
patch_alttab = !stricmp(inifile_cleanstr(value), "true"); |
| 253 |
|
else if (!stricmp(name, "particledisablebit")) |
| 254 |
< |
patch_particledisablebit = !stricmp(value, "true"); |
| 254 |
> |
patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true"); |
| 255 |
|
else if (!stricmp(name, "multibyte")) |
| 256 |
< |
patch_multibyte = !stricmp(value, "true"); |
| 256 |
> |
patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); |
| 257 |
|
else if (!stricmp(name, "cheattable")) |
| 258 |
< |
patch_cheattable = !stricmp(value, "true"); |
| 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(value, "true"); |
| 268 |
> |
patch_safeprintf = !stricmp(inifile_cleanstr(value), "true"); |
| 269 |
|
else if (!stricmp(name, "daodandisplayenum")) |
| 270 |
< |
patch_daodandisplayenum = !stricmp(value, "true"); |
| 270 |
> |
patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true"); |
| 271 |
|
else if (!stricmp(name, "usegettickcount")) |
| 272 |
< |
patch_usegettickcount = !stricmp(value, "true"); |
| 272 |
> |
patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true"); |
| 273 |
|
else if (!stricmp(name, "cheatsenabled")) |
| 274 |
< |
patch_cheatsenabled = !stricmp(value, "true"); |
| 274 |
> |
patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true"); |
| 275 |
|
else if (!stricmp(name, "usedaodangl")) |
| 276 |
< |
patch_usedaodangl = !stricmp(value, "true"); |
| 276 |
> |
patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true"); |
| 277 |
|
else if (!stricmp(name, "windowhack")) |
| 278 |
< |
patch_windowhack = !stricmp(value, "true"); |
| 278 |
> |
patch_windowhack = !stricmp(inifile_cleanstr(value), "true"); |
| 279 |
> |
else if (!stricmp(name, "daodaninit")) |
| 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; |
| 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); |
| 393 |
|
else |
| 394 |
|
DDrStartupMessage("unrecognised language item \"%s\"", name); |
| 395 |
|
break; |
| 396 |
+ |
case s_bsl: |
| 397 |
|
default: |
| 398 |
|
break; |
| 399 |
|
} |
| 420 |
|
DDrStartupMessage("finished parsing"); |
| 421 |
|
} |
| 422 |
|
|
| 423 |
+ |
void ONICALL DDrGame_Init() |
| 424 |
+ |
{ |
| 425 |
+ |
if (opt_usedaodanbsl) |
| 426 |
+ |
SLrDaodan_Initalize(); |
| 427 |
+ |
} |
| 428 |
+ |
|
| 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 + 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, 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 |
| 504 |
|
if (patch_windowhack) |
| 505 |
|
DDrWindowHack_Install(); |
| 506 |
|
|
| 507 |
+ |
if (patch_daodaninit) |
| 508 |
+ |
DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init); |
| 509 |
+ |
|
| 510 |
+ |
// Patches for existing BSL functions |
| 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) |
| 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; |