Author: hpoussin Date: Mon Oct 29 17:47:48 2007 New Revision: 29955
URL: http://svn.reactos.org/svn/reactos?rev=29955&view=rev Log: Don't crash when starting a 2nd GUI application when booted in console mode
Modified: trunk/reactos/subsystems/win32/win32k/misc/driver.c trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c trunk/reactos/subsystems/win32/win32k/objects/dc.c
Modified: trunk/reactos/subsystems/win32/win32k/misc/driver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/mis... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/misc/driver.c (original) +++ trunk/reactos/subsystems/win32/win32k/misc/driver.c Mon Oct 29 17:47:48 2007 @@ -96,8 +96,8 @@ { 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 @@ }
/* First see if the driver hasn't already been loaded */ - while (Driver && FullName) - { - if (!_wcsicmp( Driver->Name, FullName)) - { - return Driver->EnableDriver; - } - Driver = Driver->Next; + ExistingDriver = DRIVER_FindExistingDDIDriver(FullName); + if (ExistingDriver) + { + ExFreePool(FullName); + return ExistingDriver; }
/* If not, then load it */ RtlInitUnicodeString (&GdiDriverInfo.DriverName, FullName); Status = ZwSetSystemInformation (SystemLoadGdiDriverInformation, &GdiDriverInfo, sizeof(SYSTEM_GDI_DRIVER_INFORMATION)); + + if (!NT_SUCCESS(Status)) + { + ExFreePool(FullName); + return NULL; + } + + DRIVER_RegisterDriver( L"DISPLAY", GdiDriverInfo.EntryPoint); + DRIVER_RegisterDriver( FullName, GdiDriverInfo.EntryPoint); ExFreePool(FullName); - if (!NT_SUCCESS(Status)) return NULL; - - DRIVER_RegisterDriver( L"DISPLAY", GdiDriverInfo.EntryPoint); return (PGD_ENABLEDRIVER)GdiDriverInfo.EntryPoint; }
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/winsta.c Mon Oct 29 17:47:48 2007 @@ -293,12 +293,11 @@ 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) {
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/dc.c (original) +++ trunk/reactos/subsystems/win32/win32k/objects/dc.c Mon Oct 29 17:47:48 2007 @@ -530,16 +530,17 @@ } }
- 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");
@@ -800,6 +801,8 @@ PrimarySurface.DriverFunctions.DisableSurface(PrimarySurface.PDev); PrimarySurface.DriverFunctions.DisablePDEV(PrimarySurface.PDev); PrimarySurface.PreparedDriver = FALSE; + KeSetEvent(&VideoDriverNeedsPreparation, 1, FALSE); + KeResetEvent(&VideoDriverPrepared);
DceEmptyCache();