Files
spice2x.github.io/src/spice2x/hooks/winuser.cpp
T
Will 837c8a46d6 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.
2026-03-06 14:21:55 -08:00

27 lines
942 B
C++

// DisplayConfigSetDeviceInfo
#define _WIN32_WINNT 0x0601
#include "winuser.h"
#include "util/detour.h"
#include "util/logging.h"
// hooks to prevent display scaling changes (e.g., SDVX)
static decltype(DisplayConfigSetDeviceInfo) *DisplayConfigSetDeviceInfo_real = nullptr;
static LONG WINAPI DisplayConfigSetDeviceInfo_hook(DISPLAYCONFIG_DEVICE_INFO_HEADER *setPacket) {
// seems to be using some undocumented API to change the monitor scaling (type == -4)
if (setPacket && setPacket->type == 0xFFFFFFFC) {
log_misc("winuser", "DisplayConfigSetDeviceInfo_hook: ignoring request to change monitor scaling");
return ERROR_SUCCESS;
}
return DisplayConfigSetDeviceInfo_real(setPacket);
}
void winuser_hook_init(HMODULE module) {
log_info("winuser", "initializing");
DisplayConfigSetDeviceInfo_real =
detour::iat_try("DisplayConfigSetDeviceInfo", DisplayConfigSetDeviceInfo_hook, module);
}