How to fix SizeOfImage when loading a builtin dll ?

Laurent Pinchart laurent.pinchart at
Fri May 31 17:28:41 CDT 2002

On Friday 31 May 2002 19:42, Alexandre Julliard wrote:
> Laurent Pinchart <laurent.pinchart at> writes:
> > I tried the code described above, but it unfortunately doesn't work for
> > all dlls. It returns a correct value in some cases (for small dlls it
> > seems), and a huge negative value around 0xc0000000 in other cases (for
> > bigger dlls).
> Most likely the problem is with dlls that aren't properly separated
> yet. Since they don't use -Bsymbolic _end will resolve to the wrong
> symbol.
> I looked into my old linker script stuff but I'm afraid it won't help
> in this case. We used it mostly to put the PE header at the right
> place but the current solution should work just as well for that.
> So I'd suggest using _end and related symbols, maybe with a configure
> check, and fall back to some hackish solution for non-separated dlls.

I computing SizeOfImage by looking for the highest address in the export 
table. This works for all separated dlls. As you stated _end should work for 
all separated dlls, so it should be the way to go, with a fallback on export 
table highest address lookup. When all dlls will be properly separated the 
fallback won't be necessary anymore.

I still have a problem with DeviceIoControl, which is exported by kernel32.dll 
but located in ntdll.dll. I moved it to kernel32.dll as a wrapper and let the 
code in ntdll.dll. This is hackish, but works, so I can continue with 
SafeDisc support.

Is someone working on DLL separation for ntdll.dll / kernel32.dll ? It seems 
that there's a lot of work to be done.

Laurent Pinchart

More information about the wine-devel mailing list