Skip to content

Commit

Permalink
object: Move mdmp to new code
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Jul 2, 2024
1 parent a2d5892 commit 6ad5f1a
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 76 deletions.
53 changes: 27 additions & 26 deletions dumper/format/mdmp.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ int dump_minidump(adbg_object_t *o) {
if (SELECTED(Select.headers))
dump_minidump_headers(o);

//if (SELECTED(Select.debug_))
// dump_minidump_debug(o);
if (SELECTED(Select.debug_))
dump_minidump_debug(o);

return 0;
}
Expand All @@ -29,11 +29,14 @@ private:

void dump_minidump_headers(adbg_object_t *o) {
print_header("Header");
with (o.i.mdmp.header) {

mdmp_header_t *header = adbg_object_mdmp_header(o);

with (header) {
print_x32("Signature", Signature);
print_x16("Magic", Magic);
print_u16("Version", Version);
print_x32("StreamCount", StreamCount);
print_u32("StreamCount", StreamCount);
print_x32("StreamRva", StreamRva);
print_x32("Checksum", Checksum);
print_x32("Timestamp", Timestamp, ctime32(Timestamp));
Expand Down Expand Up @@ -70,40 +73,33 @@ void dump_minidump_headers(adbg_object_t *o) {
void dump_minidump_debug(adbg_object_t *o) {
print_header("Debug");

uint cnt = o.i.mdmp.header.StreamCount;
uint off = o.i.mdmp.header.StreamRva;
mdmp_directory_entry *dir = void;
if (adbg_object_offsetl(o, cast(void**)&dir, off, cnt * mdmp_directory_entry.sizeof))
panic(1, "Directory outside file bounds");

for (uint i; i < cnt; ++i) {
mdmp_directory_entry *entry = &dir[i];

with (entry) {
print_x32("StreamType", StreamType);
print_x32("Size", Size);
print_x32("Rva", Rva);
}
reset_error();
size_t i;
for (mdmp_directory_entry_t *entry; (entry = adbg_object_mdmp_dir_entry(o, i)) != null; ++i) {
print_section(cast(uint)i);
print_u32("StreamType", entry.StreamType, adbg_object_mdmp_dir_entry_type_string(entry));
print_x32("Size", entry.Size);
print_x32("Rva", entry.Rva);

switch (entry.StreamType) {
case ThreadListStream:
print_header("Threadlist");

mdmp_threadlist *tlist = void;
if (adbg_object_offsetl(o, cast(void**)&tlist,
entry.Rva, uint.sizeof + mdmp_thread.sizeof)) {
print_warningf("Threadlist.Rva points outbound");
continue;
}
for (uint ti; ti < tlist.Count; ++ti) {
mdmp_thread *thread = &tlist.Threads.ptr[ti];
mdmp_threadlist_t *threads =
cast(mdmp_threadlist_t*)adbg_object_mdmp_dir_entry_data(o, entry);
if (threads == null)
panic_adbg();

for (uint ti; ti < threads.Count; ++ti) {
mdmp_thread_t *thread = &threads.Threads.ptr[ti];
print_section(ti);
print_x32("ID", thread.ID);
print_x32("SuspendCount", thread.SuspendCount);
print_x32("PriorityClass", thread.PriorityClass);
print_x32("Priority", thread.Priority);
print_x64("Teb", thread.Teb);

/*
X86_NT_CONTEXT *context = void;
if (adbg_object_offsetl(o, cast(void**)&context,
thread.ThreadContext.Rva, thread.ThreadContext.Size)) {
Expand All @@ -112,7 +108,10 @@ void dump_minidump_debug(adbg_object_t *o) {
}
print_x32("Eip", context.Eip);
*/
}

adbg_object_mdmp_dir_entry_data_close(threads);
break;
case ModuleListStream:
break;
Expand Down Expand Up @@ -159,4 +158,6 @@ void dump_minidump_debug(adbg_object_t *o) {
default: continue;
}
}
if (i == 0 && errorcode())
panic_adbg();
}
4 changes: 3 additions & 1 deletion src/adbg/object/format/dmp.d
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ int adbg_object_dmp_load(adbg_object_t *o) {
o.internal = calloc(1, internal_dmp_t.sizeof);
if (o.internal == null)
return adbg_oops(AdbgError.crt);
if (adbg_object_read_at(o, 0, o.internal, MAX!(dmp32_header_t.sizeof, dmp64_header_t.sizeof)))
if (adbg_object_read_at(o, 0, o.internal, MAX!(dmp32_header_t.sizeof, dmp64_header_t.sizeof))) {
free(o.internal);
return adbg_errno();
}

o.format = AdbgObject.dmp;

Expand Down
Loading

0 comments on commit 6ad5f1a

Please sign in to comment.