forked from TeamTofuShop/segatools
Fix build with Microsoft Visual C++, Fix gfxhook and felica issue (#48)
I just wanna say that It is a SHAME that a Windows ONLY project was not able to build without MINGW Also where's the missing `3mpxsc.h` in diva hook? This also fixes the window size issue from hook_CreateWindowExA in gfxhook And Fixes felica issue as described in #45 Reviewed-on: Dniel97/segatools#48 Reviewed-by: Dniel97 <dniel97@noreply.gitea.tendokyu.moe> Co-authored-by: GEEKiDoS <geek_ds@foxmail.com> Co-committed-by: GEEKiDoS <geek_ds@foxmail.com>
This commit is contained in:
162
iccard/felica.c
162
iccard/felica.c
@ -21,21 +21,27 @@ static HRESULT felica_cmd_get_system_code(
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res);
|
||||
|
||||
static HRESULT felica_cmd_nda_a4(
|
||||
static HRESULT felica_cmd_active(
|
||||
struct felica *f,
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res);
|
||||
|
||||
uint64_t felica_get_generic_PMm(void)
|
||||
static HRESULT felica_cmd_read_without_encryption(
|
||||
struct felica *f,
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res);
|
||||
|
||||
static HRESULT felica_cmd_write_without_encryption(
|
||||
struct felica* f,
|
||||
struct const_iobuf* req,
|
||||
struct iobuf* res);
|
||||
|
||||
uint64_t felica_get_amusement_ic_PMm(void)
|
||||
{
|
||||
/* A FeliCa PMm contains low-level protocol timing information for
|
||||
communicating with a particular IC card. The exact values are not
|
||||
particularly important for our purposes, so we'll just return a hard-
|
||||
coded PMm. This current value has been taken from an iPhone, emulating
|
||||
a Suica pass via Apple Wallet, which seems to be one of the few
|
||||
universally accepted FeliCa types for these games. Certain older
|
||||
Suica passes and other payment and transportation cards
|
||||
do not seem to be supported anymore. */
|
||||
/*
|
||||
* AIC Card PMm, if this is returned from the card,
|
||||
* the aimelib will access the actual blocks for authentication.
|
||||
*/
|
||||
|
||||
return 0x00F1000000014300;
|
||||
}
|
||||
@ -90,8 +96,14 @@ HRESULT felica_transact(
|
||||
case FELICA_CMD_GET_SYSTEM_CODE:
|
||||
return felica_cmd_get_system_code(f, req, res);
|
||||
|
||||
case FELICA_CMD_NDA_A4:
|
||||
return felica_cmd_nda_a4(f, req, res);
|
||||
case FELICA_READ_WITHOUT_ENCRYPTION:
|
||||
return felica_cmd_read_without_encryption(f, req, res);
|
||||
|
||||
case FELICA_WRITE_WITHOUT_ENCRYPTION:
|
||||
return felica_cmd_write_without_encryption(f, req, res);
|
||||
|
||||
case FELICA_CMD_ACTIVE:
|
||||
return felica_cmd_active(f, req, res);
|
||||
|
||||
default:
|
||||
dprintf("FeliCa: Unimplemented command %02x, payload:\n", code);
|
||||
@ -184,7 +196,131 @@ static HRESULT felica_cmd_get_system_code(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT felica_cmd_nda_a4(
|
||||
static HRESULT felica_cmd_read_without_encryption(
|
||||
struct felica *f,
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res)
|
||||
{
|
||||
HRESULT hr;
|
||||
uint8_t system_code_count;
|
||||
uint16_t* system_codes;
|
||||
uint8_t read_block_count;
|
||||
uint8_t* blocks;
|
||||
size_t i;
|
||||
|
||||
hr = iobuf_read_8(req, &system_code_count);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
system_codes = malloc(sizeof(uint16_t) * system_code_count);
|
||||
if (!system_codes) goto fail;
|
||||
|
||||
for (i = 0; i < system_code_count; i++) {
|
||||
hr = iobuf_read_be16(req, system_codes + i);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
hr = iobuf_read_8(req, &read_block_count);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
blocks = malloc(read_block_count);
|
||||
if (!system_codes) goto fail;
|
||||
|
||||
for (i = 0; i < read_block_count; i++) {
|
||||
// 0x80
|
||||
hr = iobuf_read_8(req, blocks + i);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// actual block num
|
||||
hr = iobuf_read_8(req, blocks + i);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
// status
|
||||
hr = iobuf_write_be16(res, 0);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// block count
|
||||
hr = iobuf_write_8(res, read_block_count);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// block data
|
||||
for (i = 0; i < read_block_count; i++)
|
||||
{
|
||||
dprintf("FeliCa: Read block %x\n", blocks[i]);
|
||||
|
||||
switch (blocks[i]) {
|
||||
case 0x82: {
|
||||
hr = iobuf_write_be64(res, f->IDm);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = iobuf_write_be64(res, 0x0078000000000000ull);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
default: {
|
||||
hr = iobuf_write_be64(res, 0);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hr = iobuf_write_be64(res, 0);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hr = S_OK;
|
||||
|
||||
fail:
|
||||
if (system_codes) free(system_codes);
|
||||
if (blocks) free(blocks);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT felica_cmd_write_without_encryption(
|
||||
struct felica* f,
|
||||
struct const_iobuf* req,
|
||||
struct iobuf* res)
|
||||
{
|
||||
return iobuf_write_be16(res, 0);
|
||||
}
|
||||
|
||||
static HRESULT felica_cmd_active(
|
||||
struct felica *f,
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res)
|
||||
|
@ -8,9 +8,11 @@
|
||||
#include "hook/iobuf.h"
|
||||
|
||||
enum {
|
||||
FELICA_CMD_POLL = 0x00,
|
||||
FELICA_CMD_GET_SYSTEM_CODE = 0x0c,
|
||||
FELICA_CMD_NDA_A4 = 0xa4,
|
||||
FELICA_CMD_POLL = 0x00,
|
||||
FELICA_READ_WITHOUT_ENCRYPTION = 0x06,
|
||||
FELICA_WRITE_WITHOUT_ENCRYPTION = 0x08,
|
||||
FELICA_CMD_GET_SYSTEM_CODE = 0x0c,
|
||||
FELICA_CMD_ACTIVE = 0xa4,
|
||||
};
|
||||
|
||||
struct felica {
|
||||
@ -24,4 +26,4 @@ HRESULT felica_transact(
|
||||
struct const_iobuf *req,
|
||||
struct iobuf *res);
|
||||
|
||||
uint64_t felica_get_generic_PMm(void);
|
||||
uint64_t felica_get_amusement_ic_PMm(void);
|
||||
|
Reference in New Issue
Block a user