diff --git a/armsrc/Standalone/hf_young.c b/armsrc/Standalone/hf_young.c index 3d2935a9e..ddb54de02 100644 --- a/armsrc/Standalone/hf_young.c +++ b/armsrc/Standalone/hf_young.c @@ -163,10 +163,11 @@ void RunMod(void) { SpinDelay(500); // Begin clone function here: /* Example from client/mifarehost.c for commanding a block write for "magic Chinese" cards: - SendCommandMIX(CMD_HF_MIFARE_CSETBL, params & (0xFE | (uid == NULL ? 0:1)), blockNo, 0, data, 16); + SendCommandNG(CMD_HF_MIFARE_CSETBL, payload, sizeof(mf_chinese_blk_t) + 16); + where payload is mf_chinese_blk_t { u8 params, u8 blockno, u8 data[] } Block read is similar: - SendCommandMIX(CMD_HF_MIFARE_CGETBL, params, blockNo, 0,...}; + SendCommandNG(CMD_HF_MIFARE_CGETBL, payload, sizeof(mf_chinese_blk_t)); We need to imitate that call with blockNo 0 to set a uid. The get and set commands are handled in this file: diff --git a/armsrc/cmd.c b/armsrc/cmd.c index 336334b8f..b5774eab2 100644 --- a/armsrc/cmd.c +++ b/armsrc/cmd.c @@ -157,21 +157,6 @@ int reply_ng(uint16_t cmd, int8_t status, const uint8_t *data, size_t len) { return reply_ng_internal(cmd, status, PM3_REASON_UNKNOWN, data, len, true); } -int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len) { - int8_t status = PM3_SUCCESS; - uint64_t arg[3] = {arg0, arg1, arg2}; - if (len > PM3_CMD_DATA_SIZE - sizeof(arg)) { - len = PM3_CMD_DATA_SIZE - sizeof(arg); - status = PM3_EOVFLOW; - } - uint8_t cmddata[PM3_CMD_DATA_SIZE]; - memcpy(cmddata, arg, sizeof(arg)); - if (len && data) { - memcpy(cmddata + sizeof(arg), data, (int)len); - } - - return reply_ng_internal((cmd & 0xFFFF), status, PM3_REASON_UNKNOWN, cmddata, len + sizeof(arg), false); -} int reply_reason(uint16_t cmd, int8_t status, int8_t reason, const uint8_t *data, size_t len) { return reply_ng_internal(cmd, status, reason, data, len, true); diff --git a/armsrc/cmd.h b/armsrc/cmd.h index c96024bc2..9e4d440ba 100644 --- a/armsrc/cmd.h +++ b/armsrc/cmd.h @@ -29,7 +29,6 @@ extern bool g_reply_via_usb; int reply_old(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len); int reply_ng(uint16_t cmd, int8_t status, const uint8_t *data, size_t len); -int reply_mix(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len); int reply_reason(uint16_t cmd, int8_t status, int8_t reason, const uint8_t *data, size_t len); int receive_ng(PacketCommandNG *rx); diff --git a/armsrc/mifaredesfire.c b/armsrc/mifaredesfire.c index 9870ae497..0c62ee2f6 100644 --- a/armsrc/mifaredesfire.c +++ b/armsrc/mifaredesfire.c @@ -112,7 +112,7 @@ void MifareSendCommand(uint8_t *datain) { if (payload->flags & DISCONNECT) OnSuccess(); - //reply_mix(CMD_ACK, 1, len, 0, resp, len); + //reply_ng(CMD_HF_DESFIRE_COMMAND, PM3_SUCCESS, resp, len); LED_B_ON(); diff --git a/client/src/comms.c b/client/src/comms.c index ed157677d..c96ecf369 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -169,9 +169,9 @@ void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, c //__atomic_test_and_set(&txcmd_pending, __ATOMIC_SEQ_CST); } -static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool ng) { +void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) { #ifdef COMMS_DEBUG - PrintAndLogEx(INFO, "Sending %s", ng ? "NG" : "MIX"); + PrintAndLogEx(INFO, "Sending NG"); #endif if (!g_session.pm3_present) { @@ -196,7 +196,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool } txBufferNG.pre.magic = COMMANDNG_PREAMBLE_MAGIC; - txBufferNG.pre.ng = ng; + txBufferNG.pre.ng = true; txBufferNG.pre.length = len; txBufferNG.pre.cmd = cmd; if (len > 0 && data) { @@ -215,12 +215,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool #ifdef COMMS_DEBUG_RAW print_hex_break((uint8_t *)&txBufferNG.pre, sizeof(PacketCommandNGPreamble), 32); - if (ng) { - print_hex_break((uint8_t *)&txBufferNG.data, len, 32); - } else { - print_hex_break((uint8_t *)&txBufferNG.data, 3 * sizeof(uint64_t), 32); - print_hex_break((uint8_t *)&txBufferNG.data + 3 * sizeof(uint64_t), len - 3 * sizeof(uint64_t), 32); - } + print_hex_break((uint8_t *)&txBufferNG.data, len, 32); print_hex_break((uint8_t *)tx_post, sizeof(PacketCommandNGPostamble), 32); #endif txBuffer_pending = true; @@ -237,23 +232,6 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool //__atomic_test_and_set(&txcmd_pending, __ATOMIC_SEQ_CST); } -void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len) { - SendCommandNG_internal(cmd, data, len, true); -} - -void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len) { - uint64_t arg[3] = {arg0, arg1, arg2}; - if (len > PM3_CMD_DATA_SIZE_MIX) { - PrintAndLogEx(WARNING, "Sending " _RED_("%zu") " bytes of payload is too much for MIX frames, abort", len); - return; - } - uint8_t cmddata[PM3_CMD_DATA_SIZE]; - memcpy(cmddata, arg, sizeof(arg)); - if (len && data) - memcpy(cmddata + sizeof(arg), data, len); - SendCommandNG_internal(cmd, cmddata, len + sizeof(arg), false); -} - /** * @brief This method should be called when sending a new command to the pm3. In case any old @@ -1248,7 +1226,7 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3 return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED, CMD_FLASHMEM_DOWNLOAD); } case SIM_MEM: { - //SendCommandMIX(CMD_DOWNLOAD_SIM_MEM, start_index, bytes, 0, NULL, 0); + //SendCommandNG(CMD_DOWNLOAD_SIM_MEM, (uint8_t *)&req, sizeof(req)); //return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM); return false; } diff --git a/client/src/comms.h b/client/src/comms.h index 0e825f556..45e0ea2c2 100644 --- a/client/src/comms.h +++ b/client/src/comms.h @@ -93,7 +93,6 @@ void *uart_receiver(void *targ); void SendCommandBL(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len); void SendCommandOLD(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len); void SendCommandNG(uint16_t cmd, uint8_t *data, size_t len); -void SendCommandMIX(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, const void *data, size_t len); void clearCommandBuffer(void); #define FLASHMODE_SPEED 460800 diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 06826d1fb..c468de396 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -26,7 +26,6 @@ #define USART_SLOW_LINK #define PM3_CMD_DATA_SIZE 512 -#define PM3_CMD_DATA_SIZE_MIX (PM3_CMD_DATA_SIZE - 3 * sizeof(uint64_t)) typedef struct { uint64_t cmd;