Results 1 to 4 of 4
  1. #1
    xKarma's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    2

    VB.Net Memory Hack

    I keep seeing posts like "You can't do hacks in VB.Net noob, learn c++". While it's true that having your code rely on CLR sets some boundaries(for instance you can't inject managed code into unmanaged processes), .Net is just as capable of calling windows API as any other language runtime. And guess what? Accessing a processes memory is Windows API stuff.

    Alright, let's start. At this point I'm going to assume you already know what is a memory address and how to find one.
    If not, take this tutorial about memory addresses first, and then come back here.



    It's a simple c++ console application with a static variable which you can increase or decrease by typing in +/- and pressing enter. The variable will not increase after 10. We are going to use VB.Net to set that value to 100.

    First you want to find the memory address of the variable. It's generally good practice to find it yourself, but in case you feel you already handle that part well enough, I'm going to save you some time by telling you that it is...

    [SPOILER]
    0x0419004
    [/SPOILER]

    Create a new Windows Forms project and add 2 buttons to your form: "Read Memory" and "Write Memory".



    Now add a new Module to your project and call it Memory.vb.
    Copy this code in the Module:

    Code:
    Imports System.Runtime.InteropServices
    
    Module Memory
        <DllImport("kernel32.dll")> _
    Public Function ReadProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, <[In](), Out()> ByVal buffer As Byte(), ByVal size As UInt32, ByRef lpNumberOfBytesRead As IntPtr) As Int32
        End Function
    
        <DllImport("kernel32.dll")> _
       Public Function WriteProcessMemory(ByVal hProcess As IntPtr, ByVal lpBaseAddress As IntPtr, <[In](), Out()> ByVal buffer As Byte(), ByVal size As UInt32, ByRef lpNumberOfBytesWritten As IntPtr) As Int32
        End Function
    
        Public Function WriteInt32(ByVal P As Process, ByVal memAdr As Int32, ByVal value As Integer) As Boolean
            Return WriteBytes(P, memAdr, BitConverter.GetBytes(value), 4)
        End Function
    
        Public Function ReadInt32(ByVal P As Process, ByVal memAdr As Int32) As Integer
            Return BitConverter.ToInt32(ReadBytes(P, memAdr, 4), 0)
        End Function
    
        Private Function ReadBytes(ByVal P As Process, ByVal memAdr As Long, ByVal bytesToRead As UInteger) As Byte()
            Dim ptrBytesRead As IntPtr
            Dim buffer As Byte() = New Byte(bytesToRead - 1) {}
            ReadProcessMemory(P.Handle, New IntPtr(memAdr), buffer, bytesToRead, ptrBytesRead)
            Return buffer
        End Function
    
        Private Function WriteBytes(ByVal P As Process, ByVal memAdr As Long, ByVal bytes As Byte(), ByVal length As UInteger) As Boolean
            Dim bytesWritten As IntPtr
            Dim result As Integer = WriteProcessMemory(P.Handle, New IntPtr(memAdr), bytes, length, bytesWritten)
            Return result <> 0
        End Function
    
    End Module
    Now you have the API calls and simple wrapper functions declared.

    Copy this code in the first("read memory") button's click event handler:

    Code:
    Dim p As Process = Nothing
            If Process.GetProcessesByName("HackMe").Count > 0 Then
                p = Process.GetProcessesByName("HackMe")(0)
            Else
                MessageBox.Show("HackMe not open!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                Exit Sub
            End If
            Dim Adr As Int32 = &H419004
                    Try
                    Dim Variable As Int32 = Memory.ReadInt32(p, &H419004)
                    MessageBox.Show("Variable: " & Variable.ToString, "Memory Read Successful", MessageBoxButtons.OK) Catch ex As Exception
                    MessageBox.Show("Reading memory failed: " & vbCrLf & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                    End Try
    First we looked for the process by name("HackMe"). If found, we tried to read from our memory address and display the result.

    Now for the final part, writing memory and accomplishing our goal. Copy this code to the second buttons("write memory") click event handler:

    Code:
    Dim p As Process = Nothing
            If Process.GetProcessesByName("HackMe").Count > 0 Then
                p = Process.GetProcessesByName("HackMe")(0)
            Else
                MessageBox.Show("HackMe not open!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                Exit Sub
            End If
            Dim Adr As Int32 = &H419004
            Try
                If WriteInt32(p, Adr, 100) Then
                    MessageBox.Show("Variable set to 100.", "Memory Write Successful", MessageBoxButtons.OK)
                Else
                    MessageBox.Show("Writing memory failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                End If
            Catch ex As Exception
                MessageBox.Show("Writing memory failed: " & vbCrLf & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            End Try
    Compile and run. Try the buttons...



    ...and hit Enter in HackMe to see if it worked:



    Hassan's Edit: Outside links are not allowed and are removed.
    Last edited by Hassan; 05-25-2012 at 08:55 AM. Reason: Outside links are not allowed and are removed

  2. #2
    SuperRomu's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    1
    Reputation
    10
    Thanks
    0
    Thanks! This is really nice!
    btw i have Windows 7 x64 and "HackMe.exe" dont work!

  3. #3
    xKarma's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    2
    Ah. Forgot to mention the tutorial is essentially for 32-bit systems.

    Try running HackMe in XP compability mode. You will still(probably) have to find the memory address yourself though.

    I linked a tutorial on finding memory addresses in the beginning of this thread.

  4. #4
    ClaimIT's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Location
    Russia
    Posts
    73
    Reputation
    -2
    Thanks
    161
    My Mood
    Blah
    this hack will never work with NetGames truth me, this is how they make the trainers for pc games..



    IDK What Is Up There Just Was In My Mind xD


Similar Threads

  1. Wats possible and not possible through memory hacking?
    By ClanTag in forum C++/C Programming
    Replies: 13
    Last Post: 07-13-2009, 06:48 PM
  2. where can i find memory hacking software?
    By headsup in forum General Hacking
    Replies: 4
    Last Post: 06-22-2009, 09:57 AM
  3. Memory Hacking (the ones that works/doesn't work)
    By Kuro Tenshi in forum Combat Arms Europe Hacks
    Replies: 2
    Last Post: 04-12-2009, 02:36 AM
  4. Memory Hacking Software (MHS)
    By ElmoCA in forum Combat Arms Hacks & Cheats
    Replies: 5
    Last Post: 02-04-2009, 05:56 PM