FSCTL_GET_VOLUME_BITMAP Error More data available.

Hiii
Here I’ve to get the cluster usage details of a particular volume.I used FSCTL_GET_VOLUME_BITMAP along with DeviceIoControl.But always it shows erors

Error no ;21 after some modifications Error no:1784 ; again Error no:234…

21: device is not ready
234:Error more data availble (I think my output buffer is not much enough ;so I ncreased buffer size)

then
1784:The supplied user buffer is not valid for the requested operation

Here is my sample code…

HANDLE driveHandle;
STARTING_LCN_INPUT_BUFFER slib;
VOLUME_BITMAP_BUFFER vbb;
DWORD bytesReturned;
BOOL success;
slib.StartingLcn.QuadPart = 0;
driveHandle = CreateFile(
_T(“\\.\G:”),
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);

if (driveHandle == INVALID_HANDLE_VALUE)
{
printf(“Failed to open handle”);
return 0;
}
success = DeviceIoControl(
driveHandle,
FSCTL_GET_VOLUME_BITMAP,
&slib,
sizeof(STARTING_LCN_INPUT_BUFFER),
&vbb,
sizeof(VOLUME_BITMAP_BUFFER),
&bytesReturned,
NULL);
if (!success)
{
printf(“Error getting cluster information, %d\n”, GetLastError());
return 0;

}
printf(“%d clusters on the disk\n”, bytesReturned * 8);
CloseHandle(driveHandle);

Below link will help you.

http://1-800-magic.blogspot.com/2008/02/taking-disk-image-snapshots.html
http://www.kessels.com/defrag/Defrag.c


From:
Sent: Thursday, June 04, 2009 10:19 AM
To: “Windows System Software Devs Interest List”
Subject: [ntdev] FSCTL_GET_VOLUME_BITMAP Error More data available.

>
> Hiii
> Here I’ve to get the cluster usage details of a particular volume.I
> used FSCTL_GET_VOLUME_BITMAP along with DeviceIoControl.But always it
> shows erors
>
> Error no ;21 after some modifications Error no:1784 ; again Error
> no:234…
>
> 21: device is not ready
> 234:Error more data availble (I think my output buffer is not much enough
> ;so I ncreased buffer size)
>
> then
> 1784:The supplied user buffer is not valid for the requested operation
>
> Here is my sample code…
>
> HANDLE driveHandle;
> STARTING_LCN_INPUT_BUFFER slib;
> VOLUME_BITMAP_BUFFER vbb;
> DWORD bytesReturned;
> BOOL success;
> slib.StartingLcn.QuadPart = 0;
> driveHandle = CreateFile(
> _T(“\\.\G:”),
> GENERIC_READ|GENERIC_WRITE,
> FILE_SHARE_READ | FILE_SHARE_WRITE,
> NULL, OPEN_EXISTING,
> FILE_ATTRIBUTE_NORMAL,
> NULL);
>
> if (driveHandle == INVALID_HANDLE_VALUE)
> {
> printf(“Failed to open handle”);
> return 0;
> }
> success = DeviceIoControl(
> driveHandle,
> FSCTL_GET_VOLUME_BITMAP,
> &slib,
> sizeof(STARTING_LCN_INPUT_BUFFER),
> &vbb,
> sizeof(VOLUME_BITMAP_BUFFER),
> &bytesReturned,
> NULL);
> if (!success)
> {
> printf(“Error getting cluster information, %d\n”, GetLastError());
> return 0;
>
> }
> printf(“%d clusters on the disk\n”, bytesReturned * 8);
> CloseHandle(driveHandle);
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>