Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does IMAGE_FILE_NET_RUN_FROM_SWAP in an EXE file affect runtime libraries

Tags:

windows

winapi

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?

like image 994
Trellmor Avatar asked Nov 27 '12 15:11

Trellmor


1 Answers

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.

like image 190
David Heffernan Avatar answered Nov 04 '22 16:11

David Heffernan