Hi,
call me an idiot, but I have no idea how to manage this problem. It's easy, don't worry.
I just want to access a string and put something in there - let's say "AB":
It doesn't work out, though. How can I do this?
Thanks,
Claus
call me an idiot, but I have no idea how to manage this problem. It's easy, don't worry.
I just want to access a string and put something in there - let's say "AB":
.data
szTemp db 260 DUP(0)
.code
;...
invoke ChangeString, OFFSET szTemp
ChangeString proc buffer:DWORD
mov dl, 65
mov dh, 66
mov byte ptr ,dl
inc buffer
mov byte ptr ,dh
ChangeString endp
It doesn't work out, though. How can I do this?
Thanks,
Claus
Hi Claus,
Just load a register with the buffer address, let's say Esi:
Push Esi
Mov Esi,buffer
Mov Byte Ptr , Dl
Inc Esi
Mov Byte Ptr , Dh
Pop Esi
Regards,
Ramon
Just load a register with the buffer address, let's say Esi:
Push Esi
Mov Esi,buffer
Mov Byte Ptr , Dl
Inc Esi
Mov Byte Ptr , Dh
Pop Esi
Regards,
Ramon
Loading a string? Just copy the bytes. ;)
ChangeString proc buffer:DWORD
mov eax,
mov byte ptr , 'H'
mov byte ptr , 'i',
mov byte ptr , ' '
mov byte ptr , 'W'
mov byte ptr , 'o'
mov byte ptr , 'r'
mov byte ptr , 'l'
mov byte ptr , 'd'
mov byte ptr , 0
ret
ChangeString endp
Pretty bad since it does't contain a buffer-length parm and can thus be overflowed, but... well :)
Alright,
thanks alot.
I was just writing a small function that converts a number to a string:
I know, it's not optimized yet, but it works out for me.
Claus
PS: The string class looks interesting, but it would surely be an overkill for this function.
thanks alot.
I was just writing a small function that converts a number to a string:
ConvertNumberToString proc buffer:DWORD, number:DWORD
mov eax, number
push esi
mov esi,
mov ebx, 10
xor ecx, ecx
numberloop:
xor edx, edx
push ecx
div ebx
add edx, 48
pop ecx
push edx
inc ecx
cmp eax, 0
je writestring
jmp numberloop
writestring:
pop edx
mov byte ptr , dl
inc esi
dec ecx
jnz writestring
mov byte ptr , 0
pop esi
ret
ConvertNumberToString endp
I know, it's not optimized yet, but it works out for me.
Claus
PS: The string class looks interesting, but it would surely be an overkill for this function.