Rizin
unix-like reverse engineering framework and cli tools
rtti.c File Reference
#include "rz_analysis.h"

Go to the source code of this file.

Functions

RZ_API char * rz_analysis_rtti_demangle_class_name (RzAnalysis *analysis, const char *name)
 
RZ_API void rz_analysis_rtti_print_at_vtable (RzAnalysis *analysis, ut64 addr, RzOutputMode mode)
 
RZ_API void rz_analysis_rtti_print_all (RzAnalysis *analysis, RzOutputMode mode)
 
RZ_API void rz_analysis_rtti_recover_all (RzAnalysis *analysis)
 

Function Documentation

◆ rz_analysis_rtti_demangle_class_name()

RZ_API char* rz_analysis_rtti_demangle_class_name ( RzAnalysis analysis,
const char *  name 
)

Definition at line 8 of file rtti.c.

8  {
9  RVTableContext context;
11  if (context.abi == RZ_ANALYSIS_CPP_ABI_MSVC) {
13  }
15 }
RZ_API char * rz_analysis_rtti_itanium_demangle_class_name(RVTableContext *context, const char *name)
Definition: rtti_itanium.c:743
RZ_API char * rz_analysis_rtti_msvc_demangle_class_name(RVTableContext *context, const char *name)
Definition: rtti_msvc.c:393
@ RZ_ANALYSIS_CPP_ABI_MSVC
Definition: rz_analysis.h:543
Definition: z80asm.h:102
RZ_API bool rz_analysis_vtable_begin(RzAnalysis *analysis, RVTableContext *context)
Definition: vtable.c:41

References RZ_ANALYSIS_CPP_ABI_MSVC, rz_analysis_rtti_itanium_demangle_class_name(), rz_analysis_rtti_msvc_demangle_class_name(), and rz_analysis_vtable_begin().

Referenced by rz_analysis_rtti_demangle_class_name_handler().

◆ rz_analysis_rtti_print_all()

RZ_API void rz_analysis_rtti_print_all ( RzAnalysis analysis,
RzOutputMode  mode 
)

Definition at line 36 of file rtti.c.

36  {
37  RVTableContext context;
39 
40  bool use_json = mode == RZ_OUTPUT_MODE_JSON;
41  if (use_json) {
42  rz_cons_print("[");
43  }
44 
47  RzListIter *vtableIter;
48  RVTableInfo *table;
49 
50  if (vtables) {
51  bool comma = false;
52  bool success = false;
53  rz_list_foreach (vtables, vtableIter, table) {
54  if (rz_cons_is_breaked()) {
55  break;
56  }
57  if (use_json && success) {
58  rz_cons_print(",");
59  comma = true;
60  }
61  if (context.abi == RZ_ANALYSIS_CPP_ABI_MSVC) {
62  success = rz_analysis_rtti_msvc_print_at_vtable(&context, table->saddr, mode, true);
63  } else {
64  success = rz_analysis_rtti_itanium_print_at_vtable(&context, table->saddr, mode);
65  }
66  if (success) {
67  comma = false;
68  if (!use_json) {
69  rz_cons_print("\n");
70  }
71  }
72  }
73  if (use_json && !success && comma) {
74  // drop last comma if necessary
75  rz_cons_drop(1);
76  }
77  }
78  rz_list_free(vtables);
79 
80  if (use_json) {
81  rz_cons_print("]\n");
82  }
83 
85 }
RZ_API bool rz_cons_drop(int n)
Definition: cons.c:1891
RZ_API void rz_cons_break_pop(void)
Definition: cons.c:361
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
Definition: cons.c:357
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
#define NULL
Definition: cris-opc.c:27
const char int mode
Definition: ioapi.h:137
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
RZ_API bool rz_analysis_rtti_itanium_print_at_vtable(RVTableContext *context, ut64 addr, RzOutputMode mode)
Definition: rtti_itanium.c:700
RZ_API bool rz_analysis_rtti_msvc_print_at_vtable(RVTableContext *context, ut64 addr, RzOutputMode mode, bool strict)
Definition: rtti_msvc.c:617
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
RZ_API RzList * rz_analysis_vtable_search(RVTableContext *context)
Definition: vtable.c:219
static int comma
Definition: z80asm.c:76

References comma, NULL, RZ_ANALYSIS_CPP_ABI_MSVC, rz_analysis_rtti_itanium_print_at_vtable(), rz_analysis_rtti_msvc_print_at_vtable(), rz_analysis_vtable_begin(), rz_analysis_vtable_search(), rz_cons_break_pop(), rz_cons_break_push(), rz_cons_drop(), rz_cons_is_breaked(), rz_list_free(), and RZ_OUTPUT_MODE_JSON.

Referenced by rz_analysis_print_rtti_all_handler().

◆ rz_analysis_rtti_print_at_vtable()

RZ_API void rz_analysis_rtti_print_at_vtable ( RzAnalysis analysis,
ut64  addr,
RzOutputMode  mode 
)

Definition at line 17 of file rtti.c.

17  {
18  bool use_json = mode == RZ_OUTPUT_MODE_JSON;
19  if (use_json) {
20  rz_cons_print("[");
21  }
22 
23  RVTableContext context;
25  if (context.abi == RZ_ANALYSIS_CPP_ABI_MSVC) {
27  } else {
29  }
30 
31  if (use_json) {
32  rz_cons_print("]\n");
33  }
34 }
static int addr
Definition: z80asm.c:58

References addr, RZ_ANALYSIS_CPP_ABI_MSVC, rz_analysis_rtti_itanium_print_at_vtable(), rz_analysis_rtti_msvc_print_at_vtable(), rz_analysis_vtable_begin(), and RZ_OUTPUT_MODE_JSON.

Referenced by rz_analysis_print_rtti_handler().

◆ rz_analysis_rtti_recover_all()

RZ_API void rz_analysis_rtti_recover_all ( RzAnalysis analysis)

Definition at line 87 of file rtti.c.

87  {
88  RVTableContext context;
90 
93  if (vtables) {
94  if (context.abi == RZ_ANALYSIS_CPP_ABI_MSVC) {
96  } else {
98  }
99  }
100  rz_list_free(vtables);
102 }
RZ_API void rz_analysis_rtti_itanium_recover_all(RVTableContext *context, RzList *vtables)
Definition: rtti_itanium.c:860
RZ_API void rz_analysis_rtti_msvc_recover_all(RVTableContext *vt_context, RzList *vtables)
Definition: rtti_msvc.c:966

References NULL, RZ_ANALYSIS_CPP_ABI_MSVC, rz_analysis_rtti_itanium_recover_all(), rz_analysis_rtti_msvc_recover_all(), rz_analysis_vtable_begin(), rz_analysis_vtable_search(), rz_cons_break_pop(), rz_cons_break_push(), and rz_list_free().

Referenced by rz_analysis_class_recover_all(), and rz_analysis_recover_rtti_all_handler().