Get Volume Bitmap-NTFS

 // Get volume bitmap(Only correct on NTFS) VOLUME_BITMAP_BUFFER *GetVolumeBitmap( HANDLE hDev, unsigned int *puiBitmapSize) { STARTING_LCN_INPUT_BUFFER sStartLcn; sStartLcn.StartingLcn.QuadPart = 0; DWORD dwBitmapSize = 0; DWORD dwAllocatedSize = 64 * 1024; VOLUME_BITMAP_BUFFER *pVolumeBitmap = NULL; for ( ; ; ) { pVolumeBitmap = (VOLUME_BITMAP_BUFFER *) LocalAlloc(LMEM_FIXED, dwAllocatedSize); BOOL ret = DeviceIoControl(hDev, FSCTL_GET_VOLUME_BITMAP, &sStartLcn, sizeof(sStartLcn), pVolumeBitmap, dwAllocatedSize, &dwBitmapSize, NULL); if (ret) { *puiBitmapSize = dwBitmapSize; return pVolumeBitmap; } if (GetLastError() != ERROR_MORE_DATA) return NULL; dwAllocatedSize *= 2; } }  

你可能感兴趣的:(C++,Code,snippies)