--- Daodan/src/Daodan.c 2009/06/10 12:40:16 349 +++ Daodan/src/Daodan.c 2009/11/03 10:38:47 476 @@ -6,6 +6,8 @@ #include "Daodan_Win32.h" #include "Daodan_Cheater.h" #include "Daodan_Persistence.h" +#include "Daodan_BSL.h" +#include "Daodan_Console.h" #include "Daodan_WindowHack.h" @@ -34,15 +36,29 @@ bool patch_cooldowntimer = true; bool patch_throwtest = false; bool patch_alttab = true; bool patch_particledisablebit = false; -bool patch_multibyte = true; +bool patch_multibyte = false; bool patch_cheattable = true; +bool patch_argb8888 = true; +bool patch_killvtune = true; +bool patch_getcmdline = true; +bool patch_disablecmdline = true; bool patch_safeprintf = true; bool patch_daodandisplayenum = true; bool patch_usegettickcount = true; bool patch_cheatsenabled = true; -bool patch_usedaodangl = false; -bool patch_windowhack = true; +bool patch_usedaodangl = true; +bool patch_windowhack = false; +bool patch_daodaninit = true; +bool patch_bsl = true; +bool patch_cheater = true; + +// bool patch_newweapon = true; + +bool opt_usedaodanbsl = true; +bool opt_border = true; +bool opt_shadow = false; +bool opt_topmost = false; bool DDrPatch_Init() { @@ -127,7 +143,7 @@ bool DDrPatch_Init() DDrPatch_Int16 (OniExe + 0x001b184, 0x9090); // Multi-byte patch (multiple language support) - if (patch_multibyte) + if (!patch_multibyte) { DDrPatch_Byte (OniExe + 0x0002d8f8, 0xeb); DDrPatch_Byte (OniExe + 0x0002d9ad, 0xeb); @@ -154,69 +170,149 @@ bool DDrPatch_Init() DDrPatch_Int32 (OniExe + 0x000f617a, (int)&DDr_CheatTable[0].message_on); } + // ARGB8888 textures + if (patch_argb8888) + { + DDrPatch_Byte (OniExe + 0x00135af0, 0x07); + DDrPatch_Byte (OniExe + 0x00135af4, 0x0B); + } + + //Test newweap patch +// if (patch_newweapon) { + + //Makes it always say "Recieved weapon_name." + //Needs check for loc_4DFC66 + DDrPatch_NOOP( OniExe + 0x000E4DF8,2); + + //Adds Weapon name and ammo meter to pickup autoprompt + DDrPatch_NOOP( OniExe + 0x000FAC73, 9); + DDrPatch_NOOP( OniExe + 0x000FAC80, 5); + DDrPatch_MakeCall( OniExe + 0xFAC85, DDrWeapon2Message); + + //Moves location of colors + DDrPatch_Int32( OniExe + 0x0002E3D5, (int)&DDrDSayColors[0].Char ); + DDrPatch_Int32( OniExe + 0x0002E3DA, (int)&DDrDSayColors[0].Char ); +// } + + // Disable loading the vtuneapi.dll + if (patch_killvtune) + DDrPatch_Byte (OniExe + 0x00026340, 0xC3); + + // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own) + if (patch_getcmdline) + DDrPatch_NOOP (OniExe + 0x000d3280, 51); + + // Disable Oni's command line parser so it doesn't interfere with ours + if (patch_disablecmdline) + DDrPatch_Int32 (OniExe + 0x000d3570, 0xc3c03366); + return true; } -enum {s_unknown, s_patch, s_language} ini_section; +enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section; bool DDrIniCallback(char* section, bool newsection, char* name, char* value) { if (newsection) { - if (!stricmp(section, "patch")) + if (!stricmp(section, "options")) + ini_section = s_options; + else if (!stricmp(section, "patch")) ini_section = s_patch; + else if (!stricmp(section, "bsl")) + ini_section = s_bsl; else if (!stricmp(section, "language")) ini_section = s_language; else { ini_section = s_unknown; - DDrStartupMessage("unrecognised ini section \"%s\"", section); + DDrStartupMessage("unrecognised section \"%s\"", section); } } switch (ini_section) { + case s_options: + if (!stricmp(name, "usedaodanbsl")) + opt_usedaodanbsl = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "border")) + opt_border = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "shadow")) + opt_shadow = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "topmost")) + opt_topmost = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "multibyte")) + patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "debug")) + AKgDebug_DebugMaps = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "debugfiles")) + BFgDebugFileEnable = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "findsounds")) + SSgSearchOnDisk = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "ignore_private_data")) + opt_ignore_private_data = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "sound")) + opt_sound = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "switch")) + M3gResolutionSwitch = !stricmp(inifile_cleanstr(value), "true"); + else + DDrStartupMessage("unrecognised option \"%s\"", name); + break; case s_patch: if (!stricmp(name, "fonttexturecache")) - patch_fonttexturecache = !stricmp(value, "true"); + patch_fonttexturecache = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "largetextures")) - patch_largetextures = !stricmp(value, "true"); + patch_largetextures = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "levelplugins")) - patch_levelplugins = !stricmp(value, "true"); + patch_levelplugins = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "pathfinding")) - patch_pathfinding = !stricmp(value, "true"); + patch_pathfinding = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "projaware")) - patch_projaware = !stricmp(value, "true"); + patch_projaware = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "directinput")) - patch_directinput = !stricmp(value, "true"); + patch_directinput = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "wpfadetime")) - patch_wpfadetime = !stricmp(value, "true"); + patch_wpfadetime = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "kickguns")) - patch_kickguns = !stricmp(value, "true"); + patch_kickguns = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "cooldowntimer")) - patch_cooldowntimer = !stricmp(value, "true"); + patch_cooldowntimer = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "throwtest")) - patch_throwtest = !stricmp(value, "true"); + patch_throwtest = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "alttab")) - patch_alttab = !stricmp(value, "true"); + patch_alttab = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "particledisablebit")) - patch_particledisablebit = !stricmp(value, "true"); + patch_particledisablebit = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "multibyte")) - patch_multibyte = !stricmp(value, "true"); + patch_multibyte = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "cheattable")) - patch_cheattable = !stricmp(value, "true"); + patch_cheattable = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "argb8888")) + patch_argb8888 = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "killvtune")) + patch_killvtune = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "getcmdline")) + patch_getcmdline = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "disablecmdline")) + patch_disablecmdline = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "safeprintf")) - patch_safeprintf = !stricmp(value, "true"); + patch_safeprintf = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "daodandisplayenum")) - patch_daodandisplayenum = !stricmp(value, "true"); + patch_daodandisplayenum = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "usegettickcount")) - patch_usegettickcount = !stricmp(value, "true"); + patch_usegettickcount = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "cheatsenabled")) - patch_cheatsenabled = !stricmp(value, "true"); + patch_cheatsenabled = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "usedaodangl")) - patch_usedaodangl = !stricmp(value, "true"); + patch_usedaodangl = !stricmp(inifile_cleanstr(value), "true"); else if (!stricmp(name, "windowhack")) - patch_windowhack = !stricmp(value, "true"); + patch_windowhack = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "daodaninit")) + patch_daodaninit = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "bsl")) + patch_bsl = !stricmp(inifile_cleanstr(value), "true"); + else if (!stricmp(name, "cheater")) + patch_cheater = !stricmp(inifile_cleanstr(value), "true"); else DDrStartupMessage("unrecognised patch \"%s\"", name); break; @@ -279,13 +375,13 @@ bool DDrIniCallback(char* section, bool { char* str = strdup(value); DDr_CheatTable[11].message_on = str; - DDr_CheatTable[cheat_devmodex].message_on = str; + DDr_CheatTable[cheat_x].message_on = str; } else if (!stricmp(name, "devmode_off")) { char* str = strdup(value); DDr_CheatTable[11].message_off = str; - DDr_CheatTable[cheat_devmodex].message_off = str; + DDr_CheatTable[cheat_x].message_off = str; } else if (!stricmp(name, "reservoirdogs_on")) DDr_CheatTable[12].message_on = strdup(value); @@ -328,6 +424,7 @@ bool DDrIniCallback(char* section, bool else DDrStartupMessage("unrecognised language item \"%s\"", name); break; + case s_bsl: default: break; } @@ -354,10 +451,57 @@ void DDrConfig() DDrStartupMessage("finished parsing"); } +void ONICALL DDrGame_Init() +{ + if (opt_usedaodanbsl) + SLrDaodan_Initalize(); +} + void __cdecl DDrMain(int argc, char* argv[]) { DDrStartupMessage("daodan attached!"); + + opt_ignore_private_data = false; + opt_sound = true; + DDrConfig(); + DDrStartupMessage("parsing command line..."); + int i; + char* section; + char* option; + bool falseoption; + for (i = 1; i < argc; i ++) + { + if (argv[i][0] == '-') + { + section = argv[i] + 1; + if ((option = strchr(argv[i], '.'))) + { + *option = '\0'; + falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O'); + if (i < (argc - 1) && argv[i + 1][0] != '-') + DDrIniCallback(section, true, option + 1, argv[++i]); + else + DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true")); + *option = '.'; + } + else + { + falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O'); + ini_section = s_options; + if (i < (argc - 1) && argv[i + 1][0] != '-') + DDrIniCallback(NULL, false, section, argv[++i]); + else + DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true")); + } + } + else + { + DDrStartupMessage("parse error \"%s\"", argv[i]); + break; + } + } + DDrStartupMessage("finished parsing"); DDrPatch_Init(); // Safe startup message printer @@ -391,11 +535,48 @@ void __cdecl DDrMain(int argc, char* arg if (patch_windowhack) DDrWindowHack_Install(); + if (patch_daodaninit) + DDrPatch_MakeCall(OniExe + 0x000d345a, DDrGame_Init); + + // Patches for existing BSL functions + if (patch_bsl) + SLrDaodan_Patch(); + + if (patch_cheater) + { + DDrPatch_MakeCall(OniExe + 0x000f618f, DDrCheater); + DDrPatch_Int16(OniExe + 0x000deb45, 0x5590); + DDrPatch_MakeCall(OniExe + 0x000deb47, FallingFrames); + DDrPatch_MakeJump(OniExe + 0x0010f021, DDrCheater_LevelLoad); + } + init_daodan_gl(); ONiMain(argc, argv); } - +/* +void DDrWrongExe() +{ + switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n" + "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)) + { + case IDOK: + { + STARTUPINFO si; + PROCESS_INFORMATION pi; + FillMemory(&si, 0, sizeof(si)); + FillMemory(&pi, 0, sizeof(pi)); + si.cb = sizeof(si); + if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) + MessageBox(NULL, "", "", 0); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + } + default: + ExitProcess(0); + } +} +*/ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) { switch (fdwReason) @@ -404,8 +585,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DDrDLLModule = hinstDLL; DDrONiModule = GetModuleHandle(NULL); - DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain); - + if (*(uint32_t*)((void*)OniExe + 0x0011acd0) == 0x09d36852) + DDrPatch_MakeCall(OniExe + 0x0010fb49, DDrMain); + else + ExitProcess(0); break; } return TRUE;