Udostępnij za pośrednictwem


Touch the exe, after you added a manifest for it, in Vista

 

You are an enthusiastic and responsible developer. You love programming, and you love programming the right way.

So you get the latest and greatest Windows Vista. You try your hard-worked amazing.exe application in Vista. Did not work. Apparently, amazing.exe needs admin privilege to do wonderful things. But in Vista, the user by default does not have admin privilege.

You did your research. You understand that you need to add a manifest to your application, and declare that the application requires administrator in the manifest. So you added amazing.exe.manifest, and put it next to amazing.exe.

Did not work. Amazing.exe did not get admin privilege.

You double checked the syntax of the manifest. Yes, it is right. You compared it to another working example. Yes, they are the same. You run amazing.exe again. Still did not work.

You are angry. What is going on, Microsoft?

The truth is, in Windows Vista, in order to improve CreateProcess performance, we cache the fact that an exe has manifest or not. The key to this cache, are the full path of the exe, and the last modified time of the exe file.

After you execute the exe without manifest, when you add a manifest to the exe, in order for the OS to see the manifest, you need to change the last modified time of the exe (or simply say, touch the exe), to invalidate the cache entry for the exe.

The cache only exists in memory, and is never flushed to disk. On reboot the cache starts clean.

At the time we did the work, our measurement shows that the cache improved CreateProcess performance by 10-15% in warm case, when the application does not have manifest.

So remember, touch the exe, after you added a manifest for it, in Vista.

Comments

  • Anonymous
    October 28, 2006
    Petite information intéressante, lue sur le blog de Junfeng Zhang , à garder à l'esprit lorsque vous

  • Anonymous
    October 28, 2006
    Caching is a neat technique. But why you should speed up CreateProcess? A process will normally live thousands/millions times longer then the duration of single CreateProcess(). So at the end, you seem to gain nothing with this trick. Really, I'd like to see a scenario where this optimization helps much.

  • Anonymous
    October 30, 2006
    The comment has been removed

  • Anonymous
    November 30, 2006
    I found that even a full restart did not clear the cache. The Manifest was only detected if I used 'Touch', or renamed the file & manifest to a new filename. Is there a method to clear the cached entry?

  • Ryan Pertusio
  • Anonymous
    November 30, 2006
    Full restart should clear the cache. If it does not work for you, maybe your application is run during the boot.

  • Anonymous
    December 03, 2006
    I found that even a full restart did not clear the cache, too. I want to know whether there are any method to clear the cached entry, too.