taviso / loadlibrary

Porting Windows Dynamic Link Libraries to Linux
GNU General Public License v2.0
4.34k stars 378 forks source link

Load more than one custom dll possible? #76

Closed jsc-paneda closed 2 years ago

jsc-paneda commented 4 years ago

I have successfully used loadlibrary to load a custom dll and used some of its functions.

However one of the dll functions has a dependency to the GetVersionExA in the kernel32.dll.

So I used 'detours' to create a myhook.dll that replaces this function. This worked fine on Windows. However on Linux side I realized that I pretty much only replaced the kernel32.dll dependency with myhook.dll dependency. And so the issue remains.

If only I could somehow load myhook.dll also? Or is there some other way? Or do I need Wine? Its all a bit of black magic right now..

cube0x8 commented 3 years ago

Umh... I know I am commenting something quite old, but here you can find the hook for the API you need.

So, if your DLL has only that dependency, I guess you should be fine.

jsc-paneda commented 3 years ago

Yes a bit old, trying to remember myself..but I think the question was meant as a general question regarding possibility to load multiple dll:s, i.e. 'yes' or 'no'. As I recall my conclusion was 'no' and would just like to get confirmation on that.

cube0x8 commented 3 years ago

I am quite sure that the short answer to your question is: no.

i.e. if your .dll calls some of the kernel32.dll APIs, you cannot use loadlibrary to load your .dll along with kernel32.dll to make your dll able to use the exported functions of kernel32.dll.

Anyway, keep in mind that this does not mean you cannot load your dll at all if it calls third-party APIs. You can still load it, using the loadlibrary's hooks.

I hope I explained myself better this time.

jsc-paneda commented 3 years ago

Understood and as I expected. Thanks, btw I'm using loadlibrary in my app successfully so I'm very pleased with your time and effort to put this together!

cube0x8 commented 2 years ago

This can be considered a duplicate of #101