• Welcome to Valhalla Legends Archive.
 

Question [c++]

Started by iago, February 05, 2003, 06:02 PM

Previous topic - Next topic

Adron

#15
Since i've been opening nbbot again and making some changes, i'll post this snippet from it, regarding memory mapping files:

     LPCVOID map;
      int size;
      HANDLE h, sh;
      h = CreateFile(exe, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
      if(h != INVALID_HANDLE_VALUE) {
            sh = CreateFileMapping(h, 0, PAGE_READONLY|SEC_COMMIT, 0, 0, 0);
            map = MapViewOfFile(sh, FILE_MAP_READ, 0, 0, 0);
            if((int)map) {
                  size = GetFileSize(h, 0);
                  // Do something with it
                  UnmapViewOfFile(map);
            }
            CloseHandle(h);
            CloseHandle(sh);
      }

Banana fanna fo fanna

#16
Thank you my friend.