Add file object flags, complete DEVOBJ_EXTENSION, and implement: IoIsFileOriginRemote, IoGetLowerDeviceObject, IoGetdiskDeviceObject, IoGetRequestorSessionId, IoGetRequestorProcessId

svn path=/trunk/; revision=14639
This commit is contained in:
Alex Ionescu 2005-04-16 19:38:14 +00:00
parent 9d6033ebad
commit 39ef71436d
6 changed files with 117 additions and 69 deletions

View file

@ -645,6 +645,11 @@ typedef struct _IO_COMPLETION_CONTEXT
#define FO_OPENED_CASE_SENSITIVE 0x00020000 #define FO_OPENED_CASE_SENSITIVE 0x00020000
#define FO_HANDLE_CREATED 0x00040000 #define FO_HANDLE_CREATED 0x00040000
#define FO_FILE_FAST_IO_READ 0x00080000 #define FO_FILE_FAST_IO_READ 0x00080000
#define FO_RANDOM_ACCESS 0x00100000
#define FO_FILE_OPEN_CANCELLED 0x00200000
#define FO_VOLUME_OPEN 0x00400000
#define FO_FILE_OBJECT_HAS_EXTENSION 0x00800000
#define FO_REMOTE_ORIGIN 0x01000000
typedef struct _FILE_OBJECT typedef struct _FILE_OBJECT
{ {
@ -896,6 +901,12 @@ struct _FAST_IO_DISPATCH_TABLE
#define DRVO_BOOTREINIT_REGISTERED 0x20L #define DRVO_BOOTREINIT_REGISTERED 0x20L
#define DRVO_LEGACY_RESOURCES 0x40L #define DRVO_LEGACY_RESOURCES 0x40L
#define DOE_UNLOAD_PENDING 0x1
#define DOE_DELETE_PENDING 0x2
#define DOE_REMOVE_PENDING 0x4
#define DOE_REMOVE_PROCESSED 0x8
#define DOE_START_PENDING 0x10
typedef struct _DRIVER_OBJECT typedef struct _DRIVER_OBJECT
{ {
CSHORT Type; CSHORT Type;

View file

@ -41,6 +41,7 @@
#define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003) #define IO_METHOD_FROM_CTL_CODE(ctlCode) (ctlCode&0x00000003)
struct _DEVICE_OBJECT_POWER_EXTENSION;
typedef struct _IO_COMPLETION_PACKET{ typedef struct _IO_COMPLETION_PACKET{
PVOID Key; PVOID Key;
@ -53,8 +54,15 @@ typedef struct _DEVOBJ_EXTENSION {
CSHORT Type; CSHORT Type;
USHORT Size; USHORT Size;
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
ULONG Unknown[3]; ULONG PowerFlags;
struct DEVICE_OBJECT_POWER_EXTENSION *Dope;
ULONG ExtensionFlags;
struct _DEVICE_NODE *DeviceNode; struct _DEVICE_NODE *DeviceNode;
PDEVICE_OBJECT AttachedTo;
LONG StartIoCount;
LONG StartIoKey;
ULONG StartIoFlags;
struct _VPB *Vpb;
} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
typedef struct _PRIVATE_DRIVER_EXTENSIONS { typedef struct _PRIVATE_DRIVER_EXTENSIONS {

View file

@ -247,30 +247,66 @@ IoGetDeviceAttachmentBaseRef(
} }
/* /*
* @unimplemented * @implemented
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
IoGetDiskDeviceObject( IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject,
IN PDEVICE_OBJECT FileSystemDeviceObject, OUT PDEVICE_OBJECT *DiskDeviceObject)
OUT PDEVICE_OBJECT *DiskDeviceObject
)
{ {
UNIMPLEMENTED; PDEVOBJ_EXTENSION DeviceExtension;
return STATUS_NOT_IMPLEMENTED; PVPB Vpb;
KIRQL OldIrql;
/* Make sure there's a VPB */
if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER;
/* Acquire it */
IoAcquireVpbSpinLock(&OldIrql);
/* Get the Device Extension */
DeviceExtension = FileSystemDeviceObject->DeviceObjectExtension;
/* Make sure this one has a VPB too */
Vpb = DeviceExtension->Vpb;
if (!Vpb) return STATUS_INVALID_PARAMETER;
/* Make sure someone it's mounted */
if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED)) return STATUS_VOLUME_DISMOUNTED;
/* Return the Disk Device Object */
*DiskDeviceObject = Vpb->RealDevice;
/* Release the lock */
IoReleaseVpbSpinLock(OldIrql);
return STATUS_SUCCESS;
} }
/* /*
* @unimplemented * @implemented
*/ */
PDEVICE_OBJECT PDEVICE_OBJECT
STDCALL STDCALL
IoGetLowerDeviceObject( IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject)
IN PDEVICE_OBJECT DeviceObject
)
{ {
UNIMPLEMENTED; PDEVOBJ_EXTENSION DeviceExtension = DeviceObject->DeviceObjectExtension;
return 0; PDEVICE_OBJECT LowerDeviceObject = NULL;
/* Make sure it's not getting deleted */
if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING |
DOE_DELETE_PENDING |
DOE_REMOVE_PENDING |
DOE_REMOVE_PROCESSED))
{
/* Get the Lower Device Object */
LowerDeviceObject = DeviceExtension->AttachedTo;
/* Reference it */
ObReferenceObject(LowerDeviceObject);
}
/* Return it */
return LowerDeviceObject;
} }
/* /*

View file

@ -265,16 +265,14 @@ IoCreateStreamFileObjectLite(
} }
/* /*
* @unimplemented * @implemented
*/ */
BOOLEAN BOOLEAN
STDCALL STDCALL
IoIsFileOriginRemote( IoIsFileOriginRemote(IN PFILE_OBJECT FileObject)
IN PFILE_OBJECT FileObject
)
{ {
UNIMPLEMENTED; /* Return the flag status */
return FALSE; return (FileObject->Flags & FO_REMOTE_ORIGIN);
} }
/* /*

View file

@ -68,34 +68,6 @@ IoFreeIrp(PIRP Irp)
ExFreePool(Irp); ExFreePool(Irp);
} }
/*
* @unimplemented
*/
ULONG
STDCALL
IoGetRequestorProcessId(
IN PIRP Irp
)
{
UNIMPLEMENTED;
return 0;
}
/*
* @unimplemented
*/
NTSTATUS
STDCALL
IoGetRequestorSessionId(
IN PIRP Irp,
OUT PULONG pSessionId
)
{
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/* /*
* @unimplemented * @unimplemented
*/ */

View file

@ -18,17 +18,18 @@
/* /*
* @implemented * @implemented
*/ */
PVOID STDCALL PVOID
STDCALL
IoGetInitialStack(VOID) IoGetInitialStack(VOID)
{ {
return(PsGetCurrentThread()->Tcb.InitialStack); return(PsGetCurrentThread()->Tcb.InitialStack);
} }
/* /*
* @implemented * @implemented
*/ */
VOID STDCALL VOID
STDCALL
IoGetStackLimits(OUT PULONG LowLimit, IoGetStackLimits(OUT PULONG LowLimit,
OUT PULONG HighLimit) OUT PULONG HighLimit)
{ {
@ -37,22 +38,21 @@ IoGetStackLimits(OUT PULONG LowLimit,
} }
/* /*
* @unimplemented * @implemented
*/ */
BOOLEAN BOOLEAN
STDCALL STDCALL
IoIsSystemThread( IoIsSystemThread(IN PETHREAD Thread)
IN PETHREAD Thread
)
{ {
UNIMPLEMENTED; /* Call the Ps Function */
return FALSE; return PsIsSystemThread(Thread);
} }
/* /*
* @implemented * @implemented
*/ */
PEPROCESS STDCALL PEPROCESS
STDCALL
IoThreadToProcess(IN PETHREAD Thread) IoThreadToProcess(IN PETHREAD Thread)
{ {
return(Thread->ThreadsProcess); return(Thread->ThreadsProcess);
@ -68,6 +68,28 @@ IoGetRequestorProcess(IN PIRP Irp)
return(Irp->Tail.Overlay.Thread->ThreadsProcess); return(Irp->Tail.Overlay.Thread->ThreadsProcess);
} }
/*
* @implemented
*/
ULONG
STDCALL
IoGetRequestorProcessId(IN PIRP Irp)
{
return (ULONG)(IoGetRequestorProcess(Irp)->UniqueProcessId);
}
/*
* @implemented
*/
NTSTATUS
STDCALL
IoGetRequestorSessionId(IN PIRP Irp,
OUT PULONG pSessionId)
{
*pSessionId = IoGetRequestorProcess(Irp)->SessionId;
return STATUS_SUCCESS;
}
/********************************************************************** /**********************************************************************
* NAME EXPORTED * NAME EXPORTED
@ -84,7 +106,8 @@ IoGetRequestorProcess(IN PIRP Irp)
* *
* @implemented * @implemented
*/ */
BOOLEAN STDCALL BOOLEAN
STDCALL
IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled) IoSetThreadHardErrorMode(IN BOOLEAN HardErrorEnabled)
{ {
BOOLEAN PreviousHEM = (BOOLEAN)(NtCurrentTeb()->HardErrorDisabled); BOOLEAN PreviousHEM = (BOOLEAN)(NtCurrentTeb()->HardErrorDisabled);