Fixed direct reference to a driver object.

svn path=/trunk/; revision=3080
This commit is contained in:
Eric Kohl 2002-06-14 14:24:28 +00:00
parent 01b92c6de5
commit 260116f684

View file

@ -10,29 +10,47 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
DWORD STDCALL EngDeviceIoControl( #define NDEBUG
HANDLE hDevice, #include <debug.h>
DWORD dwIoControlCode,
LPVOID lpInBuffer, DWORD STDCALL
DWORD nInBufferSize, EngDeviceIoControl(HANDLE hDevice,
LPVOID lpOutBuffer, DWORD dwIoControlCode,
DWORD nOutBufferSize, LPVOID lpInBuffer,
DWORD *lpBytesReturned) DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
DWORD *lpBytesReturned)
{ {
PIRP Irp; PIRP Irp;
NTSTATUS Status; NTSTATUS Status;
KEVENT Event; KEVENT Event;
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
PDRIVER_OBJECT DriverObject; PFILE_OBJECT FileObject;
DriverObject = hDevice; DPRINT("EngDeviceIoControl() called\n");
KeInitializeEvent(&Event, SynchronizationEvent, FALSE); KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
Irp = IoBuildDeviceIoControlRequest(dwIoControlCode, DriverObject->DeviceObject, lpInBuffer, nInBufferSize, Status = ObReferenceObjectByHandle(hDevice,
lpOutBuffer, nOutBufferSize, FALSE, &Event, &Iosb); FILE_READ_DATA | FILE_WRITE_DATA,
IoFileObjectType,
KernelMode,
(PVOID *)&FileObject,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
Status = IoCallDriver(DriverObject->DeviceObject, Irp); Irp = IoBuildDeviceIoControlRequest(dwIoControlCode,
FileObject->DeviceObject,
lpInBuffer,
nInBufferSize,
lpOutBuffer,
nOutBufferSize, FALSE, &Event, &Iosb);
Status = IoCallDriver(FileObject->DeviceObject, Irp);
if (Status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {