⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filespy.c

📁 文件过滤驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
Return Value:

    The function value is TRUE or FALSE based on whether or not fast I/O
    is possible for this file.

--*/
{
    PDEVICE_OBJECT    deviceObject;
    PFAST_IO_DISPATCH fastIoDispatch;
    PRECORD_LIST      recordList;
    BOOLEAN           returnValue;
    BOOLEAN           shouldLog;

    PAGED_CODE();
    
    if (DeviceObject->DeviceExtension == NULL) {
        return FALSE;
    }
    
    if (shouldLog = SHOULD_LOG(DeviceObject)) {
        //
        // Log the necessary information for the start of the Fast I/O 
        // operation
        //
        recordList = SpyLogFastIoStart(
            QUERY_STANDARD_INFO,
            0,
            FileObject,
            NULL,
            0,
            Wait );
    }

    //
    // Pass through logic for this type of Fast I/O
    //
    deviceObject = 
        ((PDEVICE_EXTENSION) (DeviceObject->DeviceExtension))->
            NextDriverDeviceObject;
    if (!deviceObject) {
        returnValue = FALSE;
        goto SpyFastIoQueryStandardInfo_Exit;
    }
    fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;

    if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoQueryStandardInfo )) {
        returnValue = (fastIoDispatch->FastIoQueryStandardInfo)( FileObject,
                                                                 Wait,
                                                                 Buffer,
                                                                 IoStatus,
                                                                 deviceObject);
    } else {
        returnValue = FALSE;
    }

SpyFastIoQueryStandardInfo_Exit:
    if (shouldLog) {
        //
        // Log the necessary information for the end of the Fast I/O operation
        // if we were able to allocate a RecordList to store this information
        //
        if (recordList) {
            SpyLogFastIoComplete(
                0,
                FileObject,
                IoStatus,
                recordList);
        }
    }
    return returnValue;
}

DBGSTATIC
BOOLEAN
SpyFastIoLock(
    IN  PFILE_OBJECT     FileObject,
    IN  PLARGE_INTEGER   FileOffset,
    IN  PLARGE_INTEGER   Length,
    IN  PEPROCESS        ProcessId,
    IN  ULONG            Key,
    IN  BOOLEAN          FailImmediately,
    IN  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 next driver's cooresponding routine, or
    returns FALSE if the next driver 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.

--*/
{
    PDEVICE_OBJECT    deviceObject;
    PFAST_IO_DISPATCH fastIoDispatch;
    PRECORD_LIST      recordList;
    BOOLEAN           returnValue;
    BOOLEAN           shouldLog;

    PAGED_CODE();
    
    if (DeviceObject->DeviceExtension == NULL) {
        return FALSE;
    }
    
    if (shouldLog = SHOULD_LOG(DeviceObject)) {
        //
        // Log the necessary information for the start of the Fast I/O 
        // operation
        //
        recordList = SpyLogFastIoStart(
            LOCK,
            0,
            FileObject,
            FileOffset,
            0,
            0 );
    }

    //
    // Pass through logic for this type of Fast I/O
    //
    deviceObject = 
        ((PDEVICE_EXTENSION) (DeviceObject->DeviceExtension))->
            NextDriverDeviceObject;
    if (!deviceObject) {
        returnValue = FALSE;
        goto SpyFastIoLock_Exit;
    }
    fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;

    if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoLock )) {
        returnValue = (fastIoDispatch->FastIoLock)( FileObject,
                                                    FileOffset,
                                                    Length,
                                                    ProcessId,
                                                    Key,
                                                    FailImmediately,
                                                    ExclusiveLock,
                                                    IoStatus,
                                                    deviceObject);
    } else {
        returnValue = FALSE;
    }

SpyFastIoLock_Exit:
    if (shouldLog) {
        //
        // Log the necessary information for the end of the Fast I/O operation
        // if we were able to allocate a RecordList to store this information
        //
        if (recordList) {
            SpyLogFastIoComplete(
                0,
                FileObject,
                IoStatus,
                recordList);
        }
    }
    return returnValue;
}
 
DBGSTATIC
BOOLEAN
SpyFastIoUnlockSingle(
    IN  PFILE_OBJECT     FileObject,
    IN  PLARGE_INTEGER   FileOffset,
    IN  PLARGE_INTEGER   Length,
    IN  PEPROCESS        ProcessId,
    IN  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 next driver's cooresponding routine, or
    returns FALSE if the next driver 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.

--*/
{
    PDEVICE_OBJECT    deviceObject;
    PFAST_IO_DISPATCH fastIoDispatch;
    PRECORD_LIST      recordList;
    BOOLEAN           returnValue;
    BOOLEAN           shouldLog;

    PAGED_CODE();
    
    if (DeviceObject->DeviceExtension == NULL) {
        return FALSE;
    }
    
    if (shouldLog = SHOULD_LOG(DeviceObject)) {
        //
        // Log the necessary information for the start of the Fast I/O 
        // operation
        //
        recordList = SpyLogFastIoStart(
            UNLOCK_SINGLE,
            0,
            FileObject,
            FileOffset,
            0,
            0 );
    }


    //
    // Pass through logic for this type of Fast I/O
    //
    deviceObject = 
        ((PDEVICE_EXTENSION) (DeviceObject->DeviceExtension))->
            NextDriverDeviceObject;
    if (!deviceObject) {
        returnValue = FALSE;
        goto SpyFastIoUnlockSingle_Exit;
    }
    fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;

    if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoUnlockSingle )) {
        returnValue = (fastIoDispatch->FastIoUnlockSingle)( FileObject,
                                                            FileOffset,
                                                            Length,
                                                            ProcessId,
                                                            Key,
                                                            IoStatus,
                                                            deviceObject);
    } else {
        returnValue = FALSE;
    }

SpyFastIoUnlockSingle_Exit:
    if (shouldLog) {
        //
        // Log the necessary information for the end of the Fast I/O operation
        // if we were able to allocate a RecordList to store this information
        //
        if (recordList) {
            SpyLogFastIoComplete(
                0,
                FileObject,
                IoStatus,
                recordList);
        }
    }
    return returnValue;
}
 
DBGSTATIC
BOOLEAN
SpyFastIoUnlockAll(
    IN  PFILE_OBJECT     FileObject,
    IN  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.

--*/
{
    PDEVICE_OBJECT    deviceObject;
    PFAST_IO_DISPATCH fastIoDispatch;
    PRECORD_LIST      recordList;
    BOOLEAN           returnValue;
    BOOLEAN           shouldLog;

    PAGED_CODE();
    
    if (DeviceObject->DeviceExtension == NULL) {
        return FALSE;
    }
    
    if (shouldLog = SHOULD_LOG(DeviceObject)) {
        //
        // Log the necessary information for the start of the Fast I/O 
        // operation
        //
        recordList = SpyLogFastIoStart(
            UNLOCK_ALL,
            0,
            FileObject,
            NULL,
            0,
            0 );
    }

    //
    // Pass through logic for this type of Fast I/O
    //
    deviceObject = 
        ((PDEVICE_EXTENSION) (DeviceObject->DeviceExtension))->
            NextDriverDeviceObject;
    if (!deviceObject) {
        returnValue = FALSE;
        goto SpyFastIoUnlockAll_Exit;
    }
    fastIoDispatch = deviceObject->DriverObject->FastIoDispatch;

    if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoUnlockAll )) {
        returnValue = (fastIoDispatch->FastIoUnlockAll)( FileObject,
                                                         ProcessId,                                                         IoStatus,
                                                         deviceObject);
    } else {
        returnValue = FALSE;
    }

SpyFastIoUnlockAll_Exit:
    if (shouldLog) {
        //
        // Log the necessary information for the end of the Fast I/O operation
        // if we were able to allocate a RecordList to store this information
        //
        if (recordList) {
            SpyLogFastIoComplete(
                0,
                FileObject,
                IoStatus,
                recordList);
        }
    }
    return returnValue;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -