ngr dump
Prints to stdout an annotated hexadecimal dump of a dex: the bytes of each section, with the name of each field and
its value next to it. You use it to look inside a dex, for example the one that has just come out of
ngr assemble. It writes no files.
Usage
ngr dump [options] <file>
Inputs
| Input | What it is |
|---|---|
<file> |
A dex, an apk or an xapk, or a dex inside an apk (app.apk/classes2.dex) |
From an apk or an xapk it reads all the dex files, in order. To name just one, treat the apk as if it were a folder.
Options
| Option | What it does | Default |
|---|---|---|
-h, --help |
Shows the help |
What it writes
It writes no files. The whole dump goes to stdout and it is long: a 1.5 KB dex gives about 800 lines, and a 21 KB one, more than 11,000. Redirect it to a file or a pager. The dump is divided into the sections of the dex, each with its header, and it starts with the dex header:
|
|-----------------------------
|header_item section
|-----------------------------
|
|[0] header_item
000000: 6465 780a 3033 3500| magic: dex\n035\u0000
000008: 25b0 5d8e | checksum
00000c: e8f1 7479 94fa f2b7| signature
000014: 9b63 defd c631 6302|
00001c: 24be 03c7 |
000020: 0406 0000 | file_size: 1540
000024: 7000 0000 | header_size: 112
000028: 7856 3412 | endian_tag: 0x12345678 (Little Endian)
Each line has the position and the bytes on the left, and the field they form on the right. The sections that come
out, in this order, are header_item, string_id_item, type_id_item, proto_id_item, field_id_item,
method_id_item, class_def_item, string_data_item, type_list, encoded_array_item, annotation_set_item,
debug_info_item, code_item, class_data_item and map_item. A long text value is split over several lines:
000210: 0300 0000 | class_idx = type_id_item[3]: Lcom/example/app/Coun
|ter;
With an apk or an xapk, the dump of each dex is preceded by a line with its name:
dex: classes.dex
...
dex: classes2.dex
With a single dex, whether bare or named inside an apk, there is no such line.
Examples
Dump a dex to a file:
ngr dump classes.dex > classes.dump.txt
See only the header:
ngr dump classes.dex | head -40
Dump the second dex of an apk:
ngr dump app.apk/classes2.dex > classes2.dump.txt
Dump all the dex files of an apk, one after another:
ngr dump app.apk > app.dump.txt
Exit codes
| Code | When |
|---|---|
| 0 | The dump was printed |
| 1 | The input does not exist, cannot be read or is not a dex, an apk or an xapk, or the dex you name is not in the apk |
| 2 | The options are wrong: for example, <file> is missing |
Things to know
- It goes to stdout and it is long. Always redirect it; the dump of an apk with several dex files can pass 12,000 lines.
- To list instead of dump,
ngr listshows the classes, the strings and the other tables of the dex, one per line. - A dex with call sites, method handles or hidden api restrictions is not dumped.
dumpends with code 1 and says it has no dumper for that section.
See also
ngr list, the tables of the dex as plain text.ngr disassemble, the code of the dex as smali.ngr assemble, which writes the dex examined here.