
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
