Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tweak DLL module name during LoadLibrary

I want to load at runtime a third party binary plug-in (P.dll) in my application (A.exe). This plug-in has been built for another application (B.exe).

The plug-in has implicit dll import on the B.exe module, like :

  • Module Name : B.exe
  • func1
  • func2
  • func3

I have exported the functions func1, func2 and func3 from A.exe but I can't load the dll with LoadLibrary because there is no module named "B.exe".

Is there something better to do than renaming my application "B.exe" or patching P.dll's PE ?

Thanks,

Cyril

like image 825
Hulud Avatar asked Nov 14 '22 14:11

Hulud


1 Answers

You can create fake B.exe, (actually it can be DLL), and redirect B.exe exports to A.exe .

Redirecting can be done by forwarding exports, see "Export Forwarding" section here.

like image 142
Abyx Avatar answered Dec 16 '22 04:12

Abyx