From 2b88e1ebf0245923d37d040ada4ad2e9248b472b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 29 Oct 2007 14:47:48 +0000 Subject: [PATCH] Don't crash when starting a 2nd GUI application when booted in console mode svn path=/trunk/; revision=29955 --- reactos/subsystems/win32/win32k/misc/driver.c | 22 +++++++++++-------- .../subsystems/win32/win32k/ntuser/winsta.c | 3 +-- reactos/subsystems/win32/win32k/objects/dc.c | 7 ++++-- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/reactos/subsystems/win32/win32k/misc/driver.c b/reactos/subsystems/win32/win32k/misc/driver.c index 6e987b2d8cd..6e2eaeb1985 100644 --- a/reactos/subsystems/win32/win32k/misc/driver.c +++ b/reactos/subsystems/win32/win32k/misc/driver.c @@ -96,8 +96,8 @@ PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name) { static WCHAR DefaultPath[] = L"\\SystemRoot\\System32\\"; static WCHAR DefaultExtension[] = L".DLL"; + PGD_ENABLEDRIVER ExistingDriver; SYSTEM_GDI_DRIVER_INFORMATION GdiDriverInfo; - GRAPHICS_DRIVER *Driver = DriverList; NTSTATUS Status; LPWSTR FullName; LPCWSTR p; @@ -152,22 +152,26 @@ PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name) } /* First see if the driver hasn't already been loaded */ - while (Driver && FullName) + ExistingDriver = DRIVER_FindExistingDDIDriver(FullName); + if (ExistingDriver) { - if (!_wcsicmp( Driver->Name, FullName)) - { - return Driver->EnableDriver; - } - Driver = Driver->Next; + ExFreePool(FullName); + return ExistingDriver; } /* If not, then load it */ RtlInitUnicodeString (&GdiDriverInfo.DriverName, FullName); Status = ZwSetSystemInformation (SystemLoadGdiDriverInformation, &GdiDriverInfo, sizeof(SYSTEM_GDI_DRIVER_INFORMATION)); - ExFreePool(FullName); - if (!NT_SUCCESS(Status)) return NULL; + + if (!NT_SUCCESS(Status)) + { + ExFreePool(FullName); + return NULL; + } DRIVER_RegisterDriver( L"DISPLAY", GdiDriverInfo.EntryPoint); + DRIVER_RegisterDriver( FullName, GdiDriverInfo.EntryPoint); + ExFreePool(FullName); return (PGD_ENABLEDRIVER)GdiDriverInfo.EntryPoint; } diff --git a/reactos/subsystems/win32/win32k/ntuser/winsta.c b/reactos/subsystems/win32/win32k/ntuser/winsta.c index 478432788af..220e4923fd3 100644 --- a/reactos/subsystems/win32/win32k/ntuser/winsta.c +++ b/reactos/subsystems/win32/win32k/ntuser/winsta.c @@ -293,12 +293,11 @@ IntGetWindowStationObject(PWINSTATION_OBJECT Object) BOOL FASTCALL co_IntInitializeDesktopGraphics(VOID) { - UNICODE_STRING DriverName; + UNICODE_STRING DriverName = RTL_CONSTANT_STRING(L"DISPLAY"); if (! IntCreatePrimarySurface()) { return FALSE; } - RtlInitUnicodeString(&DriverName, L"DISPLAY"); ScreenDeviceContext = IntGdiCreateDC(&DriverName, NULL, NULL, NULL, FALSE); if (NULL == ScreenDeviceContext) { diff --git a/reactos/subsystems/win32/win32k/objects/dc.c b/reactos/subsystems/win32/win32k/objects/dc.c index 5019f37b68c..f3454397814 100644 --- a/reactos/subsystems/win32/win32k/objects/dc.c +++ b/reactos/subsystems/win32/win32k/objects/dc.c @@ -530,17 +530,18 @@ IntPrepareDriver() } } - RtlFreeUnicodeString(&DriverFileNames); - if (!GotDriver) { ObDereferenceObject(PrimarySurface.VideoFileObject); + RtlFreeUnicodeString(&DriverFileNames); DPRINT1("No suitable DDI driver found\n"); continue; } DPRINT("Display driver %S loaded\n", CurrentName); + RtlFreeUnicodeString(&DriverFileNames); + DPRINT("Building DDI Functions\n"); /* Construct DDI driver function dispatch table */ @@ -800,6 +801,8 @@ IntDestroyPrimarySurface() PrimarySurface.DriverFunctions.DisableSurface(PrimarySurface.PDev); PrimarySurface.DriverFunctions.DisablePDEV(PrimarySurface.PDev); PrimarySurface.PreparedDriver = FALSE; + KeSetEvent(&VideoDriverNeedsPreparation, 1, FALSE); + KeResetEvent(&VideoDriverPrepared); DceEmptyCache();