104 lines
2.2 KiB
C
104 lines
2.2 KiB
C
#include <windows.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "kizunahook/config.h"
|
|
#include "kizunahook/kizuna-dll.h"
|
|
#include "kizunahook/usio.h"
|
|
|
|
#include "amcus/amcus.h"
|
|
|
|
#include "hook/process.h"
|
|
|
|
#include "hooklib/serial.h"
|
|
#include "board/sg-reader.h"
|
|
#include "board/vfd.h"
|
|
|
|
#include "platform/platform.h"
|
|
#include "gfxhook/gfx.h"
|
|
#include "gfxhook/dxgi.h"
|
|
#include "gfxhook/d3d11.h"
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
static HMODULE kizuna_hook_mod;
|
|
static process_entry_t kizuna_startup;
|
|
static struct kizuna_hook_config kizuna_hook_cfg;
|
|
|
|
static DWORD CALLBACK kizuna_pre_startup(void)
|
|
{
|
|
HRESULT hr;
|
|
|
|
dprintf("--- Begin kizuna_pre_startup ---\n");
|
|
|
|
kizuna_hook_config_load(&kizuna_hook_cfg, L".\\bananatools.ini");
|
|
|
|
serial_hook_init();
|
|
|
|
struct dongle_info dinfo;
|
|
dinfo.pid = 0x0C00;
|
|
dinfo.vid = 0x0B9A;
|
|
|
|
hr = platform_hook_init(&kizuna_hook_cfg.platform, PLATFORM_BNA1, NULL, kizuna_hook_mod, dinfo);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
hr = sg_reader_hook_init(&kizuna_hook_cfg.aime, 1, 3, kizuna_hook_mod);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
hr = vfd_hook_init(&kizuna_hook_cfg.vfd, 2);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
hr = kizuna_dll_init(&kizuna_hook_cfg.dll, kizuna_hook_mod);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
hr = kizuna_usio_hook_init(&kizuna_hook_cfg.usio);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
hr = amcus_hook_init(&kizuna_hook_cfg.amcus);
|
|
|
|
if (FAILED(hr)) {
|
|
ExitProcess(EXIT_FAILURE);
|
|
}
|
|
|
|
gfx_hook_init(&kizuna_hook_cfg.gfx);
|
|
gfx_d3d11_hook_init(&kizuna_hook_cfg.gfx, kizuna_hook_mod);
|
|
gfx_dxgi_hook_init(&kizuna_hook_cfg.gfx, kizuna_hook_mod);
|
|
|
|
dprintf("--- End kizuna_pre_startup ---\n");
|
|
|
|
return kizuna_startup();
|
|
|
|
}
|
|
|
|
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|
{
|
|
HRESULT hr;
|
|
|
|
if (cause != DLL_PROCESS_ATTACH) {
|
|
return TRUE;
|
|
}
|
|
|
|
kizuna_hook_mod = mod;
|
|
|
|
hr = process_hijack_startup(kizuna_pre_startup, &kizuna_startup);
|
|
|
|
if (!SUCCEEDED(hr)) {
|
|
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
|
}
|
|
|
|
return SUCCEEDED(hr);
|
|
} |