* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: driver.c,v 1.28 2003/08/19 11:48:49 weiden Exp $
+/* $Id: driver.c,v 1.29 2003/10/24 08:22:29 gvg Exp $
*
* GDI Driver support routines
* (mostly swiped from Wine)
if (!NT_SUCCESS(Status))
{
- DPRINT("ZwOpenFile() failed (Status %lx)\n", Status);
+ DPRINT1("Unable to connect to miniport (Status %lx)\n", Status);
+ DPRINT1("Perhaps the miniport wasn't loaded?\n");
return(NULL);
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-/* $Id: dc.c,v 1.89 2003/10/20 17:57:05 gvg Exp $
+/* $Id: dc.c,v 1.90 2003/10/24 08:22:29 gvg Exp $
*
* DC.C - Device context functions
*
if (hDC == NULL)
{
+ if (! PrimarySurfaceCreated)
+ {
+ DPRINT1("Can't create compatible DC because initialization of primary surface failed\n");
+ return NULL;
+ }
OrigDC = NULL;
hNewDC = DC_AllocDC(L"DISPLAY");
}
return TRUE;
}
+static void FASTCALL
+CloseMiniport()
+{
+ PEPROCESS CurrentProcess;
+
+ CurrentProcess = PsGetCurrentProcess();
+ if (CurrentProcess != Win32kDeviceProcess)
+ {
+ KeAttachProcess(Win32kDeviceProcess);
+ }
+ ZwClose(PrimarySurface.DisplayDevice);
+ if (CurrentProcess != Win32kDeviceProcess)
+ {
+ KeDetachProcess();
+ }
+}
BOOL STDCALL
NtGdiCreatePrimarySurface(LPCWSTR Driver,
/* Open the miniport driver */
if ((PrimarySurface.DisplayDevice = DRIVER_FindMPDriver(Driver)) == NULL)
{
- DPRINT("FindMPDriver failed\n");
+ DPRINT1("FindMPDriver failed\n");
return(FALSE);
}
RtlInitUnicodeString(&DriverFileNames, NULL);
if (! FindDriverFileNames(&DriverFileNames))
{
- DPRINT("FindDriverFileNames failed\n");
+ DPRINT1("FindDriverFileNames failed\n");
return(FALSE);
}
RtlFreeUnicodeString(&DriverFileNames);
if (! GotDriver)
{
- DPRINT("No suitable driver found\n");
+ CloseMiniport();
+ DPRINT1("No suitable DDI driver found\n");
return FALSE;
}
/* Construct DDI driver function dispatch table */
if (!DRIVER_BuildDDIFunctions(&DED, &PrimarySurface.DriverFunctions))
{
- DPRINT("BuildDDIFunctions failed\n");
+ CloseMiniport();
+ DPRINT1("BuildDDIFunctions failed\n");
return(FALSE);
}
PrimarySurface.DisplayDevice);
if (PrimarySurface.PDev == NULL)
{
- DPRINT("DrvEnablePDEV failed\n");
+ CloseMiniport();
+ DPRINT1("DrvEnablePDEV failed\n");
+ DPRINT1("Perhaps DDI driver doesn't match miniport driver?\n");
return(FALSE);
}
/* Enable the drawing surface */
PrimarySurface.Handle =
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
+ if (NULL == PrimarySurface.Handle)
+ {
+ CloseMiniport();
+ DPRINT1("DrvEnableSurface failed\n");
+ return FALSE;
+ }
SurfObj = (PSURFOBJ)AccessUserObject((ULONG) PrimarySurface.Handle);
SurfObj->dhpdev = PrimarySurface.PDev;
{
if (!DRIVER_UnreferenceDriver (DCToDelete->DriverName))
{
- PEPROCESS CurrentProcess;
DPRINT( "No more references to driver, reseting display\n" );
DCToDelete->DriverFunctions.AssertMode( DCToDelete->PDev, FALSE );
CHECKPOINT;
CHECKPOINT;
DCToDelete->DriverFunctions.DisablePDev(DCToDelete->PDev);
- CurrentProcess = PsGetCurrentProcess();
- if (CurrentProcess != Win32kDeviceProcess)
- {
- KeAttachProcess(Win32kDeviceProcess);
- }
- ZwClose(PrimarySurface.DisplayDevice);
- if (CurrentProcess != Win32kDeviceProcess)
- {
- KeDetachProcess();
- }
+ CloseMiniport();
PrimarySurfaceCreated = FALSE;
}