Rizin
unix-like reverse engineering framework and cli tools
pdb.h File Reference
#include <rz_pdb.h>
#include "dbi.h"
#include "gdata.h"
#include "omap.h"
#include "stream_pe.h"
#include "tpi.h"

Go to the source code of this file.

Functions

RZ_IPI bool parse_omap_stream (RzPdb *pdb, RzPdbMsfStream *stream)
 
RZ_IPI void free_omap_stream (RzPdbOmapStream *stream)
 
RZ_IPI int omap_remap (void *stream, int address)
 
RZ_IPI bool parse_gdata_stream (RzPdb *pdb, RzPdbMsfStream *stream)
 
RZ_IPI void free_gdata_stream (RzPdbGDataStream *stream)
 
RZ_IPI bool parse_dbi_stream (RzPdb *pdb, RzPdbMsfStream *stream)
 
RZ_IPI void free_dbi_stream (RzPdbDbiStream *stream)
 
RZ_IPI bool parse_pe_stream (RzPdb *pdb, RzPdbMsfStream *stream)
 
RZ_IPI void free_pe_stream (RzPdbPeStream *stream)
 
RZ_IPI bool parse_tpi_stream (RzPdb *pdb, RzPdbMsfStream *stream)
 
RZ_IPI RzPdbTpiTypeparse_simple_type (RzPdbTpiStream *stream, ut32 idx)
 Parses simple type if the idx represents one. More...
 
RZ_IPI void free_tpi_stream (RzPdbTpiStream *stream)
 

Function Documentation

◆ free_dbi_stream()

RZ_IPI void free_dbi_stream ( RzPdbDbiStream stream)

Definition at line 7 of file dbi.c.

7  {
8  if (!stream) {
9  return;
10  }
11  RzPdbDbiStreamExHdr *ex_hdr;
12  RzListIter *it;
13  rz_list_foreach (stream->ex_hdrs, it, ex_hdr) {
14  RZ_FREE(ex_hdr->ModuleName);
15  RZ_FREE(ex_hdr->ObjFileName);
16  RZ_FREE(ex_hdr);
17  }
18  rz_list_free(stream->ex_hdrs);
19  free(stream);
20 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf stream
Definition: ioapi.h:138
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
#define RZ_FREE(x)
Definition: rz_types.h:369
char * ModuleName
Definition: dbi.h:42
char * ObjFileName
Definition: dbi.h:43

References free(), dbi_stream_ex_header_t::ModuleName, dbi_stream_ex_header_t::ObjFileName, RZ_FREE, and rz_list_free().

Referenced by rz_bin_pdb_free().

◆ free_gdata_stream()

RZ_IPI void free_gdata_stream ( RzPdbGDataStream stream)

Definition at line 80 of file gdata.c.

80  {
81  if (!stream) {
82  return;
83  }
84  GDataGlobal *global;
85  RzListIter *it;
86  rz_list_foreach (stream->global_list, it, global) {
87  RZ_FREE(global->name);
88  RZ_FREE(global);
89  }
90  rz_list_free(stream->global_list);
91  free(stream);
92 }
char * name
Definition: gdata.h:14

References free(), GDataGlobal::name, RZ_FREE, and rz_list_free().

Referenced by rz_bin_pdb_free().

◆ free_omap_stream()

RZ_IPI void free_omap_stream ( RzPdbOmapStream stream)

Definition at line 42 of file omap.c.

42  {
43  if (!stream) {
44  return;
45  }
47  RzListIter *it;
48  rz_list_foreach (stream->entries, it, entry) { RZ_FREE(entry); }
49  rz_list_free(stream->entries);
50  free(stream);
51 }
Definition: omap.h:9
Definition: zipcmp.c:77

References free(), RZ_FREE, and rz_list_free().

Referenced by rz_bin_pdb_free().

◆ free_pe_stream()

RZ_IPI void free_pe_stream ( RzPdbPeStream stream)

Definition at line 53 of file stream_pe.c.

53  {
54  if (!stream) {
55  return;
56  }
57  rz_list_free(stream->sections_hdrs);
58  free(stream);
59 };

References free(), and rz_list_free().

Referenced by rz_bin_pdb_free().

◆ free_tpi_stream()

RZ_IPI void free_tpi_stream ( RzPdbTpiStream stream)

Definition at line 705 of file tpi.c.

705  {
706  if (!stream) {
707  return;
708  }
710  rz_list_free(stream->print_type);
711  free(stream);
712 }
#define NULL
Definition: cris-opc.c:27
RZ_API void rz_rbtree_free(RZ_NULLABLE RBNode *root, RBNodeFree freefn, void *user)
Definition: rbtree.c:281
static void free_tpi_rbtree(RBNode *node, void *user)
Definition: tpi.c:699

References free(), free_tpi_rbtree(), NULL, rz_list_free(), and rz_rbtree_free().

Referenced by rz_bin_pdb_free().

◆ omap_remap()

RZ_IPI int omap_remap ( void *  stream,
int  address 
)

◆ parse_dbi_stream()

RZ_IPI bool parse_dbi_stream ( RzPdb pdb,
RzPdbMsfStream stream 
)

Definition at line 151 of file dbi.c.

151  {
152  if (!pdb || !stream) {
153  return false;
154  }
155  pdb->s_dbi = RZ_NEW0(RzPdbDbiStream);
156  RzPdbDbiStream *s = pdb->s_dbi;
157  if (!s) {
158  RZ_LOG_ERROR("Error allocating memory.\n");
159  return false;
160  }
161  RzBuffer *buf = stream->stream_data;
162  // parse header
164  return false;
165  }
166 
167  // skip these streams
168  ut64 seek = s->hdr.section_contribution_size + s->hdr.section_map_size +
169  s->hdr.source_info_size + s->hdr.type_server_map_size +
170  s->hdr.ec_substream_size;
172  if (!parse_dbi_dbg_header(s, buf)) {
173  return false;
174  }
175  return true;
176 }
static bool parse_dbi_stream_header(RzPdbDbiStream *s, RzBuffer *buf)
Definition: dbi.c:22
static bool parse_dbi_stream_ex_header(RzPdbDbiStream *s, RzBuffer *buf)
Definition: dbi.c:57
static bool parse_dbi_dbg_header(RzPdbDbiStream *s, RzBuffer *buf)
Definition: dbi.c:134
voidpf void * buf
Definition: ioapi.h:138
static RzSocket * s
Definition: rtr.c:28
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
Definition: buf.c:1166
#define RZ_BUF_CUR
Definition: rz_buf.h:15
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
#define RZ_NEW0(x)
Definition: rz_types.h:284
RzPdbDbiStream * s_dbi
Definition: rz_pdb.h:246
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int seek(char *argv[])

References parse_dbi_dbg_header(), parse_dbi_stream_ex_header(), parse_dbi_stream_header(), RZ_BUF_CUR, rz_buf_seek(), RZ_LOG_ERROR, RZ_NEW0, s, rz_pdb_t::s_dbi, seek(), and ut64().

Referenced by parse_streams().

◆ parse_gdata_stream()

RZ_IPI bool parse_gdata_stream ( RzPdb pdb,
RzPdbMsfStream stream 
)

Definition at line 33 of file gdata.c.

33  {
34  rz_return_val_if_fail(pdb && stream, false);
35  if (!pdb->s_gdata) {
37  }
38  RzPdbGDataStream *s = pdb->s_gdata;
39  if (!s) {
40  RZ_LOG_ERROR("Error allocating memory.\n");
41  return false;
42  }
43  RzBuffer *buf = stream->stream_data;
44  s->global_list = rz_list_new();
45  if (!s->global_list) {
46  return false;
47  }
48  ut16 len;
49  while (true) {
50  ut32 initial_seek = rz_buf_tell(buf);
51  if (!rz_buf_read_le16(buf, &len)) {
52  break;
53  }
54  if (len == 0 || len == UT16_MAX) {
55  break;
56  }
57  ut16 leaf_type;
58  if (!rz_buf_read_le16(buf, &leaf_type)) {
59  return false;
60  }
61  if (leaf_type == 0x110E || leaf_type == 0x1009) {
62  GDataGlobal *global = RZ_NEW0(GDataGlobal);
63  if (!global) {
64  goto skip;
65  }
66  global->leaf_type = leaf_type;
67  if (!parse_gdata_global(global, buf, initial_seek)) {
68  RZ_FREE(global);
69  return false;
70  }
71  rz_list_append(s->global_list, global);
72  continue;
73  }
74  skip:
75  rz_buf_seek(buf, len - sizeof(ut16), RZ_BUF_CUR);
76  }
77  return true;
78 }
size_t len
Definition: 6502dis.c:15
uint16_t ut16
uint32_t ut32
static bool parse_gdata_global(GDataGlobal *global, RzBuffer *buf, ut32 initial_seek)
Definition: gdata.c:7
void skip(file *in, unsigned n)
Definition: gzappend.c:202
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b)
Return the current cursor position.
Definition: buf.c:1238
#define rz_buf_read_le16(b, result)
Read a big endian or little endian (ut16, ut32, ut64) at the specified offset in the buffer and shift...
Definition: rz_buf.h:266
#define UT16_MAX
ut16 leaf_type
Definition: gdata.h:10
RzPdbGDataStream * s_gdata
Definition: rz_pdb.h:248

References GDataGlobal::leaf_type, len, parse_gdata_global(), RZ_BUF_CUR, rz_buf_read_le16, rz_buf_seek(), rz_buf_tell(), RZ_FREE, rz_list_append(), rz_list_new(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, s, rz_pdb_t::s_gdata, skip(), and UT16_MAX.

Referenced by parse_streams().

◆ parse_omap_stream()

RZ_IPI bool parse_omap_stream ( RzPdb pdb,
RzPdbMsfStream stream 
)

Definition at line 8 of file omap.c.

8  {
9  rz_return_val_if_fail(pdb && stream, false);
10  if (!pdb->s_omap) {
12  }
13  RzBuffer *buf = stream->stream_data;
14  RzPdbOmapStream *s = pdb->s_omap;
15  if (!s) {
16  RZ_LOG_ERROR("Error allocating memory.\n");
17  return false;
18  }
19  if (!s->entries) {
20  s->entries = rz_list_new();
21  }
23  ut32 read_len = 0;
24  while (read_len < size) {
26  if (!entry) {
27  rz_list_free(s->entries);
28  return false;
29  }
30  if (!rz_buf_read_le32(buf, &entry->from) ||
31  !rz_buf_read_le32(buf, &entry->to)) {
32  free(entry);
33  rz_list_free(s->entries);
34  return false;
35  }
36  read_len += sizeof(ut32) * 2;
37  rz_list_append(s->entries, entry);
38  }
39  return true;
40 }
voidpf void uLong size
Definition: ioapi.h:138
#define rz_buf_read_le32(b, result)
Definition: rz_buf.h:267
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
Definition: buf.c:1225
RzPdbOmapStream * s_omap
Definition: rz_pdb.h:249

References free(), rz_buf_read_le32, rz_buf_size(), rz_list_append(), rz_list_free(), rz_list_new(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, s, and rz_pdb_t::s_omap.

Referenced by parse_streams().

◆ parse_pe_stream()

RZ_IPI bool parse_pe_stream ( RzPdb pdb,
RzPdbMsfStream stream 
)

Definition at line 20 of file stream_pe.c.

20  {
21  rz_return_val_if_fail(pdb && stream, false);
22  if (!pdb->s_pe) {
23  pdb->s_pe = RZ_NEW0(RzPdbPeStream);
24  }
25  RzBuffer *buf = stream->stream_data;
26  RzPdbPeStream *s = pdb->s_pe;
27  if (!s) {
28  RZ_LOG_ERROR("Error allocating memory.\n");
29  return false;
30  }
31  if (!s->sections_hdrs) {
32  s->sections_hdrs = rz_list_newf(free);
33  }
35  ut32 read_len = 0;
36  while (read_len < size) {
38  if (!hdr) {
39  rz_list_free(s->sections_hdrs);
40  return false;
41  }
42  if (!parse_image_header(hdr, buf)) {
43  rz_list_free(s->sections_hdrs);
44  free(hdr);
45  return false;
46  }
47 
48  read_len += sizeof(PeImageSectionHeader);
49  rz_list_append(s->sections_hdrs, hdr);
50  }
51  return true;
52 }
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
static bool parse_image_header(PeImageSectionHeader *hdr, RzBuffer *buf)
Definition: stream_pe.c:7
RzPdbPeStream * s_pe
Definition: rz_pdb.h:250

References free(), parse_image_header(), rz_buf_size(), rz_list_append(), rz_list_free(), rz_list_newf(), RZ_LOG_ERROR, RZ_NEW0, rz_return_val_if_fail, s, and rz_pdb_t::s_pe.

Referenced by parse_streams().

◆ parse_simple_type()

RZ_IPI RzPdbTpiType* parse_simple_type ( RzPdbTpiStream stream,
ut32  idx 
)

Parses simple type if the idx represents one.

Parameters
RzPdbTpiStreamTPI stream context
idxleaf index
Returns
RzPdbTpiType, leaf_type = 0 -> error

Definition at line 142 of file tpi.c.

142  {
144  if (!type) {
145  RZ_LOG_ERROR("Error allocating memory.\n");
146  return NULL;
147  }
148  type->leaf_type = LF_SIMPLE_TYPE;
149  type->type_index = idx;
150  // For simple type we don't set length
151  type->length = 0;
153  if (!simple_type) {
154  RZ_LOG_ERROR("Error allocating memory.\n");
155  free(type);
156  return NULL;
157  }
158  type->type_data = simple_type;
159  RzStrBuf *buf;
161  switch (kind) {
162  case PDB_NONE:
163  simple_type->size = 0;
164  buf = rz_strbuf_new("notype_t");
165  break;
166  case PDB_VOID:
167  simple_type->size = 0;
168  buf = rz_strbuf_new("void");
169  break;
170  case PDB_SIGNED_CHAR:
171  case PDB_NARROW_CHAR:
172  simple_type->size = 1;
173  buf = rz_strbuf_new("char");
174  break;
175  case PDB_UNSIGNED_CHAR:
176  simple_type->size = 1;
177  buf = rz_strbuf_new("unsigned char");
178  break;
179  case PDB_WIDE_CHAR:
180  simple_type->size = 4;
181  buf = rz_strbuf_new("wchar_t");
182  break;
183  case PDB_CHAR16:
184  simple_type->size = 2;
185  buf = rz_strbuf_new("char16_t");
186  break;
187  case PDB_CHAR32:
188  simple_type->size = 4;
189  buf = rz_strbuf_new("char32_t");
190  break;
191  case PDB_BYTE:
192  simple_type->size = 1;
193  buf = rz_strbuf_new("uint8_t");
194  break;
195  case PDB_SBYTE:
196  simple_type->size = 1;
197  buf = rz_strbuf_new("int8_t");
198  break;
199  case PDB_INT16:
200  case PDB_INT16_SHORT:
201  simple_type->size = 2;
202  buf = rz_strbuf_new("int16_t");
203  break;
204  case PDB_UINT16:
205  case PDB_UINT16_SHORT:
206  simple_type->size = 2;
207  buf = rz_strbuf_new("uint16_t");
208  break;
209  case PDB_INT32:
210  case PDB_INT32_LONG:
211  simple_type->size = 4;
212  buf = rz_strbuf_new("int32_t");
213  break;
214  case PDB_UINT32:
215  case PDB_UINT32_LONG:
216  simple_type->size = 4;
217  buf = rz_strbuf_new("uint32_t");
218  break;
219  case PDB_INT64:
220  case PDB_INT64_QUAD:
221  simple_type->size = 8;
222  buf = rz_strbuf_new("int64_t");
223  break;
224  case PDB_UINT64:
225  case PDB_UINT64_QUAD:
226  simple_type->size = 8;
227  buf = rz_strbuf_new("uint64_t");
228  break;
229  case PDB_INT128:
230  case PDB_INT128_OCT:
231  simple_type->size = 16;
232  buf = rz_strbuf_new("int128_t");
233  break;
234  case PDB_UINT128:
235  case PDB_UINT128_OCT:
236  simple_type->size = 16;
237  buf = rz_strbuf_new("uint128_t");
238  break;
239  case PDB_FLOAT16:
240  simple_type->size = 2;
241  buf = rz_strbuf_new("float");
242  break;
243  case PDB_FLOAT32:
244  case PDB_FLOAT32_PP:
245  simple_type->size = 4;
246  buf = rz_strbuf_new("float");
247  break;
248  case PDB_FLOAT48:
249  simple_type->size = 6;
250  buf = rz_strbuf_new("float");
251  break;
252  case PDB_FLOAT64:
253  simple_type->size = 8;
254  buf = rz_strbuf_new("double");
255  break;
256  case PDB_FLOAT80:
257  simple_type->size = 10;
258  buf = rz_strbuf_new("long double");
259  break;
260  case PDB_FLOAT128:
261  simple_type->size = 16;
262  buf = rz_strbuf_new("long double");
263  break;
264  case PDB_COMPLEX16:
265  simple_type->size = 2;
266  buf = rz_strbuf_new("float _Complex");
267  break;
268  case PDB_COMPLEX32:
269  case PDB_COMPLEX32_PP:
270  simple_type->size = 4;
271  buf = rz_strbuf_new("float _Complex");
272  break;
273  case PDB_COMPLEX48:
274  simple_type->size = 6;
275  buf = rz_strbuf_new("float _Complex");
276  break;
277  case PDB_COMPLEX64:
278  simple_type->size = 8;
279  buf = rz_strbuf_new("double _Complex");
280  break;
281  case PDB_COMPLEX80:
282  simple_type->size = 10;
283  buf = rz_strbuf_new("long double _Complex");
284  break;
285  case PDB_COMPLEX128:
286  simple_type->size = 16;
287  buf = rz_strbuf_new("long double _Complex");
288  break;
289  case PDB_BOOL8:
290  simple_type->size = 1;
291  buf = rz_strbuf_new("bool");
292  break;
293  case PDB_BOOL16:
294  simple_type->size = 2;
295  buf = rz_strbuf_new("bool");
296  break;
297  case PDB_BOOL32:
298  simple_type->size = 4;
299  buf = rz_strbuf_new("bool");
300  break;
301  case PDB_BOOL64:
302  simple_type->size = 8;
303  buf = rz_strbuf_new("bool");
304  break;
305  case PDB_BOOL128:
306  simple_type->size = 16;
307  buf = rz_strbuf_new("bool");
308  break;
309  default:
310  simple_type->size = 0;
311  buf = rz_strbuf_new("unknown_t");
312  break;
313  }
315  if (mode) {
316  rz_strbuf_append(buf, " *");
317  }
318  switch (mode) {
319  case NEAR_POINTER:
320  simple_type->size = 2;
321  break;
322  case FAR_POINTER:
323  case HUGE_POINTER:
324  case NEAR_POINTER32:
325  case FAR_POINTER32:
326  simple_type->size = 4;
327  break;
328  case NEAR_POINTER64:
329  simple_type->size = 8;
330  break;
331  case NEAR_POINTER128:
332  simple_type->size = 16;
333  break;
334  default:
335  break;
336  }
337  simple_type->type = rz_strbuf_drain(buf);
338  // We just insert once
339  rz_rbtree_insert(&stream->types, &type->type_index, &type->rb, tpi_type_node_cmp, NULL);
340  return type;
341 }
const char int mode
Definition: ioapi.h:137
int type
Definition: mipsasm.c:17
int idx
Definition: setup.py:197
RZ_API bool rz_rbtree_insert(RBNode **root, void *data, RBNode *node, RBComparator cmp, void *user)
Returns true if the node was inserted successfully.
Definition: rbtree.c:291
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
Definition: strbuf.c:342
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
Definition: strbuf.c:222
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
Definition: strbuf.c:8
char * type
Definition: tpi.h:586
static TpiSimpleTypeKind get_simple_type_kind(ut32 type)
Definition: tpi.c:72
static TpiSimpleTypeMode get_simple_type_mode(ut32 type)
Definition: tpi.c:61
int tpi_type_node_cmp(const void *incoming, const RBNode *in_tree, void *user)
Definition: tpi.c:19
TpiSimpleTypeKind
Definition: tpi.h:20
@ PDB_INT128_OCT
Definition: tpi.h:47
@ PDB_VOID
Definition: tpi.h:22
@ PDB_NONE
Definition: tpi.h:21
@ PDB_UINT16
Definition: tpi.h:38
@ PDB_INT128
Definition: tpi.h:49
@ PDB_BYTE
Definition: tpi.h:34
@ PDB_FLOAT64
Definition: tpi.h:56
@ PDB_COMPLEX16
Definition: tpi.h:60
@ PDB_BOOL128
Definition: tpi.h:72
@ PDB_BOOL32
Definition: tpi.h:70
@ PDB_COMPLEX80
Definition: tpi.h:65
@ PDB_UINT128
Definition: tpi.h:50
@ PDB_COMPLEX32
Definition: tpi.h:61
@ PDB_FLOAT48
Definition: tpi.h:55
@ PDB_UINT64_QUAD
Definition: tpi.h:44
@ PDB_INT16_SHORT
Definition: tpi.h:35
@ PDB_BOOL16
Definition: tpi.h:69
@ PDB_NARROW_CHAR
Definition: tpi.h:28
@ PDB_BOOL64
Definition: tpi.h:71
@ PDB_COMPLEX48
Definition: tpi.h:63
@ PDB_CHAR32
Definition: tpi.h:31
@ PDB_COMPLEX64
Definition: tpi.h:64
@ PDB_COMPLEX32_PP
Definition: tpi.h:62
@ PDB_CHAR16
Definition: tpi.h:30
@ PDB_BOOL8
Definition: tpi.h:68
@ PDB_UINT32_LONG
Definition: tpi.h:40
@ PDB_INT64
Definition: tpi.h:45
@ PDB_FLOAT32_PP
Definition: tpi.h:54
@ PDB_UINT64
Definition: tpi.h:46
@ PDB_UNSIGNED_CHAR
Definition: tpi.h:27
@ PDB_COMPLEX128
Definition: tpi.h:66
@ PDB_SIGNED_CHAR
Definition: tpi.h:26
@ PDB_FLOAT80
Definition: tpi.h:57
@ PDB_WIDE_CHAR
Definition: tpi.h:29
@ PDB_INT32_LONG
Definition: tpi.h:39
@ PDB_SBYTE
Definition: tpi.h:33
@ PDB_UINT16_SHORT
Definition: tpi.h:36
@ PDB_INT32
Definition: tpi.h:41
@ PDB_FLOAT32
Definition: tpi.h:53
@ PDB_FLOAT16
Definition: tpi.h:52
@ PDB_UINT32
Definition: tpi.h:42
@ PDB_UINT128_OCT
Definition: tpi.h:48
@ PDB_INT64_QUAD
Definition: tpi.h:43
@ PDB_FLOAT128
Definition: tpi.h:58
@ PDB_INT16
Definition: tpi.h:37
TpiSimpleTypeMode
Definition: tpi.h:9
@ NEAR_POINTER64
Definition: tpi.h:16
@ NEAR_POINTER
Definition: tpi.h:11
@ HUGE_POINTER
Definition: tpi.h:13
@ FAR_POINTER
Definition: tpi.h:12
@ FAR_POINTER32
Definition: tpi.h:15
@ NEAR_POINTER32
Definition: tpi.h:14
@ NEAR_POINTER128
Definition: tpi.h:17
@ LF_SIMPLE_TYPE
Definition: tpi.h:246

References FAR_POINTER, FAR_POINTER32, free(), get_simple_type_kind(), get_simple_type_mode(), HUGE_POINTER, setup::idx, LF_SIMPLE_TYPE, NEAR_POINTER, NEAR_POINTER128, NEAR_POINTER32, NEAR_POINTER64, NULL, PDB_BOOL128, PDB_BOOL16, PDB_BOOL32, PDB_BOOL64, PDB_BOOL8, PDB_BYTE, PDB_CHAR16, PDB_CHAR32, PDB_COMPLEX128, PDB_COMPLEX16, PDB_COMPLEX32, PDB_COMPLEX32_PP, PDB_COMPLEX48, PDB_COMPLEX64, PDB_COMPLEX80, PDB_FLOAT128, PDB_FLOAT16, PDB_FLOAT32, PDB_FLOAT32_PP, PDB_FLOAT48, PDB_FLOAT64, PDB_FLOAT80, PDB_INT128, PDB_INT128_OCT, PDB_INT16, PDB_INT16_SHORT, PDB_INT32, PDB_INT32_LONG, PDB_INT64, PDB_INT64_QUAD, PDB_NARROW_CHAR, PDB_NONE, PDB_SBYTE, PDB_SIGNED_CHAR, PDB_UINT128, PDB_UINT128_OCT, PDB_UINT16, PDB_UINT16_SHORT, PDB_UINT32, PDB_UINT32_LONG, PDB_UINT64, PDB_UINT64_QUAD, PDB_UNSIGNED_CHAR, PDB_VOID, PDB_WIDE_CHAR, RZ_LOG_ERROR, RZ_NEW0, rz_rbtree_insert(), rz_strbuf_append(), rz_strbuf_drain(), rz_strbuf_new(), Tpi_LF_SimpleType::size, tpi_type_node_cmp(), type, and Tpi_LF_SimpleType::type.

Referenced by rz_bin_pdb_get_type_by_index().

◆ parse_tpi_stream()

RZ_IPI bool parse_tpi_stream ( RzPdb pdb,
RzPdbMsfStream stream 
)

Definition at line 1799 of file tpi.c.

1799  {
1800  if (!pdb || !stream) {
1801  return false;
1802  }
1803  if (stream->stream_idx != PDB_STREAM_TPI) {
1804  RZ_LOG_ERROR("Error TPI stream index.\n");
1805  return false;
1806  }
1807  pdb->s_tpi = RZ_NEW0(RzPdbTpiStream);
1808  RzPdbTpiStream *s = pdb->s_tpi;
1809  if (!s) {
1810  RZ_LOG_ERROR("Error allocating memory.\n");
1811  return false;
1812  }
1813  s->types = NULL;
1814  RzBuffer *buf = stream->stream_data;
1815  if (!parse_tpi_stream_header(s, buf)) {
1816  return false;
1817  }
1818  if (s->header.HeaderSize != sizeof(RzPdbTpiStreamHeader)) {
1819  RZ_LOG_ERROR("Corrupted TPI stream.\n");
1820  return false;
1821  }
1822  RzPdbTpiType *type;
1823  for (ut32 i = s->header.TypeIndexBegin; i < s->header.TypeIndexEnd; i++) {
1825  if (!type) {
1826  continue;
1827  }
1828  type->type_index = i;
1829  if (!parse_tpi_types(buf, type) || !type->type_data) {
1830  RZ_LOG_ERROR("Parse TPI type error. idx in stream: 0x%" PFMT32x "\n", i);
1831  RZ_FREE(type);
1832  return false;
1833  }
1834  rz_rbtree_insert(&s->types, &type->type_index, &type->rb, tpi_type_node_cmp, NULL);
1835  }
1836  return true;
1837 }
#define PFMT32x
lzma_index ** i
Definition: index.h:629
#define header(is_bt, len_min, ret_op)
@ PDB_STREAM_TPI
Definition: rz_pdb.h:164
RzPdbTpiStream * s_tpi
Definition: rz_pdb.h:247
static bool parse_tpi_types(RzBuffer *buf, RzPdbTpiType *type)
Definition: tpi.c:1715
static bool parse_tpi_stream_header(RzPdbTpiStream *s, RzBuffer *buf)
Definition: tpi.c:1777

References header, i, NULL, parse_tpi_stream_header(), parse_tpi_types(), PDB_STREAM_TPI, PFMT32x, RZ_FREE, RZ_LOG_ERROR, RZ_NEW0, rz_rbtree_insert(), s, rz_pdb_t::s_tpi, tpi_type_node_cmp(), and type.

Referenced by parse_streams().