This repository has been archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix surf buffer size on max resolution with windowed mode
added window observer thread
- Loading branch information
Showing
9 changed files
with
104 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
patches/screen_resolution/fix_surface_buffer_size_on_max_resolution.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// Created by DiaLight on 25.12.2022. | ||
// | ||
#include <patches.h> | ||
#include <api/patch.h> | ||
#include <api.h> | ||
|
||
typedef BOOL (WINAPI *GetClientRect_t)(HWND hWnd, LPRECT lpRect); | ||
BOOL WINAPI reimpl_GetClientRect(HWND hWnd, LPRECT lpRect) { | ||
BOOL ret = GetClientRect(hWnd, lpRect); | ||
int width = lpRect->right - lpRect->left; | ||
int height = lpRect->bottom - lpRect->top; | ||
if(width != api::g_width || height != api::g_height) { | ||
printf("FIX: GetClientRect: l=%d, t=%d, r=%d, b=%d => create surf %dx%d but game expect to work with buffers %dx%d\n", | ||
lpRect->left, lpRect->top, lpRect->right, lpRect->bottom, | ||
width, height, | ||
api::g_width, api::g_height | ||
); | ||
lpRect->right = lpRect->left + api::g_width; | ||
lpRect->bottom = lpRect->top + api::g_height; | ||
} | ||
return ret; | ||
} | ||
GetClientRect_t pGetClientRect = reimpl_GetClientRect; | ||
|
||
bool patch::fix_surface_buffer_size_on_max_resolution() { | ||
// .text:00556077 mov ebp, ds:GetClientRect | ||
GetClientRect_t **ppGetClientRect = (GetClientRect_t **) (dk2_base + (0x00556077 + 2 - dk2_virtual_base)); | ||
DWORD oldProtect; | ||
if(!VirtualProtect(ppGetClientRect, sizeof(uint32_t), PAGE_EXECUTE_READWRITE, &oldProtect)) return false; | ||
*ppGetClientRect = &pGetClientRect; | ||
VirtualProtect(ppGetClientRect, sizeof(uint32_t), oldProtect, NULL); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters