gpt4 book ai didi

kernel - APC禁用时如何查询文件大小?

转载 作者:行者123 更新时间:2023-12-02 11:47:36 25 4
gpt4 key购买 nike

在我的微过滤器的PostCreate期间,我必须使用全局推锁来按设计同步线程,并且我必须调用FltQueryInformationFile来查询文件大小。

但是,

1、调用FltAcquirePushLockExclusive后,APC下发被禁用;

2、如果禁用 APC 传递,则 FltQueryInformationFile 将失败,因为必须在 PASSIVE_LEVEL 调用并且启用 APC。

这种情况下,如何查询文件大小?构建 IRP 有帮助吗?

提前致谢。

最佳答案

您可以使用它来获取文件大小

NTSTATUS
GetFileSize (
_In_ PFLT_INSTANCE Instance,
_In_ PFILE_OBJECT FileObject,
_Out_ PLONGLONG Size
)
/*++

Routine Description:

This routine obtains the size.

Arguments:

Instance - Opaque filter pointer for the caller. This parameter is required and cannot be NULL.

FileObject - File object pointer for the file. This parameter is required and cannot be NULL.

Size - Pointer to a LONGLONG indicating the file size. This is the output.

Return Value:

Returns statuses forwarded from FltQueryInformationFile.

--*/
{
NTSTATUS status = STATUS_SUCCESS;
FILE_STANDARD_INFORMATION standardInfo;

//
// Querying for FileStandardInformation gives you the offset of EOF.
//

status = FltQueryInformationFile( Instance,
FileObject,
&standardInfo,
sizeof(FILE_STANDARD_INFORMATION),
FileStandardInformation,
NULL );

if (NT_SUCCESS( status )) {

*Size = standardInfo.EndOfFile.QuadPart;
}

return status;
}

关于kernel - APC禁用时如何查询文件大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176550/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com