2023-09-18 10:05:22 +02:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "mkachook/config.h"
|
|
|
|
#include "mkachook/mkac-dll.h"
|
|
|
|
#include "mkachook/xinput.h"
|
|
|
|
#include "mkachook/jvs.h"
|
|
|
|
|
|
|
|
#include "amcus/amcus.h"
|
|
|
|
|
|
|
|
#include "hook/process.h"
|
|
|
|
|
|
|
|
#include "hooklib/serial.h"
|
|
|
|
#include "hooklib/debug.h"
|
|
|
|
|
|
|
|
#include "platform/platform.h"
|
|
|
|
#include "gfxhook/gfx.h"
|
2024-06-18 06:28:38 +02:00
|
|
|
#include "gfxhook/d3d9.h"
|
2023-09-18 10:05:22 +02:00
|
|
|
#include "board/bpreader.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static HMODULE mkac_hook_mod;
|
|
|
|
static process_entry_t mkac_startup;
|
|
|
|
static struct mkac_hook_config mkac_hook_cfg;
|
|
|
|
|
|
|
|
static DWORD CALLBACK mkac_pre_startup(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
dprintf("--- Begin mkac_pre_startup ---\n");
|
|
|
|
|
|
|
|
mkac_hook_config_load(&mkac_hook_cfg, L".\\bananatools.ini");
|
|
|
|
|
|
|
|
serial_hook_init();
|
|
|
|
|
|
|
|
struct dongle_info dinfo;
|
|
|
|
dinfo.vid = 0x0B9A;
|
|
|
|
dinfo.pid = 0x0C10;
|
|
|
|
wcscpy_s(dinfo.manufacturer, _countof(dinfo.manufacturer), L"BM");
|
|
|
|
wcscpy_s(dinfo.product, _countof(dinfo.product), L"RUDI04GBN-274713");
|
|
|
|
|
|
|
|
hr = platform_hook_init(&mkac_hook_cfg.platform, PLATFORM_ES3, mkac_jvs_init, mkac_hook_mod, dinfo);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = mkac_dll_init(&mkac_hook_cfg.dll, mkac_hook_mod);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = mkac_xinput_init(&mkac_hook_cfg.xinput);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = amcus_hook_init(&mkac_hook_cfg.amcus);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = bpreader_init(&mkac_hook_cfg.reader, 4);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
debug_hook_init();
|
|
|
|
|
|
|
|
gfx_hook_init(&mkac_hook_cfg.gfx);
|
2024-06-18 06:28:38 +02:00
|
|
|
gfx_d3d9_hook_init(&mkac_hook_cfg.gfx, mkac_hook_mod);
|
2023-09-18 10:05:22 +02:00
|
|
|
|
|
|
|
dprintf("--- End mkac_pre_startup ---\n");
|
|
|
|
|
|
|
|
return mkac_startup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (cause != DLL_PROCESS_ATTACH) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mkac_hook_mod = mod;
|
|
|
|
|
|
|
|
hr = process_hijack_startup(mkac_pre_startup, &mkac_startup);
|
|
|
|
|
|
|
|
if (!SUCCEEDED(hr)) {
|
|
|
|
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCEEDED(hr);
|
|
|
|
}
|