Apply clang-format code style to all source files

This commit is contained in:
icex2
2019-10-20 00:50:40 +02:00
parent c600e1a423
commit c3bc8782f4
401 changed files with 13844 additions and 11361 deletions
+19 -18
View File
@@ -1,8 +1,8 @@
#include <windows.h>
#include <ntdef.h>
#include <devioctl.h>
#include <ntddser.h>
#include <ntdef.h>
#include <stdbool.h>
#include <stdint.h>
@@ -42,7 +42,8 @@ void ac_io_port_fini(void)
ac_io_emu_fini(&ac_io_emu);
}
HRESULT ac_io_port_dispatch_irp(struct irp *irp)
HRESULT
ac_io_port_dispatch_irp(struct irp *irp)
{
const struct ac_io_message *msg;
HRESULT hr;
@@ -63,31 +64,31 @@ HRESULT ac_io_port_dispatch_irp(struct irp *irp)
msg = ac_io_emu_request_peek(&ac_io_emu);
switch (msg->addr) {
case 0:
ac_io_emu_cmd_assign_addrs(&ac_io_emu, msg, 2);
case 0:
ac_io_emu_cmd_assign_addrs(&ac_io_emu, msg, 2);
break;
break;
case 1:
ac_io_emu_icca_dispatch_request(&ac_io_emu_icca, msg);
case 1:
ac_io_emu_icca_dispatch_request(&ac_io_emu_icca, msg);
break;
break;
case 2:
ac_io_emu_h44b_dispatch_request(&ac_io_emu_h44b, msg);
case 2:
ac_io_emu_h44b_dispatch_request(&ac_io_emu_h44b, msg);
break;
break;
case AC_IO_BROADCAST:
log_warning("Broadcast(?) message on jubeat ACIO bus?");
case AC_IO_BROADCAST:
log_warning("Broadcast(?) message on jubeat ACIO bus?");
break;
break;
default:
log_warning("ACIO message on unhandled bus address: %d",
msg->addr);
default:
log_warning(
"ACIO message on unhandled bus address: %d", msg->addr);
break;
break;
}
ac_io_emu_request_pop(&ac_io_emu);
+65 -51
View File
@@ -14,47 +14,49 @@
#include "util/log.h"
static void (*real_avs_boot)(
struct property_node *config, void *std_heap, size_t sz_std_heap,
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
void *log_context);
struct property_node *config,
void *std_heap,
size_t sz_std_heap,
void *avs_heap,
size_t sz_avs_heap,
avs_log_writer_t log_writer,
void *log_context);
static int (*real_log_change_level)(int level);
static int (*real_ea3_boot)(struct property_node *config);
static void my_avs_boot(
struct property_node *config, void *std_heap, size_t sz_std_heap,
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
void *log_context);
struct property_node *config,
void *std_heap,
size_t sz_std_heap,
void *avs_heap,
size_t sz_avs_heap,
avs_log_writer_t log_writer,
void *log_context);
static int my_log_change_level(int level);
static int my_ea3_boot(struct property_node *config);
static struct net_addr jbhook1_avs_boot_eamuse_server_addr;
static const struct hook_symbol jbhook1_log_gftools_hook_syms[] = {
{
.name = "avs_boot",
.patch = my_avs_boot,
.link = (void **) &real_avs_boot
},
{
.name = "log_change_level",
.patch = my_log_change_level,
.link = (void **) &real_log_change_level
},
{.name = "avs_boot",
.patch = my_avs_boot,
.link = (void **) &real_avs_boot},
{.name = "log_change_level",
.patch = my_log_change_level,
.link = (void **) &real_log_change_level},
};
static const struct hook_symbol jbhook1_log_gftools_hook_syms2[] = {
{
.name = "ea3_boot",
.patch = my_ea3_boot,
.link = (void **) &real_ea3_boot
},
{.name = "ea3_boot",
.patch = my_ea3_boot,
.link = (void **) &real_ea3_boot},
};
static void avs_boot_replace_property_uint32(struct property_node* node,
const char* name, uint32_t val)
static void avs_boot_replace_property_uint32(
struct property_node *node, const char *name, uint32_t val)
{
struct property_node* tmp;
struct property_node *tmp;
tmp = property_search(NULL, node, name);
if (tmp) {
@@ -64,11 +66,11 @@ static void avs_boot_replace_property_uint32(struct property_node* node,
property_node_create(NULL, node, PSMAP_TYPE_U32, name, val);
}
static void avs_boot_replace_property_str(struct property_node* node,
const char* name, const char* val)
static void avs_boot_replace_property_str(
struct property_node *node, const char *name, const char *val)
{
struct property_node* tmp;
struct property_node *tmp;
tmp = property_search(NULL, node, name);
if (tmp) {
@@ -83,25 +85,35 @@ static void avs_boot_replace_property_str(struct property_node* node,
}
static void my_avs_boot(
struct property_node *config, void *std_heap, size_t sz_std_heap,
void *avs_heap, size_t sz_avs_heap, avs_log_writer_t log_writer,
void *log_context)
struct property_node *config,
void *std_heap,
size_t sz_std_heap,
void *avs_heap,
size_t sz_avs_heap,
avs_log_writer_t log_writer,
void *log_context)
{
log_info("Called my_avs_boot");
avs_boot_replace_property_uint32(config, "log/level", 4);
avs_boot_replace_property_str(config, "/config/fs/nvram/device",
"./CONF/NVRAM");
avs_boot_replace_property_str(config, "/config/fs/raw/device",
"./CONF/RAW");
real_avs_boot(config, std_heap, sz_std_heap, avs_heap, sz_avs_heap,
log_writer_debug, NULL);
avs_boot_replace_property_str(
config, "/config/fs/nvram/device", "./CONF/NVRAM");
avs_boot_replace_property_str(
config, "/config/fs/raw/device", "./CONF/RAW");
real_avs_boot(
config,
std_heap,
sz_std_heap,
avs_heap,
sz_avs_heap,
log_writer_debug,
NULL);
}
static int my_ea3_boot(struct property_node *config)
{
char* server_addr;
char *server_addr;
log_info("Called my_ea3_boot");
@@ -128,30 +140,32 @@ static int my_log_change_level(int level)
void jbhook1_avs_boot_init()
{
hook_table_apply(
NULL,
"libavs-win32.dll",
jbhook1_log_gftools_hook_syms,
lengthof(jbhook1_log_gftools_hook_syms));
NULL,
"libavs-win32.dll",
jbhook1_log_gftools_hook_syms,
lengthof(jbhook1_log_gftools_hook_syms));
hook_table_apply(
NULL,
"libavs-win32-ea3.dll",
jbhook1_log_gftools_hook_syms2,
lengthof(jbhook1_log_gftools_hook_syms2));
NULL,
"libavs-win32-ea3.dll",
jbhook1_log_gftools_hook_syms2,
lengthof(jbhook1_log_gftools_hook_syms2));
memset(&jbhook1_avs_boot_eamuse_server_addr, 0, sizeof(struct net_addr));
log_info("Inserted avs log hooks");
}
void jbhook1_avs_boot_set_eamuse_addr(const struct net_addr* server_addr)
void jbhook1_avs_boot_set_eamuse_addr(const struct net_addr *server_addr)
{
char* str;
char *str;
str = net_addr_to_str(server_addr);
log_info("Setting eamuse server: %s", str);
free(str);
memcpy(&jbhook1_avs_boot_eamuse_server_addr, server_addr,
memcpy(
&jbhook1_avs_boot_eamuse_server_addr,
server_addr,
sizeof(struct net_addr));
}
+2 -2
View File
@@ -11,9 +11,9 @@ void jbhook1_avs_boot_init();
/**
* Set the target eamuse server address.
*
*
* @param server_addr Address to target eamuse server.
*/
void jbhook1_avs_boot_set_eamuse_addr(const struct net_addr* server_addr);
void jbhook1_avs_boot_set_eamuse_addr(const struct net_addr *server_addr);
#endif
+78 -45
View File
@@ -13,9 +13,11 @@
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE "localhost:80"
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE security_id_default
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN sizeof(security_id_default)
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN \
sizeof(security_id_default)
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE security_id_default
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN sizeof(security_id_default)
#define JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN \
sizeof(security_id_default)
const struct net_addr jbhook1_eamuse_default_server = {
.type = NET_ADDR_TYPE_HOSTNAME,
@@ -23,88 +25,119 @@ const struct net_addr jbhook1_eamuse_default_server = {
.hostname.port = 80,
};
void jbhook1_config_eamuse_init(struct cconfig* config)
void jbhook1_config_eamuse_init(struct cconfig *config)
{
cconfig_util_set_str(config,
cconfig_util_set_str(
config,
JBHOOK1_CONFIG_EAMUSE_SERVER_KEY,
JBHOOK1_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 "
"(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, JBHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t*) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN, "PCBID");
cconfig_util_set_data(
config,
JBHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
"PCBID");
cconfig_util_set_data(config, JBHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t*) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN, "EAMID");
cconfig_util_set_data(
config,
JBHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
"EAMID");
}
void jbhook1_config_eamuse_get(struct jbhook1_config_eamuse* config_eamuse,
struct cconfig* config)
void jbhook1_config_eamuse_get(
struct jbhook1_config_eamuse *config_eamuse, struct cconfig *config)
{
char server_url[1024];
char* tmp;
char* tmp2;
char *tmp;
char *tmp2;
memset(config_eamuse, 0, sizeof(struct jbhook1_config_eamuse));
if (!cconfig_util_get_str(config, JBHOOK1_CONFIG_EAMUSE_SERVER_KEY,
server_url, sizeof(server_url),
if (!cconfig_util_get_str(
config,
JBHOOK1_CONFIG_EAMUSE_SERVER_KEY,
server_url,
sizeof(server_url),
JBHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE)) {
log_warning("Invalid value for key '%s' specified, fallback "
"to default '%s'", JBHOOK1_CONFIG_EAMUSE_SERVER_KEY,
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
JBHOOK1_CONFIG_EAMUSE_SERVER_KEY,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_SERVER_VALUE);
}
if (!net_str_parse(server_url, &config_eamuse->server)) {
memcpy(&config_eamuse->server, &jbhook1_eamuse_default_server,
memcpy(
&config_eamuse->server,
&jbhook1_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);
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default",
tmp);
free(tmp);
}
if (!cconfig_util_get_data(config, JBHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t*) &config_eamuse->pcbid,
if (!cconfig_util_get_data(
config,
JBHOOK1_CONFIG_EAMUSE_PCBID_KEY,
(uint8_t *) &config_eamuse->pcbid,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE_LEN,
(uint8_t*) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
tmp = security_id_to_str(&JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
false);
log_warning("Invalid value for key '%s' specified, fallback "
"to default", tmp);
(uint8_t *) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE)) {
tmp = security_id_to_str(
&JBHOOK1_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(&JBHOOK1_CONFIG_EAMUSE_DEFAULT_PCBID_VALUE,
false);
tmp = security_id_to_str(
&JBHOOK1_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);
log_warning(
"PCBID verification of '%s' failed, fallback to default "
"PCBID '%s'",
tmp2,
tmp);
free(tmp);
free(tmp2);
}
if (!cconfig_util_get_data(config, JBHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t*) &config_eamuse->eamid,
if (!cconfig_util_get_data(
config,
JBHOOK1_CONFIG_EAMUSE_EAMID_KEY,
(uint8_t *) &config_eamuse->eamid,
JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE_LEN,
(uint8_t*) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
tmp = security_id_to_str(&JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
false);
log_warning("Invalid value for key '%s' specified, fallback "
"to default", tmp);
(uint8_t *) &JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE)) {
tmp = security_id_to_str(
&JBHOOK1_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(&JBHOOK1_CONFIG_EAMUSE_DEFAULT_EAMID_VALUE,
false);
tmp = security_id_to_str(
&JBHOOK1_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);
log_warning(
"EAMID verification of '%s' failed, fallback to default "
"EAMID '%s'",
tmp2,
tmp);
free(tmp);
free(tmp2);
}
+4 -4
View File
@@ -20,17 +20,17 @@ struct jbhook1_config_eamuse {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void jbhook1_config_eamuse_init(struct cconfig* config);
void jbhook1_config_eamuse_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
* struct.
*
*
* @param config_eamuse Target module specific struct to read configuration
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void jbhook1_config_eamuse_get(struct jbhook1_config_eamuse* config_eamuse,
struct cconfig* config);
void jbhook1_config_eamuse_get(
struct jbhook1_config_eamuse *config_eamuse, struct cconfig *config);
#endif
+12 -7
View File
@@ -10,22 +10,27 @@
#define JBHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE false
void jbhook1_config_gfx_init(struct cconfig* config)
void jbhook1_config_gfx_init(struct cconfig *config)
{
cconfig_util_set_bool(config,
cconfig_util_set_bool(
config,
JBHOOK1_CONFIG_GFX_WINDOWED_KEY,
JBHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE,
"Run the game windowed");
}
void jbhook1_config_gfx_get(struct jbhook1_config_gfx* config_gfx,
struct cconfig* config)
void jbhook1_config_gfx_get(
struct jbhook1_config_gfx *config_gfx, struct cconfig *config)
{
if (!cconfig_util_get_bool(config, JBHOOK1_CONFIG_GFX_WINDOWED_KEY,
if (!cconfig_util_get_bool(
config,
JBHOOK1_CONFIG_GFX_WINDOWED_KEY,
&config_gfx->windowed,
JBHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE)) {
log_warning("Invalid value for key '%s' specified, fallback "
"to default '%d'", JBHOOK1_CONFIG_GFX_WINDOWED_KEY,
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%d'",
JBHOOK1_CONFIG_GFX_WINDOWED_KEY,
JBHOOK1_CONFIG_GFX_DEFAULT_WINDOWED_VALUE);
}
}
+4 -4
View File
@@ -14,17 +14,17 @@ struct jbhook1_config_gfx {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void jbhook1_config_gfx_init(struct cconfig* config);
void jbhook1_config_gfx_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
* struct.
*
*
* @param config_gfx Target module specific struct to read configuration
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void jbhook1_config_gfx_get(struct jbhook1_config_gfx* config_gfx,
struct cconfig* config);
void jbhook1_config_gfx_get(
struct jbhook1_config_gfx *config_gfx, struct cconfig *config);
#endif
+28 -16
View File
@@ -11,7 +11,8 @@
#define JBHOOK1_CONFIG_SECURITY_MCODE_KEY "security.mcode"
#define JBHOOK1_CONFIG_SECURITY_DEFAULT_MCODE_VALUE jbhook1_config_security_default_mcode
#define JBHOOK1_CONFIG_SECURITY_DEFAULT_MCODE_VALUE \
jbhook1_config_security_default_mcode
static const struct security_mcode jbhook1_config_security_default_mcode = {
.header = SECURITY_MCODE_HEADER,
@@ -22,42 +23,53 @@ static const struct security_mcode jbhook1_config_security_default_mcode = {
.revision = SECURITY_MCODE_REVISION_B,
};
void jbhook1_config_security_init(struct cconfig* config)
void jbhook1_config_security_init(struct cconfig *config)
{
char* tmp;
char *tmp;
tmp = security_mcode_to_str(&JBHOOK1_CONFIG_SECURITY_DEFAULT_MCODE_VALUE);
cconfig_util_set_str(config,
cconfig_util_set_str(
config,
JBHOOK1_CONFIG_SECURITY_MCODE_KEY,
tmp,
tmp,
"Mcode of the game to run.");
free(tmp);
}
void jbhook1_config_security_get(
struct jbhook1_config_security* config_security, struct cconfig* config)
struct jbhook1_config_security *config_security, struct cconfig *config)
{
char* tmp_default;
char *tmp_default;
char mcode[9];
tmp_default =
tmp_default =
security_mcode_to_str(&JBHOOK1_CONFIG_SECURITY_DEFAULT_MCODE_VALUE);
if (!cconfig_util_get_str(config, JBHOOK1_CONFIG_SECURITY_MCODE_KEY,
mcode, sizeof(mcode) - 1, tmp_default)) {
log_warning("Invalid value for key '%s' specified, fallback "
"to default '%s'", JBHOOK1_CONFIG_SECURITY_MCODE_KEY, tmp_default);
if (!cconfig_util_get_str(
config,
JBHOOK1_CONFIG_SECURITY_MCODE_KEY,
mcode,
sizeof(mcode) - 1,
tmp_default)) {
log_warning(
"Invalid value for key '%s' specified, fallback "
"to default '%s'",
JBHOOK1_CONFIG_SECURITY_MCODE_KEY,
tmp_default);
}
mcode[8] = '\0';
if (!security_mcode_parse(mcode, &config_security->mcode)) {
log_warning("Invalid mcode '%s' specified, fallback to default '%s'",
mcode, tmp_default);
memcpy(&config_security->mcode,
log_warning(
"Invalid mcode '%s' specified, fallback to default '%s'",
mcode,
tmp_default);
memcpy(
&config_security->mcode,
&JBHOOK1_CONFIG_SECURITY_DEFAULT_MCODE_VALUE,
sizeof(struct security_mcode));
}
+3 -4
View File
@@ -18,18 +18,17 @@ struct jbhook1_config_security {
* Initialize a cconfig structure with the basic structure and default values
* of this configuration.
*/
void jbhook1_config_security_init(struct cconfig* config);
void jbhook1_config_security_init(struct cconfig *config);
/**
* Read the module specific config struct values from the provided cconfig
* struct.
*
*
* @param config_security Target module specific struct to read configuration
* values to.
* @param config cconfig struct holding the intermediate data to read from.
*/
void jbhook1_config_security_get(
struct jbhook1_config_security* config_security,
struct cconfig* config);
struct jbhook1_config_security *config_security, struct cconfig *config);
#endif
+40 -33
View File
@@ -1,8 +1,8 @@
#include <windows.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "bemanitools/eamio.h"
@@ -12,14 +12,14 @@
#include "hook/table.h"
#include "hooklib/adapter.h"
#include "hooklib/acp.h"
#include "hooklib/adapter.h"
#include "hooklib/rs232.h"
#include "jbhook1/avs-boot.h"
#include "jbhook1/acio.h"
#include "jbhook1/config-gfx.h"
#include "jbhook1/avs-boot.h"
#include "jbhook1/config-eamuse.h"
#include "jbhook1/config-gfx.h"
#include "jbhook1/config-security.h"
#include "jbhook1/log-gftools.h"
#include "jbhook1/p3io.h"
@@ -32,7 +32,7 @@
#include "util/thread.h"
#define JBHOOK1_INFO_HEADER \
"jbhook1 for jubeat" \
"jbhook1 for jubeat" \
", build " __DATE__ " " __TIME__ ", gitrev " STRINGIFY(GITREV)
#define JBHOOK1_CMD_USAGE \
"Usage: inject.exe jbhook1.dll <jubeat.exe> [options...]"
@@ -42,28 +42,32 @@ static const irp_handler_t jbhook1_handlers[] = {
ac_io_port_dispatch_irp,
};
static HWND CDECL my_mwindow_create(HINSTANCE, void*, const char*, DWORD,
DWORD, BOOL);
static HWND (CDECL *real_mwindow_create)(HINSTANCE, void*, const char*, DWORD,
DWORD, BOOL);
static HWND CDECL
my_mwindow_create(HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
static HWND(CDECL *real_mwindow_create)(
HINSTANCE, void *, const char *, DWORD, DWORD, BOOL);
static const struct hook_symbol init_hook_syms[] = {
{
.name = "mwindow_create",
.patch = my_mwindow_create,
.link = (void **) &real_mwindow_create,
.name = "mwindow_create",
.patch = my_mwindow_create,
.link = (void **) &real_mwindow_create,
},
};
/**
* This seems to be a good entry point to intercept before the game calls
* This seems to be a good entry point to intercept before the game calls
* anything important (very close to the start of WinMain).
*/
static HWND CDECL my_mwindow_create(HINSTANCE hinstance, void* callback,
const char* window_title, DWORD window_width, DWORD window_height,
BOOL fullscreen)
static HWND CDECL my_mwindow_create(
HINSTANCE hinstance,
void *callback,
const char *window_title,
DWORD window_width,
DWORD window_height,
BOOL fullscreen)
{
struct cconfig* config;
struct cconfig *config;
struct jbhook1_config_gfx config_gfx;
struct jbhook1_config_eamuse config_eamuse;
@@ -79,7 +83,10 @@ static HWND CDECL my_mwindow_create(HINSTANCE hinstance, void* callback,
jbhook1_config_eamuse_init(config);
jbhook1_config_security_init(config);
if (!cconfig_hook_config_init(config, JBHOOK1_INFO_HEADER "\n" JBHOOK1_CMD_USAGE, CCONFIG_CMD_USAGE_OUT_DBG)) {
if (!cconfig_hook_config_init(
config,
JBHOOK1_INFO_HEADER "\n" JBHOOK1_CMD_USAGE,
CCONFIG_CMD_USAGE_OUT_DBG)) {
cconfig_finit(config);
exit(EXIT_FAILURE);
}
@@ -101,8 +108,8 @@ static HWND CDECL my_mwindow_create(HINSTANCE hinstance, void* callback,
log_info("Starting up jubeat IO backend");
jb_io_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
log_impl_fatal);
jb_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
if (!jb_io_init(thread_create, thread_join, thread_destroy)) {
log_fatal("Initializing jb IO backend failed");
@@ -110,8 +117,8 @@ static HWND CDECL my_mwindow_create(HINSTANCE hinstance, void* callback,
log_info("Starting up card reader backend");
eam_io_set_loggers(log_impl_misc, log_impl_info, log_impl_warning,
log_impl_fatal);
eam_io_set_loggers(
log_impl_misc, log_impl_info, log_impl_warning, log_impl_fatal);
if (!eam_io_init(thread_create, thread_join, thread_destroy)) {
log_fatal("Initializing card reader backend failed");
@@ -123,15 +130,20 @@ static HWND CDECL my_mwindow_create(HINSTANCE hinstance, void* callback,
ac_io_port_init();
p3io_setupapi_insert_hooks(NULL);
jbhook1_p3io_init(&config_security.mcode, &config_eamuse.pcbid,
&config_eamuse.eamid);
jbhook1_p3io_init(
&config_security.mcode, &config_eamuse.pcbid, &config_eamuse.eamid);
log_info("-------------------------------------------------------------");
log_info("----------------- End jbhook mwindow_create -----------------");
log_info("-------------------------------------------------------------");
return real_mwindow_create(hinstance, callback, window_title, window_width,
window_height, fullscreen);
return real_mwindow_create(
hinstance,
callback,
window_title,
window_width,
window_height,
fullscreen);
}
/**
@@ -141,7 +153,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
{
if (reason == DLL_PROCESS_ATTACH) {
#ifdef DEBUG_HOOKING
FILE* file = fopen("jbhook.dllmain.log", "w+");
FILE *file = fopen("jbhook.dllmain.log", "w+");
log_to_writer(log_writer_file, file);
#else
log_to_writer(log_writer_null, NULL);
@@ -150,11 +162,7 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
/* Bootstrap hook for further init tasks (see above) */
hook_table_apply(
NULL,
"mwindow.dll",
init_hook_syms,
lengthof(init_hook_syms));
NULL, "mwindow.dll", init_hook_syms, lengthof(init_hook_syms));
/* Actual hooks for game specific stuff */
@@ -172,4 +180,3 @@ BOOL WINAPI DllMain(HMODULE mod, DWORD reason, void *ctx)
return TRUE;
}
+25 -15
View File
@@ -9,22 +9,32 @@
#include "util/log.h"
static int CDECL my_GFReportPuts(int level, const char* source_file, int a3,
const char* func, const char* msg);
static int CDECL my_GFReportPuts(
int level,
const char *source_file,
int a3,
const char *func,
const char *msg);
static int (CDECL *real_GFReportPuts)(int level, const char* source_file,
int a3, const char* func, const char* msg);
static int(CDECL *real_GFReportPuts)(
int level,
const char *source_file,
int a3,
const char *func,
const char *msg);
static const struct hook_symbol jbhook1_log_gftools_hook_syms[] = {
{
.name = "GFReportPuts",
.patch = my_GFReportPuts,
.link = (void **) &real_GFReportPuts
},
{.name = "GFReportPuts",
.patch = my_GFReportPuts,
.link = (void **) &real_GFReportPuts},
};
static int CDECL my_GFReportPuts(int level, const char* source_file, int a3,
const char* func, const char* msg)
static int CDECL my_GFReportPuts(
int level,
const char *source_file,
int a3,
const char *func,
const char *msg)
{
log_misc("[%d][%s][%d][%s]: %s", level, source_file, a3, func, msg);
@@ -34,10 +44,10 @@ static int CDECL my_GFReportPuts(int level, const char* source_file, int a3,
void jbhook1_log_gftools_init(void)
{
hook_table_apply(
NULL,
"gftools.dll",
jbhook1_log_gftools_hook_syms,
lengthof(jbhook1_log_gftools_hook_syms));
NULL,
"gftools.dll",
jbhook1_log_gftools_hook_syms,
lengthof(jbhook1_log_gftools_hook_syms));
log_info("Inserted gftools log hooks");
}
+19 -11
View File
@@ -10,14 +10,14 @@
#include "p3ioemu/emu.h"
#include "p3ioemu/uart.h"
#include "security/rp3.h"
#include "security/rp-sign-key.h"
#include "security/rp3.h"
#include "util/log.h"
static HRESULT jbhook1_p3io_read_jamma(void *ctx, uint32_t *state);
static HRESULT jbhook1_p3io_get_roundplug(void *ctx, uint8_t plug_id,
uint8_t* rom, uint8_t* eeprom);
static HRESULT jbhook1_p3io_get_roundplug(
void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom);
/*
0:0 b13
@@ -90,8 +90,10 @@ static const struct p3io_ops p3io_ddr_ops = {
.get_roundplug = jbhook1_p3io_get_roundplug,
};
void jbhook1_p3io_init(const struct security_mcode* mcode,
const struct security_id* pcbid, const struct security_id* eamid)
void jbhook1_p3io_init(
const struct security_mcode *mcode,
const struct security_id *pcbid,
const struct security_id *eamid)
{
memcpy(&jbhook1_p3io_mcode, mcode, sizeof(struct security_mcode));
memcpy(&jbhook1_p3io_pcbid, pcbid, sizeof(struct security_id));
@@ -138,8 +140,8 @@ static HRESULT jbhook1_p3io_read_jamma(void *ctx, uint32_t *state)
return S_OK;
}
static HRESULT jbhook1_p3io_get_roundplug(void *ctx, uint8_t plug_id,
uint8_t* rom, uint8_t* eeprom)
static HRESULT jbhook1_p3io_get_roundplug(
void *ctx, uint8_t plug_id, uint8_t *rom, uint8_t *eeprom)
{
struct security_rp3_eeprom eeprom_out;
@@ -147,14 +149,20 @@ static HRESULT jbhook1_p3io_get_roundplug(void *ctx, uint8_t plug_id,
/* black */
memcpy(rom, jbhook1_p3io_pcbid.id, sizeof(jbhook1_p3io_pcbid.id));
security_rp3_generate_signed_eeprom_data(
SECURITY_RP_UTIL_RP_TYPE_BLACK, &security_rp_sign_key_black_gfdmv4,
&jbhook1_p3io_mcode, &jbhook1_p3io_pcbid, &eeprom_out);
SECURITY_RP_UTIL_RP_TYPE_BLACK,
&security_rp_sign_key_black_gfdmv4,
&jbhook1_p3io_mcode,
&jbhook1_p3io_pcbid,
&eeprom_out);
} else {
/* white */
memcpy(rom, jbhook1_p3io_eamid.id, sizeof(jbhook1_p3io_eamid.id));
security_rp3_generate_signed_eeprom_data(
SECURITY_RP_UTIL_RP_TYPE_WHITE, &security_rp_sign_key_white_eamuse,
&security_mcode_eamuse, &jbhook1_p3io_eamid, &eeprom_out);
SECURITY_RP_UTIL_RP_TYPE_WHITE,
&security_rp_sign_key_white_eamuse,
&security_mcode_eamuse,
&jbhook1_p3io_eamid,
&eeprom_out);
}
memcpy(eeprom, &eeprom_out, sizeof(struct security_rp3_eeprom));
+5 -3
View File
@@ -10,13 +10,15 @@
/**
* Initialize the jbhook1 specific p3io emulation backend.
*
*
* @param mcode Mcode of the target game to run. Required for dongle emulation.
* @param pcbid PCBDID
* @param eamid EAMID
*/
void jbhook1_p3io_init(const struct security_mcode* mcode,
const struct security_id* pcbid, const struct security_id* eamid);
void jbhook1_p3io_init(
const struct security_mcode *mcode,
const struct security_id *pcbid,
const struct security_id *eamid);
/**
* Shutdown the p3io emulation backend.