How to extract a resource from a BPL?

If I have a resource in EXE and I want to extract it, it's pretty simple. Sort of:

stream := TResourceStream.Create(HInstance, ResourceName, RT_RCDATA); 

This works because the HInstance global variable is an EXE handle. Is there a similar way for the code inside the BPL to get the package descriptor of which it is a part, so I can extract the resource from it?

+4
source share
1 answer

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).

+7
source

Source: https://habr.com/ru/post/1344543/


All Articles