Ignore:
Timestamp:
Jan 14, 2001, 6:16:55 PM (25 years ago)
Author:
sandervl
Message:

odininst update, CreateProcess fix & workaround for PM hang in WaitForSingleObject (process handle)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/HandleManager.cpp

    r4739 r4946  
    1 /* $Id: HandleManager.cpp,v 1.56 2000-12-03 10:12:32 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.57 2001-01-14 17:16:54 sandervl Exp $ */
    22
    33/*
     
    6262#include "HMNPipe.h"
    6363#include <vmutex.h>
     64#include <win\thread.h>
    6465
    6566#define DBG_LOCALLOG  DBG_handlemanager
     
    18511852  if (-1 == iIndex)                                               /* error ? */
    18521853  {
    1853     dprintf(("KERNEL32: HandleManager:HMWaitForSingleObject(%08xh) passed on to Open32.\n",
    1854              hObject));
    1855 
     1854       dprintf(("KERNEL32: HandleManager:HMWaitForSingleObject(%08xh) passed on to Open32.\n",
     1855                 hObject));
     1856
     1857#if 1
     1858       //Workaround for applications that block the PM input queue
     1859       //while waiting for a child process to terminate.
     1860       //(WaitSingleObject now calls MsgWaitMultipleObjects and
     1861       // processes messages while waiting for the process to die)
     1862       //(Napster install now doesn't block PM anymore (forcing a reboot))
     1863
     1864       HMODULE hUser32 = LoadLibraryA("USER32.DLL");
     1865
     1866       BOOL (* WINAPI pfnPeekMessageA)(LPMSG,HWND,UINT,UINT,UINT);
     1867       LONG (* WINAPI pfnDispatchMessageA)(const MSG*);
     1868
     1869       *(FARPROC *)&pfnPeekMessageA = GetProcAddress(hUser32,"PeekMessageA");
     1870       *(FARPROC *)&pfnDispatchMessageA = GetProcAddress(hUser32,"DispatchMessageA");
     1871
     1872       TEB *teb = GetThreadTEB();
     1873
     1874       if(!teb || !pfnPeekMessageA || !pfnDispatchMessageA) {
     1875           dprintf(("ERROR: !teb || !pfnPeekMessageA || !pfnDispatchMessageA"));
     1876           DebugInt3();
     1877           return WAIT_FAILED;
     1878       }
     1879
     1880       //TODO: Ignoring all messages could be dangerous. But processing them,
     1881       //while the app doesn't expect any, isn't safe either.
     1882//-> must active check in pmwindow.cpp if this is enabled again!
     1883//       teb->o.odin.fIgnoreMsgs = TRUE;
     1884
     1885       while(TRUE) {
     1886           dwResult =  (O32_MsgWaitForMultipleObjects(1, &hObject, FALSE,
     1887                                                      INFINITE, QS_ALLINPUT));
     1888           if(dwResult == WAIT_OBJECT_0 + 1) {
     1889               MSG msg ;
     1890
     1891               while (pfnPeekMessageA(&msg, NULL, 0, 0, PM_REMOVE))
     1892               {
     1893                  if (msg.message == WM_QUIT)  return 1;
     1894
     1895                  /* otherwise dispatch it */
     1896                  pfnDispatchMessageA(&msg);
     1897
     1898               } // end of PeekMessage while loop
     1899           }
     1900           else {
     1901               dprintf(("WaitForSingleObject: Process %x terminated", hObject));
     1902               break;
     1903           }
     1904       }
     1905//       teb->o.odin.fIgnoreMsgs = FALSE;
     1906       FreeLibrary(hUser32);
     1907       return dwResult;
     1908  }
     1909  else {
     1910#else
    18561911    // maybe handles from CreateProcess() ...
    18571912    dwResult = O32_WaitForSingleObject(hObject, dwTimeout);
     1913#endif
    18581914    return (dwResult);
    18591915  }
Note: See TracChangeset for help on using the changeset viewer.