2

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. It maps the remote files to the local drive. The user mode program creates a reparse tag for each file on the remote system. When a create request (e.g., CreateFile for read) is detected, the minifilter asks the user mode program to download the file. 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. 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. ]

Therefore, I have also implemented a Shell Extension, IThumbnailProvider, that downloads a rendition of the file. This provides the file thumbnails.

For my testing, I've registered the IThumbnailProvider for all files (*) and for .jpg files.

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. 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. 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. But, that also triggers a download of the file.

alshamma
  • 33
  • 1
  • 5
  • 2
    Set the `FILE_ATTRIBUTE_OFFLINE` file attribute. This indicates that [the file is will trigger a download when accessed](http://blogs.msdn.com/b/oldnewthing/archive/2005/11/28/497442.aspx). Explorer respects this attribute and tries to avoid triggering downloads automatically. Other shell extensions are expected to respect the attribute as well. – Raymond Chen May 29 '15 at 07:37
  • @RaymondChen - I am experimenting with `FILE_ATTRIBUTE_OFFLINE` on Windows Server 2012. I've unregistered my Shell Extensions and restarted Explorer. Explorer shows the files as offline in Properties pane (Availability: Online-only). But, I still see my minifilter PostCreateCallback for IRP_CREATE being called with STATUS_REPARSE from Explorer.exe with desired access 0x00120089. From ProcMon, it appears it is being opened by thumbcache.dll. – alshamma Jun 02 '15 at 19:53

1 Answers1

0

There are many shell extension types which can access to your files. 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.

Community
  • 1
  • 1
Denis Anisimov
  • 3,297
  • 1
  • 10
  • 18