Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ######################## Function ########################
- Declare Function LoadLibraryA Lib "kernel32" (ByVal name As String) As IntPtr
- Declare Function GetProcAddress Lib "kernel32" (ByVal handle As IntPtr, ByVal name As String) As IntPtr
- Function CreateAPI(Of T)(ByVal name As String, ByVal method As String) As T
- Return DirectCast(DirectCast(Marshal.GetDelegateForFunctionPointer(GetProcAddress(LoadLibraryA(name), method), GetType(T)), Object), T)
- End Function
- ######################## Original ########################
- <DllImport("kernel32", CharSet:=CharSet.Auto, SetLastError:=True)> _
- Public Shared Function VirtualProtectEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UIntPtr, ByVal flNewProtect As UIntPtr, <Out()> ByVal lpflOldProtect As UInteger) As Integer
- End Function
- ######################## Delegated ########################
- Delegate Function VirtualProtectEx(ByVal hProcess As IntPtr, ByVal lpAddress As IntPtr, ByVal dwSize As UIntPtr, ByVal flNewProtect As UIntPtr, <Out()> ByVal lpflOldProtect As UInteger) As Integer
- ######################## Delegated API ########################
- Dim VPX = CreateAPI(Of VPX)("kernel32", "VirtualAllocEx")
Add Comment
Please, Sign In to add comment