Search Tools Links Login

Peek and Poke from VB


Visual Basic 6, or VB Classic

Allows you to Peek and Poke memory
(For those not old enough to remember these commands, read a value from an address in memory and write a value to an address in memory)

Original Author: Duncan Jones

API Declarations

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Long, ByVal Length As Long)
Private Declare Sub CopyMemoryByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Byte, Source As Long, ByVal Length As Long)
Private Declare Sub CopyMemoryFromByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Byte, ByVal Length As Long)

Code

'\ API Declarations
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Long, ByVal Length As Long)

Private Declare Sub CopyMemoryByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Byte, Source As Long, ByVal Length As Long)

Private Declare Sub CopyMemoryFromByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Byte, ByVal Length As Long)
'\ Utility functions
Public Function Peek(Address As Long) As Long
Call CopyMemory(Peek, ByVal Address, Len(Address))
End Function
Public Function PeekByte(Address As Long) As Byte
Call CopyMemoryByte(PeekByte, ByVal Address, Len(PeekByte))
End Function
Public Function Poke(Address As Long, Value As Long)
CopyMemory ByVal Address, Value, LenB(Value)
End Function
Public Function PokeByte(Address As Long, Value As Byte)
CopyMemoryFromByte ByVal Address, Value, LenB(Value)
End Function

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 168 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.