我挂了ZwSetInformationFile通过文件名进行过滤,但是不知道为什么,判断不成功!
NTSTATUS NewZwSetInformationFile(IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass )
{
PFILE_OBJECT pFileObject;
NTSTATUS ret = ObReferenceObjectByHandle(FileHandle,GENERIC_READ,*IoFileObjectType,KernelMode,(PVOID*)&pFileObject,0);
if(NT_SUCCESS(ret))
{
if(!_wcsicmp(pFileObject->FileName.Buffer,L"\\Desk_top.ini"))
{
KdPrint(("FileName:%wZ \n",pFileObject->FileName.Buffer));
return STATUS_ACCESS_DENIED;
}
}
KdPrint(("DeleteFileName:%wZ \n",pFileObject->FileName.Buffer));
return Old_ZwSetInformationFile(FileHandle,IoStatusBlock,FileInformation,Length,FileInformationClass);
}
NTSTATUS NewZwSetInformationFile(IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN PVOID FileInformation,
IN ULONG Length,
IN FILE_INFORMATION_CLASS FileInformationClass )
{
PFILE_OBJECT pFileObject;
NTSTATUS ret = ObReferenceObjectByHandle(FileHandle,GENERIC_READ,*IoFileObjectType,KernelMode,(PVOID*)&pFileObject,0);
if(NT_SUCCESS(ret))
{
if(!_wcsicmp(pFileObject->FileName.Buffer,L"\\Desk_top.ini"))
{
KdPrint(("FileName:%wZ \n",pFileObject->FileName.Buffer));
return STATUS_ACCESS_DENIED;
}
}
KdPrint(("DeleteFileName:%wZ \n",pFileObject->FileName.Buffer));
return Old_ZwSetInformationFile(FileHandle,IoStatusBlock,FileInformation,Length,FileInformationClass);
}
解决方案 »
- 获取CLsitCtrl控件的滚动条对象?
- 如何让toolbar自动加载。
- debug版本编译通过,一运行就出现诊断错误
- 最近开发用到了Microsoft datagrid ActiveX控件,找不到指南,所以希望各位前辈能够提供个指南或以前的书籍名称
- 再问 happyparrot !!!!!!
- 关于点击Tree中选项,进行响应的问题!(难度系数:80%)
- socket 通信问题,求助
- 各种程序中的向导功能是怎么做出来的?
- 2天没合眼了啊 好心大哥大姐们帮帮啊``在线等``我==急啊;
- 请问:AfxDaoInit在未安装VC6的机器上运行时程序为什么死掉?
- 如何发送键盘消息给输入法!!!
- MFC如何还原窗口属性
FileBasicInformation
Change the information that is supplied in a FILE_BASIC_INFORMATION structure. The caller must have opened the file with the FILE_WRITE_ATTRIBUTES flag set in the DesiredAccess parameter. FileDispositionInformation
Usually, sets the DeleteFile member of a FILE_DISPOSITION_INFORMATION to TRUE, so the file can be deleted when ZwClose is called to release the last open handle to the file object. The caller must have opened the file with the DELETE flag set in the DesiredAccess parameter. FileEndOfFileInformation
Change the current end-of-file information, supplied in a FILE_END_OF_FILE_INFORMATION structure. The operation can either truncate or extend the file. The caller must have opened the file with the FILE_WRITE_DATA flag set in the DesiredAccess parameter.FileIoPriorityHintInformation
Change the current default IRP priority hint for the file handle. The new value is supplied in a FILE_IO_PRIORITY_HINT_INFORMATION structure.
Note This structure must be 8-byte aligned.
FileLinkInformation Create a hard link to an existing file, which is specified in a FILE_LINK_INFORMATION structure. Not all file systems support hard links; for example NTFS does while FAT does not.
FilePositionInformation
Change the current file information, which is stored in a FILE_POSITION_INFORMATION structure. FileRenameInformation
Change the current file name, which is supplied in a FILE_RENAME_INFORMATION structure. The caller must have DELETE access to the file. FileShortNameInformation
Change the current short file name, which is supplied in a FILE_NAME_INFORMATION structure. The file must be on an NTFS volume, and the caller must have opened the file with the DesiredAccess DELETE flag set in the DesiredAccess parameter. FileValidDataLengthInformation
Change the current valid data length for the file, which is supplied in a FILE_VALID_DATA_LENGTH_INFORMATION structure. The file must be on an NTFS volume, and the caller must have opened the file with the FILE_WRITE_DATA flag set in the DesiredAccess parameter. Nonadministrators and remote users must have the SeManageVolumePrivilege privilege.
根据返回值可以判断出原因。
先输出pFileObject->FileName.Buffer看看是不是全路径。
IN FILE_INFORMATION_CLASS FileInformationClass是变量!!
你那样不是写死了么,这个不是要看用户怎么调用!用户传的是什么枚举类型就是什么的!我比较菜,说错了理解下哈!
文件对象中的名称有时不是完整路径,而且不是一致有效的。
IO_STATUS_BLOCK isb = {0};
NTSTATUS res= ZwQueryInformationFile(FileHandle,&isb,&si,sizeof(FILE_NAME_INFORMATION),FileNameInformation);
if(NT_SUCCESS(res))
{
KdPrint(("FileName:[%s]",si.FileName));
}
KdPrint(("FileName ERROR %d",res));