Exclamation[Help] Injection Concept [solved]

Posts 1–15 of 17 · Page 1 of 2
[Help] Injection Concept [solved]
Dear MPGH,

I am wanting to make an injector, yes again, but I won't release it anywhere, but I am wanting to make it so I can fully understand the code, and create the code myself. Can someone help me atleast at getting started?(by the way it's for a game, injecting a .dll into a game).

Thank you in advance.
Lol, giving you the code won't help you "understand" it
Code:
1.Public Class Form12. 3.    Private TargetProcessHandle As Integer4.    Private pfnStartAddr As Integer5.    Private pszLibFileRemote As String6.    Private TargetBufferSize As Integer7. 8.    Public Const PROCESS_VM_READ = &H109.    Public Const TH32CS_SNAPPROCESS = &H210.    Public Const MEM_COMMIT = 409611.    Public Const PAGE_READWRITE = 412.    Public Const PROCESS_CREATE_THREAD = (&H2)13.    Public Const PROCESS_VM_OPERATION = (&H8)14.    Public Const PROCESS_VM_WRITE = (&H20)15. 16.    Public Declare Function ReadProcessMemory Lib "kernel32" ( _17.    ByVal hProcess As Integer, _18.    ByVal lpBaseAddress As Integer, _19.    ByVal lpBuffer As String, _20.    ByVal nSize As Integer, _21.    ByRef lpNumberOfBytesWritten As Integer) As Integer22. 23.    Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" ( _24.    ByVal lpLibFileName As String) As Integer25. 26.    Public Declare Function VirtualAllocEx Lib "kernel32" ( _27.    ByVal hProcess As Integer, _28.    ByVal lpAddress As Integer, _29.    ByVal dwSize As Integer, _30.    ByVal flAllocationType As Integer, _31.    ByVal flProtect As Integer) As Integer32. 33.    Public Declare Function WriteProcessMemory Lib "kernel32" ( _34.    ByVal hProcess As Integer, _35.    ByVal lpBaseAddress As Integer, _36.    ByVal lpBuffer As String, _37.    ByVal nSize As Integer, _38.    ByRef lpNumberOfBytesWritten As Integer) As Integer39. 40.    Public Declare Function GetProcAddress Lib "kernel32" ( _41.    ByVal hModule As Integer, ByVal lpProcName As String) As Integer42. 43.    Private Declare Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" ( _44.    ByVal lpModuleName As String) As Integer45. 46.    Public Declare Function CreateRemoteThread Lib "kernel32" ( _47.    ByVal hProcess As Integer, _48.    ByVal lpThreadAttributes As Integer, _49.    ByVal dwStackSize As Integer, _50.    ByVal lpStartAddress As Integer, _51.    ByVal lpParameter As Integer, _52.    ByVal dwCreationFlags As Integer, _53.    ByRef lpThreadId As Integer) As Integer54. 55.    Public Declare Function OpenProcess Lib "kernel32" ( _56.    ByVal dwDesiredAccess As Integer, _57.    ByVal bInheritHandle As Integer, _58.    ByVal dwProcessId As Integer) As Integer59. 60.    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _61.    ByVal lpClassName As String, _62.    ByVal lpWindowName As String) As Integer63. 64.    Private Declare Function CloseHandle Lib "kernel32" Alias "CloseHandleA" ( _65.    ByVal hObject As Integer) As Integer66. 67. 68. 69. 70.    Private Sub Inject()71. 72. 73.        Timer1.Stop()74.        Dim TargetProcess As Process() = Process.GetProcessesByName("processname without .exe")75.        TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)76.        pszLibFileRemote = "path to the .dll"77.        pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")78.        TargetBufferSize = 1 + Len(pszLibFileRemote)79.        Dim Rtn As Integer80.        Dim LoadLibParamAdr As Integer81.        LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)82.        Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)83.        CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)84.        CloseHandle(TargetProcessHandle)85. 86.    End Sub87. 88.    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick89.        If IO.File.Exists("path to the .dll") Then90.            Dim TargetProcess As Process() = Process.GetProcessesByName("processname without .exe")91.            If TargetProcess.Length = 0 Then92. 93.            Else94.                Timer1.Stop()95.                Call Inject()96.            End If97.        Else98.            Timer1.Stop()99.            MsgBox(".Dll not found.")100. 101.        End If102.    End Sub103. 104.    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load105.        Timer1.Interval = 50106.        Timer1.Start()107.    End Sub108.End Class

Um y isnt code tags working?
Quote Originally Posted by Withoutwings View Post
Dear MPGH,

I am wanting to make an injector, yes again, but I won't release it anywhere, but I am wanting to make it so I can fully understand the code, and create the code myself. Can someone help me atleast at getting started?(by the way it's for a game, injecting a .dll into a game).

Thank you in advance.
Quote Originally Posted by Bombsaway707 View Post
Lol, giving you the code won't help you "understand" it

Bombsaway is right
btw
there is lots of injector codes
google it or use search button
I am not wanting any code, I wish someone would explain it to me please.
Quote Originally Posted by Withoutwings View Post
I am not wanting any code, I wish someone would explain it to me please.
Then you need to talk to a master coder because their are few people who actually understand fully what the code means
Quote Originally Posted by Lyoto Machida View Post
I think @topblast should know
Ok, thanks, both of you, for your advice.
@Void @Hell_Demon both understand the concept. If you ask REAAAAAAAALLY nicely, they may you tell you!
DLL Injection = Calling LoadLibrary in the target process.

1.Allocate memory to write the string of the path to the DLL you're injecting.
2.Write the string to the allocated memory.
3.Get the address of LoadLibrary
4.Start a remote thread at the location of LoadLibrary.

Functions:
VirtualAlloc Function (Windows)
WriteProcessMemory Function (Windows)
GetProcAddress Function (Windows)
CreateRemoteThread Function (Windows)
GetModuleHandle Function (Windows)
OpenProcess Function (Windows)

Brief explanation, should get you going.
Quote Originally Posted by Void View Post
DLL Injection = Calling LoadLibrary in the target process.

1.Allocate memory to write the string of the path to the DLL you're injecting.
2.Write the string to the allocated memory.
3.Get the address of LoadLibrary
4.Start a remote thread at the location of LoadLibrary.

Functions:
VirtualAlloc Function (Windows)
WriteProcessMemory Function (Windows)
GetProcAddress Function (Windows)
CreateRemoteThread Function (Windows)
GetModuleHandle Function (Windows)
OpenProcess Function (Windows)

Brief explanation, should get you going.
Thank you very much, would've almost kissed you, but then I came to realise you're a dude (x
Kiss him anyway. He enjoys it!
Quote Originally Posted by Jason View Post
Kiss him anyway. He enjoys it!
lawl ;$ (too short >.>)
Quote Originally Posted by Jason View Post
Kiss him anyway. He enjoys it!
WHY ARE YOU STILL AWAKE?!
Quote Originally Posted by Void View Post
WHY ARE YOU STILL AWAKE?!
Yeah just ignore it. xD
Posts 1–15 of 17 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

Need help?