Reading xD card (low level)

I’d like to write a program to run on a Windows PC (in C#, if possible) that will do “low-level” reads of an xD flash memory card. That is, I want to ignore any file system the card contains and simply read physical blocks of data.

The card can be attached to the PC via a USB port, or via PCMCIA - whatever makes the process of reading it easier.

Anyone have any idea how to do this?

I read other things via the USB port and Windows Explorer.
IIRC I read the card in a camera the same way. The photo loader did it first.

You’re really talking about writing a driver here, and that’s some pretty arcane voodoo. It’s very likely going to be a pretty intense learning process, and probably very frustrating at times. On the other hand, it’s a great thing to be able to put on your resume if you’re looking for software development work (particularly if your driver stands up to rigorous testing).

I’d be kinda surprised if you can find much about driver development in C#. MSDN has a prominent link to this section of its documentation, and that’s probably as good a place as any to start. Expect to spend some money on books.

You know, it would probably help if I were thinking at all clearly. You don’t need to write a device driver for this–you might not even need to talk to one directly. The Win32 API should be consistent between C++ and C#, so have a look at the section titled “Physical Disks and Volumes” in the CreateFile documentation and the links in the DeviceIoControl documentation

Thanks - that certainly looks as if it’s on the right track. Treating the card as if it’s a disk drive sounds like it should work.

The CreateFile document does indeed tell how to open a physical disk drive. The DeviceIoControl document seems to be leading down the right path. It even gives an example of how to get a drive’s “geometry” (cylinders, tracks, sectors, sector size).

Am I correct in thinking that the control code FSCTL_READ_FROM_PLEX is the way to actually read a block of data? It sounds as if it might be, though the structure of this is a bit arcane (in my naive view).

We’ve gone about as far as my knowledge of the subject does, so you’re going to have to do some research. But it’s entirely reasonable for this sort of thing to be arcane; the whole reason that the file system was developed was to protect us from having to deal with things like this. Just be glad that you’re not actually trying to write a driver–the HAL in the NT kernel is only slightly less horrifying than the one in that spaceship.