mirror of
https://gitea.tendokyu.moe/Dniel97/segatools.git
synced 2024-11-27 22:40:48 +01:00
diva, fgo: added gfx, close #46
This commit is contained in:
parent
892eb2b859
commit
8fc24503c8
2
dist/carol/segatools.ini
vendored
2
dist/carol/segatools.ini
vendored
@ -64,6 +64,8 @@ subnet=192.168.126.0
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
; Force the game to run windowed.
|
; Force the game to run windowed.
|
||||||
windowed=1
|
windowed=1
|
||||||
; Add a frame to the game window if running windowed.
|
; Add a frame to the game window if running windowed.
|
||||||
|
2
dist/chuni/segatools.ini
vendored
2
dist/chuni/segatools.ini
vendored
@ -56,6 +56,8 @@ subnet=192.168.139.0
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
; Force the game to run windowed.
|
; Force the game to run windowed.
|
||||||
windowed=1
|
windowed=1
|
||||||
; Add a frame to the game window if running windowed.
|
; Add a frame to the game window if running windowed.
|
||||||
|
2
dist/chusan/segatools.ini
vendored
2
dist/chusan/segatools.ini
vendored
@ -82,6 +82,8 @@ dipsw3=1
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
; Force the game to run windowed.
|
; Force the game to run windowed.
|
||||||
windowed=1
|
windowed=1
|
||||||
; Add a frame to the game window if running windowed.
|
; Add a frame to the game window if running windowed.
|
||||||
|
2
dist/cxb/segatools.ini
vendored
2
dist/cxb/segatools.ini
vendored
@ -75,6 +75,8 @@ path=../DEVICE/sram.bin
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
; Force the game to run windowed.
|
; Force the game to run windowed.
|
||||||
windowed=1
|
windowed=1
|
||||||
; Add a frame to the game window if running windowed.
|
; Add a frame to the game window if running windowed.
|
||||||
|
18
dist/diva/segatools.ini
vendored
18
dist/diva/segatools.ini
vendored
@ -5,7 +5,7 @@
|
|||||||
[vfs]
|
[vfs]
|
||||||
; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
|
; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
|
||||||
amfs=
|
amfs=
|
||||||
; Insert the path to the game Option directory here (contains Axxx directories)
|
; Insert the path to the game Option (mdata) directory here (contains Mxxx directories)
|
||||||
option=
|
option=
|
||||||
; Create an empty directory somewhere and insert the path here.
|
; Create an empty directory somewhere and insert the path here.
|
||||||
; This directory may be shared between multiple SEGA games.
|
; This directory may be shared between multiple SEGA games.
|
||||||
@ -36,6 +36,10 @@ default=127.0.0.1
|
|||||||
; Chunithm is extremely picky about its LAN environment, so leaving this
|
; Chunithm is extremely picky about its LAN environment, so leaving this
|
||||||
; setting enabled is strongly recommended.
|
; setting enabled is strongly recommended.
|
||||||
enable=1
|
enable=1
|
||||||
|
; The final octet of the local host's IP address on the virtualized subnet (so,
|
||||||
|
; if the keychip subnet is `192.168.32.0` and this value is set to `11`, then the
|
||||||
|
; local host's virtualized LAN IP is `192.168.32.11`).
|
||||||
|
addrSuffix=11
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
; Board settings
|
; Board settings
|
||||||
@ -54,6 +58,18 @@ dipsw1=1
|
|||||||
; that subnet must start with 192.168.
|
; that subnet must start with 192.168.
|
||||||
subnet=192.168.78.0
|
subnet=192.168.78.0
|
||||||
|
|
||||||
|
; -----------------------------------------------------------------------------
|
||||||
|
; Misc. hooks settings
|
||||||
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
|
; Force the game to run windowed.
|
||||||
|
windowed=1
|
||||||
|
; Add a frame to the game window if running windowed.
|
||||||
|
framed=0
|
||||||
|
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
; Custom IO settings
|
; Custom IO settings
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
8
dist/fgo/segatools.ini
vendored
8
dist/fgo/segatools.ini
vendored
@ -85,6 +85,14 @@ freeplay=0
|
|||||||
; Misc. hook settings
|
; Misc. hook settings
|
||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
|
enable=1
|
||||||
|
; Force the game to run windowed.
|
||||||
|
windowed=0
|
||||||
|
; Add a frame to the game window if running windowed.
|
||||||
|
framed=0
|
||||||
|
|
||||||
[touch]
|
[touch]
|
||||||
; WinTouch emulation setting.
|
; WinTouch emulation setting.
|
||||||
enable=1
|
enable=1
|
||||||
|
1
dist/mercury/segatools.ini
vendored
1
dist/mercury/segatools.ini
vendored
@ -74,6 +74,7 @@ dipsw1=1
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
enable=1
|
enable=1
|
||||||
|
|
||||||
; Hooks related to the touch boards
|
; Hooks related to the touch boards
|
||||||
|
1
dist/mu3/segatools.ini
vendored
1
dist/mu3/segatools.ini
vendored
@ -70,6 +70,7 @@ dipsw1=1
|
|||||||
; -----------------------------------------------------------------------------
|
; -----------------------------------------------------------------------------
|
||||||
|
|
||||||
[gfx]
|
[gfx]
|
||||||
|
; Enables the graphics hook.
|
||||||
enable=1
|
enable=1
|
||||||
|
|
||||||
[unity]
|
[unity]
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
#include "board/config.h"
|
#include "board/config.h"
|
||||||
#include "board/sg-reader.h"
|
#include "board/sg-reader.h"
|
||||||
|
|
||||||
|
#include "hooklib/config.h"
|
||||||
|
#include "hooklib/dvd.h"
|
||||||
|
|
||||||
#include "divahook/config.h"
|
#include "divahook/config.h"
|
||||||
|
|
||||||
#include "platform/config.h"
|
#include "platform/config.h"
|
||||||
@ -47,6 +50,8 @@ void diva_hook_config_load(
|
|||||||
platform_config_load(&cfg->platform, filename);
|
platform_config_load(&cfg->platform, filename);
|
||||||
amex_config_load(&cfg->amex, filename);
|
amex_config_load(&cfg->amex, filename);
|
||||||
aime_config_load(&cfg->aime, filename);
|
aime_config_load(&cfg->aime, filename);
|
||||||
|
dvd_config_load(&cfg->dvd, filename);
|
||||||
|
gfx_config_load(&cfg->gfx, filename);
|
||||||
diva_dll_config_load(&cfg->dll, filename);
|
diva_dll_config_load(&cfg->dll, filename);
|
||||||
slider_config_load(&cfg->slider, filename);
|
slider_config_load(&cfg->slider, filename);
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,25 @@
|
|||||||
|
|
||||||
#include "board/sg-reader.h"
|
#include "board/sg-reader.h"
|
||||||
|
|
||||||
|
#include "hooklib/dvd.h"
|
||||||
|
#include "hooklib/touch.h"
|
||||||
|
|
||||||
|
#include "gfxhook/config.h"
|
||||||
|
|
||||||
|
#include "platform/config.h"
|
||||||
|
|
||||||
|
#include "divahook/3mpxsc.h"
|
||||||
#include "divahook/diva-dll.h"
|
#include "divahook/diva-dll.h"
|
||||||
#include "divahook/slider.h"
|
#include "divahook/slider.h"
|
||||||
|
|
||||||
#include "platform/platform.h"
|
|
||||||
|
|
||||||
struct diva_hook_config {
|
struct diva_hook_config {
|
||||||
struct platform_config platform;
|
struct platform_config platform;
|
||||||
struct amex_config amex;
|
struct amex_config amex;
|
||||||
struct aime_config aime;
|
struct aime_config aime;
|
||||||
|
struct dvd_config dvd;
|
||||||
|
struct gfx_config gfx;
|
||||||
|
struct touch3mpxsc_config touch3mpxsc;
|
||||||
|
struct touch_screen_config touch;
|
||||||
struct diva_dll_config dll;
|
struct diva_dll_config dll;
|
||||||
struct slider_config slider;
|
struct slider_config slider;
|
||||||
};
|
};
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#include "divahook/jvs.h"
|
#include "divahook/jvs.h"
|
||||||
#include "divahook/slider.h"
|
#include "divahook/slider.h"
|
||||||
|
|
||||||
|
#include "gfxhook/gfx.h"
|
||||||
|
#include "gfxhook/gl.h"
|
||||||
|
|
||||||
#include "hook/process.h"
|
#include "hook/process.h"
|
||||||
|
|
||||||
#include "hooklib/serial.h"
|
#include "hooklib/serial.h"
|
||||||
@ -38,15 +41,30 @@ static struct diva_hook_config diva_hook_cfg;
|
|||||||
static DWORD CALLBACK diva_pre_startup(void)
|
static DWORD CALLBACK diva_pre_startup(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
HMODULE dbghelp;
|
||||||
|
|
||||||
dprintf("--- Begin diva_pre_startup ---\n");
|
dprintf("--- Begin diva_pre_startup ---\n");
|
||||||
|
|
||||||
|
/* Pin dbghelp so the path hooks apply to it. */
|
||||||
|
|
||||||
|
dbghelp = LoadLibraryW(L"dbghelp.dll");
|
||||||
|
|
||||||
|
if (dbghelp != NULL) {
|
||||||
|
dprintf("Pinned debug helper library, hMod=%p\n", dbghelp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dprintf("Failed to load debug helper library!\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Config load */
|
/* Config load */
|
||||||
|
|
||||||
diva_hook_config_load(&diva_hook_cfg, L".\\segatools.ini");
|
diva_hook_config_load(&diva_hook_cfg, L".\\segatools.ini");
|
||||||
|
|
||||||
/* Hook Win32 APIs */
|
/* Hook Win32 APIs */
|
||||||
|
|
||||||
|
dvd_hook_init(&diva_hook_cfg.dvd, diva_hook_mod);
|
||||||
|
gfx_hook_init(&diva_hook_cfg.gfx);
|
||||||
|
gfx_gl_hook_init(&diva_hook_cfg.gfx, diva_hook_mod);
|
||||||
serial_hook_init();
|
serial_hook_init();
|
||||||
|
|
||||||
/* Initialize emulation hooks */
|
/* Initialize emulation hooks */
|
||||||
|
@ -63,33 +63,33 @@ static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
|||||||
|
|
||||||
diva_dll.jvs_poll(&opbtn, &gamebtn);
|
diva_dll.jvs_poll(&opbtn, &gamebtn);
|
||||||
|
|
||||||
if (gamebtn & 0x01) {
|
if (gamebtn & DIVA_IO_GAMEBTN_CIRCLE) {
|
||||||
out->p1 |= 1 << 6;
|
out->p1 |= 1 << 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamebtn & 0x02) {
|
if (gamebtn & DIVA_IO_GAMEBTN_CROSS) {
|
||||||
out->p1 |= 1 << 7;
|
out->p1 |= 1 << 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamebtn & 0x04) {
|
if (gamebtn & DIVA_IO_GAMEBTN_SQUARE) {
|
||||||
out->p1 |= 1 << 8;
|
out->p1 |= 1 << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamebtn & 0x08) {
|
if (gamebtn & DIVA_IO_GAMEBTN_TRIANGLE) {
|
||||||
out->p1 |= 1 << 9;
|
out->p1 |= 1 << 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gamebtn & 0x10) {
|
if (gamebtn & DIVA_IO_GAMEBTN_START) {
|
||||||
out->p1 |= 1 << 15;
|
out->p1 |= 1 << 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opbtn & 0x01) {
|
if (opbtn & DIVA_IO_OPBTN_TEST) {
|
||||||
out->system = 0x80;
|
out->system = 0x80;
|
||||||
} else {
|
} else {
|
||||||
out->system = 0;
|
out->system = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opbtn & 0x02) {
|
if (opbtn & DIVA_IO_OPBTN_SERVICE) {
|
||||||
out->p1 |= 1 << 14;
|
out->p1 |= 1 << 14;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ shared_library(
|
|||||||
amex_lib,
|
amex_lib,
|
||||||
board_lib,
|
board_lib,
|
||||||
divaio_lib,
|
divaio_lib,
|
||||||
|
gfxhook_lib,
|
||||||
hooklib_lib,
|
hooklib_lib,
|
||||||
jvs_lib,
|
jvs_lib,
|
||||||
platform_lib,
|
platform_lib,
|
||||||
|
@ -37,11 +37,11 @@ void diva_io_jvs_poll(uint8_t *opbtn_out, uint8_t *gamebtn_out)
|
|||||||
opbtn = 0;
|
opbtn = 0;
|
||||||
|
|
||||||
if (GetAsyncKeyState(diva_io_cfg.vk_test) & 0x8000) {
|
if (GetAsyncKeyState(diva_io_cfg.vk_test) & 0x8000) {
|
||||||
opbtn |= 1;
|
opbtn |= DIVA_IO_OPBTN_TEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetAsyncKeyState(diva_io_cfg.vk_service) & 0x8000) {
|
if (GetAsyncKeyState(diva_io_cfg.vk_service) & 0x8000) {
|
||||||
opbtn |= 2;
|
opbtn |= DIVA_IO_OPBTN_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0 ; i < _countof(diva_io_cfg.vk_buttons) ; i++) {
|
for (i = 0 ; i < _countof(diva_io_cfg.vk_buttons) ; i++) {
|
||||||
|
@ -5,6 +5,19 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DIVA_IO_OPBTN_TEST = 0x01,
|
||||||
|
DIVA_IO_OPBTN_SERVICE = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
DIVA_IO_GAMEBTN_CIRCLE = 0x01,
|
||||||
|
DIVA_IO_GAMEBTN_CROSS = 0x02,
|
||||||
|
DIVA_IO_GAMEBTN_SQUARE = 0x04,
|
||||||
|
DIVA_IO_GAMEBTN_TRIANGLE = 0x08,
|
||||||
|
DIVA_IO_GAMEBTN_START = 0x10,
|
||||||
|
};
|
||||||
|
|
||||||
/* Get the version of the Project Diva IO API that this DLL supports. This
|
/* Get the version of the Project Diva IO API that this DLL supports. This
|
||||||
function should return a positive 16-bit integer, where the high byte is
|
function should return a positive 16-bit integer, where the high byte is
|
||||||
the major version and the low byte is the minor version (as defined by the
|
the major version and the low byte is the minor version (as defined by the
|
||||||
|
@ -122,5 +122,6 @@ void fgo_hook_config_load(
|
|||||||
fgo_deck_config_load(&cfg->deck, filename);
|
fgo_deck_config_load(&cfg->deck, filename);
|
||||||
ftdi_config_load(&cfg->ftdi, filename);
|
ftdi_config_load(&cfg->ftdi, filename);
|
||||||
led15093_config_load(&cfg->led15093, filename);
|
led15093_config_load(&cfg->led15093, filename);
|
||||||
|
gfx_config_load(&cfg->gfx, filename);
|
||||||
fgo_dll_config_load(&cfg->dll, filename);
|
fgo_dll_config_load(&cfg->dll, filename);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include "hooklib/touch.h"
|
#include "hooklib/touch.h"
|
||||||
#include "hooklib/printer.h"
|
#include "hooklib/printer.h"
|
||||||
|
|
||||||
|
#include "gfxhook/config.h"
|
||||||
|
|
||||||
#include "fgohook/deck.h"
|
#include "fgohook/deck.h"
|
||||||
#include "fgohook/ftdi.h"
|
#include "fgohook/ftdi.h"
|
||||||
#include "fgohook/fgo-dll.h"
|
#include "fgohook/fgo-dll.h"
|
||||||
@ -26,6 +28,7 @@ struct fgo_hook_config {
|
|||||||
struct deck_config deck;
|
struct deck_config deck;
|
||||||
struct ftdi_config ftdi;
|
struct ftdi_config ftdi;
|
||||||
struct led15093_config led15093;
|
struct led15093_config led15093;
|
||||||
|
struct gfx_config gfx;
|
||||||
struct fgo_dll_config dll;
|
struct fgo_dll_config dll;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#include "hooklib/serial.h"
|
#include "hooklib/serial.h"
|
||||||
#include "hooklib/spike.h"
|
#include "hooklib/spike.h"
|
||||||
|
|
||||||
|
#include "gfxhook/gfx.h"
|
||||||
|
|
||||||
#include "fgohook/config.h"
|
#include "fgohook/config.h"
|
||||||
#include "fgohook/io4.h"
|
#include "fgohook/io4.h"
|
||||||
#include "fgohook/fgo-dll.h"
|
#include "fgohook/fgo-dll.h"
|
||||||
@ -50,9 +52,21 @@ static struct fgo_hook_config fgo_hook_cfg;
|
|||||||
static DWORD CALLBACK fgo_pre_startup(void)
|
static DWORD CALLBACK fgo_pre_startup(void)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
HMODULE dbghelp;
|
||||||
|
|
||||||
dprintf("--- Begin fgo_pre_startup ---\n");
|
dprintf("--- Begin fgo_pre_startup ---\n");
|
||||||
|
|
||||||
|
/* Pin dbghelp so the path hooks apply to it. */
|
||||||
|
|
||||||
|
dbghelp = LoadLibraryW(L"dbghelp.dll");
|
||||||
|
|
||||||
|
if (dbghelp != NULL) {
|
||||||
|
dprintf("Pinned debug helper library, hMod=%p\n", dbghelp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dprintf("Failed to load debug helper library!\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Load config */
|
/* Load config */
|
||||||
|
|
||||||
fgo_hook_config_load(&fgo_hook_cfg, L".\\segatools.ini");
|
fgo_hook_config_load(&fgo_hook_cfg, L".\\segatools.ini");
|
||||||
@ -60,6 +74,7 @@ static DWORD CALLBACK fgo_pre_startup(void)
|
|||||||
/* Hook Win32 APIs */
|
/* Hook Win32 APIs */
|
||||||
|
|
||||||
dvd_hook_init(&fgo_hook_cfg.dvd, fgo_hook_mod);
|
dvd_hook_init(&fgo_hook_cfg.dvd, fgo_hook_mod);
|
||||||
|
gfx_hook_init(&fgo_hook_cfg.gfx);
|
||||||
touch_screen_hook_init(&fgo_hook_cfg.touch, fgo_hook_mod);
|
touch_screen_hook_init(&fgo_hook_cfg.touch, fgo_hook_mod);
|
||||||
serial_hook_init();
|
serial_hook_init();
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ shared_library(
|
|||||||
link_with : [
|
link_with : [
|
||||||
aimeio_lib,
|
aimeio_lib,
|
||||||
board_lib,
|
board_lib,
|
||||||
|
gfxhook_lib,
|
||||||
hooklib_lib,
|
hooklib_lib,
|
||||||
fgoio_lib,
|
fgoio_lib,
|
||||||
platform_lib,
|
platform_lib,
|
||||||
|
@ -9,18 +9,53 @@
|
|||||||
|
|
||||||
#include "util/dprintf.h"
|
#include "util/dprintf.h"
|
||||||
|
|
||||||
typedef BOOL (WINAPI *ShowWindow_t)(HWND hWnd, int nCmdShow);
|
/* Hook functions */
|
||||||
|
|
||||||
static BOOL WINAPI hook_ShowWindow(HWND hWnd, int nCmdShow);
|
static BOOL WINAPI hook_ShowWindow(HWND hWnd, int nCmdShow);
|
||||||
|
static BOOL WINAPI hook_CreateWindowExA(
|
||||||
|
DWORD dwExStyle,
|
||||||
|
LPCSTR lpClassName,
|
||||||
|
LPCSTR lpWindowName,
|
||||||
|
DWORD dwStyle,
|
||||||
|
int X,
|
||||||
|
int Y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
HWND hWndParent,
|
||||||
|
HMENU hMenu,
|
||||||
|
HINSTANCE hInstance,
|
||||||
|
LPVOID lpParam
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Link pointers */
|
||||||
|
|
||||||
|
static BOOL (WINAPI *next_ShowWindow)(HWND hWnd, int nCmdShow);
|
||||||
|
static BOOL (WINAPI *next_CreateWindowExA)(
|
||||||
|
DWORD dwExStyle,
|
||||||
|
LPCSTR lpClassName,
|
||||||
|
LPCSTR lpWindowName,
|
||||||
|
DWORD dwStyle,
|
||||||
|
int X,
|
||||||
|
int Y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
HWND hWndParent,
|
||||||
|
HMENU hMenu,
|
||||||
|
HINSTANCE hInstance,
|
||||||
|
LPVOID lpParam
|
||||||
|
);
|
||||||
|
|
||||||
static struct gfx_config gfx_config;
|
static struct gfx_config gfx_config;
|
||||||
static ShowWindow_t next_ShowWindow;
|
|
||||||
|
|
||||||
static const struct hook_symbol gfx_hooks[] = {
|
static const struct hook_symbol gfx_hooks[] = {
|
||||||
{
|
{
|
||||||
.name = "ShowWindow",
|
.name = "ShowWindow",
|
||||||
.patch = hook_ShowWindow,
|
.patch = hook_ShowWindow,
|
||||||
.link = (void **) &next_ShowWindow,
|
.link = (void **) &next_ShowWindow,
|
||||||
|
}, {
|
||||||
|
.name = "CreateWindowExA",
|
||||||
|
.patch = hook_CreateWindowExA,
|
||||||
|
.link = (void **) &next_CreateWindowExA,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,3 +81,45 @@ static BOOL WINAPI hook_ShowWindow(HWND hWnd, int nCmdShow)
|
|||||||
|
|
||||||
return next_ShowWindow(hWnd, nCmdShow);
|
return next_ShowWindow(hWnd, nCmdShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL WINAPI hook_CreateWindowExA(
|
||||||
|
DWORD dwExStyle,
|
||||||
|
LPCSTR lpClassName,
|
||||||
|
LPCSTR lpWindowName,
|
||||||
|
DWORD dwStyle,
|
||||||
|
int X,
|
||||||
|
int Y,
|
||||||
|
int nWidth,
|
||||||
|
int nHeight,
|
||||||
|
HWND hWndParent,
|
||||||
|
HMENU hMenu,
|
||||||
|
HINSTANCE hInstance,
|
||||||
|
LPVOID lpParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
dprintf("Gfx: CreateWindowExA hook hit\n");
|
||||||
|
|
||||||
|
// Set to WS_OVERLAPPEDWINDOW to enable a window with a border and windowed style
|
||||||
|
if (gfx_config.windowed) {
|
||||||
|
dwStyle = WS_OVERLAPPEDWINDOW;
|
||||||
|
|
||||||
|
if (!gfx_config.framed) {
|
||||||
|
dwStyle = WS_POPUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_CreateWindowExA(
|
||||||
|
dwExStyle,
|
||||||
|
lpClassName,
|
||||||
|
lpWindowName,
|
||||||
|
dwStyle,
|
||||||
|
X,
|
||||||
|
Y,
|
||||||
|
nWidth,
|
||||||
|
nHeight,
|
||||||
|
hWndParent,
|
||||||
|
hMenu,
|
||||||
|
hInstance,
|
||||||
|
lpParam
|
||||||
|
);
|
||||||
|
}
|
||||||
|
77
gfxhook/gl.c
Normal file
77
gfxhook/gl.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "gfxhook/gfx.h"
|
||||||
|
#include "gfxhook/gl.h"
|
||||||
|
|
||||||
|
#include "hook/table.h"
|
||||||
|
|
||||||
|
#include "hooklib/dll.h"
|
||||||
|
|
||||||
|
#include "util/dprintf.h"
|
||||||
|
|
||||||
|
/* Hook functions */
|
||||||
|
|
||||||
|
static void WINAPI hook_glutFullScreen(void);
|
||||||
|
static void WINAPI hook_glutInitDisplayMode(unsigned int mode);
|
||||||
|
|
||||||
|
/* Link pointers */
|
||||||
|
|
||||||
|
static void (WINAPI *next_glutFullScreen)(void);
|
||||||
|
static void (WINAPI *next_glutInitDisplayMode)(unsigned int mode);
|
||||||
|
|
||||||
|
static struct gfx_config gfx_config;
|
||||||
|
|
||||||
|
static const struct hook_symbol glut_hooks[] = {
|
||||||
|
{
|
||||||
|
.name = "glutFullScreen",
|
||||||
|
.patch = hook_glutFullScreen,
|
||||||
|
.link = (void **) &next_glutFullScreen,
|
||||||
|
}, {
|
||||||
|
.name = "glutInitDisplayMode",
|
||||||
|
.patch = hook_glutInitDisplayMode,
|
||||||
|
.link = (void **) &next_glutInitDisplayMode,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
void gfx_gl_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, "glut32.dll", glut_hooks, _countof(glut_hooks));
|
||||||
|
|
||||||
|
if (self != NULL) {
|
||||||
|
dll_hook_push(self, L"glut32.dll");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WINAPI hook_glutFullScreen(void)
|
||||||
|
{
|
||||||
|
dprintf("Gfx: glutFullScreen hook hit\n");
|
||||||
|
|
||||||
|
if (gfx_config.windowed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_glutFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WINAPI hook_glutInitDisplayMode(unsigned int mode)
|
||||||
|
{
|
||||||
|
dprintf("Gfx: glutInitDisplayMode hook hit\n");
|
||||||
|
|
||||||
|
// GLUT adds a frame when going windowed
|
||||||
|
if (gfx_config.windowed && !gfx_config.framed) {
|
||||||
|
// GLUT_BORDERLESS
|
||||||
|
mode |= 0x0800;
|
||||||
|
}
|
||||||
|
|
||||||
|
return next_glutInitDisplayMode(mode);
|
||||||
|
}
|
3
gfxhook/gl.h
Normal file
3
gfxhook/gl.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void gfx_gl_hook_init(const struct gfx_config *cfg, HINSTANCE self);
|
@ -22,6 +22,8 @@ gfxhook_lib = static_library(
|
|||||||
'dxgi.h',
|
'dxgi.h',
|
||||||
'gfx.c',
|
'gfx.c',
|
||||||
'gfx.h',
|
'gfx.h',
|
||||||
|
'gl.c',
|
||||||
|
'gl.h',
|
||||||
'util.c',
|
'util.c',
|
||||||
'util.h',
|
'util.h',
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user