MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / HexDump

Function HexDump

Bcore/src/main/cpp/utils/HexDump.cpp:10–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "Log.h"
9
10void HexDump(char *buf, int len, int addr) {
11 int i, j, k;
12 char binstr[80];
13
14 for (i = 0; i < len; i++) {
15 if (0 == (i % 16)) {
16 sprintf(binstr, "%08x -", i + addr);
17 sprintf(binstr, "%s %02x", binstr, (unsigned char) buf[i]);
18 } else if (15 == (i % 16)) {
19 sprintf(binstr, "%s %02x", binstr, (unsigned char) buf[i]);
20 sprintf(binstr, "%s ", binstr);
21 for (j = i - 15; j <= i; j++) {
22 sprintf(binstr, "%s%c", binstr, ('!' < buf[j] && buf[j] <= '~') ? buf[j] : '.');
23 }
24 ALOGE("%s\n", binstr);
25 } else {
26 sprintf(binstr, "%s %02x", binstr, (unsigned char) buf[i]);
27 }
28 }
29 if (0 != (i % 16)) {
30 k = 16 - (i % 16);
31 for (j = 0; j < k; j++) {
32 sprintf(binstr, "%s ", binstr);
33 }
34 sprintf(binstr, "%s ", binstr);
35 k = 16 - k;
36 for (j = i - k; j < i; j++) {
37 sprintf(binstr, "%s%c", binstr, ('!' < buf[j] && buf[j] <= '~') ? buf[j] : '.');
38 }
39 ALOGE("%s\n", binstr);
40 }
41}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected