static void WakeOneThread( PID pid, TID tid ) { HMQ hmq; hmq = WinQueueFromID( HabDebugger, pid, tid ); if( hmq != NULLHANDLE ) { WinWakeThread( hmq ); } }
static void ReleaseThreadQueue( PID pid, TID tid ) { HMQ hmq; int i; hmq = WinQueueFromID( HabDebugger, pid, tid ); if( hmq == NULLHANDLE ) return; for( i = 0; i < NumAssumedQueues; ++i ) { if( hmq == AssumedQueues[i] ) { WinPostQueueMsg( hmq, WM_QUIT, 0, 0 ); // break one soft mode loop AssumedQueues[i] = NULLHANDLE; break; } } }
static void GrabThreadQueue( PID pid, TID tid ) { thread_data thread; int i; if( HwndDummy == NULLHANDLE ) CreateDummyWindow(); thread.hmq = WinQueueFromID( HabDebugger, pid, tid ); if( thread.hmq == NULLHANDLE ) return; for( i = 0; i < NumAssumedQueues; ++i ) { if( thread.hmq == AssumedQueues[i] ) return; } AssumedQueues[NumAssumedQueues] = thread.hmq; ++NumAssumedQueues; BeginSoftModeThread( &thread ); }
DebugIt( void *crap ) { STARTDATA start; int code; SWCNTRL SW; HSWITCH hswitch; PPIB pib; PTIB tib; HWND hwndme; QMSG qmsg; /* Message from message queue */ int i; PID Pid = 0; ULONG SID; uDB_t Buff; TID tid; HMQ the_q; DosGetInfoBlocks(&tib,&pib); start.Length = offsetof( STARTDATA, IconFile ); /* default for the rest */ start.Related = 1; start.FgBg = 1; start.TraceOpt = 1; start.PgmTitle = (PSZ) "Test Session"; start.PgmName = "HELLO.EXE"; start.PgmInputs = "hi there"; start.TermQ = 0; start.Environment = NULL; start.InheritOpt = 1; start.SessionType = SSF_TYPE_PM; code = DosStartSession( &start, &SID, &Pid ); Buff.Pid = Pid; Buff.Tid = 0; Buff.Cmd = DBG_C_Connect; Buff.Value = DBG_L_386; DosDebug( &Buff ); Buff.Pid = Pid; Buff.Tid = 1; DebugExecute( &Buff, DBG_C_Stop ); if( Buff.Cmd != DBG_N_Success ) { return; } DebugExecute( &Buff, DBG_C_Go ); if( Buff.Cmd != DBG_N_Breakpoint ) { return; } #if 0 Buff.Cmd = DBG_C_Stop; DosDebug( &Buff ); Buff.Cmd = DBG_C_ReadReg; DosDebug( &Buff ); Buff.EIP++; Buff.Cmd = DBG_C_WriteReg; DosDebug( &Buff ); #endif the_q = WinQueueFromID( Hab, Buff.Pid, Buff.Tid ); #if 0 for( ;; ) { hmq = WinQuerySendMsg( Hab, 0, Q, &qmsg ); if( hmq == 0 ) break; WinReplyMsg( Hab, hmq, Q, 1 ); } #endif WinThreadAssocQueue( Hab, the_q ); while( 1 ) { if( !WinGetMsg( Hab, &qmsg, 0L, 0, 0 ) ) break; } WinThreadAssocQueue( Hab, 0 ); for( ;; ) DosSleep( 100 ); }