forked from TeamTofuShop/segatools
wip: move gfx to gfxhook, some borderless window stuff
This commit is contained in:
50
gfxhook/gfx.c
Normal file
50
gfxhook/gfx.c
Normal 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);
|
||||
}
|
Reference in New Issue
Block a user