Eric Pouech : imagehlp: Make use of the bReadOnly parameter in MapAndLoad.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jan 4 15:09:32 CST 2007


Module: wine
Branch: master
Commit: 2d6e914bc0dbd63490bfa6137af0b65713acaa9a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2d6e914bc0dbd63490bfa6137af0b65713acaa9a

Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date:   Wed Jan  3 14:39:33 2007 +0100

imagehlp: Make use of the bReadOnly parameter in MapAndLoad.

---

 dlls/imagehlp/access.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/imagehlp/access.c b/dlls/imagehlp/access.c
index 51ec161..1560d11 100644
--- a/dlls/imagehlp/access.c
+++ b/dlls/imagehlp/access.c
@@ -164,7 +164,9 @@ BOOL WINAPI MapAndLoad(LPSTR pszImageNam
         goto Error;
     }
 
-    hFile = CreateFileA(szFileName, GENERIC_READ, FILE_SHARE_READ,
+    hFile = CreateFileA(szFileName,
+                        GENERIC_READ | (bReadOnly ? 0 : GENERIC_WRITE),
+                        FILE_SHARE_READ,
                         NULL, OPEN_EXISTING, 0, NULL);
     if (hFile == INVALID_HANDLE_VALUE)
     {
@@ -172,14 +174,16 @@ BOOL WINAPI MapAndLoad(LPSTR pszImageNam
         goto Error;
     }
 
-    hFileMapping = CreateFileMappingA(hFile, NULL, PAGE_READONLY | SEC_COMMIT, 0, 0, NULL);
+    hFileMapping = CreateFileMappingA(hFile, NULL, 
+                                      (bReadOnly ? PAGE_READONLY : PAGE_READWRITE) | SEC_COMMIT,
+                                      0, 0, NULL);
     if (!hFileMapping)
     {
         WARN("CreateFileMapping: Error = %d\n", GetLastError());
         goto Error;
     }
 
-    mapping = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
+    mapping = MapViewOfFile(hFileMapping, bReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE, 0, 0, 0);
     CloseHandle(hFileMapping);
     if (!mapping)
     {




More information about the wine-cvs mailing list