May 29, 2012 at 7:42 PM

I'm having almost no luck getting this library to do anything for me at all.

Tip: Please add some quickstart help somewhere on how to get info on my local drives.  I'm still not sure how to bootstrap the whole process of investigating my disks.  There's nothing to explain what URI formats are accepted or examples of correct ones, etc.

But, my most pressing issue is that when I attempt to create a Raw Disk object I'm getting an UnauthorizedAccessException in the DiskImageFile ctor.

What I'm trying to do is create an image of a Flash drive on a WindowsCE system.  This is for a payment kiosk and certification auditing requires us to show that we haven't written any personal payment information to the flash partition.

How can I use this API to just simply create a utility to back up that Flash partition (FAT fs)?



May 30, 2012 at 5:09 AM

Hi Derek,

There's possibly a few things going on here, so it might help to clarify a few things:

  1. I haven't tested discutils on WinCE, so I'm not sure if it needs things not available in the .NET Compact Framework - you're in uncharted territory
  2. Not sure if it's what you're trying to do here, but the Raw disk type isn't for accessing local volumes at the block level, it is meant for on-disk files (.img, for example) that are a raw dump of a disk image.
  3. On conventional Windows, you need to be careful about I/O alignment, and use special flags to CreateFile to open a disk volume - which needs p/invoke.  By design, the main discutils.dll library doesn't include any p/invoke calls.

For what you're looking to achieve, it might be worth starting with the 'DiskClone' example exe that ships with DiscUtils.  On conventional Windows you can use it like this:

DiskClone -of VHD-dynamic myfile.vhd E:

This would create a dynamic VHD that contains the contents of the 'E:' volume.  It assumes NTFS (which won't apply), and also uses the Volume Snapshot Service to safely copy a live file system (which also won't apply in your case).  However, it might give you some pointers.

The classes in there that might be most useful for opening a volume in WinCE from .NET are Volume.cs, which uses CreateFile to open a raw volume and UnbufferedNativeStream which performs aligned I/O on a native file handle from .NET.



May 30, 2012 at 12:40 PM

Exactly the feedback I needed.  BTW, I was able to port the csproj to a SmartDevice library project and it compiled just fine.  Apparently you weren't using any API calls that were not present in the Compact Framework.  And, I was getting the same exception on x86 that I was getting on CE, so I assume it is working.

Thanks for the quick response.  I will check out DiskClone and give it a shot.