mirror of
https://github.com/reactos/reactos.git
synced 2024-09-29 05:54:05 +00:00
Pass pointer to device object as the "handle" to DrvEnablePDEV since
some badly written drivers need it svn path=/trunk/; revision=6536
This commit is contained in:
parent
b2a4140643
commit
49f2b1905a
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: debug.c,v 1.5 2003/07/11 15:59:37 royce Exp $
|
||||
/* $Id: debug.c,v 1.6 2003/11/05 22:46:05 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -39,6 +39,5 @@ EngDebugPrint(PCHAR StandardPrefix,
|
|||
{
|
||||
DbgPrint(StandardPrefix);
|
||||
DbgPrint(DebugMessage, ap);
|
||||
DbgPrint("\n");
|
||||
}
|
||||
/* EOF */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
/* $Id: device.c,v 1.11 2003/08/19 11:48:49 weiden Exp $
|
||||
/* $Id: device.c,v 1.12 2003/11/05 22:46:05 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -49,52 +49,29 @@ EngDeviceIoControl(HANDLE hDevice,
|
|||
NTSTATUS Status;
|
||||
KEVENT Event;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
PFILE_OBJECT FileObject;
|
||||
PEPROCESS CurrentProcess;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
|
||||
DPRINT("EngDeviceIoControl() called\n");
|
||||
|
||||
KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
|
||||
|
||||
CurrentProcess = PsGetCurrentProcess();
|
||||
if (CurrentProcess != Win32kDeviceProcess)
|
||||
{
|
||||
/* Switch to process context in which hDevice is valid */
|
||||
KeAttachProcess(Win32kDeviceProcess);
|
||||
}
|
||||
|
||||
Status = ObReferenceObjectByHandle(hDevice,
|
||||
FILE_READ_DATA | FILE_WRITE_DATA,
|
||||
IoFileObjectType,
|
||||
KernelMode,
|
||||
(PVOID *)&FileObject,
|
||||
NULL);
|
||||
if (CurrentProcess != Win32kDeviceProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
DeviceObject = (PDEVICE_OBJECT) hDevice;
|
||||
|
||||
Irp = IoBuildDeviceIoControlRequest(dwIoControlCode,
|
||||
FileObject->DeviceObject,
|
||||
DeviceObject,
|
||||
lpInBuffer,
|
||||
nInBufferSize,
|
||||
lpOutBuffer,
|
||||
nOutBufferSize, FALSE, &Event, &Iosb);
|
||||
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
(void) KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0);
|
||||
}
|
||||
|
||||
ObDereferenceObject(FileObject);
|
||||
{
|
||||
(void) KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* 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.94 2003/10/30 18:27:33 gvg Exp $
|
||||
/* $Id: dc.c,v 1.95 2003/11/05 22:46:05 gvg Exp $
|
||||
*
|
||||
* DC.C - Device context functions
|
||||
*
|
||||
|
@ -192,7 +192,7 @@ NtGdiCreateCompatableDC(HDC hDC)
|
|||
/* DriverName is copied in the AllocDC routine */
|
||||
if(OrigDC == NULL)
|
||||
{
|
||||
NewDC->DeviceDriver = DRIVER_FindMPDriver(NewDC->DriverName);
|
||||
NewDC->DeviceDriver = PrimarySurface.DisplayDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ GetRegistryPath(PUNICODE_STRING RegistryPath)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT("RegistryPath %S\n", RegistryPath.Buffer);
|
||||
DPRINT("RegistryPath %S\n", RegistryPath->Buffer);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -501,6 +501,9 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
|
|||
PWSTR CurrentName;
|
||||
BOOL GotDriver;
|
||||
BOOL DoDefault;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PEPROCESS CurrentProcess;
|
||||
extern void FASTCALL IntInitDesktopWindow(ULONG Width, ULONG Height);
|
||||
|
||||
/* Open the miniport driver */
|
||||
|
@ -582,6 +585,31 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
CurrentProcess = PsGetCurrentProcess();
|
||||
if (CurrentProcess != Win32kDeviceProcess)
|
||||
{
|
||||
/* Switch to process context in which device handle is valid */
|
||||
KeAttachProcess(Win32kDeviceProcess);
|
||||
}
|
||||
|
||||
Status = ObReferenceObjectByHandle(PrimarySurface.DisplayDevice,
|
||||
FILE_READ_DATA | FILE_WRITE_DATA,
|
||||
IoFileObjectType,
|
||||
KernelMode,
|
||||
(PVOID *)&FileObject,
|
||||
NULL);
|
||||
if (CurrentProcess != Win32kDeviceProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CloseMiniport();
|
||||
DPRINT1("Referencing miniport device failed with status 0x%08x\n", Status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Allocate a phyical device handle from the driver */
|
||||
if (SetupDevMode(&PrimarySurface.DMW))
|
||||
{
|
||||
|
@ -596,7 +624,7 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
|
|||
&PrimarySurface.DevInfo,
|
||||
NULL,
|
||||
L"",
|
||||
PrimarySurface.DisplayDevice);
|
||||
(HANDLE) (FileObject->DeviceObject));
|
||||
DoDefault = (NULL == PrimarySurface.PDev);
|
||||
if (DoDefault)
|
||||
{
|
||||
|
@ -622,10 +650,11 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
|
|||
&PrimarySurface.DevInfo,
|
||||
NULL,
|
||||
L"",
|
||||
PrimarySurface.DisplayDevice);
|
||||
(HANDLE) (FileObject->DeviceObject));
|
||||
|
||||
if (NULL == PrimarySurface.PDev)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
CloseMiniport();
|
||||
DPRINT1("DrvEnablePDEV with default parameters failed\n");
|
||||
DPRINT1("Perhaps DDI driver doesn't match miniport driver?\n");
|
||||
|
@ -662,6 +691,7 @@ NtGdiCreatePrimarySurface(LPCWSTR Driver,
|
|||
PrimarySurface.DriverFunctions.EnableSurface(PrimarySurface.PDev);
|
||||
if (NULL == PrimarySurface.Handle)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
CloseMiniport();
|
||||
DPRINT1("DrvEnableSurface failed\n");
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in a new issue