2023-01-03 05:35:53 +01:00
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "ferrumhook/config.h"
|
|
|
|
#include "ferrumhook/ferrum-dll.h"
|
|
|
|
#include "ferrumhook/xinput.h"
|
|
|
|
#include "ferrumhook/jvs.h"
|
|
|
|
#include "ferrumhook/network.h"
|
|
|
|
|
|
|
|
#include "amcus/amcus.h"
|
|
|
|
|
|
|
|
#include "hook/process.h"
|
|
|
|
|
|
|
|
#include "hooklib/serial.h"
|
2023-03-13 01:28:40 +01:00
|
|
|
#include "hooklib/debug.h"
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
#include "platform/platform.h"
|
|
|
|
#include "gfxhook/gfx.h"
|
|
|
|
#include "gfxhook/dxgi.h"
|
|
|
|
#include "gfxhook/d3d11.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static HMODULE ferrum_hook_mod;
|
|
|
|
static process_entry_t ferrum_startup;
|
|
|
|
static struct ferrum_hook_config ferrum_hook_cfg;
|
|
|
|
|
|
|
|
static DWORD CALLBACK ferrum_pre_startup(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
dprintf("--- Begin ferrum_pre_startup ---\n");
|
|
|
|
|
|
|
|
ferrum_hook_config_load(&ferrum_hook_cfg, L".\\bananatools.ini");
|
|
|
|
|
|
|
|
serial_hook_init();
|
|
|
|
|
2023-01-26 03:09:38 +01:00
|
|
|
struct dongle_info dinfo;
|
|
|
|
dinfo.vid = 2970;
|
|
|
|
dinfo.pid = 3088;
|
2023-03-10 08:46:37 +01:00
|
|
|
wcscpy_s(dinfo.manufacturer, _countof(L"BM"), L"BM");
|
|
|
|
wcscpy_s(dinfo.product, _countof(L"RUDI04GBN-274713"), L"RUDI04GBN-274713");
|
2023-01-26 03:09:38 +01:00
|
|
|
|
|
|
|
hr = platform_hook_init(&ferrum_hook_cfg.platform, PLATFORM_ES3, ferrum_jvs_init, ferrum_hook_mod, dinfo);
|
2023-01-03 05:35:53 +01:00
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ferrum_dll_init(&ferrum_hook_cfg.dll, ferrum_hook_mod);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = ferrum_xinput_init(&ferrum_hook_cfg.xinput);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = amcus_hook_init(&ferrum_hook_cfg.amcus);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = network_hook_init(&ferrum_hook_cfg.network);
|
|
|
|
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
ExitProcess(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2023-03-13 01:28:40 +01:00
|
|
|
debug_hook_init();
|
|
|
|
|
2023-01-03 05:35:53 +01:00
|
|
|
gfx_hook_init(&ferrum_hook_cfg.gfx);
|
|
|
|
gfx_d3d11_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
|
|
|
gfx_dxgi_hook_init(&ferrum_hook_cfg.gfx, ferrum_hook_mod);
|
|
|
|
|
|
|
|
dprintf("--- End ferrum_pre_startup ---\n");
|
|
|
|
|
|
|
|
return ferrum_startup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HMODULE mod, DWORD cause, void *ctx)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (cause != DLL_PROCESS_ATTACH) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ferrum_hook_mod = mod;
|
|
|
|
|
|
|
|
hr = process_hijack_startup(ferrum_pre_startup, &ferrum_startup);
|
|
|
|
|
|
|
|
if (!SUCCEEDED(hr)) {
|
|
|
|
dprintf("Failed to hijack process startup: %x\n", (int) hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCEEDED(hr);
|
2023-01-04 20:25:21 +01:00
|
|
|
}
|