From 31d1caa526a7354ff608b6d44faeea2d04c68896 Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Thu, 8 Jan 2015 17:51:52 +0100 Subject: [PATCH 1/1] Reverted some minor things, altered other things to get it to compile cleanly --- armsrc/appmain.c | 5 ++++- armsrc/apps.h | 2 +- armsrc/crapto1.c | 4 ++-- armsrc/mifarecmd.c | 24 ++++++++++++------------ client/cmdhflegic.c | 2 +- client/cmdhfmf.c | 3 +++ client/cmdlf.c | 1 + client/lualibs/html_dumplib.lua | 2 +- include/usb_cmd.h | 2 -- 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index ca16ee60..530dc39c 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -18,6 +18,7 @@ #include "util.h" #include "printf.h" #include "string.h" + #include #include "legicrf.h" @@ -667,7 +668,9 @@ void UsbPacketReceived(uint8_t *packet, int len) WriteTItag(c->arg[0],c->arg[1],c->arg[2]); break; case CMD_SIMULATE_TAG_125K: + LED_A_ON(); SimulateTagLowFrequency(c->arg[0], c->arg[1], 1); + LED_A_OFF(); break; case CMD_LF_SIMULATE_BIDIR: SimulateTagLowFrequencyBidir(c->arg[0], c->arg[1]); @@ -799,7 +802,7 @@ void UsbPacketReceived(uint8_t *packet, int len) MifareUReadBlock(c->arg[0],c->d.asBytes); break; case CMD_MIFAREU_READCARD: - MifareUReadCard(c->arg[0],c->d.asBytes); + MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes); break; case CMD_MIFARE_READSC: MifareReadSector(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes); diff --git a/armsrc/apps.h b/armsrc/apps.h index eafee559..ce721525 100644 --- a/armsrc/apps.h +++ b/armsrc/apps.h @@ -177,7 +177,7 @@ void ReaderMifare(bool first_try); int32_t dist_nt(uint32_t nt1, uint32_t nt2); void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data); void MifareUReadBlock(uint8_t arg0,uint8_t *datain); -void MifareUReadCard(uint8_t arg0,uint8_t *datain); +void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain); void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain); void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain); void MifareUWriteBlock(uint8_t arg0,uint8_t *datain); diff --git a/armsrc/crapto1.c b/armsrc/crapto1.c index df0834b8..9d491d12 100644 --- a/armsrc/crapto1.c +++ b/armsrc/crapto1.c @@ -44,12 +44,12 @@ static void quicksort(uint32_t* const start, uint32_t* const stop) else if(*rit > *start) --rit; else - *it ^= ( (*it ^= *rit ), *rit ^= *it); + *it ^= (*it ^= *rit, *rit ^= *it); if(*rit >= *start) --rit; if(rit != start) - *rit ^= ( (*rit ^= *start), *start ^= *rit); + *rit ^= (*rit ^= *start, *start ^= *rit); quicksort(start, rit - 1); quicksort(rit + 1, stop); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 2619a976..ecd8728d 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -102,21 +102,21 @@ void MifareUReadBlock(uint8_t arg0,uint8_t *datain) int len = iso14443a_select_card(uid, NULL, &cuid); if(!len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card"); - OnError(1); + //OnError(1); return; }; len = mifare_ultra_readblock(cuid, blockNo, dataout); if(len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Read block error"); - OnError(2); + //OnError(2); return; }; len = mifare_ultra_halt(cuid); if(len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Halt error"); - OnError(3); + //OnError(3); return; }; @@ -201,11 +201,11 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain) int count_Pages = 0; byte_t dataout[176] = {0x00};; uint8_t uid[10] = {0x00}; - uint32_t cuid; + uint32_t cuid; - LED_A_ON(); - LED_B_OFF(); - LED_C_OFF(); + LED_A_ON(); + LED_B_OFF(); + LED_C_OFF(); if (MF_DBGLEVEL >= MF_DBG_ALL) Dbprintf("Pages %d",Pages); @@ -218,7 +218,7 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain) if (!len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card"); - OnError(1); + //OnError(1); return; } @@ -229,7 +229,7 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain) if (len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Read block %d error",i); - OnError(2); + //OnError(2); return; } else { count_Pages++; @@ -240,7 +240,7 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain) if (len) { if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Halt error"); - OnError(3); + //OnError(3); return; } @@ -255,8 +255,8 @@ void MifareUReadCard(uint8_t arg0, int arg1, uint8_t *datain) len = 176; cmd_send(CMD_ACK, 1, 0, 0, dataout, len); - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - LEDsoff(); + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + LEDsoff(); } diff --git a/client/cmdhflegic.c b/client/cmdhflegic.c index 35ba1f28..7ee601b2 100644 --- a/client/cmdhflegic.c +++ b/client/cmdhflegic.c @@ -16,7 +16,7 @@ #include "cmdparser.h" #include "cmdhflegic.h" #include "cmdmain.h" - +#include "util.h" static int CmdHelp(const char *Cmd); static command_t CommandTable[] = diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index 66c0b25d..aae6290d 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -662,6 +662,8 @@ int CmdHF14AMfRestore(const char *Cmd) for (sectorNo = 0; sectorNo < numSectors; sectorNo++) { if (fread(keyA[sectorNo], 1, 6, fkeys) == 0) { PrintAndLog("File reading error (dumpkeys.bin)."); + + fclose(fkeys); return 2; } } @@ -669,6 +671,7 @@ int CmdHF14AMfRestore(const char *Cmd) for (sectorNo = 0; sectorNo < numSectors; sectorNo++) { if (fread(keyB[sectorNo], 1, 6, fkeys) == 0) { PrintAndLog("File reading error (dumpkeys.bin)."); + fclose(fkeys); return 2; } } diff --git a/client/cmdlf.c b/client/cmdlf.c index 572cda6c..65d6fdd5 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -19,6 +19,7 @@ #include "cmdparser.h" #include "cmdmain.h" #include "cmddata.h" +#include "util.h" #include "cmdlf.h" #include "cmdlfhid.h" #include "cmdlfti.h" diff --git a/client/lualibs/html_dumplib.lua b/client/lualibs/html_dumplib.lua index 44b6b352..3a28d5ae 100644 --- a/client/lualibs/html_dumplib.lua +++ b/client/lualibs/html_dumplib.lua @@ -49,7 +49,7 @@ end local function save_TEXT(data,filename) -- Open the output file - local outfile = io.open(filename, "wb") + local outfile = io.open(filename, "w") if outfile == nil then return oops(string.format("Could not write to file %s",tostring(filename))) end diff --git a/include/usb_cmd.h b/include/usb_cmd.h index c2e0b95b..69c3c1b6 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -150,10 +150,8 @@ typedef struct { #define CMD_MIFARE_READBL 0x0620 #define CMD_MIFAREU_READBL 0x0720 - #define CMD_MIFARE_READSC 0x0621 #define CMD_MIFAREU_READCARD 0x0721 - #define CMD_MIFARE_WRITEBL 0x0622 #define CMD_MIFAREU_WRITEBL 0x0722 #define CMD_MIFAREU_WRITEBL_COMPAT 0x0723 -- 2.39.5