From 81053d8c428fa8389105d1caf08ae34a45482cf8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 23 May 2019 03:03:24 -0400 Subject: [PATCH] fix: standalone mode mattyrun now compiles --- armsrc/Standalone/hf_mattyrun.c | 20 ++++++++++---------- armsrc/apps.h | 2 +- armsrc/mifarecmd.c | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/armsrc/Standalone/hf_mattyrun.c b/armsrc/Standalone/hf_mattyrun.c index 002a50c51..6362c170b 100644 --- a/armsrc/Standalone/hf_mattyrun.c +++ b/armsrc/Standalone/hf_mattyrun.c @@ -235,7 +235,7 @@ void RunMod() { uint64_t key64; // Defines current key uint8_t *keyBlock; // Where the keys will be held in memory. uint8_t stKeyBlock = 20; // Set the quantity of keys in the block. - uint8_t filled = 0; // Used to check if the memory was filled with success. + int filled; // Used to check if the memory was filled with success. bool keyFound = false; /* @@ -369,26 +369,26 @@ void RunMod() { if (ecfill) { Dbprintf("\tFilling in with key A."); - MifareECardLoad(sectorsCnt, 0, 0, &filled); - if (filled != 1) { + filled = MifareECardLoad(sectorsCnt, 0); + if (filled != PM3_SUCCESS) { Dbprintf("\t✕ Failed filling with A."); } Dbprintf("\tFilling in with key B."); - MifareECardLoad(sectorsCnt, 1, 0, &filled); - if (filled != 1) { + filled = MifareECardLoad(sectorsCnt, 1); + if (filled != PM3_SUCCESS) { Dbprintf("\t✕ Failed filling with B."); } - if ((filled == 1) && simulation) { - Dbprintf("\t✓ Filled, simulation started."); + if ((filled == PM3_SUCCESS) && simulation) { + Dbprintf("\t✓ Emulator memory filled, simulation started."); // This will tell the fpga to emulate using previous keys and current target tag content. Dbprintf("\t Press button to abort simulation at anytime."); LED_B_ON(); // green // assuming arg0==0, use hardcoded uid 0xdeadbeaf - Mifare1ksim(FLAG_4B_UID_IN_DATA | FLAG_UID_IN_EMUL, 0, 0, uid); + Mifare1ksim(FLAG_4B_UID_IN_DATA | FLAG_UID_IN_EMUL, 0, uid); LED_B_OFF(); /* @@ -428,8 +428,8 @@ void RunMod() { } } - } else if (filled != 1) { - Dbprintf("\t✕ Memory could not be filled due to errors."); + } else if (filled != PM3_SUCCESS) { + Dbprintf("\t✕ Emulator memory could not be filled due to errors."); LED_C_ON(); } } diff --git a/armsrc/apps.h b/armsrc/apps.h index 86dd4488c..3aeedbcee 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -159,7 +159,7 @@ void MifareSetDbgLvl(uint16_t arg0); void MifareEMemClr(void); void MifareEMemSet(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); void MifareEMemGet(uint32_t arg0, uint32_t arg1); -void MifareECardLoad(uint32_t arg0, uint32_t arg1); +int MifareECardLoad(uint32_t arg0, uint32_t arg1); void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); // Work with "magic Chinese" card void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint8_t *datain); void MifareCIdent(); // is "magic chinese" card? diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index c4f0ae3df..c1dbaced8 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1650,7 +1650,7 @@ void MifareEMemGet(uint32_t arg0, uint32_t arg1) { // Load a card into the emulator memory // //----------------------------------------------------------------------------- -void MifareECardLoad(uint32_t arg0, uint32_t arg1) { +int MifareECardLoad(uint32_t arg0, uint32_t arg1) { uint64_t ui64Key; uint32_t cuid = 0; uint8_t numSectors = arg0; @@ -1726,6 +1726,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1) { if (MF_DBGLEVEL >= 2) DbpString("EMUL FILL SECTORS FINISHED"); set_tracing(false); + return (isOK) ? PM3_SUCCESS : PM3_EUNDEF; }