So basically I converted an old trainer of mine from C# to VB in order to deploy updates in a quicker manner. My memory class throws the errors
Error 1 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 67 70 SoDHack
Error 2 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 151 71 SoDHack
Error 3 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 157 75 SoDHack
Error 4 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 160 75 SoDHack
Error 5 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 165 75 SoDHack
Error 6 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 184 72 SoDHack
Error 7 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 190 75 SoDHack
Error 8 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 192 76 SoDHack
Error 9 Value of type 'Integer' cannot be converted to 'System.IntPtr'. C:\Users\Excision\Documents\Visual Studio 2013\Projects\SoDHack\SoDHack\Memory.vb 197 75 SoDHack
Code:
Imports System.Diagnostics
Namespace State_of_Decay
Friend Class Memory
Dim num As Integer
Private m_ReadProcess As Process
Private m_hProcess As IntPtr = IntPtr.Zero
Public Property ReadProcess() As Process
Get
Return Me.m_ReadProcess
End Get
Set(value As Process)
Me.m_ReadProcess = value
End Set
End Property
Public Sub New()
End Sub
Public Sub Alloc(ByRef Addr As Integer, Size As Integer)
Addr = MemoryAPI.VirtualAllocEx(Me.m_hProcess, IntPtr.Zero, Size, MemoryAPI.AllocType.Commit, MemoryAPI.Protect.ExecuteReadWrite)
End Sub
Public Function BaseAddressD() As Integer
Return Me.m_ReadProcess.MainModule.BaseAddress.ToInt32()
End Function
Public Function BaseAddressH() As String
Dim baseAddress As IntPtr = Me.m_ReadProcess.MainModule.BaseAddress
Return Addr.ToHex(baseAddress.ToInt32())
End Function
Public Function [Call]([to] As Integer, from As Integer, nop As Boolean, Optional NumeroDiNop As Integer = 0) As Byte()
Dim num As Integer = [to] - from - 5
Dim str As String = num.ToString("X")
If str.Length = 7 Then
str = String.Concat("0", str)
End If
If str.Length = 6 Then
str = String.Concat("00", str)
End If
str = String.Concat(str, "E8")
If nop Then
For i As Integer = 0 To NumeroDiNop - 1
str = String.Concat("90", str)
Next
End If
Dim numArray As Byte() = New Byte(str.Length / 2 - 1) {}
For j As Integer = 0 To CInt(numArray.Length) - 1
numArray(j) = Convert.ToByte(str.Substring(j * 2, 2), 16)
Next
Array.Reverse(numArray)
Return numArray
End Function
Public Sub CloseHandle()
If MemoryAPI.CloseHandle(Me.m_hProcess) = 0 Then
Throw New Exception("CloseHandle Failed")
End If
End Sub
Public Function Dealloc(Addr As Integer) As Boolean
Return MemoryAPI.VirtualFreeEx(Me.m_hProcess, DirectCast(Addr, IntPtr), 0, MemoryAPI.FreeType.Release)
End Function
Public Function InvertiByte(ArrayValori As String, NumeroDiByte As Integer) As Byte()
For i As Integer = ArrayValori.Length To NumeroDiByte - 1
ArrayValori = String.Concat("0", ArrayValori)
Next
Dim num As Byte() = New Byte(ArrayValori.Length / 2 - 1) {}
For j As Integer = 0 To CInt(num.Length) - 1
num(j) = Convert.ToByte(ArrayValori.Substring(j * 2, 2), 16)
Next
Array.Reverse(num)
Return num
End Function
Public Function Jmp([to] As String, from As String, nop As Boolean, Optional NumeroDiNop As Integer = 0) As Byte()
Return Me.Jmp(Convert.ToInt32(String.Concat("0x", [to]), 16), Convert.ToInt32(String.Concat("0x", from), 16), nop, NumeroDiNop)
End Function
Public Function Jmp([to] As Integer, from As Integer, nop As Boolean, Optional NumeroDiNop As Integer = 0) As Byte()
Dim num As Integer = [to] - from - 5
Dim str As String = num.ToString("X")
If str.Length = 7 Then
str = String.Concat("0", str)
End If
If str.Length = 6 Then
str = String.Concat("00", str)
End If
str = String.Concat(str, "E9")
If nop Then
For i As Integer = 0 To NumeroDiNop - 1
str = String.Concat("90", str)
Next
End If
Dim numArray As Byte() = New Byte(str.Length / 2 - 1) {}
For j As Integer = 0 To CInt(numArray.Length) - 1
numArray(j) = Convert.ToByte(str.Substring(j * 2, 2), 16)
Next
Array.Reverse(numArray)
Return numArray
End Function
Public Function MovEAX([to] As Integer, from As Integer, nop As Boolean, Optional NumeroDiNop As Integer = 0) As Byte()
Dim num As Integer = [to] - from - 5
Dim str As String = num.ToString("X")
If str.Length = 7 Then
str = String.Concat("0", str)
End If
If str.Length = 6 Then
str = String.Concat("00", str)
End If
str = String.Concat(str, "A1")
If nop Then
For i As Integer = 0 To NumeroDiNop - 1
str = String.Concat("90", str)
Next
End If
Dim numArray As Byte() = New Byte(str.Length / 2 - 1) {}
For j As Integer = 0 To CInt(numArray.Length) - 1
numArray(j) = Convert.ToByte(str.Substring(j * 2, 2), 16)
Next
Array.Reverse(numArray)
Return numArray
End Function
Public Sub Open()
Dim processAccessType As MemoryAPI.ProcessAccessType = MemoryAPI.ProcessAccessType.PROCESS_VM_OPERATION Or MemoryAPI.ProcessAccessType.PROCESS_VM_READ Or MemoryAPI.ProcessAccessType.PROCESS_VM_WRITE
Me.m_hProcess = MemoryAPI.OpenProcess(CUInt(processAccessType), 1, CUInt(Me.m_ReadProces*****))
End Sub
Public Function PID() As Integer
Return Me.m_ReadProces*****
End Function
Public Function PointerRead(MemoryAddress As IntPtr, bytesToRead As UInteger, Offset As Integer(), ByRef bytesRead As Integer) As Byte()
Dim intPtr As IntPtr
Dim length As Integer = CInt(Offset.Length) - 1
bytesRead = 0
Dim numArray As Byte() = New Byte(3) {}
Dim num As Integer = 0
If length = 0 Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, MemoryAddress, numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(0)
numArray = New Byte(bytesToRead - 1) {}
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, bytesToRead, intPtr)
bytesRead = intPtr.ToInt32()
Return numArray
End If
For i As Integer = 0 To length
If i = length Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
numArray = New Byte(bytesToRead - 1) {}
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, bytesToRead, intPtr)
bytesRead = intPtr.ToInt32()
Return numArray
End If
If i <> 0 Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
Else
MemoryAPI.ReadProcessMemory(Me.m_hProcess, MemoryAddress, numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
End If
Next
Return numArray
End Function
Public Function PointerWrite(MemoryAddress As IntPtr, bytesToWrite As Byte(), Offset As Integer(), ByRef bytesWritten As Integer) As String
Dim intPtr As IntPtr
Dim length As Integer = CInt(Offset.Length) - 1
bytesWritten = 0
Dim numArray As Byte() = New Byte(3) {}
Dim num As Integer = 0
If length = 0 Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, MemoryAddress, numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(0)
MemoryAPI.WriteProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), bytesToWrite, CUInt(bytesToWrite.Length), intPtr)
bytesWritten = intPtr.ToInt32()
Return Addr.ToHex(num)
End If
For i As Integer = 0 To length
If i = length Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
MemoryAPI.WriteProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), bytesToWrite, CUInt(bytesToWrite.Length), intPtr)
bytesWritten = intPtr.ToInt32()
Return Addr.ToHex(num)
End If
If i <> 0 Then
MemoryAPI.ReadProcessMemory(Me.m_hProcess, DirectCast(num, IntPtr), numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
Else
MemoryAPI.ReadProcessMemory(Me.m_hProcess, MemoryAddress, numArray, 4, intPtr)
num = BitConverter.ToInt32(numArray, 0) + Offset(i)
End If
Next
Return Addr.ToHex(num)
End Function
Public Function Read(MemoryAddress As IntPtr, bytesToRead As UInteger, ByRef bytesRead As Integer) As Byte()
Dim intPtr As IntPtr
Dim numArray As Byte() = New Byte(bytesToRead - 1) {}
MemoryAPI.ReadProcessMemory(Me.m_hProcess, MemoryAddress, numArray, bytesToRead, intPtr)
bytesRead = intPtr.ToInt32()
Return numArray
End Function
Public Sub Write(MemoryAddress As IntPtr, bytesToWrite As Byte(), ByRef bytesWritten As Integer)
Dim intPtr As IntPtr
MemoryAPI.WriteProcessMemory(Me.m_hProcess, MemoryAddress, bytesToWrite, CUInt(bytesToWrite.Length), intPtr)
bytesWritten = intPtr.ToInt32()
End Sub
End Class
End Namespace