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