mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
Fix broken UI in windowed mode for Polaris Chord (#372)
This commit is contained in:
@@ -19,3 +19,8 @@ dist/*
|
|||||||
external/cv2pdb/*
|
external/cv2pdb/*
|
||||||
|
|
||||||
.ccache/*
|
.ccache/*
|
||||||
|
|
||||||
|
# Visual Studio
|
||||||
|
.vs
|
||||||
|
out
|
||||||
|
CMakeSettings.json
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace games::pc {
|
|||||||
static std::wstring portName = L"COM1";
|
static std::wstring portName = L"COM1";
|
||||||
|
|
||||||
static decltype(RegisterRawInputDevices) *RegisterRawInputDevices_orig = nullptr;
|
static decltype(RegisterRawInputDevices) *RegisterRawInputDevices_orig = nullptr;
|
||||||
|
static decltype(EnumDisplaySettingsW) *EnumDisplaySettingsW_orig = nullptr;
|
||||||
|
static decltype(QueryDisplayConfig) *QueryDisplayConfig_orig = nullptr;
|
||||||
|
|
||||||
static BOOL WINAPI RegisterRawInputDevices_hook(PCRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize) {
|
static BOOL WINAPI RegisterRawInputDevices_hook(PCRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize) {
|
||||||
|
|
||||||
@@ -38,6 +40,27 @@ namespace games::pc {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI EnumDisplaySettingsW_hook(LPCWSTR lpszDeviceName, DWORD iModeNum, DEVMODEW* lpDevMode) {
|
||||||
|
auto result = EnumDisplaySettingsW_orig(lpszDeviceName, iModeNum, lpDevMode);
|
||||||
|
|
||||||
|
// https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Screen-currentResolution.html
|
||||||
|
// "If the player is running in windowed mode, this returns the current dimensions of the game window in pixels and the display refresh rate."
|
||||||
|
// Override it to 1920x1080 to avoid broken UI under Windowed mode
|
||||||
|
if (result && iModeNum == ENUM_CURRENT_SETTINGS) {
|
||||||
|
// Actually make it returns size of the game window, Can I?
|
||||||
|
lpDevMode->dmPelsWidth = 1920;
|
||||||
|
lpDevMode->dmPelsHeight = 1080;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
// want to deal with this api which is way more complex
|
||||||
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
void PCGame::attach() {
|
void PCGame::attach() {
|
||||||
Game::attach();
|
Game::attach();
|
||||||
|
|
||||||
@@ -63,7 +86,10 @@ 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",
|
||||||
|
QueryDisplayConfig_hook, &QueryDisplayConfig_orig);
|
||||||
|
detour::trampoline_try(user32Dll, "EnumDisplaySettingsW",
|
||||||
|
EnumDisplaySettingsW_hook, &EnumDisplaySettingsW_orig);
|
||||||
|
|
||||||
if (GRAPHICS_SHOW_CURSOR) {
|
if (GRAPHICS_SHOW_CURSOR) {
|
||||||
unity_utils::force_show_cursor(true);
|
unity_utils::force_show_cursor(true);
|
||||||
|
|||||||
@@ -230,7 +230,13 @@ namespace overlay::windows {
|
|||||||
auto const register_fn = reinterpret_cast<decltype(&LdrRegisterDllNotification)>
|
auto const register_fn = reinterpret_cast<decltype(&LdrRegisterDllNotification)>
|
||||||
(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "LdrRegisterDllNotification"));
|
(GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "LdrRegisterDllNotification"));
|
||||||
|
|
||||||
auto callback = [] CALLBACK (ULONG reason, PCLDR_DLL_NOTIFICATION_DATA data, PVOID ctx) {
|
auto callback =
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
static_cast<PLDR_DLL_NOTIFICATION_FUNCTION>([]
|
||||||
|
#else
|
||||||
|
[] CALLBACK
|
||||||
|
#endif
|
||||||
|
(ULONG reason, PCLDR_DLL_NOTIFICATION_DATA data, PVOID ctx) {
|
||||||
if (reason == LDR_DLL_NOTIFICATION_REASON_LOADED) {
|
if (reason == LDR_DLL_NOTIFICATION_REASON_LOADED) {
|
||||||
auto const dll = strtolower(std::filesystem::path({
|
auto const dll = strtolower(std::filesystem::path({
|
||||||
data->Loaded.FullDllName->Buffer,
|
data->Loaded.FullDllName->Buffer,
|
||||||
@@ -241,7 +247,11 @@ namespace overlay::windows {
|
|||||||
static_cast<PatchManager*>(ctx)->reload_local_patches(true);
|
static_cast<PatchManager*>(ctx)->reload_local_patches(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
if (register_fn && NT_SUCCESS(register_fn(0, callback, this, &ldr_notify_cookie))) {
|
if (register_fn && NT_SUCCESS(register_fn(0, callback, this, &ldr_notify_cookie))) {
|
||||||
log_info("patchmanager", "registered for DLL load notifications");
|
log_info("patchmanager", "registered for DLL load notifications");
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ std::string peb::entry_name(const LDR_DATA_TABLE_ENTRY* entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PEB* peb::peb_get() {
|
const PEB* peb::peb_get() {
|
||||||
#ifdef SPICE64
|
#ifdef _WIN64
|
||||||
return reinterpret_cast<const PEB *>(__readgsqword(0x60));
|
return reinterpret_cast<const PEB *>(__readgsqword(0x60));
|
||||||
#else
|
#else
|
||||||
return reinterpret_cast<const PEB *>(__readfsdword(0x30));
|
return reinterpret_cast<const PEB *>(__readfsdword(0x30));
|
||||||
|
|||||||
Reference in New Issue
Block a user