Hi people.

I'm continuing my research into using memory mapped files and have reached a small plateau. I'm asking for the same advice as the guy in this post

http://www.asmcommunity.net/board/showthread.php?threadid=7512&highlight=read+memory+mapped+file

Basically I'm trying to figure out how to read the data stored in the pointer variable that points the start of the mapped memory region.

My code is pretty much the following:

 

invoke CreateFile,ADDR szFileName,GENERIC_READ,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
Mov hFile, EAX

; Create a mapping area in memory for the text file.
invoke CreateFileMapping,hFile,0,PAGE_READONLY,0,0, ADDR szMappingObject
Mov hMap, EAX

; Bung the whole file into the mapping area we just created.
invoke MapViewOfFile,hMap,FILE_MAP_READ,0,0,0
Mov pData, EAX


Now, how do I read the data pointed to by pData? As a test I tried



invoke MessageBox,0,pData,ADDR szFileName,MB_OK


which displayed a message box with the contents of the text file I'm using - which is cool, just what I hoped, but how do I get the induvidual byte characters starting at pData? Basically I'm writing a searching routine and I want to go through the text, pointed by pData, character by character.


Cheers guys.
Jas.
Posted on 2002-12-16 08:05:49 by MrClyfar
individual byte characters?

pData is a pointer to your memory mapped file so you already have everything you'll need.
i often use the index registers for that stuff...



mov edi, pData

;get first byte
mov al, byte ptr [ edi ]

;get 2nd byte
mov al, byte ptr [ edi + 1 ]

;change 3rd byte
mov al, 80
mov byte ptr [ edi + 2 ], al

;go though your memory mapped region and overwrite it
mov ecx, LENGHT
@@: mov byte ptr [ edi ], al
inc edi
dec ecx
jnz @B
Posted on 2002-12-16 08:28:26 by mob
Cheers man, that works a treat. I tried using BYTE PTR before, but I guess I wasn't using the right target size (AL) or something else silly!

Anyway, thanks.

Jas.
Posted on 2002-12-16 11:15:49 by MrClyfar