Example #1
0
void ReleaseQueue( PID pid, TID tid )
{
    tid = tid;
    if( !IsPMDebugger() )
        return;
    if( NeedHardMode == (char) - 1 )
        return;
    if( NeedHardMode ) {
        ExitHardMode();
    } else {
        ExitSoftMode( pid );
    }
}
Example #2
0
/*
 * ReqProg_kill
 *
 * If it was a task that we attached to (WasStarted), all we do is
 * forgive the last interrupt, and then exit
 *
 * If it was a task we started, we TerminateApp it, and then wait for
 * the task ended notification.  Note:  Task ended isn't quite good enough,
 * since the module isn't unloaded.  However, you may never get the module
 * unloaded notification, if you are debugging the 2nd, 3rd etc instance
 * of an app, since the module is loaded more than once.  BUT, a NEW command
 * from the debugger ends up restarting the app "too fast" - the module isn't
 * deleted yet, and so it ends up running a second instance, even if you
 * really don't have a first instance.  This is the reason for that half
 * second pause - to allow Windows to get on with the unloading of the module,
 * if it is going to.  Ack.
 */
unsigned ReqProg_kill( void )
{
    prog_kill_ret       *ret;

    ret = GetOutPtr( 0 );
    ret->err = 0;
    Out((OUT_LOAD,"KILL: DebugeeTask=%04x, WasStarted=%d",
        DebugeeTask, WasStarted ));
    if( DebugeeTask != NULL ) {
        IntResult.EFlags &= ~TRACE_BIT;
        if( WasStarted ) {
            Out((OUT_LOAD,"Doing Release Debugee"));
            DebuggerWaitForMessage( RELEASE_DEBUGEE, DebugeeTask, RESTART_APP );
        } else {
            TerminateApp( DebugeeTask, NO_UAE_BOX );
            DebuggerWaitForMessage( KILLING_DEBUGEE, NULL, -1 );
            Out((OUT_LOAD,"Task Terminated(not current)"));
            {
                DWORD   a;
                a = GetTickCount();
                while( GetTickCount() < a + 500 ) {
                    Yield();
                }
            }
        }
#if 0
        FiniASynchHook();
#endif
    }
    ExitSoftMode();
    if( WDebug386 ) {
        if( WasInt32 ) {
            WasInt32 = FALSE;
            DoneWithInterrupt( NULL );
        }
    }
    DebugeeTask = NULL;
    ModuleTop = 0;
    CurrentModule = 1;
    FaultHandlerEntered = FALSE;
    PendingTrap = FALSE;
    SaveStdIn = NIL_HANDLE;
    SaveStdOut = NIL_HANDLE;
    Debugging32BitApp = FALSE;
    return( sizeof( *ret ) );
}
Example #3
0
restart_opts DebugeeWaitForMessage( void )
{
    MSG         msg;
    HANDLE      huser;
    HWND        hwnddtop;
    HWND        capture;
    HWND        wnd;
    HANDLE      hinst;

    /*
     * give up any capture in context of debugee
     */
    capture = SetCapture(NULL);
    if( capture != NULL ) {
        ReleaseCapture();
        Out((OUT_SOFT,"Capture hwnd=%04x", capture ));
    }

    /*
     * hang out and wait
     */
    huser = GetModuleHandle( "USER");
    hwnddtop = GetDesktopWindow();
    wnd = GetFocus();
    if( IsTaskWnd( wnd ) ) {
        FocusWnd = wnd;
    }
    wnd = GetActiveWindow();
    if( IsTaskWnd( wnd ) ) {
        ActiveWnd = wnd;
    }
    if( HardModeRequired || SystemDebugState == SDS_NOTASKQUEUE || DebuggerWindow == NULL ) {
        Out((OUT_SOFT,"In HardMode Loop! req=%d,SDS=%d,Window=%4.4x",HardModeRequired,SystemDebugState,DebuggerWindow ));
        while( DebuggerState == ACTIVE ) {
            DirectedYield( DebuggerTask );
        }
        if( capture != NULL ) {
            SetCapture( capture );
        }
        return( AppMessage );
    }

    Out((OUT_SOFT,"In SoftMode Loop task=%04x(%04x), act=%04x, foc=%04x, t=%d, DW=%04x", GetCurrentTask(), DebugeeTask, ActiveWnd, FocusWnd, TraceOn, DebuggerWindow ));

    DefaultProcInstance = (FARPROC)MakeProcInstance( (FARPROC)DefaultProc, DebugeeInstance );

    EnumTaskProcInstance = MakeProcInstance( (FARPROC)EnumTaskWindowsFunc, DebugeeInstance );
    EnumChildProcInstance = MakeProcInstance( (FARPROC)EnumChildWindowsFunc, DebugeeInstance );
    EnumTaskWindows( GetCurrentTask(), (WNDENUMPROC)EnumTaskProcInstance, 0 );
    FreeProcInstance( EnumChildProcInstance );
    FreeProcInstance( EnumTaskProcInstance );

    while( 1 ) {
        GetMessage( &msg, NULL, 0, 0 );
        if( msg.hwnd == NULL &&
            msg.message == WM_NULL && msg.lParam == MAGIC_COOKIE ) break;
        if( msg.hwnd != NULL ) {
            hinst = (HINSTANCE)GetWindowWord( msg.hwnd, GWW_HINSTANCE );
        } else {
            hinst = NULL;
        }
        if( msg.hwnd == hwnddtop || hinst == huser ) {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        } else {
            SubClassProc( msg.hwnd, msg.message, msg.wParam, msg.lParam );
        }
    }
    if( !TraceOn && DebuggerWindow != NULL ) {
        if( IsTaskWnd( FocusWnd ) ) {
            Out((OUT_SOFT,"Focus Window to %4.4x", FocusWnd ));
            SetFocus( FocusWnd );
        }
        if( IsTaskWnd( ActiveWnd ) ) {
            Out((OUT_SOFT,"Active Window to %4.4x", ActiveWnd ));
            SetActiveWindow( ActiveWnd );
        }
    }
    ExitSoftMode();
    FreeProcInstance( DefaultProcInstance );
    if( capture != NULL ) {
        SetCapture( capture );
    }
    Out((OUT_SOFT,"active=%04x, focus=%04x, TraceOn=%d, DW=%04x", ActiveWnd, FocusWnd, TraceOn, DebuggerWindow ));
    PostAppMessage( GetCurrentTask(), WM_NULL, 0, 0L );
    return( msg.wParam );

} /* DebugeeWaitForMessage */