From e06be9fc7b6dd7fde35b1cd0f0fd119222f6dfd2 Mon Sep 17 00:00:00 2001 From: Tau Date: Mon, 3 Jun 2019 22:28:44 -0400 Subject: [PATCH] board/sg-reader.c: Configurate sg_reader --- board/sg-reader.c | 11 ++++++++++- board/sg-reader.h | 6 +++++- cardhook/dllmain.c | 7 ++++++- divahook/config.c | 3 +++ divahook/config.h | 1 + divahook/dllmain.c | 2 +- idzhook/config.c | 3 +++ idzhook/config.h | 3 +++ idzhook/dllmain.c | 4 ++-- 9 files changed, 34 insertions(+), 6 deletions(-) diff --git a/board/sg-reader.c b/board/sg-reader.c index d934600..55f0647 100644 --- a/board/sg-reader.c +++ b/board/sg-reader.c @@ -6,6 +6,7 @@ #include "aimeio/aimeio.h" +#include "board/config.h" #include "board/sg-led.h" #include "board/sg-nfc.h" #include "board/sg-reader.h" @@ -43,10 +44,18 @@ static uint8_t sg_reader_readable_bytes[520]; static struct sg_nfc sg_reader_nfc; static struct sg_led sg_reader_led; -HRESULT sg_reader_hook_init(unsigned int port_no) +HRESULT sg_reader_hook_init( + const struct aime_config *cfg, + unsigned int port_no) { HRESULT hr; + assert(cfg != NULL); + + if (!cfg->enable) { + return S_FALSE; + } + hr = aime_io_init(); if (FAILED(hr)) { diff --git a/board/sg-reader.h b/board/sg-reader.h index 32f0231..e1516f8 100644 --- a/board/sg-reader.h +++ b/board/sg-reader.h @@ -2,4 +2,8 @@ #include -HRESULT sg_reader_hook_init(unsigned int port_no); +#include "board/config.h" + +HRESULT sg_reader_hook_init( + const struct aime_config *cfg, + unsigned int port_no); diff --git a/cardhook/dllmain.c b/cardhook/dllmain.c index ef73638..3c979e6 100644 --- a/cardhook/dllmain.c +++ b/cardhook/dllmain.c @@ -1,5 +1,8 @@ #include +#include + +#include "board/config.h" #include "board/sg-reader.h" #include "hook/process.h" @@ -9,6 +12,8 @@ #include "util/dprintf.h" +// Emulating an AiMe reader is the only thing this hook DLL does +static const struct aime_config app_aime_config = { .enable = true }; static process_entry_t app_startup; static DWORD CALLBACK app_pre_startup(void) @@ -18,7 +23,7 @@ static DWORD CALLBACK app_pre_startup(void) spike_hook_init("cardspike.txt"); serial_hook_init(); - sg_reader_hook_init(12); + sg_reader_hook_init(&app_aime_config, 12); dprintf("--- End %s ---\n", __func__); diff --git a/divahook/config.c b/divahook/config.c index 1278469..9bc046d 100644 --- a/divahook/config.c +++ b/divahook/config.c @@ -3,6 +3,8 @@ #include "amex/config.h" +#include "board/config.h" + #include "divahook/config.h" #include "platform/config.h" @@ -16,4 +18,5 @@ void diva_hook_config_load( nu_config_load(&cfg->nu, filename); amex_config_load(&cfg->amex, filename); + aime_config_load(&cfg->aime, filename); } diff --git a/divahook/config.h b/divahook/config.h index 4e9f086..9e0a0dc 100644 --- a/divahook/config.h +++ b/divahook/config.h @@ -9,6 +9,7 @@ struct diva_hook_config { struct nu_config nu; struct amex_config amex; + struct aime_config aime; }; void diva_hook_config_load( diff --git a/divahook/dllmain.c b/divahook/dllmain.c index 4d78742..ca73607 100644 --- a/divahook/dllmain.c +++ b/divahook/dllmain.c @@ -48,7 +48,7 @@ static DWORD CALLBACK diva_pre_startup(void) diva_jvs_init(); } - sg_reader_hook_init(10); + sg_reader_hook_init(&diva_hook_cfg.aime, 10); slider_hook_init(); /* Initialize debug helpers */ diff --git a/idzhook/config.c b/idzhook/config.c index 302d8c5..034b4b4 100644 --- a/idzhook/config.c +++ b/idzhook/config.c @@ -2,6 +2,8 @@ #include "amex/config.h" +#include "board/config.h" + #include "idzhook/config.h" #include "platform/config.h" @@ -15,4 +17,5 @@ void idz_hook_config_load( nu_config_load(&cfg->nu, filename); amex_config_load(&cfg->amex, filename); + aime_config_load(&cfg->aime, filename); } diff --git a/idzhook/config.h b/idzhook/config.h index f82986e..7a5f7d4 100644 --- a/idzhook/config.h +++ b/idzhook/config.h @@ -4,11 +4,14 @@ #include "amex/config.h" +#include "board/config.h" + #include "platform/config.h" struct idz_hook_config { struct nu_config nu; struct amex_config amex; + struct aime_config aime; }; void idz_hook_config_load( diff --git a/idzhook/dllmain.c b/idzhook/dllmain.c index 27a7f0c..f2d80b5 100644 --- a/idzhook/dllmain.c +++ b/idzhook/dllmain.c @@ -43,12 +43,12 @@ static DWORD CALLBACK idz_pre_startup(void) platform_hook_init_nu(&idz_hook_cfg.nu, "SDDF", "AAV2", idz_hook_mod); amex_hook_init(&idz_hook_cfg.amex); - sg_reader_hook_init(10); - if (idz_hook_cfg.amex.jvs.enable) { idz_jvs_init(); } + sg_reader_hook_init(&idz_hook_cfg.aime, 10); + /* Initialize debug helpers */ spike_hook_init("idzspike.txt");