Public Class Form1
'for reading/writing the listbox content
Dim sFile As String
'declare stuffz for the injection
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)
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
Private Sub inject()
Dim LoadLibParamAdr As Integer
Dim Rtn As Integer
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
On Error GoTo 1 ' If error occurs, app will go below to "1:"
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
'count each listbox item
For i = 0 To ListBox1.Items.Count - 1
If selected.Checked = True Then
pszLibFileRemote = ListBox1.SelectedItem
Else
pszLibFileRemote = ListBox1.Items.Item(i)
End If
TargetBufferSize = 1 + Len(pszLibFileRemote)
LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
Next i
CloseHandle(TargetProcessHandle)
1: labelx24.ForeColor = Color.Red
labelx24.Text = "Erro ocurrido" 'error
End Sub
Public Sub ListBox_Save(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamWriter
Dim i As Short
'create a new streamwriter
oStream = New IO.StreamWriter(sFile)
'count each listbox item
For i = 0 To ListBox.Items.Count - 1
oStream.WriteLine(ListBox.Items(i))
Next
'close streamwriter
oStream.Close()
End Sub
Public Sub ListBox_Read(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamReader
Dim sLine As String
' Clear listbox
ListBox.Items.Clear()
' Check if file exists
Dim oFile As New IO.FileInfo(sFile)
'if the list.dat exists then read it...
If oFile.Exists() = True Then
oStream = New IO.StreamReader(sFile)
' read file
Do
'read each line
sLine = oStream.ReadLine()
If IsNothing(sLine) Then Exit Do
'add items to the listbox
ListBox.Items.Add(sLine)
'loop until it's done
Loop
'close the stream
oStream.Close()
End If
End Sub
Private Sub savelb()
'save a list.dat with listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Save(ListBox1, sFile)
End Sub
Private Sub loadlb()
'load a list.dat to fill in listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Read(ListBox1, sFile)
End Sub
Public Function IsProcessOpen(ByVal name As String) As Boolean
'if isprocessopen("process") then...
'if not isprocessopen("process") then...
'get all current running processes
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
' Do nothing
Return False
End Function
Private Sub checkprocess_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'check if process is running
If Not IsProcessOpen(txtprocess.Text) Then
labelx24.ForeColor = Color.Red
labelx24.Text = "Inicie o processo"
Else
labelx24.ForeColor = Color.Green
labelx24.Text = "Processo encontrado"
End If
End Sub
Private Sub txtprocess_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprocess.TextChanged
'save current process textbox text in settings
My.Settings.processs = txtprocess.Text
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub inject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdinject.Click
'declare a process
Try
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
'if txtprocess.text = ""
If TargetProcess.Length = 0 Then
MsgBox("Esperando por " & txtprocess.Text)
Else
'do injection
Call inject()
labelx24.Text = "Dll injetada com sucesso"
Timer1.Stop()
End If
Catch
End Try
'save listbox content
savelb()
'set the process
My.Settings.processs = txtprocess.Text
'save settings
My.Settings.Save()
My.Settings.Reload()
'close if 'close checkbox' is checked
If closebox.Checked = True Then
Me.Close()
End If
End Sub
Private Sub selectdll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dll.Click
'only .dlls files are selectable
opf.Title = "Escolha a .dll"
opf.Filter = "DLL (*.DLL)|*.Dll"
opf.Multiselect = True
'open the open file dialog
opf.ShowDialog()
'add the .dll to the listbox
For Each item As String In opf.FileNames
If Not ListBox1.Items.Contains(item) Then
If Not opf.FileName = "OpenFileDialog1" Then
ListBox1.Items.Add(item)
' dll.Text = System.IO.Path.GetFileName(opf.FileName)
End If
End If
Next item
'save listbox content
savelb()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'load listbox content
loadlb()
'process textbox
txtprocess.Text = My.Settings.processs
'check/uncheck checkboxes
selected.Checked = My.Settings.selectedonly
closebox.Checked = My.Settings.close
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclear.Click
'clear listbox(obviously)
ListBox1.Items.Clear()
'save listbox content
savelb()
End Sub
Private Sub removeselected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrs.Click
'remove the selected item
Try
If ListBox1.SelectedIndex <> -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
Catch
End Try
'save listbox content
savelb()
End Sub
Private Sub selected_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selected.CheckedChanged
'save checkbox setting
My.Settings.selectedonly = selected.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub closebox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closebox.CheckedChanged
'save checkbox setting
My.Settings.close = closebox.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
End Class
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Injector.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- Dieser Abschnitt definiert die Protokollierungskonfiguration für My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Auskommentierung des nachfolgenden Abschnitts aufheben, um in das Anwendungsereignisprotokoll zu schreiben -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Auskommentierung des nachfolgenden Abschnitts aufheben und APPLICATION_NAME durch den Namen der Anwendung ersetzen, um in das Anwendungsereignisprotokoll zu schreiben -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<userSettings>
<Injector.My.MySettings>
<setting name="dllpath" serializeAs="String">
<value />
</setting>
<setting name="processs" serializeAs="String">
<value />
</setting>
<setting name="close" serializeAs="String">
<value>False</value>
</setting>
<setting name="selectedonly" serializeAs="String">
<value>False</value>
</setting>
<setting name="Setting" serializeAs="String">
<value />
</setting>
<setting name="inject" serializeAs="String">
<value>False</value>
</setting>
</Injector.My.MySettings>
</userSettings>
</configuration>
Public Class Form1
'for reading/writing the listbox content
Dim sFile As String
'declare stuffz for the injection
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)
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
Private Sub inject()
Dim LoadLibParamAdr As Integer
Dim Rtn As Integer
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
On Error GoTo 1 ' If error occurs, app will go below to "1:"
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
'count each listbox item
For i = 0 To ListBox1.Items.Count - 1
If selected.Checked = True Then
pszLibFileRemote = ListBox1.SelectedItem
Else
pszLibFileRemote = ListBox1.Items.Item(i)
End If
TargetBufferSize = 1 + Len(pszLibFileRemote)
LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
Next i
CloseHandle(TargetProcessHandle)
1: labelx24.ForeColor = Color.Red
labelx24.Text = "Ocorreu um erro" 'error
End Sub
Public Sub ListBox_Save(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamWriter
Dim i As Short
'create a new streamwriter
oStream = New IO.StreamWriter(sFile)
'count each listbox item
For i = 0 To ListBox.Items.Count - 1
oStream.WriteLine(ListBox.Items(i))
Next
'close streamwriter
oStream.Close()
End Sub
Public Sub ListBox_Read(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamReader
Dim sLine As String
' Clear listbox
ListBox.Items.Clear()
' Check if file exists
Dim oFile As New IO.FileInfo(sFile)
'if the list.dat exists then read it...
If oFile.Exists() = True Then
oStream = New IO.StreamReader(sFile)
' read file
Do
'read each line
sLine = oStream.ReadLine()
If IsNothing(sLine) Then Exit Do
'add items to the listbox
ListBox.Items.Add(sLine)
'loop until it's done
Loop
'close the stream
oStream.Close()
End If
End Sub
Private Sub savelb()
'save a list.dat with listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Save(ListBox1, sFile)
End Sub
Private Sub loadlb()
'load a list.dat to fill in listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Read(ListBox1, sFile)
End Sub
Public Function IsProcessOpen(ByVal name As String) As Boolean
'if isprocessopen("process") then...
'if not isprocessopen("process") then...
'get all current running processes
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
' Do nothing
Return False
End Function
Private Sub checkprocess_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'check if process is running
If Not IsProcessOpen(txtprocess.Text) Then
labelx24.ForeColor = Color.Red
labelx24.Text = "Inicie o processo"
Else
labelx24.ForeColor = Color.Green
labelx24.Text = "Processo encontrado"
End If
End Sub
Private Sub txtprocess_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprocess.TextChanged
'save current process textbox text in settings
My.Settings.processs = txtprocess.Text
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub inject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdinject.Click
'declare a process
Try
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
'if txtprocess.text = ""
If TargetProcess.Length = 0 Then
MsgBox("Esperando por " & txtprocess.Text)
Else
'do injection
Call inject()
labelx24.Text = "Dll injetada com sucesso"
Timer1.Stop()
End If
Catch
End Try
'save listbox content
savelb()
'set the process
My.Settings.processs = txtprocess.Text
'save settings
My.Settings.Save()
My.Settings.Reload()
'close if 'close checkbox' is checked
If closebox.Checked = True Then
Me.Close()
End If
End Sub
Private Sub selectdll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dll.Click
'only .dlls files are selectable
opf.Title = "Escolha a .dll"
opf.Filter = "DLL (*.DLL)|*.Dll"
opf.Multiselect = True
'open the open file dialog
opf.ShowDialog()
'add the .dll to the listbox
For Each item As String In opf.FileNames
If Not ListBox1.Items.Contains(item) Then
If Not opf.FileName = "OpenFileDialog1" Then
ListBox1.Items.Add(item)
' dll.Text = System.IO.Path.GetFileName(opf.FileName)
End If
End If
Next item
'save listbox content
savelb()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'load listbox content
loadlb()
'process textbox
txtprocess.Text = My.Settings.processs
'check/uncheck checkboxes
selected.Checked = My.Settings.selectedonly
closebox.Checked = My.Settings.close
Autoinject.Checked = My.Settings.inject
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclear.Click
'clear listbox(obviously)
ListBox1.Items.Clear()
'save listbox content
savelb()
End Sub
Private Sub removeselected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrs.Click
'remove the selected item
Try
If ListBox1.SelectedIndex <> -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
Catch
End Try
'save listbox content
savelb()
End Sub
Private Sub selected_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selected.CheckedChanged
'save checkbox setting
My.Settings.selectedonly = selected.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub closebox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closebox.CheckedChanged
'save checkbox setting
My.Settings.close = closebox.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub Autoinject_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Autoinject.CheckedChanged
'save checkbox setting
My.Settings.inject = Autoinject.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
End Class
Private Sub [always]
While Checkbox1.Checkstatus = Checked Then
If [check if the process is active] Then
Inject()
End()
End If
If Checkbox1.Checkstatus = Unchecked Then
[exit while]
End If
End While
End Sub
Private Sub Autoinject_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
While Autoinject.Checkstatus = Checked Then
If [check if the process is active]Then
inject()
End()
End If
If Autoinject.Checkstatus = Unchecked Then
[exit while]
End If
End While

Public Class Form1
'for reading/writing the listbox content
Dim sFile As String
'declare stuffz for the injection
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)
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
Private Sub inject()
Dim LoadLibParamAdr As Integer
Dim Rtn As Integer
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
On Error GoTo 1 ' If error occurs, app will go below to "1:"
TargetProcessHandle = OpenProcess(PROCESS_CREATE_THREAD Or PROCESS_VM_OPERATION Or PROCESS_VM_WRITE, False, TargetProcess(0).Id)
pfnStartAddr = GetProcAddress(GetModuleHandle("Kernel32"), "LoadLibraryA")
'count each listbox item
For i = 0 To ListBox1.Items.Count - 1
If selected.Checked = True Then
pszLibFileRemote = ListBox1.SelectedItem
Else
pszLibFileRemote = ListBox1.Items.Item(i)
End If
TargetBufferSize = 1 + Len(pszLibFileRemote)
LoadLibParamAdr = VirtualAllocEx(TargetProcessHandle, 0, TargetBufferSize, MEM_COMMIT, PAGE_READWRITE)
Rtn = WriteProcessMemory(TargetProcessHandle, LoadLibParamAdr, pszLibFileRemote, TargetBufferSize, 0)
CreateRemoteThread(TargetProcessHandle, 0, 0, pfnStartAddr, LoadLibParamAdr, 0, 0)
Next i
CloseHandle(TargetProcessHandle)
1: labelx24.ForeColor = Color.Red
labelx24.Text = "Ocorreu um erro" 'error
End Sub
Public Sub ListBox_Save(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamWriter
Dim i As Short
'create a new streamwriter
oStream = New IO.StreamWriter(sFile)
'count each listbox item
For i = 0 To ListBox.Items.Count - 1
oStream.WriteLine(ListBox.Items(i))
Next
'close streamwriter
oStream.Close()
End Sub
Public Sub ListBox_Read(ByVal ListBox As ListBox, ByVal sFile As String)
' Save content
Dim oStream As IO.StreamReader
Dim sLine As String
' Clear listbox
ListBox.Items.Clear()
' Check if file exists
Dim oFile As New IO.FileInfo(sFile)
'if the list.dat exists then read it...
If oFile.Exists() = True Then
oStream = New IO.StreamReader(sFile)
' read file
Do
'read each line
sLine = oStream.ReadLine()
If IsNothing(sLine) Then Exit Do
'add items to the listbox
ListBox.Items.Add(sLine)
'loop until it's done
Loop
'close the stream
oStream.Close()
End If
End Sub
Private Sub savelb()
'save a list.dat with listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Save(ListBox1, sFile)
End Sub
Private Sub loadlb()
'load a list.dat to fill in listbox content
sFile = Application.StartupPath & "\List.dat"
ListBox_Read(ListBox1, sFile)
End Sub
Public Function IsProcessOpen(ByVal name As String) As Boolean
'if isprocessopen("process") then...
'if not isprocessopen("process") then...
'get all current running processes
For Each clsProcess As Process In Process.GetProcesses
If clsProcess.ProcessName.Contains(name) Then
Return True
End If
Next
' Do nothing
Return False
End Function
Private Sub checkprocess_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'check if process is running
If Not IsProcessOpen(txtprocess.Text) Then
labelx24.ForeColor = Color.Red
labelx24.Text = "Inicie o processo"
Else
labelx24.ForeColor = Color.Green
labelx24.Text = "Processo encontrado"
End If
End Sub
Private Sub txtprocess_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtprocess.TextChanged
'save current process textbox text in settings
My.Settings.processs = txtprocess.Text
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub inject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdinject.Click
'declare a process
Try
Dim TargetProcess As Process() = Process.GetProcessesByName(txtprocess.Text)
'if txtprocess.text = ""
If TargetProcess.Length = 0 Then
MsgBox("Esperando por " & txtprocess.Text)
Else
'do injection
Call inject()
labelx24.Text = "Dll injetada com sucesso"
Timer1.Stop()
End If
Catch
End Try
'save listbox content
savelb()
'set the process
My.Settings.processs = txtprocess.Text
'save settings
My.Settings.Save()
My.Settings.Reload()
'close if 'close checkbox' is checked
If closebox.Checked = True Then
Me.Close()
End If
End Sub
Private Sub selectdll_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dll.Click
'only .dlls files are selectable
opf.Title = "Escolha a .dll"
opf.Filter = "DLL (*.DLL)|*.Dll"
opf.Multiselect = True
'open the open file dialog
opf.ShowDialog()
'add the .dll to the listbox
For Each item As String In opf.FileNames
If Not ListBox1.Items.Contains(item) Then
If Not opf.FileName = "OpenFileDialog1" Then
ListBox1.Items.Add(item)
' dll.Text = System.IO.Path.GetFileName(opf.FileName)
End If
End If
Next item
'save listbox content
savelb()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'load listbox content
loadlb()
'process textbox
txtprocess.Text = My.Settings.processs
'check/uncheck checkboxes
selected.Checked = My.Settings.selectedonly
closebox.Checked = My.Settings.close
Autoinject.Checked = My.Settings.inject
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdclear.Click
'clear listbox(obviously)
ListBox1.Items.Clear()
'save listbox content
savelb()
End Sub
Private Sub removeselected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdrs.Click
'remove the selected item
Try
If ListBox1.SelectedIndex <> -1 Then
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
Catch
End Try
'save listbox content
savelb()
End Sub
Private Sub selected_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selected.CheckedChanged
'save checkbox setting
My.Settings.selectedonly = selected.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub closebox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closebox.CheckedChanged
'save checkbox setting
My.Settings.close = closebox.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
Private Sub Autoinject_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Autoinject.CheckedChanged
'save checkbox setting
My.Settings.inject = Autoinject.Checked
'save/reload settings
My.Settings.Save()
My.Settings.Reload()
End Sub
End Class
