-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement windows crash dumps (header-only)
- Loading branch information
Showing
6 changed files
with
230 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/// Windows memory dump dumper. | ||
/// | ||
/// Authors: dd86k <dd@dax.moe> | ||
/// Copyright: © dd86k <dd@dax.moe> | ||
/// License: BSD-3-Clause | ||
module dump.dmp; | ||
|
||
import adbg.disassembler.core; | ||
import adbg.object.server; | ||
import adbg.object.machines; | ||
import adbg.object.format.dmp; | ||
import adbg.object.format.pe : adbg_object_pe_machine_string; | ||
import dumper; | ||
|
||
extern (C): | ||
|
||
int dump_dmp(ref Dumper dump, adbg_object_t *o) { | ||
if (dump.selected_headers()) | ||
dump_dmp_header(dump, o); | ||
|
||
return 0; | ||
} | ||
|
||
private: | ||
|
||
void dump_dmp_header(ref Dumper dump, adbg_object_t *o) { | ||
print_header("Header"); | ||
|
||
bool is64 = o.i.dmp.header.ValidDumpInt == PAGEDUMP64_VALID; | ||
|
||
dmp64_header *hdr64 = cast(dmp64_header*)o.i.dmp.header; | ||
if (is64) with (hdr64) { | ||
print_x32l("Signature", SignatureInt, Signature.ptr, 4); | ||
print_x32l("ValidDump", ValidDumpInt, ValidDump.ptr, 4); | ||
print_u32("MajorVersion", MajorVersion); | ||
print_u32("MinorVersion", MinorVersion); | ||
print_x32("DirectoryTableBase", DirectoryTableBase); | ||
print_x32("PfnDatabase", PfnDatabase); | ||
print_x32("PsLoadedModuleList", PsLoadedModuleList); | ||
print_x32("PsActiveProcessHead", PsActiveProcessHead); | ||
print_x32("MachineImageType", MachineImageType, | ||
adbg_object_pe_machine_string(cast(ushort)MachineImageType)); | ||
print_u32("NumberProcessors", NumberProcessors); | ||
print_x32("BugCheckCode", BugCheckCode); | ||
print_x32("BugCheckParameter1", BugCheckParameters[0]); | ||
print_x32("BugCheckParameter2", BugCheckParameters[1]); | ||
print_x32("BugCheckParameter3", BugCheckParameters[2]); | ||
print_x32("BugCheckParameter4", BugCheckParameters[3]); | ||
print_x64("KdDebuggerDataBlock", KdDebuggerDataBlock); | ||
} else with (o.i.dmp.header) { | ||
print_x32l("Signature", SignatureInt, Signature.ptr, 4); | ||
print_x32l("ValidDump", ValidDumpInt, ValidDump.ptr, 4); | ||
print_u32("MajorVersion", MajorVersion); | ||
print_u32("MinorVersion", MinorVersion); | ||
print_x32("DirectoryTableBase", DirectoryTableBase); | ||
print_x32("PfnDatabase", PfnDatabase); | ||
print_x32("PsLoadedModuleList", PsLoadedModuleList); | ||
print_x32("PsActiveProcessHead", PsActiveProcessHead); | ||
print_x32("MachineImageType", MachineImageType, | ||
adbg_object_pe_machine_string(cast(ushort)MachineImageType)); | ||
print_u32("NumberProcessors", NumberProcessors); | ||
print_x32("BugCheckCode", BugCheckCode); | ||
print_x32("BugCheckParameter1", BugCheckParameters[0]); | ||
print_x32("BugCheckParameter2", BugCheckParameters[1]); | ||
print_x32("BugCheckParameter3", BugCheckParameters[2]); | ||
print_x32("BugCheckParameter4", BugCheckParameters[3]); | ||
print_u8("PaeEnabled", PaeEnabled); | ||
print_x32("KdDebuggerDataBlock", KdDebuggerDataBlock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ public import | |
dump.pdb70, | ||
dump.pdb20, | ||
dump.ar, | ||
dump.mdmp; | ||
dump.mdmp, | ||
dump.dmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/// Windows full memory dump format. | ||
/// | ||
/// Authors: dd86k <dd@dax.moe> | ||
/// Copyright: © dd86k <dd@dax.moe> | ||
/// License: BSD-3-Clause | ||
module adbg.object.format.dmp; | ||
|
||
import adbg.error; | ||
import adbg.object.server : adbg_object_t, AdbgObject; | ||
import adbg.utils.bit; | ||
|
||
// Sources: | ||
// - https://github.com/volatilityfoundation/volatility/ | ||
|
||
/// | ||
enum PAGEDUMP32_MAGIC = CHAR64!"PAGEDUMP"; | ||
/// | ||
enum PAGEDUMP64_MAGIC = CHAR64!"PAGEDU64"; | ||
/// | ||
enum PAGEDUMP32_VALID = CHAR32!"DUMP"; | ||
/// | ||
enum PAGEDUMP64_VALID = CHAR32!"DU64"; | ||
|
||
enum PAGEDUMP32_HEADERSIZE = 0x1000; | ||
enum PAGEDUMP64_HEADERSIZE = 0x2000; | ||
|
||
/// Windows crash dump header. | ||
struct dmp_header { | ||
union { | ||
/// Contains "PAGE" | ||
char[4] Signature; | ||
/// Ditto | ||
uint SignatureInt; | ||
} | ||
union { | ||
/// Contains "DUMP" or "DU64" | ||
char[4] ValidDump; | ||
/// Ditto | ||
uint ValidDumpInt; | ||
} | ||
/// 0xf for a Free build or 0xc for a Checked build | ||
uint MajorVersion; | ||
/// System build number | ||
uint MinorVersion; | ||
/// x86: Value of CR3 on crash, physical address of page directory | ||
uint DirectoryTableBase; | ||
/// PFN Database, virtual address | ||
uint PfnDatabase; | ||
/// List of loaded modules, virtual address | ||
uint PsLoadedModuleList; | ||
/// List of active process, virtual address | ||
uint PsActiveProcessHead; | ||
/// WinNT Machine values, same found in PE32 | ||
uint MachineImageType; | ||
/// Number of processors. | ||
uint NumberProcessors; | ||
/// Stop code | ||
uint BugCheckCode; | ||
/// Stop code parameters, from 1 to 4. | ||
uint[4] BugCheckParameters; | ||
/// | ||
char[32] VersionUser; | ||
union { | ||
char[4] Unused; | ||
/// For 32-bit dumps, this indicates if PAE is enabled. | ||
ubyte PaeEnabled; | ||
} | ||
/// Virtual address of KdDebuggerDataBlock structure | ||
uint KdDebuggerDataBlock; // 32-bit: 0x60 | ||
// _PHYSICAL_MEMORY_DESCRIPTOR PhysicalMemoryBlockBuffer; | ||
} | ||
static assert(dmp_header.KdDebuggerDataBlock.offsetof == 0x60); | ||
|
||
/// 64-bit Windows crash dump header. | ||
struct dmp64_header { | ||
union { | ||
/// Contains "PAGE" | ||
char[4] Signature; | ||
/// Ditto | ||
uint SignatureInt; | ||
} | ||
union { | ||
/// Contains "DUMP" or "DU64" | ||
char[4] ValidDump; | ||
/// Ditto | ||
uint ValidDumpInt; | ||
} | ||
/// 0xf for a Free build or 0xc for a Checked build | ||
uint MajorVersion; | ||
/// System build number | ||
uint MinorVersion; | ||
/// x86: Value of CR3 on crash, physical address of page directory | ||
uint DirectoryTableBase; | ||
/// PFN Database, virtual address | ||
uint PfnDatabase; | ||
/// List of loaded modules, virtual address | ||
uint PsLoadedModuleList; | ||
/// List of active process, virtual address | ||
uint PsActiveProcessHead; // 0x18 | ||
/// | ||
char[16] Unknown3; | ||
/// WinNT Machine values, same found in PE32 | ||
uint MachineImageType; // 0x30 | ||
/// Number of processors. | ||
uint NumberProcessors; | ||
/// Stop code | ||
uint BugCheckCode; // 0x38 | ||
/// | ||
uint Unknown4; | ||
/// Stop code parameters, from 1 to 4. | ||
uint[4] BugCheckParameters; // 0x40 | ||
/// | ||
char[48] VersionUser; | ||
/// For 64-bit dumps, virtual address of KdDebuggerDataBlock structure | ||
ulong KdDebuggerDataBlock; // 64-bit: 0x80 | ||
// _PHYSICAL_MEMORY_DESCRIPTOR PhysicalMemoryBlockBuffer; | ||
} | ||
static assert(dmp64_header.MachineImageType.offsetof == 0x30); | ||
static assert(dmp64_header.BugCheckParameters.offsetof == 0x40); | ||
static assert(dmp64_header.KdDebuggerDataBlock.offsetof == 0x80); | ||
|
||
int adbg_object_dmp_load(adbg_object_t *o) { | ||
o.format = AdbgObject.dmp; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters