mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Limit GlobalMemoryStatus values to 2GB
This commit is contained in:
parent
ff5bcc031c
commit
2ce97329a9
@ -231,6 +231,7 @@
|
||||
<ClInclude Include="Gdi\WinProc.h" />
|
||||
<ClInclude Include="Win32\DisplayMode.h" />
|
||||
<ClInclude Include="Win32\Log.h" />
|
||||
<ClInclude Include="Win32\MemoryManagement.h" />
|
||||
<ClInclude Include="Win32\MsgHooks.h" />
|
||||
<ClInclude Include="Win32\Registry.h" />
|
||||
<ClInclude Include="Win32\WaitFunctions.h" />
|
||||
@ -303,6 +304,7 @@
|
||||
<ClCompile Include="Gdi\WinProc.cpp" />
|
||||
<ClCompile Include="Win32\DisplayMode.cpp" />
|
||||
<ClCompile Include="Win32\Log.cpp" />
|
||||
<ClCompile Include="Win32\MemoryManagement.cpp" />
|
||||
<ClCompile Include="Win32\MsgHooks.cpp" />
|
||||
<ClCompile Include="Win32\Registry.cpp" />
|
||||
<ClCompile Include="Win32\WaitFunctions.cpp" />
|
||||
|
@ -393,6 +393,9 @@
|
||||
<ClInclude Include="D3dDdi\DeviceState.h">
|
||||
<Filter>Header Files\D3dDdi</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Win32\MemoryManagement.h">
|
||||
<Filter>Header Files\Win32</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Gdi\Gdi.cpp">
|
||||
@ -605,5 +608,8 @@
|
||||
<ClCompile Include="D3dDdi\DeviceState.cpp">
|
||||
<Filter>Source Files\D3dDdi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Win32\MemoryManagement.cpp">
|
||||
<Filter>Source Files\Win32</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -18,6 +18,7 @@
|
||||
#include <Gdi/Gdi.h>
|
||||
#include <Gdi/VirtualScreen.h>
|
||||
#include <Win32/DisplayMode.h>
|
||||
#include <Win32/MemoryManagement.h>
|
||||
#include <Win32/MsgHooks.h>
|
||||
#include <Win32/Registry.h>
|
||||
#include <Win32/WaitFunctions.h>
|
||||
@ -273,6 +274,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
setDpiAwareness();
|
||||
SetThemeAppProperties(0);
|
||||
|
||||
Win32::MemoryManagement::installHooks();
|
||||
Win32::MsgHooks::installHooks();
|
||||
Time::init();
|
||||
|
||||
|
@ -110,6 +110,19 @@ std::ostream& operator<<(std::ostream& os, HWND hwnd)
|
||||
<< Compat::hex(GetWindowLong(hwnd, GWL_EXSTYLE));
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const MEMORYSTATUS& ms)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< ms.dwLength
|
||||
<< ms.dwMemoryLoad
|
||||
<< ms.dwTotalPhys
|
||||
<< ms.dwAvailPhys
|
||||
<< ms.dwTotalPageFile
|
||||
<< ms.dwAvailPageFile
|
||||
<< ms.dwTotalVirtual
|
||||
<< ms.dwAvailVirtual;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const MSG& msg)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
|
@ -12,6 +12,7 @@ std::ostream& operator<<(std::ostream& os, const DEVMODEW& dm);
|
||||
std::ostream& operator<<(std::ostream& os, HDC dc);
|
||||
std::ostream& operator<<(std::ostream& os, HRGN rgn);
|
||||
std::ostream& operator<<(std::ostream& os, HWND hwnd);
|
||||
std::ostream& operator<<(std::ostream& os, const MEMORYSTATUS& ms);
|
||||
std::ostream& operator<<(std::ostream& os, const MSG& msg);
|
||||
std::ostream& operator<<(std::ostream& os, const RECT& rect);
|
||||
|
||||
|
41
DDrawCompat/Win32/MemoryManagement.cpp
Normal file
41
DDrawCompat/Win32/MemoryManagement.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <Windows.h>
|
||||
|
||||
#include <Common/Hook.h>
|
||||
#include <Common/Log.h>
|
||||
#include <Win32/MemoryManagement.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
void limitTo2Gb(SIZE_T& mem);
|
||||
|
||||
void WINAPI globalMemoryStatus(LPMEMORYSTATUS lpBuffer)
|
||||
{
|
||||
LOG_FUNC("GlobalMemoryStatus", lpBuffer);
|
||||
CALL_ORIG_FUNC(GlobalMemoryStatus)(lpBuffer);
|
||||
limitTo2Gb(lpBuffer->dwTotalPhys);
|
||||
limitTo2Gb(lpBuffer->dwAvailPhys);
|
||||
limitTo2Gb(lpBuffer->dwTotalPageFile);
|
||||
limitTo2Gb(lpBuffer->dwAvailPageFile);
|
||||
limitTo2Gb(lpBuffer->dwTotalVirtual);
|
||||
limitTo2Gb(lpBuffer->dwAvailVirtual);
|
||||
}
|
||||
|
||||
void limitTo2Gb(SIZE_T& mem)
|
||||
{
|
||||
if (mem > INT_MAX)
|
||||
{
|
||||
mem = INT_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Win32
|
||||
{
|
||||
namespace MemoryManagement
|
||||
{
|
||||
void installHooks()
|
||||
{
|
||||
HOOK_FUNCTION(kernel32, GlobalMemoryStatus, globalMemoryStatus);
|
||||
}
|
||||
}
|
||||
}
|
9
DDrawCompat/Win32/MemoryManagement.h
Normal file
9
DDrawCompat/Win32/MemoryManagement.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace Win32
|
||||
{
|
||||
namespace MemoryManagement
|
||||
{
|
||||
void installHooks();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user