core/win32/callback.c
/* This routine is called by a DynamoRIO routine that was invoked natively,
 * i.e., not under DynamoRIO control.
 * This routine takes control using the application state in its arguments,
 * and starts execution under DynamoRIO at start_pc.
 * state->callee_arg is a boolean "save_dcontext":
 * If save_dcontext is true, it saves the cur dcontext on the callback stack
 * of dcontexts and proceeds to execute with a new dcontext.
 * Otherwise, it uses the current dcontext, which has its trace squashed.
 */
This routine is called by a DynamoRIO routine that was invoked natively,
i.e., not under DynamoRIO control.
This routine takes control using the application state in its arguments,
and starts execution under DynamoRIO at start_pc.
state->callee_arg is a boolean "save_dcontext":
If save_dcontext is true, it saves the cur dcontext on the callback stack
of dcontexts and proceeds to execute with a new dcontext.
Otherwise, it uses the current dcontext, which has its trace squashed.
This routine is called by a DynamoRIO routine that was invoked natively i . e . not under DynamoRIO control . This routine takes control using the application state in its arguments and starts execution under DynamoRIO at start_pc . state - > callee_arg is a boolean " save_dcontext " : If save_dcontext is true it saves the cur dcontext on the callback stack of dcontexts and proceeds to execute with a new dcontext . Otherwise it uses the current dcontext which has its trace squashed .
static void
asynch_take_over(app_state_at_intercept_t *state)
{
    dcontext_t *dcontext;
    bool save_dcontext = (bool)(ptr_uint_t) state->callee_arg;
    if (save_dcontext) {
        dcontext = callback_setup(state->start_pc);
    } else {
        dcontext = get_thread_private_dcontext();
        ASSERT(dcontext->initialized);
        if (RUNNING_WITHOUT_CODE_CACHE() 
            && dcontext->next_tag == BACK_TO_NATIVE_AFTER_SYSCALL
            && state->start_pc == image_entry_pc) {
            ASSERT(dcontext->native_exec_postsyscall == image_entry_pc);
        } else {
            ASSERT(!RUNNING_WITHOUT_CODE_CACHE());
            dcontext->next_tag = state->start_pc;
        }
        if (is_building_trace(dcontext)) {
            LOG(THREAD, LOG_ASYNCH, 2, "asynch_take_over: squashing old trace\n");
            trace_abort(dcontext);
        }
    }
    LOG(THREAD, LOG_ASYNCH, 2, "asynch_take_over 0x%08x\n", state->start_pc);
    set_at_syscall(dcontext, false);
    if (dcontext->whereami != WHERE_APP) 
        dcontext->whereami = WHERE_TRAMPOLINE;
    set_last_exit(dcontext, (linkstub_t *) get_asynch_linkstub());
    transfer_to_dispatch(dcontext, state->app_errno, &state->mc);
    ASSERT_NOT_REACHED();
}
static void asynch_take_over ( app_state_at_intercept_t * state ) { dcontext_t * dcontext ; bool save_dcontext = ( bool ) ( ptr_uint_t ) state -> callee_arg ; if ( save_dcontext ) { dcontext = callback_setup ( state -> start_pc ) ; } else { dcontext = get_thread_private_dcontext ( ) ; ASSERT ( dcontext -> initialized ) ; if ( RUNNING_WITHOUT_CODE_CACHE ( ) && dcontext -> next_tag == BACK_TO_NATIVE_AFTER_SYSCALL && state -> start_pc == image_entry_pc ) { ASSERT ( dcontext -> native_exec_postsyscall == image_entry_pc ) ; } else { ASSERT ( ! RUNNING_WITHOUT_CODE_CACHE ( ) ) ; dcontext -> next_tag = state -> start_pc ; } if ( is_building_trace ( dcontext ) ) { LOG ( THREAD , LOG_ASYNCH , 2 , " \n " ) ; trace_abort ( dcontext ) ; } } LOG ( THREAD , LOG_ASYNCH , 2 , " \n " , state -> start_pc ) ; set_at_syscall ( dcontext , false ) ; if ( dcontext -> whereami != WHERE_APP ) dcontext -> whereami = WHERE_TRAMPOLINE ; set_last_exit ( dcontext , ( linkstub_t * ) get_asynch_linkstub ( ) ) ; transfer_to_dispatch ( dcontext , state -> app_errno , & state -> mc ) ; ASSERT_NOT_REACHED ( ) ; }
This routine is called by a DynamoRIO routine that was invoked natively,
 i.e., not under DynamoRIO control.
This routine is called by a DynamoRIO routine that was invoked natively i . e . not under DynamoRIO control .
/* save cur dcontext and get a new one */ /* case 9347 we want to let go after image entry point */ /* if we were building a trace, kill it */ /* may have been inside syscall...now we're in app! */ /* tell dispatch() why we're coming there */ /* new thread, typically: leave it that way */