diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp index 2542fbb..d4ba221 100644 --- a/DDraw/dllmain.cpp +++ b/DDraw/dllmain.cpp @@ -193,10 +193,9 @@ void PatchIAT() IMAGE_NT_HEADERS* ntHeader = (IMAGE_NT_HEADERS*)((DWORD)hInstance + ((IMAGE_DOS_HEADER*)hInstance)->e_lfanew); // Give _rwcseg proper access rights - WORD NumberOfSections = ntHeader->FileHeader.NumberOfSections; IMAGE_SECTION_HEADER* pSection = IMAGE_FIRST_SECTION(ntHeader); - for ( WORD i = 0; i < NumberOfSections; i++, pSection++ ) + for ( SIZE_T i = 0, j = ntHeader->FileHeader.NumberOfSections; i < j; i++, pSection++ ) { if ( *(uint64_t*)(pSection->Name) == 0x006765736377725F ) // _rwcseg { diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index e580cff..85b0ed8 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -317,7 +317,6 @@ static char aNoDesktopMode[64]; void Patch_III_10(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); DrawRect = (void(*)(const CRect&,const CRGBA&))0x51F970; SetScale = (void(*)(float,float))0x501B80; @@ -498,7 +497,6 @@ void Patch_III_10(const RECT& desktop) void Patch_III_11(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); DrawRect = (void(*)(const CRect&,const CRGBA&))0x51FBA0; SetScale = (void(*)(float,float))0x501C60; @@ -658,7 +656,6 @@ void Patch_III_11(const RECT& desktop) void Patch_III_Steam(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); DrawRect = (void(*)(const CRect&,const CRGBA&))0x51FB30; SetScale = (void(*)(float,float))0x501BF0; @@ -814,6 +811,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) GetWindowRect(GetDesktopWindow(), &desktop); sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); + 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); diff --git a/SilentPatchIII/SilentPatchIII.vcxproj b/SilentPatchIII/SilentPatchIII.vcxproj index 546e4c6..f7a1b2d 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj +++ b/SilentPatchIII/SilentPatchIII.vcxproj @@ -72,6 +72,7 @@ Use StdAfx.h NoExtensions + Fast true @@ -100,6 +101,7 @@ Use StdAfx.h NoExtensions + Fast false diff --git a/SilentPatchSA/GeneralSA.cpp b/SilentPatchSA/GeneralSA.cpp index 20f3263..083fd5f 100644 --- a/SilentPatchSA/GeneralSA.cpp +++ b/SilentPatchSA/GeneralSA.cpp @@ -116,7 +116,7 @@ void CEscalator::SwitchOffNoRemove() if ( !m_bExists ) return; - for ( int i = 0, j = field_7C + field_80 + field_84; i < j; ++i ) + for ( ptrdiff_t i = 0, j = field_7C + field_80 + field_84; i < j; ++i ) { if ( m_pSteps[i] != nullptr ) { diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index 83c4fa9..d2f90dd 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -2614,9 +2614,6 @@ static char aNoDesktopMode[64]; void Patch_SA_10() { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); - ScopedUnprotect::Section Protect2( (HINSTANCE)0x400000, ".rdata" ); - // IsAlreadyRunning needs to be read relatively late - the later, the better int pIsAlreadyRunning = AddressByRegion_10(0x74872D); @@ -3028,8 +3025,6 @@ void Patch_SA_10() void Patch_SA_11() { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); - ScopedUnprotect::Section Protect2( (HINSTANCE)0x400000, ".rdata" ); // IsAlreadyRunning needs to be read relatively late - the later, the better int pIsAlreadyRunning = AddressByRegion_11(0x749000); @@ -3369,8 +3364,6 @@ void Patch_SA_11() void Patch_SA_Steam() { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); - ScopedUnprotect::Section Protect2( (HINSTANCE)0x400000, ".rdata" ); // IsAlreadyRunning needs to be read relatively late - the later, the better ReadCall( 0x7826ED, IsAlreadyRunning ); @@ -3725,8 +3718,6 @@ void Patch_SA_Steam() void Patch_SA_NewSteam_r1() { using namespace Memory::DynBase; - ScopedUnprotect::Section Protect( GetModuleHandle( nullptr ), ".text" ); - ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" ); // Nazi EXE? if ( *(DWORD*)DynBaseAddress(0x49F810) == 0x64EC8B55 ) @@ -3808,8 +3799,6 @@ void Patch_SA_NewSteam_r1() void Patch_SA_NewSteam_r2() { using namespace Memory::DynBase; - ScopedUnprotect::Section Protect( GetModuleHandle( nullptr ), ".text" ); - ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" ); // (Hopefully) more precise frame limiter ReadCall( DynBaseAddress(0x77D55F), RsEventHandler ); @@ -3997,8 +3986,6 @@ void Patch_SA_NewSteam_r2() void Patch_SA_NewSteam_r2_lv() { using namespace Memory::DynBase; - ScopedUnprotect::Section Protect( GetModuleHandle( nullptr ), ".text" ); - ScopedUnprotect::Section Protect2( GetModuleHandle( nullptr ), ".rdata" ); // (Hopefully) more precise frame limiter ReadCall( DynBaseAddress(0x77D44F), RsEventHandler ); @@ -4192,6 +4179,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { hDLLModule = hinstDLL; + HINSTANCE hGameHandle = GetModuleHandle( nullptr ); + ScopedUnprotect::Section Protect( hGameHandle, ".text" ); + ScopedUnprotect::Section Protect2( hGameHandle, ".rdata" ); + if (*(DWORD*)DynBaseAddress(0x82457C) == 0x94BF || *(DWORD*)DynBaseAddress(0x8245BC) == 0x94BF) Patch_SA_10(); else if (*(DWORD*)DynBaseAddress(0x8252FC) == 0x94BF || *(DWORD*)DynBaseAddress(0x82533C) == 0x94BF) Patch_SA_11(), MessageBox( nullptr, "You're using a 1.01 executable which is no longer supported by SilentPatch!\n\nI have no idea if anyone was still using it, so if you do - shoot me an e-mail!", "SilentPatch", MB_OK | MB_ICONWARNING ); else if (*(DWORD*)DynBaseAddress(0x85EC4A) == 0x94BF) Patch_SA_Steam(); diff --git a/SilentPatchSA/SilentPatchSA.vcxproj b/SilentPatchSA/SilentPatchSA.vcxproj index 0dc6685..8516c0e 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj +++ b/SilentPatchSA/SilentPatchSA.vcxproj @@ -60,6 +60,7 @@ StdAfxSA.h NoExtensions /Zc:threadSafeInit- %(AdditionalOptions) + Fast true @@ -92,6 +93,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio StdAfxSA.h NoExtensions /Zc:threadSafeInit- %(AdditionalOptions) + Fast true diff --git a/SilentPatchVC/SilentPatchVC.cpp b/SilentPatchVC/SilentPatchVC.cpp index 24fd715..3a80f40 100644 --- a/SilentPatchVC/SilentPatchVC.cpp +++ b/SilentPatchVC/SilentPatchVC.cpp @@ -195,7 +195,6 @@ static char aNoDesktopMode[64]; void Patch_VC_10(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F98D0; PrintString = (void(*)(float,float,const wchar_t*))0x551040; @@ -344,7 +343,6 @@ void Patch_VC_10(const RECT& desktop) void Patch_VC_11(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F98F0; PrintString = (void(*)(float,float,const wchar_t*))0x551060; @@ -484,7 +482,6 @@ void Patch_VC_11(const RECT& desktop) void Patch_VC_Steam(const RECT& desktop) { using namespace Memory; - ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F9530; PrintString = (void(*)(float,float,const wchar_t*))0x550F30; @@ -645,6 +642,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) GetWindowRect(GetDesktopWindow(), &desktop); sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + ScopedUnprotect::Section Protect( (HINSTANCE)0x400000, ".text" ); + if(*(DWORD*)0x667BF5 == 0xB85548EC) Patch_VC_10(desktop); else if(*(DWORD*)0x667C45 == 0xB85548EC) Patch_VC_11(desktop); else if (*(DWORD*)0x666BA5 == 0xB85548EC) Patch_VC_Steam(desktop); diff --git a/SilentPatchVC/SilentPatchVC.vcxproj b/SilentPatchVC/SilentPatchVC.vcxproj index 31cfd33..3b37224 100644 --- a/SilentPatchVC/SilentPatchVC.vcxproj +++ b/SilentPatchVC/SilentPatchVC.vcxproj @@ -58,6 +58,7 @@ Use StdAfx.h NoExtensions + Fast true @@ -84,6 +85,7 @@ Use StdAfx.h NoExtensions + Fast false