9

My application is sometimes started from an network share and some customers reported an External exception C0000006 when running the application. According to my Google research this "may" be related to the image getting paged out and the failing to reload from the network. A workaround for this is telling Windows to load the complete image file into the swap and run it from there by setting the IMAGE_FILE_NET_RUN_FROM_SWAP flag

My application also depends on various .bpl and .dll libraries that are loaded at runtime. Only some of those can be changed by me, some are supplied by other vendors. What happens to this libraries if the exe has this flag set? Are the also loaded into the swap file or are they still paged out and reloaded when needed? Would I need to include this flag in the libraries too?

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Trellmor
  • 634
  • 1
  • 7
  • 15

1 Answers1

9

The flag applies only to the PE module which sets it. So, setting the flag in an EXE does not mean that modules loaded by that EXE are affected by the flag. Each module (DLL, package etc.) that is loaded by your EXE will be treated by the loader according to the PE options specified in that module.

So, you'll need to set the PE flag on each module that resides on a network share.

For what it's worth, I'd recommend adding IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP as well.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thank you, I'll have to check if it will be possibly for my application to include this in all files. – Trellmor Nov 27 '12 at 16:51
  • 1
    You can use, for example, `editbin` from the MS toolchain, to modify PE flags. – David Heffernan Nov 27 '12 at 17:08
  • Silly question, but what is a "PE flag" and where do they get set? I've spent 15 minutes googling and can't figure out where to stick this thing called "IMAGE_FILE_NET_RUN_FROM_SWAP". – Tim Cooper Jun 11 '15 at 01:49
  • Is this the "Swap Run From Network" option I see in VC++ "Properties > Linker > System" ...? – Tim Cooper Jun 11 '15 at 01:56