wip: move gfx to gfxhook, some borderless window stuff

This commit is contained in:
2021-11-03 17:14:24 +00:00
committed by Hay1tsme
parent dc85ee3d29
commit 0443a985bd
30 changed files with 193 additions and 111 deletions

50
gfxhook/gfx.c Normal file
View File

@ -0,0 +1,50 @@
#include <windows.h>
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include "gfxhook/config.h"
#include "gfxhook/gfx.h"
#include "hook/table.h"
#include "util/dprintf.h"
typedef BOOL (WINAPI *ShowWindow_t)(HWND hWnd, int nCmdShow);
static BOOL WINAPI hook_ShowWindow(HWND hWnd, int nCmdShow);
static struct gfx_config gfx_config;
static ShowWindow_t next_ShowWindow;
static const struct hook_symbol gfx_hooks[] = {
{
.name = "ShowWindow",
.patch = hook_ShowWindow,
.link = (void **) &next_ShowWindow,
},
};
void gfx_hook_init(const struct gfx_config *cfg, HINSTANCE self)
{
assert(cfg != NULL);
if (!cfg->enable) {
return;
}
memcpy(&gfx_config, cfg, sizeof(*cfg));
hook_table_apply(NULL, "user32.dll", gfx_hooks, _countof(gfx_hooks));
}
static BOOL WINAPI hook_ShowWindow(HWND hWnd, int nCmdShow)
{
dprintf("Gfx: ShowWindow hook hit\n");
if (!gfx_config.framed && nCmdShow == SW_RESTORE) {
nCmdShow = SW_SHOW;
}
return next_ShowWindow(hWnd, nCmdShow);
}