[SYSSETUP] Fix handling of the status message window

This fixes a race condition, where the message thread was still running when InstallReactOS returned and syssetup.dll was unloaded by the caller (setup.exe).
This commit is contained in:
Timo Kreuzer 2018-03-17 14:23:34 +01:00
parent 85d4a49acd
commit 36051d3065

View file

@ -552,9 +552,9 @@ static DWORD WINAPI
ShowStatusMessageThread( ShowStatusMessageThread(
IN LPVOID lpParameter) IN LPVOID lpParameter)
{ {
HWND *phWnd = (HWND *)lpParameter;
HWND hWnd, hItem; HWND hWnd, hItem;
MSG Msg; MSG Msg;
UNREFERENCED_PARAMETER(lpParameter);
hWnd = CreateDialogParam(hDllInstance, hWnd = CreateDialogParam(hDllInstance,
MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG), MAKEINTRESOURCE(IDD_STATUSWINDOW_DLG),
@ -563,7 +563,6 @@ ShowStatusMessageThread(
(LPARAM)NULL); (LPARAM)NULL);
if (!hWnd) if (!hWnd)
return 0; return 0;
*phWnd = hWnd;
ShowWindow(hWnd, SW_SHOW); ShowWindow(hWnd, SW_SHOW);
@ -580,6 +579,8 @@ ShowStatusMessageThread(
DispatchMessage(&Msg); DispatchMessage(&Msg);
} }
EndDialog(hWnd, 0);
return 0; return 0;
} }
@ -667,7 +668,8 @@ cleanup:
static BOOL static BOOL
CommonInstall(VOID) CommonInstall(VOID)
{ {
HWND hWnd = NULL; HANDLE hThread = NULL;
BOOL bResult = FALSE;
hSysSetupInf = SetupOpenInfFileW(L"syssetup.inf", hSysSetupInf = SetupOpenInfFileW(L"syssetup.inf",
NULL, NULL,
@ -682,49 +684,54 @@ CommonInstall(VOID)
if (!InstallSysSetupInfDevices()) if (!InstallSysSetupInfDevices())
{ {
FatalError("InstallSysSetupInfDevices() failed!\n"); FatalError("InstallSysSetupInfDevices() failed!\n");
goto error; goto Exit;
} }
if(!InstallSysSetupInfComponents()) if(!InstallSysSetupInfComponents())
{ {
FatalError("InstallSysSetupInfComponents() failed!\n"); FatalError("InstallSysSetupInfComponents() failed!\n");
goto error; goto Exit;
} }
if (!IsConsoleBoot()) if (!IsConsoleBoot())
{ {
HANDLE hThread;
hThread = CreateThread(NULL, hThread = CreateThread(NULL,
0, 0,
ShowStatusMessageThread, ShowStatusMessageThread,
(LPVOID)&hWnd, NULL,
0, 0,
NULL); NULL);
if (hThread)
CloseHandle(hThread);
} }
if (!EnableUserModePnpManager()) if (!EnableUserModePnpManager())
{ {
FatalError("EnableUserModePnpManager() failed!\n"); FatalError("EnableUserModePnpManager() failed!\n");
goto error; goto Exit;
} }
if (CMP_WaitNoPendingInstallEvents(INFINITE) != WAIT_OBJECT_0) if (CMP_WaitNoPendingInstallEvents(INFINITE) != WAIT_OBJECT_0)
{ {
FatalError("CMP_WaitNoPendingInstallEvents() failed!\n"); FatalError("CMP_WaitNoPendingInstallEvents() failed!\n");
goto error; goto Exit;
} }
EndDialog(hWnd, 0); bResult = TRUE;
return TRUE;
error: Exit:
if (hWnd)
EndDialog(hWnd, 0); if (bResult == FALSE)
SetupCloseInfFile(hSysSetupInf); {
return FALSE; SetupCloseInfFile(hSysSetupInf);
}
if (hThread != NULL)
{
PostThreadMessage(GetThreadId(hThread), WM_QUIT, 0, 0);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
}
return bResult;
} }
/* Install a section of a .inf file /* Install a section of a .inf file