The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RedXVII on April 21, 2006, 10:22:05 PM

Title: Unload part of PE
Post by: RedXVII on April 21, 2006, 10:22:05 PM
Ive compiled an executable witch has a few large bitmaps in its Resources. After ive loaded it with directx, i no longer need the them to be in the memory (i think). In fact i dont think i need the .rsrc section at all after that. Anyhow, my question; would it be worthwhile in anyway to unload this from memory seeing as im not going to be using it for anymore? If so, how would i go about doing this?

Another thing; Is it possible to make a section in a PE which is not loaded into memory on execution?

Thx  :U
Title: Re: Unload part of PE
Post by: hutch-- on April 21, 2006, 10:48:43 PM
Red,

As long as an EXE is not compressed, the OS is supposed to do this style of paging for you but you don't have much control of how it works. With a one off use of a bitmap, it sound like a perfect candidate for a DLL that uses LoadLibrary() GetProcAddress() which can be unloaded when you have the bitmap you want in seperate memory and you have perfect control of this mechanism.
Title: Re: Unload part of PE
Post by: RedXVII on April 21, 2006, 10:59:12 PM
Thats a nice idea, but errm...... as a kindof point, im trying to keep it to a single executable without any libraries (aka. dongles and doodles). If the OS handles it already, then ill just twiddle my thumbs and keep on going.  :bg

Thanks hutch
Title: Re: Unload part of PE
Post by: asmfan on April 22, 2006, 03:59:36 AM
Hi Red, i dont know is resource flag DISCARDABLE still usefull, but try... Also it's can be specified for entire section in linker options(D) like R or W or E for read,write and execute...
Title: Re: Unload part of PE
Post by: Vortex on April 22, 2006, 06:59:06 AM
If they are large, why not to store your images as bitmap files?
Title: Re: Unload part of PE
Post by: RedXVII on April 26, 2006, 03:02:23 PM
^^ as i was saying before, im trying to keep it in one neat executable, no extra files. Its kindof a point i want to make to a friend.

Its sounds to me like the OS handles it so im not worried really; just trying to keep my programs from resource hogging.