metasm 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.hgtags +3 -0
  4. data/Gemfile +1 -0
  5. data/INSTALL +61 -0
  6. data/LICENCE +458 -0
  7. data/README +29 -21
  8. data/Rakefile +10 -0
  9. data/TODO +10 -12
  10. data/doc/code_organisation.txt +2 -0
  11. data/doc/core/DynLdr.txt +247 -0
  12. data/doc/core/ExeFormat.txt +43 -0
  13. data/doc/core/Expression.txt +220 -0
  14. data/doc/core/GNUExports.txt +27 -0
  15. data/doc/core/Ia32.txt +236 -0
  16. data/doc/core/SerialStruct.txt +108 -0
  17. data/doc/core/VirtualString.txt +145 -0
  18. data/doc/core/WindowsExports.txt +61 -0
  19. data/doc/core/index.txt +1 -0
  20. data/doc/style.css +6 -3
  21. data/doc/usage/debugger.txt +327 -0
  22. data/doc/usage/index.txt +1 -0
  23. data/doc/use_cases.txt +2 -2
  24. data/metasm.gemspec +22 -0
  25. data/{lib/metasm.rb → metasm.rb} +11 -3
  26. data/{lib/metasm → metasm}/compile_c.rb +13 -7
  27. data/metasm/cpu/arc.rb +8 -0
  28. data/metasm/cpu/arc/decode.rb +425 -0
  29. data/metasm/cpu/arc/main.rb +191 -0
  30. data/metasm/cpu/arc/opcodes.rb +588 -0
  31. data/{lib/metasm → metasm/cpu}/arm.rb +7 -5
  32. data/{lib/metasm → metasm/cpu}/arm/debug.rb +2 -2
  33. data/{lib/metasm → metasm/cpu}/arm/decode.rb +13 -12
  34. data/{lib/metasm → metasm/cpu}/arm/encode.rb +23 -8
  35. data/{lib/metasm → metasm/cpu}/arm/main.rb +0 -3
  36. data/metasm/cpu/arm/opcodes.rb +324 -0
  37. data/{lib/metasm → metasm/cpu}/arm/parse.rb +25 -13
  38. data/{lib/metasm → metasm/cpu}/arm/render.rb +2 -2
  39. data/metasm/cpu/arm64.rb +15 -0
  40. data/metasm/cpu/arm64/debug.rb +38 -0
  41. data/metasm/cpu/arm64/decode.rb +289 -0
  42. data/metasm/cpu/arm64/encode.rb +41 -0
  43. data/metasm/cpu/arm64/main.rb +105 -0
  44. data/metasm/cpu/arm64/opcodes.rb +232 -0
  45. data/metasm/cpu/arm64/parse.rb +20 -0
  46. data/metasm/cpu/arm64/render.rb +95 -0
  47. data/{lib/metasm/ppc.rb → metasm/cpu/bpf.rb} +2 -4
  48. data/metasm/cpu/bpf/decode.rb +142 -0
  49. data/metasm/cpu/bpf/main.rb +60 -0
  50. data/metasm/cpu/bpf/opcodes.rb +81 -0
  51. data/metasm/cpu/bpf/render.rb +41 -0
  52. data/metasm/cpu/cy16.rb +9 -0
  53. data/metasm/cpu/cy16/decode.rb +253 -0
  54. data/metasm/cpu/cy16/main.rb +63 -0
  55. data/metasm/cpu/cy16/opcodes.rb +78 -0
  56. data/metasm/cpu/cy16/render.rb +41 -0
  57. data/metasm/cpu/dalvik.rb +11 -0
  58. data/{lib/metasm → metasm/cpu}/dalvik/decode.rb +35 -13
  59. data/{lib/metasm → metasm/cpu}/dalvik/main.rb +51 -2
  60. data/{lib/metasm → metasm/cpu}/dalvik/opcodes.rb +19 -11
  61. data/metasm/cpu/ia32.rb +17 -0
  62. data/{lib/metasm → metasm/cpu}/ia32/compile_c.rb +5 -7
  63. data/{lib/metasm → metasm/cpu}/ia32/debug.rb +5 -5
  64. data/{lib/metasm → metasm/cpu}/ia32/decode.rb +246 -59
  65. data/{lib/metasm → metasm/cpu}/ia32/decompile.rb +7 -7
  66. data/{lib/metasm → metasm/cpu}/ia32/encode.rb +19 -13
  67. data/{lib/metasm → metasm/cpu}/ia32/main.rb +51 -8
  68. data/metasm/cpu/ia32/opcodes.rb +1424 -0
  69. data/{lib/metasm → metasm/cpu}/ia32/parse.rb +47 -16
  70. data/{lib/metasm → metasm/cpu}/ia32/render.rb +31 -4
  71. data/metasm/cpu/mips.rb +14 -0
  72. data/{lib/metasm → metasm/cpu}/mips/compile_c.rb +1 -1
  73. data/metasm/cpu/mips/debug.rb +42 -0
  74. data/{lib/metasm → metasm/cpu}/mips/decode.rb +46 -16
  75. data/{lib/metasm → metasm/cpu}/mips/encode.rb +4 -3
  76. data/{lib/metasm → metasm/cpu}/mips/main.rb +11 -4
  77. data/{lib/metasm → metasm/cpu}/mips/opcodes.rb +86 -17
  78. data/{lib/metasm → metasm/cpu}/mips/parse.rb +1 -1
  79. data/{lib/metasm → metasm/cpu}/mips/render.rb +1 -1
  80. data/{lib/metasm/dalvik.rb → metasm/cpu/msp430.rb} +1 -1
  81. data/metasm/cpu/msp430/decode.rb +247 -0
  82. data/metasm/cpu/msp430/main.rb +62 -0
  83. data/metasm/cpu/msp430/opcodes.rb +101 -0
  84. data/{lib/metasm → metasm/cpu}/pic16c/decode.rb +6 -7
  85. data/{lib/metasm → metasm/cpu}/pic16c/main.rb +0 -0
  86. data/{lib/metasm → metasm/cpu}/pic16c/opcodes.rb +1 -1
  87. data/{lib/metasm/mips.rb → metasm/cpu/ppc.rb} +4 -4
  88. data/{lib/metasm → metasm/cpu}/ppc/decode.rb +18 -12
  89. data/{lib/metasm → metasm/cpu}/ppc/decompile.rb +3 -3
  90. data/{lib/metasm → metasm/cpu}/ppc/encode.rb +2 -2
  91. data/{lib/metasm → metasm/cpu}/ppc/main.rb +17 -12
  92. data/{lib/metasm → metasm/cpu}/ppc/opcodes.rb +11 -5
  93. data/metasm/cpu/ppc/parse.rb +55 -0
  94. data/metasm/cpu/python.rb +8 -0
  95. data/metasm/cpu/python/decode.rb +136 -0
  96. data/metasm/cpu/python/main.rb +36 -0
  97. data/metasm/cpu/python/opcodes.rb +180 -0
  98. data/{lib/metasm → metasm/cpu}/sh4.rb +1 -1
  99. data/{lib/metasm → metasm/cpu}/sh4/decode.rb +48 -17
  100. data/{lib/metasm → metasm/cpu}/sh4/main.rb +13 -4
  101. data/{lib/metasm → metasm/cpu}/sh4/opcodes.rb +7 -8
  102. data/metasm/cpu/x86_64.rb +15 -0
  103. data/{lib/metasm → metasm/cpu}/x86_64/compile_c.rb +28 -17
  104. data/{lib/metasm → metasm/cpu}/x86_64/debug.rb +4 -4
  105. data/{lib/metasm → metasm/cpu}/x86_64/decode.rb +57 -15
  106. data/{lib/metasm → metasm/cpu}/x86_64/encode.rb +55 -26
  107. data/{lib/metasm → metasm/cpu}/x86_64/main.rb +14 -6
  108. data/metasm/cpu/x86_64/opcodes.rb +136 -0
  109. data/{lib/metasm → metasm/cpu}/x86_64/parse.rb +10 -2
  110. data/metasm/cpu/x86_64/render.rb +35 -0
  111. data/metasm/cpu/z80.rb +9 -0
  112. data/metasm/cpu/z80/decode.rb +313 -0
  113. data/metasm/cpu/z80/main.rb +67 -0
  114. data/metasm/cpu/z80/opcodes.rb +224 -0
  115. data/metasm/cpu/z80/render.rb +59 -0
  116. data/{lib/metasm/os/main.rb → metasm/debug.rb} +160 -401
  117. data/{lib/metasm → metasm}/decode.rb +35 -4
  118. data/{lib/metasm → metasm}/decompile.rb +15 -16
  119. data/{lib/metasm → metasm}/disassemble.rb +201 -45
  120. data/{lib/metasm → metasm}/disassemble_api.rb +651 -87
  121. data/{lib/metasm → metasm}/dynldr.rb +220 -133
  122. data/{lib/metasm → metasm}/encode.rb +10 -1
  123. data/{lib/metasm → metasm}/exe_format/a_out.rb +9 -6
  124. data/{lib/metasm → metasm}/exe_format/autoexe.rb +1 -0
  125. data/{lib/metasm → metasm}/exe_format/bflt.rb +57 -27
  126. data/{lib/metasm → metasm}/exe_format/coff.rb +11 -3
  127. data/{lib/metasm → metasm}/exe_format/coff_decode.rb +53 -20
  128. data/{lib/metasm → metasm}/exe_format/coff_encode.rb +11 -13
  129. data/{lib/metasm → metasm}/exe_format/dex.rb +13 -5
  130. data/{lib/metasm → metasm}/exe_format/dol.rb +1 -0
  131. data/{lib/metasm → metasm}/exe_format/elf.rb +93 -57
  132. data/{lib/metasm → metasm}/exe_format/elf_decode.rb +143 -34
  133. data/{lib/metasm → metasm}/exe_format/elf_encode.rb +122 -31
  134. data/metasm/exe_format/gb.rb +65 -0
  135. data/metasm/exe_format/javaclass.rb +424 -0
  136. data/{lib/metasm → metasm}/exe_format/macho.rb +204 -16
  137. data/{lib/metasm → metasm}/exe_format/main.rb +26 -3
  138. data/{lib/metasm → metasm}/exe_format/mz.rb +1 -0
  139. data/{lib/metasm → metasm}/exe_format/nds.rb +7 -4
  140. data/{lib/metasm → metasm}/exe_format/pe.rb +71 -8
  141. data/metasm/exe_format/pyc.rb +167 -0
  142. data/{lib/metasm → metasm}/exe_format/serialstruct.rb +67 -14
  143. data/{lib/metasm → metasm}/exe_format/shellcode.rb +7 -3
  144. data/metasm/exe_format/shellcode_rwx.rb +114 -0
  145. data/metasm/exe_format/swf.rb +205 -0
  146. data/{lib/metasm → metasm}/exe_format/xcoff.rb +7 -7
  147. data/metasm/exe_format/zip.rb +335 -0
  148. data/metasm/gui.rb +13 -0
  149. data/{lib/metasm → metasm}/gui/cstruct.rb +35 -41
  150. data/{lib/metasm → metasm}/gui/dasm_coverage.rb +11 -11
  151. data/{lib/metasm → metasm}/gui/dasm_decomp.rb +7 -20
  152. data/{lib/metasm → metasm}/gui/dasm_funcgraph.rb +0 -0
  153. data/metasm/gui/dasm_graph.rb +1695 -0
  154. data/{lib/metasm → metasm}/gui/dasm_hex.rb +12 -8
  155. data/{lib/metasm → metasm}/gui/dasm_listing.rb +43 -28
  156. data/{lib/metasm → metasm}/gui/dasm_main.rb +310 -53
  157. data/{lib/metasm → metasm}/gui/dasm_opcodes.rb +5 -19
  158. data/{lib/metasm → metasm}/gui/debug.rb +93 -27
  159. data/{lib/metasm → metasm}/gui/gtk.rb +162 -40
  160. data/{lib/metasm → metasm}/gui/qt.rb +12 -2
  161. data/{lib/metasm → metasm}/gui/win32.rb +179 -42
  162. data/{lib/metasm → metasm}/gui/x11.rb +59 -59
  163. data/{lib/metasm → metasm}/main.rb +389 -264
  164. data/{lib/metasm/os/remote.rb → metasm/os/gdbremote.rb} +146 -54
  165. data/{lib/metasm → metasm}/os/gnu_exports.rb +1 -1
  166. data/{lib/metasm → metasm}/os/linux.rb +628 -151
  167. data/metasm/os/main.rb +330 -0
  168. data/{lib/metasm → metasm}/os/windows.rb +132 -42
  169. data/{lib/metasm → metasm}/os/windows_exports.rb +141 -0
  170. data/{lib/metasm → metasm}/parse.rb +26 -24
  171. data/{lib/metasm → metasm}/parse_c.rb +221 -116
  172. data/{lib/metasm → metasm}/preprocessor.rb +55 -40
  173. data/{lib/metasm → metasm}/render.rb +14 -38
  174. data/misc/hexdump.rb +2 -1
  175. data/misc/lint.rb +58 -0
  176. data/misc/txt2html.rb +9 -7
  177. data/samples/bindiff.rb +3 -4
  178. data/samples/dasm-plugins/bindiff.rb +15 -0
  179. data/samples/dasm-plugins/bookmark.rb +133 -0
  180. data/samples/dasm-plugins/c_constants.rb +57 -0
  181. data/samples/dasm-plugins/colortheme_solarized.rb +125 -0
  182. data/samples/dasm-plugins/cppobj_funcall.rb +60 -0
  183. data/samples/dasm-plugins/dasm_all.rb +70 -0
  184. data/samples/dasm-plugins/demangle_cpp.rb +31 -0
  185. data/samples/dasm-plugins/deobfuscate.rb +251 -0
  186. data/samples/dasm-plugins/dump_text.rb +35 -0
  187. data/samples/dasm-plugins/export_graph_svg.rb +86 -0
  188. data/samples/dasm-plugins/findgadget.rb +75 -0
  189. data/samples/dasm-plugins/hl_opcode.rb +32 -0
  190. data/samples/dasm-plugins/hotfix_gtk_dbg.rb +19 -0
  191. data/samples/dasm-plugins/imm2off.rb +34 -0
  192. data/samples/dasm-plugins/match_libsigs.rb +93 -0
  193. data/samples/dasm-plugins/patch_file.rb +95 -0
  194. data/samples/dasm-plugins/scanfuncstart.rb +36 -0
  195. data/samples/dasm-plugins/scanxrefs.rb +26 -0
  196. data/samples/dasm-plugins/selfmodify.rb +197 -0
  197. data/samples/dasm-plugins/stringsxrefs.rb +28 -0
  198. data/samples/dasmnavig.rb +1 -1
  199. data/samples/dbg-apihook.rb +24 -9
  200. data/samples/dbg-plugins/heapscan.rb +283 -0
  201. data/samples/dbg-plugins/heapscan/compiled_heapscan_lin.c +155 -0
  202. data/samples/dbg-plugins/heapscan/compiled_heapscan_win.c +128 -0
  203. data/samples/dbg-plugins/heapscan/graphheap.rb +616 -0
  204. data/samples/dbg-plugins/heapscan/heapscan.rb +709 -0
  205. data/samples/dbg-plugins/heapscan/winheap.h +174 -0
  206. data/samples/dbg-plugins/heapscan/winheap7.h +307 -0
  207. data/samples/dbg-plugins/trace_func.rb +214 -0
  208. data/samples/disassemble-gui.rb +35 -5
  209. data/samples/disassemble.rb +31 -6
  210. data/samples/dump_upx.rb +24 -12
  211. data/samples/dynamic_ruby.rb +12 -3
  212. data/samples/exeencode.rb +6 -5
  213. data/samples/factorize-headers-peimports.rb +1 -1
  214. data/samples/lindebug.rb +175 -381
  215. data/samples/metasm-shell.rb +1 -2
  216. data/samples/peldr.rb +2 -2
  217. data/tests/all.rb +1 -1
  218. data/tests/arc.rb +26 -0
  219. data/tests/dynldr.rb +22 -4
  220. data/tests/expression.rb +55 -0
  221. data/tests/graph_layout.rb +285 -0
  222. data/tests/ia32.rb +79 -26
  223. data/tests/mips.rb +9 -2
  224. data/tests/x86_64.rb +66 -18
  225. metadata +330 -218
  226. data/lib/metasm/arm/opcodes.rb +0 -177
  227. data/lib/metasm/gui.rb +0 -23
  228. data/lib/metasm/gui/dasm_graph.rb +0 -1354
  229. data/lib/metasm/ia32.rb +0 -14
  230. data/lib/metasm/ia32/opcodes.rb +0 -873
  231. data/lib/metasm/ppc/parse.rb +0 -52
  232. data/lib/metasm/x86_64.rb +0 -12
  233. data/lib/metasm/x86_64/opcodes.rb +0 -118
  234. data/samples/gdbclient.rb +0 -583
  235. data/samples/rubstop.rb +0 -399
@@ -0,0 +1,174 @@
1
+ typedef void VOID;
2
+ typedef unsigned __int8 UINT8;
3
+ typedef unsigned __int16 UINT16;
4
+ typedef __int32 LONG32;
5
+ typedef unsigned __int32 ULONG32;
6
+ typedef unsigned __int64 UINT64;
7
+
8
+ // pseudo struct, for the PEB heap list
9
+ struct HEAPTABLE {
10
+ struct _HEAP *list[16];
11
+ };
12
+
13
+ struct _LIST_ENTRY {
14
+ struct _LIST_ENTRY *FLink;
15
+ struct _LIST_ENTRY *BLink;
16
+ };
17
+
18
+ union _SLIST_HEADER {
19
+ struct _LIST_ENTRY le;
20
+ };
21
+
22
+ typedef struct _HEAP_ENTRY // 7 elements, 0x8 bytes (sizeof)
23
+ {
24
+ // union // 2 elements, 0x4 bytes (sizeof)
25
+ // {
26
+ // struct // 2 elements, 0x4 bytes (sizeof)
27
+ // {
28
+ /*0x000*/ UINT16 Size;
29
+ /*0x002*/ UINT16 PreviousSize;
30
+ // };
31
+ ///*0x000*/ VOID* SubSegmentCode;
32
+ // };
33
+ /*0x004*/ UINT8 SmallTagIndex;
34
+ /*0x005*/ UINT8 Flags;
35
+ /*0x006*/ UINT8 UnusedBytes;
36
+ /*0x007*/ UINT8 SegmentIndex;
37
+ }HEAP_ENTRY, *PHEAP_ENTRY;
38
+
39
+ typedef struct _HEAP // 36 elements, 0x588 bytes (sizeof)
40
+ {
41
+ /*0x000*/ struct _HEAP_ENTRY Entry; // 7 elements, 0x8 bytes (sizeof)
42
+ /*0x008*/ ULONG32 Signature;
43
+ /*0x00C*/ ULONG32 Flags;
44
+ /*0x010*/ ULONG32 ForceFlags;
45
+ /*0x014*/ ULONG32 VirtualMemoryThreshold;
46
+ /*0x018*/ ULONG32 SegmentReserve;
47
+ /*0x01C*/ ULONG32 SegmentCommit;
48
+ /*0x020*/ ULONG32 DeCommitFreeBlockThreshold;
49
+ /*0x024*/ ULONG32 DeCommitTotalFreeThreshold;
50
+ /*0x028*/ ULONG32 TotalFreeSize;
51
+ /*0x02C*/ ULONG32 MaximumAllocationSize;
52
+ /*0x030*/ UINT16 ProcessHeapsListIndex;
53
+ /*0x032*/ UINT16 HeaderValidateLength;
54
+ /*0x034*/ VOID* HeaderValidateCopy;
55
+ /*0x038*/ UINT16 NextAvailableTagIndex;
56
+ /*0x03A*/ UINT16 MaximumTagIndex;
57
+ /*0x03C*/ struct _HEAP_TAG_ENTRY* TagEntries;
58
+ /*0x040*/ struct _HEAP_UCR_SEGMENT* UCRSegments;
59
+ /*0x044*/ struct _HEAP_UNCOMMMTTED_RANGE* UnusedUnCommittedRanges;
60
+ /*0x048*/ ULONG32 AlignRound;
61
+ /*0x04C*/ ULONG32 AlignMask;
62
+ /*0x050*/ struct _LIST_ENTRY VirtualAllocdBlocks; // 2 elements, 0x8 bytes (sizeof)
63
+ /*0x058*/ struct _HEAP_SEGMENT* Segments[64];
64
+ union // 2 elements, 0x10 bytes (sizeof)
65
+ {
66
+ /*0x158*/ ULONG32 FreeListsInUseUlong[4];
67
+ /*0x158*/ UINT8 FreeListsInUseBytes[16];
68
+ }u;
69
+ union // 2 elements, 0x2 bytes (sizeof)
70
+ {
71
+ /*0x168*/ UINT16 FreeListsInUseTerminate;
72
+ /*0x168*/ UINT16 DecommitCount;
73
+ }u2;
74
+ /*0x16A*/ UINT16 AllocatorBackTraceIndex;
75
+ /*0x16C*/ ULONG32 NonDedicatedListLength;
76
+ /*0x170*/ VOID* LargeBlocksIndex;
77
+ /*0x174*/ struct _HEAP_PSEUDO_TAG_ENTRY* PseudoTagEntries;
78
+ /*0x178*/ struct _LIST_ENTRY FreeLists[128];
79
+ /*0x578*/ struct _HEAP_LOCK* LockVariable;
80
+ ///*0x57C*/ FUNCT_0049_0C5F_CommitRoutine* CommitRoutine;
81
+ /*0x57C*/ VOID* CommitRoutine;
82
+ /*0x580*/ VOID* FrontEndHeap;
83
+ /*0x584*/ UINT16 FrontHeapLockCount;
84
+ /*0x586*/ UINT8 FrontEndHeapType;
85
+ /*0x587*/ UINT8 LastSegmentIndex;
86
+ }HEAP, *PHEAP;
87
+
88
+ typedef struct _HEAP_UNCOMMMTTED_RANGE // 4 elements, 0x10 bytes (sizeof)
89
+ {
90
+ /*0x000*/ struct _HEAP_UNCOMMMTTED_RANGE* Next;
91
+ /*0x004*/ ULONG32 Address;
92
+ /*0x008*/ ULONG32 Size;
93
+ /*0x00C*/ ULONG32 filler;
94
+ }HEAP_UNCOMMMTTED_RANGE, *PHEAP_UNCOMMMTTED_RANGE;
95
+
96
+ typedef struct _HEAP_ENTRY_EXTRA // 4 elements, 0x8 bytes (sizeof)
97
+ {
98
+ union // 2 elements, 0x8 bytes (sizeof)
99
+ {
100
+ struct // 3 elements, 0x8 bytes (sizeof)
101
+ {
102
+ /*0x000*/ UINT16 AllocatorBackTraceIndex;
103
+ /*0x002*/ UINT16 TagIndex;
104
+ /*0x004*/ ULONG32 Settable;
105
+ };
106
+ /*0x000*/ UINT64 ZeroInit;
107
+ };
108
+ }HEAP_ENTRY_EXTRA, *PHEAP_ENTRY_EXTRA;
109
+
110
+ typedef struct _HEAP_VIRTUAL_ALLOC_ENTRY // 5 elements, 0x20 bytes (sizeof)
111
+ {
112
+ /*0x000*/ struct _LIST_ENTRY Entry; // 2 elements, 0x8 bytes (sizeof)
113
+ /*0x008*/ struct _HEAP_ENTRY_EXTRA ExtraStuff; // 4 elements, 0x8 bytes (sizeof)
114
+ /*0x010*/ ULONG32 CommitSize;
115
+ /*0x014*/ ULONG32 ReserveSize;
116
+ /*0x018*/ struct _HEAP_ENTRY BusyBlock; // 7 elements, 0x8 bytes (sizeof)
117
+ }HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY;
118
+
119
+
120
+ typedef struct _HEAP_FREE_ENTRY // 8 elements, 0x10 bytes (sizeof)
121
+ {
122
+ union // 2 elements, 0x4 bytes (sizeof)
123
+ {
124
+ struct // 2 elements, 0x4 bytes (sizeof)
125
+ {
126
+ /*0x000*/ UINT16 Size;
127
+ /*0x002*/ UINT16 PreviousSize;
128
+ };
129
+ /*0x000*/ VOID* SubSegmentCode;
130
+ };
131
+ /*0x004*/ UINT8 SmallTagIndex;
132
+ /*0x005*/ UINT8 Flags;
133
+ /*0x006*/ UINT8 UnusedBytes;
134
+ /*0x007*/ UINT8 SegmentIndex;
135
+ /*0x008*/ struct _LIST_ENTRY FreeList; // 2 elements, 0x8 bytes (sizeof)
136
+ }HEAP_FREE_ENTRY, *PHEAP_FREE_ENTRY;
137
+
138
+ typedef struct _HEAP_LOOKASIDE // 10 elements, 0x30 bytes (sizeof)
139
+ {
140
+ /*0x000*/ union _SLIST_HEADER ListHead; // 4 elements, 0x8 bytes (sizeof)
141
+ /*0x008*/ UINT16 Depth;
142
+ /*0x00A*/ UINT16 MaximumDepth;
143
+ /*0x00C*/ ULONG32 TotalAllocates;
144
+ /*0x010*/ ULONG32 AllocateMisses;
145
+ /*0x014*/ ULONG32 TotalFrees;
146
+ /*0x018*/ ULONG32 FreeMisses;
147
+ /*0x01C*/ ULONG32 LastTotalAllocates;
148
+ /*0x020*/ ULONG32 LastAllocateMisses;
149
+ /*0x024*/ ULONG32 Counters[2];
150
+ /*0x02C*/ UINT8 _PADDING0_[0x4];
151
+ }HEAP_LOOKASIDE, *PHEAP_LOOKASIDE;
152
+
153
+ struct FRONTEND1 {
154
+ struct _HEAP_LOOKASIDE l[128];
155
+ };
156
+
157
+ typedef struct _HEAP_SEGMENT // 15 elements, 0x3C bytes (sizeof)
158
+ {
159
+ /*0x000*/ struct _HEAP_ENTRY Entry; // 7 elements, 0x8 bytes (sizeof)
160
+ /*0x008*/ ULONG32 Signature;
161
+ /*0x00C*/ ULONG32 Flags;
162
+ /*0x010*/ struct _HEAP* Heap;
163
+ /*0x014*/ ULONG32 LargestUnCommittedRange;
164
+ /*0x018*/ VOID* BaseAddress;
165
+ /*0x01C*/ ULONG32 NumberOfPages;
166
+ /*0x020*/ struct _HEAP_ENTRY* FirstEntry;
167
+ /*0x024*/ struct _HEAP_ENTRY* LastValidEntry;
168
+ /*0x028*/ ULONG32 NumberOfUnCommittedPages;
169
+ /*0x02C*/ ULONG32 NumberOfUnCommittedRanges;
170
+ /*0x030*/ struct _HEAP_UNCOMMMTTED_RANGE* UnCommittedRanges;
171
+ /*0x034*/ UINT16 AllocatorBackTraceIndex;
172
+ /*0x036*/ UINT16 Reserved;
173
+ /*0x038*/ struct _HEAP_ENTRY* LastEntryInSegment;
174
+ }HEAP_SEGMENT, *PHEAP_SEGMENT;
@@ -0,0 +1,307 @@
1
+ typedef void VOID;
2
+ typedef unsigned __int8 UINT8;
3
+ typedef unsigned __int16 UINT16, WCHAR;
4
+ typedef __int32 LONG32;
5
+ typedef unsigned __int32 ULONG32;
6
+ typedef __int64 INT64;
7
+ typedef unsigned __int64 UINT64;
8
+
9
+ struct HEAPTABLE {
10
+ struct _HEAP *list[16];
11
+ };
12
+
13
+ struct _LIST_ENTRY {
14
+ struct _LIST_ENTRY *FLink;
15
+ struct _LIST_ENTRY *BLink;
16
+ };
17
+
18
+ typedef struct _SLIST_HEADER {
19
+ struct _SLIST_HEADER *Next;
20
+ UINT16 Depth;
21
+ UINT16 Sequence;
22
+ } SLIST_HEADER, *PSLIST_HEADER;
23
+
24
+ struct _SINGLE_LIST_ENTRY {
25
+ struct _SINGLE_LIST_ENTRY *Next;
26
+ };
27
+
28
+
29
+ typedef struct _HEAP_ENTRY {
30
+ VOID* PreviousBlockPrivateData;
31
+ UINT16 Size;
32
+ UINT8 Flags;
33
+ UINT8 SmallTagIndex;
34
+ UINT16 PreviousSize;
35
+ union
36
+ {
37
+ UINT8 SegmentOffset;
38
+ UINT8 LFHFlags;
39
+ };
40
+ UINT8 UnusedBytes;
41
+ } HEAP_ENTRY, *PHEAP_ENTRY;
42
+
43
+ typedef struct _HEAP_COUNTERS
44
+ {
45
+ ULONG32 TotalMemoryReserved;
46
+ ULONG32 TotalMemoryCommitted;
47
+ ULONG32 TotalMemoryLargeUCR;
48
+ ULONG32 TotalSizeInVirtualBlocks;
49
+ ULONG32 TotalSegments;
50
+ ULONG32 TotalUCRs;
51
+ ULONG32 CommittOps;
52
+ ULONG32 DeCommitOps;
53
+ ULONG32 LockAcquires;
54
+ ULONG32 LockCollisions;
55
+ ULONG32 CommitRate;
56
+ ULONG32 DecommittRate;
57
+ ULONG32 CommitFailures;
58
+ ULONG32 InBlockCommitFailures;
59
+ ULONG32 CompactHeapCalls;
60
+ ULONG32 CompactedUCRs;
61
+ ULONG32 AllocAndFreeOps;
62
+ ULONG32 InBlockDeccommits;
63
+ ULONG32 InBlockDeccomitSize;
64
+ ULONG32 HighWatermarkSize;
65
+ ULONG32 LastPolledSize;
66
+ } HEAP_COUNTERS, *PHEAP_COUNTERS;
67
+
68
+ typedef struct _HEAP_TUNING_PARAMETERS
69
+ {
70
+ ULONG32 CommittThresholdShift;
71
+ ULONG32 MaxPreCommittThreshold;
72
+ } HEAP_TUNING_PARAMETERS, *PHEAP_TUNING_PARAMETERS;
73
+
74
+ typedef struct _HEAP_SEGMENT
75
+ {
76
+ struct _HEAP_ENTRY Entry;
77
+ ULONG32 SegmentSignature;
78
+ ULONG32 SegmentFlags;
79
+ struct _LIST_ENTRY SegmentListEntry;
80
+ struct _HEAP* Heap;
81
+ VOID* BaseAddress;
82
+ ULONG32 NumberOfPages;
83
+ struct _HEAP_ENTRY* FirstEntry;
84
+ struct _HEAP_ENTRY* LastValidEntry;
85
+ ULONG32 NumberOfUnCommittedPages;
86
+ ULONG32 NumberOfUnCommittedRanges;
87
+ UINT16 SegmentAllocatorBackTraceIndex;
88
+ UINT16 Reserved;
89
+ struct _LIST_ENTRY UCRSegmentList;
90
+ } HEAP_SEGMENT, *PHEAP_SEGMENT;
91
+
92
+ typedef struct _HEAP
93
+ {
94
+ struct _HEAP_SEGMENT Segment;
95
+ ULONG32 Flags;
96
+ ULONG32 ForceFlags;
97
+ ULONG32 CompatibilityFlags;
98
+ ULONG32 EncodeFlagMask;
99
+ struct _HEAP_ENTRY Encoding;
100
+ ULONG32 PointerKey;
101
+ ULONG32 Interceptor;
102
+ ULONG32 VirtualMemoryThreshold;
103
+ ULONG32 Signature;
104
+ ULONG32 SegmentReserve;
105
+ ULONG32 SegmentCommit;
106
+ ULONG32 DeCommitFreeBlockThreshold;
107
+ ULONG32 DeCommitTotalFreeThreshold;
108
+ ULONG32 TotalFreeSize;
109
+ ULONG32 MaximumAllocationSize;
110
+ UINT16 ProcessHeapsListIndex;
111
+ UINT16 HeaderValidateLength;
112
+ VOID* HeaderValidateCopy;
113
+ UINT16 NextAvailableTagIndex;
114
+ UINT16 MaximumTagIndex;
115
+ struct _HEAP_TAG_ENTRY* TagEntries;
116
+ struct _LIST_ENTRY UCRList;
117
+ ULONG32 AlignRound;
118
+ ULONG32 AlignMask;
119
+ struct _LIST_ENTRY VirtualAllocdBlocks;
120
+ struct _LIST_ENTRY SegmentList;
121
+ UINT16 AllocatorBackTraceIndex;
122
+ UINT8 _PADDING0_[0x2];
123
+ ULONG32 NonDedicatedListLength;
124
+ VOID* BlocksIndex;
125
+ VOID* UCRIndex;
126
+ struct _HEAP_PSEUDO_TAG_ENTRY* PseudoTagEntries;
127
+ struct _LIST_ENTRY FreeLists;
128
+ struct _HEAP_LOCK* LockVariable;
129
+ VOID* CommitRoutine;
130
+ VOID* FrontEndHeap;
131
+ UINT16 FrontHeapLockCount;
132
+ UINT8 FrontEndHeapType;
133
+ UINT8 _PADDING1_[0x1];
134
+ struct _HEAP_COUNTERS Counters;
135
+ struct _HEAP_TUNING_PARAMETERS TuningParameters;
136
+ } HEAP, *PHEAP;
137
+
138
+ typedef struct _HEAP_ENTRY_EXTRA
139
+ {
140
+ union
141
+ {
142
+ struct
143
+ {
144
+ UINT16 AllocatorBackTraceIndex;
145
+ UINT16 TagIndex;
146
+ ULONG32 Settable;
147
+ };
148
+ UINT64 ZeroInit;
149
+ };
150
+ } HEAP_ENTRY_EXTRA, *PHEAP_ENTRY_EXTRA;
151
+
152
+ typedef struct _HEAP_FREE_ENTRY
153
+ {
154
+ struct _HEAP_ENTRY Entry;
155
+ struct _LIST_ENTRY FreeList;
156
+ } HEAP_FREE_ENTRY, *PHEAP_FREE_ENTRY;
157
+
158
+ typedef struct _HEAP_LIST_LOOKUP
159
+ {
160
+ struct _HEAP_LIST_LOOKUP* ExtendedLookup;
161
+ ULONG32 ArraySize;
162
+ ULONG32 ExtraItem;
163
+ ULONG32 ItemCount;
164
+ ULONG32 OutOfRangeItems;
165
+ ULONG32 BaseIndex;
166
+ struct _LIST_ENTRY* ListHead;
167
+ ULONG32* ListsInUseUlong;
168
+ struct _LIST_ENTRY** ListHints;
169
+ } HEAP_LIST_LOOKUP, *PHEAP_LIST_LOOKUP;
170
+
171
+ typedef struct _HEAP_LOOKASIDE
172
+ {
173
+ struct _SLIST_HEADER ListHead;
174
+ UINT16 Depth;
175
+ UINT16 MaximumDepth;
176
+ ULONG32 TotalAllocates;
177
+ ULONG32 AllocateMisses;
178
+ ULONG32 TotalFrees;
179
+ ULONG32 FreeMisses;
180
+ ULONG32 LastTotalAllocates;
181
+ ULONG32 LastAllocateMisses;
182
+ ULONG32 Counters[2];
183
+ UINT8 _PADDING0_[0x4];
184
+ } HEAP_LOOKASIDE, *PHEAP_LOOKASIDE;
185
+
186
+ typedef struct _INTERLOCK_SEQ
187
+ {
188
+ union
189
+ {
190
+ struct
191
+ {
192
+ UINT16 Depth;
193
+ UINT16 FreeEntryOffset;
194
+ UINT8 _PADDING0_[0x4];
195
+ };
196
+ struct
197
+ {
198
+ ULONG32 OffsetAndDepth;
199
+ ULONG32 Sequence;
200
+ };
201
+ INT64 Exchg;
202
+ };
203
+ }INTERLOCK_SEQ, *PINTERLOCK_SEQ;
204
+
205
+ typedef struct _HEAP_TAG_ENTRY
206
+ {
207
+ ULONG32 Allocs;
208
+ ULONG32 Frees;
209
+ ULONG32 Size;
210
+ UINT16 TagIndex;
211
+ UINT16 CreatorBackTraceIndex;
212
+ WCHAR TagName[24];
213
+ } HEAP_TAG_ENTRY, *PHEAP_TAG_ENTRY;
214
+
215
+ typedef struct _HEAP_UCR_DESCRIPTOR
216
+ {
217
+ struct _LIST_ENTRY ListEntry;
218
+ struct _LIST_ENTRY SegmentEntry;
219
+ VOID* Address;
220
+ ULONG32 Size;
221
+ } HEAP_UCR_DESCRIPTOR, *PHEAP_UCR_DESCRIPTOR;
222
+
223
+ typedef struct _HEAP_USERDATA_HEADER
224
+ {
225
+ union
226
+ {
227
+ struct _SINGLE_LIST_ENTRY SFreeListEntry;
228
+ struct _HEAP_SUBSEGMENT* SubSegment;
229
+ };
230
+ VOID* Reserved;
231
+ ULONG32 SizeIndex;
232
+ ULONG32 Signature;
233
+ } HEAP_USERDATA_HEADER, *PHEAP_USERDATA_HEADER;
234
+
235
+ typedef struct _HEAP_VIRTUAL_ALLOC_ENTRY
236
+ {
237
+ struct _LIST_ENTRY Entry;
238
+ struct _HEAP_ENTRY_EXTRA ExtraStuff;
239
+ ULONG32 CommitSize;
240
+ ULONG32 ReserveSize;
241
+ struct _HEAP_ENTRY BusyBlock;
242
+ } HEAP_VIRTUAL_ALLOC_ENTRY, *PHEAP_VIRTUAL_ALLOC_ENTRY;
243
+
244
+ struct _USER_MEMORY_CACHE_ENTRY {
245
+ ULONG32 Foo[4];
246
+ };
247
+ struct _HEAP_BUCKET {
248
+ ULONG32 Foo;
249
+ };
250
+ struct _HEAP_BUCKET_COUNTERS {
251
+ ULONG32 Foo[2];
252
+ };
253
+
254
+ typedef struct _HEAP_LOCAL_SEGMENT_INFO
255
+ {
256
+ struct _HEAP_SUBSEGMENT* Hint;
257
+ struct _HEAP_SUBSEGMENT* ActiveSubsegment;
258
+ struct _HEAP_SUBSEGMENT* CachedItems[16];
259
+ struct _SLIST_HEADER SListHeader;
260
+ struct _HEAP_BUCKET_COUNTERS Counters;
261
+ struct _HEAP_LOCAL_DATA* LocalData;
262
+ ULONG32 LastOpSequence;
263
+ UINT16 BucketIndex;
264
+ UINT16 LastUsed;
265
+ ULONG32 Pad;
266
+ } HEAP_LOCAL_SEGMENT_INFO, *PHEAP_LOCAL_SEGMENT_INFO;
267
+
268
+ typedef struct _HEAP_LOCAL_DATA {
269
+ struct _SLIST_HEADER DeletedSubSegments;
270
+ struct _LFH_BLOCK_ZONE* CrtZone;
271
+ struct _LFH_HEAP* LowFragHeap;
272
+ ULONG32 Sequence;
273
+ struct _HEAP_LOCAL_SEGMENT_INFO SegmentInfo[128];
274
+ } HEAP_LOCAL_DATA;
275
+
276
+ typedef struct _HEAP_SUBSEGMENT
277
+ {
278
+ struct _HEAP_LOCAL_SEGMENT_INFO* LocalInfo;
279
+ struct _HEAP_USERDATA_HEADER* UserBlocks;
280
+ struct _INTERLOCK_SEQ AggregateExchg;
281
+ UINT16 BlockSize;
282
+ UINT16 Flags;
283
+ UINT16 BlockCount;
284
+ UINT8 SizeIndex;
285
+ UINT8 AffinityIndex;
286
+ struct _SINGLE_LIST_ENTRY SFreeListEntry;
287
+ ULONG32 Lock;
288
+ } HEAP_SUBSEGMENT, *PHEAP_SUBSEGMENT;
289
+
290
+ typedef struct _LFH_HEAP
291
+ {
292
+ ULONG32 Lock[6];
293
+ struct _LIST_ENTRY SubSegmentZones;
294
+ ULONG32 ZoneBlockSize;
295
+ VOID* Heap;
296
+ ULONG32 SegmentChange;
297
+ ULONG32 SegmentCreate;
298
+ ULONG32 SegmentInsertInFree;
299
+ ULONG32 SegmentDelete;
300
+ ULONG32 CacheAllocs;
301
+ ULONG32 CacheFrees;
302
+ ULONG32 SizeInCache;
303
+ ULONG32 RunInfo[3];
304
+ struct _USER_MEMORY_CACHE_ENTRY UserBlockCache[12];
305
+ struct _HEAP_BUCKET Buckets[128];
306
+ struct _HEAP_LOCAL_DATA LocalData[1];
307
+ } LFH_HEAP;