-1

hiii

In my program I'm reading the clusters in the volume using the appropriate physical offsets to the disk.

for(  i=0; i<  total_number_ of_ clusters;i++)
{
  
// convert logical offset to physical offset 

 phys_offset= conversion(i);  // this value I get correctly


 if(!SetFilePointer(drive_handle, 
                             phys_offset,
                             NULL,
                             0))
{
 printf("\nSetFilePointer Failed: Error Number : %d\n",GetLastError());
 return o;
 }


 if(!ReadFile(drive_handle,
                    bBuffer1,
                    cluster_size,
                    &dwRetBytes1,
                    0))
{
printf("\nUnable to Read the Drive Error: %d\n",GetLastError());   
return o;
}
   

} // next cluster

The above code not giving no error messages, but how do we know the program reading correctly?.It returns the correct no of bytes read after one read operation .When I wrote theses data into destination , nothing wrote. What may be the problem??
Where is the mistake in the code ?

Any idea?
-----------
Thanking you
Krish

Votes + Comments
Cross posting.
3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by krishnampkkm
0
hmyhandle= CreateFile( _T("\\\\.\\PhysicalDrive0"),
                  GENERIC_READ|GENERIC_WRITE,
                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                  NULL,
                  OPEN_EXISTING,
                  FILE_ATTRIBUTE_NORMAL| 
                  FILE_FLAG_NO_BUFFERING,
                  NULL);
if (hmyhandle==INVALID_HANDLE_VALUE)
{
    printf("\nUnable to Open the source_drive Err_NO:%d\n",GetLastError()); 
    return 0;
}

Edited by Reverend Jim: Fixed formatting

0

May be a security issue? Your open function appears to be correct for read/write!

But I've opened as administrator....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.