[692] | 1 | #include <windows.h>
|
---|
[346] | 2 | #include <string.h>
|
---|
| 3 |
|
---|
[272] | 4 | #include "Daodan.h"
|
---|
| 5 | #include "Daodan_Patch.h"
|
---|
| 6 | #include "Daodan_Utility.h"
|
---|
[323] | 7 | #include "Daodan_Win32.h"
|
---|
[339] | 8 | #include "Daodan_Cheater.h"
|
---|
| 9 | #include "Daodan_Persistence.h"
|
---|
[439] | 10 | #include "Daodan_BSL.h"
|
---|
[476] | 11 | #include "Daodan_Console.h"
|
---|
[349] | 12 | #include "Daodan_WindowHack.h"
|
---|
| 13 |
|
---|
[273] | 14 | #include "Oni.h"
|
---|
[339] | 15 |
|
---|
[692] | 16 | #include "Oni_GL.h"
|
---|
| 17 | #include "Daodan_GL.h"
|
---|
[272] | 18 |
|
---|
[692] | 19 | #include "Inifile_Reader.h"
|
---|
[297] | 20 |
|
---|
[272] | 21 | HMODULE DDrDLLModule;
|
---|
| 22 | HMODULE DDrONiModule;
|
---|
| 23 |
|
---|
[347] | 24 | bool patch_fonttexturecache = true;
|
---|
| 25 | bool patch_largetextures = true;
|
---|
[349] | 26 | bool patch_levelplugins = true;
|
---|
[347] | 27 | bool patch_pathfinding = true;
|
---|
| 28 | bool patch_projaware = true;
|
---|
[348] | 29 | bool patch_directinput = true;
|
---|
[347] | 30 | bool patch_wpfadetime = true;
|
---|
| 31 | bool patch_kickguns = false;
|
---|
| 32 | bool patch_cooldowntimer = true;
|
---|
| 33 | bool patch_throwtest = false;
|
---|
| 34 | bool patch_alttab = true;
|
---|
| 35 | bool patch_particledisablebit = false;
|
---|
[422] | 36 | bool patch_multibyte = false;
|
---|
[347] | 37 | bool patch_cheattable = true;
|
---|
[426] | 38 | bool patch_argb8888 = true;
|
---|
[459] | 39 | bool patch_killvtune = true;
|
---|
[466] | 40 | bool patch_getcmdline = true;
|
---|
| 41 | bool patch_disablecmdline = true;
|
---|
[693] | 42 | bool patch_optionsvisible = true;
|
---|
[347] | 43 |
|
---|
| 44 | bool patch_safeprintf = true;
|
---|
| 45 | bool patch_daodandisplayenum = true;
|
---|
| 46 | bool patch_usegettickcount = true;
|
---|
[348] | 47 | bool patch_cheatsenabled = true;
|
---|
[677] | 48 | bool patch_usedaodangl = false;
|
---|
| 49 | bool patch_windowhack = true;
|
---|
[439] | 50 | bool patch_daodaninit = true;
|
---|
[447] | 51 | bool patch_bsl = true;
|
---|
[452] | 52 | bool patch_cheater = true;
|
---|
[677] | 53 | bool patch_newweapon = true;
|
---|
[439] | 54 | bool opt_usedaodanbsl = true;
|
---|
[468] | 55 | bool opt_border = true;
|
---|
| 56 | bool opt_topmost = false;
|
---|
[439] | 57 |
|
---|
[677] | 58 | typedef int (__cdecl *CHINESEPROC)(DWORD WINAPI);
|
---|
| 59 | bool patch_chinese = false;
|
---|
[693] | 60 |
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | void ONICALL DDrShowResumeButton(int window, int visibility)
|
---|
| 64 | {
|
---|
| 65 | if (visibility)
|
---|
| 66 | WMrWindow_SetLocation(window, 150, 350);
|
---|
| 67 | WMrWindow_SetVisible(window, visibility);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | /* Options always visible patch */
|
---|
| 72 | void ONICALL DDrShowOptionsButton(int window, int visibility)
|
---|
| 73 | {
|
---|
| 74 | WMrWindow_SetVisible(window, 1);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 |
|
---|
[272] | 79 | bool DDrPatch_Init()
|
---|
| 80 | {
|
---|
[346] | 81 | DDrStartupMessage("patching engine");
|
---|
[342] | 82 |
|
---|
[272] | 83 | // Font texture cache doubled
|
---|
[347] | 84 | if (patch_fonttexturecache)
|
---|
| 85 | {
|
---|
[689] | 86 | DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20);
|
---|
| 87 | DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40);
|
---|
[347] | 88 | }
|
---|
[272] | 89 |
|
---|
| 90 | // Now supports textures up to 512x512
|
---|
[347] | 91 | if (patch_largetextures)
|
---|
[689] | 92 | DDrPatch_Byte ((char*)(OniExe + 0x00005251), 0x10);
|
---|
[272] | 93 |
|
---|
| 94 | // Non-"_Final" levels are now valid
|
---|
[348] | 95 | if (patch_levelplugins)
|
---|
[689] | 96 | DDrPatch_Byte ((char*)(OniExe + 0x000206a8), 0x01);
|
---|
[272] | 97 |
|
---|
| 98 | // Pathfinding grid cache size x8
|
---|
[347] | 99 | if (patch_pathfinding)
|
---|
| 100 | {
|
---|
[689] | 101 | const unsigned char pathfinding[2] = {0x90 , 0xE9 };
|
---|
| 102 | DDrPatch_Byte ((char*)(OniExe + 0x0010b03b), 0x20);
|
---|
| 103 | DDrPatch_Byte ((char*)(OniExe + 0x0010b04c), 0x20);
|
---|
[677] | 104 |
|
---|
| 105 | //other stuff
|
---|
[689] | 106 | DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding);
|
---|
[347] | 107 | }
|
---|
[272] | 108 |
|
---|
| 109 | // Projectile awareness fixed
|
---|
[347] | 110 | if (patch_projaware)
|
---|
| 111 | {
|
---|
[689] | 112 | DDrPatch_Byte ((char*)(OniExe + 0x0009c07c), 0x6c);
|
---|
| 113 | DDrPatch_Byte ((char*)(OniExe + 0x0009c080), 0x70);
|
---|
| 114 | DDrPatch_Byte ((char*)(OniExe + 0x0009c084), 0x74);
|
---|
| 115 | DDrPatch_Byte ((char*)(OniExe + 0x0009c110), 0x6c);
|
---|
[347] | 116 | }
|
---|
[272] | 117 |
|
---|
| 118 | // Forced DirectInput (for Windows NT)
|
---|
[348] | 119 | if (patch_directinput)
|
---|
[689] | 120 | DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
|
---|
[677] | 121 |
|
---|
[347] | 122 | if (patch_wpfadetime)
|
---|
| 123 | {
|
---|
| 124 | // Makes wp_fadetime actually have a function
|
---|
[689] | 125 | const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
|
---|
| 126 | DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch);
|
---|
| 127 | DDrPatch_Byte ((char*)(OniExe + 0x0011a560), 0x31);
|
---|
[347] | 128 |
|
---|
| 129 | // Sets the fadetime to 4800 by default
|
---|
[689] | 130 | DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0);
|
---|
[347] | 131 | }
|
---|
[272] | 132 |
|
---|
[677] | 133 | // FIXME: add switches
|
---|
| 134 | //pathfinding fix
|
---|
| 135 |
|
---|
[272] | 136 |
|
---|
[677] | 137 |
|
---|
| 138 |
|
---|
[272] | 139 | // Hackish fix for Konoko not kicking guns
|
---|
[677] | 140 | // Don't use this, it breaks stairs.
|
---|
[347] | 141 | if (patch_kickguns)
|
---|
| 142 | {
|
---|
[689] | 143 | const unsigned 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 };
|
---|
| 144 | DDrPatch_Const ((char*)(OniExe + 0x000dc420), kickgun_patch);
|
---|
[347] | 145 | }
|
---|
[272] | 146 |
|
---|
| 147 | // Cooldown timer exploit fix ^_^
|
---|
[347] | 148 | if (patch_cooldowntimer)
|
---|
| 149 | {
|
---|
[689] | 150 | const unsigned 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 };
|
---|
| 151 | DDrPatch_Const ((char*)(OniExe + 0x0011a825), cooldown_patch);
|
---|
[347] | 152 | }
|
---|
[272] | 153 |
|
---|
[347] | 154 | if (patch_throwtest)
|
---|
| 155 | {
|
---|
[689] | 156 | const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
|
---|
| 157 | DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch);
|
---|
[347] | 158 | }
|
---|
[272] | 159 |
|
---|
[322] | 160 | // 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.
|
---|
[347] | 161 | if (patch_alttab)
|
---|
| 162 | {
|
---|
[690] | 163 | // 0xC3 = ret, so makes those functions just have a "ret" instruction at their start
|
---|
[689] | 164 | DDrPatch_Byte ((char*)UUrPlatform_Initialize, 0xC3);
|
---|
| 165 | DDrPatch_Byte ((char*)UUrPlatform_Terminate, 0xC3);
|
---|
[347] | 166 | }
|
---|
[322] | 167 |
|
---|
| 168 | // 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.)
|
---|
[347] | 169 | if (patch_particledisablebit)
|
---|
[689] | 170 | DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090);
|
---|
[322] | 171 |
|
---|
[329] | 172 | // Multi-byte patch (multiple language support)
|
---|
[422] | 173 | if (!patch_multibyte)
|
---|
[347] | 174 | {
|
---|
[689] | 175 | DDrPatch_Byte ((char*)(OniExe + 0x0002d8f8), 0xeb);
|
---|
| 176 | DDrPatch_Byte ((char*)(OniExe + 0x0002d9ad), 0xeb);
|
---|
| 177 | DDrPatch_Byte ((char*)(OniExe + 0x0002dbe2), 0xeb);
|
---|
| 178 | DDrPatch_Byte ((char*)(OniExe + 0x0002dec3), 0xeb);
|
---|
| 179 | DDrPatch_Byte ((char*)(OniExe + 0x0002e2ab), 0xeb);
|
---|
| 180 | DDrPatch_Byte ((char*)(OniExe + 0x0002e2c4), 0xeb);
|
---|
| 181 | DDrPatch_Byte ((char*)(OniExe + 0x0002e379), 0xeb);
|
---|
| 182 | DDrPatch_Byte ((char*)(OniExe + 0x0002e48c), 0xeb);
|
---|
| 183 | DDrPatch_Byte ((char*)(OniExe + 0x0002e4d0), 0xeb);
|
---|
| 184 | DDrPatch_Byte ((char*)(OniExe + 0x0002e4f4), 0xeb);
|
---|
| 185 | DDrPatch_Byte ((char*)(OniExe + 0x0002e646), 0xeb);
|
---|
| 186 | DDrPatch_Byte ((char*)(OniExe + 0x0002e695), 0xeb);
|
---|
| 187 | DDrPatch_Byte ((char*)(OniExe + 0x0002e944), 0xeb);
|
---|
| 188 | DDrPatch_Byte ((char*)(OniExe + 0x0002e95d), 0xeb);
|
---|
| 189 | DDrPatch_Byte ((char*)(OniExe + 0x0002e98e), 0xeb);
|
---|
| 190 | DDrPatch_Byte ((char*)(OniExe + 0x0002e9dc), 0xeb);
|
---|
[347] | 191 | }
|
---|
[329] | 192 |
|
---|
[339] | 193 | // Cheat table patch
|
---|
[347] | 194 | if (patch_cheattable)
|
---|
| 195 | {
|
---|
[689] | 196 | DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name);
|
---|
| 197 | DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on);
|
---|
[347] | 198 | }
|
---|
[339] | 199 |
|
---|
[459] | 200 | // ARGB8888 textures
|
---|
[426] | 201 | if (patch_argb8888)
|
---|
| 202 | {
|
---|
[689] | 203 | DDrPatch_Byte ((char*)(OniExe + 0x00135af0), 0x07);
|
---|
| 204 | DDrPatch_Byte ((char*)(OniExe + 0x00135af4), 0x0B);
|
---|
[426] | 205 | }
|
---|
[473] | 206 |
|
---|
| 207 | //Test newweap patch
|
---|
[677] | 208 | if (patch_newweapon) {
|
---|
[476] | 209 |
|
---|
| 210 | //Makes it always say "Recieved weapon_name."
|
---|
| 211 | //Needs check for loc_4DFC66
|
---|
[689] | 212 | //DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
|
---|
[476] | 213 |
|
---|
| 214 | //Adds Weapon name and ammo meter to pickup autoprompt
|
---|
[689] | 215 | DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9);
|
---|
| 216 | DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5);
|
---|
| 217 | DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message);
|
---|
[476] | 218 |
|
---|
| 219 | //Moves location of colors
|
---|
[689] | 220 | //DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors );
|
---|
| 221 | //DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors );
|
---|
[677] | 222 | }
|
---|
[426] | 223 |
|
---|
[459] | 224 | // Disable loading the vtuneapi.dll
|
---|
[677] | 225 | //if (patch_killvtune)
|
---|
[689] | 226 | //DDrPatch_Byte ((char*)(OniExe + 0x00026340), 0xC3);
|
---|
[459] | 227 |
|
---|
[466] | 228 | // Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
|
---|
| 229 | if (patch_getcmdline)
|
---|
[689] | 230 | DDrPatch_NOOP ((char*)(OniExe + 0x000d3280), 51);
|
---|
[466] | 231 |
|
---|
| 232 | // Disable Oni's command line parser so it doesn't interfere with ours
|
---|
| 233 | if (patch_disablecmdline)
|
---|
[689] | 234 | DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
|
---|
[466] | 235 |
|
---|
[677] | 236 | if (patch_bsl)
|
---|
| 237 | {
|
---|
| 238 | //Calculating the value of the needed offset is much more reliable when the compiler does it for you.
|
---|
| 239 |
|
---|
| 240 | //TODO: fix moonshadow.
|
---|
| 241 | Character * Chr = 0;
|
---|
| 242 | int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
|
---|
[689] | 243 | const unsigned char regen_patch[] =
|
---|
[677] | 244 | {0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat -> NOOP
|
---|
| 245 | 0x90, 0x90, // test al, al -> NOOP
|
---|
| 246 | 0x90, 0x90, // jz short loc_51BB98 -> NOOP
|
---|
| 247 | 0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov eax, [esi+Character.field_1E8]
|
---|
| 248 | // -> mov eax, [esi+Character.RegenHax]
|
---|
| 249 | 0x85, 0xC0, // test eax, eax
|
---|
| 250 | 0x74, 0x21 // jnz 0x21 -> jz 0x21
|
---|
| 251 | };
|
---|
[689] | 252 | DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
|
---|
[677] | 253 | }
|
---|
| 254 |
|
---|
| 255 | if(patch_chinese)
|
---|
| 256 | {
|
---|
| 257 | HMODULE dll = LoadLibrary("xfhsm_oni.dll");
|
---|
| 258 | if( dll )
|
---|
| 259 | {
|
---|
| 260 | void* proc = GetProcAddress( dll, "InstallHook" );
|
---|
| 261 | if(proc)
|
---|
| 262 | {
|
---|
| 263 | ((CHINESEPROC)proc)(GetCurrentThreadId());
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | //Fix crappy ai2_shownames
|
---|
| 269 | if(1)
|
---|
| 270 | {
|
---|
| 271 | //Set distance above head to 4.0
|
---|
[689] | 272 | DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
|
---|
[677] | 273 | //texture height
|
---|
[689] | 274 | DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
|
---|
[677] | 275 | //texture width
|
---|
[689] | 276 | DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
|
---|
[677] | 277 | //Set the text color to whatever we like ;)
|
---|
[689] | 278 | DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
|
---|
| 279 | DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
|
---|
| 280 | DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
|
---|
| 281 | //FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), FLrHook_DebugNameShadeHack);
|
---|
[677] | 282 |
|
---|
| 283 | //Make the background black for additive blending
|
---|
[689] | 284 | //FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), FLrHook_DebugNameTextureInit );
|
---|
[677] | 285 | }
|
---|
| 286 |
|
---|
| 287 | if(1)
|
---|
| 288 | {
|
---|
[689] | 289 | //DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
|
---|
| 290 | //DDrPatch_MakeCall((void*)(OniExe + 0x000E17F6), FLrHook_Lasers );
|
---|
[677] | 291 | }
|
---|
| 292 |
|
---|
| 293 | //Flatline related stuff
|
---|
[689] | 294 | // DDrPatch_MakeCall((void*)(OniExe + 0x000FBCEA), DDrText_Hook);
|
---|
[677] | 295 |
|
---|
[689] | 296 | //FLATLINE? DDrPatch_Int32((int*)(OniExe + 0x000B24D2), FLrSpawnHack);
|
---|
[677] | 297 |
|
---|
[689] | 298 | //FLATLINE? DDrPatch_NOOP((char*)(OniExe + 0x000C26CB), 6);
|
---|
[677] | 299 |
|
---|
[689] | 300 | //FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x000C26CB), FLrHook_DoorOpen);
|
---|
| 301 | //FLATLINE? DDrPatch_MakeCall((void*)(OniExe + 0x000EE3CF), FLrHook_ConsoleActivate);
|
---|
[693] | 302 |
|
---|
| 303 |
|
---|
| 304 | // Fix options not visible in main menu when a game was started
|
---|
| 305 | if(patch_optionsvisible)
|
---|
| 306 | {
|
---|
| 307 | DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
|
---|
| 308 | DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
|
---|
| 309 | }
|
---|
| 310 |
|
---|
[272] | 311 | return true;
|
---|
| 312 | }
|
---|
| 313 |
|
---|
[693] | 314 |
|
---|
[445] | 315 | enum {s_unknown, s_options, s_patch, s_bsl, s_language} ini_section;
|
---|
[346] | 316 |
|
---|
| 317 | bool DDrIniCallback(char* section, bool newsection, char* name, char* value)
|
---|
| 318 | {
|
---|
| 319 | if (newsection)
|
---|
| 320 | {
|
---|
[677] | 321 | if (!_stricmp(section, "options"))
|
---|
[439] | 322 | ini_section = s_options;
|
---|
[677] | 323 | else if (!_stricmp(section, "patch"))
|
---|
[347] | 324 | ini_section = s_patch;
|
---|
[677] | 325 | else if (!_stricmp(section, "bsl"))
|
---|
[445] | 326 | ini_section = s_bsl;
|
---|
[677] | 327 | else if (!_stricmp(section, "language"))
|
---|
[346] | 328 | ini_section = s_language;
|
---|
| 329 | else
|
---|
| 330 | {
|
---|
| 331 | ini_section = s_unknown;
|
---|
[466] | 332 | DDrStartupMessage("unrecognised section \"%s\"", section);
|
---|
[346] | 333 | }
|
---|
| 334 | }
|
---|
| 335 |
|
---|
| 336 | switch (ini_section)
|
---|
| 337 | {
|
---|
[439] | 338 | case s_options:
|
---|
[677] | 339 | if (!_stricmp(name, "usedaodanbsl"))
|
---|
| 340 | opt_usedaodanbsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 341 | else if (!_stricmp(name, "border"))
|
---|
| 342 | opt_border = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 343 | else if (!_stricmp(name, "topmost"))
|
---|
| 344 | opt_topmost = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 345 | else if (!_stricmp(name, "multibyte"))
|
---|
| 346 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 347 | else if (!_stricmp(name, "debug"))
|
---|
| 348 | AKgDebug_DebugMaps = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 349 | else if (!_stricmp(name, "debugfiles"))
|
---|
| 350 | BFgDebugFileEnable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 351 | else if (!_stricmp(name, "findsounds"))
|
---|
| 352 | SSgSearchOnDisk = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 353 | else if (!_stricmp(name, "ignore_private_data"))
|
---|
| 354 | opt_ignore_private_data = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 355 | else if (!_stricmp(name, "sound"))
|
---|
| 356 | opt_sound = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 357 | else if (!_stricmp(name, "switch"))
|
---|
| 358 | M3gResolutionSwitch = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[466] | 359 | else
|
---|
| 360 | DDrStartupMessage("unrecognised option \"%s\"", name);
|
---|
[439] | 361 | break;
|
---|
[347] | 362 | case s_patch:
|
---|
[677] | 363 | if (!_stricmp(name, "fonttexturecache"))
|
---|
| 364 | patch_fonttexturecache = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 365 | else if (!_stricmp(name, "largetextures"))
|
---|
| 366 | patch_largetextures = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 367 | else if (!_stricmp(name, "levelplugins"))
|
---|
| 368 | patch_levelplugins = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 369 | else if (!_stricmp(name, "pathfinding"))
|
---|
| 370 | patch_pathfinding = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 371 | else if (!_stricmp(name, "projaware"))
|
---|
| 372 | patch_projaware = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 373 | else if (!_stricmp(name, "directinput"))
|
---|
| 374 | patch_directinput = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 375 | else if (!_stricmp(name, "wpfadetime"))
|
---|
| 376 | patch_wpfadetime = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 377 | else if (!_stricmp(name, "kickguns"))
|
---|
| 378 | patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 379 | else if (!_stricmp(name, "cooldowntimer"))
|
---|
| 380 | patch_cooldowntimer = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 381 | else if (!_stricmp(name, "throwtest"))
|
---|
| 382 | patch_throwtest = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 383 | else if (!_stricmp(name, "alttab"))
|
---|
| 384 | patch_alttab = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 385 | else if (!_stricmp(name, "particledisablebit"))
|
---|
| 386 | patch_particledisablebit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 387 | else if (!_stricmp(name, "multibyte"))
|
---|
| 388 | patch_multibyte = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 389 | else if (!_stricmp(name, "cheattable"))
|
---|
| 390 | patch_cheattable = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 391 | else if (!_stricmp(name, "argb8888"))
|
---|
| 392 | patch_argb8888 = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 393 | else if (!_stricmp(name, "killvtune"))
|
---|
| 394 | patch_killvtune = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 395 | else if (!_stricmp(name, "getcmdline"))
|
---|
| 396 | patch_getcmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 397 | else if (!_stricmp(name, "disablecmdline"))
|
---|
| 398 | patch_disablecmdline = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 399 | else if (!_stricmp(name, "safeprintf"))
|
---|
| 400 | patch_safeprintf = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 401 | else if (!_stricmp(name, "daodandisplayenum"))
|
---|
| 402 | patch_daodandisplayenum = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 403 | else if (!_stricmp(name, "usegettickcount"))
|
---|
| 404 | patch_usegettickcount = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 405 | else if (!_stricmp(name, "cheatsenabled"))
|
---|
| 406 | patch_cheatsenabled = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 407 | else if (!_stricmp(name, "usedaodangl"))
|
---|
| 408 | patch_usedaodangl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 409 | else if (!_stricmp(name, "windowhack"))
|
---|
| 410 | patch_windowhack = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 411 | else if (!_stricmp(name, "daodaninit"))
|
---|
| 412 | patch_daodaninit = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 413 | else if (!_stricmp(name, "bsl"))
|
---|
| 414 | patch_bsl = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 415 | else if (!_stricmp(name, "cheater"))
|
---|
| 416 | patch_cheater = !_stricmp(inifile_cleanstr(value), "true");
|
---|
| 417 | else if (!_stricmp(name, "newweap"))
|
---|
| 418 | patch_newweapon = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[693] | 419 | else if (!_stricmp(name, "optionsvisible"))
|
---|
| 420 | patch_optionsvisible = !_stricmp(inifile_cleanstr(value), "true");
|
---|
[347] | 421 | else
|
---|
| 422 | DDrStartupMessage("unrecognised patch \"%s\"", name);
|
---|
| 423 | break;
|
---|
[346] | 424 | case s_language:
|
---|
[677] | 425 | if (!_stricmp(name, "chinese"))
|
---|
| 426 | patch_chinese = true;
|
---|
| 427 | else if (!_stricmp(name, "savepoint"))
|
---|
[346] | 428 | {
|
---|
[677] | 429 | char* str = _strdup(value);
|
---|
[689] | 430 | DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
|
---|
| 431 | DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
|
---|
[346] | 432 | }
|
---|
[677] | 433 | else if (!_stricmp(name, "syndicatewarehouse"))
|
---|
[346] | 434 | {
|
---|
[677] | 435 | char* str = _strdup(value);
|
---|
[689] | 436 | DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
|
---|
| 437 | DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
|
---|
[346] | 438 | }
|
---|
[677] | 439 | else if (!_stricmp(name, "damn"))
|
---|
[689] | 440 | DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
|
---|
[677] | 441 | else if (!_stricmp(name, "blam"))
|
---|
[689] | 442 | DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
|
---|
[677] | 443 | else if (!_stricmp(name, "shapeshifter_on"))
|
---|
| 444 | DDr_CheatTable[0].message_on = _strdup(value);
|
---|
| 445 | else if (!_stricmp(name, "shapeshifter_off"))
|
---|
| 446 | DDr_CheatTable[0].message_off = _strdup(value);
|
---|
| 447 | else if (!_stricmp(name, "liveforever_on"))
|
---|
| 448 | DDr_CheatTable[1].message_on = _strdup(value);
|
---|
| 449 | else if (!_stricmp(name, "liveforever_off"))
|
---|
| 450 | DDr_CheatTable[1].message_off = _strdup(value);
|
---|
| 451 | else if (!_stricmp(name, "touchofdeath_on"))
|
---|
| 452 | DDr_CheatTable[2].message_on = _strdup(value);
|
---|
| 453 | else if (!_stricmp(name, "touchofdeath_off"))
|
---|
| 454 | DDr_CheatTable[2].message_off = _strdup(value);
|
---|
| 455 | else if (!_stricmp(name, "canttouchthis_on"))
|
---|
| 456 | DDr_CheatTable[3].message_on = _strdup(value);
|
---|
| 457 | else if (!_stricmp(name, "canttouchthis_off"))
|
---|
| 458 | DDr_CheatTable[3].message_off = _strdup(value);
|
---|
| 459 | else if (!_stricmp(name, "fatloot_on"))
|
---|
| 460 | DDr_CheatTable[4].message_on = _strdup(value);
|
---|
| 461 | else if (!_stricmp(name, "glassworld_on"))
|
---|
| 462 | DDr_CheatTable[5].message_on = _strdup(value);
|
---|
| 463 | else if (!_stricmp(name, "glassworld_off"))
|
---|
| 464 | DDr_CheatTable[5].message_off = _strdup(value);
|
---|
| 465 | else if (!_stricmp(name, "winlevel_on"))
|
---|
| 466 | DDr_CheatTable[6].message_on = _strdup(value);
|
---|
| 467 | else if (!_stricmp(name, "loselevel_on"))
|
---|
| 468 | DDr_CheatTable[7].message_on = _strdup(value);
|
---|
| 469 | else if (!_stricmp(name, "bighead_on"))
|
---|
| 470 | DDr_CheatTable[8].message_on = _strdup(value);
|
---|
| 471 | else if (!_stricmp(name, "bighead_off"))
|
---|
| 472 | DDr_CheatTable[8].message_off = _strdup(value);
|
---|
| 473 | else if (!_stricmp(name, "minime_on"))
|
---|
| 474 | DDr_CheatTable[9].message_on = _strdup(value);
|
---|
| 475 | else if (!_stricmp(name, "minime_off"))
|
---|
| 476 | DDr_CheatTable[9].message_off = _strdup(value);
|
---|
| 477 | else if (!_stricmp(name, "superammo_on"))
|
---|
| 478 | DDr_CheatTable[10].message_on = _strdup(value);
|
---|
| 479 | else if (!_stricmp(name, "superammo_off"))
|
---|
| 480 | DDr_CheatTable[10].message_off = _strdup(value);
|
---|
| 481 | else if (!_stricmp(name, "devmode_on"))
|
---|
[349] | 482 | {
|
---|
[677] | 483 | char* str = _strdup(value);
|
---|
[349] | 484 | DDr_CheatTable[11].message_on = str;
|
---|
[452] | 485 | DDr_CheatTable[cheat_x].message_on = str;
|
---|
[349] | 486 | }
|
---|
[677] | 487 | else if (!_stricmp(name, "devmode_off"))
|
---|
[349] | 488 | {
|
---|
[677] | 489 | char* str = _strdup(value);
|
---|
[349] | 490 | DDr_CheatTable[11].message_off = str;
|
---|
[452] | 491 | DDr_CheatTable[cheat_x].message_off = str;
|
---|
[349] | 492 | }
|
---|
[677] | 493 | else if (!_stricmp(name, "reservoirdogs_on"))
|
---|
| 494 | DDr_CheatTable[12].message_on = _strdup(value);
|
---|
| 495 | else if (!_stricmp(name, "reservoirdogs_off"))
|
---|
| 496 | DDr_CheatTable[12].message_off = _strdup(value);
|
---|
| 497 | else if (!_stricmp(name, "roughjustice_on"))
|
---|
| 498 | DDr_CheatTable[13].message_on = _strdup(value);
|
---|
| 499 | else if (!_stricmp(name, "roughjustice_off"))
|
---|
| 500 | DDr_CheatTable[13].message_off = _strdup(value);
|
---|
| 501 | else if (!_stricmp(name, "chenille_on"))
|
---|
| 502 | DDr_CheatTable[14].message_on = _strdup(value);
|
---|
| 503 | else if (!_stricmp(name, "chenille_off"))
|
---|
| 504 | DDr_CheatTable[14].message_off = _strdup(value);
|
---|
| 505 | else if (!_stricmp(name, "behemoth_on"))
|
---|
| 506 | DDr_CheatTable[15].message_on = _strdup(value);
|
---|
| 507 | else if (!_stricmp(name, "behemoth_off"))
|
---|
| 508 | DDr_CheatTable[15].message_off = _strdup(value);
|
---|
| 509 | else if (!_stricmp(name, "elderrune_on"))
|
---|
| 510 | DDr_CheatTable[16].message_on = _strdup(value);
|
---|
| 511 | else if (!_stricmp(name, "elderrune_off"))
|
---|
| 512 | DDr_CheatTable[16].message_off = _strdup(value);
|
---|
| 513 | else if (!_stricmp(name, "moonshadow_on"))
|
---|
| 514 | DDr_CheatTable[17].message_on = _strdup(value);
|
---|
| 515 | else if (!_stricmp(name, "moonshadow_off"))
|
---|
| 516 | DDr_CheatTable[17].message_off = _strdup(value);
|
---|
| 517 | else if (!_stricmp(name, "munitionfrenzy_on"))
|
---|
| 518 | DDr_CheatTable[18].message_on = _strdup(value);
|
---|
| 519 | else if (!_stricmp(name, "fistsoflegend_on"))
|
---|
| 520 | DDr_CheatTable[19].message_on = _strdup(value);
|
---|
| 521 | else if (!_stricmp(name, "fistsoflegend_off"))
|
---|
| 522 | DDr_CheatTable[19].message_off = _strdup(value);
|
---|
| 523 | else if (!_stricmp(name, "killmequick_on"))
|
---|
| 524 | DDr_CheatTable[20].message_on = _strdup(value);
|
---|
| 525 | else if (!_stricmp(name, "killmequick_off"))
|
---|
| 526 | DDr_CheatTable[20].message_off = _strdup(value);
|
---|
| 527 | else if (!_stricmp(name, "carousel_on"))
|
---|
| 528 | DDr_CheatTable[21].message_on = _strdup(value);
|
---|
| 529 | else if (!_stricmp(name, "carousel_off"))
|
---|
| 530 | DDr_CheatTable[21].message_off = _strdup(value);
|
---|
[346] | 531 | else
|
---|
| 532 | DDrStartupMessage("unrecognised language item \"%s\"", name);
|
---|
| 533 | break;
|
---|
[451] | 534 | case s_bsl:
|
---|
[346] | 535 | default:
|
---|
| 536 | break;
|
---|
| 537 | }
|
---|
| 538 |
|
---|
| 539 | return true;
|
---|
| 540 | }
|
---|
| 541 |
|
---|
| 542 | void DDrConfig()
|
---|
| 543 | {
|
---|
[677] | 544 |
|
---|
[346] | 545 | if (GetFileAttributes("daodan.ini") == INVALID_FILE_ATTRIBUTES)
|
---|
| 546 | {
|
---|
[677] | 547 | FILE* fp;
|
---|
[346] | 548 | DDrStartupMessage("daodan.ini doesn't exist, creating");
|
---|
[677] | 549 | fp = fopen("daodan.ini", "w");
|
---|
[346] | 550 | if (fp)
|
---|
| 551 | {
|
---|
| 552 | fputs("[Options]\n", fp);
|
---|
| 553 | fclose(fp);
|
---|
| 554 | }
|
---|
| 555 | }
|
---|
| 556 |
|
---|
| 557 | DDrStartupMessage("parsing daodan.ini...");
|
---|
| 558 | if (!inifile_read("daodan.ini", DDrIniCallback))
|
---|
| 559 | DDrStartupMessage("error reading daodan.ini, check your syntax!");
|
---|
| 560 | DDrStartupMessage("finished parsing");
|
---|
| 561 | }
|
---|
| 562 |
|
---|
[439] | 563 | void ONICALL DDrGame_Init()
|
---|
| 564 | {
|
---|
| 565 | if (opt_usedaodanbsl)
|
---|
| 566 | SLrDaodan_Initalize();
|
---|
| 567 | }
|
---|
| 568 |
|
---|
[677] | 569 | void DDrException() {
|
---|
| 570 | int* i = 0;
|
---|
| 571 | *i = 1;
|
---|
| 572 | }
|
---|
| 573 | #include <stdio.h>
|
---|
| 574 |
|
---|
| 575 | //this was broken
|
---|
| 576 | FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
|
---|
| 577 | FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
|
---|
| 578 | {
|
---|
| 579 |
|
---|
| 580 | FILE *v4; // eax@1
|
---|
| 581 | FILE *result; // eax@4
|
---|
| 582 | char v6[512]; // [sp+0h] [bp-100h]@1
|
---|
| 583 | FILE* UUgError_WarningFile = *_UUgError_WarningFile;
|
---|
| 584 |
|
---|
[689] | 585 | if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
|
---|
[681] | 586 | sprintf(
|
---|
| 587 | v6,
|
---|
| 588 | "Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
|
---|
| 589 | errornum,
|
---|
[689] | 590 | (const char*)filename,
|
---|
[681] | 591 | linenumber,
|
---|
[689] | 592 | (const char*)message);
|
---|
[681] | 593 |
|
---|
| 594 | if ( UUgError_WarningFile
|
---|
| 595 | || (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
|
---|
| 596 | {
|
---|
| 597 | oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
|
---|
| 598 | oni_fflush(UUgError_WarningFile);
|
---|
| 599 | }
|
---|
[677] | 600 | }
|
---|
| 601 | //oni_fprintf(stdout, v6);
|
---|
| 602 | //sprintf(&v6, "%s", message);
|
---|
| 603 | *_UUgError_WarningFile = UUgError_WarningFile;
|
---|
| 604 | result = UUgError_WarningFile;
|
---|
| 605 | return result;
|
---|
| 606 | }
|
---|
| 607 |
|
---|
[274] | 608 | void __cdecl DDrMain(int argc, char* argv[])
|
---|
[273] | 609 | {
|
---|
[677] | 610 | int i;
|
---|
| 611 | char* section;
|
---|
| 612 | char* option;
|
---|
| 613 | bool falseoption;
|
---|
| 614 |
|
---|
[346] | 615 | DDrStartupMessage("daodan attached!");
|
---|
[466] | 616 |
|
---|
[690] | 617 | // Tell Oni to not load non levelX_final-files by default:
|
---|
[466] | 618 | opt_ignore_private_data = false;
|
---|
[690] | 619 |
|
---|
| 620 | // Enable sound by default:
|
---|
[466] | 621 | opt_sound = true;
|
---|
| 622 |
|
---|
[346] | 623 | DDrConfig();
|
---|
[466] | 624 | DDrStartupMessage("parsing command line...");
|
---|
| 625 | for (i = 1; i < argc; i ++)
|
---|
| 626 | {
|
---|
| 627 | if (argv[i][0] == '-')
|
---|
| 628 | {
|
---|
| 629 | section = argv[i] + 1;
|
---|
| 630 | if ((option = strchr(argv[i], '.')))
|
---|
| 631 | {
|
---|
| 632 | *option = '\0';
|
---|
| 633 | falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] = 'o' || option[2] == 'O');
|
---|
| 634 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
[467] | 635 | DDrIniCallback(section, true, option + 1, argv[++i]);
|
---|
[466] | 636 | else
|
---|
| 637 | DDrIniCallback(section, true, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
|
---|
| 638 | *option = '.';
|
---|
| 639 | }
|
---|
| 640 | else
|
---|
| 641 | {
|
---|
| 642 | falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] = 'o' || section[1] == 'O');
|
---|
| 643 | ini_section = s_options;
|
---|
| 644 | if (i < (argc - 1) && argv[i + 1][0] != '-')
|
---|
[467] | 645 | DDrIniCallback(NULL, false, section, argv[++i]);
|
---|
[466] | 646 | else
|
---|
| 647 | DDrIniCallback(NULL, false, section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
|
---|
| 648 | }
|
---|
| 649 | }
|
---|
| 650 | else
|
---|
| 651 | {
|
---|
| 652 | DDrStartupMessage("parse error \"%s\"", argv[i]);
|
---|
| 653 | break;
|
---|
| 654 | }
|
---|
| 655 | }
|
---|
| 656 | DDrStartupMessage("finished parsing");
|
---|
[273] | 657 | DDrPatch_Init();
|
---|
| 658 |
|
---|
| 659 | // Safe startup message printer
|
---|
[347] | 660 | if (patch_safeprintf)
|
---|
[689] | 661 | DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
|
---|
[273] | 662 |
|
---|
[297] | 663 | // Daodan device mode enumeration function
|
---|
[347] | 664 | if (patch_daodandisplayenum)
|
---|
[689] | 665 | DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)daodan_enumerate_valid_display_modes);
|
---|
[297] | 666 |
|
---|
| 667 | // Performance patch
|
---|
[347] | 668 | if (patch_usegettickcount)
|
---|
| 669 | {
|
---|
[689] | 670 | DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
|
---|
| 671 | DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
|
---|
| 672 | DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
|
---|
[347] | 673 | }
|
---|
[677] | 674 |
|
---|
[339] | 675 | // Cheats always enabled
|
---|
[348] | 676 | if (patch_cheatsenabled)
|
---|
[689] | 677 | DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
|
---|
[677] | 678 |
|
---|
[323] | 679 | // Windowed mode
|
---|
[347] | 680 | if (patch_usedaodangl)
|
---|
| 681 | {
|
---|
[689] | 682 | DDrPatch_NOOP((char*)(OniExe + 0x000032B7), 6);
|
---|
| 683 | DDrPatch_MakeCall((void*)(OniExe + 0x000032B7), (void*)LIiP_SetCursorPosHook);
|
---|
[677] | 684 |
|
---|
[689] | 685 | DDrPatch_NOOP((char*)(OniExe + 0x00003349), 6);
|
---|
| 686 | DDrPatch_MakeCall((void*)(OniExe + 0x00003349), (void*)LIiP_SetCursorPosHook);
|
---|
| 687 | DDrPatch_MakeJump((void*)ONrPlatform_Initialize, (void*)DDrPlatform_Initialize);
|
---|
| 688 | DDrPatch_MakeJump((void*)gl_platform_initialize, (void*)daodangl_platform_initialize);
|
---|
[347] | 689 | }
|
---|
[349] | 690 | // Hacked windowed mode (for when daodangl isn't working properly)
|
---|
[677] | 691 | else if (patch_windowhack)
|
---|
[349] | 692 | DDrWindowHack_Install();
|
---|
| 693 |
|
---|
[439] | 694 | if (patch_daodaninit)
|
---|
[689] | 695 | DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
|
---|
[439] | 696 |
|
---|
[447] | 697 | // Patches for existing BSL functions
|
---|
| 698 | if (patch_bsl)
|
---|
| 699 | SLrDaodan_Patch();
|
---|
[677] | 700 |
|
---|
[452] | 701 | if (patch_cheater)
|
---|
[455] | 702 | {
|
---|
[689] | 703 | DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
|
---|
| 704 | DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
|
---|
[677] | 705 | #if 1
|
---|
[689] | 706 | DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
|
---|
[677] | 707 | #endif
|
---|
[689] | 708 | DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
|
---|
[455] | 709 | }
|
---|
[677] | 710 |
|
---|
[689] | 711 | DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
|
---|
[452] | 712 |
|
---|
[677] | 713 | ONiMain(argc, argv);
|
---|
[273] | 714 | }
|
---|
[465] | 715 | /*
|
---|
| 716 | void DDrWrongExe()
|
---|
| 717 | {
|
---|
| 718 | switch (MessageBox(NULL, "This version of the Daodan DLL is incompatible with your Oni.exe.\n"
|
---|
| 719 | "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))
|
---|
| 720 | {
|
---|
| 721 | case IDOK:
|
---|
| 722 | {
|
---|
| 723 | STARTUPINFO si;
|
---|
| 724 | PROCESS_INFORMATION pi;
|
---|
| 725 | FillMemory(&si, 0, sizeof(si));
|
---|
| 726 | FillMemory(&pi, 0, sizeof(pi));
|
---|
| 727 | si.cb = sizeof(si);
|
---|
| 728 | if (!CreateProcess(NULL, "cmd /c \"start http://wiki.oni2.net/Daodan_DLL\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
|
---|
| 729 | MessageBox(NULL, "", "", 0);
|
---|
| 730 | CloseHandle(pi.hProcess);
|
---|
| 731 | CloseHandle(pi.hThread);
|
---|
| 732 | }
|
---|
| 733 | default:
|
---|
| 734 | ExitProcess(0);
|
---|
| 735 | }
|
---|
| 736 | }
|
---|
| 737 | */
|
---|
[272] | 738 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
---|
| 739 | {
|
---|
| 740 | switch (fdwReason)
|
---|
| 741 | {
|
---|
| 742 | case DLL_PROCESS_ATTACH:
|
---|
| 743 | DDrDLLModule = hinstDLL;
|
---|
| 744 | DDrONiModule = GetModuleHandle(NULL);
|
---|
| 745 |
|
---|
[677] | 746 | if (*(uint32_t*)(OniExe + 0x0011acd0) == 0x09d36852)
|
---|
[689] | 747 | DDrPatch_MakeCall((void*)(OniExe + 0x0010fb49), (void*)DDrMain);
|
---|
[465] | 748 | else
|
---|
| 749 | ExitProcess(0);
|
---|
[272] | 750 | break;
|
---|
| 751 | }
|
---|
| 752 | return TRUE;
|
---|
| 753 | }
|
---|