September 17th, 2025
like2 reactions

How can I get my shell thumbnail extractors to run in the same process?

We learned that Explorer uses the COM Surrogate as a sacrificial process when hosting thumbnail extraction plug-ins.

A customer had a thumbnail extraction plug-in for which preparing to perform the thumbnail extraction was expensive. But the way Explorer uses thumbnail extractors is that it loads an extractor, asks it to extract a thumbnail from a file, and then frees the extractor. There’s no real chance for one extractor to hand off cached state to the next extractor, so the second extractor has to start from scratch.

Is there a way to tell Explorer to load all the extractors into the same process and then tell each one, “Okay, transfer your state to the next guy,” and tell the last guy, “I’m done extracting, you can clean up now”?

No, there is no way to give Explorer precise instructions on how it should use thumbnail extractors, but that doesn’t mean you can’t build it yourself.

What you can do is create two COM objects. One is an in-process object that is the actual plug-in. The other is a multi-use out-of-process local server that does the work. The in-process plug-in forwards the thumbnail extraction requests to the local server. Since the local server is multi-use, all the plug-ins share a single server. and this allows the expensive resources to be shared.

In other words, when each surrogate process creates an in-process thumbnail extractor, don’t do the extraction in the surrogate process:

Surrogate 1   Surrogate 2
Plug-in

Resources
  Plug-in

Resources

Instead, put the extraction in the shared local server, so that one server does all the extracting and can reuse the expensive resources.

Surrogate 1   Local server   Surrogate 2
 
 
Plug-in
 
 
 
 
 
 
 
Extractor
 
Factory
Resource
 
Extractor
 
 
 
 
 
 
 
Plug-in
 
 

The local server can follow the traditional pattern of shutting down if all COM objects have been destroyed and no new ones have been created for 30 seconds.

The factory object is registered with COM via Co­Register­Class­Object as with any other COM local server. Register it as multiple-use so that all the plug-ins will share the same server.

The factory object can obtain the resources the first time it is asked to create an extractor, and then pass a shared reference to the resource to the extractor. Once 30 seconds elapse without any extractor, the server can shut down by revoking the factory (which causes it to release the resources).

Related reading: Forcing plug-ins to run in separate processes: How can I convert a third party in-process server so it runs in the COM surrogate?

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

1 comment

Discussion is closed. Login to edit/delete existing comments.

Sort by :
  • Ian Ginos

    I realize this is not what the subject is about, but why did the behavior of Saved Searches change in Windows 7 and later? In Windows Vista, if I open a Saved Search that returns a result that is itself (e.g., a Saved Search for all items with "ABC" in their filenames) opening that result will not open the Saved Search; it will just keep the current location in view since it is the same location.

    In Windows 7 to the present day, however, opening the same Saved Search treats it as a new Shell location in the hierarchy. If I...

    Read more