mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
add some more _WIN32_WINNT defines to hook Win vista+ APIs when compiler is targeting XP (#568)
There's already a bunch of these in the codebase, this just catches a few locations where they were missed when the compiler is targeting XP.
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
// QueryDisplayConfig
|
||||||
|
#define _WIN32_WINNT 0x0601
|
||||||
|
|
||||||
#include "pc.h"
|
#include "pc.h"
|
||||||
|
|
||||||
#include <format>
|
#include <format>
|
||||||
@@ -32,10 +35,10 @@ namespace games::pc {
|
|||||||
if (pRawInputDevices &&
|
if (pRawInputDevices &&
|
||||||
(uiNumDevices > 0) &&
|
(uiNumDevices > 0) &&
|
||||||
(pRawInputDevices[0].hwndTarget == RI_MGR->input_hwnd)) {
|
(pRawInputDevices[0].hwndTarget == RI_MGR->input_hwnd)) {
|
||||||
|
|
||||||
return RegisterRawInputDevices_orig(pRawInputDevices, uiNumDevices, cbSize);
|
return RegisterRawInputDevices_orig(pRawInputDevices, uiNumDevices, cbSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, it must be the game; prevent the game from registering for raw input
|
// otherwise, it must be the game; prevent the game from registering for raw input
|
||||||
// and hijacking WM_INPUT messages.
|
// and hijacking WM_INPUT messages.
|
||||||
SetLastError(0xDEADBEEF);
|
SetLastError(0xDEADBEEF);
|
||||||
@@ -58,7 +61,7 @@ namespace games::pc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI QueryDisplayConfig_hook(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO*, UINT32*, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*) {
|
LONG WINAPI QueryDisplayConfig_hook(UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO*, UINT32*, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*) {
|
||||||
// make unity fallback to EnumDisplaySettingsW as I don't
|
// make unity fallback to EnumDisplaySettingsW as I don't
|
||||||
// want to deal with this api which is way more complex
|
// want to deal with this api which is way more complex
|
||||||
return ERROR_NOT_SUPPORTED;
|
return ERROR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
@@ -98,9 +101,9 @@ namespace games::pc {
|
|||||||
const auto user32Dll = "user32.dll";
|
const auto user32Dll = "user32.dll";
|
||||||
detour::trampoline_try(user32Dll, "RegisterRawInputDevices",
|
detour::trampoline_try(user32Dll, "RegisterRawInputDevices",
|
||||||
RegisterRawInputDevices_hook, &RegisterRawInputDevices_orig);
|
RegisterRawInputDevices_hook, &RegisterRawInputDevices_orig);
|
||||||
detour::trampoline_try(user32Dll, "QueryDisplayConfig",
|
detour::trampoline_try(user32Dll, "QueryDisplayConfig",
|
||||||
QueryDisplayConfig_hook, &QueryDisplayConfig_orig);
|
QueryDisplayConfig_hook, &QueryDisplayConfig_orig);
|
||||||
detour::trampoline_try(user32Dll, "EnumDisplaySettingsW",
|
detour::trampoline_try(user32Dll, "EnumDisplaySettingsW",
|
||||||
EnumDisplaySettingsW_hook, &EnumDisplaySettingsW_orig);
|
EnumDisplaySettingsW_hook, &EnumDisplaySettingsW_orig);
|
||||||
|
|
||||||
if (GRAPHICS_SHOW_CURSOR) {
|
if (GRAPHICS_SHOW_CURSOR) {
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// GetLocaleInfoEx
|
||||||
|
#define _WIN32_WINNT 0x0600
|
||||||
|
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
#define WIN32_NO_STATUS
|
#define WIN32_NO_STATUS
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// DisplayConfigSetDeviceInfo
|
||||||
|
#define _WIN32_WINNT 0x0601
|
||||||
|
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
|
|
||||||
#include "util/detour.h"
|
#include "util/detour.h"
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
// GetCurrentProcessorNumberEx
|
||||||
|
#define _WIN32_WINNT 0x0601
|
||||||
|
|
||||||
#include "cpuutils.h"
|
#include "cpuutils.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -98,7 +101,7 @@ namespace cpuutils {
|
|||||||
log_misc("cpuutils", "detected {} processors", PROCESSOR_COUNT);
|
log_misc("cpuutils", "detected {} processors", PROCESSOR_COUNT);
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
|
|
||||||
// init processor states
|
// init processor states
|
||||||
get_load();
|
get_load();
|
||||||
}
|
}
|
||||||
@@ -144,11 +147,11 @@ namespace cpuutils {
|
|||||||
// dump cpu id
|
// dump cpu id
|
||||||
log_misc("cpuinfo", "{}, {} ({})",
|
log_misc("cpuinfo", "{}, {} ({})",
|
||||||
cpu.vendor,
|
cpu.vendor,
|
||||||
cpu.brand_string,
|
cpu.brand_string,
|
||||||
GetX86MicroarchitectureName(GetX86Microarchitecture(&cpu)));
|
GetX86MicroarchitectureName(GetX86Microarchitecture(&cpu)));
|
||||||
log_misc("cpuinfo", "family 0x{:x}, model 0x{:x}, stepping 0x{:x}", cpu.family, cpu.model, cpu.stepping);
|
log_misc("cpuinfo", "family 0x{:x}, model 0x{:x}, stepping 0x{:x}", cpu.family, cpu.model, cpu.stepping);
|
||||||
|
|
||||||
// dump features
|
// dump features
|
||||||
std::string features = "";
|
std::string features = "";
|
||||||
for (size_t i = 0; i < X86_LAST_; ++i) {
|
for (size_t i = 0; i < X86_LAST_; ++i) {
|
||||||
if (GetX86FeaturesEnumValue(&cpu.features, static_cast<X86FeaturesEnum>(i))) {
|
if (GetX86FeaturesEnumValue(&cpu.features, static_cast<X86FeaturesEnum>(i))) {
|
||||||
@@ -253,7 +256,7 @@ namespace cpuutils {
|
|||||||
if (GetLogicalProcessorInformationEx == nullptr) {
|
if (GetLogicalProcessorInformationEx == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine buffer size
|
// determine buffer size
|
||||||
returned_length = 0;
|
returned_length = 0;
|
||||||
result = GetLogicalProcessorInformationEx(
|
result = GetLogicalProcessorInformationEx(
|
||||||
|
|||||||
Reference in New Issue
Block a user