mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
data diff - handle different lengths
This commit is contained in:
parent
85f16fd471
commit
63612c9375
1 changed files with 48 additions and 8 deletions
|
@ -3107,16 +3107,16 @@ static int CmdDiff(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, hdr0);
|
PrintAndLogEx(INFO, hdr0);
|
||||||
PrintAndLogEx(INFO, hdr1);
|
PrintAndLogEx(INFO, hdr1);
|
||||||
|
|
||||||
// index 4bytes, spaces, bar, bytes with ansi codes
|
|
||||||
// (16 * 2 * 8 ) + 32
|
|
||||||
char line[880] = {0};
|
char line[880] = {0};
|
||||||
|
|
||||||
// print data diff loop
|
// print data diff loop
|
||||||
for (int i = 0; i < n; i += width ) {
|
int i;
|
||||||
|
for (i = 0; i < n; i += width ) {
|
||||||
|
|
||||||
memset(line, 0, sizeof(line));
|
memset(line, 0, sizeof(line));
|
||||||
|
|
||||||
int diff = memcmp(inA + i, inB + i, width);
|
int diff = memcmp(inA + i, inB + i, width);
|
||||||
|
|
||||||
// if ok, just print
|
// if ok, just print
|
||||||
if (diff == 0) {
|
if (diff == 0) {
|
||||||
hex_to_buffer((uint8_t*)line, inA + i, width, width, 0, 1, true);
|
hex_to_buffer((uint8_t*)line, inA + i, width, width, 0, 1, true);
|
||||||
|
@ -3143,20 +3143,17 @@ static int CmdDiff(const char *Cmd) {
|
||||||
char cb = inB[j];
|
char cb = inB[j];
|
||||||
|
|
||||||
if (inA[j] != inB[j]) {
|
if (inA[j] != inB[j]) {
|
||||||
//PrintAndLogEx(INFO, "%02X -- %02X", inA[j], inB[j]);
|
|
||||||
// diff
|
// diff / add colors
|
||||||
sprintf(dlnA + strlen(dlnA), _GREEN_("%02X "), inA[j]);
|
sprintf(dlnA + strlen(dlnA), _GREEN_("%02X "), inA[j]);
|
||||||
sprintf(dlnB + strlen(dlnB), _RED_("%02X "), inB[j]);
|
sprintf(dlnB + strlen(dlnB), _RED_("%02X "), inB[j]);
|
||||||
|
|
||||||
sprintf(dlnAii + strlen(dlnAii), _GREEN_("%c"), ((ca < 32) || (ca == 127)) ? '.' : ca);
|
sprintf(dlnAii + strlen(dlnAii), _GREEN_("%c"), ((ca < 32) || (ca == 127)) ? '.' : ca);
|
||||||
sprintf(dlnBii + strlen(dlnBii), _RED_("%c"), ((cb < 32) || (cb == 127)) ? '.' : cb);
|
sprintf(dlnBii + strlen(dlnBii), _RED_("%c"), ((cb < 32) || (cb == 127)) ? '.' : cb);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//PrintAndLogEx(INFO, "%02X ++ %02X", inA[j], inB[j]);
|
|
||||||
// normal
|
// normal
|
||||||
sprintf(dlnA + strlen(dlnA), "%02X ", inA[j]);
|
sprintf(dlnA + strlen(dlnA), "%02X ", inA[j]);
|
||||||
sprintf(dlnB + strlen(dlnB), "%02X ", inB[j]);
|
sprintf(dlnB + strlen(dlnB), "%02X ", inB[j]);
|
||||||
|
|
||||||
sprintf(dlnAii + strlen(dlnAii), "%c", ((ca < 32) || (ca == 127)) ? '.' : ca);
|
sprintf(dlnAii + strlen(dlnAii), "%c", ((ca < 32) || (ca == 127)) ? '.' : ca);
|
||||||
sprintf(dlnBii + strlen(dlnBii), "%c", ((cb < 32) || (cb == 127)) ? '.' : cb);
|
sprintf(dlnBii + strlen(dlnBii), "%c", ((cb < 32) || (cb == 127)) ? '.' : cb);
|
||||||
}
|
}
|
||||||
|
@ -3166,6 +3163,49 @@ static int CmdDiff(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "%03X | %s", i, line);
|
PrintAndLogEx(INFO, "%03X | %s", i, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mod
|
||||||
|
|
||||||
|
|
||||||
|
// print different length
|
||||||
|
bool tallestA = (datalenA > datalenB);
|
||||||
|
if (tallestA) {
|
||||||
|
n = datalenA;
|
||||||
|
} else {
|
||||||
|
n = datalenB;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print data diff loop
|
||||||
|
for (; i < n; i += width ) {
|
||||||
|
|
||||||
|
memset(line, 0, sizeof(line));
|
||||||
|
|
||||||
|
if (tallestA) {
|
||||||
|
hex_to_buffer((uint8_t*)line, inA + i, width, width, 0, 1, true);
|
||||||
|
ascii_to_buffer((uint8_t*)(line + strlen(line)), inA + i, width, width, 0);
|
||||||
|
strcat(line + strlen(line), " | ");
|
||||||
|
for (int j = 0; j < width; j++) {
|
||||||
|
strcat(line + strlen(line), "-- ");
|
||||||
|
}
|
||||||
|
for (int j = 0; j < width; j++) {
|
||||||
|
strcat(line + strlen(line), ".");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
for (int j = 0; j < width; j++) {
|
||||||
|
strcat(line + strlen(line), "-- ");
|
||||||
|
}
|
||||||
|
for (int j = 0; j < width; j++) {
|
||||||
|
strcat(line + strlen(line), ".");
|
||||||
|
}
|
||||||
|
strcat(line + strlen(line), " | ");
|
||||||
|
hex_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0, 1, true);
|
||||||
|
ascii_to_buffer((uint8_t*)(line + strlen(line)), inB + i, width, width, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintAndLogEx(INFO, "%03X | %s", i, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// footer
|
||||||
PrintAndLogEx(INFO, hdr1);
|
PrintAndLogEx(INFO, hdr1);
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue