Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Access Denied when MapViewOfFile [modified]

Access Denied when MapViewOfFile [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eraccn
    wrote on last edited by
    #1

    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 PM

    modified on Tuesday, December 18, 2007 8:08:17 PM

    CPalliniC N G 3 Replies Last reply
    0
    • E eraccn

      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 PM

      modified on Tuesday, December 18, 2007 8:08:17 PM

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      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.

      In testa che avete, signor di Ceprano?

      E 1 Reply Last reply
      0
      • CPalliniC CPallini

        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.

        E Offline
        E Offline
        eraccn
        wrote on last edited by
        #3

        Is it ok?

        Later buggers harm more.

        CPalliniC 1 Reply Last reply
        0
        • E eraccn

          Is it ok?

          Later buggers harm more.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Can't you see what a mess is it? :)

          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.

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • E eraccn

            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 PM

            modified on Tuesday, December 18, 2007 8:08:17 PM

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • E eraccn

              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 PM

              modified on Tuesday, December 18, 2007 8:08:17 PM

              G Offline
              G Offline
              G Haranadh
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups