mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2025-01-01 08:43:01 +05:00
VRAM fix, DEP compat fix
This commit is contained in:
parent
3fd04e395a
commit
a82447b1aa
1 changed files with 31 additions and 24 deletions
|
@ -20,15 +20,16 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R
|
||||||
pDirectDrawCreateEx = (HRESULT(WINAPI*)(GUID FAR*, LPVOID*, REFIID, IUnknown FAR*))GetProcAddress(hLib, "DirectDrawCreateEx");
|
pDirectDrawCreateEx = (HRESULT(WINAPI*)(GUID FAR*, LPVOID*, REFIID, IUnknown FAR*))GetProcAddress(hLib, "DirectDrawCreateEx");
|
||||||
|
|
||||||
static char aNoDesktopMode[64];
|
static char aNoDesktopMode[64];
|
||||||
|
|
||||||
|
RECT desktop;
|
||||||
|
GetWindowRect(GetDesktopWindow(), &desktop);
|
||||||
|
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
||||||
|
|
||||||
using namespace MemoryVP;
|
using namespace MemoryVP;
|
||||||
|
|
||||||
if (*(DWORD*)0x5C1E70 == 0x53E58955)
|
if (*(DWORD*)0x5C1E70 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// III 1.0
|
// III 1.0
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x581E5E, desktop.right);
|
Patch<DWORD>(0x581E5E, desktop.right);
|
||||||
Patch<DWORD>(0x581E68, desktop.bottom);
|
Patch<DWORD>(0x581E68, desktop.bottom);
|
||||||
Patch<BYTE>(0x581E72, 32);
|
Patch<BYTE>(0x581E72, 32);
|
||||||
|
@ -40,10 +41,6 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R
|
||||||
else if (*(DWORD*)0x5C2130 == 0x53E58955)
|
else if (*(DWORD*)0x5C2130 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// III 1.1
|
// III 1.1
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x58219E, desktop.right);
|
Patch<DWORD>(0x58219E, desktop.right);
|
||||||
Patch<DWORD>(0x5821A8, desktop.bottom);
|
Patch<DWORD>(0x5821A8, desktop.bottom);
|
||||||
Patch<BYTE>(0x5821B2, 32);
|
Patch<BYTE>(0x5821B2, 32);
|
||||||
|
@ -55,10 +52,6 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R
|
||||||
else if (*(DWORD*)0x5C6FD0 == 0x53E58955)
|
else if (*(DWORD*)0x5C6FD0 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// III Steam
|
// III Steam
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x58208E, desktop.right);
|
Patch<DWORD>(0x58208E, desktop.right);
|
||||||
Patch<DWORD>(0x582098, desktop.bottom);
|
Patch<DWORD>(0x582098, desktop.bottom);
|
||||||
Patch<BYTE>(0x5820A2, 32);
|
Patch<BYTE>(0x5820A2, 32);
|
||||||
|
@ -67,43 +60,57 @@ extern "C" HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, R
|
||||||
// No 12mb vram check
|
// No 12mb vram check
|
||||||
Patch<BYTE>(0x581653, 0xEB);
|
Patch<BYTE>(0x581653, 0xEB);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (*(DWORD*)0x667BF0 == 0x53E58955)
|
else if (*(DWORD*)0x667BF0 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// VC 1.0
|
// VC 1.0
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x600E7E, desktop.right);
|
Patch<DWORD>(0x600E7E, desktop.right);
|
||||||
Patch<DWORD>(0x600E88, desktop.bottom);
|
Patch<DWORD>(0x600E88, desktop.bottom);
|
||||||
Patch<BYTE>(0x600E92, 32);
|
Patch<BYTE>(0x600E92, 32);
|
||||||
Patch<const char*>(0x600EC8, aNoDesktopMode);
|
Patch<const char*>(0x600EC8, aNoDesktopMode);
|
||||||
|
|
||||||
|
// No 12mb vram check
|
||||||
|
Patch<BYTE>(0x601E26, 0xEB);
|
||||||
}
|
}
|
||||||
else if (*(DWORD*)0x667C40 == 0x53E58955)
|
else if (*(DWORD*)0x667C40 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// VC 1.1
|
// VC 1.1
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x600E9E, desktop.right);
|
Patch<DWORD>(0x600E9E, desktop.right);
|
||||||
Patch<DWORD>(0x600EA8, desktop.bottom);
|
Patch<DWORD>(0x600EA8, desktop.bottom);
|
||||||
Patch<BYTE>(0x600EB2, 32);
|
Patch<BYTE>(0x600EB2, 32);
|
||||||
Patch<const char*>(0x600EE8, aNoDesktopMode);
|
Patch<const char*>(0x600EE8, aNoDesktopMode);
|
||||||
|
|
||||||
|
// No 12mb vram check
|
||||||
|
Patch<BYTE>(0x601E56, 0xEB);
|
||||||
}
|
}
|
||||||
else if (*(DWORD*)0x666BA0 == 0x53E58955)
|
else if (*(DWORD*)0x666BA0 == 0x53E58955)
|
||||||
{
|
{
|
||||||
// VC Steam
|
// VC Steam
|
||||||
RECT desktop;
|
|
||||||
GetWindowRect(GetDesktopWindow(), &desktop);
|
|
||||||
sprintf(aNoDesktopMode, "Cannot find %dx%dx32 video mode", desktop.right, desktop.bottom);
|
|
||||||
|
|
||||||
Patch<DWORD>(0x600ADE, desktop.right);
|
Patch<DWORD>(0x600ADE, desktop.right);
|
||||||
Patch<DWORD>(0x600AE8, desktop.bottom);
|
Patch<DWORD>(0x600AE8, desktop.bottom);
|
||||||
Patch<BYTE>(0x600AF2, 32);
|
Patch<BYTE>(0x600AF2, 32);
|
||||||
Patch<const char*>(0x600B28, aNoDesktopMode);
|
Patch<const char*>(0x600B28, aNoDesktopMode);
|
||||||
|
|
||||||
|
// No 12mb vram check
|
||||||
|
Patch<BYTE>(0x601A96, 0xEB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Give _rwcseg proper access rights
|
||||||
|
HMODULE hModule = GetModuleHandle(nullptr);
|
||||||
|
IMAGE_NT_HEADERS* ntHeader = (IMAGE_NT_HEADERS*)((ptrdiff_t)hModule + ((IMAGE_DOS_HEADER*)hModule)->e_lfanew);
|
||||||
|
WORD NumberOfSections = ntHeader->FileHeader.NumberOfSections;
|
||||||
|
IMAGE_SECTION_HEADER* pSection = IMAGE_FIRST_SECTION(ntHeader);
|
||||||
|
|
||||||
|
for ( WORD i = 0; i < NumberOfSections; i++ )
|
||||||
|
{
|
||||||
|
if ( !strncmp((char*)pSection->Name, "_rwcseg", 8) )
|
||||||
|
{
|
||||||
|
DWORD dwProtect;
|
||||||
|
VirtualProtect((LPVOID)((ptrdiff_t)hModule + pSection->VirtualAddress), pSection->Misc.VirtualSize, PAGE_EXECUTE_READ, &dwProtect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pSection++;
|
||||||
|
}
|
||||||
|
|
||||||
bLoaded = true;
|
bLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue