mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
Better Reply structs
This commit is contained in:
parent
64eb93c9c4
commit
533667ea6d
57 changed files with 725 additions and 718 deletions
|
@ -140,7 +140,7 @@ static int CmdFlashMemRead(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
UsbCommand c = {CMD_FLASHMEM_READ, {start_index, len, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_READ, {start_index, len, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
|
@ -153,7 +153,7 @@ static int CmdFlashmemSpiBaudrate(const char *Cmd) {
|
|||
uint32_t baudrate = param_get32ex(Cmd, 0, 0, 10);
|
||||
baudrate = baudrate * 1000000;
|
||||
if (baudrate != FLASH_BAUD && baudrate != FLASH_MINBAUD) return usage_flashmem_spibaud();
|
||||
UsbCommand c = {CMD_FLASHMEM_SET_SPIBAUDRATE, {baudrate, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_SET_SPIBAUDRATE, {baudrate, 0, 0}, {{0}}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
while (bytes_remaining > 0) {
|
||||
uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining);
|
||||
|
||||
UsbCommand c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_WRITE, {start_index + bytes_sent, bytes_in_packet, 0}, {{0}}};
|
||||
|
||||
memcpy(c.d.asBytes, data + bytes_sent, bytes_in_packet);
|
||||
clearCommandBuffer();
|
||||
|
@ -290,7 +290,7 @@ static int CmdFlashMemLoad(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint8_t isok = resp.core.old.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
||||
if (!isok)
|
||||
PrintAndLogEx(FAILED, "Flash write fail [offset %u]", bytes_sent);
|
||||
|
||||
|
@ -389,7 +389,7 @@ static int CmdFlashMemWipe(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors || cmdp == 0) return usage_flashmem_wipe();
|
||||
|
||||
UsbCommand c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_WIPE, {page, initalwipe, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -397,7 +397,7 @@ static int CmdFlashMemWipe(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
return 1;
|
||||
}
|
||||
uint8_t isok = resp.core.old.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
||||
if (isok)
|
||||
PrintAndLogEx(SUCCESS, "Flash WIPE ok");
|
||||
else
|
||||
|
@ -435,7 +435,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
//Validations
|
||||
if (errors) return usage_flashmem_info();
|
||||
|
||||
UsbCommand c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
|
||||
UsbCommandOLD c = {CMD_FLASHMEM_INFO, {0, 0, 0}, {{0}}};
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
UsbReplyNG resp;
|
||||
|
@ -444,7 +444,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
uint8_t isok = resp.core.old.arg[0] & 0xFF;
|
||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
||||
if (!isok) {
|
||||
PrintAndLogEx(FAILED, "failed");
|
||||
return 1;
|
||||
|
@ -452,7 +452,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
|
||||
// validate signature here
|
||||
rdv40_validation_t mem;
|
||||
memcpy(&mem, (rdv40_validation_t *)resp.core.old.d.asBytes, sizeof(rdv40_validation_t));
|
||||
memcpy(&mem, (rdv40_validation_t *)resp.data.asBytes, sizeof(rdv40_validation_t));
|
||||
|
||||
// Flash ID hash (sha1)
|
||||
mbedtls_sha1(mem.flashid, sizeof(mem.flashid), sha_hash);
|
||||
|
@ -564,7 +564,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
|
||||
if (shall_write) {
|
||||
// save to mem
|
||||
c = (UsbCommand) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
|
||||
c = (UsbCommandOLD) {CMD_FLASHMEM_WRITE, {FLASH_MEM_SIGNATURE_OFFSET, FLASH_MEM_SIGNATURE_LEN, 0}, {{0}}};
|
||||
memcpy(c.d.asBytes, sign, sizeof(sign));
|
||||
clearCommandBuffer();
|
||||
SendCommand(&c);
|
||||
|
@ -572,7 +572,7 @@ static int CmdFlashMemInfo(const char *Cmd) {
|
|||
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
|
||||
} else {
|
||||
|
||||
if (!resp.core.old.arg[0])
|
||||
if (!resp.oldarg[0])
|
||||
PrintAndLogEx(FAILED, "Writing signature failed");
|
||||
else
|
||||
PrintAndLogEx(SUCCESS, "Writing signature ok [offset: %u]", FLASH_MEM_SIGNATURE_OFFSET);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue