drwrap.h File Reference

Header for DynamoRIO Function Wrapping and Replacing Extension. More...

#include "drext.h"

Data Structures

struct  _drwrap_stats_t
 

Macros

#define DRMGR_PRIORITY_NAME_DRWRAP   "drwrap"
 
#define DRWRAP_REPLACE_NATIVE_DATA_SLOT   SPILL_SLOT_2
 
#define DRWRAP_REPLACE_NATIVE_SP_SLOT   SPILL_SLOT_3
 

Typedefs

typedef ptr_int_t atomic_int_t
 
typedef struct _drwrap_stats_t drwrap_stats_t
 

Enumerations

enum  {
  DRMGR_PRIORITY_APP2APP_DRWRAP = -500,
  DRMGR_PRIORITY_INSERT_DRWRAP = 500,
  DRMGR_PRIORITY_FAULT_DRWRAP = 500
}
 
enum  drwrap_wrap_flags_t {
  DRWRAP_FLAGS_NONE = 0x00,
  DRWRAP_UNWIND_ON_EXCEPTION = 0x01,
  DRWRAP_NO_DYNAMIC_RETADDRS = 0x02,
  DRWRAP_REPLACE_RETADDR = 0x04
}
 
enum  drwrap_callconv_t {
  DRWRAP_CALLCONV_AMD64 = 0x01000000,
  DRWRAP_CALLCONV_MICROSOFT_X64 = 0x02000000,
  DRWRAP_CALLCONV_ARM = 0x03000000,
  DRWRAP_CALLCONV_CDECL = 0x04000000,
  DRWRAP_CALLCONV_STDCALL = DRWRAP_CALLCONV_CDECL,
  DRWRAP_CALLCONV_FASTCALL = 0x05000000,
  DRWRAP_CALLCONV_THISCALL = 0x06000000,
  DRWRAP_CALLCONV_AARCH64 = 0x07000000,
  DRWRAP_CALLCONV_RISCV_LP64 = 0x08000000,
  DRWRAP_CALLCONV_DEFAULT = DRWRAP_CALLCONV_AARCH64,
  DRWRAP_CALLCONV_VARARG = DRWRAP_CALLCONV_DEFAULT,
  DRWRAP_CALLCONV_MASK = 0xff000000
}
 
enum  drwrap_global_flags_t {
  DRWRAP_SAFE_READ_RETADDR = 0x01,
  DRWRAP_SAFE_READ_ARGS = 0x02,
  DRWRAP_NO_FRILLS = 0x04,
  DRWRAP_FAST_CLEANCALLS = 0x08,
  DRWRAP_INVERT_CONTROL = 0x10
}
 

Functions

DR_EXPORT bool drwrap_init (void)
 
DR_EXPORT void drwrap_exit (void)
 
DR_EXPORT dr_emit_flags_t drwrap_invoke_insert (void *drcontext, void *tag, instrlist_t *bb, instr_t *inst, instr_t *where, bool for_trace, bool translating, void *user_data)
 
DR_EXPORT dr_emit_flags_t drwrap_invoke_insert_cleanup_only (void *drcontext, void *tag, instrlist_t *bb, instr_t *inst, instr_t *where, bool for_trace, bool translating, void *user_data)
 
DR_EXPORT bool drwrap_replace (app_pc original, app_pc replacement, bool override)
 
DR_EXPORT bool drwrap_replace_native (app_pc original, app_pc replacement, bool at_entry, uint stack_adjust, void *user_data, bool override)
 
DR_EXPORT bool drwrap_is_replaced (app_pc func)
 
DR_EXPORT bool drwrap_is_replaced_native (app_pc func)
 
DR_EXPORT void drwrap_replace_native_fini (void *drcontext)
 
DR_EXPORT bool drwrap_wrap (app_pc func, void(*pre_func_cb)(void *wrapcxt, DR_PARAM_OUT void **user_data), void(*post_func_cb)(void *wrapcxt, void *user_data))
 
DR_EXPORT bool drwrap_wrap_ex (app_pc func, void(*pre_func_cb)(void *wrapcxt, DR_PARAM_INOUT void **user_data), void(*post_func_cb)(void *wrapcxt, void *user_data), void *user_data, uint flags)
 
DR_EXPORT bool drwrap_unwrap (app_pc func, void(*pre_func_cb)(void *wrapcxt, DR_PARAM_OUT void **user_data), void(*post_func_cb)(void *wrapcxt, void *user_data))
 
DR_EXPORT app_pc drwrap_get_drcontext (void *wrapcxt)
 
DR_EXPORT app_pc drwrap_get_func (void *wrapcxt)
 
DR_EXPORT dr_mcontext_tdrwrap_get_mcontext (void *wrapcxt)
 
DR_EXPORT dr_mcontext_tdrwrap_get_mcontext_ex (void *wrapcxt, dr_mcontext_flags_t flags)
 
DR_EXPORT bool drwrap_set_mcontext (void *wrapcxt)
 
DR_EXPORT app_pc drwrap_get_retaddr (void *wrapcxt)
 
DR_EXPORT void * drwrap_get_arg (void *wrapcxt, int arg)
 
DR_EXPORT bool drwrap_set_arg (void *wrapcxt, int arg, void *val)
 
DR_EXPORT void * drwrap_get_retval (void *wrapcxt)
 
DR_EXPORT bool drwrap_set_retval (void *wrapcxt, void *val)
 
DR_EXPORT bool drwrap_skip_call (void *wrapcxt, void *retval, size_t stdcall_args_size)
 
DR_EXPORT drext_status_t drwrap_redirect_execution (void *wrapcxt)
 
DR_EXPORT bool drwrap_is_redirect_requested (void *wrapcxt)
 
DR_EXPORT bool drwrap_register_post_call_notify (void(*cb)(app_pc pc))
 
DR_EXPORT bool drwrap_unregister_post_call_notify (void(*cb)(app_pc pc))
 
DR_EXPORT bool drwrap_mark_as_post_call (app_pc pc)
 
DR_EXPORT bool drwrap_set_global_flags (drwrap_global_flags_t flags)
 
DR_EXPORT bool drwrap_is_wrapped (app_pc func, void(*pre_func_cb)(void *wrapcxt, DR_PARAM_OUT void **user_data), void(*post_func_cb)(void *wrapcxt, void *user_data))
 
DR_EXPORT bool drwrap_is_post_wrap (app_pc pc)
 
DR_EXPORT bool drwrap_get_stats (DR_PARAM_OUT drwrap_stats_t *stats)
 
DR_EXPORT void drwrap_get_retaddr_if_sentinel (void *drcontext, DR_PARAM_INOUT app_pc *possibly_sentinel)
 

Detailed Description

Header for DynamoRIO Function Wrapping and Replacing Extension.