Obtain desktop resolution regardless of DPI scaling

Fixes "Cannot find X video mode" when DPI scaling is in use
This commit is contained in:
Silent 2021-07-26 23:52:20 +02:00
parent 177c096b69
commit 2af4ec8e06
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
16 changed files with 202 additions and 91 deletions

View File

@ -168,6 +168,7 @@ copy /y "$(TargetPath)" "D:\Steam\steamapps\common\Grand Theft Auto Vice City\dd
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Common_ddraw.cpp" />
<ClCompile Include="..\SilentPatch\Desktop.cpp" />
<ClCompile Include="..\SilentPatch\Utils\Patterns.cpp" />
<ClCompile Include="dllmain.cpp" />
</ItemGroup>
@ -176,6 +177,7 @@ copy /y "$(TargetPath)" "D:\Steam\steamapps\common\Grand Theft Auto Vice City\dd
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\Desktop.h" />
<ClInclude Include="..\SilentPatch\Utils\MemoryMgr.h" />
<ClInclude Include="..\SilentPatch\Utils\Patterns.h" />
</ItemGroup>

View File

@ -30,6 +30,9 @@
<ClCompile Include="..\SilentPatch\Utils\Patterns.cpp">
<Filter>Source Files\Utils</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common_ddraw.h">
@ -41,6 +44,9 @@
<ClInclude Include="..\SilentPatch\Utils\Patterns.h">
<Filter>Header Files\Utils</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Desktop.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -10,6 +10,7 @@
#include "Utils/Patterns.h"
#include "Common_ddraw.h"
#include "Desktop.h"
#pragma comment(lib, "shlwapi.lib")
@ -34,9 +35,8 @@ void InjectHooks()
{
static char aNoDesktopMode[64];
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
std::unique_ptr<ScopedUnprotect::Unprotect> Protect = ScopedUnprotect::UnprotectSectionOrFullModule( GetModuleHandle( nullptr ), ".text" );
@ -44,38 +44,38 @@ void InjectHooks()
{
// III 1.0
ppUserFilesDir = (char**)0x580C16;
Common::Patches::DDraw_III_10( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_10( width, height, aNoDesktopMode );
}
else if (*(DWORD*)0x5C2135 == 0xB85548EC)
{
// III 1.1
ppUserFilesDir = (char**)0x580F66;
Common::Patches::DDraw_III_11( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_11( width, height, aNoDesktopMode );
}
else if (*(DWORD*)0x5C6FD5 == 0xB85548EC)
{
// III Steam
ppUserFilesDir = (char**)0x580E66;
Common::Patches::DDraw_III_Steam( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_Steam( width, height, aNoDesktopMode );
}
else if (*(DWORD*)0x667BF5 == 0xB85548EC)
{
// VC 1.0
ppUserFilesDir = (char**)0x6022AA;
Common::Patches::DDraw_VC_10( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_10( width, height, aNoDesktopMode );
}
else if (*(DWORD*)0x667C45 == 0xB85548EC)
{
// VC 1.1
ppUserFilesDir = (char**)0x60228A;
Common::Patches::DDraw_VC_11( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_11( width, height, aNoDesktopMode );
}
else if (*(DWORD*)0x666BA5 == 0xB85548EC)
{
// VC Steam
ppUserFilesDir = (char**)0x601ECA;
Common::Patches::DDraw_VC_Steam( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_Steam( width, height, aNoDesktopMode );
}
Common::Patches::DDraw_Common();

View File

@ -1,5 +1,13 @@
#include "Common_ddraw.h"
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define NOMINMAX
#include <windows.h>
#include <Shlwapi.h>
#include <ShlObj.h>
#include "Utils/MemoryMgr.h"
@ -52,16 +60,19 @@ namespace Common {
}
// ================= III =================
void DDraw_III_10( const RECT& desktop, const char* desktopText )
void DDraw_III_10( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580BB0, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x581E5E, desktop.right);
Patch<DWORD>(0x581E68, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x581E5E, width);
Patch<DWORD>(0x581E68, height);
Patch<const char*>(0x581EA8, desktopText);
}
Patch<BYTE>(0x581E72, 32);
Patch<const char*>(0x581EA8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581411, 0xEB);
@ -71,16 +82,19 @@ namespace Common {
Patch<DWORD>(0x5812D7, 0x900);
}
void DDraw_III_11( const RECT& desktop, const char* desktopText )
void DDraw_III_11( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580F00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58219E, desktop.right);
Patch<DWORD>(0x5821A8, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x58219E, width);
Patch<DWORD>(0x5821A8, height);
Patch<const char*>(0x5821E8, desktopText);
}
Patch<BYTE>(0x5821B2, 32);
Patch<const char*>(0x5821E8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581753, 0xEB);
@ -90,16 +104,19 @@ namespace Common {
Patch<DWORD>(0x581621, 0x900);
}
void DDraw_III_Steam( const RECT& desktop, const char* desktopText )
void DDraw_III_Steam( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
InjectHook(0x580E00, GetMyDocumentsPath, PATCH_JUMP);
Patch<DWORD>(0x58208E, desktop.right);
Patch<DWORD>(0x582098, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x58208E, width);
Patch<DWORD>(0x582098, height);
Patch<const char*>(0x5820D8, desktopText);
}
Patch<BYTE>(0x5820A2, 32);
Patch<const char*>(0x5820D8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x581653, 0xEB);
@ -110,7 +127,7 @@ namespace Common {
}
// ================= VC =================
void DDraw_VC_10( const RECT& desktop, const char* desktopText )
void DDraw_VC_10( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
@ -119,10 +136,13 @@ namespace Common {
InjectHook(0x601A40, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A45, 0x601B2F, PATCH_JUMP);
Patch<DWORD>(0x600E7E, desktop.right);
Patch<DWORD>(0x600E88, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x600E7E, width);
Patch<DWORD>(0x600E88, height);
Patch<const char*>(0x600EC8, desktopText);
}
Patch<BYTE>(0x600E92, 32);
Patch<const char*>(0x600EC8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E26, 0xEB);
@ -132,7 +152,7 @@ namespace Common {
Patch<DWORD>(0x601CA1, 0x900);
}
void DDraw_VC_11( const RECT& desktop, const char* desktopText )
void DDraw_VC_11( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
@ -141,10 +161,13 @@ namespace Common {
InjectHook(0x601A70, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x601A75, 0x601B5F, PATCH_JUMP);
Patch<DWORD>(0x600E9E, desktop.right);
Patch<DWORD>(0x600EA8, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x600E9E, width);
Patch<DWORD>(0x600EA8, height);
Patch<const char*>(0x600EE8, desktopText);
}
Patch<BYTE>(0x600EB2, 32);
Patch<const char*>(0x600EE8, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601E56, 0xEB);
@ -155,7 +178,7 @@ namespace Common {
}
void DDraw_VC_Steam( const RECT& desktop, const char* desktopText )
void DDraw_VC_Steam( uint32_t width, uint32_t height, const char* desktopText )
{
using namespace Memory;
@ -164,10 +187,13 @@ namespace Common {
InjectHook(0x6016B0, GetMyDocumentsPath, PATCH_CALL);
InjectHook(0x6016B5, 0x60179F, PATCH_JUMP);
Patch<DWORD>(0x600ADE, desktop.right);
Patch<DWORD>(0x600AE8, desktop.bottom);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x600ADE, width);
Patch<DWORD>(0x600AE8, height);
Patch<const char*>(0x600B28, desktopText);
}
Patch<BYTE>(0x600AF2, 32);
Patch<const char*>(0x600B28, desktopText);
// No 12mb vram check
Patch<BYTE>(0x601A96, 0xEB);

View File

@ -1,12 +1,6 @@
#pragma once
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define NOMINMAX
#include <windows.h>
#include <cstdint>
namespace Common
{
@ -14,13 +8,13 @@ namespace Common
{
bool FixRwcseg_Patterns();
void DDraw_III_10( const RECT& desktop, const char* desktopText );
void DDraw_III_11( const RECT& desktop, const char* desktopText );
void DDraw_III_Steam( const RECT& desktop, const char* desktopText );
void DDraw_III_10( uint32_t width, uint32_t height, const char* desktopText );
void DDraw_III_11( uint32_t width, uint32_t height, const char* desktopText );
void DDraw_III_Steam( uint32_t width, uint32_t height, const char* desktopText );
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_VC_10( uint32_t width, uint32_t height, const char* desktopText );
void DDraw_VC_11( uint32_t width, uint32_t height, const char* desktopText );
void DDraw_VC_Steam( uint32_t width, uint32_t height, const char* desktopText );
void DDraw_Common();
}

24
SilentPatch/Desktop.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "Desktop.h"
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501
#define _WIN32_WINNT 0x0501
#define NOMINMAX
#include <windows.h>
std::pair<uint32_t, uint32_t> GetDesktopResolution()
{
std::pair<uint32_t, uint32_t> result {};
DEVMODEW displaySettings;
displaySettings.dmSize = sizeof(displaySettings);
displaySettings.dmDriverExtra = 0;
if (EnumDisplaySettingsW(nullptr, ENUM_CURRENT_SETTINGS, &displaySettings) != FALSE)
{
result.first = displaySettings.dmPelsWidth;
result.second = displaySettings.dmPelsHeight;
}
return result;
}

6
SilentPatch/Desktop.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
#include <utility>
#include <cstdint>
std::pair<uint32_t, uint32_t> GetDesktopResolution();

View File

@ -5,6 +5,7 @@
#include "Utils/Patterns.h"
#include "Common.h"
#include "Common_ddraw.h"
#include "Desktop.h"
#include "VehicleIII.h"
#include "ModelInfoIII.h"
@ -661,7 +662,7 @@ void InjectDelayedPatches_III_Common()
}
void Patch_III_10(const RECT& desktop)
void Patch_III_10(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -796,10 +797,10 @@ void Patch_III_10(const RECT& desktop)
}
#endif
Common::Patches::DDraw_III_10( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_10( width, height, aNoDesktopMode );
}
void Patch_III_11(const RECT& desktop)
void Patch_III_11(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -914,10 +915,10 @@ void Patch_III_11(const RECT& desktop)
// Fixed crash related to autopilot timing calculations
InjectHook(0x4139B2, AutoPilotTimerFix_III, PATCH_JUMP);
Common::Patches::DDraw_III_11( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_11( width, height, aNoDesktopMode );
}
void Patch_III_Steam(const RECT& desktop)
void Patch_III_Steam(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -1019,7 +1020,7 @@ void Patch_III_Steam(const RECT& desktop)
// Fixed crash related to autopilot timing calculations
InjectHook(0x4139B2, AutoPilotTimerFix_III, PATCH_JUMP);
Common::Patches::DDraw_III_Steam( desktop, aNoDesktopMode );
Common::Patches::DDraw_III_Steam( width, height, aNoDesktopMode );
}
void Patch_III_Common()
@ -1252,18 +1253,17 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hDLLModule = hinstDLL;
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
// This scope is mandatory so Protect goes out of scope before rwcseg gets fixed
{
std::unique_ptr<ScopedUnprotect::Unprotect> Protect = ScopedUnprotect::UnprotectSectionOrFullModule( GetModuleHandle( nullptr ), ".text" );
const int8_t version = Memory::GetVersion().version;
if ( version == 0 ) Patch_III_10(desktop);
else if ( version == 1 ) Patch_III_11(desktop);
else if ( version == 2 ) Patch_III_Steam(desktop);
if ( version == 0 ) Patch_III_10(width, height);
else if ( version == 1 ) Patch_III_11(width, height);
else if ( version == 2 ) Patch_III_Steam(width, height);
Patch_III_Common();
Common::Patches::III_VC_Common();

View File

@ -25,6 +25,11 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\RWGTA.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
@ -54,6 +59,7 @@
<ClInclude Include="..\SilentPatch\Common.h" />
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\debugmenu_public.h" />
<ClInclude Include="..\SilentPatch\Desktop.h" />
<ClInclude Include="..\SilentPatch\Maths.h" />
<ClInclude Include="..\SilentPatch\RWGTA.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" />

View File

@ -51,6 +51,9 @@
<ClCompile Include="..\SilentPatch\SVF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\Timer.h">
@ -95,6 +98,9 @@
<ClInclude Include="..\SilentPatch\SVF.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Desktop.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -25,6 +25,8 @@
#include "Utils/DelimStringReader.h"
#include "Utils/ModuleList.hpp"
#include "Desktop.h"
#include "debugmenu_public.h"
#include "resource.h"
@ -3759,13 +3761,15 @@ void Patch_SA_10()
Nop( 0x735881 + 11, 3 );
// Default resolution to native resolution
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
Patch<DWORD>(0x746363, desktop.right);
Patch<DWORD>(0x746368, desktop.bottom);
Patch<const char*>(0x7463C8, aNoDesktopMode);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x746363, width);
Patch<DWORD>(0x746368, height);
Patch<const char*>(0x7463C8, aNoDesktopMode);
}
// Corrected Map screen 1px issue
Patch<float>(0x575DE7, -0.5f);
@ -4516,13 +4520,15 @@ void Patch_SA_11()
Nop( 0x7360B1 + 11, 3 );
// Default resolution to native resolution
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
Patch<DWORD>(0x746BE3, desktop.right);
Patch<DWORD>(0x746BE8, desktop.bottom);
Patch<const char*>(0x746C48, aNoDesktopMode);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x746BE3, width);
Patch<DWORD>(0x746BE8, height);
Patch<const char*>(0x746C48, aNoDesktopMode);
}
// Corrected Map screen 1px issue
Patch<float>(0x576357, -0.5f);
@ -4825,13 +4831,15 @@ void Patch_SA_Steam()
Nop( 0x768046 + 16, 1 );
// Default resolution to native resolution
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
Patch<DWORD>(0x780219, desktop.right);
Patch<DWORD>(0x78021E, desktop.bottom);
Patch<const char*>(0x78027E, aNoDesktopMode);
if (width != 0 && height != 0)
{
Patch<DWORD>(0x780219, width);
Patch<DWORD>(0x78021E, height);
Patch<const char*>(0x78027E, aNoDesktopMode);
}
// Corrected Map screen 1px issue
/*Patch<float>(0x575DE7, -5.0f);

View File

@ -95,8 +95,11 @@
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r1\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r2\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"</Command>
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\San Andreas Multiplayer\SilentPatchSA.asi"
copy /y "$(TargetPath)" "H:\Rockstar Games\Grand Theft Auto San Andreas\SilentPatchSA.asi"</Command>
</PostBuildEvent>
<FxCompile>
<ShaderModel>2.0</ShaderModel>
@ -135,8 +138,11 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r1\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r2\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"</Command>
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\San Andreas Multiplayer\SilentPatchSA.asi"
copy /y "$(TargetPath)" "H:\Rockstar Games\Grand Theft Auto San Andreas\SilentPatchSA.asi"</Command>
</PostBuildEvent>
<FxCompile>
<ShaderModel>2.0</ShaderModel>
@ -175,8 +181,11 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r1\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\gta-sa_newsteam_r2\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"</Command>
copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowviolence_gta-sa\SilentPatchSA.asi"
copy /y "$(TargetPath)" "D:\gry\San Andreas Multiplayer\SilentPatchSA.asi"
copy /y "$(TargetPath)" "H:\Rockstar Games\Grand Theft Auto San Andreas\SilentPatchSA.asi"</Command>
</PostBuildEvent>
<FxCompile>
<ShaderModel>2.0</ShaderModel>
@ -186,6 +195,11 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\SVF.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
@ -223,6 +237,7 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\debugmenu_public.h" />
<ClInclude Include="..\SilentPatch\Desktop.h" />
<ClInclude Include="..\SilentPatch\FLAC\callback.h" />
<ClInclude Include="..\SilentPatch\FLAC\export.h" />
<ClInclude Include="..\SilentPatch\FLAC\format.h" />

View File

@ -81,6 +81,9 @@
<ClCompile Include="..\SilentPatch\SVF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\SilentPatch\FLAC\callback.h">
@ -179,6 +182,9 @@
<ClInclude Include="..\SilentPatch\SVF.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Desktop.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">

View File

@ -5,6 +5,7 @@
#include "Utils/Patterns.h"
#include "Common.h"
#include "Common_ddraw.h"
#include "Desktop.h"
#include "ModelInfoVC.h"
#include "VehicleVC.h"
#include "SVF.h"
@ -610,7 +611,7 @@ void InjectDelayedPatches_VC_Common()
Common::Patches::III_VC_DelayedCommon( hasDebugMenu, wcModulePath );
}
void Patch_VC_10(const RECT& desktop)
void Patch_VC_10(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -714,10 +715,10 @@ void Patch_VC_10(const RECT& desktop)
}
#endif
Common::Patches::DDraw_VC_10( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_10( width, height, aNoDesktopMode );
}
void Patch_VC_11(const RECT& desktop)
void Patch_VC_11(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -811,10 +812,10 @@ void Patch_VC_11(const RECT& desktop)
// Fixed crash related to autopilot timing calculations
InjectHook(0x418FAE, AutoPilotTimerFix_VC, PATCH_JUMP);
Common::Patches::DDraw_VC_11( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_11( width, height, aNoDesktopMode );
}
void Patch_VC_Steam(const RECT& desktop)
void Patch_VC_Steam(uint32_t width, uint32_t height)
{
using namespace Memory;
@ -907,7 +908,7 @@ void Patch_VC_Steam(const RECT& desktop)
// Fixed crash related to autopilot timing calculations
InjectHook(0x418FAE, AutoPilotTimerFix_VC, PATCH_JUMP);
Common::Patches::DDraw_VC_Steam( desktop, aNoDesktopMode );
Common::Patches::DDraw_VC_Steam( width, height, aNoDesktopMode );
}
void Patch_VC_JP()
@ -1154,18 +1155,17 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hDLLModule = hinstDLL;
RECT desktop;
GetWindowRect(GetDesktopWindow(), &desktop);
sprintf_s(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
const auto [width, height] = GetDesktopResolution();
sprintf_s(aNoDesktopMode, "Cannot find %ux%ux32 video mode", width, height);
// This scope is mandatory so Protect goes out of scope before rwcseg gets fixed
{
std::unique_ptr<ScopedUnprotect::Unprotect> Protect = ScopedUnprotect::UnprotectSectionOrFullModule( GetModuleHandle( nullptr ), ".text" );
const int8_t version = Memory::GetVersion().version;
if ( version == 0 ) Patch_VC_10(desktop);
else if ( version == 1 ) Patch_VC_11(desktop);
else if ( version == 2 ) Patch_VC_Steam(desktop);
if ( version == 0 ) Patch_VC_10(width, height);
else if ( version == 1 ) Patch_VC_11(width, height);
else if ( version == 2 ) Patch_VC_Steam(width, height);
// Y axis sensitivity only
else if (*(DWORD*)0x601048 == 0x5E5F5D60) Patch_VC_JP();

View File

@ -173,6 +173,7 @@
<ItemGroup>
<ClInclude Include="..\SilentPatch\Common_ddraw.h" />
<ClInclude Include="..\SilentPatch\debugmenu_public.h" />
<ClInclude Include="..\SilentPatch\Desktop.h" />
<ClInclude Include="..\SilentPatch\Maths.h" />
<ClInclude Include="..\SilentPatch\RWGTA.h" />
<ClInclude Include="..\SilentPatch\StdAfx.h" />
@ -196,6 +197,11 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\SilentPatch\RWGTA.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Master|Win32'">NotUsing</PrecompiledHeader>

View File

@ -60,6 +60,9 @@
<ClInclude Include="..\SilentPatch\SVF.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\SilentPatch\Desktop.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\SilentPatch\Timer.cpp">
@ -95,6 +98,9 @@
<ClCompile Include="VehicleVC.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\SilentPatch\Desktop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\SilentPatch\SilentPatch.rc">