/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
+#include <internal/io.h>
-#define NDEBUG
+//#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
-NTSTATUS NtQueryInformationFile(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass)
+NTSTATUS STDCALL NtQueryInformationFile(HANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ PVOID FileInformation,
+ ULONG Length,
+ FILE_INFORMATION_CLASS FileInformationClass)
{
return ZwQueryInformationFile(FileHandle,
IoStatusBlock,
FileInformationClass);
}
-NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
- PIO_STATUS_BLOCK IoStatusBlock,
- PVOID FileInformation,
- ULONG Length,
- FILE_INFORMATION_CLASS FileInformationClass)
+NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
+ PIO_STATUS_BLOCK IoStatusBlock,
+ PVOID FileInformation,
+ ULONG Length,
+ FILE_INFORMATION_CLASS FileInformationClass)
{
NTSTATUS Status;
PFILE_OBJECT FileObject;
/* Get the file object from the file handle */
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_ATTRIBUTES,
- NULL,
+ IoFileType,
UserMode,
(PVOID *) &FileObject,
NULL);
- if (Status != STATUS_SUCCESS)
+ if (!NT_SUCCESS(Status))
{
return Status;
}
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass)
{
- UNIMPLEMENTED;
+ NTSTATUS Status;
+ PFILE_OBJECT FileObject;
+ PIRP Irp;
+ PIO_STACK_LOCATION StackPtr;
+ KEVENT Event;
+
+ DPRINT("ZwSetInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
+ FileHandle,
+ IoStatusBlock,
+ FileInformation,
+ Length,
+ FileInformationClass);
+
+ /* Get the file object from the file handle */
+ Status = ObReferenceObjectByHandle(FileHandle,
+ FILE_WRITE_ATTRIBUTES,
+ IoFileType,
+ UserMode,
+ (PVOID *) &FileObject,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ DPRINT("FileObject %x\n", FileObject);
+
+ /* initialize an event object to wait on for the request */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* build the IRP to be sent to the driver for the request */
+ Irp = IoBuildSynchronousFsdRequest(IRP_MJ_SET_INFORMATION,
+ FileObject->DeviceObject,
+ FileInformation,
+ Length,
+ 0,
+ &Event,
+ IoStatusBlock);
+ StackPtr = IoGetNextIrpStackLocation(Irp);
+ StackPtr->FileObject = FileObject;
+ StackPtr->Parameters.SetFile.Length = Length;
+ StackPtr->Parameters.SetFile.FileInformationClass = FileInformationClass;
+
+ /* Pass the IRP to the FSD (and wait for it if required) */
+ DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
+ Status = IoCallDriver(FileObject->DeviceObject, Irp);
+ if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
+ {
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ Status = Irp->IoStatus.Status;
+ }
+
+ return Status;
}
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID)