2024-02-11 04:38:24 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "board/io4.h"
|
|
|
|
|
|
|
|
#include "hook/process.h"
|
|
|
|
|
|
|
|
#include "hooklib/serial.h"
|
|
|
|
#include "hooklib/spike.h"
|
|
|
|
|
2024-02-20 07:17:12 +00:00
|
|
|
#include "idmac/idmac.h"
|
|
|
|
|
2024-02-11 04:38:24 +00:00
|
|
|
#include "gfxhook/gfx.h"
|
2024-02-19 06:56:53 +00:00
|
|
|
#include "gfxhook/d3d9.h"
|
2024-02-11 04:38:24 +00:00
|
|
|
#include "gfxhook/d3d11.h"
|
2024-02-19 06:56:53 +00:00
|
|
|
#include "gfxhook/dxgi.h"
|
2024-02-11 04:38:24 +00:00
|
|
|
|
2024-02-20 07:17:12 +00:00
|
|
|
#include "sivahook/reader.h"
|
2024-02-11 04:38:24 +00:00
|
|
|
#include "sivahook/config.h"
|
|
|
|
#include "sivahook/siva-dll.h"
|
2024-02-14 18:38:52 +00:00
|
|
|
#include "sivahook/touch.h"
|
2024-02-11 04:38:24 +00:00
|
|
|
#include "sivahook/unity.h"
|
|
|
|
|
|
|
|
#include "platform/platform.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static HMODULE siva_hook_mod;
|
|
|
|
static process_entry_t siva_startup;
|
|
|
|
static struct siva_hook_config siva_hook_cfg;
|
|
|
|
|
|
|
|
/* This hook is based on mu3hook, with leaked sivahook i/o codes. */
|
|
|
|
|
|
|
|
static DWORD CALLBACK siva_pre_startup(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
dprintf("--- Begin siva_pre_startup ---\n");
|
|
|
|
|
|
|
|
/* Load config */
|
|
|
|
|
|
|
|
siva_hook_config_load(&siva_hook_cfg, L".\\taitools.ini");
|
|
|
|
|
|
|
|
/* Hook Win32 APIs */
|
|
|
|
serial_hook_init();
|
|
|
|
|
2024-02-19 06:56:53 +00:00
|
|
|
//gfx_hook_init(&siva_hook_cfg.gfx);
|
|
|
|
//gfx_d3d9_hook_init(&siva_hook_cfg.gfx, siva_hook_mod);
|
|
|
|
//gfx_d3d11_hook_init(&siva_hook_cfg.gfx, siva_hook_mod);
|
|
|
|
//gfx_dxgi_hook_init(&siva_hook_cfg.gfx, siva_hook_mod);
|
2024-02-11 04:38:24 +00:00
|
|
|
|
|
|
|
/* Initialize emulation hooks */
|
|
|
|
|
|
|
|
hr = platform_hook_init(
|
|
|
|
&siva_hook_cfg.platform,
|
|
|
|
3000,
|
|
|
|
siva_hook_mod);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
2024-02-17 07:29:52 +00:00
|
|
|
|
2024-02-11 04:38:24 +00:00
|
|
|
hr = siva_dll_init(&siva_hook_cfg.dll, siva_hook_mod);
|
|
|
|
|
2024-02-17 07:29:52 +00:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = touch_hook_init(&siva_hook_cfg.touch);
|
|
|
|
|
2024-02-11 04:38:24 +00:00
|
|
|
if (FAILED(hr)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2024-02-20 07:17:12 +00:00
|
|
|
hr = idmac_hook_init(&siva_hook_cfg.idmac, siva_reader_init);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2024-02-11 04:38:24 +00:00
|
|
|
unity_hook_init();
|
|
|
|
/* Initialize debug helpers */
|
|
|
|
|
|
|
|
spike_hook_init(L".\\taitools.ini");
|
|
|
|
|
|
|
|
dprintf("--- End siva_pre_startup ---\n");
|
|
|
|
|
|
|
|
/* Jump to EXE start address */
|
|
|
|
|
|
|
|
return siva_startup();
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
2024-02-21 08:43:44 +00:00
|
|
|
if (sizeof(uint64_t) == 4) {
|
|
|
|
printf("Connected\n");
|
2024-02-17 07:29:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cause != DLL_PROCESS_ATTACH) {
|
2024-02-11 04:38:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
siva_hook_mod = mod;
|
|
|
|
|
|
|
|
hr = process_hijack_startup(siva_pre_startup, &siva_startup);
|
|
|
|
|
|
|
|
if (!SUCCEEDED(hr)) {
|
|
|
|
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCEEDED(hr);
|
|
|
|
}
|