News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Copying file-mapped data

Started by afk, October 21, 2006, 12:42:39 AM

Previous topic - Next topic

afk

Hi,
I'm having a problem with loading a register with file-mapped data.
After invoking MapViewOfFile and storing the pointer in MapAddr I
want to :

mov ebx , MapAddr
mov al , byte ptr [ebx] <--------------

The program compiles o.k. and there are no returned errors during compilation or execution.
However, on GetOpenFileName, the dialog box appears to work normally unless I hit CANCEL.
This causes an immediate crash.

Removing the line "mov al , byte ptr [ebx]" will allow the app to run.
Is it a characteristic of file-mapped data that you can't copy it into a register or is there something
else happening here ?

Other info :
Win2000 Pro
masm 6.xxx
###################################################
I'm not sure if using the "modify message" option is the correct procedure but I
wanted to be sure to notify all of you that the problem has been solved.

My error was in not trapping for the CANCEL selection. I trapped for everything except the one
thing which zapped me. ;-)

GetOpenFileName / CANCEL returns ZERO and doesn't fill in the OPENFILENAME struc with a
filename.

ofn.lpstrFile (filename) = 0 crashes CreateFile which crashes everything downstream.

When the instruction pointer reached "mov al , [MapAddr] I **THINK** that because MapAddr
was uninitialized (still = 0) the attempt to access an illegal area of memory caused the immediate
abort. The error traps I had set for each of the APIs never got a chance to display.

Thanks again for any time you might have spent on this.
Austin Kelly




hutch--

Hi Austin,

Welcome on board. I would have a look at the value "MapAddr" to see what is in it before you try and write it to a register. If its an address it will be a number in the 4 megabyte range or larger. If you are not getting this type of number, then its probably not a valid address and I would look elsewhere to see why.

In MASM32 code,

  fn MessageBox,0,str$(MapAddr),"MapAddr",MB_OK
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php