This commit is contained in:
iceman1001 2024-01-18 16:41:13 +01:00
parent b19973368d
commit 22fd440c83
14 changed files with 270 additions and 222 deletions

View file

@ -1312,31 +1312,31 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo
// suppress repeating blocks, truncate as such that the first and last block with the same data is shown
// but the blocks in between are replaced with a single line of "......" if dense_output is enabled
if ( dense_output &&
(i > 6) &&
(i < (blocks - 1)) &&
(in_repeated_block == false) &&
(memcmp(blk, blk - blocksize, blocksize) == 0) &&
(memcmp(blk, blk + blocksize, blocksize) == 0) &&
(memcmp(blk, blk + (blocksize * 2), blocksize) == 0)
) {
if (dense_output &&
(i > 6) &&
(i < (blocks - 1)) &&
(in_repeated_block == false) &&
(memcmp(blk, blk - blocksize, blocksize) == 0) &&
(memcmp(blk, blk + blocksize, blocksize) == 0) &&
(memcmp(blk, blk + (blocksize * 2), blocksize) == 0)
) {
// we're in a user block that isn't the first user block nor last two user blocks,
// and the current block data is the same as the previous and next two block
in_repeated_block = true;
PrintAndLogEx(INFO, " ......");
} else if (in_repeated_block &&
(memcmp(blk, blk + blocksize, blocksize) || i == blocks)
) {
} else if (in_repeated_block &&
(memcmp(blk, blk + blocksize, blocksize) || i == blocks)
) {
// in a repeating block, but the next block doesn't match anymore, or we're at the end block
in_repeated_block = false;
}
if (in_repeated_block == false) {
PrintAndLogEx(INFO, "%4d | %s "
, i
, sprint_hex_ascii(blk, blocksize)
, blocksize
);
, i
, sprint_hex_ascii(blk, blocksize)
, blocksize
);
}
}
@ -1344,10 +1344,10 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize, boo
// If there is something left over print it too
// This will have a broken layout, but should not happen anyway
PrintAndLogEx(INFO, "%4d | %s "
, blocks
, sprint_hex_ascii(data + (blocks * blocksize)
, bytes % blocksize)
);
, blocks
, sprint_hex_ascii(data + (blocks * blocksize)
, bytes % blocksize)
);
}
print_hrule(blocksize);
@ -1372,7 +1372,7 @@ static int CmdHF15EView(const char *Cmd) {
CLIExecWithReturn(ctx, Cmd, argtable, true);
int blocksize = arg_get_int_def(ctx, 1, 4);
int count = arg_get_int_def(ctx, 2, -1);
bool dense_output = (g_session.dense_output || arg_get_lit(ctx, 3));
bool dense_output = (g_session.dense_output || arg_get_lit(ctx, 3));
CLIParserFree(ctx);
// santity checks
@ -1722,9 +1722,9 @@ static int CmdHF15Dump(const char *Cmd) {
void *argtable[6 + 5] = {0};
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_str0("f", "file", "<fn>", "Specify a filename for dump file"),
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0(NULL, "ns", "no save to file"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, true);
@ -2234,7 +2234,7 @@ static int CmdHF15Readblock(const char *Cmd) {
uint8_t arglen = arg_add_default(argtable);
argtable[arglen++] = arg_int1("b", "blk", "<dec>", "page number (0-255)");
argtable[arglen++] = arg_int0(NULL, "bs", "<dec>", "block size (def 4)"),
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_lit0("v", "verbose", "verbose output");
argtable[arglen++] = arg_param_end;
CLIExecWithReturn(ctx, Cmd, argtable, false);