forked from hugsy/windbg_js_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumDlls.js
More file actions
59 lines (46 loc) · 1.2 KB
/
Copy pathEnumDlls.js
File metadata and controls
59 lines (46 loc) · 1.2 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
/**
*
* Enumerate UM modules for the currently debugged process.
*
* This script was made as an exercice to manipulate the JS API, you should
* really prefer using @$curprocess.Modules
*
* Use as:
* 0:000> .scriptload \path\to\EnumDlls.js
* 0:000> dx -g -r1 @$LoadedDlls().Select( d => new { Name = (wchar_t*)(d.FullDllName.Buffer) } )
*
*/
"use strict";
const log = x => host.diagnostics.debugLog(x + "\n");
function IsKd(){ return host.namespace.Debugger.Sessions.First().Attributes.Target.IsKernelTarget != 0; }
/**
*
*/
function *LoadedDlls()
{
if (IsKd())
{
log("Cannot run in KD");
yield;
}
// Get the PEB and Loader info from the the pseudo-registers
let peb = host.namespace.Debugger.State.PseudoRegisters.General.peb;
// Create the iterator
let ModuleList = host.namespace.Debugger.Utility.Collections.FromListEntry(
peb.Ldr.InLoadOrderModuleList,
"ntdll!_LDR_DATA_TABLE_ENTRY",
"InLoadOrderLinks"
);
for( let m of ModuleList )
{
yield m;
}
}
/**
*
*/
function initializeScript()
{
log("[+] Creating the variable `LoadedDlls`...");
return [ new host.functionAlias(LoadedDlls, "LoadedDlls") ];
}