*** empty log message ***
[reactos.git] / reactos / subsys / win32k / eng / device.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: GDI Driver Device Functions
5 * FILE: subsys/win32k/eng/device.c
6 * PROGRAMER: Jason Filby
7 * REVISION HISTORY:
8 * 3/7/1999: Created
9 */
10
11 #include <ddk/ntddk.h>
12
13 DWORD APIENTRY EngDeviceIoControl(
14 HANDLE hDevice,
15 DWORD dwIoControlCode,
16 LPVOID lpInBuffer,
17 DWORD nInBufferSize,
18 LPVOID lpOutBuffer,
19 DWORD nOutBufferSize,
20 DWORD *lpBytesReturned)
21 {
22 PIRP Irp;
23 NTSTATUS Status;
24 KEVENT Event;
25 IO_STATUS_BLOCK Iosb;
26 PDEVICE_OBJECT theDevice;
27
28 ObReferenceObjectByHandle(hDevice, GENERIC_ALL, NULL, UserMode,
29 (PVOID *)&theDevice, NULL);
30
31 KeInitializeEvent(&Event, SynchronizationEvent, FALSE);
32
33 Irp = IoBuildDeviceIoControlRequest(dwIoControlCode,
34 theDevice,
35 lpInBuffer,
36 nInBufferSize,
37 lpOutBuffer,
38 nOutBufferSize,
39 FALSE,
40 &Event,
41 &Iosb);
42
43 Status = IoCallDriver(theDevice, Irp);
44
45 if (Status == STATUS_PENDING)
46 {
47 (void) KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0);
48 }
49
50 return (Status);
51 }