diff --git a/mmap/mmap_private.c b/mmap/mmap_private.c index 4c7ad17..77a205d 100644 --- a/mmap/mmap_private.c +++ b/mmap/mmap_private.c @@ -12,7 +12,7 @@ char* mmap_private(const char* filename,unsigned long* filesize) { #ifdef __MINGW32__ HANDLE fd,m; char* map; - fd=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); + fd=CreateFile(filename,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); if (fd==INVALID_HANDLE_VALUE) return 0; m=CreateFileMapping(fd,0,PAGE_WRITECOPY,0,0,NULL); @@ -27,7 +27,7 @@ char* mmap_private(const char* filename,unsigned long* filesize) { char *map; if (fd>=0) { *filesize=lseek(fd,0,SEEK_END); - map=mmap(0,*filesize,PROT_WRITE,MAP_PRIVATE,fd,0); + map=mmap(0,*filesize,PROT_READ|PROT_WRITE,MAP_PRIVATE,fd,0); if (map==(char*)-1) map=0; close(fd); diff --git a/mmap/mmap_shared.c b/mmap/mmap_shared.c index 184ebff..086a7c8 100644 --- a/mmap/mmap_shared.c +++ b/mmap/mmap_shared.c @@ -12,7 +12,7 @@ extern char* mmap_shared(const char* filename,unsigned long* filesize) { #ifdef __MINGW32__ HANDLE fd,m; char* map; - fd=CreateFile(filename,GENERIC_WRITE,FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); + fd=CreateFile(filename,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_WRITE,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0); if (fd==INVALID_HANDLE_VALUE) return 0; m=CreateFileMapping(fd,0,PAGE_READWRITE,0,0,NULL); @@ -27,7 +27,7 @@ extern char* mmap_shared(const char* filename,unsigned long* filesize) { char *map; if (fd>=0) { *filesize=lseek(fd,0,SEEK_END); - map=mmap(0,*filesize,PROT_WRITE,MAP_SHARED,fd,0); + map=mmap(0,*filesize,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0); if (map==(char*)-1) map=0; close(fd);