feat(popnhook1): Use sdk-hook and new config api

Summary:

Test Plan:
This commit is contained in:
icex2 2024-08-17 12:51:00 +02:00
parent 3008a1410d
commit 8a68e563e0
24 changed files with 754 additions and 644 deletions

View File

@ -887,10 +887,10 @@ $(zipdir)/popn-15-to-18.zip: \
dist/popn/gamestart-16.bat \
dist/popn/gamestart-17.bat \
dist/popn/gamestart-18.bat \
dist/popn/popnhook-15.conf \
dist/popn/popnhook-16.conf \
dist/popn/popnhook-17.conf \
dist/popn/popnhook-18.conf \
dist/popn/inject-15.xml \
dist/popn/inject-16.xml \
dist/popn/inject-17.xml \
dist/popn/inject-18.xml \
| $(zipdir)/
$(V)echo ... $@
$(V)zip -j $@ $^

View File

@ -1,7 +1,49 @@
@echo off
:: Keep all vars scoped to this script
setlocal
:: Game doesn't work properly when not run with administrator privileges
>nul 2>&1 net session
if %errorlevel% neq 0 (
echo This script requires administrative privileges.
echo Please run the script as an administrator.
pause
exit 1
)
:: Script expects to be located in a subfolder "bemanitools" in the root folder
:: next to the folders data and prog
cd /d %~dp0
set CONTENT_DIR=%CD%\..
set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
set REVISION_DIR=%CONTENT_DIR%\prog\2007091800
if not exist "%BEMANITOOLS_DIR%" (
echo The bemanitools directory "%BEMANITOOLS_DIR%" does not exist.
pause
exit 1
)
if not exist "%REVISION_DIR%" (
echo The game modules directory "%REVISION_DIR%" does not exist.
pause
exit 1
)
:: Keep that data vanilla, no need to copy these around anymore
:: Just add them to the env PATH so inject can find the libs and game executable
:: Remark: This also requires admin privileges to propage correctly to inject
set PATH=^
%REVISION_DIR%;^
%BEMANITOOLS_DIR%;^
%PATH%
:: Current working dir is the selected game revision root folder
cd /d %REVISION_DIR%
if not exist e\bookkeeping mkdir e\bookkeeping
if not exist e\CONF\NVRAM mkdir e\CONF\NVRAM
if not exist e\CONF\NVRAM\0 mkdir e\CONF\NVRAM\0
@ -12,5 +54,6 @@ if not exist e\CONF\RAW mkdir e\CONF\RAW
if not exist e\settings mkdir e\settings
if not exist e\UP mkdir e\UP
inject popnhook1.dll ezusb.dll=ezusb2-popn-shim.dll popn15.exe --config popnhook-15.conf %*
%BEMANITOOLS_DIR%\inject.exe^
%BEMANITOOLS_DIR%\inject-15.xml^
%*

View File

@ -1,7 +1,49 @@
@echo off
:: Keep all vars scoped to this script
setlocal
:: Game doesn't work properly when not run with administrator privileges
>nul 2>&1 net session
if %errorlevel% neq 0 (
echo This script requires administrative privileges.
echo Please run the script as an administrator.
pause
exit 1
)
:: Script expects to be located in a subfolder "bemanitools" in the root folder
:: next to the folders data and prog
cd /d %~dp0
set CONTENT_DIR=%CD%\..
set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
set REVISION_DIR=%CONTENT_DIR%\prog\2008052700
if not exist "%BEMANITOOLS_DIR%" (
echo The bemanitools directory "%BEMANITOOLS_DIR%" does not exist.
pause
exit 1
)
if not exist "%REVISION_DIR%" (
echo The game modules directory "%REVISION_DIR%" does not exist.
pause
exit 1
)
:: Keep that data vanilla, no need to copy these around anymore
:: Just add them to the env PATH so inject can find the libs and game executable
:: Remark: This also requires admin privileges to propage correctly to inject
set PATH=^
%REVISION_DIR%;^
%BEMANITOOLS_DIR%;^
%PATH%
:: Current working dir is the selected game revision root folder
cd /d %REVISION_DIR%
if not exist e\bookkeeping mkdir e\bookkeeping
if not exist e\CONF\NVRAM mkdir e\CONF\NVRAM
if not exist e\CONF\NVRAM\0 mkdir e\CONF\NVRAM\0
@ -12,5 +54,6 @@ if not exist e\CONF\RAW mkdir e\CONF\RAW
if not exist e\settings mkdir e\settings
if not exist e\UP mkdir e\UP
inject popnhook1.dll ezusb.dll=ezusb2-popn-shim.dll popn16.exe --config popnhook-16.conf %*
%BEMANITOOLS_DIR%\inject.exe^
%BEMANITOOLS_DIR%\inject-16.xml^
%*

View File

@ -1,7 +1,49 @@
@echo off
:: Keep all vars scoped to this script
setlocal
:: Game doesn't work properly when not run with administrator privileges
>nul 2>&1 net session
if %errorlevel% neq 0 (
echo This script requires administrative privileges.
echo Please run the script as an administrator.
pause
exit 1
)
:: Script expects to be located in a subfolder "bemanitools" in the root folder
:: next to the folders data and prog
cd /d %~dp0
set CONTENT_DIR=%CD%\..
set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
set REVISION_DIR=%CONTENT_DIR%\prog\2009022500
if not exist "%BEMANITOOLS_DIR%" (
echo The bemanitools directory "%BEMANITOOLS_DIR%" does not exist.
pause
exit 1
)
if not exist "%REVISION_DIR%" (
echo The game modules directory "%REVISION_DIR%" does not exist.
pause
exit 1
)
:: Keep that data vanilla, no need to copy these around anymore
:: Just add them to the env PATH so inject can find the libs and game executable
:: Remark: This also requires admin privileges to propage correctly to inject
set PATH=^
%REVISION_DIR%;^
%BEMANITOOLS_DIR%;^
%PATH%
:: Current working dir is the selected game revision root folder
cd /d %REVISION_DIR%
if not exist e\bookkeeping mkdir e\bookkeeping
if not exist e\CONF\NVRAM mkdir e\CONF\NVRAM
if not exist e\CONF\NVRAM\0 mkdir e\CONF\NVRAM\0
@ -12,5 +54,6 @@ if not exist e\CONF\RAW mkdir e\CONF\RAW
if not exist e\settings mkdir e\settings
if not exist e\UP mkdir e\UP
inject popnhook1.dll ezusb.dll=ezusb2-popn-shim.dll popn17.exe --config popnhook-17.conf %*
%BEMANITOOLS_DIR%\inject.exe^
%BEMANITOOLS_DIR%\inject-17.xml^
%*

View File

@ -1,7 +1,49 @@
@echo off
:: Keep all vars scoped to this script
setlocal
:: Game doesn't work properly when not run with administrator privileges
>nul 2>&1 net session
if %errorlevel% neq 0 (
echo This script requires administrative privileges.
echo Please run the script as an administrator.
pause
exit 1
)
:: Script expects to be located in a subfolder "bemanitools" in the root folder
:: next to the folders data and prog
cd /d %~dp0
set CONTENT_DIR=%CD%\..
set BEMANITOOLS_DIR=%CONTENT_DIR%\bemanitools
set REVISION_DIR=%CONTENT_DIR%\prog\2010040500
if not exist "%BEMANITOOLS_DIR%" (
echo The bemanitools directory "%BEMANITOOLS_DIR%" does not exist.
pause
exit 1
)
if not exist "%REVISION_DIR%" (
echo The game modules directory "%REVISION_DIR%" does not exist.
pause
exit 1
)
:: Keep that data vanilla, no need to copy these around anymore
:: Just add them to the env PATH so inject can find the libs and game executable
:: Remark: This also requires admin privileges to propage correctly to inject
set PATH=^
%REVISION_DIR%;^
%BEMANITOOLS_DIR%;^
%PATH%
:: Current working dir is the selected game revision root folder
cd /d %REVISION_DIR%
if not exist e\bookkeeping mkdir e\bookkeeping
if not exist e\CONF\NVRAM mkdir e\CONF\NVRAM
if not exist e\CONF\NVRAM\0 mkdir e\CONF\NVRAM\0
@ -12,5 +54,6 @@ if not exist e\CONF\RAW mkdir e\CONF\RAW
if not exist e\settings mkdir e\settings
if not exist e\UP mkdir e\UP
inject popnhook1.dll ezusb.dll=ezusb2-popn-shim.dll popn18.exe --config popnhook-18.conf %*
%BEMANITOOLS_DIR%\inject.exe^
%BEMANITOOLS_DIR%\inject-18.xml^
%*

68
dist/popn/inject-15.xml vendored Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="Shift-JIS"?>
<inject>
<version __type="u32">1</version>
<debugger>
<app>
<path __type="str">popn15.exe</path>
<args __type="str"></args>
</app>
<attach_type __type="str">inject</attach_type>
</debugger>
<hooks>
<iat>
<enable __type="bool">1</enable>
<source_name __type="str">ezusb.dll</source_name>
<path __type="str">ezusb2-popn-shim.dll</path>
</iat>
<hook>
<enable __type="bool">1</enable>
<path __type="str">popnhook1.dll</path>
<config kind="inline">
<hook>
<eamuse>
<!-- URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. -->
<server __type="str">localhost:80</server>
<pcbid __type="bin">0101020304050607086F</pcbid>
<eamid __type="bin">0101020304050607086F</eamid>
</eamuse>
<gfx>
<windowed __type="bool">1</windowed>
<framed __type="bool">1</framed>
<window_width __type="s32">0</window_width>
<window_height __type="s32">0</window_height>
</gfx>
<sec>
<black_plug_mcode __type="str">GQG15JAA</black_plug_mcode>
</sec>
</hook>
</config>
</hook>
</hooks>
<logger>
<enable __type="bool">1</enable>
<level __type="str">misc</level>
<msg_buffer_size_bytes __type="u32">8192</msg_buffer_size_bytes>
<sinks>
<async>
<enable __type="bool">0</enable>
<queue_length __type="u8">64</queue_length>
<overflow_policy __type="str">discard_new</overflow_policy>
</async>
<console>
<enable __type="bool">1</enable>
<color __type="bool">1</color>
</console>
<file>
<enable __type="bool">1</enable>
<path __type="str">inject.log</path>
<append __type="bool">0</append>
<rotate __type="bool">0</rotate>
<max_rotations __type="u8">1</max_rotations>
</file>
</sinks>
</logger>
<debug>
<property_configs_log __type="bool">1</property_configs_log>
<property_api_trace_log __type="bool">0</property_api_trace_log>
</debug>
</inject>

68
dist/popn/inject-16.xml vendored Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="Shift-JIS"?>
<inject>
<version __type="u32">1</version>
<debugger>
<app>
<path __type="str">popn16.exe</path>
<args __type="str"></args>
</app>
<attach_type __type="str">inject</attach_type>
</debugger>
<hooks>
<iat>
<enable __type="bool">1</enable>
<source_name __type="str">ezusb.dll</source_name>
<path __type="str">ezusb2-popn-shim.dll</path>
</iat>
<hook>
<enable __type="bool">1</enable>
<path __type="str">popnhook1.dll</path>
<config kind="inline">
<hook>
<eamuse>
<!-- URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. -->
<server __type="str">localhost:80</server>
<pcbid __type="bin">0101020304050607086F</pcbid>
<eamid __type="bin">0101020304050607086F</eamid>
</eamuse>
<gfx>
<windowed __type="bool">1</windowed>
<framed __type="bool">1</framed>
<window_width __type="s32">0</window_width>
<window_height __type="s32">0</window_height>
</gfx>
<sec>
<black_plug_mcode __type="str">GQH16JAA</black_plug_mcode>
</sec>
</hook>
</config>
</hook>
</hooks>
<logger>
<enable __type="bool">1</enable>
<level __type="str">misc</level>
<msg_buffer_size_bytes __type="u32">8192</msg_buffer_size_bytes>
<sinks>
<async>
<enable __type="bool">0</enable>
<queue_length __type="u8">64</queue_length>
<overflow_policy __type="str">discard_new</overflow_policy>
</async>
<console>
<enable __type="bool">1</enable>
<color __type="bool">1</color>
</console>
<file>
<enable __type="bool">1</enable>
<path __type="str">inject.log</path>
<append __type="bool">0</append>
<rotate __type="bool">0</rotate>
<max_rotations __type="u8">1</max_rotations>
</file>
</sinks>
</logger>
<debug>
<property_configs_log __type="bool">1</property_configs_log>
<property_api_trace_log __type="bool">0</property_api_trace_log>
</debug>
</inject>

68
dist/popn/inject-17.xml vendored Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="Shift-JIS"?>
<inject>
<version __type="u32">1</version>
<debugger>
<app>
<path __type="str">popn17.exe</path>
<args __type="str"></args>
</app>
<attach_type __type="str">inject</attach_type>
</debugger>
<hooks>
<iat>
<enable __type="bool">1</enable>
<source_name __type="str">ezusb.dll</source_name>
<path __type="str">ezusb2-popn-shim.dll</path>
</iat>
<hook>
<enable __type="bool">1</enable>
<path __type="str">popnhook1.dll</path>
<config kind="inline">
<hook>
<eamuse>
<!-- URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. -->
<server __type="str">localhost:80</server>
<pcbid __type="bin">0101020304050607086F</pcbid>
<eamid __type="bin">0101020304050607086F</eamid>
</eamuse>
<gfx>
<windowed __type="bool">1</windowed>
<framed __type="bool">1</framed>
<window_width __type="s32">0</window_width>
<window_height __type="s32">0</window_height>
</gfx>
<sec>
<black_plug_mcode __type="str">GQI17JAA</black_plug_mcode>
</sec>
</hook>
</config>
</hook>
</hooks>
<logger>
<enable __type="bool">1</enable>
<level __type="str">misc</level>
<msg_buffer_size_bytes __type="u32">8192</msg_buffer_size_bytes>
<sinks>
<async>
<enable __type="bool">0</enable>
<queue_length __type="u8">64</queue_length>
<overflow_policy __type="str">discard_new</overflow_policy>
</async>
<console>
<enable __type="bool">1</enable>
<color __type="bool">1</color>
</console>
<file>
<enable __type="bool">1</enable>
<path __type="str">inject.log</path>
<append __type="bool">0</append>
<rotate __type="bool">0</rotate>
<max_rotations __type="u8">1</max_rotations>
</file>
</sinks>
</logger>
<debug>
<property_configs_log __type="bool">1</property_configs_log>
<property_api_trace_log __type="bool">0</property_api_trace_log>
</debug>
</inject>

68
dist/popn/inject-18.xml vendored Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="Shift-JIS"?>
<inject>
<version __type="u32">1</version>
<debugger>
<app>
<path __type="str">popn18.exe</path>
<args __type="str"></args>
</app>
<attach_type __type="str">inject</attach_type>
</debugger>
<hooks>
<iat>
<enable __type="bool">1</enable>
<source_name __type="str">ezusb.dll</source_name>
<path __type="str">ezusb2-popn-shim.dll</path>
</iat>
<hook>
<enable __type="bool">1</enable>
<path __type="str">popnhook1.dll</path>
<config kind="inline">
<hook>
<eamuse>
<!-- URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80. -->
<server __type="str">localhost:80</server>
<pcbid __type="bin">0101020304050607086F</pcbid>
<eamid __type="bin">0101020304050607086F</eamid>
</eamuse>
<gfx>
<windowed __type="bool">1</windowed>
<framed __type="bool">1</framed>
<window_width __type="s32">0</window_width>
<window_height __type="s32">0</window_height>
</gfx>
<sec>
<black_plug_mcode __type="str">GCJ39JAA</black_plug_mcode>
</sec>
</hook>
</config>
</hook>
</hooks>
<logger>
<enable __type="bool">1</enable>
<level __type="str">misc</level>
<msg_buffer_size_bytes __type="u32">8192</msg_buffer_size_bytes>
<sinks>
<async>
<enable __type="bool">0</enable>
<queue_length __type="u8">64</queue_length>
<overflow_policy __type="str">discard_new</overflow_policy>
</async>
<console>
<enable __type="bool">1</enable>
<color __type="bool">1</color>
</console>
<file>
<enable __type="bool">1</enable>
<path __type="str">inject.log</path>
<append __type="bool">0</append>
<rotate __type="bool">0</rotate>
<max_rotations __type="u8">1</max_rotations>
</file>
</sinks>
</logger>
<debug>
<property_configs_log __type="bool">1</property_configs_log>
<property_api_trace_log __type="bool">0</property_api_trace_log>
</debug>
</inject>

View File

@ -1,23 +0,0 @@
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80
# PCBID
eamuse.pcbid=0101020304050607086F
# EAMID
eamuse.eamid=0101020304050607086F
# Run the game windowed
gfx.windowed=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false
# Windowed width, 0 for default size
gfx.window_width=0
# Windowed height, 0 for default size
gfx.window_height=0
# Security black plug mcode id string (e.g. GQC02JAA).
sec.black_plug_mcode=GQG15JAA

View File

@ -1,23 +0,0 @@
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80
# PCBID
eamuse.pcbid=0101020304050607086F
# EAMID
eamuse.eamid=0101020304050607086F
# Run the game windowed
gfx.windowed=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false
# Windowed width, 0 for default size
gfx.window_width=0
# Windowed height, 0 for default size
gfx.window_height=0
# Security black plug mcode id string (e.g. GQC02JAA).
sec.black_plug_mcode=GQH16JAA

View File

@ -1,23 +0,0 @@
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80
# PCBID
eamuse.pcbid=0101020304050607086F
# EAMID
eamuse.eamid=0101020304050607086F
# Run the game windowed
gfx.windowed=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false
# Windowed width, 0 for default size
gfx.window_width=0
# Windowed height, 0 for default size
gfx.window_height=0
# Security black plug mcode id string (e.g. GQC02JAA).
sec.black_plug_mcode=GQI17JAA

View File

@ -1,23 +0,0 @@
# URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 (e.g. 127.0.0.1:80) of the target eamuse server. The port is optional but defaults to 80.
eamuse.server=localhost:80
# PCBID
eamuse.pcbid=0101020304050607086F
# EAMID
eamuse.eamid=0101020304050607086F
# Run the game windowed
gfx.windowed=false
# Run the game in a framed window (requires windowed option)
gfx.framed=false
# Windowed width, 0 for default size
gfx.window_width=0
# Windowed height, 0 for default size
gfx.window_height=0
# Security black plug mcode id string (e.g. GQC02JAA).
sec.black_plug_mcode=GCJ39JAA

View File

@ -6,6 +6,7 @@ deplibs_popnhook1 := \
ldflags_popnhook1 := \
-lws2_32 \
-liphlpapi \
-lshlwapi \
libs_popnhook1 := \
core \
@ -17,7 +18,6 @@ libs_popnhook1 := \
acioemu \
hook \
hooklib \
cconfig \
util \
ezusb \
security \
@ -26,6 +26,8 @@ libs_popnhook1 := \
iface-io \
iface-core \
module \
sdk-hook \
mxml \
src_popnhook1 := \
avs-boot.c \
@ -35,3 +37,4 @@ src_popnhook1 := \
d3d9.c \
dllmain.c \
filesystem.c \
popnhook1.c \

View File

@ -1,145 +1,12 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "iface-core/log.h"
#include "core/config-ext.h"
#include "popnhook1/config-eamuse.h"
#include "security/mcode.h"
#define POPNHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
#define POPNHOOK1_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid"
#define POPNHOOK1_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid"
#define POPNHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80"
#define POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default
#define POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \
sizeof(security_id_default)
#define POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default
#define POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \
sizeof(security_id_default)
const struct net_addr popnhook1_eamuse_default_server = {
.type = NET_ADDR_TYPE_HOSTNAME,
.hostname.host = "localhost",
.hostname.port = 80,
};
void popnhook1_config_eamuse_init(struct cconfig *config)
{
cconfig_util_set_str(
config,
POPNHOOK1_CONFIG_EAMUSE_SERVER_KEY,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE,
"URL (e.g. http://my.eamuse.server:80/whatever) or IPV4 "
"(e.g. 127.0.0.1:80) of the target eamuse server. The port is "
"optional "
"but defaults to 80.");
cconfig_util_set_data(
config,
POPNHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
"PCBID");
cconfig_util_set_data(
config,
POPNHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
"EAMID");
}
void popnhook1_config_eamuse_get(
struct popnhook1_config_eamuse *config_eamuse, struct cconfig *config)
const bt_core_config_t *config,
popnhook1_config_eamuse_t *config_out)
{
char server_url[1024];
char *tmp;
char *tmp2;
memset(config_eamuse, 0, sizeof(struct popnhook1_config_eamuse));
if (!cconfig_util_get_str(
config,
POPNHOOK1_CONFIG_EAMUSE_SERVER_KEY,
server_url,
sizeof(server_url),
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
POPNHOOK1_CONFIG_EAMUSE_SERVER_KEY,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE);
}
if (!net_str_parse(server_url, &config_eamuse->server)) {
memcpy(
&config_eamuse->server,
&popnhook1_eamuse_default_server,
sizeof(config_eamuse->server));
tmp = net_addr_to_str(&config_eamuse->server);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
tmp);
free(tmp);
}
if (!cconfig_util_get_data(
config,
POPNHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &config_eamuse->pcbid,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
(uint8_t *) &POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
tmp = security_id_to_str(
&POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
tmp);
free(tmp);
}
if (!security_id_verify(&config_eamuse->pcbid)) {
tmp = security_id_to_str(
&POPNHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
tmp2 = security_id_to_str(&config_eamuse->pcbid, false);
log_warning(
"PCBID verification of '%s' failed, fallback to default "
"PCBID '%s'",
tmp2,
tmp);
free(tmp);
free(tmp2);
}
if (!cconfig_util_get_data(
config,
POPNHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &config_eamuse->eamid,
POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
(uint8_t *) &POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
tmp = security_id_to_str(
&POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
tmp);
free(tmp);
}
if (!security_id_verify(&config_eamuse->eamid)) {
tmp = security_id_to_str(
&POPNHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
tmp2 = security_id_to_str(&config_eamuse->eamid, false);
log_warning(
"EAMID verification of '%s' failed, fallback to default "
"EAMID '%s'",
tmp2,
tmp);
free(tmp);
free(tmp2);
}
}
bt_core_config_ext_net_addr_get(config, "eamuse/server", &config_out->server);
bt_core_config_ext_security_id_get(config, "eamuse/pcbid", &config_out->pcbid);
bt_core_config_ext_security_id_get(config, "eamuse/eamid", &config_out->eamid);
}

View File

@ -1,21 +1,20 @@
#ifndef POPNHOOK1_CONFIG_EAMUSE_H
#define POPNHOOK1_CONFIG_EAMUSE_H
#include "cconfig/cconfig.h"
#include "api/core/config.h"
#include "security/id.h"
#include "util/net.h"
struct popnhook1_config_eamuse {
typedef struct popnhook1_config_eamuse {
struct net_addr server;
struct security_id pcbid;
struct security_id eamid;
};
void popnhook1_config_eamuse_init(struct cconfig *config);
} popnhook1_config_eamuse_t;
void popnhook1_config_eamuse_get(
struct popnhook1_config_eamuse *config_eamuse, struct cconfig *config);
const bt_core_config_t *config,
popnhook1_config_eamuse_t *config_out);
#endif

View File

@ -1,8 +1,4 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "iface-core/log.h"
#include "core/config-ext.h"
#include "popnhook1/config-gfx.h"
@ -11,86 +7,12 @@
#define POPNHOOK1_CONFIG_GFX_WINDOW_WIDTH_KEY "gfx.window_width"
#define POPNHOOK1_CONFIG_GFX_WINDOW_HEIGHT_KEY "gfx.window_height"
#define POPNHOOK1_CONFIG_GFX_DEFAULT_FRAMED_VALUE false
#define POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE false
#define POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE -1
#define POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE -1
void popnhook1_config_gfx_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
POPNHOOK1_CONFIG_GFX_WINDOWED_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE,
"Run the game windowed");
cconfig_util_set_bool(
config,
POPNHOOK1_CONFIG_GFX_FRAMED_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_FRAMED_VALUE,
"Run the game in a framed window (requires windowed option)");
cconfig_util_set_int(
config,
POPNHOOK1_CONFIG_GFX_WINDOW_WIDTH_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE,
"Windowed width, -1 for default size");
cconfig_util_set_int(
config,
POPNHOOK1_CONFIG_GFX_WINDOW_HEIGHT_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE,
"Windowed height, -1 for default size");
}
void popnhook1_config_gfx_get(
struct popnhook1_config_gfx *config_gfx, struct cconfig *config)
const bt_core_config_t *config,
popnhook1_config_gfx_t *out_config)
{
if (!cconfig_util_get_bool(
config,
POPNHOOK1_CONFIG_GFX_WINDOWED_KEY,
&config_gfx->windowed,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
POPNHOOK1_CONFIG_GFX_WINDOWED_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE);
}
if (!cconfig_util_get_bool(
config,
POPNHOOK1_CONFIG_GFX_FRAMED_KEY,
&config_gfx->framed,
POPNHOOK1_CONFIG_GFX_DEFAULT_FRAMED_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
POPNHOOK1_CONFIG_GFX_FRAMED_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_FRAMED_VALUE);
}
if (!cconfig_util_get_int(
config,
POPNHOOK1_CONFIG_GFX_WINDOW_WIDTH_KEY,
&config_gfx->window_width,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
POPNHOOK1_CONFIG_GFX_WINDOW_WIDTH_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE);
}
if (!cconfig_util_get_int(
config,
POPNHOOK1_CONFIG_GFX_WINDOW_HEIGHT_KEY,
&config_gfx->window_height,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
POPNHOOK1_CONFIG_GFX_WINDOW_HEIGHT_KEY,
POPNHOOK1_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE);
}
bt_core_config_bool_get(config, "gfx/windowed", &out_config->windowed);
bt_core_config_bool_get(config, "gfx/framed", &out_config->framed);
bt_core_config_s32_get(config, "gfx/window_width", &out_config->window_width);
bt_core_config_s32_get(config, "gfx/window_height", &out_config->window_height);
}

View File

@ -1,21 +1,20 @@
#ifndef POPNHOOK1_CONFIG_GFX_H
#define POPNHOOK1_CONFIG_GFX_H
#include "cconfig/cconfig.h"
#include <stdbool.h>
#include <stdint.h>
#include "popnhook1/d3d9.h"
#include "api/core/config.h"
// see struct popnhook1_d3d9_config for more info
struct popnhook1_config_gfx {
typedef struct popnhook1_config_gfx {
bool framed;
bool windowed;
int32_t window_width;
int32_t window_height;
};
void popnhook1_config_gfx_init(struct cconfig *config);
} popnhook1_config_gfx_t;
void popnhook1_config_gfx_get(
struct popnhook1_config_gfx *config_gfx, struct cconfig *config);
const bt_core_config_t *config,
popnhook1_config_gfx_t *out_config);
#endif

View File

@ -1,81 +1,10 @@
#include <stdio.h>
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "iface-core/log.h"
#include "core/config-ext.h"
#include "popnhook1/config-sec.h"
#include "security/mcode.h"
#include "security/rp.h"
#include "util/mem.h"
#define POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY "sec.black_plug_mcode"
#define POPNHOOK1_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE \
popnhook1_security_default_black_plug_mcode
static const struct security_mcode popnhook1_security_default_black_plug_mcode =
{
.header = SECURITY_MCODE_HEADER,
.unkn = SECURITY_MCODE_UNKN_Q,
.game = SECURITY_MCODE_GAME_POPN_15,
.region = SECURITY_MCODE_REGION_JAPAN,
.cabinet = SECURITY_MCODE_CABINET_A,
.revision = SECURITY_MCODE_REVISION_A,
};
void popnhook1_config_sec_init(struct cconfig *config)
{
char *tmp;
tmp = security_mcode_to_str(
&POPNHOOK1_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE);
cconfig_util_set_str(
config,
POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
tmp,
"Security black plug mcode id string (e.g. GQC02JAA).");
free(tmp);
}
void popnhook1_config_sec_get(
struct popnhook1_config_sec *config_sec, struct cconfig *config)
const bt_core_config_t *config,
popnhook1_config_sec_t *out_config)
{
char tmp_mcode[sizeof(struct security_mcode) + 1];
char *tmp_str;
tmp_str = security_mcode_to_str(
&POPNHOOK1_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE);
if (!cconfig_util_get_str(
config,
POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
tmp_mcode,
sizeof(tmp_mcode) - 1,
tmp_str)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
tmp_str);
}
if (!security_mcode_parse(tmp_mcode, &config_sec->black_plug_mcode)) {
log_warning(
"Invalid format for value of key '%s' specified, fallback "
"to default '%s'",
POPNHOOK1_CONFIG_SEC_BLACK_PLUG_MCODE_KEY,
tmp_str);
memcpy(
&config_sec->black_plug_mcode,
&POPNHOOK1_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE,
sizeof(POPNHOOK1_CONFIG_SEC_DEFAULT_BLACK_PLUG_MCODE_VALUE));
}
free(tmp_str);
}
bt_core_config_ext_security_mcode_get(config, "sec/black_plug_mcode", &out_config->black_plug_mcode);
}

View File

@ -1,17 +1,16 @@
#ifndef POPNHOOK1_CONFIG_SEC_H
#define POPNHOOK1_CONFIG_SEC_H
#include "cconfig/cconfig.h"
#include "api/core/config.h"
#include "security/mcode.h"
struct popnhook1_config_sec {
struct security_mcode black_plug_mcode;
};
void popnhook1_config_sec_init(struct cconfig *config);
typedef struct popnhook1_config_sec {
security_mcode_t black_plug_mcode;
} popnhook1_config_sec_t;
void popnhook1_config_sec_get(
struct popnhook1_config_sec *config_sec, struct cconfig *config);
const bt_core_config_t *config,
popnhook1_config_sec_t *out_config);
#endif

View File

@ -1,241 +1,70 @@
#include <stdio.h>
#include <windows.h>
#include <stdbool.h>
#include <stddef.h>
#include "cconfig/cconfig-hook.h"
#include "core/log-bt-ext.h"
#include "core/log-bt.h"
#include "core/log-sink-debug.h"
#include "core/thread-crt.h"
#include "ezusb-emu/node-security-plug.h"
#include "hook/d3d9.h"
#include "hook/table.h"
#include "hooklib/adapter.h"
#include "popnhook1/popnhook1.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "main/sdk-hook/dllentry.h"
#include "iface-io/eam.h"
#include "iface-io/popn.h"
#include "module/io-ext.h"
#include "module/io.h"
#include "popnhook1/avs-boot.h"
#include "popnhook1/config-eamuse.h"
#include "popnhook1/config-gfx.h"
#include "popnhook1/config-sec.h"
#include "popnhook1/d3d9.h"
#include "popnhook1/filesystem.h"
#include "popnhook-util/acio.h"
#include "popnhook-util/mixer.h"
#include "util/cmdline.h"
#include "util/defs.h"
#include "ezusb2-emu/desc.h"
#include "ezusb2-emu/device.h"
static DWORD STDCALL _popnhook1_dllmain_my_GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo);
static DWORD(STDCALL *_popnhook1_dllmain_real_GetStartupInfoA)(LPSTARTUPINFOA lpStartupInfo);
#include "popnhook-util/acio.h"
static bool _popnhook1_dllmain_getstartupinfoa_call_check;
#include "ezusb2-popn-emu/msg.h"
#include "hooklib/rs232.h"
#include "security/rp-sign-key.h"
#define POPNHOOK1_INFO_HEADER \
"popnhook1 for pop'n music 15, 16, 17, 18" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
#define POPNHOOK1_CMD_USAGE \
"Usage: inject.exe popnhook1.dll <popn.exe> [options...]"
static DWORD STDCALL my_GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo);
static DWORD(STDCALL *real_GetStartupInfoA)(LPSTARTUPINFOA lpStartupInfo);
static bool popnhook1_init_check;
static module_io_t *popnhook_module_io_popn;
static module_io_t *popnhook_module_io_eam;
static const struct hook_symbol init_hook_syms[] = {
static const struct hook_symbol _popnhook1_dllmain_hook_syms[] = {
{
.name = "GetStartupInfoA",
.patch = my_GetStartupInfoA,
.link = (void **) &real_GetStartupInfoA,
.patch = _popnhook1_dllmain_my_GetStartupInfoA,
.link = (void **) &_popnhook1_dllmain_real_GetStartupInfoA,
},
};
static void _popnhook1_log_init()
static DWORD STDCALL
_popnhook1_dllmain_my_GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
{
core_log_bt_ext_init_with_debug();
// TODO change log level support
core_log_bt_level_set(CORE_LOG_BT_LOG_LEVEL_MISC);
}
static void _popnhook1_io_popn_init(module_io_t **module)
{
bt_io_popn_api_t api;
module_io_ext_load_and_init(
"popnio.dll", "bt_module_io_popn_api_get", module);
module_io_api_get(*module, &api);
bt_io_popn_api_set(&api);
}
static void _popnhook1_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 popnhook_setup_d3d9_hooks(
const struct popnhook1_config_gfx *config_gfx, const bool texture_usage_fix)
{
struct popnhook1_d3d9_config d3d9_config;
popnhook1_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.texture_usage_fix = texture_usage_fix;
popnhook1_d3d9_init();
popnhook1_d3d9_configure(&d3d9_config);
}
static DWORD STDCALL my_GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
{
struct cconfig *config;
struct popnhook1_config_eamuse config_eamuse;
struct popnhook1_config_gfx config_gfx;
struct popnhook1_config_sec config_sec;
if (popnhook1_init_check)
goto skip;
popnhook1_init_check = true;
log_info("-------------------------------------------------------------");
log_info("----------------- Start popnhook1 hook init -----------------");
log_info("-------------------------------------------------------------");
config = cconfig_init();
popnhook1_config_eamuse_init(config);
popnhook1_config_gfx_init(config);
popnhook1_config_sec_init(config);
if (!cconfig_hook_config_init(
config,
POPNHOOK1_INFO_HEADER "\n" POPNHOOK1_CMD_USAGE,
CCONFIG_CMD_USAGE_OUT_DBG)) {
cconfig_finit(config);
exit(EXIT_FAILURE);
if (_popnhook1_dllmain_getstartupinfoa_call_check) {
return _popnhook1_dllmain_real_GetStartupInfoA(lpStartupInfo);
}
popnhook1_config_gfx_get(&config_gfx, config);
popnhook1_config_eamuse_get(&config_eamuse, config);
popnhook1_config_sec_get(&config_sec, config);
_popnhook1_dllmain_getstartupinfoa_call_check = true;
cconfig_finit(config);
bt_hook_dllentry_main_init();
popnhook_setup_d3d9_hooks(
&config_gfx,
// pop'n music 16 requires a patch for the texture usage to not crash on
// newer Windows
memcmp(
config_sec.black_plug_mcode.game,
SECURITY_MCODE_GAME_POPN_16,
sizeof(config_sec.black_plug_mcode.game)) == 0);
popnhook1_avs_boot_init();
popnhook1_avs_boot_set_eamuse_addr(&config_eamuse.server);
/* Round plug security */
ezusb_iidx_emu_node_security_plug_set_plug_black_mcode(
&config_sec.black_plug_mcode);
ezusb_iidx_emu_node_security_plug_set_plug_white_mcode(
&security_mcode_eamuse);
ezusb_iidx_emu_node_security_plug_set_plug_black_sign_key(
&security_rp_sign_key_black_popn);
ezusb_iidx_emu_node_security_plug_set_plug_white_sign_key(
&security_rp_sign_key_white_eamuse);
ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
ezusb_iidx_emu_node_security_plug_set_eamid(&config_eamuse.eamid);
/* Start up POPNIO.DLL */
log_info("Starting pop'n IO backend");
_popnhook1_io_popn_init(&popnhook_module_io_popn);
if (!bt_io_popn_init()) {
log_fatal("Initializing pop'n IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
_popnhook1_io_eam_init(&popnhook_module_io_eam);
if (!bt_io_eam_init()) {
log_fatal("Initializing card reader backend failed");
}
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
iohook_push_handler(popnhook_acio_dispatch_irp);
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
ezusb2_emu_device_hook_init(ezusb2_popn_emu_msg_init());
rs232_hook_init();
popnhook_acio_init(true);
adapter_hook_init();
filesystem_init();
popnhook_mixer_hook_init();
log_info("-------------------------------------------------------------");
log_info("------------------ End popnhook1 hook init ------------------");
log_info("-------------------------------------------------------------");
skip:
return real_GetStartupInfoA(lpStartupInfo);
return _popnhook1_dllmain_real_GetStartupInfoA(lpStartupInfo);
}
BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
// TODO find another call right before main exits to hook cleanup and stuff with
// bt_hook_dllentry_main_fini()
BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason != DLL_PROCESS_ATTACH) {
return TRUE;
if (reason == DLL_PROCESS_ATTACH) {
bt_hook_dllentry_init(
mod,
"popnhook1",
bt_module_core_config_api_set,
bt_module_core_log_api_set,
bt_module_core_thread_api_set,
bt_module_hook_api_get);
_popnhook1_dllmain_getstartupinfoa_call_check = false;
hook_table_apply(
NULL, "kernel32.dll", _popnhook1_dllmain_hook_syms, lengthof(_popnhook1_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", _popnhook1_dllmain_hook_syms, lengthof(_popnhook1_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();
}
}
// Use bemanitools core APIs
core_log_bt_core_api_set();
core_thread_crt_core_api_set();
_popnhook1_log_init();
hook_table_apply(
NULL, "kernel32.dll", init_hook_syms, lengthof(init_hook_syms));
return TRUE;
}
}

View File

@ -0,0 +1,196 @@
#include <stdio.h>
#include <windows.h>
#include <stdbool.h>
#include <stddef.h>
#include "ezusb-emu/node-security-plug.h"
#include "hook/d3d9.h"
#include "hooklib/adapter.h"
#include "iface-core/config.h"
#include "iface-core/log.h"
#include "iface-core/thread.h"
#include "iface-io/eam.h"
#include "iface-io/popn.h"
#include "module/io-ext.h"
#include "module/io.h"
#include "popnhook1/avs-boot.h"
#include "popnhook1/config-eamuse.h"
#include "popnhook1/config-gfx.h"
#include "popnhook1/config-sec.h"
#include "popnhook1/d3d9.h"
#include "popnhook1/filesystem.h"
#include "popnhook-util/acio.h"
#include "popnhook-util/mixer.h"
#include "util/cmdline.h"
#include "util/defs.h"
#include "ezusb2-emu/desc.h"
#include "ezusb2-emu/device.h"
#include "popnhook-util/acio.h"
#include "ezusb2-popn-emu/msg.h"
#include "hooklib/rs232.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 module_io_t *popnhook_module_io_popn;
static module_io_t *popnhook_module_io_eam;
static void _popnhook1_io_popn_init(module_io_t **module)
{
bt_io_popn_api_t api;
module_io_ext_load_and_init(
"popnio.dll", "bt_module_io_popn_api_get", module);
module_io_api_get(*module, &api);
bt_io_popn_api_set(&api);
}
static void _popnhook1_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 popnhook_setup_d3d9_hooks(
const popnhook1_config_gfx_t *config_gfx, const bool texture_usage_fix)
{
struct popnhook1_d3d9_config d3d9_config;
popnhook1_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.texture_usage_fix = texture_usage_fix;
popnhook1_d3d9_init();
popnhook1_d3d9_configure(&d3d9_config);
}
static bool
_popnhook1_main_init(HMODULE game_module, const bt_core_config_t *config)
{
popnhook1_config_eamuse_t config_eamuse;
popnhook1_config_gfx_t config_gfx;
popnhook1_config_sec_t config_sec;
log_info("popnhook1 for pop'n music 15, 16, 17, 18");
log_info("build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV));
popnhook1_config_gfx_get(config, &config_gfx);
popnhook1_config_eamuse_get(config, &config_eamuse);
popnhook1_config_sec_get(config, &config_sec);
popnhook_setup_d3d9_hooks(
&config_gfx,
// pop'n music 16 requires a patch for the texture usage to not crash on
// newer Windows
memcmp(
config_sec.black_plug_mcode.game,
SECURITY_MCODE_GAME_POPN_16,
sizeof(config_sec.black_plug_mcode.game)) == 0);
popnhook1_avs_boot_init();
popnhook1_avs_boot_set_eamuse_addr(&config_eamuse.server);
/* Round plug security */
ezusb_iidx_emu_node_security_plug_set_plug_black_mcode(
&config_sec.black_plug_mcode);
ezusb_iidx_emu_node_security_plug_set_plug_white_mcode(
&security_mcode_eamuse);
ezusb_iidx_emu_node_security_plug_set_plug_black_sign_key(
&security_rp_sign_key_black_popn);
ezusb_iidx_emu_node_security_plug_set_plug_white_sign_key(
&security_rp_sign_key_white_eamuse);
ezusb_iidx_emu_node_security_plug_set_pcbid(&config_eamuse.pcbid);
ezusb_iidx_emu_node_security_plug_set_eamid(&config_eamuse.eamid);
/* Start up POPNIO.DLL */
log_info("Starting pop'n IO backend");
_popnhook1_io_popn_init(&popnhook_module_io_popn);
if (!bt_io_popn_init()) {
log_fatal("Initializing pop'n IO backend failed");
}
/* Start up EAMIO.DLL */
log_misc("Initializing card reader backend");
_popnhook1_io_eam_init(&popnhook_module_io_eam);
if (!bt_io_eam_init()) {
log_fatal("Initializing card reader backend failed");
}
iohook_push_handler(ezusb2_emu_device_dispatch_irp);
iohook_push_handler(popnhook_acio_dispatch_irp);
hook_setupapi_init(&ezusb2_emu_desc_device.setupapi);
ezusb2_emu_device_hook_init(ezusb2_popn_emu_msg_init());
rs232_hook_init();
popnhook_acio_init(true);
adapter_hook_init();
filesystem_init();
popnhook_mixer_hook_init();
return true;
}
static void _popnhook1_main_fini()
{
// TODO cleanup
}
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 = _popnhook1_main_init;
api->v1.main_fini = _popnhook1_main_fini;
}

View File

@ -2,3 +2,9 @@ LIBRARY popnhook1
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

View File

@ -0,0 +1,9 @@
#ifndef POPNHOOK1_H
#define POPNHOOK1_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