diff --git a/src/main/core/config-ext.c b/src/main/core/config-ext.c index 51efe63..6b01605 100644 --- a/src/main/core/config-ext.c +++ b/src/main/core/config-ext.c @@ -1,6 +1,9 @@ #include "iface-core/config.h" #include "iface-core/log.h" +#include "security/id.h" +#include "security/mcode.h" + #include "util/net.h" void bt_core_config_ext_s8_get( @@ -131,6 +134,28 @@ void bt_core_config_ext_net_addr_get(const bt_core_config_t *config, const char } } +void bt_core_config_ext_security_id_get(const bt_core_config_t *config, const char *path, security_id_t *id) +{ + char buffer[16]; + + bt_core_config_ext_bin_get(config, path, buffer, sizeof(buffer)); + + if (!security_id_parse(buffer, id)) { + log_fatal("Cannot parse security id: %s", buffer); + } +} + +void bt_core_config_ext_security_mcode_get(const bt_core_config_t *config, const char *path, security_mcode_t *mcode) +{ + char buffer[16]; + + bt_core_config_ext_str_get(config, path, buffer, sizeof(buffer)); + + if (!security_mcode_parse(buffer, mcode)) { + log_fatal("Cannot parse security mcode: %s", buffer); + } +} + bool bt_core_config_ext_s8_optional_get( const bt_core_config_t *config, const char *path, int8_t *value) { @@ -393,5 +418,41 @@ bool bt_core_config_ext_net_addr_optional_get(const bt_core_config_t *config, co log_fatal("Cannot parse server address: %s", buffer); } + return true; +} + +bool bt_core_config_ext_security_id_optional_get(const bt_core_config_t *config, const char *path, security_id_t *id) +{ + char buffer[16]; + bool result; + + result = bt_core_config_ext_bin_optional_get(config, path, buffer, sizeof(buffer)); + + if (!result) { + return false; + } + + if (!security_id_parse(buffer, id)) { + log_fatal("Cannot parse security id: %s", buffer); + } + + return true; +} + +bool bt_core_config_ext_security_mcode_optional_get(const bt_core_config_t *config, const char *path, security_mcode_t *mcode) +{ + char buffer[16]; + bool result; + + result = bt_core_config_ext_str_optional_get(config, path, buffer, sizeof(buffer)); + + if (!result) { + return false; + } + + if (!security_mcode_parse(buffer, mcode)) { + log_fatal("Cannot parse security mcode: %s", buffer); + } + return true; } \ No newline at end of file diff --git a/src/main/core/config-ext.h b/src/main/core/config-ext.h index e6063ce..7208625 100644 --- a/src/main/core/config-ext.h +++ b/src/main/core/config-ext.h @@ -3,6 +3,9 @@ #include "iface-core/config.h" +#include "security/id.h" +#include "security/mcode.h" + #include "util/net.h" void bt_core_config_ext_s8_get( @@ -32,6 +35,8 @@ void bt_core_config_ext_bin_get( void bt_core_config_ext_str_get( const bt_core_config_t *config, const char *path, char *value, size_t len); void bt_core_config_ext_net_addr_get(const bt_core_config_t *config, const char *path, struct net_addr *addr); +void bt_core_config_ext_security_id_get(const bt_core_config_t *config, const char *path, security_id_t *id); +void bt_core_config_ext_security_mcode_get(const bt_core_config_t *config, const char *path, security_mcode_t *mcode); bool bt_core_config_ext_s8_optional_get( const bt_core_config_t *config, const char *path, int8_t *value); @@ -60,5 +65,7 @@ bool bt_core_config_ext_bin_optional_get( bool bt_core_config_ext_str_optional_get( const bt_core_config_t *config, const char *path, char *value, size_t len); bool bt_core_config_ext_net_addr_optional_get(const bt_core_config_t *config, const char *path, struct net_addr *addr); +bool bt_core_config_ext_security_id_optional_get(const bt_core_config_t *config, const char *path, security_id_t *id); +bool bt_core_config_ext_security_mcode_optional_get(const bt_core_config_t *config, const char *path, security_mcode_t *mcode); #endif \ No newline at end of file diff --git a/src/main/iidxhook8/Module.mk b/src/main/iidxhook8/Module.mk index 170dcf9..147c90b 100644 --- a/src/main/iidxhook8/Module.mk +++ b/src/main/iidxhook8/Module.mk @@ -31,6 +31,7 @@ libs_iidxhook8 := \ iface-core \ module \ util \ + security \ src_iidxhook8 := \ config-io.c \ diff --git a/src/main/iidxhook9/Module.mk b/src/main/iidxhook9/Module.mk index d7a8449..23b3e08 100644 --- a/src/main/iidxhook9/Module.mk +++ b/src/main/iidxhook9/Module.mk @@ -33,6 +33,7 @@ libs_iidxhook9 := \ iface-core \ module \ util \ + security \ src_iidxhook9 := \ config-io.c \ diff --git a/src/main/sdvxhook2-cn/Module.mk b/src/main/sdvxhook2-cn/Module.mk index e186e8e..5e15090 100644 --- a/src/main/sdvxhook2-cn/Module.mk +++ b/src/main/sdvxhook2-cn/Module.mk @@ -28,6 +28,7 @@ libs_sdvxhook2-cn := \ iface-io \ iface-core \ module \ + security \ src_sdvxhook2-cn := \ acio.c \ diff --git a/src/main/security/id.h b/src/main/security/id.h index 6043a44..b62d191 100644 --- a/src/main/security/id.h +++ b/src/main/security/id.h @@ -9,11 +9,11 @@ /** * Structure of a security id, e.g. PCBID or EAMID. */ -struct security_id { +typedef struct security_id { uint8_t header; uint8_t id[8]; uint8_t checksum; -}; +} security_id_t; /** * "Default" security id with updated header and cheacksum ready for use. diff --git a/src/main/security/mcode.h b/src/main/security/mcode.h index a58f860..a46f1f7 100644 --- a/src/main/security/mcode.h +++ b/src/main/security/mcode.h @@ -83,7 +83,7 @@ * Structure to represent a Konami mcode which is used to identify games and * different hardware/software revisions. */ -struct security_mcode { +typedef struct security_mcode { char header; char unkn; /* Identify the game and version, e.g. IIDX 12 */ @@ -91,7 +91,7 @@ struct security_mcode { char region; char cabinet; char revision; -}; +} security_mcode_t; /** * Default mcode used to identify white eamuse roundplugs.