Results 1 to 6 of 6
  1. #1
    Erorr_'s Avatar
    Join Date
    Mar 2016
    Gender
    male
    Posts
    47
    Reputation
    10
    Thanks
    17

    Inject dll into process PID

    Good evening, I spent a few days looking for the subject I mentioned in the title, "Inject dll in PID" ie "inject dll in process pid" '-', in case I have a difficulty in making this injection code.
    For example...
    This is the process -> "CombatArms.exe"
    This is the PID -> "2000"
    *(PROCESS, PID, DLL)

    I want to inject the dll into the process PID and I do not know how to do this line of code.
    *
    If anyone can help me, thank you!

    Good Job - 26/11/2016







  2. #2
    RoPMadM's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    __asm
    Posts
    226
    Reputation
    12
    Thanks
    251
    My Mood
    Cynical
    You can't inject a .net DLL into a native operating programm.
    There are ways to do this but they are horribly laborious.

    You can inject .net DLL's into .net programms.

    If you want to inject a DLL into native programms you need to write a native DLL (for example with C++).

  3. #3
    return_cheats's Avatar
    Join Date
    Jan 2017
    Gender
    male
    Location
    Behind You.
    Posts
    15
    Reputation
    10
    Thanks
    8
    My Mood
    Stressed
    Code:
     Dim dlls As New Dictionary(Of String, String)
    
        Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
        Private 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
        Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As UInteger) As Boolean
        Private 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
        Private 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, ByVal lpThreadId As Integer) As Integer
        Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
        Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
    
        Private Function Inject(ByVal pID As Integer, ByVal dllLocation As String) As Boolean
    
            Dim hProcess As Integer = OpenProcess(&H1F0FFF, 1, pID)
            If hProcess = 0 Then Return False
            Dim dllBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(dllLocation)
            Dim allocAddress As Integer = VirtualAllocEx(hProcess, 0, dllBytes.Length, &H1000, &H4)
            If allocAddress = Nothing Then Return False
            Dim kernelMod As Integer = GetModuleHandle("kernel32.dll")
            Dim loadLibAddr = GetProcAddress(kernelMod, "LoadLibraryA")
            If kernelMod = 0 OrElse loadLibAddr = 0 Then Return False
            WriteProcessMemory(hProcess, allocAddress, dllBytes, dllBytes.Length, 0)
            Dim libThread As Integer = CreateRemoteThread(hProcess, 0, 0, loadLibAddr, allocAddress, 0, 0)
    
            If libThread = 0 Then
                Return False
            Else
                WaitForSingleObject(libThread, 5000)
                CloseHandle(libThread)
            End If
            CloseHandle(hProcess)
            Label3.Text = "DLL Successfully Injected." & vbNewLine & "@get: 0x" & allocAddress.ToString()
            If CheckBox1.Checked = True Then
                Me.Close()
            End If
    
            Return True
        End Function
    
        Inject(PROC_ID, DLL_PATH)
    Quote Originally Posted by RoPMadM View Post
    You can't inject a .net DLL into a native operating programm.
    There are ways to do this but they are horribly laborious.


    You can inject .net DLL's into .net programms.

    If you want to inject a DLL into native programms you need to write a native DLL (for example with C++).
    Last edited by return_cheats; 01-19-2017 at 09:25 AM.

  4. #4
    RoPMadM's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    __asm
    Posts
    226
    Reputation
    12
    Thanks
    251
    My Mood
    Cynical

    Quote Originally Posted by return_cheats View Post
    Code:
    [SPOILER]
     Dim dlls As New Dictionary(Of String, String)
    
        Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
        Private 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
        Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, ByVal lpBuffer() As Byte, ByVal nSize As Integer, ByVal lpNumberOfBytesWritten As UInteger) As Boolean
        Private 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
        Private 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, ByVal lpThreadId As Integer) As Integer
        Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
        Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
    
        Private Function Inject(ByVal pID As Integer, ByVal dllLocation As String) As Boolean
    
            Dim hProcess As Integer = OpenProcess(&H1F0FFF, 1, pID)
            If hProcess = 0 Then Return False
            Dim dllBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(dllLocation)
            Dim allocAddress As Integer = VirtualAllocEx(hProcess, 0, dllBytes.Length, &H1000, &H4)
            If allocAddress = Nothing Then Return False
            Dim kernelMod As Integer = GetModuleHandle("kernel32.dll")
            Dim loadLibAddr = GetProcAddress(kernelMod, "LoadLibraryA")
            If kernelMod = 0 OrElse loadLibAddr = 0 Then Return False
            WriteProcessMemory(hProcess, allocAddress, dllBytes, dllBytes.Length, 0)
            Dim libThread As Integer = CreateRemoteThread(hProcess, 0, 0, loadLibAddr, allocAddress, 0, 0)
    
            If libThread = 0 Then
                Return False
            Else
                WaitForSingleObject(libThread, 5000)
                CloseHandle(libThread)
            End If
            CloseHandle(hProcess)
            Label3.Text = "DLL Successfully Injected." & vbNewLine & "@get: 0x" & allocAddress.ToString()
            If CheckBox1.Checked = True Then
                Me.Close()
            End If
    
            Return True
        End Function
    
        Inject(PROC_ID, DLL_PATH)[/SPOILER]

    lol
    This will just inject the DLL into a process, but the code wich got injected won‘t work at all. Perhabs it will crash
    .net DLL's need the CLR and the JIT compiler to run/create native code
    Your code will only work for .net DLL's injected to .net processes.
    Last edited by RoPMadM; 01-19-2017 at 01:57 PM.

  5. #5
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Quote Originally Posted by RoPMadM View Post
    You can't inject a .net DLL into a native operating programm.
    There are ways to do this but they are horribly laborious.
    Something like https://******.com/biesigrr/clrbtstrp

  6. #6
    RoPMadM's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Location
    __asm
    Posts
    226
    Reputation
    12
    Thanks
    251
    My Mood
    Cynical
    Quote Originally Posted by Biesi View Post
    Yes, exactly something like this

    OffTopic: Esslingen, best christmas market!
    Last edited by RoPMadM; 01-20-2017 at 03:12 AM.

Similar Threads

  1. [Solved] how to inject dll into blackshot (32bit)
    By awaltora11 in forum Blackshot Help
    Replies: 4
    Last Post: 06-08-2016, 01:31 PM
  2. [Solved] how to inject dll to process 32bit
    By headehd in forum Blackshot Help
    Replies: 3
    Last Post: 06-02-2016, 12:46 PM
  3. [Release] C++ Manually Inject Dll to process.
    By nullptr_t in forum C++/C Programming
    Replies: 0
    Last Post: 04-03-2016, 10:05 AM
  4. INJECT DLL INTO BLACKSHOT
    By acem007 in forum Blackshot Help
    Replies: 7
    Last Post: 11-27-2014, 05:11 PM
  5. How To Inject DLLs Into BlackShot
    By Seanwong98 in forum Blackshot Help
    Replies: 12
    Last Post: 04-10-2013, 05:57 PM