HInstance is actually located in the SysInit module, which is unique for each PE (package, exe, dll). A system in which the main part of the RTL compiler and auxiliary functions live together with packages if the rtl package is used.
So, the code shown above should work fine inside the package. MainInstance is probably what you consider an exe load descriptor (or even a DLL in some cases).
source share