How to fix SizeOfImage when loading a builtin dll ?

Laurent Pinchart laurent.pinchart at skynet.be
Wed May 29 04:21:18 CDT 2002


>
>
>>Hi everybody,
>>
>>I noticed that, when a builtin dll (.so) is loaded, the SizeOfImage field in 
>>the OptionalHeader is not updated and stays equal to page_size (see 
>>winebuild, spec32).
>>
>>I need to get the correct value in SizeOfImage.
>>
>>I thought about updating that field in map_dll at library/loader.c, but don't 
>>know how to get the size of the image.
>>
>>Could anyone help me ? I'm not familiar with the PE loader.
>>
>
>You can't find out the size of the image from the libdl API calls
>except going into heavy ELF parsing.
>
>winebuild does not really know either.
>
>My suggestion would be to use a heuristic like the one below. However
>it is not perfect, the sizes are too large sometimes.
>
>Ciao, Marcus
>
I thought about modifying winebuild to add

char _end[];
nt_headers->OptionalHeader.SizeOfImage = pe_header - _end;

in the library initialisation function. This is small, fast and probably 
more accurate.

Does anyone have any comment about that ?

Laurent Pinchart





More information about the wine-devel mailing list