Question on the userspace side, help please.
I would like to access the $bitmap file. Am using the
following code per MSDN:
HANDLE hDevice = CreateFile(“\\.\PhysicalDrive0”,
… // per msdn example
STARTING_LCN_INPUT_BUFFER Lcn_Buffer;
VOLUME_BITMAP_BUFFER Bitmap;
BOOL besult = false;
Lcn_Buffer.StartingLcn.LowPart = 0;
Lcn_Buffer.StartingLcn.HighPart = 0;
bResult = DeviceIoControl( hDevice,
FSCNTL_GET_VOLUME_BITMAP,
Lcn_Buffer,
sizeof( STARTING_LCN_INPUT_BUFFER ),
&Bitmap,
&Bytes_Returned;
(LPOVERLAPPED) NULL
);
…
The error I get return is #1 “incorrect function”
This should be easy, any suggestions?
Thanx
Dave Sharp
Post your free ad now! http://personals.yahoo.ca
Hi
Here is a fragment of code I use to fragment a file (for testing defrag
:o) )
HANDLE VolumeHandle = CreateFile(“\\.\C:”, GENERIC_READ, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE != VolumeHandle)
{
/* Browse for a file */
const DWORD ReturnSize = MAX_PATH;
TCHAR szFileName[ReturnSize] = {0};
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = “All Files\0*.*\0\0\0”;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrInitialDir = “C:\”;
ofn.lpstrTitle = “Select File to Fragment”;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_LONGNAMES |
OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
if (GetOpenFileName(&ofn))
{
STARTING_LCN_INPUT_BUFFER StartLCN = {0};
StartLCN.StartingLcn.QuadPart = 1000;
DWORD ClusterMapSize = 5000000;
VOLUME_BITMAP_BUFFER *ClusterMap = (VOLUME_BITMAP_BUFFER *)new
BYTE[ClusterMapSize];
ClusterMap->StartingLcn = StartLCN.StartingLcn;
/* find some blank clusters */
DWORD ReturnCount = 0;
BOOL Okay = DeviceIoControl(VolumeHandle, FSCTL_GET_VOLUME_BITMAP,
&StartLCN, sizeof(StartLCN), ClusterMap, ClusterMapSize, &ReturnCount,
NULL);
if (Okay)
{
/* Open the file to fragment */
HANDLE FragHandle = CreateFile(szFileName, GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE != FragHandle)
{
STARTING_VCN_INPUT_BUFFER StartVCN = {0};
StartVCN.StartingVcn.QuadPart = 0;
const DWORD RetrieveSize = 1024 * 1024;
“Dave B. Sharp” wrote in message news:xxxxx@ntfsd…
>
>
> Question on the userspace side, help please.
>
> I would like to access the $bitmap file. Am using the
> following code per MSDN:
>
> --------------------------------------------------------------------------
------
> HANDLE hDevice = CreateFile(“\\.\PhysicalDrive0”,
> … // per msdn example
>
>
> STARTING_LCN_INPUT_BUFFER Lcn_Buffer;
> VOLUME_BITMAP_BUFFER Bitmap;
> BOOL besult = false;
>
> Lcn_Buffer.StartingLcn.LowPart = 0;
> Lcn_Buffer.StartingLcn.HighPart = 0;
>
> bResult = DeviceIoControl( hDevice,
> FSCNTL_GET_VOLUME_BITMAP,
> Lcn_Buffer,
> sizeof( STARTING_LCN_INPUT_BUFFER ),
> &Bitmap,
> &Bytes_Returned;
> (LPOVERLAPPED) NULL
> );
> …
> --------------------------------------------------------------------------
------
> The error I get return is #1 “incorrect function”
> This should be easy, any suggestions?
>
> Thanx
>
> Dave Sharp
>
> ______________________________________________________________________
> Post your free ad now! http://personals.yahoo.ca
>
The bitmap is not available via the physical driver. You must open the
volume “c:”, etc…
Jamey
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Dave B. Sharp
Sent: Monday, January 17, 2005 10:34 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Reading Bitmap files
Question on the userspace side, help please.
I would like to access the $bitmap file. Am using the
following code per MSDN:
HANDLE hDevice = CreateFile(“\\.\PhysicalDrive0”,
… // per msdn example
STARTING_LCN_INPUT_BUFFER Lcn_Buffer;
VOLUME_BITMAP_BUFFER Bitmap;
BOOL besult = false;
Lcn_Buffer.StartingLcn.LowPart = 0;
Lcn_Buffer.StartingLcn.HighPart = 0;
bResult = DeviceIoControl( hDevice,
FSCNTL_GET_VOLUME_BITMAP,
Lcn_Buffer,
sizeof( STARTING_LCN_INPUT_BUFFER ),
&Bitmap,
&Bytes_Returned;
(LPOVERLAPPED) NULL
);
…
The error I get return is #1 “incorrect function”
This should be easy, any suggestions?
Thanx
Dave Sharp
Post your free ad now! http://personals.yahoo.ca
Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
You are currently subscribed to ntfsd as: xxxxx@tfb.com
To unsubscribe send a blank email to xxxxx@lists.osr.com
__________ NOD32 1.973 (20050116) Information __________
This message was checked by NOD32 antivirus system.
http://www.nod32.com