Access Denied when MapViewOfFile [modified]
-
The class is used for recording informations which may be massive.In the initialization:
m_qwFileSize = 0x4000000; m_qwFileOffset = 0; m_T = 600 * m_siInfo.dwAllocationGranularity; m_hMappingFile = ::CreateFileMapping(m_hFile,NULL,PAGE_READWRITE,0,m_qwFileSize + sizeof(TCHAR),NULL); m_lpStartLoc = ::MapViewOfFil(m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock);
When the view's size is larger than 60%,I re-mapping the file:if (m_qwFileOffset >= m_T){ m_T = m_qwFileOffset + 600 * m_siInfo.dwAllocationGranularity; ::UnmapViewOfFile(m_lpStartLoc); __int64 qwOldFileOffset = m_qwFileOffset; RndToSysAllocGranularity(m_qwFileOffset); __int64 qwOffVar = qwOldFileOffset - m_qwFileOffset; m_lpStartLoc = ::MapViewOfFile (m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock); PBYTE pByte = reinterpret_cast(m_lpStartLoc); pByte += qwOffVar; m_lpStartLoc = pByte;}
in the RndToSysAllocGranularity(), I allocate the File offset:
if (dwRemains){ __int64 dwDevided = dwValue / m_siInfo.dwAllocationGranularity; dwValue = (dwDevided + 1) * m_siInfo.dwAllocationGranularity;}
When it works, I get the errors and its error code is 0x5,it means access denied.Why? Later buggers harm more. modified on Tuesday, December 18, 2007 7:57:40 PMmodified on Tuesday, December 18, 2007 8:08:17 PM
-
The class is used for recording informations which may be massive.In the initialization:
m_qwFileSize = 0x4000000; m_qwFileOffset = 0; m_T = 600 * m_siInfo.dwAllocationGranularity; m_hMappingFile = ::CreateFileMapping(m_hFile,NULL,PAGE_READWRITE,0,m_qwFileSize + sizeof(TCHAR),NULL); m_lpStartLoc = ::MapViewOfFil(m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock);
When the view's size is larger than 60%,I re-mapping the file:if (m_qwFileOffset >= m_T){ m_T = m_qwFileOffset + 600 * m_siInfo.dwAllocationGranularity; ::UnmapViewOfFile(m_lpStartLoc); __int64 qwOldFileOffset = m_qwFileOffset; RndToSysAllocGranularity(m_qwFileOffset); __int64 qwOffVar = qwOldFileOffset - m_qwFileOffset; m_lpStartLoc = ::MapViewOfFile (m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock); PBYTE pByte = reinterpret_cast(m_lpStartLoc); pByte += qwOffVar; m_lpStartLoc = pByte;}
in the RndToSysAllocGranularity(), I allocate the File offset:
if (dwRemains){ __int64 dwDevided = dwValue / m_siInfo.dwAllocationGranularity; dwValue = (dwDevided + 1) * m_siInfo.dwAllocationGranularity;}
When it works, I get the errors and its error code is 0x5,it means access denied.Why? Later buggers harm more. modified on Tuesday, December 18, 2007 7:57:40 PMmodified on Tuesday, December 18, 2007 8:08:17 PM
-
Please use the <pre></pre> tags to surround code. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
-
The class is used for recording informations which may be massive.In the initialization:
m_qwFileSize = 0x4000000; m_qwFileOffset = 0; m_T = 600 * m_siInfo.dwAllocationGranularity; m_hMappingFile = ::CreateFileMapping(m_hFile,NULL,PAGE_READWRITE,0,m_qwFileSize + sizeof(TCHAR),NULL); m_lpStartLoc = ::MapViewOfFil(m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock);
When the view's size is larger than 60%,I re-mapping the file:if (m_qwFileOffset >= m_T){ m_T = m_qwFileOffset + 600 * m_siInfo.dwAllocationGranularity; ::UnmapViewOfFile(m_lpStartLoc); __int64 qwOldFileOffset = m_qwFileOffset; RndToSysAllocGranularity(m_qwFileOffset); __int64 qwOffVar = qwOldFileOffset - m_qwFileOffset; m_lpStartLoc = ::MapViewOfFile (m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock); PBYTE pByte = reinterpret_cast(m_lpStartLoc); pByte += qwOffVar; m_lpStartLoc = pByte;}
in the RndToSysAllocGranularity(), I allocate the File offset:
if (dwRemains){ __int64 dwDevided = dwValue / m_siInfo.dwAllocationGranularity; dwValue = (dwDevided + 1) * m_siInfo.dwAllocationGranularity;}
When it works, I get the errors and its error code is 0x5,it means access denied.Why? Later buggers harm more. modified on Tuesday, December 18, 2007 7:57:40 PMmodified on Tuesday, December 18, 2007 8:08:17 PM
You can always use "Preview" to check if format is ok or not before posting.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
-
The class is used for recording informations which may be massive.In the initialization:
m_qwFileSize = 0x4000000; m_qwFileOffset = 0; m_T = 600 * m_siInfo.dwAllocationGranularity; m_hMappingFile = ::CreateFileMapping(m_hFile,NULL,PAGE_READWRITE,0,m_qwFileSize + sizeof(TCHAR),NULL); m_lpStartLoc = ::MapViewOfFil(m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock);
When the view's size is larger than 60%,I re-mapping the file:if (m_qwFileOffset >= m_T){ m_T = m_qwFileOffset + 600 * m_siInfo.dwAllocationGranularity; ::UnmapViewOfFile(m_lpStartLoc); __int64 qwOldFileOffset = m_qwFileOffset; RndToSysAllocGranularity(m_qwFileOffset); __int64 qwOffVar = qwOldFileOffset - m_qwFileOffset; m_lpStartLoc = ::MapViewOfFile (m_hMappingFile,FILE_MAP_ALL_ACCESS,static_cast(m_qwFileOffset >> 32),static_cast(m_qwFileOffset & 0xFFFFFFFF),m_dwBytesInBlock); PBYTE pByte = reinterpret_cast(m_lpStartLoc); pByte += qwOffVar; m_lpStartLoc = pByte;}
in the RndToSysAllocGranularity(), I allocate the File offset:
if (dwRemains){ __int64 dwDevided = dwValue / m_siInfo.dwAllocationGranularity; dwValue = (dwDevided + 1) * m_siInfo.dwAllocationGranularity;}
When it works, I get the errors and its error code is 0x5,it means access denied.Why? Later buggers harm more. modified on Tuesday, December 18, 2007 7:57:40 PMmodified on Tuesday, December 18, 2007 8:08:17 PM
hi all, i am also looking for same error's solution. first iteration it worked for me. second iteration not worked at all. any help appriciated.
Nice talking to you. :-O
If you judge people, you have no time to love them. -- Mother Teresa