diff --git a/ResSock/ResSock.def b/ResSock/ResSock.def new file mode 100644 index 0000000..ef1f607 --- /dev/null +++ b/ResSock/ResSock.def @@ -0,0 +1,3 @@ +LIBRARY DDRAW +EXPORTS + DirectDrawCreateEx=_DirectDrawCreateEx@16 \ No newline at end of file diff --git a/ResSock/ResSock.vcxproj b/ResSock/ResSock.vcxproj new file mode 100644 index 0000000..b0471eb --- /dev/null +++ b/ResSock/ResSock.vcxproj @@ -0,0 +1,73 @@ + + + + + Release + Win32 + + + + {B695EC1B-7258-426A-81CF-9323C016ACFB} + ResSock + + + + DynamicLibrary + false + true + MultiByte + + + + + + + + + + ddraw + + + .dll + + + + Level4 + MaxSpeed + true + true + false + AnySuitable + Speed + true + NDEBUG;%(PreprocessorDefinitions) + true + MultiThreaded + ..\SilentPatch;%(AdditionalIncludeDirectories) + + + false + true + true + true + Windows + 5.0 + DllMain@12 + ntdllp.lib;shlwapi.lib;%(AdditionalDependencies) + ResSock.def + + + copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto Vice City\ddraw.dll" +copy /y "$(TargetPath)" "D:\gry\Steam\steamapps\common\Grand Theft Auto 3\ddraw.dll" + + + + + + + + + + + + \ No newline at end of file diff --git a/ResSock/ResSock.vcxproj.filters b/ResSock/ResSock.vcxproj.filters new file mode 100644 index 0000000..c74c8ab --- /dev/null +++ b/ResSock/ResSock.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/ResSock/dllmain.cpp b/ResSock/dllmain.cpp new file mode 100644 index 0000000..9487e99 --- /dev/null +++ b/ResSock/dllmain.cpp @@ -0,0 +1,111 @@ +#define WIN32_LEAN_AND_MEAN +#define _CRT_SECURE_NO_WARNINGS + +#include +#include +#include +#include "MemoryMgr.h" + +extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter) +{ + static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID FAR*, LPVOID*, REFIID, IUnknown FAR*); + static bool bLoaded = false; + if ( !bLoaded ) + { + wchar_t wcSystemPath[MAX_PATH]; + GetSystemDirectoryW(wcSystemPath, MAX_PATH); + PathAppendW(wcSystemPath, L"ddraw.dll"); + + HMODULE hLib = LoadLibraryW(wcSystemPath); + pDirectDrawCreateEx = (HRESULT(WINAPI*)(GUID FAR*, LPVOID*, REFIID, IUnknown FAR*))GetProcAddress(hLib, "DirectDrawCreateEx"); + + bLoaded = true; + } + return pDirectDrawCreateEx(lpGUID, lplpDD, iid, pUnkOuter); +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + UNREFERENCED_PARAMETER(hinstDLL); + UNREFERENCED_PARAMETER(lpvReserved); + + if ( fdwReason == DLL_PROCESS_ATTACH ) + { + static char aNoDesktopMode[64]; + using namespace MemoryVP; + + if (*(DWORD*)0x5C1E70 == 0x53E58955) + { + // III 1.0 + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x581E5E, desktop.right); + Patch(0x581E68, desktop.bottom); + Patch(0x581E72, 32); + Patch(0x581EA8, aNoDesktopMode); + } + else if (*(DWORD*)0x5C2130 == 0x53E58955) + { + // III 1.1 + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x58219E, desktop.right); + Patch(0x5821A8, desktop.bottom); + Patch(0x5821B2, 32); + Patch(0x5821E8, aNoDesktopMode); + } + else if (*(DWORD*)0x5C6FD0 == 0x53E58955) + { + // III Steam + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x58208E, desktop.right); + Patch(0x582098, desktop.bottom); + Patch(0x5820A2, 32); + Patch(0x5820D8, aNoDesktopMode); + } + else if (*(DWORD*)0x667BF0 == 0x53E58955) + { + // VC 1.0 + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x600E7E, desktop.right); + Patch(0x600E88, desktop.bottom); + Patch(0x600E92, 32); + Patch(0x600EC8, aNoDesktopMode); + } + else if (*(DWORD*)0x667C40 == 0x53E58955) + { + // VC 1.1 + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x600E9E, desktop.right); + Patch(0x600EA8, desktop.bottom); + Patch(0x600EB2, 32); + Patch(0x600EE8, aNoDesktopMode); + } + else if (*(DWORD*)0x666BA0 == 0x53E58955) + { + // VC Steam + RECT desktop; + GetWindowRect(GetDesktopWindow(), &desktop); + sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom); + + Patch(0x600ADE, desktop.right); + Patch(0x600AE8, desktop.bottom); + Patch(0x600AF2, 32); + Patch(0x600B28, aNoDesktopMode); + } + } + return TRUE; +} \ No newline at end of file diff --git a/ResSock/ntdllp.lib b/ResSock/ntdllp.lib new file mode 100644 index 0000000..057be92 Binary files /dev/null and b/ResSock/ntdllp.lib differ diff --git a/SilentPatch.sln b/SilentPatch.sln index 8036ff4..83c8923 100644 --- a/SilentPatch.sln +++ b/SilentPatch.sln @@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCFix", "VCFix\VCFix.vcxpro EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SAFix", "SAFix\SAFix.vcxproj", "{D3E18BC0-A120-451D-A16A-F77072625D66}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ResSock", "ResSock\ResSock.vcxproj", "{B695EC1B-7258-426A-81CF-9323C016ACFB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -25,6 +27,9 @@ Global {D3E18BC0-A120-451D-A16A-F77072625D66}.Debug|Win32.Build.0 = Debug|Win32 {D3E18BC0-A120-451D-A16A-F77072625D66}.Release|Win32.ActiveCfg = Release|Win32 {D3E18BC0-A120-451D-A16A-F77072625D66}.Release|Win32.Build.0 = Release|Win32 + {B695EC1B-7258-426A-81CF-9323C016ACFB}.Debug|Win32.ActiveCfg = Release|Win32 + {B695EC1B-7258-426A-81CF-9323C016ACFB}.Release|Win32.ActiveCfg = Release|Win32 + {B695EC1B-7258-426A-81CF-9323C016ACFB}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE