$ERROR Requires QB64 v1.5
or greater
testbyte = -126
Print "Value at _Offset(testbyte):", , PeekByte
(exe
, _Offset(testbyte
)) pokey
= PokeByte
(exe
, _Offset(testbyte
), -108)Print "Value after PokeByte:", , testbyte
testunsignedbyte = 243
Print "Value at _Offset(testunsignedbyte):", PeekUnsignedByte
(exe
, _Offset(testunsignedbyte
)) pokey
= PokeUnsignedByte
(exe
, _Offset(testunsignedbyte
), 204)Print "Value after PokeUnsignedByte:", testunsignedbyte
testint = -5005
Print "Value at _Offset(testint):", , PeekInt
(exe
, _Offset(testint
)) pokey
= PokeInt
(exe
, _Offset(testint
), -4080)Print "Value after PokeInt:", , testint
testunsignedint = 5234
Print "Value at _Offset(testunsignedint):", PeekUnsignedInt
(exe
, _Offset(testunsignedint
)) pokey
= PokeUnsignedInt
(exe
, _Offset(testunsignedint
), 5500)Print "Value after PokeUnsignedInt:", , testunsignedint
testlong = -55000
Print "Value at _Offset(testlong):", , PeekLong
(exe
, _Offset(testlong
)) pokey
= PokeLong
(exe
, _Offset(testlong
), -32872)Print "Value after PokeLong:", , testlong
testunsignedlong = 56985
Print "Value at _Offset(testunsignedlong:", PeekUnsignedLong
(exe
, _Offset(testunsignedlong
)) pokey
= PokeUnsignedLong
(exe
, _Offset(testunsignedlong
), 57234)Print "Value after PokeUnsignedLong:", testunsignedlong
testint64 = -58698560
Print "Value at _Offset(testint64):", , PeekInt64
(exe
, _Offset(testint64
)) pokey
= PokeInt64
(exe
, _Offset(testint64
), -98758763)Print "Value after PokeInt64:", , testint64
testunsignedint64 = 5854324590
Print "Value at _Offset(testunsignedint64):", PeekUnsignedInt64
(exe
, _Offset(testunsignedint64
)) pokey
= PokeUnsignedInt64
(exe
, _Offset(testunsignedint64
), 3248506902)Print "Value after PokeUnsignedInt64:", testunsignedint64
teststring
= "This is a test of peeking a string stored at _Offset(teststring)" + Chr$(0)pokey
= PokeString
(exe
, _Offset(teststring
), "This is the value of the string after poking")
'Begin $INCLUDE
Const PROCESS_VM_READ
= &H0010 Const PROCESS_QUERY_INFORMATION
= &H0400 Const PROCESS_VM_WRITE
= &H0020 Const PROCESS_VM_OPERATION
= &H0008 Const STANDARD_RIGHTS_REQUIRED
= &H000F0000 Const SYNCHRONIZE
= &H00100000 Const PROCESS_ALL_ACCESS
= STANDARD_RIGHTS_REQUIRED
Or SYNCHRONIZE
Or &HFFFF
Const TH32CS_INHERIT
= &H80000000 Const TH32CS_SNAPHEAPLIST
= &H00000001 Const TH32CS_SNAPMODULE
= &H00000008 Const TH32CS_SNAPMODULE32
= &H00000010 Const TH32CS_SNAPPROCESS
= &H00000002 Const TH32CS_SNAPTHREAD
= &H00000004 Const TH32CS_SNAPALL
= TH32CS_SNAPHEAPLIST
Or TH32CS_SNAPMODULE
Or TH32CS_SNAPPROCESS
Or TH32CS_SNAPTHREAD
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 1, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekByte = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 1, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeByte = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 1, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekUnsignedByte = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 1, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeUnsignedByte = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 2, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekInt = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 2, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeInt = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 2, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekUnsignedInt = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 2, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeUnsignedInt = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 4, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekLong = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 4, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeLong = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 4, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekUnsignedLong = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 4, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeUnsignedLong = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 8, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekInt64 = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 8, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeInt64 = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), 8, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekUnsignedInt64 = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), 8, 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeUnsignedInt64 = memo
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) result
= Space$(strlen
(address
)) memo
= ReadProcessMemory
(hProcess
, address
, _Offset(result
), Len(result
), 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PeekString = result
Dim As PROCESSENTRY32 pe32
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
hProcess
= OpenProcess
(PROCESS_VM_READ
Or PROCESS_QUERY_INFORMATION
Or PROCESS_VM_WRITE
Or PROCESS_VM_OPERATION
, TOM_FALSE
, pe32.th32ProcessID
) lenaddress = strlen(address)
memo
= WriteProcessMemory
(hProcess
, address
, _Offset(value
), Len(value
), 0) closeh = CloseHandle(hProcessSnap)
closeh = CloseHandle(hProcess)
PokeString = memo
'End $INCLUDE