Changeset 4950


Ignore:
Timestamp:
Jan 14, 2001, 7:18:26 PM (24 years ago)
Author:
sandervl
Message:

WaitForSingleObject fix

File:
1 edited

Legend:

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

    r4949 r4950  
    1 /* $Id: HandleManager.cpp,v 1.58 2001-01-14 17:59:05 sandervl Exp $ */
     1/* $Id: HandleManager.cpp,v 1.59 2001-01-14 18:18:26 sandervl Exp $ */
    22
    33/*
     
    18551855                 hObject));
    18561856
    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;
     1857       if(dwTimeout == INFINITE) {
     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;
    18781908       }
    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            }
     1909       else {
     1910          // maybe handles from CreateProcess() ...
     1911          dwResult = O32_WaitForSingleObject(hObject, dwTimeout);
     1912          return (dwResult);
    19041913       }
    1905 //       teb->o.odin.fIgnoreMsgs = FALSE;
    1906        FreeLibrary(hUser32);
    1907        return dwResult;
    1908 #else
    1909     // maybe handles from CreateProcess() ...
    1910     dwResult = O32_WaitForSingleObject(hObject, dwTimeout);
    1911     return (dwResult);
    1912 #endif
    19131914  }
    19141915
Note: See TracChangeset for help on using the changeset viewer.