www.pudn.com > FsTPM0.rar > FastIO.cpp
/*
Copyright (c) 2004 By LiGen, All right reserved
Module Name:
FastIO.cpp
Abstract:
FAST I/O 处理函数
Environment:
Windows XP, Compiler Ver > 13.00
Notes:
注意,本文件不光包括了FastIO的函数的声明还包括实体
Revision History:
created: 18:7:2004
Author:
李根 13574849558@hnmcc.com
--*/
#include "FsTPM.h"
//
// Macro to test if this is my device extension
//
#define IS_MY_DEVICE_EXTENSION(_devExt) \
( ((_devExt) != NULL) && \
(((PHOOK_EXTENSION)(_devExt))->thisDriver == FsTPMDriverObject) )
#define VALID_FAST_IO_DISPATCH_HANDLER(_FastIoDispatchPtr, _FieldName) \
(((_FastIoDispatchPtr) != NULL) && \
(((_FastIoDispatchPtr)->SizeOfFastIoDispatch) >= \
(FIELD_OFFSET(FAST_IO_DISPATCH, _FieldName) + sizeof(void *))) && \
((_FastIoDispatchPtr)->_FieldName != NULL))
/////////////////////////////////////////////////////////////////////////////
//
// FastIO Handling routines
//
/////////////////////////////////////////////////////////////////////////////
BOOLEAN
FsTPMFastIoCheckIfPossible (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
IN BOOLEAN CheckForReadOperation,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for checking to see
whether fast I/O is possible for this file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be operated on.
FileOffset - Byte offset in the file for the operation.
Length - Length of the operation to be performed.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
LockKey - Provides the caller's key for file locks.
CheckForReadOperation - Indicates whether the caller is checking for a
read (TRUE) or a write operation.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoCheckIfPossible \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoCheckIfPossible )) {
return (fastIoDispatch->FastIoCheckIfPossible)(
FileObject,
FileOffset,
Length,
Wait,
LockKey,
CheckForReadOperation,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoRead (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for reading from a
file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be read.
FileOffset - Byte offset in the file of the read.
Length - Length of the read operation to be performed.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
LockKey - Provides the caller's key for file locks.
Buffer - Pointer to the caller's buffer to receive the data read.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoRead \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoRead )) {
return (fastIoDispatch->FastIoRead)(
FileObject,
FileOffset,
Length,
Wait,
LockKey,
Buffer,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN BOOLEAN Wait,
IN ULONG LockKey,
IN PVOID Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for writing to a
file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be written.
FileOffset - Byte offset in the file of the write operation.
Length - Length of the write operation to be performed.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
LockKey - Provides the caller's key for file locks.
Buffer - Pointer to the caller's buffer that contains the data to be
written.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoWrite \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoWrite )) {
return (fastIoDispatch->FastIoWrite)(
FileObject,
FileOffset,
Length,
Wait,
LockKey,
Buffer,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoQueryBasicInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_BASIC_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for querying basic
information about the file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be queried.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
Buffer - Pointer to the caller's buffer to receive the information about
the file.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoQueryBasicInfo \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoQueryBasicInfo )) {
return (fastIoDispatch->FastIoQueryBasicInfo)(
FileObject,
Wait,
Buffer,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoQueryStandardInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_STANDARD_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for querying standard
information about the file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be queried.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
Buffer - Pointer to the caller's buffer to receive the information about
the file.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoQueryStandardInfo \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoQueryStandardInfo )) {
return (fastIoDispatch->FastIoQueryStandardInfo)(
FileObject,
Wait,
Buffer,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoLock (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
PEPROCESS ProcessId,
ULONG Key,
BOOLEAN FailImmediately,
BOOLEAN ExclusiveLock,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for locking a byte
range within a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be locked.
FileOffset - Starting byte offset from the base of the file to be locked.
Length - Length of the byte range to be locked.
ProcessId - ID of the process requesting the file lock.
Key - Lock key to associate with the file lock.
FailImmediately - Indicates whether or not the lock request is to fail
if it cannot be immediately be granted.
ExclusiveLock - Indicates whether the lock to be taken is exclusive (TRUE)
or shared.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoLock \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoLock )) {
return (fastIoDispatch->FastIoLock)(
FileObject,
FileOffset,
Length,
ProcessId,
Key,
FailImmediately,
ExclusiveLock,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoUnlockSingle (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PLARGE_INTEGER Length,
PEPROCESS ProcessId,
ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for unlocking a byte
range within a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be unlocked.
FileOffset - Starting byte offset from the base of the file to be
unlocked.
Length - Length of the byte range to be unlocked.
ProcessId - ID of the process requesting the unlock operation.
Key - Lock key associated with the file lock.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoUnlockSingle \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoUnlockSingle )) {
return (fastIoDispatch->FastIoUnlockSingle)(
FileObject,
FileOffset,
Length,
ProcessId,
Key,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoUnlockAll (
IN PFILE_OBJECT FileObject,
PEPROCESS ProcessId,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for unlocking all
locks within a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be unlocked.
ProcessId - ID of the process requesting the unlock operation.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoUnlockAll \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoUnlockAll )) {
return (fastIoDispatch->FastIoUnlockAll)(
FileObject,
ProcessId,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoUnlockAllByKey (
IN PFILE_OBJECT FileObject,
PVOID ProcessId,
ULONG Key,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for unlocking all
locks within a file based on a specified key.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be unlocked.
ProcessId - ID of the process requesting the unlock operation.
Key - Lock key associated with the locks on the file to be released.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoUnlockAllByKey \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoUnlockAllByKey )) {
return (fastIoDispatch->FastIoUnlockAllByKey)(
FileObject,
ProcessId,
Key,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoDeviceControl (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength,
IN ULONG IoControlCode,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for device I/O control
operations on a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object representing the device to be
serviced.
Wait - Indicates whether or not the caller is willing to wait if the
appropriate locks, etc. cannot be acquired
InputBuffer - Optional pointer to a buffer to be passed into the driver.
InputBufferLength - Length of the optional InputBuffer, if one was
specified.
OutputBuffer - Optional pointer to a buffer to receive data from the
driver.
OutputBufferLength - Length of the optional OutputBuffer, if one was
specified.
IoControlCode - I/O control code indicating the operation to be performed
on the device.
IoStatus - Pointer to a variable to receive the I/O status of the
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
FsTPM_DbgPrint(("->FsTPMFastIoDeviceControl \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
if (((PHOOK_EXTENSION)DeviceObject->DeviceExtension)->Type==GUIINTERFACE)
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_SUCCESS;
switch(IoControlCode)
{
case IOCTL_FSTPM_ADD_PROTECT_FILE:
if (InputBuffer!=NULL && InputBufferLength==sizeof(FILE_PROTECT_LIST_ITEM))
{
DbgPrint("===>Add Protect File ****************\n");
PFILE_PROTECT_LIST_ITEM pItem = (PFILE_PROTECT_LIST_ITEM)ExAllocatePoolWithTag(NonPagedPool, sizeof(FILE_PROTECT_LIST_ITEM), TAGS);
pItem->ProtectedFileName[MAXPATHLEN-1] = 0; // 确保字符串正确
RtlCopyMemory( pItem, InputBuffer, InputBufferLength);
UpperWordW(pItem->ProtectedFileName);
DbgPrint("===>FileName is: %S\n", pItem->ProtectedFileName);
ListInsert(&ProtectControlBlock.FileProtectList,pItem);
IoStatus->Information = sizeof(FILE_PROTECT_LIST_ITEM);
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_DELETE_PROTECT_FILE:
if (InputBuffer!=NULL && InputBufferLength==sizeof(FILE_PROTECT_LIST_ITEM))
{
PFILE_PROTECT_LIST_ITEM pItem = (PFILE_PROTECT_LIST_ITEM)InputBuffer;
pItem->ProtectedFileName[MAXPATHLEN-1] = 0;
ListDelete(&ProtectControlBlock.FileProtectList, pItem->ProtectedFileName);
IoStatus->Information = sizeof(FILE_PROTECT_LIST_ITEM);
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_SET_CHECK_PROTECT_STATUS:
if (InputBufferLength == 1 && InputBuffer!=NULL)
{
ProtectControlBlock.EnableCheckProtect = (unsigned char)InputBuffer ? TRUE:FALSE;
IoStatus->Information = 1;
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_SET_STATIC_PROTECT_STATUS:
if (InputBufferLength == 1 && InputBuffer!=NULL)
{
ProtectControlBlock.EnableStaticProtect = (unsigned char)InputBuffer ? TRUE:FALSE;
IoStatus->Information = 1;
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_SET_ENCRYPT_PROTECT:
if (InputBufferLength == 1 && InputBuffer!=NULL)
{
ProtectControlBlock.EnableEncryptProtect = (unsigned char)InputBuffer ? TRUE:FALSE;
IoStatus->Information = 1;
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_QUERY_PROTECT_FILE:
if (OutputBufferLength==sizeof(FILE_PROTECT_LIST_ITEM) &&
InputBufferLength==sizeof(FILE_PROTECT_LIST_ITEM) &&
InputBuffer !=NULL && OutputBuffer != NULL
)
{
PFILE_PROTECT_LIST_ITEM pItem1 = (PFILE_PROTECT_LIST_ITEM)InputBuffer ,pItem2;
pItem1->ProtectedFileName[MAXPATHLEN-1]=0;
if (ProtectList_Is_In( &ProtectControlBlock.FileProtectList,pItem1->ProtectedFileName, &pItem2))
{
RtlCopyMemory(OutputBuffer, (PVOID)pItem2, OutputBufferLength);
IoStatus->Information = OutputBufferLength;
}
else
{
IoStatus->Information = 0;
}
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_QUERY_PROTECT_FILE_COUNT:
if (OutputBufferLength==sizeof(ULONG) && OutputBuffer!=NULL)
{
*((ULONG*)OutputBuffer) = ProtectControlBlock.FileProtectList.Count;
IoStatus->Information = sizeof(ULONG);
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
break;
case IOCTL_FSTPM_QUERY_PROTECT_LIST:
if (OutputBufferLength == sizeof(FILE_PROTECT_LIST_ITEM)*ProtectControlBlock.FileProtectList.Count &&
OutputBuffer!=NULL
)
{
RtlCopyMemory( OutputBuffer, ProtectControlBlock.FileProtectList.head, OutputBufferLength );
IoStatus->Information = 0;
IoStatus->Status = STATUS_SUCCESS;
}
break;
case IOCTL_FSTPM_SET_EVENT:
if (InputBufferLength == 1 && InputBuffer!=NULL)
{
gUser_Command = (*((BOOL*)InputBuffer));
//KeSetEvent(pAck_Event, 0, FALSE);
gAck=1;
IoStatus->Information = 1 ;
}
else
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_INVALID_PARAMETER;
}
default:
{
IoStatus->Information = 0;
IoStatus->Status = STATUS_SUCCESS;
}
break;
}
return TRUE;
}
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoDeviceControl )) {
return (fastIoDispatch->FastIoDeviceControl)(
FileObject,
Wait,
InputBuffer,
InputBufferLength,
OutputBuffer,
OutputBufferLength,
IoControlCode,
IoStatus,
deviceObject );
}
}
return FALSE;
}
VOID
FsTPMFastIoDetachDevice (
IN PDEVICE_OBJECT SourceDevice,
IN PDEVICE_OBJECT TargetDevice
)
/*++
Routine Description:
This routine is invoked on the fast path to detach from a device that
is being deleted. This occurs when this driver has attached to a file
system volume device object, and then, for some reason, the file system
decides to delete that device (it is being dismounted, it was dismounted
at some point in the past and its last reference has just gone away, etc.)
Arguments:
SourceDevice - Pointer to this driver's device object, which is attached
to the file system's volume device object.
TargetDevice - Pointer to the file system's volume device object.
Return Value:
None
--*/
{
// 暂不予支持
return ;
FsTPM_DbgPrint(("->FsTPMFastIoDetachDevice \n"));
PAGED_CODE();
//
// Simply acquire the database lock for exclusive access, and detach from
// the file system's volume device object.
//
// FsRtlEnterFileSystem();
// ExAcquireResourceExclusive( &FsLock, TRUE );
IoDetachDevice( TargetDevice );
IoDeleteDevice( SourceDevice );
// ExReleaseResource( &FsLock );
// FsRtlExitFileSystem();
}
BOOLEAN
FsTPMFastIoQueryNetworkOpenInfo (
IN PFILE_OBJECT FileObject,
IN BOOLEAN Wait,
OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for querying network
information about a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object to be queried.
Wait - Indicates whether or not the caller can handle the file system
having to wait and tie up the current thread.
Buffer - Pointer to a buffer to receive the network information about the
file.
IoStatus - Pointer to a variable to receive the final status of the query
operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoQueryNetworkOpenInfo \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoQueryNetworkOpenInfo )) {
return (fastIoDispatch->FastIoQueryNetworkOpenInfo)(
FileObject,
Wait,
Buffer,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoMdlRead (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for reading a file
using MDLs as buffers.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object that is to be read.
FileOffset - Supplies the offset into the file to begin the read operation.
Length - Specifies the number of bytes to be read from the file.
LockKey - The key to be used in byte range lock checks.
MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
chain built to describe the data read.
IoStatus - Variable to receive the final status of the read operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoMdlRead \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, MdlRead )) {
return (fastIoDispatch->MdlRead)(
FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoMdlReadComplete (
IN PFILE_OBJECT FileObject,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for completing an
MDL read operation.
This function simply invokes the file system's cooresponding routine, if
it has one. It should be the case that this routine is invoked only if
the MdlRead function is supported by the underlying file system, and
therefore this function will also be supported, but this is not assumed
by this driver.
Arguments:
FileObject - Pointer to the file object to complete the MDL read upon.
MdlChain - Pointer to the MDL chain used to perform the read operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE, depending on whether or not it is
possible to invoke this function on the fast I/O path.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoMdlReadComplete \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, MdlReadComplete )) {
return (fastIoDispatch->MdlReadComplete)(
FileObject,
MdlChain,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoPrepareMdlWrite (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for preparing for an
MDL write operation.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object that will be written.
FileOffset - Supplies the offset into the file to begin the write operation.
Length - Specifies the number of bytes to be write to the file.
LockKey - The key to be used in byte range lock checks.
MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
chain built to describe the data written.
IoStatus - Variable to receive the final status of the write operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoPrepareMdlWrite \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, PrepareMdlWrite )) {
return (fastIoDispatch->PrepareMdlWrite)(
FileObject,
FileOffset,
Length,
LockKey,
MdlChain,
IoStatus,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoMdlWriteComplete (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for completing an
MDL write operation.
This function simply invokes the file system's cooresponding routine, if
it has one. It should be the case that this routine is invoked only if
the PrepareMdlWrite function is supported by the underlying file system,
and therefore this function will also be supported, but this is not
assumed by this driver.
Arguments:
FileObject - Pointer to the file object to complete the MDL write upon.
FileOffset - Supplies the file offset at which the write took place.
MdlChain - Pointer to the MDL chain used to perform the write operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE, depending on whether or not it is
possible to invoke this function on the fast I/O path.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoMdlWriteComplete \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, MdlWriteComplete )) {
return (fastIoDispatch->MdlWriteComplete)(
FileObject,
FileOffset,
MdlChain,
deviceObject );
}
}
return FALSE;
}
/*********************************************************************************
UNIMPLEMENTED FAST IO ROUTINES
The following four Fast Io routines are for compression on the wire
which is not yet implemented in NT.
FastIoReadCompressed, FastIoWriteCompressed,
FastIoMdlReadCompleteCompressed, FastIoMdlWriteCompleteCompressed
**********************************************************************************/
BOOLEAN
FsTPMFastIoReadCompressed (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
OUT PVOID Buffer,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
IN ULONG CompressedDataInfoLength,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for reading compressed
data from a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object that will be read.
FileOffset - Supplies the offset into the file to begin the read operation.
Length - Specifies the number of bytes to be read from the file.
LockKey - The key to be used in byte range lock checks.
Buffer - Pointer to a buffer to receive the compressed data read.
MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
chain built to describe the data read.
IoStatus - Variable to receive the final status of the read operation.
CompressedDataInfo - A buffer to receive the description of the compressed
data.
CompressedDataInfoLength - Specifies the size of the buffer described by
the CompressedDataInfo parameter.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoReadCompressed \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoReadCompressed )) {
return (fastIoDispatch->FastIoReadCompressed)(
FileObject,
FileOffset,
Length,
LockKey,
Buffer,
MdlChain,
IoStatus,
CompressedDataInfo,
CompressedDataInfoLength,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoWriteCompressed (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN ULONG Length,
IN ULONG LockKey,
IN PVOID Buffer,
OUT PMDL *MdlChain,
OUT PIO_STATUS_BLOCK IoStatus,
IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
IN ULONG CompressedDataInfoLength,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for writing compressed
data to a file.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
FileObject - Pointer to the file object that will be written.
FileOffset - Supplies the offset into the file to begin the write operation.
Length - Specifies the number of bytes to be write to the file.
LockKey - The key to be used in byte range lock checks.
Buffer - Pointer to the buffer containing the data to be written.
MdlChain - A pointer to a variable to be filled in w/a pointer to the MDL
chain built to describe the data written.
IoStatus - Variable to receive the final status of the write operation.
CompressedDataInfo - A buffer to containing the description of the
compressed data.
CompressedDataInfoLength - Specifies the size of the buffer described by
the CompressedDataInfo parameter.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoWriteCompressed \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoWriteCompressed )) {
return (fastIoDispatch->FastIoWriteCompressed)(
FileObject,
FileOffset,
Length,
LockKey,
Buffer,
MdlChain,
IoStatus,
CompressedDataInfo,
CompressedDataInfoLength,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoMdlReadCompleteCompressed (
IN PFILE_OBJECT FileObject,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for completing an
MDL read compressed operation.
This function simply invokes the file system's cooresponding routine, if
it has one. It should be the case that this routine is invoked only if
the read compressed function is supported by the underlying file system,
and therefore this function will also be supported, but this is not assumed
by this driver.
Arguments:
FileObject - Pointer to the file object to complete the compressed read
upon.
MdlChain - Pointer to the MDL chain used to perform the read operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE, depending on whether or not it is
possible to invoke this function on the fast I/O path.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoMdlReadCompleteCompressed \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, MdlReadCompleteCompressed )) {
return (fastIoDispatch->MdlReadCompleteCompressed)(
FileObject,
MdlChain,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoMdlWriteCompleteCompressed (
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER FileOffset,
IN PMDL MdlChain,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for completing a
write compressed operation.
This function simply invokes the file system's cooresponding routine, if
it has one. It should be the case that this routine is invoked only if
the write compressed function is supported by the underlying file system,
and therefore this function will also be supported, but this is not assumed
by this driver.
Arguments:
FileObject - Pointer to the file object to complete the compressed write
upon.
FileOffset - Supplies the file offset at which the file write operation
began.
MdlChain - Pointer to the MDL chain used to perform the write operation.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE, depending on whether or not it is
possible to invoke this function on the fast I/O path.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoMdlWriteCompleteCompressed \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, MdlWriteCompleteCompressed )) {
return (fastIoDispatch->MdlWriteCompleteCompressed)(
FileObject,
FileOffset,
MdlChain,
deviceObject );
}
}
return FALSE;
}
BOOLEAN
FsTPMFastIoQueryOpen (
IN PIRP Irp,
OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for opening a file
and returning network information it.
This function simply invokes the file system's cooresponding routine, or
returns FALSE if the file system does not implement the function.
Arguments:
Irp - Pointer to a create IRP that represents this open operation. It is
to be used by the file system for common open/create code, but not
actually completed.
NetworkInformation - A buffer to receive the information required by the
network about the file being opened.
DeviceObject - Pinter to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is TRUE or FALSE based on whether or not fast I/O
is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoQueryOpen \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
BOOLEAN result;
PAGED_CODE();
ASSERT(IS_MY_DEVICE_EXTENSION( DeviceObject->DeviceExtension ));
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (deviceObject) {
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoQueryOpen )) {
PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation( Irp );
irpSp->DeviceObject = deviceObject;
result = (fastIoDispatch->FastIoQueryOpen)(
Irp,
NetworkInformation,
deviceObject );
if (!result) {
irpSp->DeviceObject = DeviceObject;
}
return result;
}
}
return FALSE;
}
//----------------------------------------------------------------------
//
// FsTPMFastIoAcquireFile
//
//----------------------------------------------------------------------
VOID
FsTPMFastIoAcquireFile(
PFILE_OBJECT FileObject
)
{
// 暂不予支持
return ;
FsTPM_DbgPrint(("->FsTPMFastIoAcquireFile \n"));
PDEVICE_OBJECT deviceObject, checkDevice;
PHOOK_EXTENSION hookExt;
PFAST_IO_DISPATCH fastIoDispatch;
//
// We've got to locate our own device object
//
checkDevice = FileObject->DeviceObject->Vpb->DeviceObject;
while( checkDevice ) {
if( checkDevice->DriverObject == FsTPMDriverObject ) {
//
// Found it
//
deviceObject = checkDevice;
hookExt = (PHOOK_EXTENSION)deviceObject->DeviceExtension;
fastIoDispatch=hookExt->Vcb.NextLowerDevice->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER(fastIoDispatch, AcquireFileForNtCreateSection))
{
fastIoDispatch->AcquireFileForNtCreateSection( FileObject );
}
return;
}
checkDevice = checkDevice->AttachedDevice;
}
}
//----------------------------------------------------------------------
//
// FsTPMFastIoReleaseFile
//
//----------------------------------------------------------------------
VOID
FsTPMFastIoReleaseFile(
PFILE_OBJECT FileObject
)
{
// 暂不予支持
return ;
FsTPM_DbgPrint(("->FsTPMFastIoReleaseFile \n"));
PDEVICE_OBJECT deviceObject, checkDevice;
PHOOK_EXTENSION hookExt;
PFAST_IO_DISPATCH fastIoDispatch;
//
// We've got to locate our own device object
//
checkDevice = FileObject->DeviceObject->Vpb->DeviceObject;
while( checkDevice ) {
if( checkDevice->DriverObject == FsTPMDriverObject ) {
//
// Found it
//
deviceObject = checkDevice;
hookExt = (PHOOK_EXTENSION)deviceObject->DeviceExtension;
fastIoDispatch=hookExt->Vcb.NextLowerDevice->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER(fastIoDispatch, AcquireFileForNtCreateSection))
{
fastIoDispatch->ReleaseFileForNtCreateSection( FileObject );
}
return;
}
checkDevice = checkDevice->AttachedDevice;
}
}
NTSTATUS
FsTPMFastIoAcquireForModWrite(
IN PFILE_OBJECT FileObject,
IN PLARGE_INTEGER EndingOffset,
OUT PERESOURCE *ResourceToRelease,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for acquiring the
file resource prior to attempting a modified write operation.
This function simply invokes the next driver's cooresponding routine, or
returns FALSE if the next driver does not implement the function.
Arguments:
FileObject - Pointer to the file object whose resource is to be acquired.
EndingOffset - The offset to the last byte being written plus one.
ResourceToRelease - Pointer to a variable to return the resource to
release. Not defined if an error is returned.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is either success or failure based on whether or not
fast I/O is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoAcquireForModWrite \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
NTSTATUS returnStatus;
PAGED_CODE();
if (DeviceObject->DeviceExtension == NULL)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (!deviceObject)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER(fastIoDispatch, AcquireForModWrite)) {
returnStatus = (fastIoDispatch->AcquireForModWrite)( FileObject,
EndingOffset,
ResourceToRelease,
DeviceObject);
} else {
returnStatus = STATUS_INVALID_DEVICE_REQUEST;
}
return returnStatus;
}
NTSTATUS
FsTPMFastIoReleaseForModWrite(
IN PFILE_OBJECT FileObject,
IN PERESOURCE ResourceToRelease,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for releasing the
resource previously acquired for performing a modified write operation
to a file.
This function simply invokes the next driver's cooresponding routine, or
returns FALSE if the next driver does not implement the function.
Arguments:
FileObject - Pointer to the file object whose resource is to be released.
ResourceToRelease - Specifies the modified writer resource for the file
that is to be released.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is either success or failure based on whether or not
fast I/O is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoReleaseForModWrite \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
NTSTATUS returnStatus;
PAGED_CODE();
if (DeviceObject->DeviceExtension == NULL)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (!deviceObject)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, ReleaseForModWrite ))
{
returnStatus = (fastIoDispatch->ReleaseForModWrite)( FileObject,
ResourceToRelease,
DeviceObject);
}
else
{
returnStatus = STATUS_INVALID_DEVICE_REQUEST;
}
return returnStatus;
}
NTSTATUS
FsTPMFastIoAcquireForCcFlush(
IN PFILE_OBJECT FileObject,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for acquiring the
appropriate file system resource prior to a call to CcFlush.
This function simply invokes the next driver's cooresponding routine, or
returns FALSE if the next driver does not implement the function.
Arguments:
FileObject - Pointer to the file object whose resource is to be acquired.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is either success or failure based on whether or not
fast I/O is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoAcquireForCcFlush \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
NTSTATUS returnStatus;
if (DeviceObject->DeviceExtension == NULL) {
return STATUS_INVALID_DEVICE_REQUEST;
}
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (!deviceObject)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, AcquireForCcFlush )) {
returnStatus = (fastIoDispatch->AcquireForCcFlush)( FileObject,
DeviceObject);
} else {
returnStatus = STATUS_INVALID_DEVICE_REQUEST;
}
return returnStatus;
}
NTSTATUS
FsTPMFastIoReleaseForCcFlush(
IN PFILE_OBJECT FileObject,
IN PDEVICE_OBJECT DeviceObject
)
/*++
Routine Description:
This routine is the fast I/O "pass through" routine for releasing the
appropriate file system resource previously acquired for a CcFlush.
This function simply invokes the next driver's cooresponding routine, or
returns FALSE if the next driver does not implement the function.
Arguments:
FileObject - Pointer to the file object whose resource is to be released.
DeviceObject - Pointer to this driver's device object, the device on
which the operation is to occur.
Return Value:
The function value is either success or failure based on whether or not
fast I/O is possible for this file.
--*/
{
// 暂不予支持
return FALSE;
FsTPM_DbgPrint(("->FsTPMFastIoReleaseForCcFlush \n"));
PDEVICE_OBJECT deviceObject;
PFAST_IO_DISPATCH fastIoDispatch;
NTSTATUS returnStatus;
if (DeviceObject->DeviceExtension == NULL) {
return STATUS_INVALID_DEVICE_REQUEST;
}
//
// Pass through logic for this type of Fast I/O
//
deviceObject = ((PHOOK_EXTENSION) (DeviceObject->DeviceExtension))->Vcb.NextLowerDevice;
if (!deviceObject)
{
return STATUS_INVALID_DEVICE_REQUEST;
}
fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;
if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, ReleaseForCcFlush )) {
returnStatus = (fastIoDispatch->ReleaseForCcFlush)( FileObject,
DeviceObject);
} else {
returnStatus = STATUS_INVALID_DEVICE_REQUEST;
}
return returnStatus;
}
//
// This FsTPM's Fast I/O dispatch table. Note that NT assumes that
// file system drivers support some Fast I/O calls, so this table must
// be present for an file system filter driver
//
FAST_IO_DISPATCH FastIOHook = {
sizeof(FAST_IO_DISPATCH),
FsTPMFastIoCheckIfPossible,
FsTPMFastIoRead,
FsTPMFastIoWrite,
FsTPMFastIoQueryBasicInfo,
FsTPMFastIoQueryStandardInfo,
FsTPMFastIoLock,
FsTPMFastIoUnlockSingle,
FsTPMFastIoUnlockAll,
FsTPMFastIoUnlockAllByKey,
FsTPMFastIoDeviceControl,
FsTPMFastIoAcquireFile,
FsTPMFastIoReleaseFile,
FsTPMFastIoDetachDevice,
//
// new for NT 4.0
//
FsTPMFastIoQueryNetworkOpenInfo,
FsTPMFastIoAcquireForModWrite,
FsTPMFastIoMdlRead,
FsTPMFastIoMdlReadComplete,
FsTPMFastIoPrepareMdlWrite,
FsTPMFastIoMdlWriteComplete,
FsTPMFastIoReadCompressed,
FsTPMFastIoWriteCompressed,
FsTPMFastIoMdlReadCompleteCompressed,
FsTPMFastIoMdlWriteCompleteCompressed,
FsTPMFastIoQueryOpen,
FsTPMFastIoReleaseForModWrite,
FsTPMFastIoAcquireForCcFlush,
FsTPMFastIoReleaseForCcFlush
};