From 72f28e40b0d2d79548de16ed24491fcd6a9aa5d1 Mon Sep 17 00:00:00 2001 From: Tau Date: Mon, 4 Mar 2019 18:38:37 -0500 Subject: [PATCH] amex/ds.c: Read optional region code --- amex/ds.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/amex/ds.c b/amex/ds.c index 1130b77..a56f24d 100644 --- a/amex/ds.c +++ b/amex/ds.c @@ -37,7 +37,8 @@ enum { struct ds_eeprom { uint32_t crc32; - uint8_t unk_04[5]; + uint8_t unk_04[4]; + uint8_t region; char serial_no[17]; uint8_t unk_1A[6]; }; @@ -62,36 +63,22 @@ static HANDLE ds_fd; HRESULT ds_hook_init(void) { HRESULT hr; + int region; FILE *f; - char c; - int i; + region = 0x01; /* Japan; use this default if ds.txt read fails */ memset(&ds_eeprom, 0, sizeof(ds_eeprom)); f = fopen(ds_serial_file, "r"); if (f != NULL) { - i = 0; - - for (;;) { - if (feof(f) || i >= sizeof(ds_eeprom.serial_no) - 1) { - break; - } - - c = getc(f); - - if (isspace(c)) { - break; - } - - ds_eeprom.serial_no[i++] = c; - } - + fscanf(f, "%16s %x", ds_eeprom.serial_no, ®ion); fclose(f); } else { dprintf("Failed to open %s\n", ds_serial_file); } + ds_eeprom.region = region; ds_eeprom.crc32 = crc32(&ds_eeprom.unk_04, 0x1C, 0); hr = iohook_push_handler(ds_handle_irp);