Don't crash when starting a 2nd GUI application when booted in console mode

svn path=/trunk/; revision=29955
This commit is contained in:
Hervé Poussineau 2007-10-29 14:47:48 +00:00
parent babcc56c4a
commit 2b88e1ebf0
3 changed files with 19 additions and 13 deletions

View file

@ -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;
}

View file

@ -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)
{

View file

@ -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();