📄 fastio.cpp
字号:
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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -