asm question

Posts 113 of 13 · Page 1 of 1
asm question
say i have this in c++


how do i convert that to asm?

i have this so far
Code:
local dd 004E4DBCh
playertable dd 004E4E08h
if i wanted to access them like i did in c++, what would i do?
Code:
mov eax, dword ptr ds:[004E4DBCh]
mov eax, [eax]
// eax is now local

mov eax, dword ptr ds:[004E4E08h]
mov eax, [eax]
//eax is now pPlayerTable
Just a side question:


when you write: [eax] . Does that mean the data located in eax or like the address of eax?

This might be a stupid question but i get confused on stuff like this.
Quote Originally Posted by 258456 View Post
Just a side question:


when you write: [eax] . Does that mean the data located in eax or like the address of eax?

This might be a stupid question but i get confused on stuff like this.
If eax has a memory address it will write in that address.

Ex:
Code:
mov eax, 004E4E08h
mov word ptr ds:[eax],9090 ;it will write 9090 in 004E4E08h

mov word ptr ds:[004E4E08h],9090 ;direct without use register
teleport proc
mov edx, DWORD PTR [player1]
add edx, DWORD PTR ofs_new_x
mov [edx], WORD PTR 0
add edx, 4h
mov [edx], WORD PTR 0
add edx, 4h
mov [edx], WORD PTR 0
ret
teleport endp
The declaration of player1 and playertable is not like a C preprocessor macro, that is to say that player will not be replaced by the value it has been initialized as. It has its own legitimate address. You need one more level of indirection (otherwise known as dereferencing) in order to obtain the same C code you posted above.
i dont understand. lets say i have this
Code:
teleport proc
mov eax, DWORD PTR player1
mov edx, [eax]
add edx, DWORD PTR ofs_new_x
mov [edx], WORD PTR 0
add edx, 4h
mov [edx], WORD PTR 0
add edx, 4h
mov [edx], WORD PTR 0
ret
teleport endp
i know that i have it all right. the class start address is inside of 004E4DBC. so i access the class start it by doing [004E4DBC]. then i move that into a register,so the register holds the class start address. then, i add my x offset to get the x value, and try to change it. then i add 4 and do the same for y, and z. but it won't work ingame. i know the hotkey works, i used a messagebox for testing.
i converted the class to offsets.
[player] is not the same as [004E4DBCh]. [player] is 004E4DBCh.

Code:
// This...
mov eax, dword ptr ds:[player]
mov eax, [eax]
mov eax, [eax]

// is equivalent to this...
mov eax, dword ptr ds:[004E4DBCh]
mov eax, [eax]
As you can see, there is one more level of indirection.
Why are you derefrencing the pointer twice? The address of player1 (004e4dbc) is a pointer that points to the address of the class. If u derefrence it once, you should have the class address.

So what is player1 by itself?
also, when is it appropriate to use ds: ?

here it is in cheat engine...

34 is ofs_new_x
By creating the variable player1, you are effectively creating a pointer. If you create another pointer, you must dereference one more time to achieve the same result. In every single post, I have in some form or another stated that player1 occupies its own memory space. player1 contains the value 004E4DBCh, it is not 004E4DBCh itself.

ds - data
ss - stack
fs - OS defined (TIB for Windows)

cs/gs/es - point to the same locations/reserved
so if i did
Code:
mov edx, dword ptr [player1]
mov edx, [edx]
then edx would hold the value contained at the address of 004E4DBC?
Quote Originally Posted by kibbles18 View Post
so if i did
Code:
mov edx, dword ptr [player1]
mov edx, [edx]
then edx would hold the value contained at the address of 004E4DBC?
Could be wrong but i think edx is 004E4DBC.
Posts 113 of 13 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?