mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Added WinVersionLie setting
This commit is contained in:
parent
04c29d1f38
commit
516ed1f7da
@ -23,4 +23,5 @@ namespace Config
|
||||
Settings::TextureFilter textureFilter;
|
||||
Settings::ThreadPriorityBoost threadPriorityBoost;
|
||||
Settings::VSync vSync;
|
||||
Settings::WinVersionLie winVersionLie;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <Config/Settings/TextureFilter.h>
|
||||
#include <Config/Settings/ThreadPriorityBoost.h>
|
||||
#include <Config/Settings/VSync.h>
|
||||
#include <Config/Settings/WinVersionLie.h>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
@ -45,4 +46,5 @@ namespace Config
|
||||
extern Settings::TextureFilter textureFilter;
|
||||
extern Settings::ThreadPriorityBoost threadPriorityBoost;
|
||||
extern Settings::VSync vSync;
|
||||
extern Settings::WinVersionLie winVersionLie;
|
||||
}
|
||||
|
35
DDrawCompat/Config/Settings/WinVersionLie.cpp
Normal file
35
DDrawCompat/Config/Settings/WinVersionLie.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <Config/Settings/WinVersionLie.h>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
bool VersionInfo::operator==(const VersionInfo& other) const
|
||||
{
|
||||
return version == other.version &&
|
||||
build == other.build &&
|
||||
platform == other.platform;
|
||||
}
|
||||
|
||||
WinVersionLie::WinVersionLie()
|
||||
: MappedSetting("WinVersionLie", "off", {
|
||||
{"off", {}},
|
||||
{"95", {0xC3B60004, 0x3B6, 1}},
|
||||
{"nt4", {0x5650004, 0x565, 2}},
|
||||
{"98", {0xC0000A04, 0x40A08AE, 1}},
|
||||
{"2000", {0x8930005, 0x893, 2}},
|
||||
{"xp", {0xA280105, 0xA28, 2}}
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
Setting::ParamInfo WinVersionLie::getParamInfo() const
|
||||
{
|
||||
if (0 != m_value.version)
|
||||
{
|
||||
return { "SP", 0, 5, 0, m_param };
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
26
DDrawCompat/Config/Settings/WinVersionLie.h
Normal file
26
DDrawCompat/Config/Settings/WinVersionLie.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <Config/MappedSetting.h>
|
||||
|
||||
namespace Config
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
struct VersionInfo
|
||||
{
|
||||
DWORD version;
|
||||
DWORD build;
|
||||
DWORD platform;
|
||||
|
||||
bool operator==(const VersionInfo& other) const;
|
||||
};
|
||||
|
||||
class WinVersionLie : public MappedSetting<VersionInfo>
|
||||
{
|
||||
public:
|
||||
WinVersionLie();
|
||||
|
||||
virtual ParamInfo getParamInfo() const override;
|
||||
};
|
||||
}
|
||||
}
|
@ -238,6 +238,7 @@
|
||||
<ClInclude Include="Config\Settings\TextureFilter.h" />
|
||||
<ClInclude Include="Config\Settings\ThreadPriorityBoost.h" />
|
||||
<ClInclude Include="Config\Settings\VSync.h" />
|
||||
<ClInclude Include="Config\Settings\WinVersionLie.h" />
|
||||
<ClInclude Include="D3dDdi\Adapter.h" />
|
||||
<ClInclude Include="D3dDdi\AdapterCallbacks.h" />
|
||||
<ClInclude Include="D3dDdi\AdapterFuncs.h" />
|
||||
@ -342,6 +343,7 @@
|
||||
<ClInclude Include="Win32\MemoryManagement.h" />
|
||||
<ClInclude Include="Win32\Registry.h" />
|
||||
<ClInclude Include="Win32\Thread.h" />
|
||||
<ClInclude Include="Win32\Version.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Common\Log.cpp" />
|
||||
@ -366,6 +368,7 @@
|
||||
<ClCompile Include="Config\Settings\SupportedResolutions.cpp" />
|
||||
<ClCompile Include="Config\Settings\TextureFilter.cpp" />
|
||||
<ClCompile Include="Config\Settings\VSync.cpp" />
|
||||
<ClCompile Include="Config\Settings\WinVersionLie.cpp" />
|
||||
<ClCompile Include="D3dDdi\Adapter.cpp" />
|
||||
<ClCompile Include="D3dDdi\AdapterCallbacks.cpp" />
|
||||
<ClCompile Include="D3dDdi\AdapterFuncs.cpp" />
|
||||
@ -450,6 +453,7 @@
|
||||
<ClCompile Include="Win32\MemoryManagement.cpp" />
|
||||
<ClCompile Include="Win32\Registry.cpp" />
|
||||
<ClCompile Include="Win32\Thread.cpp" />
|
||||
<ClCompile Include="Win32\Version.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DDrawCompat.rc" />
|
||||
|
@ -555,6 +555,12 @@
|
||||
<ClInclude Include="Config\Settings\RemoveBorders.h">
|
||||
<Filter>Header Files\Config\Settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Config\Settings\WinVersionLie.h">
|
||||
<Filter>Header Files\Config\Settings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Win32\Version.h">
|
||||
<Filter>Header Files\Win32</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Gdi\Gdi.cpp">
|
||||
@ -875,6 +881,12 @@
|
||||
<ClCompile Include="DDraw\Surfaces\TagSurface.cpp">
|
||||
<Filter>Source Files\DDraw\Surfaces</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Config\Settings\WinVersionLie.cpp">
|
||||
<Filter>Source Files\Config\Settings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Win32\Version.cpp">
|
||||
<Filter>Source Files\Win32</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="DDrawCompat.rc">
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <Win32/MemoryManagement.h>
|
||||
#include <Win32/Registry.h>
|
||||
#include <Win32/Thread.h>
|
||||
#include <Win32/Version.h>
|
||||
|
||||
HRESULT WINAPI SetAppCompatData(DWORD, DWORD);
|
||||
|
||||
@ -231,6 +232,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||
Input::installHooks();
|
||||
Win32::MemoryManagement::installHooks();
|
||||
Win32::Thread::installHooks();
|
||||
Win32::Version::installHooks();
|
||||
Compat::closeDbgEng();
|
||||
|
||||
timeBeginPeriod(1);
|
||||
|
@ -71,6 +71,31 @@ namespace
|
||||
<< Compat::hex(mcs.style)
|
||||
<< Compat::hex(mcs.lParam);
|
||||
}
|
||||
|
||||
template <typename OsVersionInfoEx>
|
||||
std::ostream& logOsVersionInfoEx(std::ostream& os, const OsVersionInfoEx& vi)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
<< vi.dwOSVersionInfoSize
|
||||
<< vi.dwMajorVersion
|
||||
<< vi.dwMinorVersion
|
||||
<< vi.dwBuildNumber
|
||||
<< vi.dwPlatformId
|
||||
<< Compat::out(vi.szCSDVersion)
|
||||
<< vi.wServicePackMajor
|
||||
<< vi.wServicePackMinor
|
||||
<< Compat::hex(vi.wSuiteMask)
|
||||
<< static_cast<DWORD>(vi.wProductType)
|
||||
<< static_cast<DWORD>(vi.wReserved);
|
||||
}
|
||||
|
||||
template <typename OsVersionInfoEx, typename OsVersionInfo>
|
||||
std::ostream& logOsVersionInfo(std::ostream& os, const OsVersionInfo& vi)
|
||||
{
|
||||
OsVersionInfoEx viEx = {};
|
||||
memcpy(&viEx, &vi, min(sizeof(viEx), vi.dwOSVersionInfoSize));
|
||||
return logOsVersionInfoEx(os, viEx);
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const COMPAREITEMSTRUCT& cis)
|
||||
@ -349,6 +374,26 @@ std::ostream& operator<<(std::ostream& os, const NMHDR& nm)
|
||||
<< Compat::hex(nm.code);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOA& vi)
|
||||
{
|
||||
return logOsVersionInfo<OSVERSIONINFOEXA>(os, vi);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOW& vi)
|
||||
{
|
||||
return logOsVersionInfo<OSVERSIONINFOEXW>(os, vi);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXA& vi)
|
||||
{
|
||||
return logOsVersionInfoEx(os, vi);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXW& vi)
|
||||
{
|
||||
return logOsVersionInfoEx(os, vi);
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const POINT& p)
|
||||
{
|
||||
return Compat::LogStruct(os)
|
||||
|
@ -31,6 +31,10 @@ std::ostream& operator<<(std::ostream& os, const MINMAXINFO& mmi);
|
||||
std::ostream& operator<<(std::ostream& os, const MSG& msg);
|
||||
std::ostream& operator<<(std::ostream& os, const NCCALCSIZE_PARAMS& nccs);
|
||||
std::ostream& operator<<(std::ostream& os, const NMHDR& nm);
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOA& vi);
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOW& vi);
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXA& vi);
|
||||
std::ostream& operator<<(std::ostream& os, const OSVERSIONINFOEXW& vi);
|
||||
std::ostream& operator<<(std::ostream& os, const POINT& p);
|
||||
std::ostream& operator<<(std::ostream& os, const POINTS& p);
|
||||
std::ostream& operator<<(std::ostream& os, const RECT& rect);
|
||||
|
80
DDrawCompat/Win32/Version.cpp
Normal file
80
DDrawCompat/Win32/Version.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include <sstream>
|
||||
|
||||
#include <Common/Hook.h>
|
||||
#include <Common/Log.h>
|
||||
#include <Config/Config.h>
|
||||
|
||||
#include <Win32/Version.h>
|
||||
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
namespace
|
||||
{
|
||||
DWORD WINAPI getVersion()
|
||||
{
|
||||
LOG_FUNC("GetVersion");
|
||||
auto vi = Config::winVersionLie.get();
|
||||
if (0 != vi.version)
|
||||
{
|
||||
return LOG_RESULT(vi.version);
|
||||
}
|
||||
return LOG_RESULT(CALL_ORIG_FUNC(GetVersion)());
|
||||
}
|
||||
|
||||
template <typename OsVersionInfoEx, typename OsVersionInfo>
|
||||
BOOL getVersionInfo(OsVersionInfo* osVersionInfo, BOOL(WINAPI* origGetVersionInfo)(OsVersionInfo*),
|
||||
[[maybe_unused]] const char* funcName)
|
||||
{
|
||||
LOG_FUNC(funcName, osVersionInfo);
|
||||
BOOL result = origGetVersionInfo(osVersionInfo);
|
||||
auto vi = Config::winVersionLie.get();
|
||||
if (result && 0 != vi.version)
|
||||
{
|
||||
osVersionInfo->dwMajorVersion = vi.version & 0xFF;
|
||||
osVersionInfo->dwMinorVersion = (vi.version & 0xFF00) >> 8;
|
||||
osVersionInfo->dwBuildNumber = vi.build;
|
||||
osVersionInfo->dwPlatformId = vi.platform;
|
||||
|
||||
auto sp = Config::winVersionLie.getParam();
|
||||
if (0 != sp)
|
||||
{
|
||||
typedef std::remove_reference_t<decltype(osVersionInfo->szCSDVersion[0])> Char;
|
||||
std::basic_ostringstream<Char> oss;
|
||||
oss << "Service Pack " << sp;
|
||||
memset(osVersionInfo->szCSDVersion, 0, sizeof(osVersionInfo->szCSDVersion));
|
||||
memcpy(osVersionInfo->szCSDVersion, oss.str().c_str(), oss.str().length() * sizeof(Char));
|
||||
|
||||
if (osVersionInfo->dwOSVersionInfoSize >= sizeof(OsVersionInfoEx))
|
||||
{
|
||||
auto osVersionInfoEx = reinterpret_cast<OsVersionInfoEx*>(osVersionInfo);
|
||||
osVersionInfoEx->wServicePackMajor = static_cast<WORD>(sp);
|
||||
osVersionInfoEx->wServicePackMinor = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL WINAPI getVersionExA(LPOSVERSIONINFOA lpVersionInformation)
|
||||
{
|
||||
return getVersionInfo<OSVERSIONINFOEXA>(lpVersionInformation, CALL_ORIG_FUNC(GetVersionExA), "GetVersionExA");
|
||||
}
|
||||
|
||||
BOOL WINAPI getVersionExW(LPOSVERSIONINFOW lpVersionInformation)
|
||||
{
|
||||
return getVersionInfo<OSVERSIONINFOEXW>(lpVersionInformation, CALL_ORIG_FUNC(GetVersionExW), "GetVersionExW");
|
||||
}
|
||||
}
|
||||
|
||||
namespace Win32
|
||||
{
|
||||
namespace Version
|
||||
{
|
||||
void installHooks()
|
||||
{
|
||||
HOOK_FUNCTION(kernel32, GetVersion, getVersion);
|
||||
HOOK_FUNCTION(kernel32, GetVersionExA, getVersionExA);
|
||||
HOOK_FUNCTION(kernel32, GetVersionExW, getVersionExW);
|
||||
}
|
||||
}
|
||||
}
|
9
DDrawCompat/Win32/Version.h
Normal file
9
DDrawCompat/Win32/Version.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace Win32
|
||||
{
|
||||
namespace Version
|
||||
{
|
||||
void installHooks();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user