1
0
mirror of https://github.com/djhackersdev/bemanitools.git synced 2025-01-31 04:03:43 +01:00

Fixes based on PR feedback

This commit is contained in:
QCDLZCLW3K 2022-05-19 11:18:03 +09:00
parent 41de45d459
commit c3f9ce7e91
50 changed files with 406 additions and 379 deletions

View File

@ -93,8 +93,8 @@ include src/main/cconfig/Module.mk
include src/main/config/Module.mk
include src/main/d3d9exhook/Module.mk
include src/main/ddrhook-util/Module.mk
include src/main/ddrhook/Module.mk
include src/main/ddrhookx/Module.mk
include src/main/ddrhook1/Module.mk
include src/main/ddrhook2/Module.mk
include src/main/ddrio-mm/Module.mk
include src/main/ddrio-smx/Module.mk
include src/main/ddrio/Module.mk
@ -569,7 +569,7 @@ $(zipdir)/sdvx-hwio-x64.zip: \
$(zipdir)/ddr-11.zip: \
build/bin/indep-32/inject.exe \
build/bin/avs2_803-32/ddrhookx.dll \
build/bin/avs2_803-32/ddrhook1.dll \
build/bin/avs2_803-32/unicorntail.dll \
build/bin/indep-32/config.exe \
build/bin/indep-32/ddrio.dll \
@ -588,7 +588,7 @@ $(zipdir)/ddr-11.zip: \
$(zipdir)/ddr-12.zip: \
build/bin/avs2_1002-32/launcher.exe \
build/bin/avs2_1002-32/ddrhook.dll \
build/bin/avs2_1002-32/ddrhook2.dll \
build/bin/avs2_1002-32/unicorntail.dll \
build/bin/indep-32/config.exe \
build/bin/indep-32/ddrio.dll \
@ -604,7 +604,7 @@ $(zipdir)/ddr-12.zip: \
$(zipdir)/ddr-13.zip: \
build/bin/avs2_1304-32/launcher.exe \
build/bin/avs2_1304-32/ddrhook.dll \
build/bin/avs2_1304-32/ddrhook2.dll \
build/bin/avs2_1304-32/unicorntail.dll \
build/bin/indep-32/config.exe \
build/bin/indep-32/ddrio.dll \
@ -620,7 +620,7 @@ $(zipdir)/ddr-13.zip: \
$(zipdir)/ddr-14-to-16.zip: \
build/bin/avs2_1508-32/launcher.exe \
build/bin/avs2_1508-32/ddrhook.dll \
build/bin/avs2_1508-32/ddrhook2.dll \
build/bin/avs2_1508-32/unicorntail.dll \
build/bin/indep-32/config.exe \
build/bin/indep-32/ddrio.dll \
@ -638,7 +638,7 @@ $(zipdir)/ddr-14-to-16.zip: \
$(zipdir)/ddr-16-x64.zip: \
build/bin/avs2_1603-64/launcher.exe \
build/bin/avs2_1603-64/ddrhook.dll \
build/bin/avs2_1603-64/ddrhook2.dll \
build/bin/avs2_1603-64/unicorntail.dll \
build/bin/indep-64/config.exe \
build/bin/indep-64/ddrio.dll \

View File

@ -31,13 +31,13 @@ The tl;dr version and golden rules of the sections in the document:
* BeatStream (bst.zip) using bsthook
* BeatStream アニムトライヴ (bst.zip) using bsthook
* Dance Dance Revolution
* Dance Dance Revolution X (ddr-11.zip) using ddrhookx
* Dance Dance Revolution X2 (ddr-12.zip) using ddrhook
* Dance Dance Revolution X2 (ddr-13.zip) using ddrhook
* Dance Dance Revolution X3 vs. 2ndMIX (ddr-14-to-16.zip) using ddrhook
* Dance Dance Revolution 2013 (ddr-14-to-16.zip) using ddrhook
* Dance Dance Revolution 2014 (ddr-14-to-16.zip) using ddrhook
* Dance Dance Revolution A (ddr-14-to-16.zip) using ddrhook
* Dance Dance Revolution X (ddr-11.zip) using ddrhook1
* Dance Dance Revolution X2 (ddr-12.zip) using ddrhook2
* Dance Dance Revolution X2 (ddr-13.zip) using ddrhook2
* Dance Dance Revolution X3 vs. 2ndMIX (ddr-14-to-16.zip) using ddrhook2
* Dance Dance Revolution 2013 (ddr-14-to-16.zip) using ddrhook2
* Dance Dance Revolution 2014 (ddr-14-to-16.zip) using ddrhook2
* Dance Dance Revolution A (ddr-14-to-16.zip) using ddrhook2
* Beatmania IIDX
* Beatmania IIDX 9th Style (iidx-09-to-12.zip) using [iidxhook1](doc/iidxhook/iidxhook1.md)
* Beatmania IIDX 10th Style (iidx-09-to-12.zip) using [iidxhook1](doc/iidxhook/iidxhook1.md)

View File

@ -16,8 +16,11 @@ ddrhookx.use_com4_emu=true
# SD cabinet mode
ddrhookx.standard_def=false
# Use 15 kHz monitor mode
ddrhookx.use_15khz=false
# Specify path for USB memory data
ddrhookx.usbmem_path=usbmem
# Run the game windowed
gfx.windowed=true
gfx.windowed=false

View File

@ -16,8 +16,11 @@ ddrhookx.use_com4_emu=true
# SD cabinet mode
ddrhookx.standard_def=false
# Use 15 kHz monitor mode
ddrhookx.use_15khz=false
# Specify path for USB memory data
ddrhookx.usbmem_path=usbmem
# Run the game windowed
gfx.windowed=true
gfx.windowed=false

View File

@ -8,4 +8,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s xactengine2_10.dll
inject ddrhookx.dll DDR.exe --config ddr-11-us.conf %*
inject ddrhook1.dll DDR.exe --config ddr-11-us.conf %*

View File

@ -8,4 +8,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s xactengine2_10.dll
inject ddrhookx.dll DDR.exe --config ddr-11.conf %*
inject ddrhook1.dll DDR.exe --config ddr-11.conf %*

View File

@ -8,4 +8,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s k-clvsd.dll
regsvr32 /s xactengine2_10.dll
.\launcher.exe -K .\ddrhook.dll .\ddr.dll %*
.\launcher.exe -K .\ddrhook2.dll .\ddr.dll %*

View File

@ -8,4 +8,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s k-clvsd.dll
regsvr32 /s xactengine2_10.dll
.\launcher.exe -K .\ddrhook.dll .\ddr.dll %*
.\launcher.exe -K .\ddrhook2.dll .\ddr.dll %*

View File

@ -11,4 +11,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s k-clvsd.dll
regsvr32 /s xactengine2_10.dll
.\launcher.exe -K .\ddrhook.dll .\mdxja_945.dll %*
.\launcher.exe -K .\ddrhook2.dll .\mdxja_945.dll %*

View File

@ -11,4 +11,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s k-clvsd.dll
regsvr32 /s xactengine2_10.dll
.\launcher.exe -K .\ddrhook.dll .\mdxja_945.dll %*
.\launcher.exe -K .\ddrhook2.dll .\mdxja_945.dll %*

View File

@ -12,4 +12,4 @@ if not exist conf\raw mkdir conf\raw
regsvr32 /s com\k-clvsd.dll
regsvr32 /s com\xactengine2_10.dll
.\launcher.exe -H 33554432 -K .\ddrhook.dll .\arkmdxp3.dll %*
.\launcher.exe -H 33554432 -K .\ddrhook2.dll .\arkmdxp3.dll %*

View File

@ -1,5 +1,5 @@
#ifndef IIDXHOOK_COM4_H
#define IIDXHOOK_COM4_H
#ifndef DDRHOOK_UTIL_COM4_H
#define DDRHOOK_UTIL_COM4_H
#include "hook/iohook.h"

View File

@ -1,5 +1,5 @@
#ifndef HOOK_DINPUT_H
#define HOOK_DINPUT_H
#ifndef DDRHOOK_UTIL_DINPUT_H
#define DDRHOOK_UTIL_DINPUT_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOK_EXTIO_H
#define DDRHOOK_EXTIO_H
#ifndef DDRHOOK_UTIL_EXTIO_H
#define DDRHOOK_UTIL_EXTIO_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOK_GFX_H
#define DDRHOOK_GFX_H
#ifndef DDRHOOK_UTIL_GFX_H
#define DDRHOOK_UTIL_GFX_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef HOOK_MISC_H
#define HOOK_MISC_H
#ifndef DDRHOOK_UTIL_MISC_H
#define DDRHOOK_UTIL_MISC_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOK_MONITOR_H
#define DDRHOOK_MONITOR_H
#ifndef DDRHOOK_UTIL_MONITOR_H
#define DDRHOOK_UTIL_MONITOR_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOK_P3IO_H
#define DDRHOOK_P3IO_H
#ifndef DDRHOOK_UTIL_P3IO_H
#define DDRHOOK_UTIL_P3IO_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOK_SPIKE_H
#define DDRHOOK_SPIKE_H
#ifndef DDRHOOK_UTIL_SPIKE_H
#define DDRHOOK_UTIL_SPIKE_H
#include <windows.h>

View File

@ -1,5 +1,5 @@
#ifndef HOOK_USBMEM_H
#define HOOK_USBMEM_H
#ifndef DDRHOOK_UTIL_USBMEM_H
#define DDRHOOK_UTIL_USBMEM_H
void usbmem_init(const char *path);
void usbmem_fini(void);

View File

@ -1,8 +0,0 @@
#ifndef DDRHOOK_MASTER_H
#define DDRHOOK_MASTER_H
#include <windows.h>
void master_insert_hooks(HMODULE target);
#endif

View File

@ -1,9 +1,9 @@
avsdlls += ddrhookx
avsdlls += ddrhook1
deplibs_ddrhookx := \
deplibs_ddrhook1 := \
avs \
libs_ddrhookx := \
libs_ddrhook1 := \
acioemu \
cconfig \
ddrhook-util \
@ -16,10 +16,10 @@ libs_ddrhookx := \
ddrio \
security \
src_ddrhookx := \
src_ddrhook1 := \
avs-boot.c \
dllmain.c \
config-ddrhookx.c \
config-ddrhook1.c \
config-eamuse.c \
config-gfx.c \
config-security.c \

View File

@ -10,8 +10,8 @@
#include "imports/avs.h"
#include "ddrhookx/avs-boot.h"
#include "ddrhookx/filesystem.h"
#include "ddrhook1/avs-boot.h"
#include "ddrhook1/filesystem.h"
#include "util/log.h"
#include "util/str.h"
@ -36,7 +36,7 @@ static void my_avs_boot(
size_t sz_avs_heap,
avs_log_writer_t log_writer,
void *log_context);
static struct net_addr ddrhookx_avs_boot_eamuse_server_addr;
static struct net_addr ddrhook1_avs_boot_eamuse_server_addr;
static const struct hook_symbol ddrxhook_avs_hook_syms[] = {
{.name = "avs_boot",
@ -44,7 +44,7 @@ static const struct hook_symbol ddrxhook_avs_hook_syms[] = {
.link = (void **) &real_avs_boot},
};
static const struct hook_symbol ddrhookx_avs_ea3_hook_syms[] = {
static const struct hook_symbol ddrhook1_avs_ea3_hook_syms[] = {
{.name = "ea3_boot",
.patch = my_ea3_boot,
.link = (void **) &real_ea3_boot},
@ -85,7 +85,7 @@ static void my_avs_boot(
// Using the full path as part of the AVS paths seems to break on long paths.
// So instead, just take the launcher folder relative to the main game directory.
char *launcher_folder;
get_launcher_path_parts(NULL, &launcher_folder);
ddrhook1_get_launcher_path_parts(NULL, &launcher_folder);
if (launcher_folder) {
strcpy(nvram_path, launcher_folder);
@ -123,10 +123,10 @@ static int my_ea3_boot(struct property_node *config)
log_info("Called my_ea3_boot");
if (ddrhookx_avs_boot_eamuse_server_addr.type != NET_ADDR_TYPE_INVALID) {
if (ddrhook1_avs_boot_eamuse_server_addr.type != NET_ADDR_TYPE_INVALID) {
log_misc("Injecting network server address");
server_addr = net_addr_to_str(&ddrhookx_avs_boot_eamuse_server_addr);
server_addr = net_addr_to_str(&ddrhook1_avs_boot_eamuse_server_addr);
avs_boot_replace_property_str(config, "network/services", server_addr);
@ -136,7 +136,7 @@ static int my_ea3_boot(struct property_node *config)
return real_ea3_boot(config);
}
void ddrhookx_avs_boot_init()
void ddrhook1_avs_boot_init()
{
hook_table_apply(
NULL,
@ -147,15 +147,15 @@ void ddrhookx_avs_boot_init()
hook_table_apply(
NULL,
"libavs-win32-ea3.dll",
ddrhookx_avs_ea3_hook_syms,
lengthof(ddrhookx_avs_ea3_hook_syms));
ddrhook1_avs_ea3_hook_syms,
lengthof(ddrhook1_avs_ea3_hook_syms));
memset(&ddrhookx_avs_boot_eamuse_server_addr, 0, sizeof(struct net_addr));
memset(&ddrhook1_avs_boot_eamuse_server_addr, 0, sizeof(struct net_addr));
log_info("Inserted avs log hooks");
}
void ddrhookx_avs_boot_set_eamuse_addr(const struct net_addr *server_addr)
void ddrhook1_avs_boot_set_eamuse_addr(const struct net_addr *server_addr)
{
char *str;
@ -164,7 +164,7 @@ void ddrhookx_avs_boot_set_eamuse_addr(const struct net_addr *server_addr)
free(str);
memcpy(
&ddrhookx_avs_boot_eamuse_server_addr,
&ddrhook1_avs_boot_eamuse_server_addr,
server_addr,
sizeof(struct net_addr));
}

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOKX_AVS_BOOT_H
#define DDRHOOKX_AVS_BOOT_H
#ifndef DDRHOOK1_AVS_BOOT_H
#define DDRHOOK1_AVS_BOOT_H
#include "util/net.h"
@ -7,13 +7,13 @@
* Initialize hooking of avs_boot and ea3_boot. This re-enables avs logging
* and injects a few important settings.
*/
void ddrhookx_avs_boot_init();
void ddrhook1_avs_boot_init();
/**
* Set the target eamuse server address.
*
* @param server_addr Address to target eamuse server.
*/
void ddrhookx_avs_boot_set_eamuse_addr(const struct net_addr *server_addr);
void ddrhook1_avs_boot_set_eamuse_addr(const struct net_addr *server_addr);
#endif

View File

@ -0,0 +1,91 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "ddrhook1/config-ddrhook1.h"
#include "util/log.h"
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY "ddrhookx.use_com4_emu"
#define DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY "ddrhookx.standard_def"
#define DDRHOOK1_CONFIG_DDRHOOK1_USE_15KHZ_KEY "ddrhookx.use_15khz"
#define DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH "ddrhookx.usbmem_path"
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_COM4_EMU_VALUE true
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_STANDARD_DEF_VALUE false
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_15KHZ_VALUE false
#define DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH "usbmem"
void ddrhook1_config_ddrhook1_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_COM4_EMU_VALUE,
"Don't emulate P3IO COM4 and its downstream devices, use the Windows COM4 port instead");
cconfig_util_set_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_STANDARD_DEF_VALUE,
"SD cabinet mode");
cconfig_util_set_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USE_15KHZ_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_15KHZ_VALUE,
"Use 15 kHz monitor mode");
cconfig_util_set_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH,
"Specify path for USB memory data");
}
void ddrhook1_config_ddrhook1_get(
struct ddrhook1_config_ddrhookx *config_ddrhookx, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY,
&config_ddrhookx->use_com4_emu,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_COM4_EMU_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOK1_CONFIG_DDRHOOK1_USE_COM4_EMU_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_COM4_EMU_VALUE);
}
if (!cconfig_util_get_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY,
&config_ddrhookx->standard_def,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_STANDARD_DEF_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOK1_CONFIG_DDRHOOK1_STANDARD_DEF_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_STANDARD_DEF_VALUE);
}
if (!cconfig_util_get_bool(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USE_15KHZ_KEY,
&config_ddrhookx->standard_def,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_15KHZ_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOK1_CONFIG_DDRHOOK1_USE_15KHZ_KEY,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USE_15KHZ_VALUE);
}
if (!cconfig_util_get_str(
config,
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
config_ddrhookx->usbmem_path,
sizeof(config_ddrhookx->usbmem_path) - 1,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOK1_CONFIG_DDRHOOK1_USBMEM_PATH,
DDRHOOK1_CONFIG_DDRHOOK1_DEFAULT_USBMEM_PATH);
}
}

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOKX_CONFIG_DDRHOOKX_H
#define DDRHOOKX_CONFIG_DDRHOOKX_H
#ifndef DDRHOOK1_CONFIG_DDRHOOK1_H
#define DDRHOOK1_CONFIG_DDRHOOK1_H
#include <windows.h>
@ -8,9 +8,10 @@
/**
* Struct holding configuration values for game-specific items.
*/
struct ddrhookx_config_ddrhookx {
struct ddrhook1_config_ddrhookx {
bool use_com4_emu;
bool standard_def;
bool use_15khz;
char usbmem_path[MAX_PATH];
};
@ -18,7 +19,7 @@ struct ddrhookx_config_ddrhookx {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void ddrhookx_config_ddrhookx_init(struct cconfig *config);
void ddrhook1_config_ddrhook1_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
@ -28,7 +29,7 @@ void ddrhookx_config_ddrhookx_init(struct cconfig *config);
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void ddrhookx_config_ddrhookx_get(
struct ddrhookx_config_ddrhookx *config_ddrhookx, struct cconfig *config);
void ddrhook1_config_ddrhook1_get(
struct ddrhook1_config_ddrhookx *config_ddrhookx, struct cconfig *config);
#endif

View File

@ -2,35 +2,35 @@
#include "cconfig/cconfig-util.h"
#include "ddrhookx/config-eamuse.h"
#include "ddrhook1/config-eamuse.h"
#include "util/log.h"
#include "util/net.h"
#define DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
#define DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid"
#define DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid"
#define DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY "eamuse.server"
#define DDRHOOK1_CONFIG_EAMUSE_PCBID_KEY "eamuse.pcbid"
#define DDRHOOK1_CONFIG_EAMUSE_EAMID_KEY "eamuse.eamid"
#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80"
#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default
#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \
#define DDRHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80"
#define DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default
#define DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \
sizeof(security_id_default)
#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default
#define DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \
#define DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default
#define DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \
sizeof(security_id_default)
const struct net_addr ddrhookx_eamuse_default_server = {
const struct net_addr ddrhook1_eamuse_default_server = {
.type = NET_ADDR_TYPE_HOSTNAME,
.hostname.host = "localhost",
.hostname.port = 80,
};
void ddrhookx_config_eamuse_init(struct cconfig *config)
void ddrhook1_config_eamuse_init(struct cconfig *config)
{
cconfig_util_set_str(
config,
DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE,
DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY,
DDRHOOK1_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 "
@ -38,45 +38,45 @@ void ddrhookx_config_eamuse_init(struct cconfig *config)
cconfig_util_set_data(
config,
DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
DDRHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
"PCBID");
cconfig_util_set_data(
config,
DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
DDRHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
"EAMID");
}
void ddrhookx_config_eamuse_get(
struct ddrhookx_config_eamuse *config_eamuse, struct cconfig *config)
void ddrhook1_config_eamuse_get(
struct ddrhook1_config_eamuse *config_eamuse, struct cconfig *config)
{
char server_url[1024];
char *tmp;
char *tmp2;
memset(config_eamuse, 0, sizeof(struct ddrhookx_config_eamuse));
memset(config_eamuse, 0, sizeof(struct ddrhook1_config_eamuse));
if (!cconfig_util_get_str(
config,
DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY,
DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY,
server_url,
sizeof(server_url),
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) {
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOKX_CONFIG_EAMUSE_SERVER_KEY,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE);
DDRHOOK1_CONFIG_EAMUSE_SERVER_KEY,
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE);
}
if (!net_str_parse(server_url, &config_eamuse->server)) {
memcpy(
&config_eamuse->server,
&ddrhookx_eamuse_default_server,
&ddrhook1_eamuse_default_server,
sizeof(config_eamuse->server));
tmp = net_addr_to_str(&config_eamuse->server);
log_warning(
@ -88,12 +88,12 @@ void ddrhookx_config_eamuse_get(
if (!cconfig_util_get_data(
config,
DDRHOOKX_CONFIG_EAMUSE_PCBID_KEY,
DDRHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &config_eamuse->pcbid,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
(uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
(uint8_t *) &DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
tmp = security_id_to_str(
&DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
&DDRHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
@ -103,7 +103,7 @@ void ddrhookx_config_eamuse_get(
if (!security_id_verify(&config_eamuse->pcbid)) {
tmp = security_id_to_str(
&DDRHOOKX_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE, false);
&DDRHOOK1_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 "
@ -116,12 +116,12 @@ void ddrhookx_config_eamuse_get(
if (!cconfig_util_get_data(
config,
DDRHOOKX_CONFIG_EAMUSE_EAMID_KEY,
DDRHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &config_eamuse->eamid,
DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
(uint8_t *) &DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
(uint8_t *) &DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
tmp = security_id_to_str(
&DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
&DDRHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
@ -131,7 +131,7 @@ void ddrhookx_config_eamuse_get(
if (!security_id_verify(&config_eamuse->eamid)) {
tmp = security_id_to_str(
&DDRHOOKX_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE, false);
&DDRHOOK1_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 "

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOKX_CONFIG_EAMUSE_H
#define DDRHOOKX_CONFIG_EAMUSE_H
#ifndef DDRHOOK1_CONFIG_EAMUSE_H
#define DDRHOOK1_CONFIG_EAMUSE_H
#include "cconfig/cconfig.h"
@ -10,7 +10,7 @@
/**
* Struct holding configuration values for eamuse related items.
*/
struct ddrhookx_config_eamuse {
struct ddrhook1_config_eamuse {
struct net_addr server;
struct security_id pcbid;
struct security_id eamid;
@ -20,7 +20,7 @@ struct ddrhookx_config_eamuse {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void ddrhookx_config_eamuse_init(struct cconfig *config);
void ddrhook1_config_eamuse_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
@ -30,7 +30,7 @@ void ddrhookx_config_eamuse_init(struct cconfig *config);
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void ddrhookx_config_eamuse_get(
struct ddrhookx_config_eamuse *config_eamuse, struct cconfig *config);
void ddrhook1_config_eamuse_get(
struct ddrhook1_config_eamuse *config_eamuse, struct cconfig *config);
#endif

View File

@ -0,0 +1,36 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "ddrhook1/config-gfx.h"
#include "util/log.h"
#define DDRHOOK1_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
#define DDRHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE true
void ddrhook1_config_gfx_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
DDRHOOK1_CONFIG_GFX_WINDOWED_KEY,
DDRHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE,
"Run the game windowed");
}
void ddrhook1_config_gfx_get(
struct ddrhook1_config_gfx *config_gfx, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
DDRHOOK1_CONFIG_GFX_WINDOWED_KEY,
&config_gfx->windowed,
DDRHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOK1_CONFIG_GFX_WINDOWED_KEY,
DDRHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE);
}
}

View File

@ -1,12 +1,12 @@
#ifndef DDRHOOKX_CONFIG_GFX_H
#define DDRHOOKX_CONFIG_GFX_H
#ifndef DDRHOOK1_CONFIG_GFX_H
#define DDRHOOK1_CONFIG_GFX_H
#include "cconfig/cconfig.h"
/**
* Struct holding configuration values for GFX related items.
*/
struct ddrhookx_config_gfx {
struct ddrhook1_config_gfx {
bool windowed;
};
@ -14,7 +14,7 @@ struct ddrhookx_config_gfx {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void ddrhookx_config_gfx_init(struct cconfig *config);
void ddrhook1_config_gfx_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
@ -24,7 +24,7 @@ void ddrhookx_config_gfx_init(struct cconfig *config);
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void ddrhookx_config_gfx_get(
struct ddrhookx_config_gfx *config_gfx, struct cconfig *config);
void ddrhook1_config_gfx_get(
struct ddrhook1_config_gfx *config_gfx, struct cconfig *config);
#endif

View File

@ -2,14 +2,14 @@
#include "cconfig/cconfig-util.h"
#include "ddrhookx/config-security.h"
#include "ddrhook1/config-security.h"
#include "security/mcode.h"
#include "util/log.h"
#include "util/net.h"
#define DDRHOOKX_CONFIG_SECURITY_MCODE_KEY "security.mcode"
#define DDRHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode"
static const struct security_mcode security_mcode_ddr_x = {
.header = SECURITY_MCODE_HEADER,
@ -20,7 +20,7 @@ static const struct security_mcode security_mcode_ddr_x = {
.revision = SECURITY_MCODE_REVISION_A,
};
void ddrhookx_config_security_init(struct cconfig *config)
void ddrhook1_config_security_init(struct cconfig *config)
{
char *tmp;
@ -28,15 +28,15 @@ void ddrhookx_config_security_init(struct cconfig *config)
cconfig_util_set_str(
config,
DDRHOOKX_CONFIG_SECURITY_MCODE_KEY,
DDRHOOK1_CONFIG_SECURITY_MCODE_KEY,
tmp,
"Mcode of the game to run.");
free(tmp);
}
void ddrhookx_config_security_get(
struct ddrhookx_config_security *config_security, struct cconfig *config)
void ddrhook1_config_security_get(
struct ddrhook1_config_security *config_security, struct cconfig *config)
{
char *tmp_default;
char mcode[9];
@ -46,14 +46,14 @@ void ddrhookx_config_security_get(
if (!cconfig_util_get_str(
config,
DDRHOOKX_CONFIG_SECURITY_MCODE_KEY,
DDRHOOK1_CONFIG_SECURITY_MCODE_KEY,
mcode,
sizeof(mcode) - 1,
tmp_default)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOKX_CONFIG_SECURITY_MCODE_KEY,
DDRHOOK1_CONFIG_SECURITY_MCODE_KEY,
tmp_default);
}

View File

@ -1,5 +1,5 @@
#ifndef DDRHOOKX_CONFIG_SECURITY_H
#define DDRHOOKX_CONFIG_SECURITY_H
#ifndef DDRHOOK1_CONFIG_SECURITY_H
#define DDRHOOK1_CONFIG_SECURITY_H
#include "cconfig/cconfig.h"
@ -10,7 +10,7 @@
/**
* Struct holding configuration values for security related items.
*/
struct ddrhookx_config_security {
struct ddrhook1_config_security {
struct security_mcode mcode;
};
@ -18,7 +18,7 @@ struct ddrhookx_config_security {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void ddrhookx_config_security_init(struct cconfig *config);
void ddrhook1_config_security_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
@ -28,7 +28,7 @@ void ddrhookx_config_security_init(struct cconfig *config);
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void ddrhookx_config_security_get(
struct ddrhookx_config_security *config_security, struct cconfig *config);
void ddrhook1_config_security_get(
struct ddrhook1_config_security *config_security, struct cconfig *config);
#endif

View File

@ -14,7 +14,7 @@
#include "hook/com-proxy.h"
#include "hook/table.h"
#include "ddrhookx/d3d9.h"
#include "ddrhook1/d3d9.h"
#include "util/defs.h"
#include "util/log.h"
@ -34,7 +34,7 @@ static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong);
static BOOL STDCALL my_SetWindowPos(
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
static struct ddrhookx_d3d9_config ddrhookx_d3d9_config;
static struct ddrhook1_d3d9_config ddrhook1_d3d9_config;
static const struct hook_symbol misc_user32_syms[] = {
{
@ -56,7 +56,7 @@ static const struct hook_symbol misc_user32_syms[] = {
/* ------------------------------------------------------------------------- */
static void ddrhookx_d3d9_calc_win_size_with_framed(
static void ddrhook1_d3d9_calc_win_size_with_framed(
HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp)
{
/* taken from dxwnd */
@ -100,7 +100,7 @@ static void ddrhookx_d3d9_calc_win_size_with_framed(
static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
{
if (ddrhookx_d3d9_config.windowed && nIndex == GWL_STYLE) {
if (ddrhook1_d3d9_config.windowed && nIndex == GWL_STYLE) {
dwNewLong |= WS_OVERLAPPEDWINDOW;
}
@ -110,10 +110,10 @@ static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
static BOOL STDCALL my_SetWindowPos(
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
{
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
WINDOWPOS wp;
ddrhookx_d3d9_calc_win_size_with_framed(hWnd, X, Y, cx, cy, &wp);
ddrhook1_d3d9_calc_win_size_with_framed(hWnd, X, Y, cx, cy, &wp);
return real_SetWindowPos(
hWnd, hWndInsertAfter, wp.x, wp.y, wp.cx, wp.cy, uFlags);
@ -125,7 +125,7 @@ static BOOL STDCALL my_SetWindowPos(
static LONG STDCALL my_ChangeDisplaySettingsExA(
char *dev_name, DEVMODE *dev_mode, HWND hwnd, DWORD flags, void *param)
{
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
return DISP_CHANGE_SUCCESSFUL;
}
@ -136,22 +136,22 @@ static LONG STDCALL my_ChangeDisplaySettingsExA(
/* ------------------------------------------------------------------------- */
static void
ddrhookx_d3d9_log_config(const struct ddrhookx_d3d9_config *config)
ddrhook1_d3d9_log_config(const struct ddrhook1_d3d9_config *config)
{
log_misc(
"ddrhookx_d3d9_config\n"
"ddrhook1_d3d9_config\n"
"windowed: %d\n",
config->windowed);
}
void ddrhookx_d3d9_init_config(struct ddrhookx_d3d9_config *config)
void ddrhook1_d3d9_init_config(struct ddrhook1_d3d9_config *config)
{
config->windowed = false;
}
void ddrhookx_d3d9_hook_init()
void ddrhook1_d3d9_hook_init()
{
ddrhookx_d3d9_init_config(&ddrhookx_d3d9_config);
ddrhook1_d3d9_init_config(&ddrhook1_d3d9_config);
hook_table_apply(
NULL, "user32.dll", misc_user32_syms, lengthof(misc_user32_syms));
@ -161,25 +161,25 @@ void ddrhookx_d3d9_hook_init()
/* ------------------------------------------------------------------------- */
void ddrhookx_d3d9_configure(
const struct ddrhookx_d3d9_config *config)
void ddrhook1_d3d9_configure(
const struct ddrhook1_d3d9_config *config)
{
log_assert(config);
ddrhookx_d3d9_log_config(config);
ddrhook1_d3d9_log_config(config);
memcpy(
&ddrhookx_d3d9_config,
&ddrhook1_d3d9_config,
config,
sizeof(struct ddrhookx_d3d9_config));
sizeof(struct ddrhook1_d3d9_config));
}
static void ddrhookx_d3d9_patch_window(struct hook_d3d9_irp *irp)
static void ddrhook1_d3d9_patch_window(struct hook_d3d9_irp *irp)
{
log_assert(irp);
log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX);
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
/* use a different style */
irp->args.create_window_ex.style |= WS_OVERLAPPEDWINDOW;
@ -189,18 +189,18 @@ static void ddrhookx_d3d9_patch_window(struct hook_d3d9_irp *irp)
}
static void
ddrhookx_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp *irp)
ddrhook1_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp *irp)
{
log_assert(irp);
log_assert(irp->op == HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX);
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
/* we have to adjust the window size, because the window needs to be a
slightly bigger than the rendering resolution (window caption and
stuff is included in the window size) */
WINDOWPOS wp;
ddrhookx_d3d9_calc_win_size_with_framed(
ddrhook1_d3d9_calc_win_size_with_framed(
irp->args.create_window_ex.result,
irp->args.create_window_ex.x,
irp->args.create_window_ex.y,
@ -218,34 +218,34 @@ ddrhookx_d3d9_fix_window_size_and_pos(struct hook_d3d9_irp *irp)
}
}
static void ddrhookx_d3d9_create_device_apply_window_mode(
static void ddrhook1_d3d9_create_device_apply_window_mode(
struct hook_d3d9_irp *irp)
{
log_assert(irp);
log_assert(irp->op == HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE);
D3DPRESENT_PARAMETERS *pp = irp->args.ctx_create_device.pp;
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
pp->Windowed = TRUE;
pp->FullScreen_RefreshRateInHz = 0;
}
}
static void ddrhookx_d3d9_reset_apply_window_mode(
static void ddrhook1_d3d9_reset_apply_window_mode(
struct hook_d3d9_irp *irp)
{
log_assert(irp);
log_assert(irp->op == HOOK_D3D9_IRP_OP_DEV_RESET);
D3DPRESENT_PARAMETERS *pp = irp->args.dev_reset.pp;
if (ddrhookx_d3d9_config.windowed) {
if (ddrhook1_d3d9_config.windowed) {
pp->Windowed = TRUE;
pp->FullScreen_RefreshRateInHz = 0;
}
}
HRESULT
ddrhookx_d3d9_irp_handler(struct hook_d3d9_irp *irp)
ddrhook1_d3d9_irp_handler(struct hook_d3d9_irp *irp)
{
HRESULT hr;
@ -253,23 +253,23 @@ ddrhookx_d3d9_irp_handler(struct hook_d3d9_irp *irp)
switch (irp->op) {
case HOOK_D3D9_IRP_OP_CREATE_WINDOW_EX:
ddrhookx_d3d9_patch_window(irp);
ddrhook1_d3d9_patch_window(irp);
hr = hook_d3d9_irp_invoke_next(irp);
if (hr == S_OK) {
ddrhookx_d3d9_fix_window_size_and_pos(irp);
ddrhook1_d3d9_fix_window_size_and_pos(irp);
}
return hr;
case HOOK_D3D9_IRP_OP_CTX_CREATE_DEVICE:
ddrhookx_d3d9_create_device_apply_window_mode(irp);
ddrhook1_d3d9_create_device_apply_window_mode(irp);
hr = hook_d3d9_irp_invoke_next(irp);
return hr;
case HOOK_D3D9_IRP_OP_DEV_RESET:
ddrhookx_d3d9_reset_apply_window_mode(irp);
ddrhook1_d3d9_reset_apply_window_mode(irp);
hr = hook_d3d9_irp_invoke_next(irp);
return hr;

18
src/main/ddrhook1/d3d9.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef DDRHOOK1_D3D9_H
#define DDRHOOK1_D3D9_H
#include <stdbool.h>
#include <stdint.h>
#include "hook/d3d9.h"
struct ddrhook1_d3d9_config {
bool windowed;
};
void ddrhook1_d3d9_hook_init();
void ddrhook1_d3d9_configure(
const struct ddrhook1_d3d9_config *config);
HRESULT ddrhook1_d3d9_irp_handler(struct hook_d3d9_irp *irp);
#endif

View File

@ -1,4 +1,4 @@
LIBRARY ddrhookx
LIBRARY ddrhook1
EXPORTS
DllMain@12 @1 NONAME

View File

@ -13,14 +13,14 @@
#include "ddrhook-util/spike.h"
#include "ddrhook-util/usbmem.h"
#include "ddrhookx/avs-boot.h"
#include "ddrhookx/config-ddrhookx.h"
#include "ddrhookx/config-eamuse.h"
#include "ddrhookx/config-gfx.h"
#include "ddrhookx/config-security.h"
#include "ddrhookx/d3d9.h"
#include "ddrhookx/filesystem.h"
#include "ddrhookx/master.h"
#include "ddrhook1/avs-boot.h"
#include "ddrhook1/config-ddrhook1.h"
#include "ddrhook1/config-eamuse.h"
#include "ddrhook1/config-gfx.h"
#include "ddrhook1/config-security.h"
#include "ddrhook1/d3d9.h"
#include "ddrhook1/filesystem.h"
#include "ddrhook1/master.h"
#include "hook/iohook.h"
#include "hook/process.h"
@ -39,10 +39,10 @@
#include "util/log.h"
#include "util/thread.h"
#define DDRHOOKX_INFO_HEADER \
#define DDRHOOK1_INFO_HEADER \
"ddrhookx for DDR X" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
#define DDRHOOKX_CMD_USAGE \
#define DDRHOOK1_CMD_USAGE \
"Usage: inject.exe ddrhookx.dll <ddr.exe> [options...]"
bool standard_def;
@ -51,22 +51,22 @@ bool _15khz;
static DWORD STDCALL my_main();
static DWORD(STDCALL *real_main)();
static const hook_d3d9_irp_handler_t ddrhookx_d3d9_handlers[] = {
ddrhookx_d3d9_irp_handler,
static const hook_d3d9_irp_handler_t ddrhook1_d3d9_handlers[] = {
ddrhook1_d3d9_irp_handler,
};
static bool ddrhookx_init_check = false;
static bool ddrhook1_init_check = false;
static void ddrhookx_setup_d3d9_hooks(
const struct ddrhookx_config_gfx *config_gfx)
static void ddrhook1_setup_d3d9_hooks(
const struct ddrhook1_config_gfx *config_gfx)
{
struct ddrhookx_d3d9_config d3d9_config;
struct ddrhook1_d3d9_config d3d9_config;
d3d9_config.windowed = config_gfx->windowed;
ddrhookx_d3d9_configure(&d3d9_config);
ddrhook1_d3d9_configure(&d3d9_config);
hook_d3d9_init(ddrhookx_d3d9_handlers, lengthof(ddrhookx_d3d9_handlers));
hook_d3d9_init(ddrhook1_d3d9_handlers, lengthof(ddrhook1_d3d9_handlers));
}
static DWORD STDCALL my_main()
@ -74,47 +74,47 @@ static DWORD STDCALL my_main()
bool ok;
struct cconfig *config;
struct ddrhookx_config_ddrhookx config_ddrhookx;
struct ddrhookx_config_eamuse config_eamuse;
struct ddrhookx_config_gfx config_gfx;
struct ddrhookx_config_security config_security;
struct ddrhook1_config_ddrhookx config_ddrhookx;
struct ddrhook1_config_eamuse config_eamuse;
struct ddrhook1_config_gfx config_gfx;
struct ddrhook1_config_security config_security;
if (ddrhookx_init_check)
if (ddrhook1_init_check)
goto skip;
log_info("--- Begin ddrhookx GetModuleFileNameA ---");
ddrhookx_init_check = true;
ddrhook1_init_check = true;
config = cconfig_init();
ddrhookx_config_ddrhookx_init(config);
ddrhookx_config_eamuse_init(config);
ddrhookx_config_gfx_init(config);
ddrhookx_config_security_init(config);
ddrhook1_config_ddrhook1_init(config);
ddrhook1_config_eamuse_init(config);
ddrhook1_config_gfx_init(config);
ddrhook1_config_security_init(config);
if (!cconfig_hook_config_init(
config,
DDRHOOKX_INFO_HEADER "\n" DDRHOOKX_CMD_USAGE,
DDRHOOK1_INFO_HEADER "\n" DDRHOOK1_CMD_USAGE,
CCONFIG_CMD_USAGE_OUT_DBG)) {
cconfig_finit(config);
exit(EXIT_FAILURE);
}
ddrhookx_config_ddrhookx_get(&config_ddrhookx, config);
ddrhookx_config_eamuse_get(&config_eamuse, config);
ddrhookx_config_gfx_get(&config_gfx, config);
ddrhookx_config_security_get(&config_security, config);
ddrhook1_config_ddrhook1_get(&config_ddrhookx, config);
ddrhook1_config_eamuse_get(&config_eamuse, config);
ddrhook1_config_gfx_get(&config_gfx, config);
ddrhook1_config_security_get(&config_security, config);
cconfig_finit(config);
standard_def = config_ddrhookx.standard_def;
log_info(DDRHOOKX_INFO_HEADER);
log_info(DDRHOOK1_INFO_HEADER);
log_info("Initializing ddrhookx...");
ddrhookx_avs_boot_init();
ddrhookx_avs_boot_set_eamuse_addr(&config_eamuse.server);
ddrhook1_avs_boot_init();
ddrhook1_avs_boot_set_eamuse_addr(&config_eamuse.server);
iohook_push_handler(p3io_emu_dispatch_irp);
iohook_push_handler(extio_dispatch_irp);
@ -122,11 +122,11 @@ static DWORD STDCALL my_main()
iohook_push_handler(usbmem_dispatch_irp);
if (config_ddrhookx.use_com4_emu) {
/* See ddrhook/p3io.c for details. */
/* See ddrhook2/p3io.c for details. */
iohook_push_handler(com4_dispatch_irp);
}
ddrhookx_setup_d3d9_hooks(&config_gfx);
ddrhook1_setup_d3d9_hooks(&config_gfx);
rs232_hook_init();
@ -177,10 +177,10 @@ BOOL WINAPI DllMain(HMODULE self, DWORD reason, void *ctx)
process_hijack_startup(my_main, &real_main);
master_insert_hooks(NULL);
filesystem_hook_init();
ddrhook1_master_insert_hooks(NULL);
ddrhook1_filesystem_hook_init();
ddrhookx_d3d9_hook_init();
ddrhook1_d3d9_hook_init();
}
return TRUE;

View File

@ -22,13 +22,7 @@ static const struct hook_symbol filesystem_hook_syms[] = {
},
};
void get_launcher_path_parts(char **output_path, char **output_foldername) {
// DDR sets the current directory on boot to "D:/HDX" and then uses
// relative file paths for everything else.
// This function is a helper function to make it easier to turn a path
// into an absolute path relative to the launcher ("D:/HDX/ddr_datecode")
// and not the current working directory ("D:/HDX") so that settings
// can be saved in the same manner as every other game.
void ddrhook1_get_launcher_path_parts(char **output_path, char **output_foldername) {
char module_path[MAX_PATH];
char launcher_path[MAX_PATH];
@ -93,7 +87,7 @@ static BOOL STDCALL my_SetCurrentDirectoryA(LPCTSTR lpPathName)
if (stricmp(lpPathName, "D:/HDX") == 0
|| stricmp(lpPathName, "D:\\HDX") == 0) {
char *new_path;
get_launcher_path_parts(&new_path, NULL);
ddrhook1_get_launcher_path_parts(&new_path, NULL);
if (new_path != NULL) {
bool r = real_SetCurrentDirectoryA(new_path);
@ -106,7 +100,7 @@ static BOOL STDCALL my_SetCurrentDirectoryA(LPCTSTR lpPathName)
return real_SetCurrentDirectoryA(lpPathName);
}
void filesystem_hook_init()
void ddrhook1_filesystem_hook_init()
{
hook_table_apply(
NULL, "kernel32.dll", filesystem_hook_syms, lengthof(filesystem_hook_syms));

View File

@ -0,0 +1,16 @@
#ifndef DDRHOOK1_FILESYSTEM_H
#define DDRHOOK1_FILESYSTEM_H
/**
* DDR sets the current directory on boot to "D:/HDX" and then uses
* relative file paths for everything else.
* This function is a helper function to make it easier to turn a path
* into an absolute path relative to the launcher ("D:/HDX/ddr_datecode")
* and not the current working directory ("D:/HDX") so that settings
* can be saved in the same manner as every other game.
*/
char *ddrhook1_get_launcher_path_parts();
void ddrhook1_filesystem_hook_init();
#endif

View File

@ -1,4 +1,4 @@
#include "ddrhookx/master.h"
#include "ddrhook1/master.h"
#include "ddrhook-util/dinput.h"
#include "ddrhook-util/monitor.h"
@ -41,12 +41,12 @@ static HMODULE STDCALL my_LoadLibraryA(const char *name)
return result;
}
master_insert_hooks(result);
ddrhook1_master_insert_hooks(result);
return result;
}
void master_insert_hooks(HMODULE target)
void ddrhook1_master_insert_hooks(HMODULE target)
{
/* Insert all other hooks here */

View File

@ -0,0 +1,8 @@
#ifndef DDRHOOK1_MASTER_H
#define DDRHOOK1_MASTER_H
#include <windows.h>
void ddrhook1_master_insert_hooks(HMODULE target);
#endif

View File

@ -1,9 +1,9 @@
avsdlls += ddrhook
avsdlls += ddrhook2
deplibs_ddrhook := \
deplibs_ddrhook2 := \
avs \
libs_ddrhook := \
libs_ddrhook2 := \
acioemu \
ddrhook-util \
p3ioemu \
@ -14,7 +14,7 @@ libs_ddrhook := \
eamio \
ddrio \
src_ddrhook := \
src_ddrhook2 := \
dllmain.c \
master.c \

View File

@ -1,4 +1,4 @@
LIBRARY ddrhook
LIBRARY ddrhook2
EXPORTS
DllMain@12 @1 NONAME

View File

@ -12,7 +12,7 @@
#include "ddrhook-util/spike.h"
#include "ddrhook-util/usbmem.h"
#include "ddrhook/master.h"
#include "ddrhook2/master.h"
#include "hook/iohook.h"
@ -89,13 +89,13 @@ static bool my_dll_entry_init(char *sidcode, struct property_node *param)
iohook_push_handler(usbmem_dispatch_irp);
if (com4) {
/* See ddrhook/p3io.c for details. */
/* See ddrhook2/p3io.c for details. */
iohook_push_handler(com4_dispatch_irp);
}
rs232_hook_init();
master_insert_hooks(NULL);
ddrhook2_master_insert_hooks(NULL);
p3io_ddr_init();
extio_init();
usbmem_init(usbmem_data_path);

View File

@ -1,4 +1,4 @@
#include "ddrhook/master.h"
#include "ddrhook2/master.h"
#include "ddrhook-util/dinput.h"
#include "ddrhook-util/gfx.h"
@ -43,12 +43,12 @@ static HMODULE STDCALL my_LoadLibraryA(const char *name)
return result;
}
master_insert_hooks(result);
ddrhook2_master_insert_hooks(result);
return result;
}
void master_insert_hooks(HMODULE target)
void ddrhook2_master_insert_hooks(HMODULE target)
{
/* Insert all other hooks here */

View File

@ -0,0 +1,8 @@
#ifndef DDRHOOK2_MASTER_H
#define DDRHOOK2_MASTER_H
#include <windows.h>
void ddrhook2_master_insert_hooks(HMODULE target);
#endif

View File

@ -1,73 +0,0 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "ddrhookx/config-ddrhookx.h"
#include "util/log.h"
#define DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY "ddrhookx.use_com4_emu"
#define DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY "ddrhookx.standard_def"
#define DDRHOOKX_CONFIG_DDRHOOKX_USBMEM_PATH "ddrhookx.usbmem_path"
#define DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE true
#define DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE false
#define DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USBMEM_PATH "usbmem"
void ddrhookx_config_ddrhookx_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE,
"Don't emulate P3IO COM4 and its downstream devices, use the Windows COM4 port instead");
cconfig_util_set_bool(
config,
DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE,
"SD cabinet mode");
cconfig_util_set_str(
config,
DDRHOOKX_CONFIG_DDRHOOKX_USBMEM_PATH,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USBMEM_PATH,
"Specify path for USB memory data");
}
void ddrhookx_config_ddrhookx_get(
struct ddrhookx_config_ddrhookx *config_ddrhookx, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY,
&config_ddrhookx->use_com4_emu,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOKX_CONFIG_DDRHOOKX_USE_COM4_EMU_KEY,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USE_COM4_EMU_VALUE);
}
if (!cconfig_util_get_bool(
config,
DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY,
&config_ddrhookx->standard_def,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOKX_CONFIG_DDRHOOKX_STANDARD_DEF_KEY,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_STANDARD_DEF_VALUE);
}
if (!cconfig_util_get_str(
config,
DDRHOOKX_CONFIG_DDRHOOKX_USBMEM_PATH,
config_ddrhookx->usbmem_path,
sizeof(config_ddrhookx->usbmem_path) - 1,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USBMEM_PATH)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
DDRHOOKX_CONFIG_DDRHOOKX_USBMEM_PATH,
DDRHOOKX_CONFIG_DDRHOOKX_DEFAULT_USBMEM_PATH);
}
}

View File

@ -1,36 +0,0 @@
#include <string.h>
#include "cconfig/cconfig-util.h"
#include "ddrhookx/config-gfx.h"
#include "util/log.h"
#define DDRHOOKX_CONFIG_GFX_WINDOWED_KEY "gfx.windowed"
#define DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE true
void ddrhookx_config_gfx_init(struct cconfig *config)
{
cconfig_util_set_bool(
config,
DDRHOOKX_CONFIG_GFX_WINDOWED_KEY,
DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE,
"Run the game windowed");
}
void ddrhookx_config_gfx_get(
struct ddrhookx_config_gfx *config_gfx, struct cconfig *config)
{
if (!cconfig_util_get_bool(
config,
DDRHOOKX_CONFIG_GFX_WINDOWED_KEY,
&config_gfx->windowed,
DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
DDRHOOKX_CONFIG_GFX_WINDOWED_KEY,
DDRHOOKX_CONFIG_GFX_DEFAULT_WINDOWED_VALUE);
}
}

View File

@ -1,18 +0,0 @@
#ifndef DDRHOOKX_D3D9_H
#define DDRHOOKX_D3D9_H
#include <stdbool.h>
#include <stdint.h>
#include "hook/d3d9.h"
struct ddrhookx_d3d9_config {
bool windowed;
};
void ddrhookx_d3d9_hook_init();
void ddrhookx_d3d9_configure(
const struct ddrhookx_d3d9_config *config);
HRESULT ddrhookx_d3d9_irp_handler(struct hook_d3d9_irp *irp);
#endif

View File

@ -1,8 +0,0 @@
#ifndef DDRHOOKX_FILESYSTEM_H
#define DDRHOOKX_FILESYSTEM_H
char *get_launcher_path_parts();
void filesystem_hook_init();
#endif

View File

@ -1,8 +0,0 @@
#ifndef DDRHOOK_MASTER_H
#define DDRHOOK_MASTER_H
#include <windows.h>
void master_insert_hooks(HMODULE target);
#endif