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":

szTemp db 260 DUP(0)

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?

Posted on 2006-10-21 05:21:32 by Claus von der Burchard
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


Posted on 2006-10-21 05:33:29 by rsala
Loading a string? Just copy the bytes.  ;)
Posted on 2006-10-21 05:37:55 by roticv

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
ChangeString endp

Pretty bad since it does't contain a buffer-length parm and can thus be overflowed, but... well :)
Posted on 2006-10-21 08:19:16 by f0dder

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
xor edx, edx
push ecx
div ebx
add edx, 48
pop ecx
push edx
inc ecx
cmp eax, 0
je writestring
jmp numberloop

pop edx
mov byte ptr , dl
inc esi
dec ecx
jnz writestring

mov byte ptr , 0
pop esi
ConvertNumberToString endp

I know, it's not optimized yet, but it works out for me.


PS: The string class looks interesting, but it would surely be an overkill for this function.
Posted on 2006-10-22 09:27:16 by Claus von der Burchard