yvvan added a comment.

According to 
https://msdn.microsoft.com/en-us/2e9c3174-af48-4fa3-9f6a-fb62b23ed994 - 
"Unmapping a mapped view of a file invalidates the range occupied by the view 
in the address space of the process and makes the range available for other 
allocations".
Also as far as i understand from 
https://msdn.microsoft.com/en-us/library/ms810613.aspx mapped files can only be 
edited in other apps as mapped files opened with the same name 
(OpenFileMapping).

Simple example, I launch it and until i enter the number the test.h header 
remains locked and therefore i can't edit it in other apps.

  DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
  int accessRights = 0;
  accessRights |= GENERIC_READ;
  SECURITY_ATTRIBUTES securityAtts = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE 
};
  HANDLE fileHandle =
      CreateFile("D:\\test.h", accessRights, shareMode, &securityAtts,
                 OPEN_EXISTING,
                 FILE_FLAG_BACKUP_SEMANTICS,
                 NULL);
  
  HANDLE FileMappingHandle =
      CreateFileMappingA(fileHandle, 0, PAGE_READONLY, 0, 0, "D:_code_test.h");
  
  LPVOID Mapping = MapViewOfFile(FileMappingHandle, FILE_MAP_READ, 0, 0, 0);
  assert(Mapping);
  
  CloseHandle(FileMappingHandle);
  
  int i {0};
  std::cin >> i;
  UnmapViewOfFile(Mapping);
  
  CloseHandle(fileHandle);


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54995/new/

https://reviews.llvm.org/D54995



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to