简体   繁体   English

Windows资源管理器和重新解析点文件:阻止资源管理器打开我的文件

[英]Windows Explorer and Reparse Point Files: keep Explorer from opening my files

I've implemented a user mode program and a Windows file system minifilter that creates a skeleton view of users files for a remote file storage system. 我已经实现了一个用户模式程序和一个Windows文件系统微型过滤器,该文件为远程文件存储系统创建用户文件的框架视图。 It maps the remote files to the local drive. 它将远程文件映射到本地驱动器。 The user mode program creates a reparse tag for each file on the remote system. 用户模式程序为远程系统上的每个文件创建一个reparse标签。 When a create request (eg, CreateFile for read) is detected, the minifilter asks the user mode program to download the file. 当检测到创建请求(例如,供读取的CreateFile)时,微型过滤器会要求用户模式程序下载文件。 This should only happen when a program wants to open the file for viewing or editing. 仅当程序要打开文件进行查看或编辑时,才应该发生这种情况。

But, I'm finding that Windows Explorer is triggering my files to download. 但是,我发现Windows资源管理器正在触发我的文件下载。 I'd like to prevent the Explorer File windows and File Open/Save dialogs from triggering downloads. 我想防止“资源管理器文件”窗口和“文件打开/保存”对话框触发下载。 And, I also want to display the file thumbnails and file size. 而且,我还想显示文件缩略图和文件大小。

[Update: I've found I can use Windows sparse files to show my remote file size in Explorer. [更新:我发现我可以使用Windows稀疏文件在资源管理器中显示远程文件的大小。 ] ]

Therefore, I have also implemented a Shell Extension, IThumbnailProvider, that downloads a rendition of the file. 因此,我还实现了一个Shell扩展IThumbnailProvider,可以下载该文件的副本。 This provides the file thumbnails. 这提供了文件缩略图。

For my testing, I've registered the IThumbnailProvider for all files (*) and for .jpg files. 为了进行测试,我已经为所有文件(*)和.jpg文件注册了IThumbnailProvider。

I'm seeing two interesting behaviors using a combination of Process Monitor and DebugView (both from SysInternals): 1. If I make my minifilter reject requests to open the file from Explorer, then my IThumbnailProvider is invoked. 我看到同时使用Process Monitor和DebugView的两种有趣行为(均来自SysInternals):1.如果我发出了微型过滤器拒绝从资源管理器打开文件的请求,则会调用IThumbnailProvider。 2. If I permit open requests from Explorer, I see thumbcache.dll in the call stack trying to open the file and my IThumbnailProvider is not called. 2.如果我允许来自Explorer的打开请求,则在调用堆栈中看到thumbcache.dll试图打开该文件,并且未调用我的IThumbnailProvider。 It appears that the default thumbnail provider reads the downloaded file and creates the thumbnail. 似乎默认的缩略图提供程序会读取下载的文件并创建缩略图。

I must be missing something. 我肯定错过了什么。

Update: if I use InitializeWithStream instead of InitializeWithFile, it appears my handler is invoked. 更新:如果我使用InitializeWithStream而不是InitializeWithFile,则看来我的处理程序已被调用。 But, that also triggers a download of the file. 但是,这也会触发文件下载。

There are many shell extension types which can access to your files. 有许多Shell扩展类型可以访问您的文件。 Icon handler can read file to create icon, Info tip handler can read file to create text hint, Data object handler can read file to create clipboard data and so on. 图标处理程序可以读取文件以创建图标,信息提示处理程序可以读取文件以创建文本提示,数据对象处理程序可以读取文件以创建剪贴板数据,等等。

Questions from developer with the same problem: first and second . 来自开发人员的具有相同问题的问题: 第一第二 Solution was to create namespace shell extension. 解决方案是创建名称空间外壳扩展。 NSE can control all access to your files. NSE可以控制对文件的所有访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM