diff --git a/Module.mk b/Module.mk
index 7ae9050..05800ca 100644
--- a/Module.mk
+++ b/Module.mk
@@ -430,10 +430,6 @@ $(zipdir)/iidx-21-to-24.zip: \
dist/iidx/gamestart-22.bat \
dist/iidx/gamestart-23.bat \
dist/iidx/gamestart-24.bat \
- dist/iidx/iidxhook-21.conf \
- dist/iidx/iidxhook-22.conf \
- dist/iidx/iidxhook-23.conf \
- dist/iidx/iidxhook-24.conf \
dist/iidx/launcher-21.xml \
dist/iidx/launcher-22.xml \
dist/iidx/launcher-23.xml \
diff --git a/dist/iidx/gamestart-21.bat b/dist/iidx/gamestart-21.bat
index a3e30f0..05bad2d 100755
--- a/dist/iidx/gamestart-21.bat
+++ b/dist/iidx/gamestart-21.bat
@@ -48,5 +48,4 @@ cd /d %CONTENT_DIR%
%BEMANITOOLS_DIR%\launcher.exe^
%BEMANITOOLS_DIR%\launcher-21.xml^
- --config %BEMANITOOLS_DIR%\iidxhook-21.conf^
%*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-22.bat b/dist/iidx/gamestart-22.bat
index f98a924..2ebb529 100755
--- a/dist/iidx/gamestart-22.bat
+++ b/dist/iidx/gamestart-22.bat
@@ -48,5 +48,4 @@ cd /d %CONTENT_DIR%
%BEMANITOOLS_DIR%\launcher.exe^
%BEMANITOOLS_DIR%\launcher-22.xml^
- --config %BEMANITOOLS_DIR%\iidxhook-22.conf^
%*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-23.bat b/dist/iidx/gamestart-23.bat
index d177566..06821d9 100755
--- a/dist/iidx/gamestart-23.bat
+++ b/dist/iidx/gamestart-23.bat
@@ -48,5 +48,4 @@ cd /d %CONTENT_DIR%
%BEMANITOOLS_DIR%\launcher.exe^
%BEMANITOOLS_DIR%\launcher-23.xml^
- --config %BEMANITOOLS_DIR%\iidxhook-23.conf^
%*
\ No newline at end of file
diff --git a/dist/iidx/gamestart-24.bat b/dist/iidx/gamestart-24.bat
index 81e220c..2e23695 100755
--- a/dist/iidx/gamestart-24.bat
+++ b/dist/iidx/gamestart-24.bat
@@ -48,5 +48,4 @@ cd /d %CONTENT_DIR%
%BEMANITOOLS_DIR%\launcher.exe^
%BEMANITOOLS_DIR%\launcher-24.xml^
- --config %BEMANITOOLS_DIR%\iidxhook-24.conf^
%*
\ No newline at end of file
diff --git a/dist/iidx/iidxhook-21.conf b/dist/iidx/iidxhook-21.conf
deleted file mode 100755
index d5ed89e..0000000
--- a/dist/iidx/iidxhook-21.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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
-
-# 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
-
-# Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted/wavepass readers)
-io.disable_card_reader_emu=false
-
-# Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware
-io.disable_io_emu=false
\ No newline at end of file
diff --git a/dist/iidx/iidxhook-22.conf b/dist/iidx/iidxhook-22.conf
deleted file mode 100755
index d5ed89e..0000000
--- a/dist/iidx/iidxhook-22.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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
-
-# 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
-
-# Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted/wavepass readers)
-io.disable_card_reader_emu=false
-
-# Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware
-io.disable_io_emu=false
\ No newline at end of file
diff --git a/dist/iidx/iidxhook-23.conf b/dist/iidx/iidxhook-23.conf
deleted file mode 100755
index d5ed89e..0000000
--- a/dist/iidx/iidxhook-23.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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
-
-# 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
-
-# Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted/wavepass readers)
-io.disable_card_reader_emu=false
-
-# Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware
-io.disable_io_emu=false
\ No newline at end of file
diff --git a/dist/iidx/iidxhook-24.conf b/dist/iidx/iidxhook-24.conf
deleted file mode 100755
index d5ed89e..0000000
--- a/dist/iidx/iidxhook-24.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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
-
-# 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
-
-# Disable card reader emulation and enable usage of real card reader hardware on COM1 (for games supporting slotted/wavepass readers)
-io.disable_card_reader_emu=false
-
-# Disable ezusb IO emulation and enable usage of real ezusb1/2 IO hardware
-io.disable_io_emu=false
\ No newline at end of file
diff --git a/dist/iidx/launcher-21.xml b/dist/iidx/launcher-21.xml
index beb6458..92df834 100644
--- a/dist/iidx/launcher-21.xml
+++ b/dist/iidx/launcher-21.xml
@@ -68,6 +68,37 @@
iidxhook7.dll
+
+
+
+ -1
+
+ -1
+
+ 0.0
+
+ 1002
+ 7146
+
+
+ 1
+ 1
+
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+ none
+
+
+
+ 0
+ 0
+
diff --git a/dist/iidx/launcher-22.xml b/dist/iidx/launcher-22.xml
index beb6458..92df834 100644
--- a/dist/iidx/launcher-22.xml
+++ b/dist/iidx/launcher-22.xml
@@ -68,6 +68,37 @@
iidxhook7.dll
+
+
+
+ -1
+
+ -1
+
+ 0.0
+
+ 1002
+ 7146
+
+
+ 1
+ 1
+
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+ none
+
+
+
+ 0
+ 0
+
diff --git a/dist/iidx/launcher-23.xml b/dist/iidx/launcher-23.xml
index beb6458..92df834 100644
--- a/dist/iidx/launcher-23.xml
+++ b/dist/iidx/launcher-23.xml
@@ -68,6 +68,37 @@
iidxhook7.dll
+
+
+
+ -1
+
+ -1
+
+ 0.0
+
+ 1002
+ 7146
+
+
+ 1
+ 1
+
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+ none
+
+
+
+ 0
+ 0
+
diff --git a/dist/iidx/launcher-24.xml b/dist/iidx/launcher-24.xml
index beb6458..92df834 100644
--- a/dist/iidx/launcher-24.xml
+++ b/dist/iidx/launcher-24.xml
@@ -68,6 +68,37 @@
iidxhook7.dll
+
+
+
+ -1
+
+ -1
+
+ 0.0
+
+ 1002
+ 7146
+
+
+ 1
+ 1
+
+ 0
+ 0
+
+
+
+ 0
+ 0
+
+ none
+
+
+
+ 0
+ 0
+
diff --git a/src/main/iidxhook7/Module.mk b/src/main/iidxhook7/Module.mk
index f086078..5bad45c 100644
--- a/src/main/iidxhook7/Module.mk
+++ b/src/main/iidxhook7/Module.mk
@@ -33,3 +33,4 @@ libs_iidxhook7 := \
src_iidxhook7 := \
dllmain.c \
+ iidxhook7.c \
diff --git a/src/main/iidxhook7/dllmain.c b/src/main/iidxhook7/dllmain.c
index 9c27c15..f8f6588 100644
--- a/src/main/iidxhook7/dllmain.c
+++ b/src/main/iidxhook7/dllmain.c
@@ -1,244 +1,6 @@
#include
-#include
-#include
-#include
-#include
-
-#include "cconfig/cconfig-hook.h"
-
-#include "ezusb-iidx-emu/nodes.h"
-
-#include "ezusb2-emu/desc.h"
-#include "ezusb2-emu/device.h"
-
-#include "ezusb2-iidx-emu/msg.h"
-
-#include "hook/d3d9.h"
-
-#include "hooklib/acp.h"
-#include "hooklib/adapter.h"
-#include "hooklib/rs232.h"
-#include "hooklib/setupapi.h"
-
-#include "iface-core/log.h"
-#include "iface-core/thread.h"
-
-#include "iface-io/eam.h"
-#include "iface-io/iidx.h"
-
-#include "iidxhook-d3d9/bb-scale-hd.h"
-
-#include "iidxhook-util/acio.h"
-#include "iidxhook-util/config-gfx.h"
-#include "iidxhook-util/config-io.h"
-#include "iidxhook-util/d3d9.h"
-
-#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 "util/str.h"
-
-#define IIDXHOOK7_INFO_HEADER \
- "iidxhook for SPADA, PENDUAL, copula and SINOBUZ" \
- ", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
-#define IIDXHOOK7_CMD_USAGE \
- "Usage: launcher.exe -K iidxhook7.dll [options...]"
-
-static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
- iidxhook_d3d9_bb_scale_hd_d3d9_irp_handler,
- iidxhook_util_d3d9_irp_handler,
-};
-
-static struct iidxhook_config_io config_io;
-static module_io_t *iidxhook_module_io_iidx;
-static module_io_t *iidxhook_module_io_eam;
-
-static void _iidxhook7_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 _iidxhook7_io_eam_init(module_io_t **module)
-{
- bt_io_eam_api_t api;
-
- module_io_ext_load_and_init(
- "eamio.dll", "bt_module_io_eam_api_get", module);
- module_io_api_get(*module, &api);
- bt_io_eam_api_set(&api);
-}
-
-static void
-iidxhook7_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.forced_refresh_rate = config_gfx->forced_refresh_rate;
- d3d9_config.device_adapter = config_gfx->device_adapter;
-
- iidxhook_util_d3d9_configure(&d3d9_config);
-
- // The "old"/current scaling feature does not work with 20-26 because
- // the render engine changed and provides its own built-in scaling feature
- if (config_gfx->scale_back_buffer_width > 0 &&
- config_gfx->scale_back_buffer_height > 0) {
- iidxhook_d3d9_bb_scale_hd_init(
- config_gfx->scale_back_buffer_width,
- config_gfx->scale_back_buffer_height);
- }
-
- hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
-}
-
-static bool
-_iidxhook7_main_init(HMODULE game_module, const bt_core_config_t *config_)
-{
- struct cconfig *config;
-
- struct iidxhook_config_gfx config_gfx;
-
- log_info("-------------------------------------------------------------");
- log_info("--------------- Begin iidxhook dll_entry_init ---------------");
- log_info("-------------------------------------------------------------");
-
- config = cconfig_init();
-
- iidxhook_config_gfx_init(config);
- iidxhook_config_io_init(config);
-
- if (!cconfig_hook_config_init(
- config,
- IIDXHOOK7_INFO_HEADER "\n" IIDXHOOK7_CMD_USAGE,
- CCONFIG_CMD_USAGE_OUT_DBG)) {
- cconfig_finit(config);
-
- exit(EXIT_FAILURE);
- }
-
- iidxhook_config_gfx_get(&config_gfx, config);
- iidxhook_config_io_get(&config_io, config);
-
- cconfig_finit(config);
-
- log_info(IIDXHOOK7_INFO_HEADER);
- log_info("Initializing iidxhook...");
-
- acp_hook_init();
- adapter_hook_init();
-
- iidxhook7_setup_d3d9_hooks(&config_gfx);
-
- if (!config_io.disable_io_emu) {
- log_info("Starting IIDX IO backend");
-
- _iidxhook7_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");
- }
-
- if (!config_io.disable_card_reader_emu) {
- log_misc("Initializing card reader backend");
-
- _iidxhook7_io_eam_init(&iidxhook_module_io_eam);
-
- if (!bt_io_eam_init()) {
- log_fatal("Initializing card reader backend failed");
- }
- } else {
- log_info("Card reader emulation backend disabled");
- }
-
- /* iohooks are okay, even if emu is diabled since the fake handlers won't be
- * used */
- /* 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_acio_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());
- }
-
- /* Card reader emulation, same issue with hooking as IO emulation */
- rs232_hook_init();
-
- if (!config_io.disable_card_reader_emu) {
- /* Do not use legacy mode, wave pass readers */
- iidxhook_util_acio_init(false);
- }
-
- log_info("-------------------------------------------------------------");
- log_info("---------------- End iidxhook dll_entry_init ----------------");
- log_info("-------------------------------------------------------------");
-
- return true;
-}
-
-static void _iidxhook7_main_fini()
-{
- if (!config_io.disable_card_reader_emu) {
- log_misc("Shutting down card reader backend");
- bt_io_eam_fini();
-
- bt_io_eam_api_clear();
- module_io_free(&iidxhook_module_io_eam);
- }
-
- if (!config_io.disable_io_emu) {
- log_misc("Shutting down IIDX IO backend");
- bt_io_iidx_fini();
-
- bt_io_iidx_api_clear();
- module_io_free(&iidxhook_module_io_iidx);
- }
-}
-
-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 = _iidxhook7_main_init;
- api->v1.main_fini = _iidxhook7_main_fini;
-}
-
-/**
- * Hook library for SPADA, PENDUAL, copula and SINOBUZ
- */
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
return TRUE;
-}
+}
\ No newline at end of file
diff --git a/src/main/iidxhook7/iidxhook7.c b/src/main/iidxhook7/iidxhook7.c
new file mode 100644
index 0000000..ff4bc1e
--- /dev/null
+++ b/src/main/iidxhook7/iidxhook7.c
@@ -0,0 +1,211 @@
+#define LOG_MODULE "iidxhook7"
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "ezusb-iidx-emu/nodes.h"
+
+#include "ezusb2-emu/desc.h"
+#include "ezusb2-emu/device.h"
+
+#include "ezusb2-iidx-emu/msg.h"
+
+#include "hook/d3d9.h"
+
+#include "hooklib/acp.h"
+#include "hooklib/adapter.h"
+#include "hooklib/rs232.h"
+#include "hooklib/setupapi.h"
+
+#include "iface-core/config.h"
+#include "iface-core/log.h"
+#include "iface-core/thread.h"
+
+#include "iface-io/eam.h"
+#include "iface-io/iidx.h"
+
+#include "iidxhook-d3d9/bb-scale-hd.h"
+
+#include "iidxhook-util/acio.h"
+#include "iidxhook-util/config-gfx.h"
+#include "iidxhook-util/config-io.h"
+#include "iidxhook-util/d3d9.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 "util/str.h"
+
+static const hook_d3d9_irp_handler_t iidxhook_d3d9_handlers[] = {
+ iidxhook_d3d9_bb_scale_hd_d3d9_irp_handler,
+ iidxhook_util_d3d9_irp_handler,
+};
+
+static struct iidxhook_config_io config_io;
+static module_io_t *iidxhook_module_io_iidx;
+static module_io_t *iidxhook_module_io_eam;
+
+static void _iidxhook7_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 _iidxhook7_io_eam_init(module_io_t **module)
+{
+ bt_io_eam_api_t api;
+
+ module_io_ext_load_and_init(
+ "eamio.dll", "bt_module_io_eam_api_get", module);
+ module_io_api_get(*module, &api);
+ bt_io_eam_api_set(&api);
+}
+
+static void
+iidxhook7_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.forced_refresh_rate = config_gfx->forced_refresh_rate;
+ d3d9_config.device_adapter = config_gfx->device_adapter;
+
+ iidxhook_util_d3d9_configure(&d3d9_config);
+
+ // The "old"/current scaling feature does not work with 20-26 because
+ // the render engine changed and provides its own built-in scaling feature
+ if (config_gfx->scale_back_buffer_width > 0 &&
+ config_gfx->scale_back_buffer_height > 0) {
+ iidxhook_d3d9_bb_scale_hd_init(
+ config_gfx->scale_back_buffer_width,
+ config_gfx->scale_back_buffer_height);
+ }
+
+ hook_d3d9_init(iidxhook_d3d9_handlers, lengthof(iidxhook_d3d9_handlers));
+}
+
+static bool
+_iidxhook7_main_init(HMODULE game_module, const bt_core_config_t *config)
+{
+ iidxhook_config_gfx_t config_gfx;
+
+ log_info("iidxhook for SPADA, PENDUAL, copula and SINOBUZ");
+ log_info("build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV));
+
+ iidxhook_util_config_gfx_get2(config, &config_gfx);
+ iidxhook_util_config_io_get2(config, &config_io);
+
+ acp_hook_init();
+ adapter_hook_init();
+
+ iidxhook7_setup_d3d9_hooks(&config_gfx);
+
+ if (!config_io.disable_io_emu) {
+ log_info("Starting IIDX IO backend");
+
+ _iidxhook7_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");
+ }
+
+ if (!config_io.disable_card_reader_emu) {
+ log_misc("Initializing card reader backend");
+
+ _iidxhook7_io_eam_init(&iidxhook_module_io_eam);
+
+ if (!bt_io_eam_init()) {
+ log_fatal("Initializing card reader backend failed");
+ }
+ } else {
+ log_info("Card reader emulation backend disabled");
+ }
+
+ /* iohooks are okay, even if emu is diabled since the fake handlers won't be
+ * used */
+ /* 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_acio_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());
+ }
+
+ /* Card reader emulation, same issue with hooking as IO emulation */
+ rs232_hook_init();
+
+ if (!config_io.disable_card_reader_emu) {
+ /* Do not use legacy mode, wave pass readers */
+ iidxhook_util_acio_init(false);
+ }
+
+ return true;
+}
+
+static void _iidxhook7_main_fini()
+{
+ if (!config_io.disable_card_reader_emu) {
+ log_misc("Shutting down card reader backend");
+ bt_io_eam_fini();
+
+ bt_io_eam_api_clear();
+ module_io_free(&iidxhook_module_io_eam);
+ }
+
+ if (!config_io.disable_io_emu) {
+ log_misc("Shutting down IIDX IO backend");
+ bt_io_iidx_fini();
+
+ bt_io_iidx_api_clear();
+ module_io_free(&iidxhook_module_io_iidx);
+ }
+}
+
+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 = _iidxhook7_main_init;
+ api->v1.main_fini = _iidxhook7_main_fini;
+}
diff --git a/src/main/iidxhook7/iidxhook7.def b/src/main/iidxhook7/iidxhook7.def
index 46f472b..40ce412 100644
--- a/src/main/iidxhook7/iidxhook7.def
+++ b/src/main/iidxhook7/iidxhook7.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/iidxhook7/iidxhook7.h b/src/main/iidxhook7/iidxhook7.h
new file mode 100644
index 0000000..34377d8
--- /dev/null
+++ b/src/main/iidxhook7/iidxhook7.h
@@ -0,0 +1,9 @@
+#ifndef IIDXHOOK7_H
+#define IIDXHOOK7_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