Dim name As String = Application.StartupPath + "\TEST.dll"
On Error GoTo 1
Timer1.Stop()
Dim TargetProcess As Process() = Process.GetProcessesByName("pointblank")
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pszLibFileRemote = name
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)
1:
End Sub
ตรง Dim name As String = Application.StartupPath + "\TEST.dll"
Private TargetProcessHandle As Integer
Private pfnStartAddr As Integer
Private pszLibFileRemote As String
Private TargetBufferSize As Integer
Public Const PROCESS_VM_READ As Integer = 16
Public Const TH32CS_SNAPPROCESS As Integer = 2
Public Const MEM_COMMIT As Integer = 4096
Public Const PAGE_READWRITE As Integer = 4
Public Const PROCESS_CREATE_THREAD As Integer = 2
Public Const PROCESS_VM_OPERATION As Integer = 8
Public Const PROCESS_VM_WRITE As Integer = 32
Private DLLFileName As String
Public Declare Ansi Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, <MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Public Declare Ansi Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (<MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpLibFileName As String) As Integer
Public Declare Ansi 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 Ansi Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Integer, ByVal lpBaseAddress As Integer, <MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpBuffer As String, ByVal nSize As Integer, ByRef lpNumberOfBytesWritten As Integer) As Integer
Public Declare Ansi Function GetProcAddress Lib "kernel32" (ByVal hModule As Integer, <MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpProcName As String) As Integer
Private Declare Ansi Function GetModuleHandle Lib "Kernel32" Alias "GetModuleHandleA" (<MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpModuleName As String) As Integer
Public Declare Ansi 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 Ansi Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Private Declare Ansi Function FindWindow Lib "user32" Alias "FindWindowA" (<MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpClassName As String, <MarshalAs(UnmanagedType.VBByRefStr)> ByRef lpWindowName As String) As Integer
Private Declare Ansi Function CloseHandle Lib "kernel32" Alias "CloseHandelA" (ByVal hObject As Integer) As Integer
Private Sub Inject()
Try
File.WriteAllBytes(Path.GetTempPath() + "\D3D9_Recognition_Logger.dll", My.Resources.D3D9_Recognition_Logger)
Dim text As String = Path.GetTempPath() + "\D3D9_Recognition_Logger.dll"
Me.Timer2.[Stop]()
Dim processesByName As Process() = Process.GetProcessesByName(ComboBox1.SelectedItem)
Me.TargetProcessHandle = Form1.OpenProcess(42, 0, processesByName(0).Id)
Me.pszLibFileRemote = text
Dim text2 As String = "Kernel32"
Dim arg_74_0 As Integer = Form1.GetModuleHandle(text2)
Dim text3 As String = "LoadLibraryA"
Me.pfnStartAddr = Form1.GetProcAddress(arg_74_0, text3)
' The following expression was wrapped in a checked-expression
Me.TargetBufferSize = 1 + Strings.Len(Me.pszLibFileRemote)
Dim num As Integer = Form1.VirtualAllocEx(Me.TargetProcessHandle, 0, Me.TargetBufferSize, 4096, 4)
Dim arg_C2_0 As Integer = Me.TargetProcessHandle
Dim arg_C2_1 As Integer = num
Dim arg_C2_3 As Integer = Me.TargetBufferSize
Dim num2 As Integer = 0
Dim num3 As Integer = Form1.WriteProcessMemory(arg_C2_0, arg_C2_1, Me.pszLibFileRemote, arg_C2_3, num2)
Dim arg_DD_0 As Integer = Me.TargetProcessHandle
Dim arg_DD_1 As Integer = 0
Dim arg_DD_2 As Integer = 0
Dim arg_DD_3 As Integer = Me.pfnStartAddr
Dim arg_DD_4 As Integer = num
Dim arg_DD_5 As Integer = 0
num2 = 0
Form1.CreateRemoteThread(arg_DD_0, arg_DD_1, arg_DD_2, arg_DD_3, arg_DD_4, arg_DD_5, num2)
Form1.CloseHandle(Me.TargetProcessHandle)
Catch ex As Exception
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
End Try
End Sub