metasm 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.hgtags +3 -0
- data/Gemfile +1 -0
- data/INSTALL +61 -0
- data/LICENCE +458 -0
- data/README +29 -21
- data/Rakefile +10 -0
- data/TODO +10 -12
- data/doc/code_organisation.txt +2 -0
- data/doc/core/DynLdr.txt +247 -0
- data/doc/core/ExeFormat.txt +43 -0
- data/doc/core/Expression.txt +220 -0
- data/doc/core/GNUExports.txt +27 -0
- data/doc/core/Ia32.txt +236 -0
- data/doc/core/SerialStruct.txt +108 -0
- data/doc/core/VirtualString.txt +145 -0
- data/doc/core/WindowsExports.txt +61 -0
- data/doc/core/index.txt +1 -0
- data/doc/style.css +6 -3
- data/doc/usage/debugger.txt +327 -0
- data/doc/usage/index.txt +1 -0
- data/doc/use_cases.txt +2 -2
- data/metasm.gemspec +22 -0
- data/{lib/metasm.rb → metasm.rb} +11 -3
- data/{lib/metasm → metasm}/compile_c.rb +13 -7
- data/metasm/cpu/arc.rb +8 -0
- data/metasm/cpu/arc/decode.rb +425 -0
- data/metasm/cpu/arc/main.rb +191 -0
- data/metasm/cpu/arc/opcodes.rb +588 -0
- data/{lib/metasm → metasm/cpu}/arm.rb +7 -5
- data/{lib/metasm → metasm/cpu}/arm/debug.rb +2 -2
- data/{lib/metasm → metasm/cpu}/arm/decode.rb +13 -12
- data/{lib/metasm → metasm/cpu}/arm/encode.rb +23 -8
- data/{lib/metasm → metasm/cpu}/arm/main.rb +0 -3
- data/metasm/cpu/arm/opcodes.rb +324 -0
- data/{lib/metasm → metasm/cpu}/arm/parse.rb +25 -13
- data/{lib/metasm → metasm/cpu}/arm/render.rb +2 -2
- data/metasm/cpu/arm64.rb +15 -0
- data/metasm/cpu/arm64/debug.rb +38 -0
- data/metasm/cpu/arm64/decode.rb +289 -0
- data/metasm/cpu/arm64/encode.rb +41 -0
- data/metasm/cpu/arm64/main.rb +105 -0
- data/metasm/cpu/arm64/opcodes.rb +232 -0
- data/metasm/cpu/arm64/parse.rb +20 -0
- data/metasm/cpu/arm64/render.rb +95 -0
- data/{lib/metasm/ppc.rb → metasm/cpu/bpf.rb} +2 -4
- data/metasm/cpu/bpf/decode.rb +142 -0
- data/metasm/cpu/bpf/main.rb +60 -0
- data/metasm/cpu/bpf/opcodes.rb +81 -0
- data/metasm/cpu/bpf/render.rb +41 -0
- data/metasm/cpu/cy16.rb +9 -0
- data/metasm/cpu/cy16/decode.rb +253 -0
- data/metasm/cpu/cy16/main.rb +63 -0
- data/metasm/cpu/cy16/opcodes.rb +78 -0
- data/metasm/cpu/cy16/render.rb +41 -0
- data/metasm/cpu/dalvik.rb +11 -0
- data/{lib/metasm → metasm/cpu}/dalvik/decode.rb +35 -13
- data/{lib/metasm → metasm/cpu}/dalvik/main.rb +51 -2
- data/{lib/metasm → metasm/cpu}/dalvik/opcodes.rb +19 -11
- data/metasm/cpu/ia32.rb +17 -0
- data/{lib/metasm → metasm/cpu}/ia32/compile_c.rb +5 -7
- data/{lib/metasm → metasm/cpu}/ia32/debug.rb +5 -5
- data/{lib/metasm → metasm/cpu}/ia32/decode.rb +246 -59
- data/{lib/metasm → metasm/cpu}/ia32/decompile.rb +7 -7
- data/{lib/metasm → metasm/cpu}/ia32/encode.rb +19 -13
- data/{lib/metasm → metasm/cpu}/ia32/main.rb +51 -8
- data/metasm/cpu/ia32/opcodes.rb +1424 -0
- data/{lib/metasm → metasm/cpu}/ia32/parse.rb +47 -16
- data/{lib/metasm → metasm/cpu}/ia32/render.rb +31 -4
- data/metasm/cpu/mips.rb +14 -0
- data/{lib/metasm → metasm/cpu}/mips/compile_c.rb +1 -1
- data/metasm/cpu/mips/debug.rb +42 -0
- data/{lib/metasm → metasm/cpu}/mips/decode.rb +46 -16
- data/{lib/metasm → metasm/cpu}/mips/encode.rb +4 -3
- data/{lib/metasm → metasm/cpu}/mips/main.rb +11 -4
- data/{lib/metasm → metasm/cpu}/mips/opcodes.rb +86 -17
- data/{lib/metasm → metasm/cpu}/mips/parse.rb +1 -1
- data/{lib/metasm → metasm/cpu}/mips/render.rb +1 -1
- data/{lib/metasm/dalvik.rb → metasm/cpu/msp430.rb} +1 -1
- data/metasm/cpu/msp430/decode.rb +247 -0
- data/metasm/cpu/msp430/main.rb +62 -0
- data/metasm/cpu/msp430/opcodes.rb +101 -0
- data/{lib/metasm → metasm/cpu}/pic16c/decode.rb +6 -7
- data/{lib/metasm → metasm/cpu}/pic16c/main.rb +0 -0
- data/{lib/metasm → metasm/cpu}/pic16c/opcodes.rb +1 -1
- data/{lib/metasm/mips.rb → metasm/cpu/ppc.rb} +4 -4
- data/{lib/metasm → metasm/cpu}/ppc/decode.rb +18 -12
- data/{lib/metasm → metasm/cpu}/ppc/decompile.rb +3 -3
- data/{lib/metasm → metasm/cpu}/ppc/encode.rb +2 -2
- data/{lib/metasm → metasm/cpu}/ppc/main.rb +17 -12
- data/{lib/metasm → metasm/cpu}/ppc/opcodes.rb +11 -5
- data/metasm/cpu/ppc/parse.rb +55 -0
- data/metasm/cpu/python.rb +8 -0
- data/metasm/cpu/python/decode.rb +136 -0
- data/metasm/cpu/python/main.rb +36 -0
- data/metasm/cpu/python/opcodes.rb +180 -0
- data/{lib/metasm → metasm/cpu}/sh4.rb +1 -1
- data/{lib/metasm → metasm/cpu}/sh4/decode.rb +48 -17
- data/{lib/metasm → metasm/cpu}/sh4/main.rb +13 -4
- data/{lib/metasm → metasm/cpu}/sh4/opcodes.rb +7 -8
- data/metasm/cpu/x86_64.rb +15 -0
- data/{lib/metasm → metasm/cpu}/x86_64/compile_c.rb +28 -17
- data/{lib/metasm → metasm/cpu}/x86_64/debug.rb +4 -4
- data/{lib/metasm → metasm/cpu}/x86_64/decode.rb +57 -15
- data/{lib/metasm → metasm/cpu}/x86_64/encode.rb +55 -26
- data/{lib/metasm → metasm/cpu}/x86_64/main.rb +14 -6
- data/metasm/cpu/x86_64/opcodes.rb +136 -0
- data/{lib/metasm → metasm/cpu}/x86_64/parse.rb +10 -2
- data/metasm/cpu/x86_64/render.rb +35 -0
- data/metasm/cpu/z80.rb +9 -0
- data/metasm/cpu/z80/decode.rb +313 -0
- data/metasm/cpu/z80/main.rb +67 -0
- data/metasm/cpu/z80/opcodes.rb +224 -0
- data/metasm/cpu/z80/render.rb +59 -0
- data/{lib/metasm/os/main.rb → metasm/debug.rb} +160 -401
- data/{lib/metasm → metasm}/decode.rb +35 -4
- data/{lib/metasm → metasm}/decompile.rb +15 -16
- data/{lib/metasm → metasm}/disassemble.rb +201 -45
- data/{lib/metasm → metasm}/disassemble_api.rb +651 -87
- data/{lib/metasm → metasm}/dynldr.rb +220 -133
- data/{lib/metasm → metasm}/encode.rb +10 -1
- data/{lib/metasm → metasm}/exe_format/a_out.rb +9 -6
- data/{lib/metasm → metasm}/exe_format/autoexe.rb +1 -0
- data/{lib/metasm → metasm}/exe_format/bflt.rb +57 -27
- data/{lib/metasm → metasm}/exe_format/coff.rb +11 -3
- data/{lib/metasm → metasm}/exe_format/coff_decode.rb +53 -20
- data/{lib/metasm → metasm}/exe_format/coff_encode.rb +11 -13
- data/{lib/metasm → metasm}/exe_format/dex.rb +13 -5
- data/{lib/metasm → metasm}/exe_format/dol.rb +1 -0
- data/{lib/metasm → metasm}/exe_format/elf.rb +93 -57
- data/{lib/metasm → metasm}/exe_format/elf_decode.rb +143 -34
- data/{lib/metasm → metasm}/exe_format/elf_encode.rb +122 -31
- data/metasm/exe_format/gb.rb +65 -0
- data/metasm/exe_format/javaclass.rb +424 -0
- data/{lib/metasm → metasm}/exe_format/macho.rb +204 -16
- data/{lib/metasm → metasm}/exe_format/main.rb +26 -3
- data/{lib/metasm → metasm}/exe_format/mz.rb +1 -0
- data/{lib/metasm → metasm}/exe_format/nds.rb +7 -4
- data/{lib/metasm → metasm}/exe_format/pe.rb +71 -8
- data/metasm/exe_format/pyc.rb +167 -0
- data/{lib/metasm → metasm}/exe_format/serialstruct.rb +67 -14
- data/{lib/metasm → metasm}/exe_format/shellcode.rb +7 -3
- data/metasm/exe_format/shellcode_rwx.rb +114 -0
- data/metasm/exe_format/swf.rb +205 -0
- data/{lib/metasm → metasm}/exe_format/xcoff.rb +7 -7
- data/metasm/exe_format/zip.rb +335 -0
- data/metasm/gui.rb +13 -0
- data/{lib/metasm → metasm}/gui/cstruct.rb +35 -41
- data/{lib/metasm → metasm}/gui/dasm_coverage.rb +11 -11
- data/{lib/metasm → metasm}/gui/dasm_decomp.rb +7 -20
- data/{lib/metasm → metasm}/gui/dasm_funcgraph.rb +0 -0
- data/metasm/gui/dasm_graph.rb +1695 -0
- data/{lib/metasm → metasm}/gui/dasm_hex.rb +12 -8
- data/{lib/metasm → metasm}/gui/dasm_listing.rb +43 -28
- data/{lib/metasm → metasm}/gui/dasm_main.rb +310 -53
- data/{lib/metasm → metasm}/gui/dasm_opcodes.rb +5 -19
- data/{lib/metasm → metasm}/gui/debug.rb +93 -27
- data/{lib/metasm → metasm}/gui/gtk.rb +162 -40
- data/{lib/metasm → metasm}/gui/qt.rb +12 -2
- data/{lib/metasm → metasm}/gui/win32.rb +179 -42
- data/{lib/metasm → metasm}/gui/x11.rb +59 -59
- data/{lib/metasm → metasm}/main.rb +389 -264
- data/{lib/metasm/os/remote.rb → metasm/os/gdbremote.rb} +146 -54
- data/{lib/metasm → metasm}/os/gnu_exports.rb +1 -1
- data/{lib/metasm → metasm}/os/linux.rb +628 -151
- data/metasm/os/main.rb +330 -0
- data/{lib/metasm → metasm}/os/windows.rb +132 -42
- data/{lib/metasm → metasm}/os/windows_exports.rb +141 -0
- data/{lib/metasm → metasm}/parse.rb +26 -24
- data/{lib/metasm → metasm}/parse_c.rb +221 -116
- data/{lib/metasm → metasm}/preprocessor.rb +55 -40
- data/{lib/metasm → metasm}/render.rb +14 -38
- data/misc/hexdump.rb +2 -1
- data/misc/lint.rb +58 -0
- data/misc/txt2html.rb +9 -7
- data/samples/bindiff.rb +3 -4
- data/samples/dasm-plugins/bindiff.rb +15 -0
- data/samples/dasm-plugins/bookmark.rb +133 -0
- data/samples/dasm-plugins/c_constants.rb +57 -0
- data/samples/dasm-plugins/colortheme_solarized.rb +125 -0
- data/samples/dasm-plugins/cppobj_funcall.rb +60 -0
- data/samples/dasm-plugins/dasm_all.rb +70 -0
- data/samples/dasm-plugins/demangle_cpp.rb +31 -0
- data/samples/dasm-plugins/deobfuscate.rb +251 -0
- data/samples/dasm-plugins/dump_text.rb +35 -0
- data/samples/dasm-plugins/export_graph_svg.rb +86 -0
- data/samples/dasm-plugins/findgadget.rb +75 -0
- data/samples/dasm-plugins/hl_opcode.rb +32 -0
- data/samples/dasm-plugins/hotfix_gtk_dbg.rb +19 -0
- data/samples/dasm-plugins/imm2off.rb +34 -0
- data/samples/dasm-plugins/match_libsigs.rb +93 -0
- data/samples/dasm-plugins/patch_file.rb +95 -0
- data/samples/dasm-plugins/scanfuncstart.rb +36 -0
- data/samples/dasm-plugins/scanxrefs.rb +26 -0
- data/samples/dasm-plugins/selfmodify.rb +197 -0
- data/samples/dasm-plugins/stringsxrefs.rb +28 -0
- data/samples/dasmnavig.rb +1 -1
- data/samples/dbg-apihook.rb +24 -9
- data/samples/dbg-plugins/heapscan.rb +283 -0
- data/samples/dbg-plugins/heapscan/compiled_heapscan_lin.c +155 -0
- data/samples/dbg-plugins/heapscan/compiled_heapscan_win.c +128 -0
- data/samples/dbg-plugins/heapscan/graphheap.rb +616 -0
- data/samples/dbg-plugins/heapscan/heapscan.rb +709 -0
- data/samples/dbg-plugins/heapscan/winheap.h +174 -0
- data/samples/dbg-plugins/heapscan/winheap7.h +307 -0
- data/samples/dbg-plugins/trace_func.rb +214 -0
- data/samples/disassemble-gui.rb +35 -5
- data/samples/disassemble.rb +31 -6
- data/samples/dump_upx.rb +24 -12
- data/samples/dynamic_ruby.rb +12 -3
- data/samples/exeencode.rb +6 -5
- data/samples/factorize-headers-peimports.rb +1 -1
- data/samples/lindebug.rb +175 -381
- data/samples/metasm-shell.rb +1 -2
- data/samples/peldr.rb +2 -2
- data/tests/all.rb +1 -1
- data/tests/arc.rb +26 -0
- data/tests/dynldr.rb +22 -4
- data/tests/expression.rb +55 -0
- data/tests/graph_layout.rb +285 -0
- data/tests/ia32.rb +79 -26
- data/tests/mips.rb +9 -2
- data/tests/x86_64.rb +66 -18
- metadata +330 -218
- data/lib/metasm/arm/opcodes.rb +0 -177
- data/lib/metasm/gui.rb +0 -23
- data/lib/metasm/gui/dasm_graph.rb +0 -1354
- data/lib/metasm/ia32.rb +0 -14
- data/lib/metasm/ia32/opcodes.rb +0 -873
- data/lib/metasm/ppc/parse.rb +0 -52
- data/lib/metasm/x86_64.rb +0 -12
- data/lib/metasm/x86_64/opcodes.rb +0 -118
- data/samples/gdbclient.rb +0 -583
- 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;
|