1 /* radare - LGPL - Copyright 2018 - pancake */ 2 3 #ifndef R_EVENT_H 4 #define R_EVENT_H 5 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 10 #include <ht_up.h> 11 #include <r_vector.h> 12 13 typedef struct r_event_t { 14 void *user; 15 bool incall; 16 HtUP *callbacks; 17 RVector all_callbacks; 18 int next_handle; 19 } REvent; 20 21 typedef struct r_event_callback_handle_t { 22 int handle; 23 int type; 24 } REventCallbackHandle; 25 26 typedef void (*REventCallback)(REvent *ev, int type, void *user, void *data); 27 28 typedef enum { 29 R_EVENT_ALL = 0, 30 R_EVENT_META_SET, // REventMeta 31 R_EVENT_META_DEL, // REventMeta 32 R_EVENT_META_CLEAR, // REventMeta 33 R_EVENT_CLASS_NEW, // REventClass 34 R_EVENT_CLASS_DEL, // REventClass 35 R_EVENT_CLASS_RENAME, // REventClassRename 36 R_EVENT_CLASS_ATTR_SET, // REventClassAttr 37 R_EVENT_CLASS_ATTR_DEL, // REventClassAttrSet 38 R_EVENT_CLASS_ATTR_RENAME, // REventClassAttrRename 39 R_EVENT_DEBUG_PROCESS_FINISHED, // REventDebugProcessFinished 40 R_EVENT_IO_WRITE, // REventIOWrite 41 R_EVENT_MAX, 42 } REventType; 43 44 typedef struct r_event_meta_t { 45 int type; 46 ut64 addr; 47 const char *string; 48 } REventMeta; 49 50 typedef struct r_event_class_t { 51 const char *name; 52 } REventClass; 53 54 typedef struct r_event_class_rename_t { 55 const char *name_old; 56 const char *name_new; 57 } REventClassRename; 58 59 typedef struct r_event_class_attr_t { 60 const char *class_name; 61 int attr_type; // RAnalClassAttrType 62 const char *attr_id; 63 } REventClassAttr; 64 65 typedef struct r_event_class_attr_set_t { 66 REventClassAttr attr; 67 const char *content; 68 } REventClassAttrSet; 69 70 typedef struct r_event_class_attr_rename_t { 71 REventClassAttr attr; 72 const char *attr_id_new; 73 } REventClassAttrRename; 74 75 typedef struct r_event_debug_process_finished_t { 76 int pid; 77 } REventDebugProcessFinished; 78 79 typedef struct r_event_io_write_t { 80 ut64 addr; 81 const ut8 *buf; 82 int len; 83 } REventIOWrite; 84 85 R_API REvent *r_event_new(void *user); 86 R_API void r_event_free(REvent *ev); 87 R_API REventCallbackHandle r_event_hook(REvent *ev, int type, REventCallback cb, void *user); 88 R_API void r_event_unhook(REvent *ev, REventCallbackHandle handle); 89 R_API void r_event_send(REvent *ev, int type, void *data); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 95 #endif 96