Reading memory in VB.Net menu

User Tag List

Results 1 to 7 of 7
  1. #1
    XGenius's Avatar Private
    Reputation
    1
    Join Date
    Nov 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reading memory in VB.Net

    I am using these functions to read a processes memory:
    Code:
    Public Function GetInt64FromMemory(ByVal Address As Long, Optional ByVal Offset As Integer = 0) As Int64
            Try
                Return Marshal.ReadInt64(New IntPtr(Address), 0)
            Catch ex As Exception
                Debug.WriteLine("Exception in GetInt64FromMemory. Address: " _
                    & Address.ToString("x") & ". Offset: " & Offset.ToString & ". Description: " & ex.Message)
                Return Nothing
            End Try
        End Function
    
        Public Function GetInt32FromMemory(ByVal Address As Long, Optional ByVal Offset As Integer = 0) As Int32
            Try
                Return Marshal.ReadInt32(New IntPtr(Address), 0) 'GetMemory(Address, 4))
            Catch ex As Exception
                Debug.WriteLine("Exception in GetInt32FromMemory. Address: " _
                    & Address.ToString("x") & ". Offset: " & Offset.ToString & ". Description: " & ex.Message)
                Return Nothing
            End Try
        End Function
    
        Public Function GetInt16FromMemory(ByVal Address As Long, Optional ByVal Offset As Integer = 0) As Int16
            Try
                Return Marshal.ReadInt16(New IntPtr(Address), Offset)
            Catch ex As Exception
                Debug.WriteLine("Exception in GetInt16FromMemory. Address: " _
                    & Address.ToString("x") & ". Offset: " & Offset.ToString & ". Description: " & ex.Message)
                Return Nothing
            End Try
        End Function
    
        Friend Function GetStringFromMemory(ByVal Address As Long, ByVal nByte As Integer, Optional ByVal Offset As Integer = 0) As String
            Try
                Dim sBuffer(nByte - 1) As Byte
                sBuffer = GetMemory(New IntPtr(Address + Offset), nByte)
                Return System.Text.Encoding.ASCII.GetString(sBuffer)
            Catch ex As Exception
                Debug.WriteLine("Exception in GetStringFromMemory. Address: " _
                    & Address.ToString("x") & ". Offset: " & Offset.ToString & ". Num Bytes: " _
                    & nByte.ToString & ". Description: " & ex.Message)
                Return Nothing
            End Try
    
        End Function
    
        Public Function GetMemory(ByVal Address As Long, ByVal ByteCount As Long) As Object
            Try
                Dim _Return(ByteCount - 1) As Byte
                Marshal.Copy(New IntPtr(Address), _Return, 0, ByteCount)
                Return _Return
            Catch ex As Exception
                Debug.WriteLine("Exception occured in GetMemory. Start Address: " & Address.ToString("x") & _
                                 " Byte Count: " & ByteCount.ToString & " Details: " & ex.Message)
                Return Nothing
            End Try
    
        End Function
    And to see if I am logged in, I am trying to use:
    Code:
                Dim ObjectOffset As Integer = GetInt32FromMemory(_BaseAddress, &H1139F80)
                Debug.WriteLine("Client Connection: " & ObjectOffset)
                Dim IsLoadedOffset As Integer = GetInt32FromMemory(ObjectOffset, &H113D78C)
                Dim IsLoaded As Integer = GetInt32FromMemory(IsLoadedOffset, 0)
    But I just can't seem to get it to work at all. I have been a "leach" on this site for like 2 weeks now trying to read everything and get a grasp on this. I believe my offsets are correct for 3.2.2. I either just get a copy of my _BaseAddress value or I get an "Access Denied" error (assuming I am reading memory out of process.)

    To find my process, I am using
    Code:
            For Each tmpProcess As Process In Process.GetProcesses
                'Debug.WriteLine(tmpProcess.ProcessName)
                If tmpProcess.ProcessName.ToLower.Contains("wow") Then
    
                    tmpProcess.EnterDebugMode()
                    Dim _BaseAddress As Long = tmpProcess.MainModule.BaseAddress.ToInt32  'GetHeapAddress(tmpProcess.Handle)
    Any help would be very appreciated.

    These ads disappear when you log in.

  2. #2
    Sychotix's Avatar Moderator Authenticator enabled
    Reputation
    1277
    Join Date
    Apr 2006
    Posts
    3,610
    Thanks G/R
    230/439
    Trade Feedback
    1 (100%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I'm too lazy to read the code... but use something like SetForegroundWindow(WoWHandle); to see if you have the correct handle. Also, you must use OpenProcess(); to open the process and allow reading memory. You should check out some of the open-source bots that have been posted in the bots section. I belive that there was one recently released in Delphi, which is fairly similar to VB.

  3. #3
    XGenius's Avatar Private
    Reputation
    1
    Join Date
    Nov 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ya, I am using this:
    Dim hProcess As Integer = OpenProcess(PROCESS_ALL_ACCESS, 0, tmpProcess.Id)

    right after I call the [tmpProcess.EnterDebugMode()], just missed that line of code when I was posting this. I tried to keep most of my bs code out of this post.

  4. #4
    XGenius's Avatar Private
    Reputation
    1
    Join Date
    Nov 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I tried this code to see if I had the right process, but I don't think I have it right:
    Code:
            Process.EnterDebugMode()
            For Each tmpProcess As Process In Process.GetProcesses
                Try
                    Debug.WriteLine(tmpProcess.Id & ControlChars.Tab & tmpProcess.ProcessName.ToString & ControlChars.Tab & tmpProcess.MainWindowTitle)
                Catch ex As Exception
                    Debug.WriteLine(tmpProcess.Id & ControlChars.Tab & tmpProcess.ProcessName.ToString)
                End Try
                If tmpProcess.ProcessName.ToLower.Contains("wow") Then
                    SetForegroundWindow(tmpProcess.Id)
                End If
            Next
            Process.LeaveDebugMode()
            For intXCnt As Integer = 0 To 1000000
                Application.DoEvents()
            Next
    It seems to be the right process. It is the only process I have on my system that looks like WoW.

    I have even tried to change
    SetForegroundWindow(tmpProcess.Id)
    to be
    SetForegroundWindow(tmpProcess.Handle.ToInt32)

    But still it never comes up.

  5. #5
    XGenius's Avatar Private
    Reputation
    1
    Join Date
    Nov 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I am having other issues I think. I have downloaded wowRadar3.2.0VBNet and the WowFun source codes from this site, and neither of them seem to be working correctly either. I keep getting 0's from my memory reads. Any ideas?

  6. #6
    Sychotix's Avatar Moderator Authenticator enabled
    Reputation
    1277
    Join Date
    Apr 2006
    Posts
    3,610
    Thanks G/R
    230/439
    Trade Feedback
    1 (100%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by XGenius View Post
    Okay, I am having other issues I think. I have downloaded wowRadar3.2.0VBNet and the WowFun source codes from this site, and neither of them seem to be working correctly either. I keep getting 0's from my memory reads. Any ideas?
    If SetForegroundWindow is not bringing the window in front, then you are not getting the correct handle.

  7. #7
    morxxxel's Avatar Member
    Reputation
    1
    Join Date
    Aug 2008
    Posts
    11
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hmm

    Try
    SetForegroundWindow(tmpProcess(0).Id)

    code by Andrew Buckau not me.
    Code:
     
     wowProcessIDS = Process.GetProcessesByName("wow")
            If wowProcessIDS.Length = 0 Then
                MessageBox.Show("Unable to find wow.exe : MUST STOP" & Environment.NewLine _
                                & "(is wow open/running /logged in?)")
                Return False
            Else
                'DoOutput("[wow.exe found]")
            End If
            If memReader.SetProcess("wow", "Read") = True Then ' READ READ..READ! only! <- not my .dll! found @ mmowned.com late 2009
                ' DoOutput("[mem_read OK]")
            Else
                MessageBox.Show("UNABLE to attach to wow.exe : MUST STOP")
                Return False
            End If
    another way to check if you have the proccess i dunno if it will help but i hope it does.(
    Last edited by morxxxel; 02-06-2010 at 07:02 PM.

Similar Threads

  1. Need help reading Memory, Writing too memory
    By Neer in forum Programming
    Replies: 0
    Last Post: 08-17-2009, 12:11 PM
  2. Witch util are you using to read memory ?
    By guillaume76290 in forum WoW Memory Editing
    Replies: 3
    Last Post: 07-19-2009, 07:52 PM
  3. Replies: 2
    Last Post: 03-11-2009, 04:20 PM
  4. Read Memory Return 0
    By marko002 in forum WoW Memory Editing
    Replies: 3
    Last Post: 12-12-2008, 09:13 PM
  5. [c++] problem with reading memory
    By Lucani in forum WoW Memory Editing
    Replies: 3
    Last Post: 05-08-2008, 03:41 AM
All times are GMT -5. The time now is 11:45 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search