Author: hpoussin
Date: Wed May 31 18:26:56 2006
New Revision: 22126
URL:
http://svn.reactos.ru/svn/reactos?rev=22126&view=rev
Log:
Fix BSOD in IntPrepareDriver (bug 1321)
Modified:
trunk/reactos/subsystems/win32/win32k/include/dc.h
trunk/reactos/subsystems/win32/win32k/main/dllmain.c
trunk/reactos/subsystems/win32/win32k/objects/dc.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dc.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/include/dc.h (original)
+++ trunk/reactos/subsystems/win32/win32k/include/dc.h Wed May 31 18:26:56 2006
@@ -170,6 +170,7 @@
#define DC_UnlockDc(pDC) \
GDIOBJ_UnlockObjByPtr (GdiHandleTable, pDC)
+NTSTATUS FASTCALL InitDcImpl(VOID);
HDC FASTCALL RetrieveDisplayHDC(VOID);
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_InitDC(HDC DCToInit);
Modified: trunk/reactos/subsystems/win32/win32k/main/dllmain.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/subsystems/win32/win32k/mai…
==============================================================================
--- trunk/reactos/subsystems/win32/win32k/main/dllmain.c (original)
+++ trunk/reactos/subsystems/win32/win32k/main/dllmain.c Wed May 31 18:26:56 2006
@@ -500,6 +500,13 @@
return STATUS_UNSUCCESSFUL;
}
+ Status = InitDcImpl();
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to initialize Device context implementation!\n");
+ return STATUS_UNSUCCESSFUL;
+ }
+
/* Initialize FreeType library */
if (! InitFontSupport())
{
Modified: trunk/reactos/subsystems/win32/win32k/objects/dc.c
URL:
http://svn.reactos.ru/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 Wed May 31 18:26:56 2006
@@ -41,6 +41,17 @@
#endif
static GDIDEVICE PrimarySurface;
+static KEVENT VideoDriverNeedsPreparation;
+static KEVENT VideoDriverPrepared;
+
+
+NTSTATUS FASTCALL
+InitDcImpl(VOID)
+{
+ KeInitializeEvent(&VideoDriverNeedsPreparation, SynchronizationEvent, TRUE);
+ KeInitializeEvent(&VideoDriverPrepared, NotificationEvent, FALSE);
+ return STATUS_SUCCESS;
+}
/* FIXME: DCs should probably be thread safe */
@@ -489,6 +500,17 @@
BOOL GotDriver;
BOOL DoDefault;
ULONG DisplayNumber;
+ LARGE_INTEGER Zero;
+ BOOLEAN ret = FALSE;
+
+ Zero.QuadPart = 0;
+ if (STATUS_SUCCESS != KeWaitForSingleObject(&VideoDriverNeedsPreparation,
Executive, KernelMode, TRUE, &Zero))
+ {
+ /* Concurrent access. Wait for VideoDriverPrepared event */
+ if (STATUS_SUCCESS == KeWaitForSingleObject(&VideoDriverPrepared, Executive,
KernelMode, TRUE, NULL))
+ ret = PrimarySurface.PreparedDriver;
+ goto cleanup;
+ }
for (DisplayNumber = 0; ; DisplayNumber++)
{
@@ -502,7 +524,7 @@
if (PrimarySurface.VideoFileObject == NULL)
{
DPRINT1("FindMPDriver failed\n");
- return FALSE;
+ goto cleanup;
}
/* Retrieve DDI driver names from registry */
@@ -576,7 +598,7 @@
{
ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("BuildDDIFunctions failed\n");
- return FALSE;
+ goto cleanup;
}
/* Allocate a phyical device handle from the driver */
@@ -659,10 +681,13 @@
PrimarySurface.PreparedDriver = TRUE;
PrimarySurface.DisplayNumber = DisplayNumber;
- return TRUE;
+ ret = TRUE;
+ goto cleanup;
}
- return FALSE;
+cleanup:
+ KeSetEvent(&VideoDriverPrepared, 1, FALSE);
+ return ret;
}
static BOOL FASTCALL