mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
Use ST25TB_SR_BLOCK_SIZE instead of 4
This commit is contained in:
parent
f6ae161fd5
commit
b80cc92c39
1 changed files with 7 additions and 7 deletions
|
@ -1646,7 +1646,7 @@ static int CmdHF14BSriWrbl(const char *Cmd) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int status = write_sr_block(blockno, 4, data);
|
int status = write_sr_block(blockno, ST25TB_SR_BLOCK_SIZE, data);
|
||||||
if (status != PM3_SUCCESS) {
|
if (status != PM3_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1903,15 +1903,15 @@ static int CmdHF14BRestore(const char *Cmd) {
|
||||||
// reserve memory
|
// reserve memory
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
int res = pm3_load_dump(filename, (void **)&data, &bytes_read, (4 * block_cnt));
|
int res = pm3_load_dump(filename, (void **)&data, &bytes_read, (ST25TB_SR_BLOCK_SIZE * block_cnt));
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(FAILED, "Failed to load file");
|
PrintAndLogEx(FAILED, "Failed to load file");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore remaining 4 bytes if the file is 4 bytes larger than the expected size
|
// Ignore remaining block if the file is 1 block larger than the expected size
|
||||||
// (because hf 14b dump also saves the special block at the end of the memory, it will be ignored by the restore command)
|
// (because hf 14b dump also saves the special block at the end of the memory, it will be ignored by the restore command)
|
||||||
if (bytes_read != (block_cnt * 4) && bytes_read != (block_cnt * 4 + 4)) {
|
if (bytes_read != (block_cnt * ST25TB_SR_BLOCK_SIZE) && bytes_read != ((block_cnt + 1) * ST25TB_SR_BLOCK_SIZE)) {
|
||||||
PrintAndLogEx(ERR, "File content error. Read %zu", bytes_read);
|
PrintAndLogEx(ERR, "File content error. Read %zu", bytes_read);
|
||||||
free(data);
|
free(data);
|
||||||
return PM3_EFILE;
|
return PM3_EFILE;
|
||||||
|
@ -1921,7 +1921,7 @@ static int CmdHF14BRestore(const char *Cmd) {
|
||||||
int blockno = 0;
|
int blockno = 0;
|
||||||
while (bytes_read) {
|
while (bytes_read) {
|
||||||
|
|
||||||
int status = write_sr_block(blockno, 4, data+blockno*4);
|
int status = write_sr_block(blockno, ST25TB_SR_BLOCK_SIZE, data+blockno*ST25TB_SR_BLOCK_SIZE);
|
||||||
if (status != PM3_SUCCESS) {
|
if (status != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(FAILED, "Write failed");
|
PrintAndLogEx(FAILED, "Write failed");
|
||||||
free(data);
|
free(data);
|
||||||
|
@ -1929,10 +1929,10 @@ static int CmdHF14BRestore(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify
|
// verify
|
||||||
uint8_t out[4] = {0};
|
uint8_t out[ST25TB_SR_BLOCK_SIZE] = {0};
|
||||||
status = read_sr_block(blockno, out);
|
status = read_sr_block(blockno, out);
|
||||||
if (status == PM3_SUCCESS) {
|
if (status == PM3_SUCCESS) {
|
||||||
if (memcmp(data+blockno*ST25TB_SR_BLOCK_SIZE, out, 4) == 0) {
|
if (memcmp(data+blockno*ST25TB_SR_BLOCK_SIZE, out, ST25TB_SR_BLOCK_SIZE) == 0) {
|
||||||
printf("\33[2K\r");
|
printf("\33[2K\r");
|
||||||
PrintAndLogEx(INFO, "SRx write block %d/%d ( " _GREEN_("ok") " )" NOLF, blockno, block_cnt-1);
|
PrintAndLogEx(INFO, "SRx write block %d/%d ( " _GREEN_("ok") " )" NOLF, blockno, block_cnt-1);
|
||||||
}else {
|
}else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue