--- Daodan/src/Daodan.c 2009/08/24 11:32:06 459 +++ Daodan/src/Daodan.c 2009/10/17 12:35:06 467 @@ -39,6 +39,8 @@ 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; @@ -173,6 +175,14 @@ bool DDrPatch_Init() 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; } @@ -193,7 +203,7 @@ bool DDrIniCallback(char* section, bool else { ini_section = s_unknown; - DDrStartupMessage("unrecognised ini section \"%s\"", section); + DDrStartupMessage("unrecognised section \"%s\"", section); } } @@ -202,6 +212,20 @@ bool DDrIniCallback(char* section, bool case s_options: if (!stricmp(name, "usedaodanbsl")) opt_usedaodanbsl = !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")) @@ -236,6 +260,10 @@ bool DDrIniCallback(char* section, bool 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(inifile_cleanstr(value), "true"); else if (!stricmp(name, "daodandisplayenum")) @@ -401,7 +429,48 @@ void ONICALL DDrGame_Init() 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 @@ -454,7 +523,29 @@ void __cdecl DDrMain(int argc, char* arg 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) @@ -463,8 +554,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;