/* * MySpawn - spawn a windows app */ int MySpawn( char *cmd ) { FARPROC proc; HANDLE inst; cmd_struct cmds; char path[FILENAME_MAX]; #ifndef __WINDOWS_386__ char buffer[FILENAME_MAX]; #endif int rc; GetSpawnCommandLine( path, cmd, &cmds ); cmds.cmd[cmds.len] = 0; proc = MakeProcInstance( (FARPROC)NotifyHandler, InstanceHandle ); if( !NotifyRegister( (HANDLE)NULLHANDLE, (LPFNNOTIFYCALLBACK)proc, NF_NORMAL ) ) { FreeProcInstance( proc ); return( -1 ); } strcat( path, " " ); strcat( path, &(cmds.cmd[0]) ); inst = (HANDLE) WinExec( (LPCSTR)path, SW_SHOWNORMAL ); if( inst > (HANDLE)32 ) { union REGS in_regs, out_regs; doneExec = FALSE; #ifdef __WINDOWS_386__ moduleHandle = GetModuleHandle( PASS_WORD_AS_POINTER( inst ) ); #else GetModuleFileName( inst, buffer, FILENAME_MAX - 1 ); moduleHandle = GetModuleHandle( buffer ); #endif // waiting doesn't work under win-os2 so don't wait! in_regs.h.ah = 0x30; in_regs.h.al = 0x0; intdos( &in_regs, &out_regs ); if( out_regs.h.al == 20 ) { doneExec = TRUE; } instanceHandle = inst; EditFlags.HoldEverything = TRUE; while( !doneExec ) { MessageLoop( TRUE ); Yield(); } EditFlags.HoldEverything = FALSE; rc = 0; } else { rc = -1; } NotifyUnRegister( (HANDLE)NULLHANDLE ); FreeProcInstance( proc ); return( rc ); } /* MySpawn */
/* * InitDebugging: * * - check for WDEBUG.386 * - register an interrupt handler (for handling 16-bit faults) * - register a notify handler (for receiving all system notifications) * - if we have WDEBUG.386, then we load WINT32.DLL, get all its entry * points, and then tell it we want to handle 32-bit faults * - we then get a data segment alias for our code segment, so that we * can write stuff into our code segment (see FAULT.C) * */ char *InitDebugging( void ) { DebuggerState=ACTIVE; StartWDebug386(); faultInstance = MakeProcInstance( (FARPROC)IntHandler, Instance ); if( !InterruptRegister( NULL, faultInstance ) ) { return( TRP_WIN_Failed_to_get_interrupt_hook ); } notifyInstance = MakeProcInstance( (FARPROC)NotifyHandler, Instance ); if( !NotifyRegister( NULL, (LPFNNOTIFYCALLBACK)notifyInstance, NF_NORMAL | NF_RIP ) ) { return( TRP_WIN_Failed_to_get_notify_hook ); } Out(( OUT_INIT,"ds=%04x, faultInstance=%Fp, notifyInstance=%Fp,Instance=%04x", FP_SEG( &faultInstance ), faultInstance, notifyInstance, Instance )); if( WDebug386 ) { wint32 = LoadLibrary( "wint32.dll" ); if( (UINT)wint32 < 32 ) { WDebug386 = FALSE; } else { DoneWithInterrupt = (LPVOID) GetProcAddress( wint32, "DoneWithInterrupt" ); GetDebugInterruptData = (LPVOID) GetProcAddress( wint32, "GetDebugInterruptData" ); ResetDebugInterrupts32 = (LPVOID) GetProcAddress( wint32, "ResetDebugInterrupts32" ); SetDebugInterrupts32 = (LPVOID) GetProcAddress( wint32, "SetDebugInterrupts32" ); DebuggerIsExecuting = (LPVOID) GetProcAddress( wint32, "DebuggerIsExecuting" ); if( !SetDebugInterrupts32() ) { WDebug386 = FALSE; FreeLibrary( wint32 ); } else { DebuggerIsExecuting( 1 ); Out((OUT_INIT,"Hooked Interrupts")); } } } // SubClassProcInstance = MakeProcInstance( (FARPROC)SubClassProc, Instance ); InitDebugHook(); CSAlias = AllocCSToDSAlias( CS() ); return( "" ); } /* InitDebugging */