Click to See Complete Forum and Search --> : Memory Hacking - BBC Basic for Windows


QJimbo
June 12th, 2004, 12:38 PM
Hi All,
Basically I'm trying to access the memory of the Game GTA: Vice City to learn a bit about memory hacking. The Language I'm using is BBC Basic for windows, which is actually closer to C++ with the way it deals with API's.
Here is the code so far:

SYS "FindWindow",0,"GTA: Vice City" TO vc%
SYS "GetWindowThreadProcessId", vc%, ^mainid% TO process%
PRINT "Process Id: ";mainid%

This works, I can find the ID. However I have hit a large brickwall:

SYS "OpenProcess",?,FALSE,mainid% TO hProcess
PRINT hProcess

REM Read The Clocks Hour from Memory
SYS "ReadProcessMemory", hProcess,&A10B6B, ^buffer%,3,^read% TO out%
PRINT out%
PRINT "Buffer: ";buffer%
PRINT "Read: ";read%

SYS "GetLastError" TO error%
PRINT error%

I don't know what to put in the dwDesiredAccess part (hence the questionmark) and any random number I try either produces and invalid handle or access denied error.

It is also possible to load DLLs into BBC Basic - here is an extract from the help file:
Functions in other DLLs must be explicitly loaded into memory, and must be called by address rather than by name. For example to call the function OleUIChangeIconA which is in OLEDLG.DLL you must perform the following steps:

SYS "LoadLibrary", "OLEDLG.DLL"
SYS "GetModuleHandle", "OLEDLG.DLL" TO oledlg%
SYS "GetProcAddress", oledlg%, "OleUIChangeIconA" TO chicon%
SYS chicon%, ci% TO uint%

Another problem is that BBC Basic for Windows cannot do Constants :(

If anyone can provide either an alternative/easier way of accessing memory or tell me what I'm doing wrong I would be very pleased :)
James

sbubis
June 15th, 2004, 05:09 AM
I don't know BBC but I think You should OpenProcess with dwDesiredAccess=PROCESS_VM_READ (the value is (0x0010)).
It'll allow you to ReadProcessMemory further
(Look at the OpenProcess topic in MSDN)

QJimbo
June 15th, 2004, 05:43 AM
Don't worry I've figured it out now, but thanks anyway for your help :)