News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Buffer not filling correctly

Started by Magnum, April 05, 2013, 10:16:28 AM

Previous topic - Next topic

Magnum

This is only filling the buffer with one A.

Andy

xor ecx,ecx

comp:

mov    ebx,offset Buffer
mov    [ebx],byte ptr 'A'

inc    ebx
inc    ecx
cmp    ecx,5
jne    comp
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

MichaelW

The code is setting EBX to the start of the buffer at the top of the loop... you  need to move your loop label.
Well Microsoft, here's another nice mess you've gotten us into.

Gunner

xor     ecx,ecx

mov     ebx,offset Buffer

comp:
mov     [ebx],byte ptr 'A'

inc     ebx
inc     ecx
cmp     ecx,5
jne     comp


See the difference?  Your code, each time the loop starts you reload the Buffer address into ebx, move an "A", then reload the address.  You keep resetting the pointer each iteration.
~Rob

Magnum

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

I know that buffer overruns are bad, but I wanted to see what happened if I did.

If I put another buffer after the 1st one, it writes into that.

Otherwise, I assume it is writing over my code.

Just for information, when does that become a problem ?

I could not see any ill effects writing 30 bytes over.

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

it's a trick used for malware
we can't really discuss it any further on this forum   :P