From b60c4dbfcf52e86094cbca57e7cda832c78b9c4b Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 18 Sep 2017 23:11:19 +0200 Subject: [PATCH] FILE_FLAG_NO_BUFFERING fix moved to fixes-shared-with-ddraw --- DDraw/dllmain.cpp | 6 ++++-- SilentPatch/Common.cpp | 17 ++++++++++++++++- SilentPatch/Common.h | 2 ++ SilentPatchIII/SilentPatchIII.cpp | 8 +------- SilentPatchVC/SilentPatchVC.cpp | 8 +------- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp index 2397e56..8979a21 100644 --- a/DDraw/dllmain.cpp +++ b/DDraw/dllmain.cpp @@ -47,14 +47,14 @@ char* GetMyDocumentsPath() void InjectHooks() { - using namespace Memory::VP; - static char aNoDesktopMode[64]; RECT desktop; GetWindowRect(GetDesktopWindow(), &desktop); sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + std::unique_ptr Protect = ScopedUnprotect::UnprotectSectionOrFullModule( GetModuleHandle( nullptr ), ".text" ); + if (*(DWORD*)0x5C1E75 == 0xB85548EC) { // III 1.0 @@ -92,6 +92,8 @@ void InjectHooks() ppUserFilesDir = (char**)0x601ECA; Common::Patches::DDraw_VC_Steam( desktop, aNoDesktopMode ); } + + Common::Patches::DDraw_Common(); } static bool rwcsegUnprotected = false; diff --git a/SilentPatch/Common.cpp b/SilentPatch/Common.cpp index a875fec..a28c02e 100644 --- a/SilentPatch/Common.cpp +++ b/SilentPatch/Common.cpp @@ -104,7 +104,6 @@ namespace Common { } // ================= VC ================= - void DDraw_VC_10( const RECT& desktop, const char* desktopText ) { using namespace Memory; @@ -171,5 +170,21 @@ namespace Common { Patch(0x601910, 0xB8); Patch(0x601911, 0x900); } + + // ================= COMMON ================= + void DDraw_Common() + { + using namespace Memory; + using namespace hook; + + // Remove FILE_FLAG_NO_BUFFERING from CdStreams + { + auto mem = pattern( "81 7C 24 04 00 08 00 00" ).count_hint(1); + if ( mem.size() == 1 ) + { + Patch( mem.get_first( 0x12 ), 0xEB ); + } + } + } } } \ No newline at end of file diff --git a/SilentPatch/Common.h b/SilentPatch/Common.h index 7d04629..f3964e3 100644 --- a/SilentPatch/Common.h +++ b/SilentPatch/Common.h @@ -21,5 +21,7 @@ namespace Common void DDraw_VC_10( const RECT& desktop, const char* desktopText ); void DDraw_VC_11( const RECT& desktop, const char* desktopText ); void DDraw_VC_Steam( const RECT& desktop, const char* desktopText ); + + void DDraw_Common(); } }; \ No newline at end of file diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index ccad529..a76ed2a 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -752,12 +752,6 @@ void Patch_III_Common() InjectHook( hookPoint.get( 0x21 + 5 ), jmpPoint, PATCH_JUMP ); } - // Remove FILE_FLAG_NO_BUFFERING from CdStreams - { - auto addr = get_pattern( "81 7C 24 04 00 08 00 00", 0x12 ); - Patch( addr, 0xEB ); - } - // Alt+F4 { auto addr = pattern( "59 59 31 C0 83 C4 48 5D 5F 5E 5B C2 10 00" ).count(2); @@ -841,9 +835,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) if (*(DWORD*)0x5C1E75 == 0xB85548EC) Patch_III_10(desktop); else if (*(DWORD*)0x5C2135 == 0xB85548EC) Patch_III_11(desktop); else if (*(DWORD*)0x5C6FD5 == 0xB85548EC) Patch_III_Steam(desktop); - else return TRUE; Patch_III_Common(); + Common::Patches::DDraw_Common(); } Common::Patches::FixRwcseg_Patterns(); diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 54ecdec..89ea2c5 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -559,12 +559,6 @@ void Patch_VC_Common() InjectHook( hookPoint.get( 0x21 + 5 ), jmpPoint, PATCH_JUMP ); } - // Remove FILE_FLAG_NO_BUFFERING from CdStreams - { - auto addr = get_pattern( "81 7C 24 04 00 08 00 00", 0x12 ); - Patch( addr, 0xEB ); - } - // Alt+F4 { auto addr = pattern( "59 59 31 C0 83 C4 70 5D 5F 5E 5B C2 10 00" ).count(2); @@ -656,9 +650,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) // Y axis sensitivity only else if (*(DWORD*)0x601048 == 0x5E5F5D60) Patch_VC_JP(); - else return TRUE; Patch_VC_Common(); + Common::Patches::DDraw_Common(); } Common::Patches::FixRwcseg_Patterns();