Advertisement
cos8o

Visual Basic VirtualProtectEx

Dec 7th, 2016
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.98 KB | None | 0 0
  1. Imports System.Runtime.InteropServices
  2. Module Module1
  3.  <DllImport("kernel32.dll")>
  4.     Private Function OpenProcess(ByVal dwDesiredAccess As UInteger, <MarshalAs(UnmanagedType.Bool)> ByVal bInheritHandle As Boolean, ByVal dwProcessId As Integer) As IntPtr
  5.     End Function
  6. Public Declare Function VirtualProtectEx Lib "kernel32" (ByVal hProcess As IntPtr, ByVal lpAddress As Integer, ByVal dwSize As Integer, ByVal flNewProtect As Integer, <Out> ByRef lpflOldProtect As Integer) As Boolean
  7.     Dim oldProtect As Integer = 0
  8.     Const PROCESS_VM_WRITE As UInteger = &H20
  9.     Const PROCESS_VM_READ As UInteger = &H10
  10.     Const PROCESS_VM_OPERATION As UInteger = &H8
  11. Dim processHandle As IntPtr = IntPtr.Zero
  12. Sub Main()
  13.  Dim p() As Process = Process.GetProcessesByName("process")
  14. processHandle = OpenProcess(PROCESS_VM_READ Or PROCESS_VM_WRITE Or PROCESS_VM_OPERATION, False, p(0).Id)
  15. VirtualProtectEx(processHandle, &Haddress, byteLength, PROCESS_VM_WRITE, PROCESS_VM_READ)
  16. End Sub
  17. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement