pub unsafe extern "C" fn dr_get_mcontext(
drcontext: *mut c_void,
context: *mut dr_mcontext_t,
) -> bool_Expand description
Copies the fields of the current application machine context selected by the \p flags field of \p context into \p context.
This routine may only be called from:
- A clean call invoked by dr_insert_clean_call() or dr_prepare_for_call(). If register reservation code is in use (e.g., via the drreg extension library \ref page_drreg), dr_insert_clean_call_ex() must be used with its flags argument including #DR_CLEANCALL_READS_APP_CONTEXT (and possibly #DR_CLEANCALL_MULTIPATH)to ensure proper interaction with register reservations.
- A pre- or post-syscall event (dr_register_pre_syscall_event(), dr_register_post_syscall_event())
- Basic block or trace creation events (dr_register_bb_event(), dr_register_trace_event()), but for basic block creation only when the basic block callback parameters \p for_trace and \p translating are false, and for trace creation only when \p translating is false.
- A nudge callback (dr_register_nudge_event()) on Linux. (On Windows nudges happen in separate dedicated threads.)
- A thread or process exit event (dr_register_thread_exit_event(), dr_register_exit_event())
- A thread init event (dr_register_thread_init_event()) for all but the initial thread.
- A kernel transfer event (dr_register_kernel_xfer_event()). Here the obtained context is the target context of the transfer, not the source (about to be changed) context. For Windows system call event types #DR_XFER_CONTINUE and #DR_XFER_SET_CONTEXT_THREAD, only the portions of the context selected by the application are available. The \p flags field of \p context is adjusted to reflect which fields were returned. Given the disparity in how Ebp/Rbp is handled (in #DR_MC_INTEGER but in CONTEXT_CONTROL), clients that care about that register are better off using system call events instead of kernel transfer events to take actions on these two system calls.
Even when #DR_MC_CONTROL is specified, does NOT copy the pc field, except for system call events, when it will point at the post-syscall address, and kernel transfer events, when it will point to the target pc.
Returns false if called from the init event or the initial thread’s init event; returns true otherwise (cannot distinguish whether the caller is in a clean call so it is up to the caller to ensure it is used properly).
The size field of \p context must be set to the size of the structure as known at compile time. If the size field is invalid, this routine will return false.
The flags field of \p context must be set to the desired amount of information using the dr_mcontext_flags_t values. Asking for multimedia registers incurs a higher performance cost. An invalid flags value will return false.
\note NUM_SIMD_SLOTS in the dr_mcontext_t.xmm array are filled in, but only if dr_mcontext_xmm_fields_valid() returns true and #DR_MC_MULTIMEDIA is set in the flags field.
\note The context is the context saved at the dr_insert_clean_call() or dr_prepare_for_call() points. It does not correct for any registers saved with dr_save_reg(). To access registers saved with dr_save_reg() from a clean call use dr_read_saved_reg().
\note System data structures are swapped to private versions prior to invoking clean calls or client events. Use dr_switch_to_app_state() to examine the application version of system state.