Skip to content

Commit

Permalink
Insignificant tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dd86k committed Sep 26, 2024
1 parent 5ee2aa9 commit 6f4cbdf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
9 changes: 4 additions & 5 deletions dumper/dumper.d
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,12 @@ int dump_file(const(char)* path) {
}

// Otherwise, make a basic summary
printf("%s, %s",
adbg_object_type_name(o), adbg_object_kind_string(o));
printf("%s, %s", adbg_object_type_name(o), adbg_object_kind_string(o));

// Print machine type used for object
AdbgMachine mach = adbg_object_machine(o);
if (mach)
printf(", %s", adbg_object_machine_string(o));
const(char)* machstr = adbg_object_machine_string(o);
if (machstr)
printf(", %s", machstr);

putchar('\n');
return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void loop_handler(adbg_process_t *proc, int event, void *edata, void *udata) {
if (ex.faultz && dis) {
adbg_opcode_t op = void;
if (adbg_dis_process_once(dis, &op, proc, ex.fault_address))
printf(` nodisasm=%s`, adbg_error_message);
printf(` nodisasm="%s"`, adbg_error_message);
else if (op.operands)
printf(` disasm="%s %s"`, op.mnemonic, op.operands);
else
Expand Down
11 changes: 6 additions & 5 deletions src/adbg/objects/pe.d
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ pe_section_entry_t* adbg_object_pe_directory_section(adbg_object_t *o, uint rva)
if (section == null) return null;

// If RVA is outside section's VA and range
with (section) if (rva < VirtualAddress || rva > VirtualAddress + SizeOfRawData)
with (section) if (rva <= VirtualAddress || rva > VirtualAddress + SizeOfRawData)
continue;

return section;
Expand All @@ -1134,15 +1134,15 @@ pe_section_entry_t* adbg_object_pe_directory_section(adbg_object_t *o, uint rva)
// Given a section and directory RVA, return absolute file offset
private
uint adbg_object_pe_directory_offset_section(pe_section_entry_t *section, uint dirrva) {
version (Trace) trace("dir_rva=%#x", dirrva);
version (Trace) trace("rva=%#x", dirrva);
if (section == null) return 0;
with (section) return PointerToRawData + (dirrva - VirtualAddress);
}

// Given a directory RVA, return absolute file offset
private
uint adbg_object_pe_directory_offset(adbg_object_t *o, uint dirrva) {
version (Trace) trace("dir_rva=%#x", dirrva);
version (Trace) trace("rva=%#x", dirrva);
if (o == null) {
adbg_oops(AdbgError.invalidArgument);
return 0;
Expand Down Expand Up @@ -1328,7 +1328,7 @@ const(char)* adbg_object_pe_rich_prodid_string(ushort prodid) {
}

pe_section_entry_t* adbg_object_pe_section(adbg_object_t *o, size_t index) {
version (Trace) trace("o=%p index=%u", o, cast(uint)index);
version (Trace) trace("o=%p index=%zu", o, index);

if (o == null) {
adbg_oops(AdbgError.invalidArgument);
Expand Down Expand Up @@ -1473,7 +1473,8 @@ pe_export_descriptor_t* adbg_object_pe_export(adbg_object_t *o) {
}

// ExportFlags must be zero
if (internal.export_directory.ExportFlags != 0) {
version(Trace) trace("ExportFlags=%#x", internal.export_directory.ExportFlags);
if (internal.export_directory.ExportFlags) {
adbg_oops(AdbgError.unavailable);
free(internal.export_directory);
internal.export_directory = null;
Expand Down
3 changes: 1 addition & 2 deletions src/adbg/objectserver.d
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,7 @@ AdbgMachine adbg_object_machine(adbg_object_t *o) {
return AdbgMachine.unknown;
}
const(char)* adbg_object_machine_string(adbg_object_t *o) {
AdbgMachine mach = adbg_object_machine(o);
return mach ? adbg_machine_name(mach) : `Unknown`;
return adbg_machine_name( adbg_object_machine(o) );
}

/// Get the short name of the loaded object type.
Expand Down

0 comments on commit 6f4cbdf

Please sign in to comment.