diff --git a/Module.mk b/Module.mk
index ff2a58a..dc2cc42 100644
--- a/Module.mk
+++ b/Module.mk
@@ -358,7 +358,7 @@ $(zipdir)/iidx-18-cn.zip: \
build/bin/indep-32/inject.exe \
dist/iidx/config.bat \
dist/iidx/gamestart-18-cn.bat \
- dist/iidx/iidxhook-18-cn.conf \
+ dist/iidx/inject-18-cn.xml \
dist/iidx/vefx.txt \
| $(zipdir)/
$(V)echo ... $@
diff --git a/dist/iidx/gamestart-18-cn.bat b/dist/iidx/gamestart-18-cn.bat
index 1c82bfb..e9b5612 100644
--- a/dist/iidx/gamestart-18-cn.bat
+++ b/dist/iidx/gamestart-18-cn.bat
@@ -57,8 +57,5 @@ if not exist dev\nvram mkdir dev\nvram
if not exist dev\raw mkdir dev\raw
%BEMANITOOLS_DIR%\inject.exe^
- %BEMANITOOLS_DIR%\iidxhook4-cn.dll^
- %REVISION_DIR%\bm2dx.exe^
- -D^
- --config %BEMANITOOLS_DIR%\iidxhook-18-cn.conf^
+ %BEMANITOOLS_DIR%\inject-18-cn.xml^
%*
diff --git a/dist/iidx/iidxhook-18-cn.conf b/dist/iidx/iidxhook-18-cn.conf
deleted file mode 100644
index 10bb802..0000000
--- a/dist/iidx/iidxhook-18-cn.conf
+++ /dev/null
@@ -1,50 +0,0 @@
-# PCBID
-eamuse.pcbid=0101020304050607086F
-
-# Run the game in a framed window (requires windowed option)
-gfx.framed=false
-
-# Software limit the frame rate of the rendering loop in hz, e.g. 60 or 59.95 (0.0 = no software limit)
-gfx.frame_rate_limit=0.0
-
-# Enable/disable software monitor check/auto timebase or set a pre-determined refresh value. -1 disables this feature. 0 enables auto detecting the current refresh rate on startup. Setting any positive value > 0 allows you to set a pre-determined refresh rate (e.g. retrieved from the monitor check on newer IIDX games). Either the auto detected value or pre-determined value is used to patch any chart files in-memory to fix song synchronization issues. Requires constant refresh rate!!!
-gfx.monitor_check=-1.000000
-
-# Patch the GPU device ID detection (leave empty to disable), format XXXX:YYYY, two 4 digit hex numbers (vid:pid). Examples: 1002:7146 (RV515, Radeon X1300), 1002:95C5 (RV620 LE, Radeon HD3450)
-gfx.pci_id=1002:7146
-
-# Run the game windowed
-gfx.windowed=false
-
-# Windowed width, 0 for default size
-gfx.window_width=0
-
-# Windowed height, 0 for default size
-gfx.window_height=0
-
-# Up-/downscale the back buffer's width. This does not change the game's rendering resolution but scales the final frame. Use this to target the native resolution of your monitor/TV, e.g. to avoid over-/underscan, bad image quality or latency caused by the monitors internal upscaler. 0 to disable this feature. Must be set in combination with the corresponding height parameter.
-gfx.scale_back_buffer_width=0
-
-# Up-/downscale the back buffer's height. This does not change the game's rendering resolution but scales the final frame. Use this to target the native resolution of your monitor/TV, e.g. to avoid over-/underscan, bad image quality or latency caused by the monitors internal upscaler. 0 to disable this feature. Must be set in combination with the corresponding width parameter.
-gfx.scale_back_buffer_height=0
-
-# Filter type to use for up-/downscaling the back buffer. Only used if scaling feature was enabled by setting the scaling width and height parameters. Available types: none, linear, point (refer to D3DTEXTUREFILTERTYPE for explanation).
-gfx.scale_back_buffer_filter=none
-
-# Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)
-gfx.forced_refresh_rate=-1
-
-# D3D9 device adapter (monitor), -1 to use default, 0, 1, 2 etc. to use specified adapter
-gfx.device_adapter=-1
-
-# Fix diagonal tearing with video cards other than Radeon X1300 and HD3450
-gfx.diagonal_tearing_fix=false
-
-# Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware
-io.disable_io_emu=false
-
-# Path to store the settings, e.g. bookkeeping, operator settings. d:, e: and f: drive configuration/settings data
-misc.settings_path=.\
-
-# Security black plug mcode id string (e.g. GQC02JAA).
-sec.black_plug_mcode=GKJDZCAA
diff --git a/dist/iidx/inject-18-cn.xml b/dist/iidx/inject-18-cn.xml
new file mode 100644
index 0000000..10e3fa0
--- /dev/null
+++ b/dist/iidx/inject-18-cn.xml
@@ -0,0 +1,97 @@
+
+
+ 1
+
+
+ bm2dx.exe
+
+
+ inject
+
+
+
+ 1
+ iidxhook4-cn.dll
+
+
+
+ 0101020304050607086F
+
+
+
+
+ -1
+
+ -1
+
+ 0.0
+
+ 1002
+ 7146
+
+
+ 1
+ 1
+
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+ none
+
+
+
+ -1.000000
+
+ 0
+
+
+
+
+ GKJDZCAA
+
+
+
+ 0
+
+
+
+ .\
+ 1
+
+
+
+
+
+
+ 1
+ misc
+ 8192
+
+
+ 0
+ 64
+ discard_new
+
+
+ 1
+ 1
+
+
+ 1
+ inject.log
+ 0
+ 0
+ 1
+
+
+
+
+ 1
+ 0
+
+
\ No newline at end of file
diff --git a/src/main/iidxhook4-cn/Module.mk b/src/main/iidxhook4-cn/Module.mk
index 5448bd4..ea120fa 100644
--- a/src/main/iidxhook4-cn/Module.mk
+++ b/src/main/iidxhook4-cn/Module.mk
@@ -3,6 +3,7 @@ avsdlls += iidxhook4-cn
ldflags_iidxhook4-cn := \
-liphlpapi \
-lws2_32 \
+ -lshlwapi \
deplibs_iidxhook4-cn := \
avs \
@@ -29,8 +30,10 @@ libs_iidxhook4-cn := \
module \
util \
mxml \
+ sdk-hook \
src_iidxhook4-cn := \
avs-boot.c \
- path.c \
dllmain.c \
+ iidxhook4-cn.c \
+ path.c \
diff --git a/src/main/iidxhook4-cn/dllmain.c b/src/main/iidxhook4-cn/dllmain.c
index c779399..e824e94 100644
--- a/src/main/iidxhook4-cn/dllmain.c
+++ b/src/main/iidxhook4-cn/dllmain.c
@@ -1,248 +1,70 @@
#include
-#include
-#include
-#include
-#include
-
-#include "cconfig/cconfig-hook.h"
-
-#include "core/log-bt-ext.h"
-#include "core/log-bt.h"
-#include "core/log-sink-debug.h"
-
-#include "ezusb-emu/node-security-plug.h"
-
-#include "ezusb2-emu/desc.h"
-#include "ezusb2-emu/device.h"
-
-#include "ezusb2-iidx-emu/msg.h"
-
#include "hook/table.h"
-#include "hooklib/acp.h"
-#include "hooklib/setupapi.h"
+#include "iidxhook4-cn/iidxhook4-cn.h"
-#include "iface-core/log.h"
-#include "iface-core/thread.h"
+#include "main/sdk-hook/dllentry.h"
-#include "iface-io/iidx.h"
+#include "util/defs.h"
-#include "iidxhook4-cn/avs-boot.h"
-#include "iidxhook4-cn/path.h"
+static HANDLE STDCALL _iidxhook4_cn_dllmain_my_OpenProcess(DWORD, BOOL, DWORD);
+static HANDLE(STDCALL *_iidxhook4_cn_dllmain_real_OpenProcess)(DWORD, BOOL, DWORD);
-#include "iidxhook-util/chart-patch.h"
-#include "iidxhook-util/config-eamuse.h"
-#include "iidxhook-util/config-gfx.h"
-#include "iidxhook-util/config-io.h"
-#include "iidxhook-util/config-misc.h"
-#include "iidxhook-util/config-sec.h"
-#include "iidxhook-util/d3d9.h"
-#include "iidxhook-util/settings.h"
+static bool _iidxhook4_cn_dllmain_openprocess_call_check;
-#include "module/io-ext.h"
-#include "module/io.h"
-
-#include "sdk/module/core/log.h"
-#include "sdk/module/core/thread.h"
-#include "sdk/module/hook.h"
-
-#include "security/rp-sign-key.h"
-
-#define IIDXHOOK4_CN_INFO_HEADER \
- "iidxhook for Resort Anthem CN" \
- ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
-#define IIDXHOOK4_CN_CMD_USAGE \
- "Usage: inject.exe iidxhook4-cn.dll [options...]"
-
-static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
- iidxhook_util_d3d9_irp_handler,
+static const struct hook_symbol _iidxhook4_cn_dllmain_hook_syms[] = {
+ {
+ .name = "OpenProcess",
+ .patch = _iidxhook4_cn_dllmain_my_OpenProcess,
+ .link = (void **) &_iidxhook4_cn_dllmain_real_OpenProcess,
+ },
};
-static struct iidxhook_config_io config_io;
-static module_io_t *iidxhook_module_io_iidx;
-
-static void _iidxhook4_cn_io_iidx_init(module_io_t **module)
+static HANDLE STDCALL
+_iidxhook4_cn_dllmain_my_OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId)
{
- bt_io_iidx_api_t api;
-
- module_io_ext_load_and_init(
- "iidxio.dll", "bt_module_io_iidx_api_get", module);
- module_io_api_get(*module, &api);
- bt_io_iidx_api_set(&api);
-}
-
-static void
-iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
-{
- struct iidxhook_util_d3d9_config d3d9_config;
-
- iidxhook_util_d3d9_init_config(&d3d9_config);
-
- d3d9_config.windowed = config_gfx->windowed;
- d3d9_config.framed = config_gfx->framed;
- d3d9_config.override_window_width = config_gfx->window_width;
- d3d9_config.override_window_height = config_gfx->window_height;
- d3d9_config.framerate_limit = config_gfx->frame_rate_limit;
- d3d9_config.pci_vid = config_gfx->pci_id_vid;
- d3d9_config.pci_pid = config_gfx->pci_id_pid;
- d3d9_config.scale_back_buffer_width = config_gfx->scale_back_buffer_width;
- d3d9_config.scale_back_buffer_height = config_gfx->scale_back_buffer_height;
- d3d9_config.scale_back_buffer_filter = config_gfx->scale_back_buffer_filter;
- d3d9_config.forced_refresh_rate = config_gfx->forced_refresh_rate;
- d3d9_config.device_adapter = config_gfx->device_adapter;
- d3d9_config.iidx18_and_19_diagonal_tearing_fix =
- config_gfx->diagonal_tearing_fix;
- d3d9_config.iidx14_to_19_nvidia_fix = true;
- d3d9_config.iidx18_and_19_diagonal_tearing_fix =
- config_gfx->diagonal_tearing_fix;
-
- if (config_gfx->monitor_check == 0) {
- log_info("Auto monitor check enabled");
-
- d3d9_config.iidx09_to_19_monitor_check_cb =
- iidxhook_util_chart_patch_set_refresh_rate;
- iidxhook_util_chart_patch_init(
- IIDXHOOK_UTIL_CHART_PATCH_TIMEBASE_14_TO_19_VGA);
- } else if (config_gfx->monitor_check > 0) {
- log_info(
- "Manual monitor check, resulting refresh rate: %f",
- config_gfx->monitor_check);
-
- iidxhook_util_chart_patch_init(
- IIDXHOOK_UTIL_CHART_PATCH_TIMEBASE_14_TO_19_VGA);
- iidxhook_util_chart_patch_set_refresh_rate(config_gfx->monitor_check);
+ if (_iidxhook4_cn_dllmain_openprocess_call_check) {
+ return _iidxhook4_cn_dllmain_real_OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
}
- iidxhook_util_d3d9_configure(&d3d9_config);
+ _iidxhook4_cn_dllmain_openprocess_call_check = true;
- hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
+ bt_hook_dllentry_main_init();
+
+ return _iidxhook4_cn_dllmain_real_OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
}
-static bool
-_iidxhook4_cn_main_init(HMODULE game_module, const bt_core_config_t *config_)
-{
- struct cconfig *config;
+// TODO find another call right before main exits to hook cleanup and stuff with
+// bt_hook_dllentry_main_fini()
- struct iidxhook_util_config_eamuse config_eamuse;
- struct iidxhook_config_gfx config_gfx;
- struct iidxhook_config_sec config_sec;
- struct iidxhook_config_misc config_misc;
-
- log_info("-------------------------------------------------------------");
- log_info("--------------- Begin iidxhook my_OpenProcess ---------------");
- log_info("-------------------------------------------------------------");
-
- config = cconfig_init();
-
- iidxhook_util_config_eamuse_init(config);
- iidxhook_config_gfx_init(config);
- iidxhook_config_io_init(config);
- iidxhook_config_sec_init(config);
- iidxhook_config_misc_init(config);
-
- if (!cconfig_hook_config_init(
- config,
- IIDXHOOK4_CN_INFO_HEADER "\n" IIDXHOOK4_CN_CMD_USAGE,
- CCONFIG_CMD_USAGE_OUT_DBG)) {
- cconfig_finit(config);
- exit(EXIT_FAILURE);
- }
-
- iidxhook_util_config_eamuse_get(&config_eamuse, config);
- iidxhook_config_gfx_get(&config_gfx, config);
- iidxhook_config_io_get(&config_io, config);
- iidxhook_config_sec_get(&config_sec, config);
- iidxhook_config_misc_get(&config_misc, config);
-
- cconfig_finit(config);
-
- log_info(IIDXHOOK4_CN_INFO_HEADER);
- log_info("Initializing iidxhook...");
-
- iidxhook4_cn_path_init();
- iidxhook4_cn_avs_boot_init();
- acp_hook_init();
- settings_hook_init();
-
- /**
- * This game is using a black round plug for game license management instead
- * of a black usb dongle. No white dongle hooks applies since the game does
- * not have network functionality. Also, card readers are not used/checked;
- * no card reader hooks required.
- */
- ezusb_iidx_emu_node_security_plug_set_boot_version(
- &config_sec.boot_version);
- ezusb_iidx_emu_node_security_plug_set_boot_seeds(config_sec.boot_seeds);
- ezusb_iidx_emu_node_security_plug_set_plug_black_sign_key(
- &security_rp_sign_key_black_iidx);
- ezusb_iidx_emu_node_security_plug_set_plug_black_mcode(
- &config_sec.black_plug_mcode);
- ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
-
- iidxhook4_cn_setup_d3d9_hooks(&config_gfx);
-
- if (strlen(config_misc.settings_path) > 0) {
- settings_hook_set_path(config_misc.settings_path);
- }
-
- if (!config_io.disable_io_emu) {
- log_info("Starting IIDX IO backend");
-
- _iidxhook4_cn_io_iidx_init(&iidxhook_module_io_iidx);
-
- if (!bt_io_iidx_init()) {
- log_fatal("Initializing IIDX IO backend failed");
- }
- } else {
- log_info("IIDX IO emulation backend disabled");
- }
-
- /* Set up IO emulation hooks _after_ IO API setup to allow
- API implementations with real IO devices */
- iohook_push_handler(ezusb2_emu_device_dispatch_irp);
- iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
- iohook_push_handler(settings_hook_dispatch_irp);
-
- if (!config_io.disable_io_emu) {
- hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
- ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
- }
-
- log_info("-------------------------------------------------------------");
- log_info("---------------- End iidxhook my_OpenProcess ----------------");
- log_info("-------------------------------------------------------------");
-
- return true;
-}
-
-static void _iidxhook4_cn_main_fini()
-{
- // TODO cleanup initialized stuff
-}
-
-void bt_module_core_log_api_set(const bt_core_log_api_t *api)
-{
- bt_core_log_api_set(api);
-}
-
-void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
-{
- bt_core_thread_api_set(api);
-}
-
-void bt_module_hook_api_get(bt_hook_api_t *api)
-{
- api->version = 1;
-
- api->v1.main_init = _iidxhook4_cn_main_init;
- api->v1.main_fini = _iidxhook4_cn_main_fini;
-}
-
-/**
- * Hook library for Resort Anthem CN
- */
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
+ if (reason == DLL_PROCESS_ATTACH) {
+ bt_hook_dllentry_init(
+ mod,
+ "iidxhook4-cn",
+ bt_module_core_config_api_set,
+ bt_module_core_log_api_set,
+ bt_module_core_thread_api_set,
+ bt_module_hook_api_get);
+
+ _iidxhook4_cn_dllmain_openprocess_call_check = false;
+
+ hook_table_apply(
+ NULL, "kernel32.dll", _iidxhook4_cn_dllmain_hook_syms, lengthof(_iidxhook4_cn_dllmain_hook_syms));
+
+ } else if (reason == DLL_PROCESS_DETACH) {
+ // https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain#remarks
+ if (ctx == NULL) {
+ hook_table_revert(NULL, "kernel32.dll", _iidxhook4_cn_dllmain_hook_syms, lengthof(_iidxhook4_cn_dllmain_hook_syms));
+
+ // Hacky to have this here, should be close/right after application main exits, see TODO above
+ bt_hook_dllentry_main_fini();
+
+ bt_hook_dllentry_fini();
+ }
+ }
+
return TRUE;
-}
+}
\ No newline at end of file
diff --git a/src/main/iidxhook4-cn/iidxhook4-cn.c b/src/main/iidxhook4-cn/iidxhook4-cn.c
new file mode 100644
index 0000000..e1628d6
--- /dev/null
+++ b/src/main/iidxhook4-cn/iidxhook4-cn.c
@@ -0,0 +1,209 @@
+#define LOG_MODULE "iidxhook4-cn"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "ezusb-emu/node-security-plug.h"
+
+#include "ezusb2-emu/desc.h"
+#include "ezusb2-emu/device.h"
+
+#include "ezusb2-iidx-emu/msg.h"
+
+#include "hook/table.h"
+
+#include "hooklib/acp.h"
+#include "hooklib/setupapi.h"
+
+#include "iface-core/config.h"
+#include "iface-core/log.h"
+#include "iface-core/thread.h"
+
+#include "iface-io/iidx.h"
+
+#include "iidxhook4-cn/avs-boot.h"
+#include "iidxhook4-cn/path.h"
+
+#include "iidxhook-util/chart-patch.h"
+#include "iidxhook-util/config-eamuse.h"
+#include "iidxhook-util/config-gfx.h"
+#include "iidxhook-util/config-io.h"
+#include "iidxhook-util/config-misc.h"
+#include "iidxhook-util/config-sec.h"
+#include "iidxhook-util/d3d9.h"
+#include "iidxhook-util/settings.h"
+
+#include "module/io-ext.h"
+#include "module/io.h"
+
+#include "sdk/module/core/config.h"
+#include "sdk/module/core/log.h"
+#include "sdk/module/core/thread.h"
+#include "sdk/module/hook.h"
+
+#include "security/rp-sign-key.h"
+
+static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
+ iidxhook_util_d3d9_irp_handler,
+};
+
+static module_io_t *iidxhook_module_io_iidx;
+
+static void _iidxhook4_cn_io_iidx_init(module_io_t **module)
+{
+ bt_io_iidx_api_t api;
+
+ module_io_ext_load_and_init(
+ "iidxio.dll", "bt_module_io_iidx_api_get", module);
+ module_io_api_get(*module, &api);
+ bt_io_iidx_api_set(&api);
+}
+
+static void
+iidxhook4_cn_setup_d3d9_hooks(const struct iidxhook_config_gfx *config_gfx)
+{
+ struct iidxhook_util_d3d9_config d3d9_config;
+
+ iidxhook_util_d3d9_init_config(&d3d9_config);
+
+ d3d9_config.windowed = config_gfx->windowed;
+ d3d9_config.framed = config_gfx->framed;
+ d3d9_config.override_window_width = config_gfx->window_width;
+ d3d9_config.override_window_height = config_gfx->window_height;
+ d3d9_config.framerate_limit = config_gfx->frame_rate_limit;
+ d3d9_config.pci_vid = config_gfx->pci_id_vid;
+ d3d9_config.pci_pid = config_gfx->pci_id_pid;
+ d3d9_config.scale_back_buffer_width = config_gfx->scale_back_buffer_width;
+ d3d9_config.scale_back_buffer_height = config_gfx->scale_back_buffer_height;
+ d3d9_config.scale_back_buffer_filter = config_gfx->scale_back_buffer_filter;
+ d3d9_config.forced_refresh_rate = config_gfx->forced_refresh_rate;
+ d3d9_config.device_adapter = config_gfx->device_adapter;
+ d3d9_config.iidx18_and_19_diagonal_tearing_fix =
+ config_gfx->diagonal_tearing_fix;
+ d3d9_config.iidx14_to_19_nvidia_fix = true;
+ d3d9_config.iidx18_and_19_diagonal_tearing_fix =
+ config_gfx->diagonal_tearing_fix;
+
+ if (config_gfx->monitor_check == 0) {
+ log_info("Auto monitor check enabled");
+
+ d3d9_config.iidx09_to_19_monitor_check_cb =
+ iidxhook_util_chart_patch_set_refresh_rate;
+ iidxhook_util_chart_patch_init(
+ IIDXHOOK_UTIL_CHART_PATCH_TIMEBASE_14_TO_19_VGA);
+ } else if (config_gfx->monitor_check > 0) {
+ log_info(
+ "Manual monitor check, resulting refresh rate: %f",
+ config_gfx->monitor_check);
+
+ iidxhook_util_chart_patch_init(
+ IIDXHOOK_UTIL_CHART_PATCH_TIMEBASE_14_TO_19_VGA);
+ iidxhook_util_chart_patch_set_refresh_rate(config_gfx->monitor_check);
+ }
+
+ iidxhook_util_d3d9_configure(&d3d9_config);
+
+ hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
+}
+
+static bool
+_iidxhook4_cn_main_init(HMODULE game_module, const bt_core_config_t *config)
+{
+ iidxhook_util_config_eamuse_t config_eamuse;
+ iidxhook_config_gfx_t config_gfx;
+ iidxhook_config_sec_t config_sec;
+ iidxhook_config_misc_t config_misc;
+ iidxhook_config_io_t config_io;
+
+ log_info("iidxhook for Resort Anthem CN");
+ log_info("build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV));
+
+ iidxhook_util_config_eamuse_get2(config, &config_eamuse);
+ iidxhook_util_config_gfx_get2(config, &config_gfx);
+ iidxhook_util_config_sec_get2(config, &config_sec);
+ iidxhook_util_config_misc_get2(config, &config_misc);
+ iidxhook_util_config_io_get2(config, &config_io);
+
+ iidxhook4_cn_path_init();
+ iidxhook4_cn_avs_boot_init();
+ acp_hook_init();
+ settings_hook_init();
+
+ /**
+ * This game is using a black round plug for game license management instead
+ * of a black usb dongle. No white dongle hooks applies since the game does
+ * not have network functionality. Also, card readers are not used/checked;
+ * no card reader hooks required.
+ */
+ ezusb_iidx_emu_node_security_plug_set_boot_version(
+ &config_sec.boot_version);
+ ezusb_iidx_emu_node_security_plug_set_boot_seeds(config_sec.boot_seeds);
+ ezusb_iidx_emu_node_security_plug_set_plug_black_sign_key(
+ &security_rp_sign_key_black_iidx);
+ ezusb_iidx_emu_node_security_plug_set_plug_black_mcode(
+ &config_sec.black_plug_mcode);
+ ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
+
+ iidxhook4_cn_setup_d3d9_hooks(&config_gfx);
+
+ if (strlen(config_misc.settings_path) > 0) {
+ settings_hook_set_path(config_misc.settings_path);
+ }
+
+ if (!config_io.disable_io_emu) {
+ log_info("Starting IIDX IO backend");
+
+ _iidxhook4_cn_io_iidx_init(&iidxhook_module_io_iidx);
+
+ if (!bt_io_iidx_init()) {
+ log_fatal("Initializing IIDX IO backend failed");
+ }
+ } else {
+ log_info("IIDX IO emulation backend disabled");
+ }
+
+ /* Set up IO emulation hooks _after_ IO API setup to allow
+ API implementations with real IO devices */
+ iohook_push_handler(ezusb2_emu_device_dispatch_irp);
+ iohook_push_handler(iidxhook_util_chart_patch_dispatch_irp);
+ iohook_push_handler(settings_hook_dispatch_irp);
+
+ if (!config_io.disable_io_emu) {
+ hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
+ ezusb2_emu_device_hook_init(ezusb2_iidx_emu_msg_init());
+ }
+
+ return true;
+}
+
+static void _iidxhook4_cn_main_fini()
+{
+ // TODO cleanup initialized stuff
+}
+
+void bt_module_core_config_api_set(const bt_core_config_api_t *api)
+{
+ bt_core_config_api_set(api);
+}
+
+void bt_module_core_log_api_set(const bt_core_log_api_t *api)
+{
+ bt_core_log_api_set(api);
+}
+
+void bt_module_core_thread_api_set(const bt_core_thread_api_t *api)
+{
+ bt_core_thread_api_set(api);
+}
+
+void bt_module_hook_api_get(bt_hook_api_t *api)
+{
+ api->version = 1;
+
+ api->v1.main_init = _iidxhook4_cn_main_init;
+ api->v1.main_fini = _iidxhook4_cn_main_fini;
+}
diff --git a/src/main/iidxhook4-cn/iidxhook4-cn.def b/src/main/iidxhook4-cn/iidxhook4-cn.def
index 7d3c005..fa45dd2 100644
--- a/src/main/iidxhook4-cn/iidxhook4-cn.def
+++ b/src/main/iidxhook4-cn/iidxhook4-cn.def
@@ -4,6 +4,7 @@ EXPORTS
DllMain@12 @1 NONAME
; Bemanitools 6 API
+ bt_module_core_config_api_set
bt_module_core_log_api_set
bt_module_core_thread_api_set
bt_module_hook_api_get
\ No newline at end of file
diff --git a/src/main/iidxhook4-cn/iidxhook4-cn.h b/src/main/iidxhook4-cn/iidxhook4-cn.h
new file mode 100644
index 0000000..6f58004
--- /dev/null
+++ b/src/main/iidxhook4-cn/iidxhook4-cn.h
@@ -0,0 +1,9 @@
+#ifndef IIDXHOOK4_CN_H
+#define IIDXHOOK4_CN_H
+
+#include "sdk/module/core/config.h"
+#include "sdk/module/core/log.h"
+#include "sdk/module/core/thread.h"
+#include "sdk/module/hook.h"
+
+#endif
\ No newline at end of file