Merge a .dll in the program ?

Posts 1–8 of 8 · Page 1 of 1
Merge a .dll in the program ?
In the past I have always done download from the web and inject. But I would like to just inject a .dll that is built in the form. Is that possible? And how? Thanks.
To use standard injection methods you would need to add the dll to resources and then write it to the user's filesystem just before injecting
Quote Originally Posted by Jason View Post
To use standard injection methods you would need to add the dll to resources and then write it to the user's filesystem just before injecting
In the Solution Explorer, right-click on your project and click on the Resources Tab. Click on the little arrow next to Add Resource and click on Add Existing File. Browse to the DLL you would like to include in your project.

Then, when you want to extract the file you use this:
[highlight=vb.net]IO.File.WriteAllBytes("filePathHere", My.Resources.DLLName[/highlight]
First add the DLL to your Resources.


Form1_Load (When Starting Form):

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	IO.File.WriteAllBytes("FILEPATH", My.Resources.DLLNAME
    End Sub
Form1_Unload (When Closing Form):

Code:
    Private Sub Form1_UnLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosed
                Dim DLLDelete As String
        DLLDelete = "FILEPATH"
        If System.IO.File.Exists(DLLDelete) = True Then
            System.IO.File.Delete(DLLDelete)
        End If
    End Sub
Quote Originally Posted by xx360 View Post
First add the DLL to your Resources.


Form1_Load (When Starting Form):

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	IO.File.WriteAllBytes("FILEPATH", My.Resources.DLLNAME
    End Sub
Form1_Unload (When Closing Form):

Code:
    Private Sub Form1_UnLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.FormClosed
                Dim DLLDelete As String
        DLLDelete = "FILEPATH"
        If System.IO.File.Exists(DLLDelete) = True Then
            System.IO.File.Delete(DLLDelete)
        End If
    End Sub
When Closing Form When Successful Injection?
Woops, I forgot the ) at the end lol. Also if you are going to inject the DLL you can't delete it because it will be in use by a process.
@master131 what i was thinking Hide it in a folder somewhere ?
You could generate a temporary file, that should be good enough.

[highlight=vb.net]Dim sTemporaryFilePath As String = IO.Path.GetTempFileName
IO.File.WriteAllBytes(sTemporaryFilePath, My.Resources.MyDLLFile)[/highlight]
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us