question

09917186 avatar image
0 Votes"
09917186 asked ·

How to programmatically unload / remove an executable from (superfetch?) cache ?

We are manufacturer of a printer device and its printer driver. In the list of driver's dependent files (see Windows Registry "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\<printer name>\Dependent Files" as illustration on term "dependent file") is, amongst others, an executable, let's call it PostProc.exe. During print process, PostProc.exe is started by driver's User Interface part (let's call it MyDriversUI.dll). It allows users to post-process print data.

When updating / upgrading from older version of printer driver to newer one, new version of PostProc.exe is correctly copied to driver directory (like C:\Windows\System32\spool\drivers\x64\3), in this process overwriting the old version. But unfortunately, at least until next spooler restart, Windows does not run this new version, but old one instead, because old version is still loaded in cache. In WinDbg, I see Windows' debug output line

"Application "\??\C:\Windows\system32\spool\DRIVERS\x64\3\PostProc.exe" found in cache"

A simple - but clumsy - solution would be to just rename new version of PostProc.exe to Post_Proc.exe. This would force Windows to run new Post_Proc.exe instead of old PostProc.exe. But of course we do not want to rename it every time we release a new version, especially we don't want to adapt MyDriver.inf, MyDriversUI.dll, and user manual every time, since our product is already out on the market.

I have read some articles on superfetch cache and memory management functions, but none of them seems to suggest a solution. I have also studied the numerous parameters of CreateProcessAsUser, with which I start PostProc.exe, but none of them appeared promissing to me. We do have an installation programm, which could implement a programmatical solution, but some Windows Server administrators do not want third party software to install anything on their system. They prefer manual driver update by opening Printer Property Pages, tab "Advanced", button "New driver" instead. With this said, our problem splits into 3 parts:

a) programmatical solution, which could be implemented in our installation programm

b) manual solution, which human administrator could carry out. Needless to say that "restart your spooler at least twice" is not an instruction, which would make administrators happy, because during spooler restart, nobody in the whole network can print, no matter whether to our device or to any other device. It also does not help to rename or delete old C:\Windows\system32\spool\DRIVERS\x64\3\PostProc.exe - as long as old PostProc.exe is loaded in cache, Windows uses it.

c) programmatical solution, which could be implemented in MyDriversUI.dll - this would cover both a) and b), making them superfluous.

And finally, just for curiosity: Does Microsoft consider the fact that Windows runs an executable, which Windows' Driver Update Wizard has already overwritten on harddisk, as a bug or as works-as-designed ?

windows-hardware-wdk-general
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

09917186 avatar image
0 Votes"
09917186 answered ·

Please consider as solved. It turned out to be a misconclusion drawn from extremely improbable coincidences and circumstances, and a misinterpretation of test results among several testers.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.