53 const int rsds_sz = 4 +
sizeof(
SGUID) + 4;
54 if (dbg_data_len < rsds_sz) {
57 memcpy(res, dbg_data, rsds_sz);
63 const int nb10sz = 16;
64 if (dbg_data_len < nb10sz) {
67 memcpy(res, dbg_data, nb10sz);
72 #define SIZEOF_FILE_NAME 255
78 switch (dbg_dir_entry->Type) {
80 if (!strncmp((
char *)dbg_data,
"RSDS", 4)) {
83 if (!
get_rsds(dbg_data, dbg_data_len, &rsds_hdr)) {
88 "%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x%x",
105 }
else if (strncmp((
const char *)dbg_data,
"NB10", 4) == 0) {
106 if (dbg_data_len < 20) {
107 RZ_LOG_ERROR(
"Truncated NB10 entry, not enough data to parse\n");
112 get_nb10(dbg_data, dbg_data_len, &nb10_hdr);
122 RZ_LOG_INFO(
"CodeView section not NB10 or RSDS\n");
144 ut8 buf[
sizeof(
PE_(image_debug_directory_entry))];
155 return sizeof(
PE_(image_debug_directory_entry));
159 PE_(image_debug_directory_entry)
160 img_dbg_dir_entry = { 0 };
161 PE_(image_data_directory) *dbg_dir =
NULL;
168 dbg_dir = &
bin->nt_headers->optional_header.DataDirectory[6 ];
170 if ((
int)dbg_dir_offset < 0 || dbg_dir_offset >=
bin->size) {
177 if ((
rz_buf_size(
bin->b) - dbg_dir_offset) <
sizeof(
PE_(image_debug_directory_entry))) {
182 if (dbg_data_len < 1) {
185 dbg_data = (
ut8 *)
calloc(1, dbg_data_len + 1);
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * calloc(size_t number, size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
PE_DWord PE_() bin_pe_rva_to_paddr(RzBinPEObj *bin, PE_DWord rva)
#define PE_READ_STRUCT_FIELD(var, struct_type, field, size)
int PE_() rz_bin_pe_get_debug_data(RzBinPEObj *bin, SDebugInfo *res)
static void free_rsdr_hdr(SCV_RSDS_HEADER *rsds_hdr)
static void free_cv_nb10_header(SCV_NB10_HEADER *cv_nb10_header)
static void get_nb10(ut8 *dbg_data, int dbg_data_len, SCV_NB10_HEADER *res)
static int get_debug_info(RzBinPEObj *bin, PE_(image_debug_directory_entry) *dbg_dir_entry, ut8 *dbg_data, int dbg_data_len, SDebugInfo *res)
static bool get_rsds(ut8 *dbg_data, int dbg_data_len, SCV_RSDS_HEADER *res)
static void init_rsdr_hdr(SCV_RSDS_HEADER *rsds_hdr)
static void init_cv_nb10_header(SCV_NB10_HEADER *cv_nb10_header)
static int read_image_debug_directory_entry(RzBuffer *b, ut64 addr, PE_(image_debug_directory_entry) *entry)
#define IMAGE_DEBUG_TYPE_CODEVIEW
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
#define RZ_LOG_INFO(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
char file_name[DBG_FILE_NAME_LEN]
char guidstr[GUIDSTR_LEN]
ut64(WINAPI *w32_GetEnabledXStateFeatures)()