I have a question. I admit I am a bit of a newbit at Intel ASM. when i was doing ASM we dealt with 1byte OP codes. We onbly had 128kb to address and that was alot lol
EDI is pointing to a memory location that has a string
EDI is incremented till we find the right character
and then we want to put a 0 in it
mov , 00

I am getting a Memory Access Violation Error. Is there something i need to define to allow me to access memory or what?
am i not acessing memory right or what?

I understand that move dword ptr supposedly puts in a loads the value that is located at edi and then accesses it
but how do I write to the memory directly.

Any help or shedding of light is much appreciated
Posted on 2002-03-05 13:57:31 by Volcano_88101
mov BYTE PTR , 0h


DWORD PTR is (4 bytes)
BYTE PTR is (1 byte)

Each character in a string is a byte(1).

Posted on 2002-03-05 14:01:13 by stryker
EDI = 00425115

00425112 3A 30 32 33 34 35 3A 32 33 3A 33 :02345:23:3
0042511D 35 3A 34 33 35 35 3A 45 44 44 44 5:4355:EDDD
00425128 00 00 00 00 00 00 00 00 00 00 00 .......

The character we are looking for is the ':' so it did stop in the right place
now we need to replace it with a null character

i have tried
move byte ptr, 00
move byte ptr, al ; where al = 0
move , al ; of course the compiler automatically converts it to the first one

Each time it hits that insturction it pops up a Access Violation error. Is there something that i have to include or Enable to allow it to write to it ?
Posted on 2002-03-05 14:13:45 by Volcano_88101
if your looking for : and want to replace that with a null character.


testStr db "hello cruel : world", 0


xor eax, eax
mov edi, OFFSET testStr


mov al, BYTE PTR [edi]
inc edi
or eax, eax ;Check for the end of string
jz @f
cmp al, 3Ah ;Check if we found a : character
jne @b

; minus 1 since we inc edi after the mov al, ...

mov BYTE PTR [edi-1], 0h



Not tested though. But same logic. :)
Posted on 2002-03-05 14:21:07 by stryker
"Access Violation" means that you are trying to write to memory area that you shouldn't. Unless you are writing a virus or a vxd, this is not something you want to enable :) You have probably incremented edi too much, and you have gone past your .data segment, trying to write to a read-only segment, probably your code segment. You don't have to "enable" something, it's just that when you are trying to do the mov byte ptr , 0, edi is not pointing at your string. In fact, it is not even pointing at your .data segment.
Posted on 2002-03-05 16:01:04 by micmic
I assume this is code you have written yourself as I don't address other situations. The problem is an easy one, the address you have in is not within memory that your application owns.

It can be that you have gone past the end of a buffer that you have allocated or you may have obtained the memory location incorrectly and are trying to write to a completely unrelated address.

Either will give you access violations.


Posted on 2002-03-05 17:22:58 by hutch--
I think we all jumped the gun here. A little more information would probably go a long way.

What OS are you using.
What type of program are you writing (app, device driver)
How did you first aquire the memory address that you've initially loaded into edi
Posted on 2002-03-05 22:02:31 by Canite
Yeah I finally figured it out.. stupid old me lol. The Value that I was passing was a Pointer to a String but apparently the String did not want to be modified.. so I ended up copying the string to another buffer which i was then able to modify.. which if you ask me is a complete waste of time but it works cause i can split a 60 character long string 9,123,657 times in under 10 seconds :) versus the normal 22 seconds that the regular one i created in regular C++.. Not really worth it but it the experience was good :)
ty for all the help and suggstions :) still would like to know how to write to thyat.. if icould just knock off having to allocate that buffer hmmm i could knock a few OP's off ;)

:alright: :alright:
Posted on 2002-03-06 00:58:57 by Volcano_88101
First off, are you using the stack to store the string, or a buffer defined in the .data segment of your code? If it is a buffer through the .data segment I would try mov 0:,al . The move
instruction is looking for a segment:offset memory address. Second question, are you writing a dos or windows program. In dos you have to supply the segment:offset values but in windows I think you can use just the offset because of the flat memory model. Please anyone correct me if I am wrong :) When I use this I dont even think about it, so it is hard to say for sure off the top of my head. Hope this helps.
Posted on 2002-03-06 01:44:48 by Jag
Also on second though, are you setting the value of DS? using something like
assum DS:.data #?? not quite sure about this
mov DS, offset .data #but this should work

when no segment is entered in a move command DS is assumed. If ds is some wired value (and you are writing for dos or 16bit) then it could be trying to access some bezair memory location :)
Posted on 2002-03-06 01:53:39 by Jag

Just to clear up something, you code line looks like 32 bit code when you use and if this is so, you must NOT use segment definitions at all in 32 bit code or it will crash the code. 32 bit windows is in protected mode and flat memory model so a 32 bit PE file works something like a DOS com file that has all of its code and data within ONE segment.


Posted on 2002-03-06 08:37:03 by hutch--
My guess is the original buffer was placed in .code , or sections
were merged without adding write to the section flags.
Posted on 2002-03-06 11:45:40 by f0dder