diff --git a/rostests/rosautotest/CDialogSurpass.cpp b/rostests/rosautotest/CDialogSurpass.cpp
new file mode 100644
index 00000000000..59728b4fabd
--- /dev/null
+++ b/rostests/rosautotest/CDialogSurpass.cpp
@@ -0,0 +1,97 @@
+/*
+ * PROJECT: ReactOS Automatic Testing Utility
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE: Class for managing all the configuration parameters
+ * COPYRIGHT: Copyright 2011
+ */
+
+#include "precomp.h"
+
+BOOL CALLBACK PrintWindow(HWND hwnd, LPARAM lParam)
+{
+ CHAR WindowTitle[100];
+ int lenght;
+
+ lenght = GetWindowTextA(hwnd, WindowTitle, 100);
+ if(lenght == 0)
+ return TRUE;
+
+ StringOut( string(WindowTitle) + "\n" );
+
+ return TRUE;
+}
+
+
+void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook,
+ DWORD event,
+ HWND hwnd,
+ LONG idObject,
+ LONG idChild,
+ DWORD dwEventThread,
+ DWORD dwmsEventTime)
+{
+ /* make sure we got the correct event */
+ if(event == EVENT_SYSTEM_DIALOGSTART)
+ {
+ /* wait for some time to make sure that the dialog is hung */
+ Sleep(30 * 1000);
+
+ /* Check if it is still open */
+ if(IsWindow(hwnd))
+ {
+ /* Print an error message */
+ StringOut("Closing following dialog box:\n");
+ PrintWindow(hwnd, NULL);
+ EnumChildWindows(hwnd, PrintWindow, NULL);
+
+ /* Close the dialog */
+ SendMessage(hwnd, WM_CLOSE, 0, 0);
+ }
+ }
+}
+
+
+DWORD WINAPI DialogSurpassThread(LPVOID lpThreadParameter)
+{
+ MSG dummy;
+
+ /* Install event notifications */
+ SetWinEventHook(EVENT_SYSTEM_DIALOGSTART,
+ EVENT_SYSTEM_DIALOGSTART,
+ NULL,
+ WinEventProc,
+ 0,
+ 0,
+ WINEVENT_OUTOFCONTEXT);
+
+ while(GetMessage(&dummy, 0,0,0))
+ {
+ /* There is no need to dispatch messages here */
+ /* Actually this block will never be executed */
+ }
+
+ return 0;
+}
+
+CDialogSurpass::CDialogSurpass()
+{
+ /* Creat the trhead that will receive notifications */
+ hThread = CreateThread(NULL,
+ 0,
+ DialogSurpassThread,
+ NULL,
+ 0,
+ &ThreadID);
+}
+
+CDialogSurpass::~CDialogSurpass()
+{
+ /* Notify the thread to close */
+ PostThreadMessage(ThreadID, WM_QUIT, 0, 0);
+
+ /* Wait for it close */
+ WaitForSingleObject(hThread, INFINITE);
+
+ /* Now close its handle*/
+ CloseHandle(hThread);
+}
diff --git a/rostests/rosautotest/CDialogSurpass.h b/rostests/rosautotest/CDialogSurpass.h
new file mode 100644
index 00000000000..54e186df541
--- /dev/null
+++ b/rostests/rosautotest/CDialogSurpass.h
@@ -0,0 +1,17 @@
+/*
+ * PROJECT: ReactOS Automatic Testing Utility
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE: Class for managing all the configuration parameters
+ * COPYRIGHT: Copyright 2011
+ */
+
+class CDialogSurpass
+{
+private:
+
+ DWORD ThreadID;
+ HANDLE hThread;
+public:
+ CDialogSurpass();
+ ~CDialogSurpass();
+};
diff --git a/rostests/rosautotest/main.cpp b/rostests/rosautotest/main.cpp
index 5fb5dd4c297..17189a52e15 100644
--- a/rostests/rosautotest/main.cpp
+++ b/rostests/rosautotest/main.cpp
@@ -48,6 +48,7 @@ wmain(int argc, wchar_t* argv[])
{
CWineTest WineTest;
int ReturnValue = 1;
+ CDialogSurpass s;
try
{
diff --git a/rostests/rosautotest/precomp.h b/rostests/rosautotest/precomp.h
index f5e65ad0798..9f71ff13345 100644
--- a/rostests/rosautotest/precomp.h
+++ b/rostests/rosautotest/precomp.h
@@ -20,6 +20,7 @@ using namespace std;
/* Class includes */
#include "auto_array_ptr.h"
#include "CConfiguration.h"
+#include "CDialogSurpass.h"
#include "CFatalException.h"
#include "CInvalidParameterException.h"
#include "CProcess.h"
diff --git a/rostests/rosautotest/rosautotest.rbuild b/rostests/rosautotest/rosautotest.rbuild
index 5224c24df97..0f593c551e4 100644
--- a/rostests/rosautotest/rosautotest.rbuild
+++ b/rostests/rosautotest/rosautotest.rbuild
@@ -8,6 +8,7 @@
user32
wininet
CConfiguration.cpp
+ CDialogSurpass.cpp
CFatalException.cpp
CInvalidParameterException.cpp
CJournaledTestList.cpp