10 #include "../bin/pdb/pdb.h"
69 typ->
array.type = element_type;
76 switch (
type->leaf_type) {
80 RZ_LOG_INFO(
"%s : LF_CLASS is not handled for now.\n", __FUNCTION__);
91 RZ_LOG_INFO(
"%s : LF_BITFIELD is not handled for now.\n", __FUNCTION__);
102 RZ_LOG_INFO(
"%s : unsupported leaf type 0x%x\n", __FUNCTION__,
type->leaf_type);
158 char *error_msg =
NULL;
161 RZ_LOG_ERROR(
"%s : Error parsing complex type member \"%s\" type:\n%s\n", __FUNCTION__, simple_type->
type, error_msg);
181 for (
int i = 0;
i < lf_arglist->
count;
i++) {
202 if (!typ || !callable) {
243 if (!
type || !callable) {
249 type->callable = callable;
256 if (!
type->callable->ret) {
257 type->callable->noret =
true;
262 if (!
type->callable->args) {
319 if (b_type && b_type->
type) {
336 btype->
type = n_type;
393 RZ_LOG_INFO(
"%s : couldn't parse structure member type!\n", __FUNCTION__);
411 return !
name || !strcmp(
name,
"<unnamed-tag>") || !strcmp(
name,
"<anonymous-tag>");
453 RZ_LOG_WARN(
"PDB: Type of %s (struct) conflicts with already defined type (%s), redefining it.\n",
476 base_type->
type = typ;
489 rz_list_foreach (members, it, member_info) {
493 it = rz_list_head(members);
500 if (!struct_member) {
554 RZ_LOG_INFO(
"%s : couldn't parse union member type!\n", __FUNCTION__);
586 RZ_LOG_WARN(
"PDB: Type of %s (union) conflicts with already defined type (%s), redefining it.\n",
609 base_type->
type = typ;
622 rz_list_foreach (members, it, member_info) {
626 it = rz_list_head(members);
693 RZ_LOG_WARN(
"PDB: Type of %s (enum) conflicts with already defined type (%s), redefining it.\n",
723 base_type->
type = btype;
735 rz_list_foreach (members, it, member_info) {
739 it = rz_list_head(members);
774 switch (
type->leaf_type) {
810 if (!
stream->print_type) {
RZ_API void rz_type_base_type_free(RzBaseType *type)
Frees the RzBaseType instance and all of its members.
RZ_API void rz_type_base_enum_case_free(void *e, void *user)
RZ_API void rz_type_base_struct_member_free(void *e, void *user)
RZ_API RZ_OWN RzBaseType * rz_type_base_type_new(RzBaseTypeKind kind)
Allocates a new instance of RzBaseType given the kind.
RZ_API void rz_type_db_save_base_type(const RzTypeDB *typedb, const RzBaseType *type)
Saves RzBaseType into the Types DB.
RZ_API RZ_BORROW const char * rz_type_base_type_kind_as_string(RzBaseTypeKind kind)
Returns string representing the kind of base type.
RZ_API void rz_type_base_union_member_free(void *e, void *user)
RZ_API RZ_BORROW RzBaseType * rz_type_db_get_base_type(const RzTypeDB *typedb, RZ_NONNULL const char *name)
Searches for the RzBaseType in the types database given the name.
RZ_API bool rz_type_db_delete_base_type(RzTypeDB *typedb, RZ_NONNULL RzBaseType *type)
Removes RzBaseType from the Types DB.
RZ_API RZ_OWN RzType * rz_type_parse_string_single(RzTypeParser *parser, const char *code, char **error_msg)
Parses the single C type definition.
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW void * rz_list_first(RZ_NONNULL const RzList *list)
Returns the first element of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
void * malloc(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")
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
#define RZ_LOG_INFO(fmtstr,...)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
#define rz_rbtree_foreach(root, it, data, struc, rb)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
@ RZ_BASE_TYPE_KIND_TYPEDEF
@ RZ_BASE_TYPE_KIND_UNION
@ RZ_BASE_TYPE_KIND_STRUCT
@ RZ_TYPE_IDENTIFIER_KIND_STRUCT
@ RZ_TYPE_IDENTIFIER_KIND_UNION
@ RZ_TYPE_TYPECLASS_INVALID
@ RZ_TYPE_KIND_IDENTIFIER
RZ_API void * rz_vector_push(RzVector *vec, void *x)
RZ_API RzPVector * rz_pvector_new(RzPVectorFree free)
void(* RzPVectorFree)(void *e)
static void ** rz_pvector_push(RzPVector *vec, void *x)
RZ_API void rz_vector_clear(RzVector *vec)
RzPdbTpiCallingConvention call_conv
RzPdbTpiCallingConvention call_conv
RzBaseTypeStruct struct_data
RzBaseTypeUnion union_data
RzPVector * args
optional for the time being
RZ_NULLABLE const char * cc
struct rz_type_t::@292::@295 pointer
struct rz_type_t::@292::@294 identifier
struct rz_type_t::@292::@296 array
RZ_API ut64 rz_bin_pdb_get_type_val(RZ_NONNULL RzPdbTpiType *type)
Get the numeric value inside the type.
RZ_API RZ_BORROW RzList * rz_bin_pdb_get_type_members(RZ_NONNULL RzPdbTpiStream *stream, RzPdbTpiType *t)
Get the RzPdbTpiType member list.
RZ_API RZ_BORROW RzPdbTpiType * rz_bin_pdb_get_type_by_index(RZ_NONNULL RzPdbTpiStream *stream, ut32 index)
Get RzPdbTpiType that matches tpi stream index.
RZ_API RZ_OWN char * rz_bin_pdb_calling_convention_as_string(RZ_NONNULL RzPdbTpiCallingConvention idx)
Parses calling convention type as string.
RZ_API RZ_BORROW char * rz_bin_pdb_get_type_name(RZ_NONNULL RzPdbTpiType *type)
Get the name of the type.
RZ_API bool rz_bin_pdb_type_is_fwdref(RZ_NONNULL RzPdbTpiType *t)
Return true if type is forward definition.
RZ_API bool rz_type_func_save(RzTypeDB *typedb, RZ_NONNULL RzCallable *callable)
Stores RzCallable type in the types database.
RZ_API void rz_type_callable_arg_free(RzCallableArg *arg)
Frees the RzCallableArg.
RZ_API ut64 rz_type_db_get_bitsize(const RzTypeDB *typedb, RZ_NONNULL RzType *type)
Returns the type size in bits (target dependent)
RZ_API void rz_type_free(RZ_NULLABLE RzType *type)
Frees the RzType.
RZ_API RZ_OWN RzType * rz_type_clone(RZ_BORROW RZ_NONNULL const RzType *type)
Creates an exact clone of the RzType.
static RzTypeUnionMember * parse_union_member(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info)
Parses union member.
static bool is_parsable_type(const TpiLeafType type)
static RzType * create_rztype(RzPdbTpiType *type, RzTypeIdentifierKind kind, const char *name)
static RzType * parse_type_member(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info, char *name)
static RzType * parse_structure(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
Parses structures into BaseType and saves them into hashtable.
static RzType * parse_type_mfunction(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info, char *name)
static RzType * parse_regular_type(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type, char *name)
static RzBaseType * get_tpitype_basetype(const RzTypeDB *typedb, RzPdbTpiType *type, const char *name)
static RzType * parse_type_nest(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info)
static RzType * parse_type_static_member(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info, char *name)
static RzType * parse_type_procedure(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type, char *name)
static RzType * parse_type_onemethod(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info)
static RzTypeEnumCase * parse_enumerate(RzPdbTpiType *type)
Parse enum case.
static char * create_type_name_from_offset(ut64 offset)
Create a type name from offset.
static RzTypeStructMember * parse_struct_member(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type_info)
Parses struct member.
static RzType * parse_type_modifier(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
static RzType * parse_type_pointer(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type, char *name)
static RzType * parse_union(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
Parses union into BaseType and saves it into hashtable.
RZ_API void rz_parse_pdb_types(const RzTypeDB *typedb, const RzPdb *pdb)
Saves PDB types from TPI stream into the type database.
static void parse_types(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
Delegate the type parsing to appropriate function.
static RzType * parse_enum(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
Parses enum into BaseType and saves it into SDB.
static bool is_tpitype_unnamed(const char *name)
static RzType * parse_type(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type, char *name)
static RzType * parse_type_array(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *type)
static void parse_type_arglist(const RzTypeDB *typedb, RzPdbTpiStream *stream, RzPdbTpiType *arglist, RzPVector *vec)
struct TpiCVModifier::@210 bits
void error(const char *msg)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()