Keep reference to display file open

svn path=/trunk/; revision=6963
This commit is contained in:
Gé van Geldorp 2003-12-12 12:53:10 +00:00
parent a754cb4e7f
commit 49546dc5fc
4 changed files with 15 additions and 21 deletions

View file

@ -114,7 +114,7 @@ typedef struct
GDIINFO GDIInfo; GDIINFO GDIInfo;
DEVINFO DevInfo; DEVINFO DevInfo;
DRIVER_FUNCTIONS DriverFunctions; DRIVER_FUNCTIONS DriverFunctions;
PDEVICE_OBJECT VideoDeviceObject; PFILE_OBJECT VideoFileObject;
} GDIDEVICE; } GDIDEVICE;
/* Internal functions */ /* Internal functions */

View file

@ -160,7 +160,7 @@ typedef struct _DRIVER_FUNCTIONS
BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver); BOOL DRIVER_RegisterDriver(LPCWSTR Name, PGD_ENABLEDRIVER EnableDriver);
PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name); PGD_ENABLEDRIVER DRIVER_FindDDIDriver(LPCWSTR Name);
PDEVICE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name); PFILE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name);
BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED, BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED,
PDRIVER_FUNCTIONS DF); PDRIVER_FUNCTIONS DF);
BOOL DRIVER_UnregisterDriver(LPCWSTR Name); BOOL DRIVER_UnregisterDriver(LPCWSTR Name);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: driver.c,v 1.32 2003/11/17 02:12:52 hyperion Exp $ /* $Id: driver.c,v 1.33 2003/12/12 12:53:10 gvg Exp $
* *
* GDI Driver support routines * GDI Driver support routines
* (mostly swiped from Wine) * (mostly swiped from Wine)
@ -236,7 +236,7 @@ BOOL DRIVER_BuildDDIFunctions(PDRVENABLEDATA DED,
typedef VP_STATUS (*PMP_DRIVERENTRY)(PVOID, PVOID); typedef VP_STATUS (*PMP_DRIVERENTRY)(PVOID, PVOID);
PDEVICE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name) PFILE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
@ -244,8 +244,8 @@ PDEVICE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name)
HANDLE DisplayHandle; HANDLE DisplayHandle;
NTSTATUS Status; NTSTATUS Status;
PFILE_OBJECT VideoFileObject; PFILE_OBJECT VideoFileObject;
PDEVICE_OBJECT VideoDeviceObject;
__asm__("int $3\n");
RtlRosInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1"); RtlRosInitUnicodeStringFromLiteral(&DeviceName, L"\\??\\DISPLAY1");
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&DeviceName, &DeviceName,
@ -266,12 +266,6 @@ PDEVICE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name)
KernelMode, KernelMode,
(PVOID *)&VideoFileObject, (PVOID *)&VideoFileObject,
NULL); NULL);
if (NT_SUCCESS(Status))
{
VideoDeviceObject = VideoFileObject->DeviceObject;
ObReferenceObject(VideoDeviceObject);
ObDereferenceObject(VideoFileObject);
}
ZwClose(DisplayHandle); ZwClose(DisplayHandle);
} }
@ -282,7 +276,7 @@ PDEVICE_OBJECT DRIVER_FindMPDriver(LPCWSTR Name)
return(NULL); return(NULL);
} }
return VideoDeviceObject; return VideoFileObject;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dc.c,v 1.108 2003/12/07 23:02:57 gvg Exp $ /* $Id: dc.c,v 1.109 2003/12/12 12:53:10 gvg Exp $
* *
* DC.C - Device context functions * DC.C - Device context functions
* *
@ -472,7 +472,7 @@ IntCreatePrimarySurface()
BOOL DoDefault; BOOL DoDefault;
/* Open the miniport driver */ /* Open the miniport driver */
if ((PrimarySurface.VideoDeviceObject = DRIVER_FindMPDriver(L"DISPLAY")) == NULL) if ((PrimarySurface.VideoFileObject = DRIVER_FindMPDriver(L"DISPLAY")) == NULL)
{ {
DPRINT1("FindMPDriver failed\n"); DPRINT1("FindMPDriver failed\n");
return FALSE; return FALSE;
@ -530,7 +530,7 @@ IntCreatePrimarySurface()
RtlFreeUnicodeString(&DriverFileNames); RtlFreeUnicodeString(&DriverFileNames);
if (! GotDriver) if (! GotDriver)
{ {
ObDereferenceObject(PrimarySurface.VideoDeviceObject); ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("No suitable DDI driver found\n"); DPRINT1("No suitable DDI driver found\n");
return FALSE; return FALSE;
} }
@ -545,7 +545,7 @@ IntCreatePrimarySurface()
/* Construct DDI driver function dispatch table */ /* Construct DDI driver function dispatch table */
if (! DRIVER_BuildDDIFunctions(&DED, &PrimarySurface.DriverFunctions)) if (! DRIVER_BuildDDIFunctions(&DED, &PrimarySurface.DriverFunctions))
{ {
ObDereferenceObject(PrimarySurface.VideoDeviceObject); ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("BuildDDIFunctions failed\n"); DPRINT1("BuildDDIFunctions failed\n");
return FALSE; return FALSE;
} }
@ -564,7 +564,7 @@ IntCreatePrimarySurface()
&PrimarySurface.DevInfo, &PrimarySurface.DevInfo,
NULL, NULL,
L"", L"",
(HANDLE) (PrimarySurface.VideoDeviceObject)); (HANDLE) (PrimarySurface.VideoFileObject->DeviceObject));
DoDefault = (NULL == PrimarySurface.PDev); DoDefault = (NULL == PrimarySurface.PDev);
if (DoDefault) if (DoDefault)
{ {
@ -590,11 +590,11 @@ IntCreatePrimarySurface()
&PrimarySurface.DevInfo, &PrimarySurface.DevInfo,
NULL, NULL,
L"", L"",
(HANDLE) (PrimarySurface.VideoDeviceObject)); (HANDLE) (PrimarySurface.VideoFileObject->DeviceObject));
if (NULL == PrimarySurface.PDev) if (NULL == PrimarySurface.PDev)
{ {
ObDereferenceObject(PrimarySurface.VideoDeviceObject); ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("DrvEnablePDEV with default parameters failed\n"); DPRINT1("DrvEnablePDEV with default parameters failed\n");
DPRINT1("Perhaps DDI driver doesn't match miniport driver?\n"); DPRINT1("Perhaps DDI driver doesn't match miniport driver?\n");
return FALSE; return FALSE;
@ -629,7 +629,7 @@ IntCreatePrimarySurface()
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev); PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
if (NULL == PrimarySurface.Handle) if (NULL == PrimarySurface.Handle)
{ {
ObDereferenceObject(PrimarySurface.VideoDeviceObject); ObDereferenceObject(PrimarySurface.VideoFileObject);
DPRINT1("DrvEnableSurface failed\n"); DPRINT1("DrvEnableSurface failed\n");
return FALSE; return FALSE;
} }
@ -656,7 +656,7 @@ IntDestroyPrimarySurface()
DceEmptyCache(); DceEmptyCache();
ObDereferenceObject(PrimarySurface.VideoDeviceObject); ObDereferenceObject(PrimarySurface.VideoFileObject);
} }
HDC STDCALL HDC STDCALL