![]() |
|
#1
|
|||
|
|||
|
How to add code to dll?
I have a Windows x86 .dll file (specifically its a mixed mode Managed C++ and Native C++ dll if that makes a difference) and I want to add some new code and data
to that dll including adding the necessary entries to the .reloc segment. What's the best way to do that? The code and data I want to add is already in a different version of the same .dll as binary assembler instructions (obviously I would need to fix up the addresses to point to the right places in the dll I am modifying) and I don't need to touch the managed side of things. |
|
#2
|
||||
|
||||
|
There are many ways to add your own code to a DLL.
I recommend writing your own dynamic library (DLL) and attaching it to the target DLL via the import table. In your DLL's DllMain, perform the initialization and patch the necessary code sections to link them to your code.
__________________
EnJoy! |
| The Following User Says Thank You to Jupiter For This Useful Post: | ||
niculaita (12-07-2025) | ||
|
#3
|
|||
|
|||
|
Another way is to just load the dll, add a trampoline to your own code, and return. If its out of process, maybe just create a code section, add code you want, and start a remote thread to run it.
I guess a lot depends on what your ultimate goal is. Just to extend some functionality, or add new functions, etc. Does the old functions need to call the new code etc. |
|
#4
|
||||
|
||||
|
My suggestion is similar to Jupiter's method, but with a Proxy method.
That is, a Proxy dll. |
![]() |
|
|