From f39c7c8d2ce2845be6673857b5a983cb2144037b Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 9 Apr 2017 20:25:19 +0200 Subject: [PATCH] more security improvements --- DDraw/dllmain.cpp | 1 - SilentPatch/StdAfx.h | 3 +-- SilentPatchIII/SilentPatchIII.vcxproj | 2 ++ SilentPatchSA/ModelInfoSA.cpp | 6 +++--- SilentPatchSA/SilentPatchSA.cpp | 20 +++++++++----------- SilentPatchSA/SilentPatchSA.vcxproj | 1 - SilentPatchSA/SilentPatchSA.vcxproj.filters | 3 --- SilentPatchSA/StdAfxSA.h | 2 -- SilentPatchVC/SilentPatchVC.vcxproj | 2 ++ 9 files changed, 17 insertions(+), 23 deletions(-) diff --git a/DDraw/dllmain.cpp b/DDraw/dllmain.cpp index 1b250b1..4f203a1 100644 --- a/DDraw/dllmain.cpp +++ b/DDraw/dllmain.cpp @@ -1,5 +1,4 @@ #define WIN32_LEAN_AND_MEAN -#define _CRT_SECURE_NO_WARNINGS #define WINVER 0x0501 #define _WIN32_WINNT 0x0501 diff --git a/SilentPatch/StdAfx.h b/SilentPatch/StdAfx.h index acda869..d72b7dd 100644 --- a/SilentPatch/StdAfx.h +++ b/SilentPatch/StdAfx.h @@ -1,9 +1,8 @@ #define WIN32_LEAN_AND_MEAN -#define _CRT_SECURE_NO_WARNINGS -#define _USE_MATH_DEFINES #define WINVER 0x0501 #define _WIN32_WINNT 0x0501 +#define NOMINMAX #include #include diff --git a/SilentPatchIII/SilentPatchIII.vcxproj b/SilentPatchIII/SilentPatchIII.vcxproj index 9d8c091..0846867 100644 --- a/SilentPatchIII/SilentPatchIII.vcxproj +++ b/SilentPatchIII/SilentPatchIII.vcxproj @@ -85,6 +85,7 @@ NoExtensions Fast /Zc:threadSafeInit- /std:c++latest %(AdditionalOptions) + true true @@ -115,6 +116,7 @@ NoExtensions Fast /Zc:threadSafeInit- /std:c++latest %(AdditionalOptions) + true false diff --git a/SilentPatchSA/ModelInfoSA.cpp b/SilentPatchSA/ModelInfoSA.cpp index c799b40..3d77bd4 100644 --- a/SilentPatchSA/ModelInfoSA.cpp +++ b/SilentPatchSA/ModelInfoSA.cpp @@ -30,7 +30,7 @@ void CVehicleModelInfo::FindEditableMaterialList() { if ( const char* texName = RwTextureGetName(texture) ) { - if ( _strnicmp(texName, "vehiclegrunge256", 16) == 0 ) + if ( _stricmp(texName, "vehiclegrunge256") == 0 ) { if ( materialCount < _countof(m_apDirtMaterials) ) m_apDirtMaterials[materialCount++] = material; @@ -81,7 +81,7 @@ void CCustomCarPlateMgr::PollPlates( RpClump* clump, RpMaterial** materials ) { if ( const char* texName = RwTextureGetName(texture) ) { - if ( _strnicmp( texName, "carplate", 8 ) == 0 ) + if ( _stricmp( texName, "carplate" ) == 0 ) { assert(numCarplates < NUM_MAX_PLATES); if ( numCarplates < NUM_MAX_PLATES ) @@ -89,7 +89,7 @@ void CCustomCarPlateMgr::PollPlates( RpClump* clump, RpMaterial** materials ) carplates[numCarplates++] = material; } } - else if ( _strnicmp( texName, "carpback", 8 ) == 0 ) + else if ( _stricmp( texName, "carpback" ) == 0 ) { assert(numCarpbacks < NUM_MAX_PLATES); if ( numCarpbacks < NUM_MAX_PLATES ) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index c2c2c01..f37f99e 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -774,9 +774,7 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size CRGBA* CRGBA::BlendGangColour(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { double colourIntensity = static_cast(pCurrZoneInfo->ZoneColour.a) / 255.0; - *this = BlendSqr(CRGBA(r, g, b), HudColour[3], colourIntensity); - this->a = a; - + *this = CRGBA(BlendSqr( CRGBA(r, g, b), HudColour[3], colourIntensity ), a); return this; } @@ -809,7 +807,7 @@ void DrawRect_HalfPixel_Steam(CRect& rect, const CRGBA& rgba) char* GetMyDocumentsPath() { static char cUserFilesPath[MAX_PATH]; - static char* ppTempBufPtr = *GetVer() == 0 ? *AddressByRegion_10(0x744FE5) : cUserFilesPath; + static char* const ppTempBufPtr = *GetVer() == 0 ? *AddressByRegion_10(0x744FE5) : cUserFilesPath; if (ppTempBufPtr[0] == '\0') { @@ -932,7 +930,7 @@ void SetMultiSamplingLevels( RwUInt32 level ) void MSAAText( char* buffer, const char*, DWORD level ) { - sprintf( buffer, "%ux", 1 << level ); + sprintf_s( buffer, 100, "%ux", 1 << level ); } @@ -3189,8 +3187,8 @@ void Patch_SA_10() // Fixed police scanner names char* pScannerNames = *(char**)0x4E72D4; - strcpy(pScannerNames + (8*113), "WESTP"); - strcpy(pScannerNames + (8*134), "????"); + strcpy_s(pScannerNames + (8*113), 8, "WESTP"); + strcpy_s(pScannerNames + (8*134), 8, "????"); // Handle IMGs bigger than 4GB Nop( 0x4065BB, 3 ); @@ -3581,8 +3579,8 @@ void Patch_SA_11() // Fixed police scanner names char* pScannerNames = *(char**)0x4E7714; - strcpy(pScannerNames + (8*113), "WESTP"); - strcpy(pScannerNames + (8*134), "????"); + strcpy_s(pScannerNames + (8*113), 8, "WESTP"); + strcpy_s(pScannerNames + (8*134), 8, "????"); // 1.01 ONLY @@ -3963,8 +3961,8 @@ void Patch_SA_Steam() // Fixed police scanner names char* pScannerNames = *(char**)0x4F2B83; - strcpy(pScannerNames + (8*113), "WESTP"); - strcpy(pScannerNames + (8*134), "????"); + strcpy_s(pScannerNames + (8*113), 8, "WESTP"); + strcpy_s(pScannerNames + (8*134), 8, "????"); // STEAM ONLY // Proper aspect ratios - why Rockstar, why? diff --git a/SilentPatchSA/SilentPatchSA.vcxproj b/SilentPatchSA/SilentPatchSA.vcxproj index 77912e0..26c0cfb 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj +++ b/SilentPatchSA/SilentPatchSA.vcxproj @@ -164,7 +164,6 @@ copy /y "$(TargetPath)" "D:\gry\GTA San Andreas clean\scripts\newsteam_r2_lowvio - diff --git a/SilentPatchSA/SilentPatchSA.vcxproj.filters b/SilentPatchSA/SilentPatchSA.vcxproj.filters index ca03eb6..a44590d 100644 --- a/SilentPatchSA/SilentPatchSA.vcxproj.filters +++ b/SilentPatchSA/SilentPatchSA.vcxproj.filters @@ -68,9 +68,6 @@ Header Files - - Header Files - Header Files\FLAC diff --git a/SilentPatchSA/StdAfxSA.h b/SilentPatchSA/StdAfxSA.h index 7ebef04..cb44827 100644 --- a/SilentPatchSA/StdAfxSA.h +++ b/SilentPatchSA/StdAfxSA.h @@ -3,8 +3,6 @@ #pragma warning(disable:4100) // unreferenced formal parameter #define WIN32_LEAN_AND_MEAN -#define _CRT_SECURE_NO_WARNINGS -#define _USE_MATH_DEFINES #define NOMINMAX #define WINVER 0x0502 diff --git a/SilentPatchVC/SilentPatchVC.vcxproj b/SilentPatchVC/SilentPatchVC.vcxproj index 8bdcf0e..0dda6ad 100644 --- a/SilentPatchVC/SilentPatchVC.vcxproj +++ b/SilentPatchVC/SilentPatchVC.vcxproj @@ -63,6 +63,7 @@ NoExtensions Fast /Zc:threadSafeInit- /std:c++latest %(AdditionalOptions) + true true @@ -91,6 +92,7 @@ NoExtensions Fast /Zc:threadSafeInit- /std:c++latest %(AdditionalOptions) + true false