#include #include "board/io4.h" #include "hook/process.h" #include "hooklib/serial.h" #include "hooklib/spike.h" #include "gfxhook/gfx.h" #include "gfxhook/d3d11.h" #include "ll3hook/config.h" #include "ll3hook/ll3-dll.h" #include "platform/platform.h" #include "util/dprintf.h" static HMODULE ll3_hook_mod; static process_entry_t ll3_startup; static struct ll3_hook_config ll3_hook_cfg; /* This hook is based on mu3hook, with leaked ll3hook i/o codes. */ static DWORD CALLBACK ll3_pre_startup(void) { HRESULT hr; dprintf("--- Begin ll3_pre_startup ---\n"); /* Load config */ ll3_hook_config_load(&ll3_hook_cfg, L".\\taitools.ini"); /* Hook Win32 APIs */ serial_hook_init(); gfx_hook_init(&ll3_hook_cfg.gfx); gfx_d3d11_hook_init(&ll3_hook_cfg.gfx, ll3_hook_mod); /* Initialize emulation hooks */ hr = platform_hook_init( &ll3_hook_cfg.platform, 3800, ll3_hook_mod); if (FAILED(hr)) { goto fail; } hr = ll3_dll_init(&ll3_hook_cfg.dll, ll3_hook_mod); if (FAILED(hr)) { goto fail; } /* Initialize debug helpers */ spike_hook_init(L".\\taitools.ini"); dprintf("--- End ll3_pre_startup ---\n"); /* Jump to EXE start address */ return ll3_startup(); fail: ExitProcess(EXIT_FAILURE); } BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx) { HRESULT hr; if (cause == DLL_THREAD_ATTACH && sizeof(uint64_t) == 4) { dprintf("Connected\n"); } if (cause != DLL_PROCESS_ATTACH) { return TRUE; } ll3_hook_mod = mod; hr = process_hijack_startup(ll3_pre_startup, &ll3_startup); if (!SUCCEEDED(hr)) { dprintf("Failed to hijack process startup: %x\n", (int) hr); } return SUCCEEDED(hr); }