Hi,
Not sure whether this is the right group to post.. If I post at the wrong
group, please indicate which group i should post the message. :)
Anyway, I am recompling one of my old Appz from 32 bit to 64 bit to run in
vista. The appz will use loadlibrary to load a static dll to open a file and
write. In vista 64 bit OS, I have both 64bit version of appz and 32bit
version of appz running together and a crash occurs.
These are the steps I tried:
1. Launch 64bit Appz, it will map the file into memory using
MapViewOfFile(hHandle, FILE_MAP_WRITE, 0,0,0). Write something to the
memory.
2. Launch 32bit Appz, it can map the same file into memory successfully. But
when it tries to 'write' the same thing to the memory using memcpy, an
access violation occurs.
In windbg memory window, I found that the source address of memcpy in 32 bit
appz points to somewhere that cannot be seen/accessed by memory window. It
seems like that part of memory has been paged out or sth.. Although the
source address is near the end of the file, but still, it is within the
filesize range and it seems that the last few K bytes of the file have been
paged out.
I read msdn on MapViewOfFile and still had no clue at all.. anyone knows
what is happening here?
By the way, if I run the 64bit or 32 bit appz alone there won't have any
problem. The crash occurs only when I launch both Appz together for the
first time. If I have launched either 32 or 64 bit Appz before, launching
both Appz together won't cause any access violation also.
Thanks.
Angela
Angela Yan - 13 Apr 2007 11:52 GMT
Let me simplify my question.
BYTE Buffer[256] = {0};
....
if (hFile != INVALID_HANDLE_VALUE)
{
hFileMapping = CreateFileMapping(hFile,NULL, PAGE_READWRITE, 0,0,
FileName);
if (hFileMapping != NULL)
{
pMappedView = (BYTE *)MapViewOfFile(hFileMapping, FILE_MAP_WRITE,
0,0,0);
if (pMappedView != NULL)
{
// Say file size is 0x92000 Bytes
memcpy(Buffer, pMappedView + 0x91D00, 20) //Copy 20 bytes
from location pMappedView + 0x91D00 to buffer
}
}
}
Compile the code in 32 bit and 64 bit respectively. Launch 64 bit appz then
followed 32 bit Appz (Sequence does not matter), the second Appz will crash
at the "memcpy()" call because the location pMappedView + 0x91D00 is not
accessible.
Thanks in advance.
Angela
> Hi,
>
[quoted text clipped - 31 lines]
> Thanks.
> Angela