[MSGINA] Prevent an infinite loop in ShellDimScreen. CORE-12028
[reactos.git] / reactos / dll / win32 / msgina / dimmedwindow.cpp
index e3df825..0a3abad 100644 (file)
@@ -104,7 +104,7 @@ public:
     {
         MSG msg;
 
-        while (!IsWindowVisible(m_hwnd))
+        while (!IsWindowVisible(m_hwnd) && IsWindow(m_hwnd))
         {
             while (::PeekMessage(&msg, m_hwnd, 0, 0, PM_REMOVE))
             {
@@ -261,6 +261,15 @@ ShellDimScreen(void** pUnknown, HWND* hWindow)
 
     pWindow->WaitForInit();
 
+    if (!IsWindow(pWindow->Wnd()))
+    {
+        refcount = pWindow->AddRef();
+        while (refcount)
+            refcount = pWindow->Release();
+
+        return E_FAIL;
+    }
+
     _SEH2_TRY
     {
         hr = pWindow->QueryInterface(IID_IUnknown, pUnknown);