diff --git a/reactos/subsystems/win32/win32k/eng/device.c b/reactos/subsystems/win32/win32k/eng/device.c index 600ab6463fc..93afb133e78 100644 --- a/reactos/subsystems/win32/win32k/eng/device.c +++ b/reactos/subsystems/win32/win32k/eng/device.c @@ -4,8 +4,7 @@ * PURPOSE: GDI Driver Device Functions * FILE: subsys/win32k/eng/device.c * PROGRAMER: Jason Filby - * REVISION HISTORY: - * 3/7/1999: Created + * Timo Kreuzer */ #include @@ -13,6 +12,138 @@ #define NDEBUG #include +static +DWORD +EngpFileIoRequest( + PFILE_OBJECT pFileObject, + ULONG ulMajorFunction, + LPVOID lpBuffer, + DWORD nBufferSize, + ULONGLONG ullStartOffset, + OUT LPDWORD lpInformation) +{ + PDEVICE_OBJECT pDeviceObject; + KEVENT Event; + PIRP pIrp; + IO_STATUS_BLOCK Iosb; + NTSTATUS Status; + LARGE_INTEGER liStartOffset; + + /* Get corresponding device object */ + pDeviceObject = IoGetRelatedDeviceObject(pFileObject); + if (!pDeviceObject) + { + return STATUS_INVALID_PARAMETER; + } + + /* Initialize an event */ + KeInitializeEvent(&Event, SynchronizationEvent, FALSE); + + /* Build IPR */ + liStartOffset.QuadPart = ullStartOffset; + pIrp = IoBuildSynchronousFsdRequest(ulMajorFunction, + pDeviceObject, + lpBuffer, + nBufferSize, + &liStartOffset, + &Event, + &Iosb); + if (!pIrp) + { + return FALSE; + } + + /* Call the driver */ + Status = IoCallDriver(pDeviceObject, pIrp); + + /* Wait if neccessary */ + if (STATUS_PENDING == Status) + { + KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0); + Status = Iosb.Status; + } + + /* Return information to the caller about the operation. */ + *lpInformation = Iosb.Information; + + return NT_SUCCESS(Status); +} + +VOID +APIENTRY +EngFileWrite( + IN PFILE_OBJECT pFileObject, + IN PVOID lpBuffer, + IN SIZE_T nLength, + IN PSIZE_T lpBytesWritten) +{ + EngpFileIoRequest(pFileObject, + IRP_MJ_WRITE, + lpBuffer, + nLength, + 0, + lpBytesWritten); +} + +NTSTATUS +APIENTRY +EngFileIoControl( + IN PFILE_OBJECT pFileObject, + IN DWORD dwIoControlCode, + IN PVOID lpInBuffer, + IN SIZE_T nInBufferSize, + OUT PVOID lpOutBuffer, + IN SIZE_T nOutBufferSize, + OUT LPDWORD lpInformation) +{ + PDEVICE_OBJECT pDeviceObject; + KEVENT Event; + PIRP pIrp; + IO_STATUS_BLOCK Iosb; + NTSTATUS Status; + + /* Get corresponding device object */ + pDeviceObject = IoGetRelatedDeviceObject(pFileObject); + if (!pDeviceObject) + { + return STATUS_INVALID_PARAMETER; + } + + /* Initialize an event */ + KeInitializeEvent(&Event, SynchronizationEvent, FALSE); + + /* Build IO control IPR */ + pIrp = IoBuildDeviceIoControlRequest(dwIoControlCode, + pDeviceObject, + lpInBuffer, + nInBufferSize, + lpOutBuffer, + nOutBufferSize, + FALSE, + &Event, + &Iosb); + if (!pIrp) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Call the driver */ + Status = IoCallDriver(pDeviceObject, pIrp); + + /* Wait if neccessary */ + if (Status == STATUS_PENDING) + { + KeWaitForSingleObject(&Event, Executive, KernelMode, TRUE, 0); + Status = Iosb.Status; + } + + /* Return information to the caller about the operation. */ + *lpInformation = Iosb.Information; + + /* This function returns NTSTATUS */ + return Status; +} + /* * @implemented */ diff --git a/reactos/subsystems/win32/win32k/stubs/stubs.c b/reactos/subsystems/win32/win32k/stubs/stubs.c index 42f09f6d0b7..0b8a9a84a4d 100644 --- a/reactos/subsystems/win32/win32k/stubs/stubs.c +++ b/reactos/subsystems/win32/win32k/stubs/stubs.c @@ -2796,29 +2796,6 @@ EngAllocSectionMem(IN PVOID SectionObject, return NULL; } -NTSTATUS -APIENTRY -EngFileIoControl(IN PFILE_OBJECT FileObject, - IN ULONG IoControlCode, - IN PVOID InputBuffer, - IN SIZE_T InputBufferLength, - OUT PVOID OutputBuffer, - IN SIZE_T OutputBufferLength, - OUT PULONG Information) -{ - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -} - -VOID -APIENTRY -EngFileWrite(IN PFILE_OBJECT FileObject, - IN PVOID Buffer, - IN SIZE_T Length, - IN PSIZE_T BytesWritten) -{ - UNIMPLEMENTED; -} BOOLEAN APIENTRY