VOID PumpMessageQueue( VOID ) { char class_name[80]; QMSG qmsg; ERRORID err; ULONG ulCount; for( ;; ) { DosWaitEventSem( PumpMessageSem, SEM_INDEFINITE_WAIT ); DosResetEventSem( PumpMessageSem, &ulCount ); WinThreadAssocQueue( GUIGetHAB(), GUIPMmq ); while ( WinGetMsg( GUIGetHAB(), &qmsg, 0L, 0, 0 ) ) { WinQueryClassName( qmsg.hwnd, sizeof( class_name ), class_name ); if (strcmp( class_name, "GUIClass" ) == 0 || strcmp( class_name, "WTool" ) == 0) { WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 ); } else { WinDispatchMsg( GUIGetHAB(), &qmsg ); } } WinThreadAssocQueue( GUIGetHAB(), NULL ); err = WinGetLastError( GUIGetHAB() ); DosPostEventSem( PumpMessageDoneSem ); } }
static void APIENTRY SoftModeThread( thread_data *thread ) { QMSG qmsg; ULONG rc; RECTL rcl; HPS ps; rc = WinThreadAssocQueue( HabDebugger, thread->hmq ); rc = WinSetHook( HabDebugger, thread->hmq, HK_CALLHOOK, (PFN)CallHookProc, NULLHANDLE ); PSetHmqDebugee( thread->hmq, HwndDummy ); rc = WinSetHook( HabDebugger, NULLHANDLE, HK_SENDMSG, (PFN)PSendMsgHookProc, HookDLL ); while( WinQuerySendMsg( HabDebugger, NULLHANDLE, thread->hmq, &qmsg ) ) { WinReplyMsg( HabDebugger, NULLHANDLE, thread->hmq, (MRESULT)0 ); } while( WinGetMsg( HabDebugger, &qmsg, 0, 0, 0 ) ) { // handle messages for task switch( qmsg.msg ) { case WM_PAINT: // don't do any painting ps = WinBeginPaint( qmsg.hwnd, 0, &rcl ); WinEndPaint( ps ); break; default: // have the default window procedure handle the rest WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 ); } } WinReleaseHook( HabDebugger, NULLHANDLE, HK_SENDMSG, (PFN)PSendMsgHookProc, HookDLL ); PSetHmqDebugee( thread->hmq, NULLHANDLE ); WinReleaseHook( HabDebugger, thread->hmq, HK_CALLHOOK, (PFN)CallHookProc, NULLHANDLE ); WinThreadAssocQueue( HabDebugger, NULLHANDLE ); WinPostMsg( HwndDebugger, WM_QUIT, 0, 0 ); // tell debugger we're done }
static void UnLockIt( void ) { if( Locked ) { WinThreadAssocQueue( Hab, Hmq ); WinLockInput( 0,0 ); WinThreadAssocQueue( Hab, NULL ); Locked = 0; } }
static void LockIt( void ) { if( !Locked ) { WinThreadAssocQueue( Hab, Hmq ); WinLockInput( 0,1 ); WinThreadAssocQueue( Hab, NULL ); Locked = 1; } }
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 ); }