Driver Problems? Questions? Issues?
Put OSR's experience to work for you! Contact us for assistance with:
  • Creating the right design for your requirements
  • Reviewing your existing driver code
  • Analyzing driver reliability/performance issues
  • Custom training mixed with consulting and focused directly on your specific areas of interest/concern.
Check us out. OSR, the Windows driver experts.

OSR Seminars


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 7  
10 Jul 18 11:46
adnan
xxxxxx@gmail.com
Join Date: 24 May 2013
Posts To This List: 28
FSCTL_GET_VOLUME_BITMAP subsequent calls

Hi All, I am calling FSCTL_GET_VOLUME_BITMAP to get bitmap. The return code is ERROR_MORE_DATA with lpBytesReturned 1024*1024. So what should be the STARTING_LCN_INPUT_BUFFER for next call? LONGLONG GetVolumeBitmap( HANDLE hDev, char* bitmap, LONGLONG startOffset) { STARTING_LCN_INPUT_BUFFER sStartLcn; sStartLcn.StartingLcn.QuadPart = startOffset; // 0 in first call DWORD dwBitmapSize = 0; DWORD dwAllocatedSize = 1024 * 1024; VOLUME_BITMAP_BUFFER *pVolumeBitmap = NULL; pVolumeBitmap = (VOLUME_BITMAP_BUFFER *) LocalAlloc(LMEM_FIXED, dwAllocatedSize); BOOL ret = DeviceIoControl(hDev, FSCTL_GET_VOLUME_BITMAP, &sStartLcn, sizeof(sStartLcn), pVolumeBitmap, dwAllocatedSize, &dwBitmapSize, NULL); So if this returns `ret = 0` and `GetLastError() = ERROR_MORE_DATA` and `dwBitmapSize = 1024*1024`. So what should be the new LCN now?
  Message 2 of 7  
10 Jul 18 12:41
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6243
List Moderator
FSCTL_GET_VOLUME_BITMAP subsequent calls

From the MSDN documentation: <quote> A return value from GetLastError of ERROR_MORE_DATA indicates to the caller that the buffer was not large enough to accommodate a complete bitmap from the requested starting LCN to the last cluster on the volume. In this event, you can make subsequent FSCTL_GET_VOLUME_BITMAP calls to retrieve the remaining bitmap. </quote> It says "...to retrieve the remaining bitmap"... so, you start with the NEXT LCN, I would think. Or, you know, double the size of the buffer and call it again starting at zero ;-) Peter OSR @OSRDrivers
  Message 3 of 7  
10 Jul 18 12:48
Jamey Kirby
xxxxxx@gmail.com
Join Date: 31 Dec 2014
Posts To This List: 292
FSCTL_GET_VOLUME_BITMAP subsequent calls

> Or, you know, double the size of the buffer and call it again starting at zero ;-) Although not elegant, that is what I would do. I have to do the same when getting retrieval pointers of a file. On Tue, Jul 10, 2018 at 12:40 PM xxxxx@osr.com <xxxxx@lists.osr.com> wrote: > From the MSDN documentation: > > <quote> > A return value from GetLastError of ERROR_MORE_DATA indicates to the > caller that the buffer was not large enough to accommodate a complete > bitmap from the requested starting LCN to the last cluster on the volume. > In this event, you can make subsequent FSCTL_GET_VOLUME_BITMAP calls to > retrieve the remaining bitmap. > </quote> > <...excess quoted lines suppressed...> -- Jamey Kirby Disrupting the establishment since 1964 *This is a personal email account and as such, emails are not subject to archiving. Nothing else really matters.* --
  Message 4 of 7  
10 Jul 18 12:53
Jamey Kirby
xxxxxx@gmail.com
Join Date: 31 Dec 2014
Posts To This List: 292
FSCTL_GET_VOLUME_BITMAP subsequent calls

And with a little math, you can figure out how large the buffer needs to be for the entire volume (or pretty darn close). On Tue, Jul 10, 2018 at 12:47 PM Jamey Kirby <xxxxx@gmail.com> wrote: > > Or, you know, double the size of the buffer and call it again starting > at zero ;-) > > Although not elegant, that is what I would do. I have to do the same when > getting retrieval pointers of a file. > > On Tue, Jul 10, 2018 at 12:40 PM xxxxx@osr.com <xxxxx@lists.osr.com> > wrote: > >> From the MSDN documentation: <...excess quoted lines suppressed...> -- Jamey Kirby Disrupting the establishment since 1964 *This is a personal email account and as such, emails are not subject to archiving. Nothing else really matters.* --
  Message 5 of 7  
10 Jul 18 14:08
adnan
xxxxxx@gmail.com
Join Date: 24 May 2013
Posts To This List: 28
FSCTL_GET_VOLUME_BITMAP subsequent calls

> It says "...to retrieve the remaining bitmap"... so, you start with the NEXT LCN, I would think. How to get next LCN. That is exact question. I don't want to double the buffer size.
  Message 6 of 7  
10 Jul 18 17:19
Peter Viscarola
xxxxxx@osr.com
Join Date:
Posts To This List: 6243
List Moderator
FSCTL_GET_VOLUME_BITMAP subsequent calls

>How to get next LCN I'm sorry, but your question is not clear. If you mean "How do I CALCULATE the next LCN" the answer is: You take the number of bytes returned to you and multiple by 8. That's the NEXT LCN number. Just for testing purposes, you can validate that you're computing the next LCN correctly by retrieving the bitmap for a few clusters BEFORE that next LCN, and comparing the contents of the two buffers. That is, let's say you get clusters 1 through 16 in your first request (you'll get a lot more than this, but this is an example). You then get 17 through 32 in your SECOND request. You can validate that you're calculating things correctly by retrieving the bitmap for clusters 8 through 24 and comparing the bits at the end of the first buffer you had previous retrieved and at the beginning of the second buffer you previously retrieved. Hope that helps, Peter OSR @OSRDrivers
  Message 7 of 7  
10 Jul 18 17:52
adnan
xxxxxx@gmail.com
Join Date: 24 May 2013
Posts To This List: 28
FSCTL_GET_VOLUME_BITMAP subsequent calls

Thanks Peter. > You take the number of bytes returned to you and multiple by 8. That's the NEXT LCN number. This is what I wanted, and it worked
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 19:23.


Copyright ©2015, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license