Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LoadLibraryEx / LOAD_LIBRARY_AS_IMAGE_RESOURCE

317 views
Skip to first unread message

lallous

unread,
Nov 24, 2010, 2:41:00 PM11/24/10
to
Hello,

When I LoadLibraryEx with LOAD_LIBRARY_AS_IMAGE_RESOURCE flag, the
returned hMod flag is the normal image base value + 2.

Example: LoadLibrary("f.dll") -> base = 0x10000000
LoadLibraryEx("f.dll", LOAD_LIBRARY_AS_IMAGE_RESOURCE) -> base =
0x10000002

It is a bit misleading because I am trying to find the RVA of a given
resource and if I use the hMod I will get an off by two RVA.

(The flag DONT_RESOLVE_DLL_REFERENCES works fine, but what about the
aforementioned flag?)

Please advise.

--
Elias

RossettoeCioccolato

unread,
Nov 24, 2010, 6:25:19 PM11/24/10
to
This is by design. The module handle returned by LoadLibraryEx() is
supposed to be opaque, so MS is free to do whatever it wants with it. The
fact that the module handle is the base address on x86 and x64 platforms is
undocumented. If you want to rely on this undocumented behaviour (which a
lot of programmers do) you will need to mask off the flag bits in the module
handle before calculating the RVA.


rogero

unread,
Nov 25, 2010, 8:47:24 AM11/25/10
to

Not entirely sure I understand what you're trying to do...
but perhaps you can use the MapAndLoad function instead (from
imagehlp)?
And then use other functions, such as ImageRvaToVa(), to navigate
round the data.

Regards,
Roger.

0 new messages