mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
extend versionhelpers
This commit is contained in:
parent
cc97cc0761
commit
6626480358
@ -67,6 +67,7 @@
|
|||||||
<ClCompile Include="src\screenshot.c" />
|
<ClCompile Include="src\screenshot.c" />
|
||||||
<ClCompile Include="src\config.c" />
|
<ClCompile Include="src\config.c" />
|
||||||
<ClCompile Include="src\ddsurface.c" />
|
<ClCompile Include="src\ddsurface.c" />
|
||||||
|
<ClCompile Include="src\versionhelpers.c" />
|
||||||
<ClCompile Include="src\winapi_hooks.c" />
|
<ClCompile Include="src\winapi_hooks.c" />
|
||||||
<ClCompile Include="src\wndproc.c" />
|
<ClCompile Include="src\wndproc.c" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -159,6 +159,9 @@
|
|||||||
<ClCompile Include="src\ini.c">
|
<ClCompile Include="src\ini.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\versionhelpers.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="inc\debug.h">
|
<ClInclude Include="inc\debug.h">
|
||||||
|
@ -19,7 +19,6 @@ typedef struct CNCDDRAWCONFIG
|
|||||||
char process_file_ext[MAX_PATH];
|
char process_file_ext[MAX_PATH];
|
||||||
char dll_file_ext[MAX_PATH];
|
char dll_file_ext[MAX_PATH];
|
||||||
INIFILE ini;
|
INIFILE ini;
|
||||||
BOOL is_wine;
|
|
||||||
BOOL d3d9on12;
|
BOOL d3d9on12;
|
||||||
BOOL opengl_core;
|
BOOL opengl_core;
|
||||||
|
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#ifndef _INC_VERSIONHELPERS
|
#ifndef _INC_VERSIONHELPERS
|
||||||
#define _INC_VERSIONHELPERS
|
#define _INC_VERSIONHELPERS
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define VERSIONHELPERAPI inline bool
|
#define VERSIONHELPERAPI inline bool
|
||||||
#else
|
#else
|
||||||
@ -26,73 +24,91 @@
|
|||||||
#ifndef _WIN32_WINNT_WIN10
|
#ifndef _WIN32_WINNT_WIN10
|
||||||
#define _WIN32_WINNT_WIN10 0x0A00 /* ABRACADABRA_THRESHOLD*/
|
#define _WIN32_WINNT_WIN10 0x0A00 /* ABRACADABRA_THRESHOLD*/
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _WIN32_WINNT_WIN11
|
||||||
|
#define _WIN32_WINNT_WIN11 0x0A00
|
||||||
|
#endif
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsVersionOrGreater(WORD major, WORD minor, WORD servpack)
|
|
||||||
|
void verhelp_init();
|
||||||
|
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask);
|
||||||
|
const char* verhelp_wine_get_version();
|
||||||
|
void verhelp_wine_get_host_version(const char** sysname, const char** release);
|
||||||
|
BOOL verhelp_is_wine();
|
||||||
|
BOOL verhelp_is_macos();
|
||||||
|
BOOL verhelp_is_linux();
|
||||||
|
|
||||||
|
/* Original MS Functions */
|
||||||
|
|
||||||
|
VERSIONHELPERAPI IsWindowsVersionOrGreater(DWORD major, DWORD minor, DWORD build, WORD servpack)
|
||||||
{
|
{
|
||||||
OSVERSIONINFOEXW vi = {sizeof(vi),major,minor,0,0,{0},servpack};
|
RTL_OSVERSIONINFOEXW vi = {sizeof(vi),major,minor,build,0,{0},servpack};
|
||||||
return VerifyVersionInfoW(&vi, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
|
return verhelp_verify_version(&vi, VER_MAJORVERSION|VER_MINORVERSION|VER_BUILDNUMBER|VER_SERVICEPACKMAJOR,
|
||||||
VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
|
VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
|
||||||
VER_MAJORVERSION,VER_GREATER_EQUAL),
|
VER_MAJORVERSION,VER_GREATER_EQUAL),
|
||||||
VER_MINORVERSION,VER_GREATER_EQUAL),
|
VER_MINORVERSION,VER_GREATER_EQUAL),
|
||||||
|
VER_BUILDNUMBER,VER_GREATER_EQUAL),
|
||||||
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
|
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsXPOrGreater(void) {
|
VERSIONHELPERAPI IsWindowsXPOrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsXPSP1OrGreater(void) {
|
VERSIONHELPERAPI IsWindowsXPSP1OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 1);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsXPSP2OrGreater(void) {
|
VERSIONHELPERAPI IsWindowsXPSP2OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 2);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsXPSP3OrGreater(void) {
|
VERSIONHELPERAPI IsWindowsXPSP3OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 3);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINXP), LOBYTE(_WIN32_WINNT_WINXP), 0, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsVistaOrGreater(void) {
|
VERSIONHELPERAPI IsWindowsVistaOrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsVistaSP1OrGreater(void) {
|
VERSIONHELPERAPI IsWindowsVistaSP1OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 1);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsVistaSP2OrGreater(void) {
|
VERSIONHELPERAPI IsWindowsVistaSP2OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 2);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindows7OrGreater(void) {
|
VERSIONHELPERAPI IsWindows7OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindows7SP1OrGreater(void) {
|
VERSIONHELPERAPI IsWindows7SP1OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 1);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindows8OrGreater(void) {
|
VERSIONHELPERAPI IsWindows8OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0, 0);
|
||||||
}
|
}
|
||||||
/* Those can't be used without manifest so we comment them out to ensure they're not being used by accident
|
|
||||||
VERSIONHELPERAPI IsWindows8Point1OrGreater(void) {
|
VERSIONHELPERAPI IsWindows8Point1OrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINBLUE), LOBYTE(_WIN32_WINNT_WINBLUE), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsThresholdOrGreater(void) {
|
VERSIONHELPERAPI IsWindowsThresholdOrGreater(void) {
|
||||||
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0);
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WINTHRESHOLD), LOBYTE(_WIN32_WINNT_WINTHRESHOLD), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindows10OrGreater(void) {
|
VERSIONHELPERAPI IsWindows10OrGreater(void) {
|
||||||
return IsWindowsThresholdOrGreater();
|
return IsWindowsThresholdOrGreater();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
VERSIONHELPERAPI IsWindows11OrGreater(void) {
|
||||||
|
return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN11), LOBYTE(_WIN32_WINNT_WIN11), 22000, 0);
|
||||||
|
}
|
||||||
|
|
||||||
VERSIONHELPERAPI IsWindowsServer(void) {
|
VERSIONHELPERAPI IsWindowsServer(void) {
|
||||||
OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
|
OSVERSIONINFOEXW vi = {sizeof(vi),0,0,0,0,{0},0,0,0,VER_NT_WORKSTATION};
|
||||||
return !VerifyVersionInfoW(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
|
return !verhelp_verify_version(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "dllmain.h"
|
#include "dllmain.h"
|
||||||
#include "ini.h"
|
#include "ini.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
static void cfg_init();
|
static void cfg_init();
|
||||||
static void cfg_create_ini();
|
static void cfg_create_ini();
|
||||||
@ -1075,8 +1076,6 @@ static void cfg_create_ini()
|
|||||||
|
|
||||||
static void cfg_init()
|
static void cfg_init()
|
||||||
{
|
{
|
||||||
g_config.is_wine = real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version") != 0;
|
|
||||||
|
|
||||||
/* get process filename and directory */
|
/* get process filename and directory */
|
||||||
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
|
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
|
||||||
{
|
{
|
||||||
@ -1151,7 +1150,7 @@ static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string,
|
|||||||
{
|
{
|
||||||
char buf[MAX_PATH] = { 0 };
|
char buf[MAX_PATH] = { 0 };
|
||||||
|
|
||||||
if (g_config.is_wine)
|
if (verhelp_is_wine())
|
||||||
{
|
{
|
||||||
char section[MAX_PATH] = { 0 };
|
char section[MAX_PATH] = { 0 };
|
||||||
_snprintf(section, sizeof(section) - 1, "%s/wine", g_config.process_file_name);
|
_snprintf(section, sizeof(section) - 1, "%s/wine", g_config.process_file_name);
|
||||||
|
12
src/dd.c
12
src/dd.c
@ -875,7 +875,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
|||||||
if (g_config.remove_menu && GetMenu(g_ddraw.hwnd))
|
if (g_config.remove_menu && GetMenu(g_ddraw.hwnd))
|
||||||
SetMenu(g_ddraw.hwnd, NULL);
|
SetMenu(g_ddraw.hwnd, NULL);
|
||||||
|
|
||||||
if (!g_config.is_wine)
|
if (!verhelp_is_wine())
|
||||||
{
|
{
|
||||||
MSG msg; /* workaround for "Not Responding" window problem in cnc games */
|
MSG msg; /* workaround for "Not Responding" window problem in cnc games */
|
||||||
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
|
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
|
||||||
@ -905,7 +905,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
|||||||
real_SetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_TOOLWINDOW));
|
real_SetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_TOOLWINDOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_config.is_wine)
|
if (verhelp_is_wine())
|
||||||
{
|
{
|
||||||
real_SetWindowLongA(
|
real_SetWindowLongA(
|
||||||
g_ddraw.hwnd,
|
g_ddraw.hwnd,
|
||||||
@ -1053,7 +1053,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
|||||||
Fix wayland bug:
|
Fix wayland bug:
|
||||||
ChangeDisplaySettings fails silently - enable borderless mode in case display resolution was not changed
|
ChangeDisplaySettings fails silently - enable borderless mode in case display resolution was not changed
|
||||||
*/
|
*/
|
||||||
if (g_config.is_wine &&
|
if (verhelp_is_wine() &&
|
||||||
(g_ddraw.render.mode.dmPelsWidth != real_GetSystemMetrics(SM_CXSCREEN) ||
|
(g_ddraw.render.mode.dmPelsWidth != real_GetSystemMetrics(SM_CXSCREEN) ||
|
||||||
g_ddraw.render.mode.dmPelsHeight != real_GetSystemMetrics(SM_CYSCREEN)))
|
g_ddraw.render.mode.dmPelsHeight != real_GetSystemMetrics(SM_CYSCREEN)))
|
||||||
{
|
{
|
||||||
@ -1066,7 +1066,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_config.is_wine)
|
if (verhelp_is_wine())
|
||||||
{
|
{
|
||||||
real_SetWindowLongA(
|
real_SetWindowLongA(
|
||||||
g_ddraw.hwnd,
|
g_ddraw.hwnd,
|
||||||
@ -1273,7 +1273,7 @@ HRESULT dd_WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
|
|||||||
if (g_config.maxgameticks == -2)
|
if (g_config.maxgameticks == -2)
|
||||||
{
|
{
|
||||||
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
||||||
if (g_ddraw.renderer == ogl_render_main && !g_config.is_wine && !IsWindows8OrGreater())
|
if (g_ddraw.renderer == ogl_render_main && !verhelp_is_wine() && !IsWindows8OrGreater())
|
||||||
{
|
{
|
||||||
if (fpsl_wait_for_vblank())
|
if (fpsl_wait_for_vblank())
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
@ -1556,7 +1556,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
|
|||||||
}
|
}
|
||||||
else /* auto */
|
else /* auto */
|
||||||
{
|
{
|
||||||
if (!g_config.is_wine && d3d9_is_available())
|
if (!verhelp_is_wine() && d3d9_is_available())
|
||||||
{
|
{
|
||||||
g_ddraw.renderer = d3d9_render_main;
|
g_ddraw.renderer = d3d9_render_main;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "blt.h"
|
#include "blt.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
|
||||||
LONG g_dds_gdi_handles;
|
LONG g_dds_gdi_handles;
|
||||||
@ -957,7 +958,7 @@ HRESULT dds_Lock(
|
|||||||
|
|
||||||
dbg_dump_dds_lock_flags(dwFlags);
|
dbg_dump_dds_lock_flags(dwFlags);
|
||||||
|
|
||||||
if (g_ddraw.ref && g_config.fixnotresponding && !g_config.is_wine)
|
if (g_ddraw.ref && g_config.fixnotresponding && !verhelp_is_wine())
|
||||||
{
|
{
|
||||||
MSG msg; /* workaround for "Not Responding" window problem */
|
MSG msg; /* workaround for "Not Responding" window problem */
|
||||||
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE);
|
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE);
|
||||||
|
17
src/debug.c
17
src/debug.c
@ -8,6 +8,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
|
||||||
double g_dbg_frame_time = 0;
|
double g_dbg_frame_time = 0;
|
||||||
@ -130,23 +131,13 @@ void dbg_init()
|
|||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* (CDECL * wine_get_version)() =
|
if (verhelp_is_wine())
|
||||||
(void*)real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version");
|
|
||||||
|
|
||||||
if (wine_get_version)
|
|
||||||
{
|
{
|
||||||
TRACE("Wine version = %s\n", wine_get_version());
|
TRACE("Wine version = %s\n", verhelp_wine_get_version());
|
||||||
}
|
|
||||||
|
|
||||||
void (CDECL* wine_get_host_version)(const char** sysname, const char** release) =
|
|
||||||
(void*)real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_host_version");
|
|
||||||
|
|
||||||
if (wine_get_host_version)
|
|
||||||
{
|
|
||||||
const char* sysname = NULL;
|
const char* sysname = NULL;
|
||||||
const char* release = NULL;
|
const char* release = NULL;
|
||||||
|
verhelp_wine_get_host_version(&sysname, &release);
|
||||||
wine_get_host_version(&sysname, &release);
|
|
||||||
|
|
||||||
TRACE("Wine sysname = %s, release = %s\n", sysname, release);
|
TRACE("Wine sysname = %s, release = %s\n", sysname, release);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
|
||||||
/* export for cncnet cnc games */
|
/* export for cncnet cnc games */
|
||||||
@ -28,6 +29,8 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
|||||||
{
|
{
|
||||||
g_ddraw_module = hDll;
|
g_ddraw_module = hDll;
|
||||||
|
|
||||||
|
verhelp_init();
|
||||||
|
|
||||||
if (GetEnvironmentVariableW(L"cnc_ddraw_config_init", NULL, 0))
|
if (GetEnvironmentVariableW(L"cnc_ddraw_config_init", NULL, 0))
|
||||||
{
|
{
|
||||||
cfg_load();
|
cfg_load();
|
||||||
|
@ -157,7 +157,7 @@ void fpsl_frame_end()
|
|||||||
(g_config.vsync && (!g_config.maxfps || g_config.maxfps >= g_ddraw.mode.dmDisplayFrequency)))
|
(g_config.vsync && (!g_config.maxfps || g_config.maxfps >= g_ddraw.mode.dmDisplayFrequency)))
|
||||||
{
|
{
|
||||||
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
||||||
if (g_ddraw.renderer == ogl_render_main && !g_config.is_wine && !IsWindows8OrGreater())
|
if (g_ddraw.renderer == ogl_render_main && !verhelp_is_wine() && !IsWindows8OrGreater())
|
||||||
{
|
{
|
||||||
if (fpsl_wait_for_vblank())
|
if (fpsl_wait_for_vblank())
|
||||||
return;
|
return;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
PFNWGLCREATECONTEXTPROC xwglCreateContext;
|
PFNWGLCREATECONTEXTPROC xwglCreateContext;
|
||||||
PFNWGLDELETECONTEXTPROC xwglDeleteContext;
|
PFNWGLDELETECONTEXTPROC xwglDeleteContext;
|
||||||
@ -212,7 +213,7 @@ void oglu_init()
|
|||||||
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
|
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
|
||||||
glGetUniformLocation;
|
glGetUniformLocation;
|
||||||
|
|
||||||
if (g_config.is_wine && glversion && glversion[0] == '2') // macOS
|
if (verhelp_is_wine() && glversion && glversion[0] == '2') // macOS
|
||||||
{
|
{
|
||||||
g_oglu_got_version3 = FALSE;
|
g_oglu_got_version3 = FALSE;
|
||||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
|
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
|
||||||
|
72
src/versionhelpers.c
Normal file
72
src/versionhelpers.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
typedef NTSTATUS(WINAPI* RTLVERIFYVERSIONINFOPROC)(PRTL_OSVERSIONINFOEXW, ULONG, ULONGLONG);
|
||||||
|
typedef const char* (CDECL* WINE_GET_VERSIONPROC)();
|
||||||
|
typedef void (CDECL* WINE_GET_HOST_VERSIONPROC)(const char** sysname, const char** release);
|
||||||
|
|
||||||
|
static RTLVERIFYVERSIONINFOPROC RtlVerifyVersionInfo;
|
||||||
|
static WINE_GET_VERSIONPROC wine_get_version;
|
||||||
|
static WINE_GET_HOST_VERSIONPROC wine_get_host_version;
|
||||||
|
|
||||||
|
/* GetProcAddress is rather slow so we use a function to inizialize it once on startup */
|
||||||
|
void verhelp_init()
|
||||||
|
{
|
||||||
|
HMODULE mod = GetModuleHandleA("ntdll.dll");
|
||||||
|
if (mod)
|
||||||
|
{
|
||||||
|
RtlVerifyVersionInfo = (RTLVERIFYVERSIONINFOPROC)GetProcAddress(mod, "RtlVerifyVersionInfo");
|
||||||
|
wine_get_version = (WINE_GET_VERSIONPROC)GetProcAddress(mod, "wine_get_version");
|
||||||
|
wine_get_host_version = (WINE_GET_HOST_VERSIONPROC)GetProcAddress(mod, "wine_get_host_version");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask)
|
||||||
|
{
|
||||||
|
return RtlVerifyVersionInfo ?
|
||||||
|
RtlVerifyVersionInfo(versionInfo, typeMask, conditionMask) == 0 :
|
||||||
|
VerifyVersionInfoW(versionInfo, typeMask, conditionMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* verhelp_wine_get_version()
|
||||||
|
{
|
||||||
|
return wine_get_version ? wine_get_version() : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void verhelp_wine_get_host_version(const char** sysname, const char** release)
|
||||||
|
{
|
||||||
|
if (wine_get_host_version)
|
||||||
|
{
|
||||||
|
wine_get_host_version(sysname, release);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sysname)
|
||||||
|
*sysname = NULL;
|
||||||
|
|
||||||
|
if (release)
|
||||||
|
*release = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL verhelp_is_wine()
|
||||||
|
{
|
||||||
|
return wine_get_version != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL verhelp_is_macos()
|
||||||
|
{
|
||||||
|
const char* sysname = NULL;
|
||||||
|
const char* release = NULL;
|
||||||
|
verhelp_wine_get_host_version(&sysname, &release);
|
||||||
|
|
||||||
|
return sysname && _strcmpi(sysname, "Darwin") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL verhelp_is_linux()
|
||||||
|
{
|
||||||
|
const char* sysname = NULL;
|
||||||
|
const char* release = NULL;
|
||||||
|
verhelp_wine_get_host_version(&sysname, &release);
|
||||||
|
|
||||||
|
return sysname && _strcmpi(sysname, "Linux") == 0;
|
||||||
|
}
|
@ -13,6 +13,7 @@
|
|||||||
#include "wndproc.h"
|
#include "wndproc.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "versionhelpers.h"
|
||||||
|
|
||||||
|
|
||||||
LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
@ -228,7 +229,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
pos->hwndInsertAfter, pos->x, pos->y, pos->cx, pos->cy);
|
pos->hwndInsertAfter, pos->x, pos->y, pos->cx, pos->cy);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (g_config.is_wine &&
|
if (verhelp_is_wine() &&
|
||||||
!g_config.windowed &&
|
!g_config.windowed &&
|
||||||
(pos->x > 0 || pos->y > 0) &&
|
(pos->x > 0 || pos->y > 0) &&
|
||||||
g_ddraw.last_set_window_pos_tick + 500 < timeGetTime())
|
g_ddraw.last_set_window_pos_tick + 500 < timeGetTime())
|
||||||
@ -462,7 +463,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
util_update_bnet_pos(x, y);
|
util_update_bnet_pos(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_size_move || (g_config.is_wine && !g_config.fullscreen && g_ddraw.render.thread))
|
if (in_size_move || (verhelp_is_wine() && !g_config.fullscreen && g_ddraw.render.thread))
|
||||||
{
|
{
|
||||||
if (x != -32000)
|
if (x != -32000)
|
||||||
g_config.window_rect.left = x; /* -32000 = Exit/Minimize */
|
g_config.window_rect.left = x; /* -32000 = Exit/Minimize */
|
||||||
@ -479,7 +480,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
}
|
}
|
||||||
case WM_NCMOUSELEAVE:
|
case WM_NCMOUSELEAVE:
|
||||||
{
|
{
|
||||||
if (!g_config.is_wine) /* hack: disable aero snap */
|
if (!verhelp_is_wine()) /* hack: disable aero snap */
|
||||||
{
|
{
|
||||||
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
||||||
|
|
||||||
@ -492,7 +493,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
}
|
}
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
{
|
{
|
||||||
if ((wParam & ~0x0F) == SC_MOVE && !g_config.is_wine) /* hack: disable aero snap */
|
if ((wParam & ~0x0F) == SC_MOVE && !verhelp_is_wine()) /* hack: disable aero snap */
|
||||||
{
|
{
|
||||||
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
||||||
|
|
||||||
@ -633,7 +634,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
|||||||
|
|
||||||
mouse_unlock();
|
mouse_unlock();
|
||||||
|
|
||||||
if (g_config.is_wine && g_ddraw.last_set_window_pos_tick + 500 > timeGetTime())
|
if (verhelp_is_wine() && g_ddraw.last_set_window_pos_tick + 500 > timeGetTime())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!g_config.windowed)
|
if (!g_config.windowed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user