Hello Coding-Friends,
can you help me, to write and read from the RAM ?
Im not that good in programming, so show a litle code, please !

Many THX in advanced.
Posted on 2003-02-14 15:46:09 by Forginforcer
well,




.data
test_dword1 dd 1234h ;from here we will read
test_dword2 dd 0 ;here we will write

.code

mov eax,[test_dword1] ; now we have read 1234 value into eax register
mov [test_dword2],eax ; here we write the contents of eax register over the old "zero" value



BTW
- why do you need to know this info?
- have you read Iczelion's tutorials?
Posted on 2003-02-14 16:12:02 by BogdanOntanu
THX BogdanOntanu

but i have still probs.

how i can specify the right address ?
I never get the right adress.

and how i can read a row of character from the RAM ?

Thanks again.
Posted on 2003-02-15 06:12:19 by Forginforcer
with ADDR, OFFSET and lea

you can read as much as you want as long as you stay in memory allocated to you. strings usually end with 0
Posted on 2003-02-15 06:35:09 by Hiroshimator
Thanks, but hot zo use it ?
Can you please give me an example for readng 1024bytes form the memoryadress 6400:9999 ?

Danke !
Posted on 2003-02-15 07:51:47 by Forginforcer
Memory in Windows is a vertual memory map. When you open a program , Windows assigns you what it refers to as a thread. Really it is a Local Descriptor Table With all your entries. Your regester settup and segments of memory to use as well as a priviledge level that is lower than Windows. Windows has priviledge level 0. So in it's Global Descriptor table it gives it's self access to all memory. You do not have access to all memory. Only what Windows allows. This is a hardware feature of the processor. Intel brought this about stating with the '286. The first program or operating system that inters protected mode status has dibs on all memerory and memory assignments. If your program tries to read memory not assigned to your priviledge level or if you attempt to alter a Task State Segments priviledge level you will get an interrupt (General Protection Exception 13).
Now if you just want to view memory. DOS's "Debug.exe" works veiwing segments and offsets like you listed. A 16 bit method of dumping memory would look like this:

Mov CX,1234 ; no of bytes to move
Mov DS,F000
Mov ES,4000
Mov SI,1000
mov DI,2000
repnz
movsb

That copies memory from DS:SI to ES:DI.
In Windows you need to ask Windows for permission to read and write through the Windows API's. Like GlobalAlloc etc.
Don't forget. If your are in vertual 8086 mode than you are still in protected mode. You must reboot into DOS real mode for full access of all memory.
Posted on 2003-02-15 14:14:52 by mrgone
Access-rules have to do with rings, havn't it ?
Posted on 2003-02-15 15:02:58 by Forginforcer
I tried to explain that you cannot Access all memory unless you boot with your own operating system and set up Your own Local Descriptor Tables and The Global Descriptor and Task State Segments as well as Interrupt decriptor tables.
If you are interested in writing in Windows than you must adhere to it's rules. Do you have the Win32 API help file? If you don't you can down load it from Iczelion's Win32 Home Page.
Since Virtual 8086 Mode is still in protected mode environment, you should be able to read all memory within Virtual DOS except that in 16 bit mode you only have 20 address lines on the address buss. They are laid out like this : F000
+FFFF
equals-------
FFFFF hex
or 1,048,575 dec

One Meg access. 2 to the 20th power
Posted on 2003-02-15 17:03:50 by mrgone