2023-01-03 05:35:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "taikohook/config.h"
|
|
|
|
#include "taikohook/taiko-dll.h"
|
|
|
|
#include "taikohook/amfw.h"
|
|
|
|
#include "taikohook/network.h"
|
2023-07-11 05:21:36 +02:00
|
|
|
#include "taikohook/usio.h"
|
|
|
|
|
|
|
|
#include "board/bpreader.h"
|
|
|
|
#include "board/qr.h"
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
#include "amcus/amcus.h"
|
|
|
|
|
|
|
|
#include "hook/process.h"
|
|
|
|
|
|
|
|
#include "hooklib/serial.h"
|
|
|
|
|
|
|
|
#include "platform/platform.h"
|
|
|
|
#include "gfxhook/gfx.h"
|
|
|
|
#include "gfxhook/dxgi.h"
|
|
|
|
#include "gfxhook/d3d11.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static HMODULE taiko_hook_mod;
|
|
|
|
static process_entry_t taiko_startup;
|
|
|
|
static struct taiko_hook_config taiko_hook_cfg;
|
|
|
|
|
|
|
|
static DWORD CALLBACK taiko_pre_startup(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
dprintf("--- Begin taiko_pre_startup ---\n");
|
|
|
|
|
|
|
|
taiko_hook_config_load(&taiko_hook_cfg, L".\\bananatools.ini");
|
|
|
|
|
|
|
|
serial_hook_init();
|
|
|
|
|
2023-01-26 03:09:38 +01:00
|
|
|
struct dongle_info dinfo;
|
2023-07-11 05:21:36 +02:00
|
|
|
dinfo.pid = 0x0C00;
|
|
|
|
dinfo.vid = 0x0B9A;
|
2023-01-26 03:09:38 +01:00
|
|
|
|
|
|
|
hr = platform_hook_init(&taiko_hook_cfg.platform, PLATFORM_BNA1, NULL, taiko_hook_mod, dinfo);
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = taiko_dll_init(&taiko_hook_cfg.dll, taiko_hook_mod);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
hr = taiko_usio_hook_init(&taiko_hook_cfg.usio);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = qr_hook_init(&taiko_hook_cfg.qr, 1);
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2023-07-11 05:21:36 +02:00
|
|
|
hr = bpreader_init(&taiko_hook_cfg.reader, 3);
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = amfw_hook_init(taiko_hook_cfg.platform.dongle.serial);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = amcus_hook_init(&taiko_hook_cfg.amcus);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = network_hook_init(&taiko_hook_cfg.network);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx_hook_init(&taiko_hook_cfg.gfx);
|
|
|
|
gfx_d3d11_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
|
|
|
gfx_dxgi_hook_init(&taiko_hook_cfg.gfx, taiko_hook_mod);
|
|
|
|
|
|
|
|
dprintf("--- End taiko_pre_startup ---\n");
|
|
|
|
|
|
|
|
return taiko_startup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (cause != DLL_PROCESS_ATTACH) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
taiko_hook_mod = mod;
|
|
|
|
|
|
|
|
hr = process_hijack_startup(taiko_pre_startup, &taiko_startup);
|
|
|
|
|
|
|
|
if (!SUCCEEDED(hr)) {
|
|
|
|
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCEEDED(hr);
|
|
|
|
}
|