1
0
Fork 0

added `aimeGen` as default instead of `feliciaGen`

This commit is contained in:
Dniel97 2023-08-29 22:57:04 +02:00
parent f0dc51d01e
commit 51b11469d0
Signed by untrusted user: Dniel97
GPG Key ID: 6180B3C768FB2E08
8 changed files with 81 additions and 7 deletions

View File

@ -17,6 +17,7 @@ struct aime_io_config {
wchar_t aime_path[MAX_PATH];
wchar_t felica_path[MAX_PATH];
bool felica_gen;
bool aime_gen;
uint8_t vk_scan;
};
@ -40,6 +41,11 @@ static HRESULT aime_io_generate_felica(
uint8_t *bytes,
size_t nbytes);
static HRESULT aime_io_generate_aime(
const wchar_t *path,
uint8_t *bytes,
size_t nbytes);
static void aime_io_config_read(
struct aime_io_config *cfg,
const wchar_t *filename)
@ -67,6 +73,12 @@ static void aime_io_config_read(
cfg->felica_gen = GetPrivateProfileIntW(
L"aime",
L"felicaGen",
0,
filename);
cfg->aime_gen = GetPrivateProfileIntW(
L"aime",
L"aimeGen",
1,
filename);
@ -136,7 +148,7 @@ static HRESULT aime_io_generate_felica(
srand(time(NULL));
for (i = 0 ; i < nbytes ; i++) {
for (i = 0; i < nbytes; i++) {
bytes[i] = rand();
}
@ -151,7 +163,7 @@ static HRESULT aime_io_generate_felica(
return E_FAIL;
}
for (i = 0 ; i < nbytes ; i++) {
for (i = 0; i < nbytes; i++) {
fprintf(f, "%02X", bytes[i]);
}
@ -163,6 +175,47 @@ static HRESULT aime_io_generate_felica(
return S_OK;
}
static HRESULT aime_io_generate_aime(
const wchar_t *path,
uint8_t *bytes,
size_t nbytes)
{
size_t i;
FILE *f;
assert(path != NULL);
assert(bytes != NULL);
assert(nbytes > 0);
srand(time(NULL));
/* AiMe IDs should not start with 3, due to a missing check for BananaPass IDs */
do {
for (i = 0; i < nbytes; i++) {
bytes[i] = rand() % 10 << 4 | rand() % 10;
}
} while (bytes[0] >> 4 == 3);
f = _wfopen(path, L"w");
if (f == NULL) {
dprintf("AimeIO DLL: %S: fopen failed: %i\n", path, (int) errno);
return E_FAIL;
}
for (i = 0; i < nbytes; i++) {
fprintf(f, "%02x", bytes[i]);
}
fprintf(f, "\n");
fclose(f);
dprintf("AimeIO DLL: Generated random AiMe ID\n");
return S_OK;
}
uint16_t aime_io_get_api_version(void)
{
return 0x0100;
@ -210,6 +263,22 @@ HRESULT aime_io_nfc_poll(uint8_t unit_no)
return S_OK;
}
/* Try generating AiMe IC (if enabled) */
if (aime_io_cfg.aime_gen) {
hr = aime_io_generate_aime(
aime_io_cfg.aime_path,
aime_io_aime_id,
sizeof(aime_io_aime_id));
if (FAILED(hr)) {
return hr;
}
aime_io_aime_id_present = true;
return S_OK;
}
/* Try FeliCa IC */
hr = aime_io_read_id_file(

View File

@ -11,6 +11,7 @@ appdata=
[aime]
; Enable aime reader emulation.
enable=1
aimePath=DEVICE\aime.txt
; Enable high baud rate.
;highbaud=1

View File

@ -12,7 +12,6 @@ appdata=
; Enable aime reader emulation.
enable=1
aimePath=DEVICE\aime.txt
felicaGen=0
[dns]
; Insert the hostname or IP address of the server you wish to use here.

View File

@ -12,7 +12,6 @@ appdata=
; Controls emulation of the Aime card reader assembly.
enable=1
aimePath=DEVICE\aime.txt
felicaGen=0
[dns]
; Insert the hostname or IP address of the server you wish to use here.

View File

@ -11,6 +11,7 @@ appdata=
[aime]
; Enable aime reader emulation.
enable=1
aimePath=DEVICE\aime.txt
[dns]
; Insert the hostname or IP address of the server you wish to use here.

View File

@ -12,7 +12,6 @@ appdata=
; Controls emulation of the Aime card reader assembly.
enable=1
aimePath=DEVICE\aime.txt
felicaGen=0
[dns]
; Insert the hostname or IP address of the server you wish to use here.

View File

@ -12,7 +12,6 @@ appdata=
; Controls emulation of the Aime card reader assembly.
enable=1
aimePath=DEVICE\aime.txt
felicaGen=0
[dns]
; Insert the hostname or IP address of the server you wish to use here.

View File

@ -45,6 +45,13 @@ Default: `DEVICE\aime.txt`
Path to a text file containing a classic Aime IC card ID. **This does not
currently work**.
### `aimeGen`
Default: `1`
Whether to generate a random AiMe ID if the file at `aimePath` does not
exist.
### `felicaPath`
Default: `DEVICE\felica.txt`
@ -53,7 +60,7 @@ Path to a text file containing a FeliCa e-cash card IDm serial number.
### `felicaGen`
Default: `1`
Default: `0`
Whether to generate a random FeliCa ID if the file at `felicaPath` does not
exist.