Hi all,
I have a quick question, whats wrong with this code below:
invoke lstrlen addr username
; eax now holds the number of characters in the username
mov dword ptr [eax], offset random
As you might of noticed, I want to move the value of eax into a buffer. I am having troubles finding the correct code, can someone please help me out?
Cheers, Tipidy.
mov buffer,eax
I thought it would be?
mov dword ptr [buffer], eax
@travism
that is more appropriate, but if the buffer is a local dword then it is also fine :)
I assumed that random was a dword variable, we need a bit more information as to what it is.
mov dword ptr [buffer], eax
generally, if the size is defined by a register (eax in this case), a ptr is not needed
if it were an immediate value, then you would want one
mov buffer,eax - the assembler knows it is a dword because of the size of eax
mov dword ptr buffer,27h - the assembler does not know the width of 27h (27h could be a byte, word, or dword)
although, if buffer is defined as a dword, it may know - don't trust it
cmp word ptr [esi],27h - in this case, [esi] could be any size - so could 27h - so a ptr is needed
Hey Neil
No offense intended brother.
None taken :bg, if Tipidy had posted a bit more code then we wouldn't be guessing ::) what exactly he means.
Quote from: dedndave on May 17, 2009, 02:38:04 PM
mov dword ptr [buffer], eax
generally, if the size is defined by a register (eax in this case), a ptr is not needed
if it were an immediate value, then you would want one
mov buffer,eax - the assembler knows it is a dword because of the size of eax
mov dword ptr buffer,27h - the assembler does not know the width of 27h (27h could be a byte, word, or dword)
although, if buffer is defined as a dword, it may know - don't trust it
cmp word ptr [esi],27h - in this case, [esi] could be any size - so could 27h - so a ptr is needed
Hey thanks for the explanation on that :) Im sure he should get it now.