Visual Studio 2013开发 mini-filter driver step by step 获取文件读写内容(6)
来源:互联网 发布:实况足球球员数据库 编辑:程序博客网 时间:2024/06/04 23:34
由于后面的内容跟Visual Studio已经没有太大关系,故文章标题去掉Visual Studio前缀。
今天刚好在CSDN上读到一篇文章《程序员都要有八块腹肌》,所以要练好身体啊!其实我也想说,现代程序员要练好太极,才能以柔克刚,以一当十。
本文以获取文件写的内容为例,来探讨怎样获取写入的数据。
请先参考这个关于如何获取数据buffer的文章
http://msdn.microsoft.com/en-us/library/windows/hardware/ff554436(v=vs.85).aspx
请看下面的源代码获取数据的两种方式。
PFLT_FILE_NAME_INFORMATION file_name_info = NULL;
status = FltGetFileNameInformation(Data, FLT_FILE_NAME_NORMALIZED | FLT_FILE_NAME_QUERY_DEFAULT, &file_name_info);
if (NT_SUCCESS(status))
{
WCHAR *ssmfflag = L".ssmffile";
SIZE_T len = sizeof(WCHAR) * wcslen(ssmfflag);
if (file_name_info->Name.Length > wcslen(ssmfflag) &&
RtlCompareMemory((char*)ssmfflag, (char *)((char *)file_name_info->Name.Buffer + file_name_info->Name.Length - len), len) == len)
{
PT_DBG_PRINT(PTDBG_TRACE_ROUTINES, ("The file name is %wZ,the offset is %u,len is %u", file_name_info->Name, iopb->Parameters.Write.ByteOffset, writeLen));
if (iopb->Parameters.Write.MdlAddress == NULL)
{
try
{
RtlCopyMemory(buffer,
iopb->Parameters.Write.WriteBuffer,
min(writeLen, 90));
}
except(EXCEPTION_EXECUTE_HANDLER)
{
PT_DBG_PRINT(PTDBG_TRACE_ROUTINES, (""Exception occurred.\n"));
}
}
else
{//这个是针对direct io的。
PUCHAR buff = MmGetSystemAddressForMdlSafe(iopb->Parameters.Write.MdlAddress,
NormalPagePriority);
PT_DBG_PRINT(PTDBG_TRACE_ROUTINES, ("MDL"));
if (buff)
{
RtlCopyMemory(buffer,
buff,
min(writeLen, 90));
}
}
PT_DBG_PRINT(PTDBG_TRACE_ROUTINES, ("The data is %s", buffer));
}
FltReleaseFileNameInformation(file_name_info);
}
return FLT_PREOP_SUCCESS_WITH_CALLBACK;
上面的这段代码就是获取写入的数据并把前100个数据内容打印出来。
- Visual Studio 2013开发 mini-filter driver step by step 获取文件读写内容(6)
- Visual Studio 2013开发 mini-filter driver step by step (5) - 读写文件
- Visual Studio 2013开发 mini-filter driver step by step (1) - 创建 mini filter driver 工程
- Visual Studio 2013开发 mini-filter driver step by step (4) - 获取文件名
- Visual Studio 2013开发 mini-filter driver step by step 内核中使用线程(7)
- Visual Studio 2013开发 mini-filter driver step by step (11) driver 签名
- Visual Studio 2013开发 mini-filter driver step by step 获取可执行文件名称 - 实现process monitor的一个功能 (10)
- Visual Studio 2013开发 mini-filter driver step by step (2) - 编译,部署,运行
- Visual Studio 2013开发 mini-filter driver step by step (3) - 查看运行结果
- Visual Studio 2013开发 mini-filter driver step by step 应用层与内核通讯(8)
- Visual Studio 2013开发 mini-filter driver step by step 内核代码段分页alloc_text的使用(9)
- File System Mini Filter Driver Step by Step
- Introduction to Microsoft Visual Studio(for beginners)step by step
- Visual Studio 2010 step by step学习摘要
- Step By Step Mini Site Video Training
- iPhone开发step by step
- RMI开发 Step By Step
- Microsoft Visual C# 2005 Step by Step
- 打包APK问题
- hdu 1978(记忆化搜索)
- web前端开发高大上的jquery插件
- 易忽略的sprintf和printf用法
- 静态库管理
- Visual Studio 2013开发 mini-filter driver step by step 获取文件读写内容(6)
- 【WebGL初学系列之一】WebGl基础知识
- Struts2框架的使用方法
- .Net下的多媒体定时器(适用于Winform和WPF程序)
- Calabash-Android用法入门
- hdoj--1063 Exponentiation 解题报告
- 微信也能报案 你听说过吗
- github的使用方法之一
- MonoDevelop当保存时跳到最顶端解决办法