* dll_init.cc (dll_list::alloc): Initialize dll::image_size.

(reserve_at): Don't reserve space needed by the target dll if the latter
overlaps the free region to be blocked.
(dll_list::load_after_fork): Use new version of reserve_at.
* dll_init.h (dll::image_size): New member.
(pefile): New struct.
This commit is contained in:
Christopher Faylor
2011-05-28 20:55:34 +00:00
parent 07f89f85db
commit 6cd2e18523
3 changed files with 48 additions and 6 deletions

View File

@ -52,6 +52,7 @@ struct dll
int count;
bool has_dtors;
dll_type type;
DWORD image_size;
WCHAR name[1];
void detach ();
int init ();
@ -109,6 +110,24 @@ public:
dll_list () { protect.init ("dll_list"); }
};
/* References:
http://msdn.microsoft.com/en-us/windows/hardware/gg463125
http://msdn.microsoft.com/en-us/library/ms809762.aspx
*/
struct pefile
{
IMAGE_DOS_HEADER dos_hdr;
char* rva (long offset) { return (char*) this + offset; }
PIMAGE_NT_HEADERS32 pe_hdr () { return (PIMAGE_NT_HEADERS32) rva (dos_hdr.e_lfanew); }
PIMAGE_OPTIONAL_HEADER32 optional_hdr () { return &pe_hdr ()->OptionalHeader; }
PIMAGE_DATA_DIRECTORY idata_dir (DWORD which)
{
PIMAGE_OPTIONAL_HEADER32 oh = optional_hdr ();
return (which < oh->NumberOfRvaAndSizes)? oh->DataDirectory + which : 0;
}
};
extern dll_list dlls;
void dll_global_dtors ();