mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 06:13:27 -07:00
[mod] hf list: allow traces bigger than 64K to be saved and loaded
This commit is contained in:
parent
21420d060e
commit
4b3ede7028
1 changed files with 9 additions and 9 deletions
|
@ -461,24 +461,24 @@ int CmdHFList(const char *Cmd)
|
||||||
|
|
||||||
|
|
||||||
uint8_t *trace;
|
uint8_t *trace;
|
||||||
uint16_t tracepos = 0;
|
uint32_t tracepos = 0;
|
||||||
uint16_t traceLen = 0;
|
uint32_t traceLen = 0;
|
||||||
|
|
||||||
if (loadFromFile) {
|
if (loadFromFile) {
|
||||||
FILE *tracefile = NULL;
|
FILE *tracefile = NULL;
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
uint8_t buf[2];
|
uint8_t buf[4];
|
||||||
if ((tracefile = fopen(filename,"rb")) == NULL) {
|
if ((tracefile = fopen(filename,"rb")) == NULL) {
|
||||||
PrintAndLog("Could not open file %s", filename);
|
PrintAndLog("Could not open file %s", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bytes_read = fread(buf, 1, 2, tracefile);
|
bytes_read = fread(buf, 1, 4, tracefile);
|
||||||
if (bytes_read != 2) {
|
if (bytes_read != 4) {
|
||||||
PrintAndLog("File reading error.");
|
PrintAndLog("File reading error.");
|
||||||
fclose(tracefile);
|
fclose(tracefile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
traceLen = bytes_to_num(buf, 2); // little endian in file
|
traceLen = bytes_to_num(buf, 4); // little endian in file
|
||||||
trace = malloc(traceLen+2);
|
trace = malloc(traceLen+2);
|
||||||
if (trace == NULL) {
|
if (trace == NULL) {
|
||||||
PrintAndLog("Cannot allocate memory for trace");
|
PrintAndLog("Cannot allocate memory for trace");
|
||||||
|
@ -512,13 +512,13 @@ int CmdHFList(const char *Cmd)
|
||||||
|
|
||||||
if (saveToFile) {
|
if (saveToFile) {
|
||||||
FILE *traceFile = NULL;
|
FILE *traceFile = NULL;
|
||||||
uint8_t buf[2];
|
uint8_t buf[4];
|
||||||
if ((traceFile = fopen(filename,"wb")) == NULL) {
|
if ((traceFile = fopen(filename,"wb")) == NULL) {
|
||||||
PrintAndLog("Could not create file %s", filename);
|
PrintAndLog("Could not create file %s", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
num_to_bytes(traceLen, 2, buf);
|
num_to_bytes(traceLen, 4, buf);
|
||||||
fwrite(buf, 1, 2, traceFile);
|
fwrite(buf, 1, 4, traceFile);
|
||||||
fwrite(trace, 1, traceLen, traceFile);
|
fwrite(trace, 1, traceLen, traceFile);
|
||||||
PrintAndLog("Recorded Activity (TraceLen = %d bytes) written to file %s", traceLen, filename);
|
PrintAndLog("Recorded Activity (TraceLen = %d bytes) written to file %s", traceLen, filename);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue