forked from hugsy/windbg_js_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDumpKnownTypes.js
More file actions
58 lines (50 loc) · 1.5 KB
/
Copy pathDumpKnownTypes.js
File metadata and controls
58 lines (50 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
*
* Dynamic dumping of known object types of Windows (_OBJECT_HEADER->Type)
*
*/
"use strict";
var log = x => host.diagnostics.debugLog(x + "\n");
function DumpTypeIndex()
{
var ReadWideString = host.memory.readWideString;
// Get symbol from ntoskrnl
var ObTypeIndexTableAddress = host.getModuleSymbolAddress("nt","ObTypeIndexTable");
// Create a typed variable (type = _OBJECT_TYPE**)
var pObTypeIndexTable = host.createPointerObject(ObTypeIndexTableAddress, "nt", "_OBJECT_TYPE **");
var i = 2;
while(true)
{
try
{
//
// Note that we can use directly structure component (recursively)
// kd> dt _OBJECT_TYPE
// nt!_OBJECT_TYPE
// +0x000 TypeList : _LIST_ENTRY
// +0x010 Name : _UNICODE_STRING
// [...]
//
// kd> dt _UNICODE_STRING
// nt!_UNICODE_STRING
// +0x000 Length : Uint2B
// +0x002 MaximumLength : Uint2B
// +0x008 Buffer : Ptr64 Wchar
//
let ObjectName = ReadWideString(pObTypeIndexTable[i].Name.Buffer);
log(`- Type[${i}] = '${ObjectName}'`);
i++
}
catch(err)
{
// Reaching the end of the table will trigger an access violation, caught by JS, so we can exit
break;
}
}
return;
}
function invokeScript()
{
DumpTypeIndex();
return;
}