Subj : Mapped view of file read error beyond 4096 Bytes To : borland.public.cpp.borlandcpp From : Douglas Martin Date : Thu Jan 20 2005 03:40 am I can only read the first 4096 Bytes on a page using memory mapped file IO: /**********************************************************/ /* mmfread.c */ #include #include #define BYTE_TO_READ 4096 /* From 0; 4095 OK, 4096 crashes */ VOID main() { HANDLE hFile; HANDLE hMapFile; LPVOID lpMapAddress; LPBYTE lpMapPointer; // Open the file hFile = CreateFile( "data.bin", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); // Create file mapping object hMapFile = CreateFileMapping( hFile, NULL, PAGE_READONLY, 0, 0, NULL); // Map a view of the file for reading lpMapAddress = MapViewOfFile( hMapFile, FILE_MAP_READ, 0, 0, 1); lpMapPointer=(LPBYTE)lpMapAddress+BYTE_TO_READ; printf("Byte is 0x%02X\n", *lpMapPointer); UnmapViewOfFile(lpMapAddress); CloseHandle(hMapFile); CloseHandle(hFile); getchar(); return; } /**********************************************************/ "data.bin" must be in the directory and atleast 4096 Bytes. /**********************************************************/ /* write.c */ #include #define BYTES_TO_WRITE 5000 void main() { HANDLE hFile; DWORD dwBytesWritten, i; unsigned char *Buffer; Buffer=(unsigned char *)malloc(BYTES_TO_WRITE); for (i=0; i