Reading/Writing Memory

Discussion in 'Programming General' started by Terrankiller, Feb 13, 2008.

Reading/Writing Memory
  1. Unread #1 - Feb 13, 2008 at 5:59 PM
  2. Terrankiller
    Joined:
    May 7, 2005
    Posts:
    1,286
    Referrals:
    1
    Sythe Gold:
    1

    Terrankiller Ex-Administrator
    Retired Administrator Visual Basic Programmers

    Reading/Writing Memory

    I decided to release this because mostly everything in this forum sucks and I haven't seen anything like this posted yet. Basically, this should get you started with making actual trainers. If you do not know how to get a process handle or byte address, then you shouldn't even be using this code in the first place:

    Code:
    'Written by: Terrankiller
    '[email protected]
    'http://www.terrankiller.com
    
    Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
    
    Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, ByVal lpNumberOfBytesWritten As Long) As Long
    
    Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    
    Public Declare Sub CloseHandle Lib "kernel32" (ByVal hPass As Long)
    
    Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
    
    Public Const PROCESS_VM_READ = &H10&
    
    'Read Process Memory
    'ReadMemory ProcessID, &H1C4F982, VarPtr(ReadValue), LenB(ReadValue)
    
    Public Function ReadMemory(Process As Long, ByVal Address As Long, ByVal Buffer As Long, ByVal Size As Long)
    
       On Error Resume Next
       
       Dim pHnd As Long, bWritten As Long
       
          pHnd = OpenProcess(PROCESS_VM_READ, False, Process)
          
          If pHnd = 0 Then Exit Function
          
          ReadProcessMemory pHnd, ByVal Address, ByVal Buffer, Size, bWritten
          
          CloseHandle pHnd
    
    End Function
    
    'Modify Process Memory
    'WriteMemory ProcessID, &H1C4F982, VarPtr(ModifyValue), LenB(ModifyValue)
    
    Public Function WriteMemory(Process As Long, ByVal Address As Long, ByVal Buffer As Long, ByVal Size As Long)
    
       On Error Resume Next
       
       Dim pHnd As Long, bWritten As Long
        
          pHnd = OpenProcess(PROCESS_ALL_ACCESS, False, Process)
          
          If pHnd = 0 Then Exit Function
    
          WriteProcessMemory pHnd, ByVal Address, ByVal Buffer, Size, bWritten
          
          CloseHandle pHnd
    
    End Function
    
     
  3. Unread #2 - Feb 27, 2008 at 10:17 PM
  4. colinrusovic
    Joined:
    Dec 8, 2007
    Posts:
    79
    Referrals:
    0
    Sythe Gold:
    0

    colinrusovic Member

    Reading/Writing Memory

    your a legend programer with amazing programs, and im just a leecher, but maybe ude get some feedback in ur posts if u were a bit nicer :)

    just a suggestion. and if u don't mind me asking, why'd you close your sight?

    -colin
     
< GetWindowText | Program Error-Need Help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site