Intentation consistency and misc formatting fixes

This commit is contained in:
gergely.erdelyi 2009-05-23 16:35:50 +00:00
parent f2e422d208
commit 7d468f3b94
13 changed files with 620 additions and 634 deletions

View File

@ -11,223 +11,222 @@ typedef struct
%feature("director") DBG_Hooks;
%inline %{
int idaapi DBG_Callback(void *ud, int notification_code, va_list va);
class DBG_Hooks
{
public:
virtual ~DBG_Hooks() {};
virtual ~DBG_Hooks() {};
bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); };
bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); };
/* Hook functions to be overridden in Python */
virtual void dbg_process_start(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_process_exit(pid_t pid,
thid_t tid,
ea_t ea,
int exit_code) { };
virtual void dbg_process_attach(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_process_detach(pid_t pid,
thid_t tid,
ea_t ea) { };
virtual void dbg_thread_start(pid_t pid,
thid_t tid,
ea_t ea) { };
virtual void dbg_thread_exit(pid_t pid,
thid_t tid,
ea_t ea,
int exit_code) { };
virtual void dbg_library_load(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_library_unload(pid_t pid,
thid_t tid,
ea_t ea,
char *libname) { };
virtual void dbg_information(pid_t pid,
thid_t tid,
ea_t ea,
char *info) { };
virtual int dbg_exception(pid_t pid,
thid_t tid,
ea_t ea,
int code,
bool can_cont,
ea_t exc_ea,
char *info) { return 0; };
virtual void dbg_suspend_process(void) { };
virtual int dbg_bpt(thid_t tid, ea_t breakpoint_ea) { return 0; };
virtual int dbg_trace(thid_t tid, ea_t ip) { return 0; };
virtual void dbg_request_error(ui_notification_t failed_command,
dbg_notification_t failed_dbg_notification) { };
virtual void dbg_step_into(void) { };
virtual void dbg_step_over(void) { };
virtual void dbg_run_to(thid_t tid) { };
virtual void dbg_step_until_ret(void) { };
bool hook() { return hook_to_notification_point(HT_DBG, DBG_Callback, this); };
bool unhook() { return unhook_from_notification_point(HT_DBG, DBG_Callback, this); };
/* Hook functions to be overridden in Python */
virtual void dbg_process_start(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_process_exit(pid_t pid,
thid_t tid,
ea_t ea,
int exit_code) { };
virtual void dbg_process_attach(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_process_detach(pid_t pid,
thid_t tid,
ea_t ea) { };
virtual void dbg_thread_start(pid_t pid,
thid_t tid,
ea_t ea) { };
virtual void dbg_thread_exit(pid_t pid,
thid_t tid,
ea_t ea,
int exit_code) { };
virtual void dbg_library_load(pid_t pid,
thid_t tid,
ea_t ea,
char *name,
ea_t base,
asize_t size) { };
virtual void dbg_library_unload(pid_t pid,
thid_t tid,
ea_t ea,
char *libname) { };
virtual void dbg_information(pid_t pid,
thid_t tid,
ea_t ea,
char *info) { };
virtual int dbg_exception(pid_t pid,
thid_t tid,
ea_t ea,
int code,
bool can_cont,
ea_t exc_ea,
char *info) { return 0; };
virtual void dbg_suspend_process(void) { };
virtual int dbg_bpt(thid_t tid, ea_t breakpoint_ea) { return 0; };
virtual int dbg_trace(thid_t tid, ea_t ip) { return 0; };
virtual void dbg_request_error(ui_notification_t failed_command,
dbg_notification_t failed_dbg_notification) { };
virtual void dbg_step_into(void) { };
virtual void dbg_step_over(void) { };
virtual void dbg_run_to(thid_t tid) { };
virtual void dbg_step_until_ret(void) { };
};
int idaapi DBG_Callback(void *ud, int notification_code, va_list va)
{
class DBG_Hooks *proxy = (class DBG_Hooks *)ud;
class DBG_Hooks *proxy = (class DBG_Hooks *)ud;
debug_event_t *event;
thid_t tid;
int *warn;
ea_t ip;
ui_notification_t failed_command;
dbg_notification_t failed_dbg_notification;
ea_t breakpoint_ea;
debug_event_t *event;
thid_t tid;
int *warn;
ea_t ip;
ui_notification_t failed_command;
dbg_notification_t failed_dbg_notification;
ea_t breakpoint_ea;
try {
switch (notification_code)
{
case dbg_process_start:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_start(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_process_exit:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_exit(event->pid,
event->tid,
event->ea,
event->exit_code);
return 0;
try {
switch (notification_code)
{
case dbg_process_start:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_start(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_process_exit:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_exit(event->pid,
event->tid,
event->ea,
event->exit_code);
return 0;
case dbg_process_attach:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_attach(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_process_attach:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_attach(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_process_detach:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_detach(event->pid,
event->tid,
event->ea);
return 0;
case dbg_process_detach:
event = va_arg(va, debug_event_t *);
proxy->dbg_process_detach(event->pid,
event->tid,
event->ea);
return 0;
case dbg_thread_start:
event = va_arg(va, debug_event_t *);
proxy->dbg_thread_start(event->pid,
event->tid,
event->ea);
return 0;
case dbg_thread_start:
event = va_arg(va, debug_event_t *);
proxy->dbg_thread_start(event->pid,
event->tid,
event->ea);
return 0;
case dbg_thread_exit:
event = va_arg(va, debug_event_t *);
proxy->dbg_thread_exit(event->pid,
event->tid,
event->ea,
event->exit_code);
return 0;
case dbg_thread_exit:
event = va_arg(va, debug_event_t *);
proxy->dbg_thread_exit(event->pid,
event->tid,
event->ea,
event->exit_code);
return 0;
case dbg_library_load:
event = va_arg(va, debug_event_t *);
proxy->dbg_library_load(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_library_load:
event = va_arg(va, debug_event_t *);
proxy->dbg_library_load(event->pid,
event->tid,
event->ea,
event->modinfo.name,
event->modinfo.base,
event->modinfo.size);
return 0;
case dbg_library_unload:
event = va_arg(va, debug_event_t *);
proxy->dbg_library_unload(event->pid,
event->tid,
event->ea,
event->info);
return 0;
case dbg_library_unload:
event = va_arg(va, debug_event_t *);
proxy->dbg_library_unload(event->pid,
event->tid,
event->ea,
event->info);
return 0;
case dbg_information:
event = va_arg(va, debug_event_t *);
proxy->dbg_information(event->pid,
event->tid,
event->ea,
event->info);
return 0;
case dbg_information:
event = va_arg(va, debug_event_t *);
proxy->dbg_information(event->pid,
event->tid,
event->ea,
event->info);
return 0;
case dbg_exception:
event = va_arg(va, debug_event_t *);
warn = va_arg(va, int *);
*warn = proxy->dbg_exception(event->pid,
event->tid,
event->ea,
event->exc.code,
event->exc.can_cont,
event->exc.ea,
event->exc.info);
return 0;
case dbg_exception:
event = va_arg(va, debug_event_t *);
warn = va_arg(va, int *);
*warn = proxy->dbg_exception(event->pid,
event->tid,
event->ea,
event->exc.code,
event->exc.can_cont,
event->exc.ea,
event->exc.info);
return 0;
case dbg_suspend_process:
proxy->dbg_suspend_process();
return 0;
case dbg_suspend_process:
proxy->dbg_suspend_process();
return 0;
case dbg_bpt:
tid = va_arg(va, thid_t);
breakpoint_ea = va_arg(va, ea_t);
warn = va_arg(va, int *);
*warn = proxy->dbg_bpt(tid, breakpoint_ea);
return 0;
case dbg_bpt:
tid = va_arg(va, thid_t);
breakpoint_ea = va_arg(va, ea_t);
warn = va_arg(va, int *);
*warn = proxy->dbg_bpt(tid, breakpoint_ea);
return 0;
case dbg_trace:
tid = va_arg(va, thid_t);
ip = va_arg(va, ea_t);
return proxy->dbg_bpt(tid, ip);
case dbg_trace:
tid = va_arg(va, thid_t);
ip = va_arg(va, ea_t);
return proxy->dbg_bpt(tid, ip);
case dbg_request_error:
failed_command = (ui_notification_t)va_arg(va, int);
failed_dbg_notification = (dbg_notification_t)va_arg(va, int);
proxy->dbg_request_error(failed_command, failed_dbg_notification);
return 0;
case dbg_request_error:
failed_command = (ui_notification_t)va_arg(va, int);
failed_dbg_notification = (dbg_notification_t)va_arg(va, int);
proxy->dbg_request_error(failed_command, failed_dbg_notification);
return 0;
case dbg_step_into:
proxy->dbg_step_into();
return 0;
case dbg_step_into:
proxy->dbg_step_into();
return 0;
case dbg_step_over:
proxy->dbg_step_over();
return 0;
case dbg_step_over:
proxy->dbg_step_over();
return 0;
case dbg_run_to:
tid = va_arg(va, thid_t);
proxy->dbg_run_to(tid);
return 0;
case dbg_run_to:
tid = va_arg(va, thid_t);
proxy->dbg_run_to(tid);
return 0;
case dbg_step_until_ret:
proxy->dbg_step_until_ret();
return 0;
}
}
catch (Swig::DirectorException &e)
case dbg_step_until_ret:
proxy->dbg_step_until_ret();
return 0;
}
}
catch (Swig::DirectorException &e)
{
msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred())
{
PyErr_Print();
}
msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred())
{
PyErr_Print();
}
}
}
%}

View File

@ -38,7 +38,7 @@
bool CompileEx_wrap(const char *file, bool del_macros,
char *errbuf, size_t errbufsize)
{
return !CompileEx(file, del_macros, errbuf, errbufsize);
return !CompileEx(file, del_macros, errbuf, errbufsize);
}
%}
@ -46,7 +46,7 @@ bool CompileEx_wrap(const char *file, bool del_macros,
%inline %{
bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize)
{
return !Compile(file, errbuf, errbufsize);
return !Compile(file, errbuf, errbufsize);
}
%}
@ -54,7 +54,7 @@ bool Compile_wrap(const char *file, char *errbuf, size_t errbufsize)
%inline %{
bool calcexpr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize)
{
return !calcexpr(where, line, rv, errbuf, errbufsize);
return !calcexpr(where, line, rv, errbuf, errbufsize);
}
%}
@ -62,7 +62,7 @@ bool calcexpr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, s
%inline %{
bool calc_idc_expr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errbuf, size_t errbufsize)
{
return !calc_idc_expr(where, line, rv, errbuf, errbufsize);
return !calc_idc_expr(where, line, rv, errbuf, errbufsize);
}
%}
@ -72,7 +72,7 @@ bool calc_idc_expr_wrap(ea_t where,const char *line, idc_value_t *rv, char *errb
%inline %{
bool CompileLine_wrap(const char *line, char *errbuf, size_t errbufsize)
{
return !CompileLine(line, errbuf, errbufsize);
return !CompileLine(line, errbuf, errbufsize);
}
%}

View File

@ -38,10 +38,10 @@
%inline %{
ea_t get_fchunk_referer(ea_t ea, size_t idx)
{
func_t *pfn = get_fchunk(ea);
func_parent_iterator_t dummy(pfn); // read referer info
if ( idx >= pfn->refqty || pfn->referers == NULL )
return BADADDR;
return pfn->referers[idx];
func_t *pfn = get_fchunk(ea);
func_parent_iterator_t dummy(pfn); // read referer info
if (idx >= pfn->refqty || pfn->referers == NULL)
return BADADDR;
return pfn->referers[idx];
}
%}

View File

@ -124,7 +124,7 @@ typedef long long longlong;
/* Small wrapper to get the inf structure */
idainfo *get_inf_structure(void)
{
return &inf;
return &inf;
}
}
@ -147,7 +147,7 @@ idainfo *get_inf_structure(void)
%include "xref.i"
%inline {
void set_script_timeout(int timeout);
void enable_extlang_python(bool enable);
void enable_python_cli(bool enable);
void set_script_timeout(int timeout);
void enable_extlang_python(bool enable);
void enable_python_cli(bool enable);
}

View File

@ -3,53 +3,51 @@
%include "idd.hpp"
%inline %{
char get_event_module_name(const debug_event_t* ev, char *buf, size_t bufsize)
{
qstrncpy(buf, ev->modinfo.name, bufsize);
return true;
qstrncpy(buf, ev->modinfo.name, bufsize);
return true;
}
ea_t get_event_module_base(const debug_event_t* ev)
{
return ev->modinfo.base;
return ev->modinfo.base;
}
asize_t get_event_module_size(const debug_event_t* ev)
{
return ev->modinfo.size;
return ev->modinfo.size;
}
char get_event_exc_info(const debug_event_t* ev, char *buf, size_t bufsize)
{
qstrncpy(buf, ev->exc.info, bufsize);
return true;
qstrncpy(buf, ev->exc.info, bufsize);
return true;
}
char get_event_info(const debug_event_t* ev, char *buf, size_t bufsize)
{
qstrncpy(buf, ev->info, bufsize);
return true;
qstrncpy(buf, ev->info, bufsize);
return true;
}
ea_t get_event_bpt_hea(const debug_event_t* ev)
{
return ev->bpt.hea;
return ev->bpt.hea;
}
uint get_event_exc_code(const debug_event_t* ev)
{
return ev->exc.code;
return ev->exc.code;
}
ea_t get_event_exc_ea(const debug_event_t* ev)
{
return ev->exc.ea;
return ev->exc.ea;
}
bool can_exc_continue(const debug_event_t* ev)
{
return ev->exc.can_cont;
return ev->exc.can_cont;
}
%}

View File

@ -66,216 +66,215 @@
%feature("director") IDB_Hooks;
%inline %{
int idaapi IDB_Callback(void *ud, int notification_code, va_list va);
class IDB_Hooks
{
public:
virtual ~IDB_Hooks() {};
virtual ~IDB_Hooks() {};
bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); }
bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); }
/* Hook functions to override in Python */
virtual int byte_patched(ea_t ea) { return 0; };
virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; };
virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; };
virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; };
virtual int op_type_changed(ea_t ea, int n) { return 0; };
virtual int enum_created(enum_t id) { return 0; };
virtual int enum_deleted(enum_t id) { return 0; };
virtual int enum_bf_changed(enum_t id) { return 0; };
virtual int enum_renamed(enum_t id) { return 0; };
virtual int enum_cmt_changed(enum_t id) { return 0; };
virtual int enum_const_created(enum_t id, const_t cid) { return 0; };
virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; };
virtual int struc_created(tid_t struc_id) { return 0; };
virtual int struc_deleted(tid_t struc_id) { return 0; };
virtual int struc_renamed(struc_t *sptr) { return 0; };
virtual int struc_expanded(struc_t *sptr) { return 0; };
virtual int struc_cmt_changed(tid_t struc_id) { return 0; };
virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; };
virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int thunk_func_created(func_t *pfn) { return 0; };
virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; };
virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; };
virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; };
virtual int func_noret_changed(func_t *pfn) { return 0; };
virtual int segm_added(segment_t *s) { return 0; };
virtual int segm_deleted(ea_t startEA) { return 0; };
virtual int segm_start_changed(segment_t *s) { return 0; };
virtual int segm_end_changed(segment_t *s) { return 0; };
virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; };
bool hook() { return hook_to_notification_point(HT_IDB, IDB_Callback, this); }
bool unhook() { return unhook_from_notification_point(HT_IDB, IDB_Callback, this); }
/* Hook functions to override in Python */
virtual int byte_patched(ea_t ea) { return 0; };
virtual int cmt_changed(ea_t, bool repeatable_cmt) { return 0; };
virtual int ti_changed(ea_t ea, const type_t *type, const p_list *fnames) { msg("ti_changed hook not supported yet\n"); return 0; };
virtual int op_ti_changed(ea_t ea, int n, const type_t *type, const p_list *fnames) { msg("op_ti_changed hook not supported yet\n"); return 0; };
virtual int op_type_changed(ea_t ea, int n) { return 0; };
virtual int enum_created(enum_t id) { return 0; };
virtual int enum_deleted(enum_t id) { return 0; };
virtual int enum_bf_changed(enum_t id) { return 0; };
virtual int enum_renamed(enum_t id) { return 0; };
virtual int enum_cmt_changed(enum_t id) { return 0; };
virtual int enum_const_created(enum_t id, const_t cid) { return 0; };
virtual int enum_const_deleted(enum_t id, const_t cid) { return 0; };
virtual int struc_created(tid_t struc_id) { return 0; };
virtual int struc_deleted(tid_t struc_id) { return 0; };
virtual int struc_renamed(struc_t *sptr) { return 0; };
virtual int struc_expanded(struc_t *sptr) { return 0; };
virtual int struc_cmt_changed(tid_t struc_id) { return 0; };
virtual int struc_member_created(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_deleted(struc_t *sptr, tid_t member_id) { return 0; };
virtual int struc_member_renamed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int struc_member_changed(struc_t *sptr, member_t *mptr) { return 0; };
virtual int thunk_func_created(func_t *pfn) { return 0; };
virtual int func_tail_appended(func_t *pfn, func_t *tail) { return 0; };
virtual int func_tail_removed(func_t *pfn, ea_t tail_ea) { return 0; };
virtual int tail_owner_changed(func_t *tail, ea_t owner_func) { return 0; };
virtual int func_noret_changed(func_t *pfn) { return 0; };
virtual int segm_added(segment_t *s) { return 0; };
virtual int segm_deleted(ea_t startEA) { return 0; };
virtual int segm_start_changed(segment_t *s) { return 0; };
virtual int segm_end_changed(segment_t *s) { return 0; };
virtual int segm_moved(ea_t from, ea_t to, asize_t size) { return 0; };
};
int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
{
class IDB_Hooks *proxy = (class IDB_Hooks *)ud;
ea_t ea, ea2;
bool repeatable_cmt;
type_t *type;
/* p_list *fnames; */
int n;
enum_t id;
const_t cid;
tid_t struc_id;
struc_t *sptr;
member_t *mptr;
tid_t member_id;
func_t *pfn;
func_t *tail;
segment_t *seg;
asize_t size;
class IDB_Hooks *proxy = (class IDB_Hooks *)ud;
ea_t ea, ea2;
bool repeatable_cmt;
type_t *type;
/* p_list *fnames; */
int n;
enum_t id;
const_t cid;
tid_t struc_id;
struc_t *sptr;
member_t *mptr;
tid_t member_id;
func_t *pfn;
func_t *tail;
segment_t *seg;
asize_t size;
try {
switch (notification_code)
{
case idb_event::byte_patched:
ea = va_arg(va, ea_t);
return proxy->byte_patched(ea);
try {
switch (notification_code)
{
case idb_event::byte_patched:
ea = va_arg(va, ea_t);
return proxy->byte_patched(ea);
case idb_event::cmt_changed:
ea = va_arg(va, ea_t);
repeatable_cmt = va_arg(va, int);
return proxy->cmt_changed(ea, repeatable_cmt);
case idb_event::cmt_changed:
ea = va_arg(va, ea_t);
repeatable_cmt = va_arg(va, int);
return proxy->cmt_changed(ea, repeatable_cmt);
#if 0
case idb_event::ti_changed:
ea = va_arg(va, ea_t);
type = va_arg(va, type_t *);
fnames = va_arg(va, fnames);
return proxy->ti_changed(ea, type, fnames);
case idb_event::ti_changed:
ea = va_arg(va, ea_t);
type = va_arg(va, type_t *);
fnames = va_arg(va, fnames);
return proxy->ti_changed(ea, type, fnames);
case idb_event::op_ti_changed:
ea = va_arg(va, ea_t);
n = va_arg(va, int);
type = va_arg(va, type_t *);
fnames = va_arg(va, fnames);
return proxy->op_ti_changed(ea, n, type, fnames);
case idb_event::op_ti_changed:
ea = va_arg(va, ea_t);
n = va_arg(va, int);
type = va_arg(va, type_t *);
fnames = va_arg(va, fnames);
return proxy->op_ti_changed(ea, n, type, fnames);
#endif
case idb_event::op_type_changed:
ea = va_arg(va, ea_t);
n = va_arg(va, int);
return proxy->op_type_changed(ea, n);
case idb_event::op_type_changed:
ea = va_arg(va, ea_t);
n = va_arg(va, int);
return proxy->op_type_changed(ea, n);
case idb_event::enum_created:
id = va_arg(va, enum_t);
return proxy->enum_created(id);
case idb_event::enum_created:
id = va_arg(va, enum_t);
return proxy->enum_created(id);
case idb_event::enum_deleted:
id = va_arg(va, enum_t);
return proxy->enum_deleted(id);
case idb_event::enum_deleted:
id = va_arg(va, enum_t);
return proxy->enum_deleted(id);
case idb_event::enum_bf_changed:
id = va_arg(va, enum_t);
return proxy->enum_bf_changed(id);
case idb_event::enum_bf_changed:
id = va_arg(va, enum_t);
return proxy->enum_bf_changed(id);
case idb_event::enum_cmt_changed:
id = va_arg(va, enum_t);
return proxy->enum_cmt_changed(id);
case idb_event::enum_cmt_changed:
id = va_arg(va, enum_t);
return proxy->enum_cmt_changed(id);
case idb_event::enum_const_created:
id = va_arg(va, enum_t);
cid = va_arg(va, const_t);
return proxy->enum_const_created(id, cid);
case idb_event::enum_const_created:
id = va_arg(va, enum_t);
cid = va_arg(va, const_t);
return proxy->enum_const_created(id, cid);
case idb_event::enum_const_deleted:
id = va_arg(va, enum_t);
cid = va_arg(va, const_t);
return proxy->enum_const_deleted(id, cid);
case idb_event::enum_const_deleted:
id = va_arg(va, enum_t);
cid = va_arg(va, const_t);
return proxy->enum_const_deleted(id, cid);
case idb_event::struc_created:
struc_id = va_arg(va, tid_t);
return proxy->struc_created(struc_id);
case idb_event::struc_created:
struc_id = va_arg(va, tid_t);
return proxy->struc_created(struc_id);
case idb_event::struc_deleted:
struc_id = va_arg(va, tid_t);
return proxy->struc_deleted(struc_id);
case idb_event::struc_deleted:
struc_id = va_arg(va, tid_t);
return proxy->struc_deleted(struc_id);
case idb_event::struc_renamed:
sptr = va_arg(va, struc_t *);
return proxy->struc_renamed(sptr);
case idb_event::struc_renamed:
sptr = va_arg(va, struc_t *);
return proxy->struc_renamed(sptr);
case idb_event::struc_expanded:
sptr = va_arg(va, struc_t *);
return proxy->struc_expanded(sptr);
case idb_event::struc_expanded:
sptr = va_arg(va, struc_t *);
return proxy->struc_expanded(sptr);
case idb_event::struc_cmt_changed:
struc_id = va_arg(va, tid_t);
return proxy->struc_cmt_changed(struc_id);
case idb_event::struc_cmt_changed:
struc_id = va_arg(va, tid_t);
return proxy->struc_cmt_changed(struc_id);
case idb_event::struc_member_created:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_created(sptr, mptr);
case idb_event::struc_member_created:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_created(sptr, mptr);
case idb_event::struc_member_deleted:
sptr = va_arg(va, struc_t *);
member_id = va_arg(va, tid_t);
return proxy->struc_member_deleted(sptr, member_id);
case idb_event::struc_member_deleted:
sptr = va_arg(va, struc_t *);
member_id = va_arg(va, tid_t);
return proxy->struc_member_deleted(sptr, member_id);
case idb_event::struc_member_renamed:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_renamed(sptr, mptr);
case idb_event::struc_member_renamed:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_renamed(sptr, mptr);
case idb_event::struc_member_changed:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_changed(sptr, mptr);
case idb_event::struc_member_changed:
sptr = va_arg(va, struc_t *);
mptr = va_arg(va, member_t *);
return proxy->struc_member_changed(sptr, mptr);
case idb_event::thunk_func_created:
pfn = va_arg(va, func_t *);
return proxy->thunk_func_created(pfn);
case idb_event::thunk_func_created:
pfn = va_arg(va, func_t *);
return proxy->thunk_func_created(pfn);
case idb_event::func_tail_appended:
pfn = va_arg(va, func_t *);
tail = va_arg(va, func_t *);
return proxy->func_tail_appended(pfn, tail);
case idb_event::func_tail_appended:
pfn = va_arg(va, func_t *);
tail = va_arg(va, func_t *);
return proxy->func_tail_appended(pfn, tail);
case idb_event::func_tail_removed:
pfn = va_arg(va, func_t *);
ea = va_arg(va, ea_t);
return proxy->func_tail_removed(pfn, ea);
case idb_event::func_tail_removed:
pfn = va_arg(va, func_t *);
ea = va_arg(va, ea_t);
return proxy->func_tail_removed(pfn, ea);
case idb_event::tail_owner_changed:
tail = va_arg(va, func_t *);
ea = va_arg(va, ea_t);
return proxy->tail_owner_changed(tail, ea);
case idb_event::tail_owner_changed:
tail = va_arg(va, func_t *);
ea = va_arg(va, ea_t);
return proxy->tail_owner_changed(tail, ea);
case idb_event::func_noret_changed:
pfn = va_arg(va, func_t *);
return proxy->func_noret_changed(pfn);
case idb_event::func_noret_changed:
pfn = va_arg(va, func_t *);
return proxy->func_noret_changed(pfn);
case idb_event::segm_added:
seg = va_arg(va, segment_t *);
return proxy->segm_added(seg);
case idb_event::segm_added:
seg = va_arg(va, segment_t *);
return proxy->segm_added(seg);
case idb_event::segm_deleted:
ea = va_arg(va, ea_t);
return proxy->segm_deleted(ea);
case idb_event::segm_deleted:
ea = va_arg(va, ea_t);
return proxy->segm_deleted(ea);
case idb_event::segm_start_changed:
seg = va_arg(va, segment_t *);
return proxy->segm_start_changed(seg);
case idb_event::segm_start_changed:
seg = va_arg(va, segment_t *);
return proxy->segm_start_changed(seg);
case idb_event::segm_end_changed:
seg = va_arg(va, segment_t *);
return proxy->segm_end_changed(seg);
case idb_event::segm_end_changed:
seg = va_arg(va, segment_t *);
return proxy->segm_end_changed(seg);
case idb_event::segm_moved:
ea = va_arg(va, ea_t);
ea2 = va_arg(va, ea_t);
size = va_arg(va, asize_t);
return proxy->segm_moved(ea, ea2, size);
}
}
catch (Swig::DirectorException &e)
case idb_event::segm_moved:
ea = va_arg(va, ea_t);
ea2 = va_arg(va, ea_t);
size = va_arg(va, asize_t);
return proxy->segm_moved(ea, ea2, size);
}
}
catch (Swig::DirectorException &e)
{
msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred())
msg("Exception in IDP Hook function:\n");
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Print();
}
}
}
@ -290,18 +289,18 @@ int idaapi IDB_Callback(void *ud, int notification_code, va_list va)
// returns: 1: success, 0: failure
inline const int assemble(ea_t ea, ea_t cs, ea_t ip, bool use32, const char *line)
{
int inslen;
char buf[256]; // FIXME: Shouldn't be longer than this... is there a MAX_INSTR_LENGTH anywhere?
int inslen;
char buf[256]; // FIXME: Shouldn't be longer than this... is there a MAX_INSTR_LENGTH anywhere?
if (ph.notify != NULL)
if (ph.notify != NULL)
{
inslen = ph.notify(ph.assemble, ea, cs, ip, use32, line, buf);
if (inslen > 0)
inslen = ph.notify(ph.assemble, ea, cs, ip, use32, line, buf);
if (inslen > 0)
{
patch_many_bytes(ea, buf, inslen);
return 1;
patch_many_bytes(ea, buf, inslen);
return 1;
}
}
return 0;
return 0;
}
%}

View File

@ -41,28 +41,28 @@ void refresh_lists(void)
%pythoncode %{
def asklong(defval, format):
res, val = _idaapi._asklong(defval, format)
res, val = _idaapi._asklong(defval, format)
if res == 1:
return val
else:
return None
if res == 1:
return val
else:
return None
def askaddr(defval, format):
res, ea = _idaapi._askaddr(defval, format)
res, ea = _idaapi._askaddr(defval, format)
if res == 1:
return ea
else:
return None
if res == 1:
return ea
else:
return None
def askseg(defval, format):
res, sel = _idaapi._askseg(defval, format)
res, sel = _idaapi._askseg(defval, format)
if res == 1:
return sel
else:
return None
if res == 1:
return sel
else:
return None
%}
@ -75,60 +75,60 @@ def askseg(defval, format):
%{
bool idaapi py_menu_item_callback(void *userdata)
{
PyObject *func, *args, *result;
bool ret = 0;
PyObject *func, *args, *result;
bool ret = 0;
// userdata is a tuple of ( func, args )
// func and args are borrowed references from userdata
func = PyTuple_GET_ITEM(userdata, 0);
args = PyTuple_GET_ITEM(userdata, 1);
// userdata is a tuple of ( func, args )
// func and args are borrowed references from userdata
func = PyTuple_GET_ITEM(userdata, 0);
args = PyTuple_GET_ITEM(userdata, 1);
// call the python function
result = PyEval_CallObject(func, args);
// call the python function
result = PyEval_CallObject(func, args);
// we cannot raise an exception in the callback, just print it.
if (!result) {
PyErr_Print();
return 0;
}
// we cannot raise an exception in the callback, just print it.
if (!result) {
PyErr_Print();
return 0;
}
// if the function returned a non-false value, then return 1 to ida,
// overwise return 0
if (PyObject_IsTrue(result)) {
ret = 1;
}
Py_DECREF(result);
// if the function returned a non-false value, then return 1 to ida,
// overwise return 0
if (PyObject_IsTrue(result)) {
ret = 1;
}
Py_DECREF(result);
return ret;
return ret;
}
%}
%rename (add_menu_item) wrap_add_menu_item;
%inline %{
bool wrap_add_menu_item (
const char *menupath,
const char *name,
const char *hotkey,
int flags,
PyObject *pyfunc,
PyObject *args) {
// FIXME: probably should keep track of this data, and destroy it when the menu item is removed
PyObject *cb_data;
const char *menupath,
const char *name,
const char *hotkey,
int flags,
PyObject *pyfunc,
PyObject *args) {
// FIXME: probably should keep track of this data, and destroy it when the menu item is removed
PyObject *cb_data;
if (args == Py_None) {
Py_DECREF(Py_None);
args = PyTuple_New( 0 );
if (!args)
return 0;
}
if (args == Py_None) {
Py_DECREF(Py_None);
args = PyTuple_New( 0 );
if (!args)
return 0;
}
if(!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError, "args must be a tuple or None");
return 0;
}
if(!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError, "args must be a tuple or None");
return 0;
}
cb_data = Py_BuildValue("(OO)", pyfunc, args);
return add_menu_item(menupath, name, hotkey, flags, py_menu_item_callback, (void *)cb_data);
cb_data = Py_BuildValue("(OO)", pyfunc, args);
return add_menu_item(menupath, name, hotkey, flags, py_menu_item_callback, (void *)cb_data);
}
%}
@ -143,51 +143,51 @@ uint32 choose_choose(PyObject *self,
%{
uint32 idaapi choose_sizer(void *self)
{
PyObject *pyres;
uint32 res;
PyObject *pyres;
uint32 res;
pyres = PyObject_CallMethod((PyObject *)self, "sizer", "");
res = PyInt_AsLong(pyres);
Py_DECREF(pyres);
return res;
pyres = PyObject_CallMethod((PyObject *)self, "sizer", "");
res = PyInt_AsLong(pyres);
Py_DECREF(pyres);
return res;
}
char * idaapi choose_getl(void *self, uint32 n, char *buf)
{
PyObject *pyres;
char *res;
PyObject *pyres;
char *res;
char tmp[1024];
char tmp[1024];
pyres = PyObject_CallMethod((PyObject *)self, "getl", "l", n);
pyres = PyObject_CallMethod((PyObject *)self, "getl", "l", n);
if (!pyres)
{
strcpy(buf, "<Empty>");
return buf;
}
if (!pyres)
{
strcpy(buf, "<Empty>");
return buf;
}
res = PyString_AsString(pyres);
res = PyString_AsString(pyres);
if (res)
{
strcpy(buf, res);
res = buf;
}
else
{
strcpy(buf, "<Empty>");
res = buf;
}
if (res)
{
strcpy(buf, res);
res = buf;
}
else
{
strcpy(buf, "<Empty>");
res = buf;
}
Py_DECREF(pyres);
return res;
Py_DECREF(pyres);
return res;
}
void idaapi choose_enter(void *self, uint32 n)
{
PyObject_CallMethod((PyObject *)self, "enter", "l", n);
return;
PyObject_CallMethod((PyObject *)self, "enter", "l", n);
return;
}
uint32 choose_choose(void *self,
@ -196,35 +196,35 @@ uint32 choose_choose(void *self,
int x1,int y1,
int width)
{
PyObject *pytitle;
PyObject *pytitle;
char deftitle[] = "Choose";
char *title = NULL;
char deftitle[] = "Choose";
char *title = NULL;
if ((pytitle = PyObject_GetAttrString((PyObject *)self, "title")))
{
title = PyString_AsString(pytitle);
}
if ((pytitle = PyObject_GetAttrString((PyObject *)self, "title")))
{
title = PyString_AsString(pytitle);
}
return choose(
flags,
x0, y0,
x1, y1,
self,
width,
&choose_sizer,
&choose_getl,
title ? title : deftitle,
1,
1,
NULL, /* del */
NULL, /* inst */
NULL, /* update */
NULL, /* edit */
&choose_enter,
NULL, /* destroy */
NULL, /* popup_names */
NULL /* get_icon */
return choose(
flags,
x0, y0,
x1, y1,
self,
width,
&choose_sizer,
&choose_getl,
title ? title : deftitle,
1,
1,
NULL, /* del */
NULL, /* inst */
NULL, /* update */
NULL, /* edit */
&choose_enter,
NULL, /* destroy */
NULL, /* popup_names */
NULL /* get_icon */
);
}
%}

View File

@ -120,7 +120,7 @@
%inline %{
int mem2base_wrap(char *buf, int len, ea_t ea, long fpos)
{
return mem2base((void *)buf, ea, ea+len, fpos);
return mem2base((void *)buf, ea, ea+len, fpos);
}
%}

View File

@ -22,12 +22,12 @@
%include "segment.hpp"
%inline %{
sel_t get_defsr(segment_t *s, int reg)
{
sel_t get_defsr(segment_t *s, int reg)
{
return s->defsr[reg];
}
void set_defsr(segment_t *s, int reg, sel_t value)
{
}
void set_defsr(segment_t *s, int reg, sel_t value)
{
s->defsr[reg] = value;
}
}
%}

View File

@ -9,6 +9,6 @@
// Add a get_member() member function to struc_t.
// This helps to access the members array in the class.
%extend struc_t {
member_t * get_member(int index) { return &(self->members[index]); }
member_t * get_member(int index) { return &(self->members[index]); }
}

View File

@ -29,85 +29,85 @@
%define %cstring_output_maxstr_none(TYPEMAP, SIZE)
%typemap (default) SIZE {
$1 = MAXSTR;
}
$1 = MAXSTR;
}
%typemap(in,numinputs=0) (TYPEMAP, SIZE) {
#ifdef __cplusplus
$1 = ($1_ltype) new char[MAXSTR+1];
$1 = ($1_ltype) new char[MAXSTR+1];
#else
$1 = ($1_ltype) malloc(MAXSTR+1);
$1 = ($1_ltype) malloc(MAXSTR+1);
#endif
}
%typemap(out) ssize_t {
/* REMOVING ssize_t return value in $symname */
}
%typemap(argout) (TYPEMAP,SIZE) {
if (result > 0)
{
resultobj = PyString_FromString($1);
}
else
{
Py_INCREF(Py_None);
resultobj = Py_None;
}
if (result > 0)
{
resultobj = PyString_FromString($1);
}
else
{
Py_INCREF(Py_None);
resultobj = Py_None;
}
#ifdef __cplusplus
delete [] $1;
delete [] $1;
#else
free($1);
free($1);
#endif
}
%enddef
%define %cstring_bounded_output_none(TYPEMAP,MAX)
%typemap(in, numinputs=0) TYPEMAP(char temp[MAX+1]) {
$1 = ($1_ltype) temp;
$1 = ($1_ltype) temp;
}
%typemap(argout,fragment="t_output_helper") TYPEMAP {
PyObject *o;
$1[MAX] = 0;
PyObject *o;
$1[MAX] = 0;
if ($1 > 0)
{
o = PyString_FromString($1);
}
else
{
o = Py_None;
Py_INCREF(Py_None);
}
$result = t_output_helper($result,o);
if ($1 > 0)
{
o = PyString_FromString($1);
}
else
{
o = Py_None;
Py_INCREF(Py_None);
}
$result = t_output_helper($result,o);
}
%enddef
%define %binary_output_or_none(TYPEMAP, SIZE)
%typemap (default) SIZE {
$1 = MAXSPECSIZE;
$1 = MAXSPECSIZE;
}
%typemap(in,numinputs=0) (TYPEMAP, SIZE) {
#ifdef __cplusplus
$1 = (char *) new char[MAXSPECSIZE+1];
$1 = (char *) new char[MAXSPECSIZE+1];
#else
$1 = (char *) malloc(MAXSPECSIZE+1);
$1 = (char *) malloc(MAXSPECSIZE+1);
#endif
}
%typemap(out) ssize_t {
/* REMOVING ssize_t return value in $symname */
}
%typemap(argout) (TYPEMAP,SIZE) {
if (result > 0)
{
resultobj = PyString_FromStringAndSize((char *)$1, result);
}
else
{
Py_INCREF(Py_None);
resultobj = Py_None;
}
if (result > 0)
{
resultobj = PyString_FromStringAndSize((char *)$1, result);
}
else
{
Py_INCREF(Py_None);
resultobj = Py_None;
}
#ifdef __cplusplus
delete [] (char *)$1;
delete [] (char *)$1;
#else
free((char *)$1);
free((char *)$1);
#endif
}
%enddef
@ -145,11 +145,11 @@
}
%enddef
// Check that the argument is a callable Python object
// Check that the argument is a callable Python object
%typemap(in) PyObject *pyfunc {
if (!PyCallable_Check($input)) {
PyErr_SetString(PyExc_TypeError, "Expecting a callable object");
return NULL;
}
$1 = $input;
if (!PyCallable_Check($input)) {
PyErr_SetString(PyExc_TypeError, "Expecting a callable object");
return NULL;
}
$1 = $input;
}

View File

@ -142,18 +142,18 @@
%inline %{
til_t * load_til(const char *tildir, const char *name)
{
char errbuf[4096];
til_t *res;
char errbuf[4096];
til_t *res;
res = load_til(tildir, name, errbuf, sizeof(errbuf));
res = load_til(tildir, name, errbuf, sizeof(errbuf));
if (!res)
{
PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL;
}
if (!res)
{
PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL;
}
return res;
return res;
}
%}
@ -161,18 +161,18 @@ til_t * load_til(const char *tildir, const char *name)
%inline %{
til_t * load_til_header_wrap(const char *tildir, const char *name)
{
char errbuf[4096];
til_t *res;
char errbuf[4096];
til_t *res;
res = load_til_header(tildir, name, errbuf, sizeof(errbuf));;
res = load_til_header(tildir, name, errbuf, sizeof(errbuf));;
if (!res)
{
PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL;
}
if (!res)
{
PyErr_SetString(PyExc_RuntimeError, errbuf);
return NULL;
}
return res;
return res;
}
%}
@ -184,10 +184,8 @@ int idc_parse_types(const char *input, int flags)
{
int hti = ((flags >> 4) & 7) << HTI_PAK_SHIFT;
if ( (flags & 1) != 0 )
{
if ((flags & 1) != 0)
hti |= HTI_FIL;
}
return parse_types2(input, (flags & 2) == 0 ? msg : NULL, hti);
}
@ -201,12 +199,10 @@ char *idc_get_type(ea_t ea, char *buf, size_t bufsize)
{
int code = print_type_to_one_line(buf, bufsize, idati, type,
NULL, NULL, fnames);
if ( code == T_NORMAL )
{
if (code == T_NORMAL)
return buf;
}
} \
return NULL;
} \
return NULL;
}
char *idc_guess_type(ea_t ea, char *buf, size_t bufsize)
@ -218,78 +214,75 @@ char *idc_guess_type(ea_t ea, char *buf, size_t bufsize)
{
int code = print_type_to_one_line(buf, bufsize, idati, type,
NULL, NULL, fnames);
if ( code == T_NORMAL )
{
if (code == T_NORMAL)
return buf;
}
} \
return NULL;
} \
return NULL;
}
int idc_set_local_type(int ordinal, const char *dcl, int flags)
{
if (dcl == NULL || dcl[0] == '\0')
if (dcl == NULL || dcl[0] == '\0')
{
if (!del_numbered_type(idati, ordinal))
return 0;
if (!del_numbered_type(idati, ordinal))
return 0;
}
else
else
{
qstring name;
qtype type;
qtype fields;
qstring name;
qtype type;
qtype fields;
if (!parse_decl(idati, dcl, &name, &type, &fields, flags))
return 0;
if (!parse_decl(idati, dcl, &name, &type, &fields, flags))
return 0;
if (ordinal <= 0)
if (ordinal <= 0)
{
if (!name.empty())
ordinal = get_type_ordinal(idati, name.c_str());
if (!name.empty())
ordinal = get_type_ordinal(idati, name.c_str());
if (ordinal <= 0)
ordinal = alloc_type_ordinal(idati);
if (ordinal <= 0)
ordinal = alloc_type_ordinal(idati);
}
if (!set_numbered_type(idati, ordinal, 0, name.c_str(), type.c_str(), fields.c_str()))
return 0;
if (!set_numbered_type(idati, ordinal, 0, name.c_str(), type.c_str(), fields.c_str()))
return 0;
}
return ordinal;
return ordinal;
}
int idc_get_local_type(int ordinal, int flags, char *buf, size_t maxsize)
{
const type_t *type;
const p_list *fields;
const type_t *type;
const p_list *fields;
if (!get_numbered_type(idati, ordinal, &type, &fields))
if (!get_numbered_type(idati, ordinal, &type, &fields))
{
buf[0] = 0;
return false;
buf[0] = 0;
return false;
}
qstring res;
const char *name = get_numbered_type_name(idati, ordinal);
qstring res;
const char *name = get_numbered_type_name(idati, ordinal);
if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0)
if (print_type_to_qstring(&res, NULL, 2, 40, flags, idati, type, name, NULL, fields) <= 0)
{
buf[0] = 0;
return false;
buf[0] = 0;
return false;
}
qstrncpy(buf, res.c_str(), maxsize);
return true;
qstrncpy(buf, res.c_str(), maxsize);
return true;
}
char idc_get_local_type_name(int ordinal, char *buf, size_t bufsize)
{
const char *name = get_numbered_type_name(idati, ordinal);
const char *name = get_numbered_type_name(idati, ordinal);
if (name == NULL)
return false;
if (name == NULL)
return false;
qstrncpy(buf, name, bufsize);
return true;
qstrncpy(buf, name, bufsize);
return true;
}
%}

View File

@ -6,7 +6,7 @@
%inline {
insn_t * get_current_instruction()
{
return &cmd;
return &cmd;
}
}
@ -14,12 +14,9 @@ insn_t * get_current_instruction()
%inline {
op_t *get_instruction_operand(insn_t *ins, int n)
{
if (!ins)
{
return NULL;
}
return &(ins->Operands[n]);
if (!ins)
return NULL;
return &(ins->Operands[n]);
}
}