Hack Forums
[.NET] >> Merge DLL | Use DLL from Ressources | Remove Depencies | No ILMerge! << - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] >> Merge DLL | Use DLL from Ressources | Remove Depencies | No ILMerge! << (/showthread.php?tid=3762223)

Pages: Pages 1 2 3


>> Merge DLL | Use DLL from Ressources | Remove Depencies | No ILMerge! << - Madara-Uchiha - Sep 19, 2013

Merge DLL's


I think, many people often asked this question theirself: "How can I merge my DLL with my exe, so I can use a standalone exe file without needing the DLL file in the same folder etc...
I had the same problem just a few hours ago, and found a solution which works pretty awesome! :)

Well, this method which works like a charm.
I'll show you this in a small little tutorial :)
First we will create our own little DLL


Part 1 - Create a DLL File


So start by launching Visual Basic and create a new Project. Choose Class Library to create a new DLL file.
You get Something like this:


Code
Public Class Class1

End Class


Change the Class1 to any name you like. This will be our DLL name when using the DLL in a project.
I call it TestDLL. So it should now look similar to this:


[img]http://s1.directupload.net/images/130919/we2ves46.png[/img]


Now we create to little functions, so our DLL can do some stuff.
First, I create a Public Function which returns the computername, and second I create a Public Function which returns the Operating System name. Of course you can add whatever you like your DLL be able to do. You can also just use other .Net DLLs, downloaded from the web.
This should now look like this:


[img]http://s7.directupload.net/images/130919/jhyxlul6.png[/img]


Then compile the DLL. It will now created inside the Debug folder of your project.


Part 2 - Create Main Application


Now we are going to create our Main program which requires the DLL file. We will remove the Depencies from this Application and merge the DLL and the executable together.
But calm down and go step by step ^^
So, Start by creating a new Windows Form Application.
Just add Two Buttons and Title one of the "Computername" and the second one "Operating System".
This should now look like this:


[img]http://s1.directupload.net/images/130919/nof37tvc.png[/img]


Now go to Project >> Add Reference and search our TestDLL.dll on your computer. Then you add it as reference.
Till now its just like we use it normally.
Now type at the top of your Code:


Code
Imports TestDLL


Now below the Public Class Form1 we are going to type:


Code
Dim MyDLL As New TestDLL.TestDLL


Now just doubleclick the first and second button and call the functions of the dll file:


[img]http://s7.directupload.net/images/130919/n6zw7hpn.png[/img]


Part 3 - Add DLL as Ressource and merge it with Main Application


Now we are going to do the most important part. We remove the depencies by merging the DLL with the Main Application as a Ressource File.
Go To My Project in The Project Explorer.

Go to the Ressource Tab.
Add your TestDLL.dll as a ressource file.

Now go to the Application Tab and Click on Application Events.
You will get something like this (in your native language of course):


[img]http://s14.directupload.net/images/130919/n9hzhur3.png[/img]


Now inside the Partial Friiend Class MyApplication you are going to paste this code:


Code
Partial Friend Class MyApplication
  Private WithEvents DLLDomain As AppDomain = AppDomain.CurrentDomain
  Private Function DLL_AssemblyResolve(ByVal sender As Object, ByVal args As System.ResolveEventArgs) As System.Reflection.Assembly Handles DLLDomain.AssemblyResolve
    If args.Name.Contains("TestDLL") Then
    Return System.Reflection.Assembly.Load(My.Resources.TestDLL)
    Else
    Return Nothing
    End If
  End Function
    End Class


You basiclly paste the name of TestDLL (or whatever DLL you like to merge) without the .dll at the end in the right places.
After this is done, you are finished with this, we are done!!

Compile your Application and you can use it as a standalone exe file.
You don't need the DLL file to be with your App.
Whenever you use it, the App will automaticlly use it from the ressources without extracting it.
This can be used for Rat Servers if they need DLL's or just If you are to lazy to get two files.
Everything compact in one executable!!

This will only work with .net DLL's.
C++ DLL's are not working with this method!


I hope u liked the Tutorial :)





* - mullinupp - Sep 19, 2013

I like ur Tuts and such my friend keep it up :) <3


* - Madara-Uchiha - Sep 19, 2013

Thanks, I am glad u like this.
Its pretty useful when creating RAT's, Keyloggers which require some DLL's to work.
So you can give only one .exe file and there is no need to bring the .DLL file always with you :)


* - SIM-1456245 - Sep 19, 2013

WoW, you always impress me man, congrats.


* - Marwix - Sep 19, 2013

Nice tutorials as always, keep upp the good works bro ;-) - Allan


* - Spadassin150 - Sep 19, 2013

Great tutorial keep up the great work bro :)


* - Madara-Uchiha - Sep 20, 2013

Thank you guys for commenting. I am glad this tutorial has helped you:)


* - Mr. Evil - Dec 26, 2013

Nice TUT man, With this basics is easy to introduce to "hard" and advanced things.


* - Madara-Uchiha - Dec 26, 2013

I am glad you liked it. I hope you can use it :)


* - iNViSi8LE - Dec 27, 2013

Thank for good tutorial! Thats useful thing. Il give you credits :)


* - Golden Kappa - Dec 27, 2013

Another very good tutorial, thank you very much ;)


* - HskCool78 - Dec 27, 2013

Thanks dude very usefully !!!! i have search this for 3 month :D


* - Madara-Uchiha - Dec 28, 2013

(Dec 27, 2013 10:06 PM)HskCool78 Wrote:  Thanks dude very usefully !!!! i have search this for 3 month :D
3 months... really dude? O_o
Well then enjoy :)


* - Giommi - Dec 28, 2013

(Dec 27, 2013 10:06 PM)HskCool78 Wrote:  Thanks dude very usefully !!!! i have search this for 3 month :D

lol i just released the same 2 years ago. but i used the title "integrate dll"


* - ๖ۣۜXilluX - Dec 29, 2013

Again another great Tutorial from you ! :D