<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>知识库 &#187; miniFilter</title>
	<atom:link href="http://www.wezu.net/blog/archives/category/%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0/minifilter/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wezu.net/blog</link>
	<description>知识就是力量，知识就是财富！</description>
	<lastBuildDate>Fri, 06 Feb 2009 03:15:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>FltReadFile</title>
		<link>http://www.wezu.net/blog/archives/43</link>
		<comments>http://www.wezu.net/blog/archives/43#comments</comments>
		<pubDate>Thu, 27 Nov 2008 07:29:31 +0000</pubDate>
		<dc:creator>snox</dc:creator>
				<category><![CDATA[miniFilter]]></category>
		<category><![CDATA[FltReadFile]]></category>

		<guid isPermaLink="false">http://www.wezu.net/blog/?p=43</guid>
		<description><![CDATA[FltReadFile 从一个打开的文件、流或者设备中读取数据。 NTSTATUS   FltReadFile(     IN PFLT_INSTANCE  InitiatingInstance,     IN PFILE_OBJECT  FileObject,     IN PLARGE_INTEGER  ByteOffset OPTIONAL,     IN ULONG  Length,     OUT PVOID  Buffer,     IN FLT_IO_OPERATION_FLAGS  Flags,     OUT PULONG  BytesRead OPTIONAL,     IN PFLT_COMPLETED_ASYNC_IO_CALLBACK  CallbackRoutine OPTIONAL,     IN PVOID  CallbackContext OPTIONAL     );  参数 InitiatingInstance Opaque instance pointer for the minifilter driver instance that is initiating the read request. This parameter is required and cannot be NULL. FileObject Pointer to a file object for the file that the data is to be read from. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>FltReadFile</strong> 从一个打开的文件、流或者设备中读取数据。</p>
<p>NTSTATUS<br />
  FltReadFile(<br />
    IN PFLT_INSTANCE  <em><a class="synParam" onclick="showTip(this)" href="about:blank">InitiatingInstance</a></em>,<br />
    IN PFILE_OBJECT  <em><a class="synParam" onclick="showTip(this)" href="about:blank">FileObject</a></em>,<br />
    IN PLARGE_INTEGER  <em><a class="synParam" onclick="showTip(this)" href="about:blank">ByteOffset</a> </em>OPTIONAL,<br />
    IN ULONG  <em><a class="synParam" onclick="showTip(this)" href="about:blank">Length</a></em>,<br />
    OUT PVOID  <em><a class="synParam" onclick="showTip(this)" href="about:blank">Buffer</a></em>,<br />
    IN FLT_IO_OPERATION_FLAGS  <em><a class="synParam" onclick="showTip(this)" href="about:blank">Flags</a></em>,<br />
    OUT PULONG  <em><a class="synParam" onclick="showTip(this)" href="about:blank">BytesRead</a> </em>OPTIONAL,<br />
    IN PFLT_COMPLETED_ASYNC_IO_CALLBACK  <em><a class="synParam" onclick="showTip(this)" href="about:blank">CallbackRoutine</a></em> OPTIONAL,<br />
    IN PVOID  <em><a class="synParam" onclick="showTip(this)" href="about:blank">CallbackContext</a></em> OPTIONAL<br />
    ); </p>
<dl>
<h4>参数</h4>
<dt><em>InitiatingInstance</em> </dt>
<dd>Opaque instance pointer for the minifilter driver instance that is initiating the read request. This parameter is required and cannot be NULL. </dd>
<dt><em>FileObject</em> </dt>
<dd>Pointer to a file object for the file that the data is to be read from. This file object must be currently open. Calling <strong>FltReadFile</strong> when the file object is not yet open or is no longer open (for example, in a pre-create or post-cleanup callback routine) causes the system to ASSERT on a checked build. This parameter is required and cannot be NULL. </dd>
<dt><em>ByteOffset</em> </dt>
<dd>Pointer to a caller-allocated variable that specifies the starting byte offset within the file where the read operation is to begin.If this offset is supplied, or if the FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET flag is specified in the <em>Flags</em> parameter, <strong>FltReadFile</strong> does not update the file object&#8217;s <strong>CurrentByteOffset</strong> field.If the file object that <em>FileObject</em> points to was opened for synchronous I/O, the caller of <strong>FltReadFile</strong> can specify that the current file position offset be used instead of an explicit <em>ByteOffset</em> value by setting this parameter to NULL. If the current file position is used, <strong>FltReadFile</strong> updates the file object&#8217;s <strong>CurrentByteOffset</strong> field by adding the number of bytes read when it completes the read operation.</p>
<p>If the file object that <em>FileObject</em> points to was opened for asynchronous I/O, this parameter is required and cannot be NULL.</p>
</dd>
<dt><em>Length</em> </dt>
<dd>Size, in bytes, of the buffer that the <em>Buffer</em> parameter points to. </dd>
<dt><em>Buffer</em> </dt>
<dd>Pointer to a caller-allocated buffer that receives the data that is read from the file. </dd>
<dt><em>Flags</em> </dt>
<dd>Bitmask of flags specifying the type of read operation to be performed. <strong></strong></p>
<table border="0">
<tbody>
<tr valign="top">
<th>标志</th>
<th>含义</th>
</tr>
<tr valign="top">
<td>FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET</td>
<td>Minifilter drivers can set this flag to specify that <strong>FltReadFile</strong> should not update the file object&#8217;s <strong>CurrentByteOffset</strong> field.</td>
</tr>
<tr valign="top">
<td>FLTFL_IO_OPERATION_NON_CACHED</td>
<td>Minifilter drivers can set this flag to specify a noncached read, even if the file object was not opened with FILE_NO_INTERMEDIATE_BUFFERING.</td>
</tr>
<tr valign="top">
<td>FLTFL_IO_OPERATION_PAGING</td>
<td>Minifilter drivers can set this flag to specify a paging read.</td>
</tr>
</tbody>
</table>
<p> </p>
</dd>
<dt><em>BytesRead</em> </dt>
<dd>Pointer to a caller-allocated variable that receives the number of bytes read from the file. If <em>CallbackRoutine</em> is not NULL, this parameter is ignored. Otherwise, this parameter is optional and can be NULL. </dd>
<dt><em>CallbackRoutine</em> </dt>
<dd>Pointer to a <a href="http://www.wezu.net/blog/wp-admin/fltcallbacks_b85c12a6-7d3b-4d0c-9d21-9d9613aa057c.xml.htm">PFLT_COMPLETED_ASYNC_IO_CALLBACK</a>-typed callback routine to call when the read operation is complete. This parameter is optional and can be NULL. </dd>
<dt><em>CallbackContext</em> </dt>
<dd>Context pointer to be passed to the <em>CallbackRoutine</em> if one is present. This parameter is optional and can be NULL. If <em>CallbackRoutine</em> is NULL, this parameter is ignored. </dd>
</dl>
<h4>返回值</h4>
<p><strong>FltReadFile</strong> returns the NTSTATUS value that was returned by the file system.</p>
<h4>注释</h4>
<p>微过滤器调用 <strong>FltReadFile</strong> 从一个打开的文件中读取数据。</p>
<p><strong>FltReadFile</strong> 创建一个读请求并发送到微过滤器驱动挂载的进程后到文件系统。指定的进程之上的挂载进程则收不到读请求。</p>
<p><strong>FltReadFile</strong> 在下列条件成立时，准备非缓存I/O：</p>
<p><strong></strong></p>
<ul type="disc">
<li>调用者在参数 <em>Flags</em> 中设置了 FLTFL_IO_OPERATION_NON_CACHED 标志；</li>
<li>文件对象使用非缓存I/O打开的。通常是在调用 <a href="http://www.wezu.net/blog/wp-admin/fltapiref_a_to_d_2059a625-6d9e-4083-9c2e-d92e76c7539a.xml.htm"><strong>FltCreateFile</strong></a>, <a href="http://www.wezu.net/blog/wp-admin/fltapiref_a_to_d_3bc45f49-48cd-4c08-8906-09074f48e712.xml.htm"><strong><span style="text-decoration: underline;">FltCreateFileEx</span></strong></a>, 或 <strong>ZwCreateFile </strong>时，在参数<em>CreateOptions</em> 标志中指定了FILE_NO_INTERMEDIATE_BUFFERING 。 </li>
</ul>
<p>Noncached I/O imposes the following restrictions on the parameter values passed to <strong>FltReadFile</strong>:</p>
<p><strong></strong></p>
<ul type="disc">
<li>The buffer that the <em>Buffer</em> parameter points to must be aligned in accordance with the alignment requirement of the underlying storage device. To allocate such an aligned buffer, call <a href="http://www.wezu.net/blog/wp-admin/fltapiref_a_to_d_b617aed0-5103-4a1e-aa0d-86247d99e803.xml.htm"><strong>FltAllocatePoolAlignedWithTag</strong></a>.</li>
<li>The byte offset that the <em>ByteOffset</em> parameter points to must be a nonnegative multiple of the volume&#8217;s sector size.</li>
<li>The length specified in the <em>Length</em> parameter must be a nonnegative multiple of the volume&#8217;s sector size.</li>
</ul>
<p> </p>
<p>If an attempt is made to read beyond the end of the file, <strong>FltReadFile</strong> returns an error.</p>
<p>If the value of the <em>CallbackRoutine</em> parameter is not NULL, the read operation is performed asynchronously.</p>
<p>If the value of the <em>CallbackRoutine</em> parameter is NULL, the read operation is performed synchronously. That is, <strong>FltReadFile</strong> waits until the read operation is complete before returning. This is true even if the file object that <em>FileObject</em> points to was opened for asynchronous I/O.</p>
<p>If multiple threads call <strong>FltReadFile</strong> for the same file object, and the file object was opened for synchronous I/O, the Filter Manager does not attempt to serialize I/O on the file. In this respect, <strong>FltReadFile</strong> differs from <strong>ZwReadFile</strong>.</p>
<h4>Requirements</h4>
<p><strong>IRQL: </strong>PASSIVE_LEVEL</p>
<p><strong>Headers: </strong>Declared in <em>fltkernel.h</em>. Include <em>fltkernel.h</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wezu.net/blog/archives/43/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在miniFilter驱动里管理上下文</title>
		<link>http://www.wezu.net/blog/archives/42</link>
		<comments>http://www.wezu.net/blog/archives/42#comments</comments>
		<pubDate>Tue, 11 Nov 2008 07:06:55 +0000</pubDate>
		<dc:creator>snox</dc:creator>
				<category><![CDATA[miniFilter]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[上下文]]></category>

		<guid isPermaLink="false">http://www.wezu.net/blog/?p=42</guid>
		<description><![CDATA[上下文 是一个由微过滤器定义的结构，可以用于和一个过滤管理器对象关联。微过滤器可以微下列对象创建和设置上下文： 文件(Files，Vista及后续操作系统) 实例 卷 流 流句柄（File objects） Transactions(Files，Vista及后续操作系统) 除了卷上下文必须在非分页的内存池上分配，其他的既可以在非分页也可以在分页内存池中分配。 过滤管理器在他们挂载的对象删除后、微过滤器驱动实例从卷上解挂载或微过滤器卸载，自动删除相关的上下文。 注册上下文类型 当微过滤器驱动在DriverEntry中调用 FsRegisterFilter时，必须注册好每个要使用的上下文类型。 要注册上下文类型，微过滤器驱动创建一个类型为 FLT_CONTEXT_REGISTRATION 的变长数组。保持在 FLT_REGISTRATION 结构的 ContextRegistration 域中，传递到 FltRegisterFilter 函数的 Registration 参数。数组中的成员的顺序没有关系，但最后一个成员必须是 {FLT_CONTEXT_END}。 对于微过滤器驱动使用到的每一个上下文类型，FLT_CONTEXT_REGISTRATION 结构必须至少提供一个上下文定义。每一个FLT_CONTEXT_REGISTRATION结构定义了上下文的类型、大小和其他信息。 微过滤器驱动调用FltAllocateContext创建一个新的上下文，过滤管理器使用size参数 对于固定大小的上下文，FLT_CONTEXT_REGISTRATION结构的Size成员指定了字节大小，上下文的大小最大为MAXUSHORT(64KB)。0也是一个有效的值。过滤管理器用旁视列表分配固定大小的上下文。 对于不定大小的上下文，Size成员必须设置为FLT_VARIABLE_SIZED_CONTEXTS。过滤管理器直接从分页或非分页的内存池中分配不定长的上下文。 FLT_CONTEXT_REGISTRATION结构的Flags成员，可以指定FLTFL_CONTEXT_REGISTRATION_NO_EXACT_SIZE_MATCH。如果微过滤器驱动使用定长的上下文，并且指定了这个标志，上下文的大小大于等于请求的长度的话，过滤管理器从旁视列表里分配内存。否则上下文大小必须等于请求大小。 对于一个给定的上下文类型，微过滤器驱动可以支持3种固定大小（每一个大小不同）的上下文定义和1种变长定义。【更多信息，参见FLT_CONTEXT_REGISTRATION】 微过滤器驱动支持可选上下文释放前的清理回调例程。【参见 PFLT_CONTEXT_CLEANUP_CALLBACK】 微过滤器驱动可以定义一个他自己的分配、释放回调例程。【参见PFLT_CONTEXT_ALLOCATE_CALLBACK 和 PFLT_CONTEXT_FREE_CALLBACK】。 下面是从CTX示例中的部分代码，展示了一个用于注册实例、文件、流和文件对象（流句柄）的FLT_CONTEXT_REGISTRATION结构数组。]]></description>
			<content:encoded><![CDATA[<p><em>上下文</em> 是一个由微过滤器定义的结构，可以用于和一个过滤管理器对象关联。微过滤器可以微下列对象创建和设置上下文：</p>
<ul>
<li>文件(Files，Vista及后续操作系统)</li>
<li>实例</li>
<li>卷</li>
<li>流</li>
<li>流句柄（File objects）</li>
<li>Transactions(Files，Vista及后续操作系统)</li>
</ul>
<p>除了卷上下文必须在非分页的内存池上分配，其他的既可以在非分页也可以在分页内存池中分配。</p>
<p>过滤管理器在他们挂载的对象删除后、微过滤器驱动实例从卷上解挂载或微过滤器卸载，自动删除相关的上下文。</p>
<h3>注册上下文类型</h3>
<p>当微过滤器驱动在<strong>DriverEntry</strong>中调用 <strong>FsRegisterFilter</strong>时，必须注册好每个要使用的上下文类型。</p>
<p>要注册上下文类型，微过滤器驱动创建一个类型为 FLT_CONTEXT_REGISTRATION 的变长数组。保持在 FLT_REGISTRATION 结构的<strong> ContextRegistration</strong> 域中，传递到<strong> FltRegisterFilter</strong> 函数的<em> Registration</em> 参数。数组中的成员的顺序没有关系，但最后一个成员必须是 {FLT_CONTEXT_END}。</p>
<p>对于微过滤器驱动使用到的每一个上下文类型，FLT_CONTEXT_REGISTRATION 结构必须至少提供一个上下文定义。每一个FLT_CONTEXT_REGISTRATION结构定义了上下文的类型、大小和其他信息。</p>
<p>微过滤器驱动调用FltAllocateContext创建一个新的上下文，过滤管理器使用size参数</p>
<p>对于固定大小的上下文，FLT_CONTEXT_REGISTRATION结构的<strong>Size</strong>成员指定了字节大小，上下文的大小最大为MAXUSHORT(64KB)。0也是一个有效的值。过滤管理器用旁视列表分配固定大小的上下文。</p>
<p>对于不定大小的上下文，<strong>Size</strong>成员必须设置为FLT_VARIABLE_SIZED_CONTEXTS。过滤管理器直接从分页或非分页的内存池中分配不定长的上下文。</p>
<p>FLT_CONTEXT_REGISTRATION结构的<strong>Flags</strong>成员，可以指定FLTFL_CONTEXT_REGISTRATION_NO_EXACT_SIZE_MATCH。如果微过滤器驱动使用定长的上下文，并且指定了这个标志，上下文的大小大于等于请求的长度的话，过滤管理器从旁视列表里分配内存。否则上下文大小必须等于请求大小。</p>
<p>对于一个给定的上下文类型，微过滤器驱动可以支持3种固定大小（每一个大小不同）的上下文定义和1种变长定义。【更多信息，参见FLT_CONTEXT_REGISTRATION】</p>
<p>微过滤器驱动支持可选上下文释放前的清理回调例程。【参见 PFLT_CONTEXT_CLEANUP_CALLBACK】</p>
<p>微过滤器驱动可以定义一个他自己的分配、释放回调例程。【参见PFLT_CONTEXT_ALLOCATE_CALLBACK 和 PFLT_CONTEXT_FREE_CALLBACK】。</p>
<p>下面是从CTX示例中的部分代码，展示了一个用于注册实例、文件、流和文件对象（流句柄）的FLT_CONTEXT_REGISTRATION结构数组。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wezu.net/blog/archives/42/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
