Results 1 to 9 of 9
  1. #1
    NobDerp's Avatar
    Join Date
    Apr 2017
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    Inject a Dll in to a Exe

    I have the dll in the same folder, I have the inject button, what is the code that injects the dll into the exe?

    Thanks for your help Mpgh!
    Last edited by NobDerp; 11-05-2017 at 06:59 PM. Reason: useless information

  2. #2
    Kappatos's Avatar
    Join Date
    Jun 2015
    Gender
    male
    Posts
    152
    Reputation
    44
    Thanks
    11
    My Mood
    Cool
    Download the plugin for olly and inject it

  3. #3
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    1) Get target process handle
    2) Allocate memory in target process memory space
    3) Write dll name to allocated space
    4) Create a remote thread on LoadLibrary passing the address of previously allocated memory

    I'm not going to spoon feed you with code. There is more than enough source code for injectors in this forum

  4. The Following User Says Thank You to Biesi For This Useful Post:

    Trogrin (01-09-2018)

  5. #4
    NobDerp's Avatar
    Join Date
    Apr 2017
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    you don't have to send me the code, but can you send me the link of its thread? I cannot find a good/proper one, most of them are requesting the code, Thanks Biesi!
    Great Day!

  6. #5

  7. #6
    Nutty1337's Avatar
    Join Date
    Feb 2019
    Gender
    male
    Location
    Toronto
    Posts
    17
    Reputation
    10
    Thanks
    0
    My Mood
    Angelic
    search on mpgh, there's a project downloadable about it

  8. #7
    heiron70's Avatar
    Join Date
    Sep 2014
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    4
    here is some code thanks to sosha you have to add the components on the form (eg. comx) it is easy.

    - - - Updated - - -

    Imports System.Diagnostics
    Public Class Form1
    Dim ProcessIsReal As Integer
    Private TargetProcessHandle As Integer
    Private pfnStartAddr As Integer
    Private pszLibFileRemote As String
    Private TargetBufferSize As Integer

    Public Const PROCESS_VM_READ = &H10
    Public Const TH32CS_SNAPPROCESS = &H2
    Public Const MEM_COMMIT = 4096
    Public Const PAGE_READWRITE = 4
    Public Const PROCESS_CREATE_THREAD = (&H2)
    Public Const PROCESS_VM_OPERATION = (&H8)
    Public Const PROCESS_VM_WRITE = (&H20)
    Dim DLLFileName As String
    Public Declare Function ReadProcessMemory Lib "kernel32" ( _
    ByVal hProcess As Integer, _
    ByVal lpBaseAddress As Integer, _
    ByVal lpBuffer As String, _
    ByVal nSize As Integer, _
    ByRef lpNumberOfBytesWritten As Integer) As Integer

    Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _
    ByVal lpLibFileName As String) As Integer

    Public Declare Function VirtualAllocEx Lib "kernel32" ( _
    ByVal hProcess As Integer, _
    ByVal lpAddress As Integer, _
    ByVal dwSize As Integer, _
    ByVal flAllocationType As Integer, _
    ByVal flProtect As Integer) As Integer

    Public Declare Function WriteProcessMemory Lib "kernel32" ( _
    ByVal hProcess As Integer, _
    ByVal lpBaseAddress As Integer, _
    ByVal lpBuffer As String, _
    ByVal nSize As Integer, _
    ByRef lpNumberOfBytesWritten As Integer) As Integer

    Public Declare Function GetProcAddress Lib "kernel32" ( _
    ByVal hModule As Integer, ByVal lpProcName As String) As Integer

    Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _
    ByVal lpModuleName As String) As Integer

    Public Declare Function CreateRemoteThread Lib "kernel32" ( _
    ByVal hProcess As Integer, _
    ByVal lpThreadAttributes As Integer, _
    ByVal dwStackSize As Integer, _
    ByVal lpStartAddress As Integer, _
    ByVal lpParameter As Integer, _
    ByVal dwCreationFlags As Integer, _
    ByRef lpThreadId As Integer) As Integer

    Public Declare Function OpenProcess Lib "kernel32" ( _
    ByVal dwDesiredAccess As Integer, _
    ByVal bInheritHandle As Integer, _
    ByVal dwProcessId As Integer) As Integer

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Integer

    Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _
    ByVal hObject As Integer) As Integer


    Dim ExeName As String = IO.Path.GetFileNameWithoutExtension(Application.Ex ecutablePath)

    Private Sub Inject()

    On Error Resume Next

    Dim TargetProcess As Process() = Process.GetProcessesByName(ComboBox1.Text)
    TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
    pszLibFileRemote = OpenFileDialog1.FileName
    pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
    TargetBufferSize = 1 + Len(pszLibFileRemote)
    Dim Rtn As Integer
    Dim LoadLibParamAdr As Integer
    LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
    Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
    CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
    CloseHandle(TargetProcessHandle)
    Me.Show()
    Beep()
    Label1.Text = ComboBox2.Text + " Successfully Injected to " + ComboBox1.Text
    Timer1.Stop()
    Timer2.Enabled = True
    If CheckBox2.Checked = True Then
    Dim wannamaximized As String = ComboBox1.Text + ".exe"
    For Each p As Process In Process.GetProcessesByName(ComboBox1.Text)
    ShowWindow(p.MainWindowHandle, SHOW_WINDOW.SW_MAXIMIZE)
    Next p
    End If

    If CheckBox3.Checked = True Then
    ExitAfter.Enabled = True
    End If
    RadioButton3.Checked = False
    RadioButton1.Checked = True

    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick



    Dim TargetProcess As Process() = Process.GetProcessesByName(ComboBox1.Text)
    If TargetProcess.Length = 0 Then
    Me.Label1.Text = ("Waiting for " + ComboBox1.Text + ".exe")
    ProcessIsReal = 0

    Else

    Me.Label1.Text = "Process Found ! Now You Can Inject Your Dll"
    ProcessIsReal = 1
    End If
    Label2.Text = OpenFileDialog1.FileName
    Dim DllSafeFileName As String = OpenFileDialog1.SafeFileName.Replace(".dll", "")
    Label3.Text = "*_* " + DllSafeFileName + " *_*"

    If CheckBox1.Checked = True Then
    TextBox1.Enabled = True

    On Error Resume Next
    TimedInjection.Interval = TextBox1.Text * 1000
    Else
    TextBox1.Enabled = False
    End If




    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    On Error Resume Next

    OpenFileDialog1.Filter = "DLL (*.dll) |*.dll|(*.*) |*.*"
    OpenFileDialog1.ShowDialog()
    Dim FileName As String
    FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1 .FileName.LastIndexOf(""))
    Dim DllFileName As String = FileName.Replace("", "")
    Me.ComboBox2.Text = (DllFileName)

    End Sub
    Private Sub CheckInjectiftimedornot()
    If CheckBox1.Checked = True Then
    TimedInjection.Enabled = True
    Button4.Text = "Please Wait ..."
    Button4.Enabled = False
    Else
    Call Inject()
    End If
    End Sub
    Private Sub CheckInject()
    If ComboBox2.Text <> "" Then
    Call CheckInjectiftimedornot()
    Else
    MsgBox("Please select a Dll file", MsgBoxStyle.Information, "File not found")

    End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    If ProcessIsReal = 0 Then
    MsgBox("Please select a process first", MsgBoxStyle.Information, "Process not found")
    Else
    Call CheckInject()
    End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
    Dim allProcess As Process
    For Each allProcess In Process.GetProcesses()
    ComboBox1.Items.Add(allProcess.ProcessName)
    Next
    Catch exx As Exception
    ComboBox1.Items.Add("ERROR")
    End Try
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    Timer1.Start()
    Timer2.Enabled = True


    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    On Error Resume Next
    OpenFileDialog2.Filter = "EXE (*.exe) |*.exe|(*.*) |*.*"
    OpenFileDialog2.ShowDialog()
    Dim FileExe As String
    FileExe = OpenFileDialog2.FileName.Substring(OpenFileDialog2 .FileName.LastIndexOf(""))
    Dim ExeFileNames As String = FileExe.Replace(".exe", "")
    Dim ExeFileName As String = ExeFileNames.Replace("", "")
    Me.ComboBox1.Text = (ExeFileName)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    End
    End Sub

    Private Sub TimedInjection_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimedInjection.Tick
    Call Inject()
    TimedInjection.Enabled = False
    Button4.Text = "Inject"
    Button4.Enabled = True
    End Sub

    Private Sub ExitAfter_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitAfter.Tick
    End
    End Sub

    Private Declare Function ShowWindow Lib "user32.dll" ( _
    ByVal hWnd As IntPtr, _
    ByVal nCmdShow As SHOW_WINDOW _
    ) As Boolean

    Private Enum SHOW_WINDOW As Integer
    SW_HIDE = 0
    SW_SHOWNORMAL = 1
    SW_NORMAL = 1
    SW_SHOWMINIMIZED = 2
    SW_SHOWMAXIMIZED = 3
    SW_MAXIMIZE = 3
    SW_SHOWNOACTIVATE = 4
    SW_SHOW = 5
    SW_MINIMIZE = 6
    SW_SHOWMINNOACTIVE = 7
    SW_SHOWNA = 8
    SW_RESTORE = 9
    SW_SHOWDEFAULT = 10
    SW_FORCEMINIMIZE = 11
    SW_MAX = 11
    End Enum

    Private Sub SelectFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectFileToolStripMenuItem.Click
    On Error Resume Next
    OpenFileDialog2.Filter = "EXE (*.exe) |*.exe|(*.*) |*.*"
    OpenFileDialog2.ShowDialog()
    Dim FileExe As String
    FileExe = OpenFileDialog2.FileName.Substring(OpenFileDialog2 .FileName.LastIndexOf(""))
    Dim ExeFileNames As String = FileExe.Replace(".exe", "")
    Dim ExeFileName As String = ExeFileNames.Replace("", "")
    Me.ComboBox1.Text = (ExeFileName)
    End Sub

    Private Sub SelectDllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectDllToolStripMenuItem.Click
    On Error Resume Next

    OpenFileDialog1.Filter = "DLL (*.dll) |*.dll|(*.*) |*.*"
    OpenFileDialog1.ShowDialog()
    Dim FileName As String
    FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1 .FileName.LastIndexOf(""))
    Dim DllFileName As String = FileName.Replace("", "")
    Me.ComboBox2.Text = (DllFileName)

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
    End
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
    AboutBox1.Show()
    End Sub

    Private Sub InjectToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InjectToolStripMenuItem.Click
    If ProcessIsReal = 0 Then
    MsgBox("Please select a process first", MsgBoxStyle.Information, "Process not found")
    Else
    Call CheckInject()
    End If
    End Sub

    Private Sub CheckAutoInject()
    If ComboBox2.Text <> "" Then
    Call CheckInjectiftimedornot()
    Else


    End If
    End Sub

    Private Sub AutoInject()
    If ProcessIsReal = 0 Then

    Else
    Call CheckAutoInject()

    End If


    End Sub

    Private Sub AutoCheck_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AutoCheck.Tick
    If RadioButton3.Checked = True Then


    Call AutoInject()
    End If
    End Sub

    Private Sub RefreshToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshToolStripMenuItem.Click
    ComboBox1.Items.Clear()
    Try
    Dim allProcess As Process
    For Each allProcess In Process.GetProcesses()
    ComboBox1.Items.Add(allProcess.ProcessName)
    Next
    Catch exx As Exception
    ComboBox1.Items.Add("ERROR")
    End Try
    End Sub
    End Class

  9. #8
    MikeRohsoft's Avatar
    Join Date
    May 2013
    Gender
    male
    Location
    Los Santos
    Posts
    797
    Reputation
    593
    Thanks
    26,314
    Quote Originally Posted by heiron70 View Post
    here is some code thanks to sosha you have to add the components on the form (eg. comx) it is easy.
    Beside the fact that there are existing Code-[code]Blocks[/code], is this the C# Forum and your Code, is very obviously Visual Basic...

  10. #9
    XoXlonG's Avatar
    Join Date
    Sep 2019
    Gender
    male
    Posts
    22
    Reputation
    10
    Thanks
    0
    Interesting try

Similar Threads

  1. [Help] Can't inject dll's in Sf2.exe, and where can I find a good Xigncode3 Bypass?
    By Unteroffizier901 in forum SKILL - Special Force 2 Hacks & Cheats
    Replies: 0
    Last Post: 08-13-2016, 06:17 PM
  2. [Help] After inject a dll to a .exe , in a conner appears text ! ~~ HELP ME FAST :(
    By AntiOptical in forum C++/C Programming
    Replies: 6
    Last Post: 03-02-2014, 04:01 PM
  3. [Solved] When ever i inject a DLL it says Waiting for .exe?
    By joeztest1 in forum Alliance of Valiant Arms (AVA) Help
    Replies: 5
    Last Post: 04-07-2013, 03:18 AM
  4. [Help Request] Injecting .dll files into Engine.exe (Combat Arms) crashes game
    By ukoshak in forum Combat Arms Help
    Replies: 2
    Last Post: 02-09-2013, 03:35 AM
  5. could not inject the dll...????Zeas simple....HELP!!!!
    By lox in forum Combat Arms Hacks & Cheats
    Replies: 1
    Last Post: 03-10-2009, 12:26 PM