Fix mdmp endianness (#3126)
* MiniDmpHeader & MiniDmpLocDescr32/64 & MiniDmpMemDescr32/64 * MiniDmpException & MiniDmpExcStream * MiniDmpModule * MiniDmpThread & MiniDmpThreadList * MiniDmpThreadEx & MiniDmpThreadExList * Removed struct minidump_string * MiniDmpDir * MiniDmpExcPointers & MiniDmpExcInfo & MiniDmpFuncTableDescr * MiniDmpFuncTableStream & MiniDmpHandleDataStream * MiniDmpExcRecord & MiniDmpHandleDescr/2 * MiniDmpHandleObjInfo * MiniDmpMemList64 & MiniDmpMemDescr64 (init) * MiniDmpMemInfo & MiniDmpMemInfoList * MiniDmpMiscInfo * MiniDmpMiscInfo2 * MiniDmpSysInfo * MiniDmpThreadInfoList & MiniDmpThreadInfo * MiniDmpTokenInfo & MiniDmpTokenInfoList * MiniDmpUnloadedModule & MiniDmpUnloadedModuleList * MiniDmpUserStream & MiniDmpUserStreamInfo * MiniDmpIncludeThreadCallback * MiniDmpModuleCallback * MiniDmpIncludeModuleCallback * MiniDmpIOCallback * MiniDmpReadMemoryFailureCallback * MiniDmpCallbackOutput * AVRFBacktraceInfo & AVRFHandleOp & MiniDmpHandleOpList * MiniDmpObj
This commit is contained in:
parent
2957d60730
commit
3e5217456d
5 changed files with 816 additions and 994 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -14,22 +14,22 @@
|
|||
#include "mdmp_pe.h"
|
||||
#include "mdmp_pe64.h"
|
||||
|
||||
struct rz_bin_mdmp_obj {
|
||||
struct minidump_header *hdr;
|
||||
typedef struct minidump_object_t {
|
||||
MiniDmpHeader *hdr;
|
||||
|
||||
/* Encountered streams */
|
||||
struct minidump_streams {
|
||||
ut8 *comments_a;
|
||||
ut8 *comments_w;
|
||||
|
||||
struct minidump_exception_stream *exception;
|
||||
struct minidump_function_table_stream *function_table;
|
||||
struct minidump_handle_data_stream *handle_data;
|
||||
struct minidump_system_info *system_info;
|
||||
MiniDmpExcStream *exception;
|
||||
MiniDmpFuncTableStream *function_table;
|
||||
MiniDmpHandleDataStream *handle_data;
|
||||
MiniDmpSysInfo *system_info;
|
||||
|
||||
union {
|
||||
struct minidump_misc_info *misc_info_1;
|
||||
struct minidump_misc_info_2 *misc_info_2;
|
||||
MiniDmpMiscInfo *misc_info_1;
|
||||
MiniDmpMiscInfo2 *misc_info_2;
|
||||
} misc_info;
|
||||
|
||||
/* Lists */
|
||||
|
|
@ -56,12 +56,12 @@ struct rz_bin_mdmp_obj {
|
|||
size_t size;
|
||||
ut8 endian;
|
||||
Sdb *kv;
|
||||
};
|
||||
} MiniDmpObj;
|
||||
|
||||
struct rz_bin_mdmp_obj *rz_bin_mdmp_new_buf(RzBuffer *buf);
|
||||
void rz_bin_mdmp_free(struct rz_bin_mdmp_obj *obj);
|
||||
ut64 rz_bin_mdmp_get_paddr(struct rz_bin_mdmp_obj *obj, ut64 vaddr);
|
||||
ut32 rz_bin_mdmp_get_perm(struct rz_bin_mdmp_obj *obj, ut64 vaddr);
|
||||
struct minidump_memory_info *rz_bin_mdmp_get_mem_info(struct rz_bin_mdmp_obj *obj, ut64 vaddr);
|
||||
MiniDmpObj *rz_bin_mdmp_new_buf(RzBuffer *buf);
|
||||
void rz_bin_mdmp_free(MiniDmpObj *obj);
|
||||
ut64 rz_bin_mdmp_get_paddr(MiniDmpObj *obj, ut64 vaddr);
|
||||
ut32 rz_bin_mdmp_get_perm(MiniDmpObj *obj, ut64 vaddr);
|
||||
MiniDmpMemInfo *rz_bin_mdmp_get_mem_info(MiniDmpObj *obj, ut64 vaddr);
|
||||
|
||||
#endif /* MDMP_H */
|
||||
|
|
|
|||
|
|
@ -194,560 +194,493 @@ typedef enum thread_write_flags_t {
|
|||
} thread_write_flags;
|
||||
|
||||
/* Contains header information for the minidump file. */
|
||||
RZ_PACKED(
|
||||
struct minidump_header {
|
||||
ut32 signature;
|
||||
ut32 version;
|
||||
ut32 number_of_streams;
|
||||
rva_t stream_directory_rva;
|
||||
ut32 check_sum;
|
||||
typedef struct minidump_header_t {
|
||||
ut32 signature;
|
||||
ut32 version;
|
||||
ut32 number_of_streams;
|
||||
rva_t stream_directory_rva;
|
||||
ut32 check_sum;
|
||||
|
||||
union {
|
||||
ut32 reserved;
|
||||
ut32 time_date_stamp;
|
||||
};
|
||||
union {
|
||||
ut32 reserved;
|
||||
ut32 time_date_stamp;
|
||||
};
|
||||
|
||||
ut64 flags;
|
||||
});
|
||||
ut64 flags;
|
||||
} MiniDmpHeader;
|
||||
|
||||
/* Contains information describing the location of a data stream within a
|
||||
* minidump file. */
|
||||
RZ_PACKED(
|
||||
struct minidump_location_descriptor {
|
||||
ut32 data_size;
|
||||
rva_t rva;
|
||||
});
|
||||
typedef struct minidump_location_descriptor32_t {
|
||||
ut32 data_size;
|
||||
rva_t rva;
|
||||
} MiniDmpLocDescr32;
|
||||
|
||||
/* Contains information describing the location of a data stream within a
|
||||
* minidump file. */
|
||||
RZ_PACKED(
|
||||
struct minidump_location_descriptor64 {
|
||||
ut64 data_size;
|
||||
rva64_t rva;
|
||||
});
|
||||
typedef struct minidump_location_descriptor64_t {
|
||||
ut64 data_size;
|
||||
rva64_t rva;
|
||||
} MiniDmpLocDescr64;
|
||||
|
||||
/* Describes a range of memory. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory_descriptor {
|
||||
ut64 start_of_memory_range;
|
||||
struct minidump_location_descriptor memory;
|
||||
});
|
||||
typedef struct minidump_memory_descriptor32_t {
|
||||
ut64 start_of_memory_range;
|
||||
MiniDmpLocDescr32 memory;
|
||||
} MiniDmpMemDescr32;
|
||||
|
||||
/* Describes a range of memory. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory_descriptor64 {
|
||||
ut64 start_of_memory_range;
|
||||
ut64 data_size;
|
||||
});
|
||||
typedef struct minidump_memory_descriptor64_t {
|
||||
ut64 start_of_memory_range;
|
||||
ut64 data_size;
|
||||
} MiniDmpMemDescr64;
|
||||
|
||||
/* Contains the information needed to access a specific data stream in a minidump file. */
|
||||
RZ_PACKED(
|
||||
struct minidump_directory {
|
||||
ut32 stream_type;
|
||||
struct minidump_location_descriptor location;
|
||||
});
|
||||
typedef struct minidump_directory_t {
|
||||
ut32 stream_type;
|
||||
MiniDmpLocDescr32 location;
|
||||
} MiniDmpDir;
|
||||
|
||||
/* Contains exception information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_exception {
|
||||
ut32 exception_code;
|
||||
ut32 exception_flags;
|
||||
ut64 exception_record;
|
||||
ut64 exception_address;
|
||||
ut32 number_parameters;
|
||||
ut32 __unused_alignment;
|
||||
ut64 exception_information[EXCEPTION_MAXIMUM_PARAMETERS];
|
||||
});
|
||||
typedef struct minidump_exception_t {
|
||||
ut32 exception_code;
|
||||
ut32 exception_flags;
|
||||
ut64 exception_record;
|
||||
ut64 exception_address;
|
||||
ut32 number_parameters;
|
||||
ut32 __unused_alignment;
|
||||
ut64 exception_information[EXCEPTION_MAXIMUM_PARAMETERS];
|
||||
} MiniDmpException;
|
||||
|
||||
/* Contains exception information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_exception_stream {
|
||||
ut32 thread_id;
|
||||
ut32 __alignment;
|
||||
typedef struct minidump_exception_stream_t {
|
||||
ut32 thread_id;
|
||||
ut32 __alignment;
|
||||
|
||||
struct minidump_exception exception_record;
|
||||
struct minidump_location_descriptor thread_context;
|
||||
});
|
||||
MiniDmpException exception_record;
|
||||
MiniDmpLocDescr32 thread_context;
|
||||
} MiniDmpExcStream;
|
||||
|
||||
/* Describes an exception. */
|
||||
RZ_PACKED(
|
||||
struct minidump_exception_record {
|
||||
ut32 exception_code;
|
||||
ut32 exception_flags;
|
||||
typedef struct minidump_exception_record_t {
|
||||
ut32 exception_code;
|
||||
ut32 exception_flags;
|
||||
|
||||
struct minidump_exception_record *exception_record;
|
||||
struct minidump_exception_record_t *exception_record;
|
||||
|
||||
void *exception_address;
|
||||
ut32 number_parameters;
|
||||
void /*ULONG_PTR*/ *exception_information[EXCEPTION_MAXIMUM_PARAMETERS];
|
||||
});
|
||||
void *exception_address;
|
||||
ut32 number_parameters;
|
||||
void /*ULONG_PTR*/ *exception_information[EXCEPTION_MAXIMUM_PARAMETERS];
|
||||
} MiniDmpExcRecord; /* unused */
|
||||
|
||||
/* Contains an exception record with a machine-independent description of an
|
||||
* exception and a context record with a machine-dependent description of the
|
||||
* processor context at the time of the exception. */
|
||||
RZ_PACKED(
|
||||
struct minidump_exception_pointers {
|
||||
struct minidump_exception_record exception_record;
|
||||
void /* struct context */ *context_record;
|
||||
});
|
||||
typedef struct minidump_exception_pointers_t {
|
||||
MiniDmpExcRecord exception_record;
|
||||
void /* struct context */ *context_record;
|
||||
} MiniDmpExcPointers; /* unused */
|
||||
|
||||
/* Contains the exception information written to the minidump file by the
|
||||
* MiniDumpWriteDump function. */
|
||||
RZ_PACKED(
|
||||
struct minidump_exception_information {
|
||||
ut32 thread_id;
|
||||
|
||||
struct minidump_exception_pointers *exception_pointers;
|
||||
|
||||
ut8 /*bool*/ client_pointers;
|
||||
});
|
||||
typedef struct minidump_exception_information_t {
|
||||
ut32 thread_id;
|
||||
MiniDmpExcPointers *exception_pointers;
|
||||
ut8 /*bool*/ client_pointers;
|
||||
} MiniDmpExcInfo; /* unused */
|
||||
|
||||
/* Represents a function table stream. */
|
||||
RZ_PACKED(
|
||||
struct minidump_function_table_descriptor {
|
||||
ut64 minimum_address;
|
||||
ut64 maximum_address;
|
||||
ut64 base_address;
|
||||
ut32 entry_count;
|
||||
ut32 size_of_align_pad;
|
||||
});
|
||||
typedef struct minidump_function_table_descriptor_t {
|
||||
ut64 minimum_address;
|
||||
ut64 maximum_address;
|
||||
ut64 base_address;
|
||||
ut32 entry_count;
|
||||
ut32 size_of_align_pad;
|
||||
} MiniDmpFuncTableDescr; /* unused */
|
||||
|
||||
/* Represents the header for the function table stream. */
|
||||
RZ_PACKED(
|
||||
struct minidump_function_table_stream {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_descriptor;
|
||||
ut32 size_of_native_descriptor;
|
||||
ut32 size_of_function_entry;
|
||||
ut32 number_of_descriptors;
|
||||
ut32 size_of_align_pad;
|
||||
});
|
||||
typedef struct minidump_function_table_stream_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_descriptor;
|
||||
ut32 size_of_native_descriptor;
|
||||
ut32 size_of_function_entry;
|
||||
ut32 number_of_descriptors;
|
||||
ut32 size_of_align_pad;
|
||||
} MiniDmpFuncTableStream;
|
||||
|
||||
/* Represents the header for a handle data stream. */
|
||||
RZ_PACKED(
|
||||
struct minidump_handle_data_stream {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_descriptor;
|
||||
ut32 number_of_descriptors;
|
||||
ut32 reserved;
|
||||
});
|
||||
typedef struct minidump_handle_data_stream_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_descriptor;
|
||||
ut32 number_of_descriptors;
|
||||
ut32 reserved;
|
||||
} MiniDmpHandleDataStream;
|
||||
|
||||
/* Contains the state of an individual system handle at the time the minidump
|
||||
* was written. */
|
||||
RZ_PACKED(
|
||||
struct minidump_handle_descriptor {
|
||||
ut64 handle;
|
||||
rva_t type_name_rva;
|
||||
rva_t object_name_rva;
|
||||
ut32 attributes;
|
||||
ut32 granted_access;
|
||||
ut32 handle_count;
|
||||
ut32 pointer_count;
|
||||
});
|
||||
typedef struct minidump_handle_descriptor_t {
|
||||
ut64 handle;
|
||||
rva_t type_name_rva;
|
||||
rva_t object_name_rva;
|
||||
ut32 attributes;
|
||||
ut32 granted_access;
|
||||
ut32 handle_count;
|
||||
ut32 pointer_count;
|
||||
} MiniDmpHandleDescr; /* unused */
|
||||
|
||||
/* Contains the state of an individual system handle at the time the minidump
|
||||
* was written. */
|
||||
RZ_PACKED(
|
||||
struct minidump_handle_descriptor_2 {
|
||||
ut64 handle;
|
||||
rva_t type_name_rva;
|
||||
rva_t object_name_rva;
|
||||
ut32 attributes;
|
||||
ut32 granted_access;
|
||||
ut32 handle_count;
|
||||
ut32 pointer_count;
|
||||
rva_t object_info_rva;
|
||||
ut32 reserved_0;
|
||||
});
|
||||
typedef struct minidump_handle_descriptor_2_t {
|
||||
ut64 handle;
|
||||
rva_t type_name_rva;
|
||||
rva_t object_name_rva;
|
||||
ut32 attributes;
|
||||
ut32 granted_access;
|
||||
ut32 handle_count;
|
||||
ut32 pointer_count;
|
||||
rva_t object_info_rva;
|
||||
ut32 reserved_0;
|
||||
} MiniDmpHandleDescr2; /* unused */
|
||||
|
||||
/* Contains object-specific information for a handle. */
|
||||
RZ_PACKED(
|
||||
struct minidump_handle_object_information {
|
||||
rva_t next_info_rva;
|
||||
ut32 info_type;
|
||||
ut32 size_of_info;
|
||||
});
|
||||
typedef struct minidump_handle_object_information_t {
|
||||
rva_t next_info_rva;
|
||||
ut32 info_type;
|
||||
ut32 size_of_info;
|
||||
} MiniDmpHandleObjInfo; /* unused */
|
||||
|
||||
/* Contains a list of memory ranges. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory_list {
|
||||
ut32 number_of_memory_ranges;
|
||||
struct minidump_memory_descriptor memory_ranges[];
|
||||
});
|
||||
typedef struct minidump_memory_list32_t {
|
||||
ut32 number_of_memory_ranges;
|
||||
} MiniDmpMemList32;
|
||||
|
||||
/* Contains a list of memory ranges. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory64_list {
|
||||
ut64 number_of_memory_ranges;
|
||||
rva64_t base_rva;
|
||||
struct minidump_memory_descriptor64 memory_ranges[];
|
||||
});
|
||||
typedef struct minidump_memory_list64_t {
|
||||
ut64 number_of_memory_ranges;
|
||||
rva64_t base_rva;
|
||||
} MiniDmpMemList64;
|
||||
|
||||
/* Describes a region of memory. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory_info {
|
||||
ut64 base_address;
|
||||
ut64 allocation_base;
|
||||
ut32 allocation_protect;
|
||||
ut32 __alignment_1;
|
||||
ut64 region_size;
|
||||
ut32 state;
|
||||
ut32 protect;
|
||||
ut32 type;
|
||||
ut32 __alignment_2;
|
||||
});
|
||||
typedef struct minidump_memory_info_t {
|
||||
ut64 base_address;
|
||||
ut64 allocation_base;
|
||||
ut32 allocation_protect;
|
||||
ut32 __alignment_1;
|
||||
ut64 region_size;
|
||||
ut32 state;
|
||||
ut32 protect;
|
||||
ut32 type;
|
||||
ut32 __alignment_2;
|
||||
} MiniDmpMemInfo;
|
||||
|
||||
/* Contains a list of memory regions. */
|
||||
RZ_PACKED(
|
||||
struct minidump_memory_info_list {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut64 number_of_entries;
|
||||
struct minidump_memory_info entries[];
|
||||
});
|
||||
typedef struct minidump_memory_info_list_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut64 number_of_entries;
|
||||
} MiniDmpMemInfoList;
|
||||
|
||||
/* Contains a variety of information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_misc_info {
|
||||
ut32 size_of_info;
|
||||
ut32 flags_1;
|
||||
ut32 process_id;
|
||||
ut32 process_create_time;
|
||||
ut32 process_user_time;
|
||||
ut32 process_kernel_time;
|
||||
});
|
||||
typedef struct minidump_misc_info_t {
|
||||
ut32 size_of_info;
|
||||
ut32 flags_1;
|
||||
ut32 process_id;
|
||||
ut32 process_create_time;
|
||||
ut32 process_user_time;
|
||||
ut32 process_kernel_time;
|
||||
} MiniDmpMiscInfo;
|
||||
|
||||
/* Represents information in the miscellaneous information stream. */
|
||||
RZ_PACKED(
|
||||
struct minidump_misc_info_2 {
|
||||
ut32 size_of_info;
|
||||
ut32 flags_1;
|
||||
ut32 process_id;
|
||||
ut32 process_create_time;
|
||||
ut32 process_user_time;
|
||||
ut32 process_kernel_time;
|
||||
ut32 processor_max_mhz;
|
||||
ut32 processor_current_mhz;
|
||||
ut32 processor_mhz_limit;
|
||||
ut32 processor_max_idle_state;
|
||||
ut32 processor_current_idle_state;
|
||||
});
|
||||
typedef struct minidump_misc_info_2_t {
|
||||
ut32 size_of_info;
|
||||
ut32 flags_1;
|
||||
ut32 process_id;
|
||||
ut32 process_create_time;
|
||||
ut32 process_user_time;
|
||||
ut32 process_kernel_time;
|
||||
ut32 processor_max_mhz;
|
||||
ut32 processor_current_mhz;
|
||||
ut32 processor_mhz_limit;
|
||||
ut32 processor_max_idle_state;
|
||||
ut32 processor_current_idle_state;
|
||||
} MiniDmpMiscInfo2; /* unused */
|
||||
|
||||
/* Contains version information for a file. This information is language and
|
||||
* code page independent. */
|
||||
RZ_PACKED(
|
||||
struct vs_fixedfileinfo {
|
||||
ut32 dw_signature;
|
||||
ut32 dw_struc_version;
|
||||
ut32 dw_file_version_ms;
|
||||
ut32 dw_file_version_ls;
|
||||
ut32 dw_product_version_ms;
|
||||
ut32 dw_product_version_ls;
|
||||
ut32 dw_file_flags_mask;
|
||||
ut32 dw_file_flags;
|
||||
ut32 dw_file_os;
|
||||
ut32 dw_file_type;
|
||||
ut32 dw_file_subtype;
|
||||
ut32 dw_file_date_ms;
|
||||
ut32 dw_file_date_ls;
|
||||
});
|
||||
typedef struct vs_fixedfileinfo_t {
|
||||
ut32 dw_signature;
|
||||
ut32 dw_struc_version;
|
||||
ut32 dw_file_version_ms;
|
||||
ut32 dw_file_version_ls;
|
||||
ut32 dw_product_version_ms;
|
||||
ut32 dw_product_version_ls;
|
||||
ut32 dw_file_flags_mask;
|
||||
ut32 dw_file_flags;
|
||||
ut32 dw_file_os;
|
||||
ut32 dw_file_type;
|
||||
ut32 dw_file_subtype;
|
||||
ut32 dw_file_date_ms;
|
||||
ut32 dw_file_date_ls;
|
||||
} VSFixedFileInfo;
|
||||
|
||||
/* Contains information for a specific module. */
|
||||
RZ_PACKED(
|
||||
struct minidump_module {
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
rva_t module_name_rva;
|
||||
typedef struct minidump_module_t {
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
rva_t module_name_rva;
|
||||
|
||||
struct vs_fixedfileinfo version_info;
|
||||
struct minidump_location_descriptor cv_record;
|
||||
struct minidump_location_descriptor misc_record;
|
||||
VSFixedFileInfo version_info;
|
||||
MiniDmpLocDescr32 cv_record;
|
||||
MiniDmpLocDescr32 misc_record;
|
||||
|
||||
ut64 reserved_0;
|
||||
ut64 reserved_1;
|
||||
});
|
||||
ut64 reserved_0;
|
||||
ut64 reserved_1;
|
||||
} MiniDmpModule;
|
||||
|
||||
/* Contains a list of modules. */
|
||||
RZ_PACKED(
|
||||
struct minidump_module_list {
|
||||
ut32 number_of_modules;
|
||||
struct minidump_module modules[];
|
||||
});
|
||||
|
||||
/* Describes a string. */
|
||||
RZ_PACKED(
|
||||
struct minidump_string {
|
||||
ut32 length;
|
||||
ut16 *buffer;
|
||||
});
|
||||
typedef struct minidump_module_list_t {
|
||||
ut32 number_of_modules;
|
||||
} MiniDmpModuleList;
|
||||
|
||||
/* Contains processor and operating system information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_system_info {
|
||||
ut16 processor_architecture;
|
||||
ut16 processor_level;
|
||||
ut16 processor_revision;
|
||||
typedef struct minidump_system_info_t {
|
||||
ut16 processor_architecture;
|
||||
ut16 processor_level;
|
||||
ut16 processor_revision;
|
||||
|
||||
union {
|
||||
ut16 reserved_0;
|
||||
struct {
|
||||
ut8 number_of_processors;
|
||||
ut8 product_type;
|
||||
};
|
||||
union {
|
||||
ut16 reserved_0;
|
||||
struct {
|
||||
ut8 number_of_processors;
|
||||
ut8 product_type;
|
||||
};
|
||||
};
|
||||
|
||||
ut32 major_version;
|
||||
ut32 minor_version;
|
||||
ut32 build_number;
|
||||
ut32 platform_id;
|
||||
rva_t csd_version_rva;
|
||||
ut32 major_version;
|
||||
ut32 minor_version;
|
||||
ut32 build_number;
|
||||
ut32 platform_id;
|
||||
rva_t csd_version_rva;
|
||||
|
||||
union {
|
||||
ut32 reserved_1;
|
||||
struct {
|
||||
ut16 suite_mask;
|
||||
ut16 reserved_2;
|
||||
};
|
||||
union {
|
||||
ut32 reserved_1;
|
||||
struct {
|
||||
ut16 suite_mask;
|
||||
ut16 reserved_2;
|
||||
};
|
||||
};
|
||||
|
||||
union {
|
||||
struct {
|
||||
ut32 vendor_id[3];
|
||||
ut32 version_information;
|
||||
ut32 feature_information;
|
||||
ut32 amd_extended_cpu_features;
|
||||
} x86_cpu_info;
|
||||
struct {
|
||||
ut64 processor_features[2];
|
||||
} other_cpu_info;
|
||||
} cpu;
|
||||
});
|
||||
union {
|
||||
struct {
|
||||
ut32 vendor_id[3];
|
||||
ut32 version_information;
|
||||
ut32 feature_information;
|
||||
ut32 amd_extended_cpu_features;
|
||||
} x86_cpu_info;
|
||||
struct {
|
||||
ut64 processor_features[2];
|
||||
} other_cpu_info;
|
||||
} cpu;
|
||||
} MiniDmpSysInfo;
|
||||
|
||||
/* Contains information for a specific thread. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread {
|
||||
ut32 thread_id;
|
||||
ut32 suspend_count;
|
||||
ut32 priority_class;
|
||||
ut32 priority;
|
||||
ut64 teb;
|
||||
struct minidump_memory_descriptor stack;
|
||||
struct minidump_location_descriptor thread_context;
|
||||
});
|
||||
typedef struct minidump_thread_t {
|
||||
ut32 thread_id;
|
||||
ut32 suspend_count;
|
||||
ut32 priority_class;
|
||||
ut32 priority;
|
||||
ut64 teb;
|
||||
MiniDmpMemDescr32 stack;
|
||||
MiniDmpLocDescr32 thread_context;
|
||||
} MiniDmpThread;
|
||||
|
||||
/* Contains a list of threads. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread_list {
|
||||
ut32 number_of_threads;
|
||||
struct minidump_thread threads[0];
|
||||
});
|
||||
typedef struct minidump_thread_list_t {
|
||||
ut32 number_of_threads;
|
||||
MiniDmpThread threads[0]; // not parsed because not used due missing usage.
|
||||
} MiniDmpThreadList;
|
||||
|
||||
/* Contains extended information for a specific thread. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread_ex {
|
||||
ut32 thread_id;
|
||||
ut32 suspend_count;
|
||||
ut32 priority_class;
|
||||
ut32 priority;
|
||||
ut64 teb;
|
||||
typedef struct minidump_thread_ex_t {
|
||||
ut32 thread_id;
|
||||
ut32 suspend_count;
|
||||
ut32 priority_class;
|
||||
ut32 priority;
|
||||
ut64 teb;
|
||||
|
||||
struct minidump_memory_descriptor stack;
|
||||
struct minidump_location_descriptor thread_context;
|
||||
struct minidump_memory_descriptor backing_store;
|
||||
});
|
||||
MiniDmpMemDescr32 stack;
|
||||
MiniDmpLocDescr32 thread_context;
|
||||
MiniDmpMemDescr32 backing_store;
|
||||
} MiniDmpThreadEx;
|
||||
|
||||
/* Contains a list of threads. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread_ex_list {
|
||||
ut32 number_of_threads;
|
||||
struct minidump_thread_ex threads[];
|
||||
});
|
||||
typedef struct minidump_thread_ex_list_t {
|
||||
ut32 number_of_threads;
|
||||
} MiniDmpThreadExList;
|
||||
|
||||
/* Contains thread state information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread_info {
|
||||
ut32 thread_id;
|
||||
ut32 dump_flags;
|
||||
ut32 dump_error;
|
||||
ut32 exit_status;
|
||||
ut64 create_time;
|
||||
ut64 exit_time;
|
||||
ut64 kernel_time;
|
||||
ut64 user_time;
|
||||
ut64 start_address;
|
||||
ut64 affinity;
|
||||
});
|
||||
typedef struct minidump_thread_info_t {
|
||||
ut32 thread_id;
|
||||
ut32 dump_flags;
|
||||
ut32 dump_error;
|
||||
ut32 exit_status;
|
||||
ut64 create_time;
|
||||
ut64 exit_time;
|
||||
ut64 kernel_time;
|
||||
ut64 user_time;
|
||||
ut64 start_address;
|
||||
ut64 affinity;
|
||||
} MiniDmpThreadInfo;
|
||||
|
||||
/* Contains a list of threads. */
|
||||
RZ_PACKED(
|
||||
struct minidump_thread_info_list {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
struct minidump_thread_info entries[];
|
||||
});
|
||||
typedef struct minidump_thread_info_list_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
} MiniDmpThreadInfoList;
|
||||
|
||||
/* Contains a token information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_token_info {
|
||||
ut32 token_size;
|
||||
ut32 token_id;
|
||||
ut64 token_handle;
|
||||
});
|
||||
typedef struct minidump_token_info_t {
|
||||
ut32 token_size;
|
||||
ut32 token_id;
|
||||
ut64 token_handle;
|
||||
} MiniDmpTokenInfo;
|
||||
|
||||
/* Contains a list of token information. */
|
||||
RZ_PACKED(
|
||||
struct minidump_token_info_list {
|
||||
ut32 size_of_list;
|
||||
ut32 number_of_entries;
|
||||
ut32 list_header_size;
|
||||
ut32 element_header_size;
|
||||
struct minidump_token_info entries[];
|
||||
});
|
||||
typedef struct minidump_token_info_list_t {
|
||||
ut32 size_of_list;
|
||||
ut32 number_of_entries;
|
||||
ut32 list_header_size;
|
||||
ut32 element_header_size;
|
||||
} MiniDmpTokenInfoList;
|
||||
|
||||
/* Contains information about a module that has been unloaded. This information
|
||||
* can help diagnose problems calling code that is no longer loaded. */
|
||||
RZ_PACKED(
|
||||
struct minidump_unloaded_module {
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
rva_t module_name_rva;
|
||||
});
|
||||
typedef struct minidump_unloaded_module_t {
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
rva_t module_name_rva;
|
||||
} MiniDmpUnloadedModule;
|
||||
|
||||
/* Contains a list of unloaded modules. */
|
||||
RZ_PACKED(
|
||||
struct minidump_unloaded_module_list {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
struct minidump_unloaded_module entries[];
|
||||
});
|
||||
typedef struct minidump_unloaded_module_list_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
} MiniDmpUnloadedModuleList;
|
||||
|
||||
/* Contains user-defined information stored in a data stream. */
|
||||
RZ_PACKED(
|
||||
struct minidump_user_stream {
|
||||
ut32 type;
|
||||
ut32 buffer_size;
|
||||
void /*PVOID*/ *buffer;
|
||||
});
|
||||
typedef struct minidump_user_stream_t {
|
||||
ut32 type;
|
||||
ut32 buffer_size;
|
||||
void /*PVOID*/ *buffer;
|
||||
} MiniDmpUserStream; /* unused */
|
||||
|
||||
/* Contains a list of user data streams used by the MiniDumpWriteDump function. */
|
||||
RZ_PACKED(
|
||||
struct minidump_user_stream_information {
|
||||
ut32 user_stream_count;
|
||||
|
||||
struct minidump_user_stream *user_stream_array;
|
||||
});
|
||||
typedef struct minidump_user_stream_information_t {
|
||||
ut32 user_stream_count;
|
||||
MiniDmpUserStream *user_stream_array;
|
||||
} MiniDmpUserStreamInfo; /* unused */
|
||||
|
||||
/* Contains information for the MiniDumpCallback function when the callback
|
||||
* type is IncludeThreadCallback. */
|
||||
RZ_PACKED(
|
||||
struct minidump_include_thread_callback {
|
||||
ut32 thread_id;
|
||||
});
|
||||
typedef struct minidump_include_thread_callback_t {
|
||||
ut32 thread_id;
|
||||
} MiniDmpIncludeThreadCallback; /* unused */
|
||||
|
||||
/* Contains module information for the MiniDumpCallback function when the
|
||||
* callback type is ModuleCallback. */
|
||||
RZ_PACKED(
|
||||
struct minidump_module_callback {
|
||||
ut16 /*pwchar*/ *full_path;
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
typedef struct minidump_module_callback_t {
|
||||
ut16 /*pwchar*/ *full_path;
|
||||
ut64 base_of_image;
|
||||
ut32 size_of_image;
|
||||
ut32 check_sum;
|
||||
ut32 time_date_stamp;
|
||||
|
||||
struct vs_fixedfileinfo version_info;
|
||||
VSFixedFileInfo version_info;
|
||||
|
||||
void /*pvoid*/ *cv_record;
|
||||
ut32 size_of_cv_record;
|
||||
void /*pvoid*/ *misc_record;
|
||||
ut32 size_of_misc_record;
|
||||
});
|
||||
void /*pvoid*/ *cv_record;
|
||||
ut32 size_of_cv_record;
|
||||
void /*pvoid*/ *misc_record;
|
||||
ut32 size_of_misc_record;
|
||||
} MiniDmpModuleCallback; /* unused */
|
||||
|
||||
/* Contains information for the MiniDumpCallback function when the callback
|
||||
* type is IncludeModuleCallback. */
|
||||
RZ_PACKED(
|
||||
struct minidump_include_module_callback {
|
||||
ut64 base_of_image;
|
||||
});
|
||||
typedef struct minidump_include_module_callback_t {
|
||||
ut64 base_of_image;
|
||||
} MiniDmpIncludeModuleCallback; /* unused */
|
||||
|
||||
/* Contains I/O callback information. This structure is used by the
|
||||
* MiniDumpCallback function when the callback type is IoStartCallback,
|
||||
* IoWriteAllCallback, or IoFinishCallback. */
|
||||
RZ_PACKED(
|
||||
struct minidump_io_callback {
|
||||
void /*handle*/ *Handle;
|
||||
ut64 offset;
|
||||
void /*pvoid*/ *buffer;
|
||||
ut32 buffer_bytes;
|
||||
});
|
||||
typedef struct minidump_io_callback_t {
|
||||
void /*handle*/ *Handle;
|
||||
ut64 offset;
|
||||
void /*pvoid*/ *buffer;
|
||||
ut32 buffer_bytes;
|
||||
} MiniDmpIOCallback; /* unused */
|
||||
|
||||
/* Contains information about a failed memory read operation. This structure is
|
||||
* used by the MiniDumpCallback function when the callback type is
|
||||
* ReadMemoryFailureCallback. */
|
||||
RZ_PACKED(
|
||||
struct minidump_read_memory_failure_callback {
|
||||
ut64 offset;
|
||||
ut32 bytes;
|
||||
st32 /* HRESULT */ failure_status;
|
||||
});
|
||||
typedef struct minidump_read_memory_failure_callback_t {
|
||||
ut64 offset;
|
||||
ut32 bytes;
|
||||
st32 /* HRESULT */ failure_status;
|
||||
} MiniDmpReadMemoryFailureCallback; /* unused */
|
||||
|
||||
/* Contains information returned by the MiniDumpCallback function. */
|
||||
RZ_PACKED(
|
||||
struct minidump_callback_output {
|
||||
union {
|
||||
ut32 module_write_flags;
|
||||
ut32 thread_write_flags;
|
||||
ut32 secondary_flags;
|
||||
struct {
|
||||
ut64 memory_base;
|
||||
ut32 memory_size;
|
||||
};
|
||||
struct {
|
||||
ut8 /*bool*/ check_cancel;
|
||||
ut8 /*bool*/ cancel;
|
||||
};
|
||||
void /*handle*/ *handle;
|
||||
};
|
||||
|
||||
typedef struct minidump_callback_output_t {
|
||||
union {
|
||||
ut32 module_write_flags;
|
||||
ut32 thread_write_flags;
|
||||
ut32 secondary_flags;
|
||||
struct {
|
||||
struct minidump_memory_info vm_region;
|
||||
ut8 /*bool*/ should_continue;
|
||||
ut64 memory_base;
|
||||
ut32 memory_size;
|
||||
};
|
||||
struct {
|
||||
ut8 /*bool*/ check_cancel;
|
||||
ut8 /*bool*/ cancel;
|
||||
};
|
||||
void /*handle*/ *handle;
|
||||
};
|
||||
|
||||
st32 /* HRESULT */ status;
|
||||
});
|
||||
struct {
|
||||
MiniDmpMemInfo vm_region;
|
||||
ut8 /*bool*/ should_continue;
|
||||
};
|
||||
|
||||
RZ_PACKED(
|
||||
struct avrf_backtrace_information {
|
||||
ut32 depth;
|
||||
ut32 index;
|
||||
ut64 return_addresses[AVRF_MAX_TRACES];
|
||||
});
|
||||
st32 /* HRESULT */ status;
|
||||
} MiniDmpCallbackOutput; /* unused */
|
||||
|
||||
RZ_PACKED(
|
||||
struct avrf_handle_operation {
|
||||
ut64 handle;
|
||||
ut32 process_id;
|
||||
ut32 thread_id;
|
||||
ut32 operation_type;
|
||||
ut32 spare_0;
|
||||
typedef struct avrf_backtrace_information_t {
|
||||
ut32 depth;
|
||||
ut32 index;
|
||||
ut64 return_addresses[AVRF_MAX_TRACES];
|
||||
} AVRFBacktraceInfo;
|
||||
|
||||
struct avrf_backtrace_information back_trace_information;
|
||||
});
|
||||
typedef struct avrf_handle_operation_t {
|
||||
ut64 handle;
|
||||
ut32 process_id;
|
||||
ut32 thread_id;
|
||||
ut32 operation_type;
|
||||
ut32 spare_0;
|
||||
|
||||
AVRFBacktraceInfo back_trace_information;
|
||||
} AVRFHandleOp;
|
||||
|
||||
/* Contains a list of handle operations. */
|
||||
RZ_PACKED(
|
||||
struct minidump_handle_operation_list {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
ut32 reserved;
|
||||
struct avrf_handle_operation entries[];
|
||||
});
|
||||
typedef struct minidump_handle_operation_list_t {
|
||||
ut32 size_of_header;
|
||||
ut32 size_of_entry;
|
||||
ut32 number_of_entries;
|
||||
ut32 reserved;
|
||||
} MiniDmpHandleOpList;
|
||||
|
||||
#endif /* MDMP_SPECS_H */
|
||||
|
|
|
|||
|
|
@ -10,18 +10,18 @@
|
|||
|
||||
#include "mdmp/mdmp.h"
|
||||
|
||||
static Sdb *get_sdb(RzBinFile *bf) {
|
||||
static Sdb *mdmp_get_sdb(RzBinFile *bf) {
|
||||
rz_return_val_if_fail(bf && bf->o, NULL);
|
||||
struct rz_bin_mdmp_obj *obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
MiniDmpObj *obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
return (obj && obj->kv) ? obj->kv : NULL;
|
||||
}
|
||||
|
||||
static void destroy(RzBinFile *bf) {
|
||||
rz_bin_mdmp_free((struct rz_bin_mdmp_obj *)bf->o->bin_obj);
|
||||
static void mdmp_destroy(RzBinFile *bf) {
|
||||
rz_bin_mdmp_free((MiniDmpObj *)bf->o->bin_obj);
|
||||
}
|
||||
|
||||
static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinAddr *>*/ *mdmp_entries(RzBinFile *bf) {
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzListIter *it;
|
||||
|
|
@ -31,7 +31,7 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
rz_list_foreach (obj->pe32_bins, it, pe32_bin) {
|
||||
list = Pe32_rz_bin_mdmp_pe_get_entrypoint(pe32_bin);
|
||||
|
|
@ -47,15 +47,15 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzBinInfo *info(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzBinInfo *mdmp_info(RzBinFile *bf) {
|
||||
MiniDmpObj *obj;
|
||||
RzBinInfo *ret;
|
||||
|
||||
if (!(ret = RZ_NEW0(RzBinInfo))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
ret->big_endian = obj->endian;
|
||||
ret->claimed_checksum = strdup(sdb_fmt("0x%08x", obj->hdr->check_sum)); // FIXME: Leaks
|
||||
|
|
@ -121,10 +121,10 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<char *>*/ *libs(RzBinFile *bf) {
|
||||
static RzList /*<char *>*/ *mdmp_libs(RzBinFile *bf) {
|
||||
char *ptr = NULL;
|
||||
int i;
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
MiniDmpObj *obj;
|
||||
struct rz_bin_pe_lib_t *libs = NULL;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
|
|
@ -138,7 +138,7 @@ static RzList /*<char *>*/ *libs(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
/* TODO: Resolve module name for lib, or filter to remove duplicates,
|
||||
** rather than the vaddr :) */
|
||||
|
|
@ -165,26 +165,26 @@ static RzList /*<char *>*/ *libs(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb) {
|
||||
static bool mdmp_load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb) {
|
||||
rz_return_val_if_fail(buf, false);
|
||||
struct rz_bin_mdmp_obj *res = rz_bin_mdmp_new_buf(buf);
|
||||
MiniDmpObj *res = rz_bin_mdmp_new_buf(buf);
|
||||
if (res) {
|
||||
sdb_ns_set(sdb, "info", res->kv);
|
||||
sdb_ns_set(sdb, "mdmp_info", res->kv);
|
||||
obj->bin_obj = res;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
static RzList /*<RzBinMap *>*/ *mdmp_maps(RzBinFile *bf) {
|
||||
MiniDmpObj *obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_map_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RzListIter *it;
|
||||
struct minidump_memory_descriptor *memory;
|
||||
MiniDmpMemDescr32 *memory;
|
||||
rz_list_foreach (obj->streams.memories, it, memory) {
|
||||
RzBinMap *map = RZ_NEW0(RzBinMap);
|
||||
if (!map) {
|
||||
|
|
@ -200,7 +200,7 @@ static RzList /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
}
|
||||
|
||||
ut64 index = obj->streams.memories64.base_rva;
|
||||
struct minidump_memory_descriptor64 *memory64;
|
||||
MiniDmpMemDescr64 *memory64;
|
||||
rz_list_foreach (obj->streams.memories64.memories, it, memory64) {
|
||||
RzBinMap *map = RZ_NEW0(RzBinMap);
|
||||
if (!map) {
|
||||
|
|
@ -219,17 +219,18 @@ static RzList /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
struct minidump_module *module;
|
||||
struct minidump_string *str;
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
||||
MiniDmpModule *module;
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzList *ret, *pe_secs;
|
||||
RzListIter *it, *it0;
|
||||
RzBinSection *ptr;
|
||||
ut8 str_buffer[512];
|
||||
ut32 str_length = 0;
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
|
|
@ -237,32 +238,36 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
|
||||
// XXX: Never add here as they are covered above
|
||||
rz_list_foreach (obj->streams.modules, it, module) {
|
||||
ut8 b[512];
|
||||
if (!rz_buf_read_le32_at(obj->b, module->module_name_rva, &str_length)) {
|
||||
RZ_LOG_ERROR("bin: mdmp: failed to read utf16 string length\n");
|
||||
break;
|
||||
}
|
||||
|
||||
size_t ptr_name_len = (str_length + 2) * 4;
|
||||
if (ptr_name_len < 1 || ptr_name_len > (sizeof(str_buffer) + sizeof(str_length))) {
|
||||
continue;
|
||||
} else if ((module->module_name_rva + sizeof(str_length) + str_length) > rz_buf_size(obj->b)) {
|
||||
break;
|
||||
}
|
||||
|
||||
memset(str_buffer, 0, sizeof(str_buffer));
|
||||
|
||||
// best effor reading
|
||||
if (rz_buf_read_at(obj->b, module->module_name_rva + sizeof(str_length), str_buffer, sizeof(str_buffer)) < 2) {
|
||||
RZ_LOG_ERROR("bin: mdmp: failed to read utf16 string\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
}
|
||||
if (module->module_name_rva + sizeof(struct minidump_string) >= rz_buf_size(obj->b)) {
|
||||
free(ptr);
|
||||
continue;
|
||||
}
|
||||
rz_buf_read_at(obj->b, module->module_name_rva, (ut8 *)&b, sizeof(b));
|
||||
str = (struct minidump_string *)b;
|
||||
int ptr_name_len = (str->length + 2) * 4;
|
||||
if (ptr_name_len < 1 || ptr_name_len > sizeof(b) - 4) {
|
||||
continue;
|
||||
}
|
||||
if (module->module_name_rva + str->length > rz_buf_size(obj->b)) {
|
||||
free(ptr);
|
||||
break;
|
||||
}
|
||||
ptr->name = calloc(1, ptr_name_len);
|
||||
|
||||
ptr->name = RZ_NEWS0(char, ptr_name_len);
|
||||
if (!ptr->name) {
|
||||
free(ptr);
|
||||
continue;
|
||||
}
|
||||
rz_str_utf16_to_utf8((ut8 *)ptr->name, str->length * 4,
|
||||
(const ut8 *)(&str->buffer), str->length, obj->endian);
|
||||
rz_str_utf16_to_utf8((ut8 *)ptr->name, str_length * 4, str_buffer, str_length, obj->endian);
|
||||
ptr->vaddr = module->base_of_image;
|
||||
ptr->vsize = module->size_of_image;
|
||||
ptr->paddr = rz_bin_mdmp_get_paddr(obj, ptr->vaddr);
|
||||
|
|
@ -297,12 +302,12 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinMem *>*/ *mem(RzBinFile *bf) {
|
||||
struct minidump_location_descriptor *location = NULL;
|
||||
struct minidump_memory_descriptor *module;
|
||||
struct minidump_memory_descriptor64 *module64;
|
||||
struct minidump_memory_info *mem_info;
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinMem *>*/ *mdmp_mem(RzBinFile *bf) {
|
||||
MiniDmpLocDescr32 *location = NULL;
|
||||
MiniDmpMemDescr32 *module;
|
||||
MiniDmpMemDescr64 *module64;
|
||||
MiniDmpMemInfo *mem_info;
|
||||
MiniDmpObj *obj;
|
||||
RzList *ret;
|
||||
RzListIter *it;
|
||||
RzBinMem *ptr;
|
||||
|
|
@ -313,9 +318,9 @@ static RzList /*<RzBinMem *>*/ *mem(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
/* [1] As there isnt a better place to put this info at the moment we will
|
||||
/* [1] As there isnt a better place to put this mdmp_info at the moment we will
|
||||
** mash it into the name field, but without enumeration for now */
|
||||
rz_list_foreach (obj->streams.memories, it, module) {
|
||||
if (!(ptr = RZ_NEW0(RzBinMem))) {
|
||||
|
|
@ -368,8 +373,8 @@ static RzList /*<RzBinMem *>*/ *mem(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinReloc *>*/ *relocs(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinReloc *>*/ *mdmp_relocs(RzBinFile *bf) {
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzListIter *it;
|
||||
|
|
@ -379,7 +384,7 @@ static RzList /*<RzBinReloc *>*/ *relocs(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
rz_list_foreach (obj->pe32_bins, it, pe32_bin) {
|
||||
if (pe32_bin->bin && pe32_bin->bin->relocs) {
|
||||
|
|
@ -395,8 +400,8 @@ static RzList /*<RzBinReloc *>*/ *relocs(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinImport *>*/ *mdmp_imports(RzBinFile *bf) {
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzList *list;
|
||||
|
|
@ -407,7 +412,7 @@ static RzList /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
rz_list_foreach (obj->pe32_bins, it, pe32_bin) {
|
||||
list = Pe32_rz_bin_mdmp_pe_get_imports(pe32_bin);
|
||||
|
|
@ -426,8 +431,8 @@ static RzList /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
||||
struct rz_bin_mdmp_obj *obj;
|
||||
static RzList /*<RzBinSymbol *>*/ *mdmp_symbols(RzBinFile *bf) {
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzList *ret, *list;
|
||||
|
|
@ -437,7 +442,7 @@ static RzList /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
obj = (struct rz_bin_mdmp_obj *)bf->o->bin_obj;
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
rz_list_foreach (obj->pe32_bins, it, pe32_bin) {
|
||||
list = Pe32_rz_bin_mdmp_pe_get_symbols(bf->rbin, pe32_bin);
|
||||
|
|
@ -452,7 +457,7 @@ static RzList /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool check_buffer(RzBuffer *b) {
|
||||
static bool mdmp_check_buffer(RzBuffer *b) {
|
||||
ut8 magic[6];
|
||||
if (rz_buf_read_at(b, 0, magic, sizeof(magic)) == 6) {
|
||||
return !memcmp(magic, MDMP_MAGIC, 6);
|
||||
|
|
@ -460,28 +465,28 @@ static bool check_buffer(RzBuffer *b) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinString *>*/ *strings(RzBinFile *bf) {
|
||||
static RzList /*<RzBinString *>*/ *mdmp_strings(RzBinFile *bf) {
|
||||
return rz_bin_file_strings(bf, 0, false);
|
||||
}
|
||||
|
||||
RzBinPlugin rz_bin_plugin_mdmp = {
|
||||
.name = "mdmp",
|
||||
.desc = "Minidump format rz_bin plugin",
|
||||
.desc = "Windows MiniDump plugin",
|
||||
.license = "LGPL3",
|
||||
.destroy = &destroy,
|
||||
.entries = entries,
|
||||
.get_sdb = &get_sdb,
|
||||
.imports = &imports,
|
||||
.info = &info,
|
||||
.libs = &libs,
|
||||
.load_buffer = &load_buffer,
|
||||
.check_buffer = &check_buffer,
|
||||
.mem = &mem,
|
||||
.relocs = &relocs,
|
||||
.maps = &maps,
|
||||
.sections = §ions,
|
||||
.symbols = &symbols,
|
||||
.strings = &strings,
|
||||
.destroy = &mdmp_destroy,
|
||||
.entries = mdmp_entries,
|
||||
.get_sdb = &mdmp_get_sdb,
|
||||
.imports = &mdmp_imports,
|
||||
.info = &mdmp_info,
|
||||
.libs = &mdmp_libs,
|
||||
.load_buffer = &mdmp_load_buffer,
|
||||
.check_buffer = &mdmp_check_buffer,
|
||||
.mem = &mdmp_mem,
|
||||
.relocs = &mdmp_relocs,
|
||||
.maps = &mdmp_maps,
|
||||
.sections = &mdmp_sections,
|
||||
.symbols = &mdmp_symbols,
|
||||
.strings = &mdmp_strings,
|
||||
};
|
||||
|
||||
#ifndef RZ_PLUGIN_INCORE
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ bin luac LUA Compiled File (LGPL3)
|
|||
bin mach0 mach0 bin plugin (LGPL3)
|
||||
bin mach064 mach064 bin plugin (LGPL3)
|
||||
bin mbn MBN/SBL bootloader things (LGPL3)
|
||||
bin mdmp Minidump format rz_bin plugin (LGPL3)
|
||||
bin mdmp Windows MiniDump plugin (LGPL3)
|
||||
bin menuet Menuet/KolibriOS bin plugin (LGPL3)
|
||||
bin mz MZ bin plugin (MIT)
|
||||
bin ne NE format plugin (LGPL3) GustavoLCR
|
||||
|
|
@ -219,7 +219,7 @@ NAME=Print the bin plugins in JSON
|
|||
FILE==
|
||||
CMDS=Lij
|
||||
EXPECT=<<EOF
|
||||
[{"name":"any","description":"Dummy format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"art","description":"Android Runtime","license":"LGPL3","author":"LGPL3"},{"name":"avr","description":"ATmel AVR MCUs","license":"LGPL3","author":"LGPL3"},{"name":"bf","description":"brainfuck","license":"LGPL3","author":"LGPL3"},{"name":"bflt","description":"bFLT uClinux executable","license":"LGPL3","author":"LGPL3"},{"name":"bios","description":"BIOS bin plugin","license":"LGPL","author":"LGPL"},{"name":"bootimg","description":"Android Boot Image","license":"LGPL3","author":"LGPL3"},{"name":"cgc","description":"CGC format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"coff","description":"COFF format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dex","description":"dex bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dmp64","description":"Windows Crash Dump x64 rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dol","description":"Nintendo Dolphin binary format","license":"BSD","author":"BSD"},{"name":"dyldcache","description":"dyldcache bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"elf","description":"ELF format plugin","license":"LGPL3","author":"LGPL3"},{"name":"elf64","description":"elf64 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"java","description":"java bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"le","description":"LE/LX format plugin","license":"LGPL3","author":"LGPL3"},{"name":"luac","description":"LUA Compiled File","license":"LGPL3","author":"LGPL3"},{"name":"mach0","description":"mach0 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mach064","description":"mach064 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mbn","description":"MBN/SBL bootloader things","license":"LGPL3","author":"LGPL3"},{"name":"mdmp","description":"Minidump format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"menuet","description":"Menuet/KolibriOS bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mz","description":"MZ bin plugin","license":"MIT","author":"MIT"},{"name":"ne","description":"NE format plugin","license":"LGPL3","author":"LGPL3"},{"name":"nes","description":"NES","license":"MIT","author":"MIT"},{"name":"nin3ds","description":"Nintendo 3DS Firmware plugin","license":"LGPL3","author":"LGPL3"},{"name":"ninds","description":"Nintendo DS plugin","license":"LGPL3","author":"LGPL3"},{"name":"ningb","description":"Nintendo Gameboy plugin","license":"LGPL3","author":"LGPL3"},{"name":"ningba","description":"Nintendo Gameboy Advance plugin","license":"LGPL3","author":"LGPL3"},{"name":"nro","description":"Nintendo Switch NRO0 binaries","license":"MIT","author":"MIT"},{"name":"nso","description":"Nintendo Switch NSO0 binaries","license":"MIT","author":"MIT"},{"name":"omf","description":"omf bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"qnx","description":"QNX executable file support","license":"LGPL3","author":"LGPL3"},{"name":"p9","description":"Plan9 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pe","description":"PE bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pe64","description":"PE64 (PE32+) bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pebble","description":"Pebble Watch App","license":"LGPL","author":"LGPL"},{"name":"prg","description":"C64 PRG","license":"LGPL3","author":"LGPL3"},{"name":"psxexe","description":"Sony PlayStation 1 Executable","license":"LGPL3","author":"LGPL3"},{"name":"pyc","description":"Python byte-compiled file plugin","license":"LGPL3","author":"LGPL3"},{"name":"sfc","description":"Super NES / Super Famicom ROM file","license":"LGPL3","author":"LGPL3"},{"name":"smd","description":"SEGA Genesis/Megadrive","license":"LGPL3","author":"LGPL3"},{"name":"sms","description":"SEGA MasterSystem/GameGear","license":"LGPL3","author":"LGPL3"},{"name":"spc700","description":"SNES-SPC700 Sound File Data","license":"LGPL3","author":"LGPL3"},{"name":"symbols","description":"Apple Symbols file","license":"MIT","author":"MIT"},{"name":"te","description":"TE bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"vsf","description":"VICE Snapshot File","license":"LGPL3","author":"LGPL3"},{"name":"wasm","description":"WebAssembly bin plugin","license":"MIT","author":"MIT"},{"name":"xbe","description":"Microsoft Xbox XBE plugin","license":"LGPL3","author":"LGPL3"},{"name":"kernelcache","description":"kernelcache bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"z64","description":"Nintendo 64 Bin-BE plugin","license":"LGPL3","author":"LGPL3"},{"name":"zimg","description":"zimg format bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"xtr.fatmach0","description":"fat mach0 bin extractor plugin","license":"LGPL3"},{"name":"xtr.sep64","description":"64-bit SEP bin extractor plugin","license":"LGPL3"}]
|
||||
[{"name":"any","description":"Dummy format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"art","description":"Android Runtime","license":"LGPL3","author":"LGPL3"},{"name":"avr","description":"ATmel AVR MCUs","license":"LGPL3","author":"LGPL3"},{"name":"bf","description":"brainfuck","license":"LGPL3","author":"LGPL3"},{"name":"bflt","description":"bFLT uClinux executable","license":"LGPL3","author":"LGPL3"},{"name":"bios","description":"BIOS bin plugin","license":"LGPL","author":"LGPL"},{"name":"bootimg","description":"Android Boot Image","license":"LGPL3","author":"LGPL3"},{"name":"cgc","description":"CGC format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"coff","description":"COFF format rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dex","description":"dex bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dmp64","description":"Windows Crash Dump x64 rz_bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"dol","description":"Nintendo Dolphin binary format","license":"BSD","author":"BSD"},{"name":"dyldcache","description":"dyldcache bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"elf","description":"ELF format plugin","license":"LGPL3","author":"LGPL3"},{"name":"elf64","description":"elf64 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"java","description":"java bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"le","description":"LE/LX format plugin","license":"LGPL3","author":"LGPL3"},{"name":"luac","description":"LUA Compiled File","license":"LGPL3","author":"LGPL3"},{"name":"mach0","description":"mach0 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mach064","description":"mach064 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mbn","description":"MBN/SBL bootloader things","license":"LGPL3","author":"LGPL3"},{"name":"mdmp","description":"Windows MiniDump plugin","license":"LGPL3","author":"LGPL3"},{"name":"menuet","description":"Menuet/KolibriOS bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"mz","description":"MZ bin plugin","license":"MIT","author":"MIT"},{"name":"ne","description":"NE format plugin","license":"LGPL3","author":"LGPL3"},{"name":"nes","description":"NES","license":"MIT","author":"MIT"},{"name":"nin3ds","description":"Nintendo 3DS Firmware plugin","license":"LGPL3","author":"LGPL3"},{"name":"ninds","description":"Nintendo DS plugin","license":"LGPL3","author":"LGPL3"},{"name":"ningb","description":"Nintendo Gameboy plugin","license":"LGPL3","author":"LGPL3"},{"name":"ningba","description":"Nintendo Gameboy Advance plugin","license":"LGPL3","author":"LGPL3"},{"name":"nro","description":"Nintendo Switch NRO0 binaries","license":"MIT","author":"MIT"},{"name":"nso","description":"Nintendo Switch NSO0 binaries","license":"MIT","author":"MIT"},{"name":"omf","description":"omf bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"qnx","description":"QNX executable file support","license":"LGPL3","author":"LGPL3"},{"name":"p9","description":"Plan9 bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pe","description":"PE bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pe64","description":"PE64 (PE32+) bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"pebble","description":"Pebble Watch App","license":"LGPL","author":"LGPL"},{"name":"prg","description":"C64 PRG","license":"LGPL3","author":"LGPL3"},{"name":"psxexe","description":"Sony PlayStation 1 Executable","license":"LGPL3","author":"LGPL3"},{"name":"pyc","description":"Python byte-compiled file plugin","license":"LGPL3","author":"LGPL3"},{"name":"sfc","description":"Super NES / Super Famicom ROM file","license":"LGPL3","author":"LGPL3"},{"name":"smd","description":"SEGA Genesis/Megadrive","license":"LGPL3","author":"LGPL3"},{"name":"sms","description":"SEGA MasterSystem/GameGear","license":"LGPL3","author":"LGPL3"},{"name":"spc700","description":"SNES-SPC700 Sound File Data","license":"LGPL3","author":"LGPL3"},{"name":"symbols","description":"Apple Symbols file","license":"MIT","author":"MIT"},{"name":"te","description":"TE bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"vsf","description":"VICE Snapshot File","license":"LGPL3","author":"LGPL3"},{"name":"wasm","description":"WebAssembly bin plugin","license":"MIT","author":"MIT"},{"name":"xbe","description":"Microsoft Xbox XBE plugin","license":"LGPL3","author":"LGPL3"},{"name":"kernelcache","description":"kernelcache bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"z64","description":"Nintendo 64 Bin-BE plugin","license":"LGPL3","author":"LGPL3"},{"name":"zimg","description":"zimg format bin plugin","license":"LGPL3","author":"LGPL3"},{"name":"xtr.fatmach0","description":"fat mach0 bin extractor plugin","license":"LGPL3"},{"name":"xtr.sep64","description":"64-bit SEP bin extractor plugin","license":"LGPL3"}]
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue