Reputation: 9
I disassemled a game's DLL and want to insert some code. I need asm code to call another DLL in the current directory(I'm on Windows). The background is, that I want to be able to execute custom code in my DLL, but I can't load the DLL. So my idea was to load the DLL via modified game DLL.
There may be a function in the game which gives me the current directory path the DLL's are but I think I won't find it.
Upvotes: 0
Views: 4031
Reputation: 18320
Microsoft Detours comes with setdll.exe
and withdll.exe
, those utilities will let you start an exe with a custom dll file.
Upvotes: 3
Reputation:
The calls you are looking for are LoadLibrary, which will search in a selection of places including the current directory for the DLL and then load it, then GetProcAddress.
If the DLL makes any other Win32 calls it is probably already linked against kernel32.dll
, so that's all you need to do.
It is arguable as to whether modifying the DLL or using DLL injection is faster in terms of how long it takes to write the code since you're going to have to reverse engineer anyway, however, one advantage of pure DLL injection is that all existing code remains unmodified in terms of the installation, making these modifications easier to undo should the user wish to "unpatch" whatever you are doing.
Upvotes: 3