News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Converting Code

Started by NMMX, December 17, 2005, 04:20:17 PM

Previous topic - Next topic

NMMX

I have started to try and learn ASM *again*, I can already program in Borland Delphi, so I tried to convert one of my Delphi projects to MASM, but im stuck on a few things.

I need help with,
Buffer Array, The Memory Address.

This is the Delphi code,

var
StrBuffer: Array [0..1024] of Char;
GameWindow: String = 'Game';
GameAddress: LongInt = $004617AC;
GameHandle: DWORD;
WinHandle: DWORD;
PID: DWORD;
Read: DWORD;

begin
WinHandle:= FindWindow(nil, pChar(GameWindow));
if WinHandle = 0 then begin
MessageDlg('Window Not Found', mtError, [mbOk], 0);
ExitProcess(0);
end;
GetWindowThreadProcessId(WinHandle, PID);
GameHandle:= OpenProcess(PROCESS_ALL_ACCESS, False, PID);
ReadProcessMemory(GameHandle, Pointer(GameAddress), @StrBuffer, SizeOf(StrBuffer), Read);
MessageDlg(String(StrBuffer), mtInformation, [mbOk], 0);
end.


And this is the asm I got so far,

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
GameWindow      db 'Game',0

.data?
GameHandle      DWORD ?
PID             DWORD ?
WinHandle       DWORD ?

.code
start:
invoke FindWindow, NULL, addr GameWindow
mov WinHandle, eax
.if WinHandle==NULL
invoke MessageBox, NULL, "Window Not Found", "Error", MB_OK
invoke ExitProcess,NULL
.endif
invoke GetWindowThreadProcessId, WinHandle, addr PID
invoke OpenProcess, PROCESS_ALL_ACCESS, 0, PID
mov GameHandle, eax

*** Need the ReadProcessMemory and the MessageBox ***

invoke ExitProcess, NULL
end start


Also anyone know something like a ebook or website that will help me learn things like eax, esi because these still confuse me.

Thanks :thumbu

G`HOST

Quote from: NMMX on December 17, 2005, 04:20:17 PM
Also anyone know something like a ebook or website that will help me learn things like eax, esi because these still confuse me.

http://webster.cs.ucr.edu/AoA/index.html
http://win.asmcommunity.net/x86book/


NMMX

Well im very proud to say I have done it, alittle searching and trial and error.

These are the missing lines,


.data
MsgTitle        db 'Hello',0

.data?
StrBuffer       db 10 dup(?)

.code
invoke ReadProcessMemory, GameHandle, 4617ACh, offset StrBuffer, sizeof StrBuffer, 0
invoke MessageBox, NULL, addr StrBuffer, addr MsgTitle, MB_OK