[fpc-devel] Manual reload of a DLL snapshot (with relocations) causes multiple AV

Sergei Gorelkin sergei_gorelkin at mail.ru
Fri Jan 6 18:44:15 CET 2012


06.01.2012 18:07, Gennadiy Poryev пишет:
> = Preamble =

> First, I'd like to know why calling of DLL entry point anew does not re-initialize _all_ RTL
> internals regardless of what was remembered prior to taking the snapshot. Is it just assuming good
> behavior of system loader that carefully zeroes data segment while I don't?
>
The data segment is not necessarily zeroed, it can contain non-zero initial values. Once you load 
DLL using LoadLibrary and let its entrypoint run, it will overwrite initialized part with new values 
and there is no way to recover the original values.
In particular, tlsindex global variable is initalized with value of -1, not 0.

Several APIs exist which allow to load the image without invoking its entrypoint. LoadLibraryEx, 
MapImage, etc. They vary in processing imports and relocations, though.

Regards,
Sergei



More information about the fpc-devel mailing list