0

Using the flags (based on this post)

IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP

and

IMAGE_FILE_NET_RUN_FROM_SWAP

It is possible to load the executable in memory when executable is in LAN path or in removable device.

Is there a way to achieve the same even when the exe is on a local disc?

I know there is little performance improvement but to get "rid of discs" it is an idea. I did not find such a compiler option in the docs.

Community
  • 1
  • 1
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249

1 Answers1

6

Is there a way to achieve the same even when the exe is on a local disc?

No there is not. There is no such PE flag. It would be rather pointless one imagines. Why would you want to copy from one location on your disk to another, and then load the copy of the image?

You talk about performance improvement with IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP and IMAGE_FILE_NET_RUN_FROM_SWAP, but you've got it the wrong way round. The performance is worse when you use these flags. That's because the entire image has to be read first, before the executable is mapped. Without these PE flags, the image can be mapped and only loaded on demand. Furthermore, you consume space in your swap file that can have negative implications.

You don't use these flags to improve performance because they do not improve performance, they make your program slower to start. You use these flags for reliability. Once the image has been copied to the local swap file, you are less likely to encounter hard page faults when trying to load part of the executable on demand.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thanks for the answer. I am aware that using those flags i slow down the application (in fact it takes more seconds to start expecially when exe is on a shared folder on a non fast network). In fact i made this for reliability, discussing with a colleegue he suggested to use ram instead of swap, swap in fact it is hard disc as you correctly pointed out. So since i never had reliability issues with an exe on the local hard disc i could discard this idea. – UnDiUdin Dec 22 '15 at 09:27