fixed GetFileAttributes()

svn path=/trunk/; revision=404
This commit is contained in:
Eric Kohl 1999-04-21 19:16:31 +00:00
parent 73a193b7fe
commit 36322cffcd
4 changed files with 91 additions and 53 deletions

View file

@ -1609,7 +1609,26 @@ NTSTATUS FsdGetPositionInformation(PFILE_OBJECT FileObject,
PositionInfo->CurrentByteOffset));
return(STATUS_SUCCESS);
}
NTSTATUS FsdGetBasicInformation(PFILE_OBJECT FileObject,
PVfatFCB FCB,
PDEVICE_OBJECT DeviceObject,
PFILE_BASIC_INFORMATION BasicInfo)
{
DPRINT("FsdGetBasicInformation()\n");
// BasicInfo->CreationTime =
// BasicInfo->LastAccessTime =
// BasicInfo->LastWriteTime =
// BasicInfo->ChangeTime =
BasicInfo->FileAttributes = FCB->entry.Attrib;
DPRINT("Getting attributes %x\n", BasicInfo->FileAttributes);
return(STATUS_SUCCESS);
}
NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
/*
@ -1655,10 +1674,20 @@ NTSTATUS FsdQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
DeviceObject,
SystemBuffer);
break;
case FileBasicInformation:
RC = FsdGetBasicInformation(FileObject,
FCB,
DeviceObject,
SystemBuffer);
break;
default:
RC=STATUS_NOT_IMPLEMENTED;
}
Irp->IoStatus.Status = RC;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return RC;
}
@ -1710,11 +1739,13 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
RC = STATUS_NOT_IMPLEMENTED;
}
Irp->IoStatus.Status = RC;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return RC;
}
STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
PUNICODE_STRING RegistryPath)

View file

@ -19,7 +19,7 @@
#include <string.h>
#include <wchar.h>
//#define NDEBUG
#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS *****************************************************************/

View file

@ -402,7 +402,7 @@ DWORD STDCALL GetFileAttributesW(LPCWSTR lpFileName)
NTSTATUS errCode;
hFile = CreateFileW(lpFileName,
GENERIC_READ,
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
@ -419,7 +419,7 @@ DWORD STDCALL GetFileAttributesW(LPCWSTR lpFileName)
{
CloseHandle(hFile);
SetLastError(RtlNtStatusToDosError(errCode));
return 0;
return 0xFFFFFFFF;
}
CloseHandle(hFile);
return (DWORD)FileBasic.FileAttributes;

View file

@ -37,58 +37,65 @@ NTSTATUS STDCALL ZwQueryInformationFile(HANDLE FileHandle,
ULONG Length,
FILE_INFORMATION_CLASS FileInformationClass)
{
NTSTATUS Status;
PFILE_OBJECT FileObject;
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
PIRP Irp;
PDEVICE_OBJECT DeviceObject;
PFILE_OBJECT FileObject;
NTSTATUS Status;
KEVENT Event;
PIO_STACK_LOCATION StackPtr;
DPRINT("ZwQueryInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
FileHandle,
IoStatusBlock,
FileInformation,
Length,
FileInformationClass);
DPRINT("ZwQueryInformationFile(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_READ_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);
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_ATTRIBUTES,
IoFileType,
UserMode,
(PVOID *)&FileObject,
NULL);
if (!NT_SUCCESS(Status))
{
return(Status);
}
DPRINT("FileObject %x\n", FileObject);
/* build the IRP to be sent to the driver for the request */
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_QUERY_INFORMATION,
FileObject->DeviceObject,
FileInformation,
Length,
0,
&Event,
IoStatusBlock);
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
StackPtr->Parameters.QueryFile.Length = Length;
StackPtr->Parameters.QueryFile.FileInformationClass = FileInformationClass;
KeInitializeEvent(&Event,NotificationEvent,FALSE);
DeviceObject = FileObject->DeviceObject;
/* 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;
}
Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE);
if (Irp==NULL)
{
ObDereferenceObject(FileObject);
return STATUS_UNSUCCESSFUL;
}
return Status;
Irp->UserIosb = IoStatusBlock;
Irp->UserEvent = &Event;
Irp->UserBuffer=FileInformation;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_INFORMATION;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.QueryFile.FileInformationClass =
FileInformationClass;
StackPtr->Parameters.QueryFile.Length = Length;
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);
}
NTSTATUS NtSetInformationFile(HANDLE FileHandle,
@ -116,7 +123,7 @@ NTSTATUS ZwSetInformationFile(HANDLE FileHandle,
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
DPRINT("ZwSetInformation(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
DPRINT("ZwSetInformationFile(Handle %x StatBlk %x FileInfo %x Length %d Class %d)\n",
FileHandle,
IoStatusBlock,
FileInformation,