Raw I/O

A program to do raw read/write on Windows.

I used to use a Windows variant of dd, from here but that stopped working for me on Windows 10.

Win32DiskImager doesn't allow me to specify offsets on the device and also isn't a command line program.

This code can help find suitable devices, and then read or write them. Because it needs direct access to devices, it only works if you are running as Administrator.

Windows insists you access raw devices using sector aligned and integer sector length transfers. This can mean the rawio program has to read enclosing sectors and discard data, or do a read-modify-write.

eg: 512 byte sectors, read 1024 bytes, from offset 256

  1. read sector 0, discard first 256 bytes, return 256 bytes
  2. read sector 1, return all 512 bytes
  3. read sector 2, return 256 bytes, discard last 256 bytes

eg: 512 byte sectors, write 1024 bytes, to offset 256

  1. read sector 0, update last 256 bytes, write sector back
  2. write sector 1 with 512 bytes (no need to read, we're fully overwriting it)
  3. read sector 2, update first 256 bytes, write sector back

An alternative to this program is the BERAWIO memory extension for the BE editor. Thats a better option if you want to view or edit bytes on the device in-situ.


The full usage is :-

usage: rawio [flags]
flags: -f file    filename
       -d device  device filename
       -o offset  offset into device (default 0)
       -l length  length to read or write (default 8MB)
       -R         read from device to file
       -W         write to device from file
       -L         list available devices

The general pattern is to set up the parameters with lower-case arguments, and then trigger the action using an upper-case argument.

To list available block devices :-

c:\rawio>rawio -L
\\.\PhysicalDrive0                       fixed       60801 255 63  512 465.76GB
\\.\PhysicalDrive3                       removable      15 255 63  512 117.66MB
\\.\C:                                   fixed       60801 255 63  512 465.76GB
\\.\D:                                   fixed       60801 255 63  512 465.76GB
\\.\G:                                   removable      15 255 63  512 117.66MB

Each line is devicename, type, cylinders, heads, sectors, block size and total device size.

If you see no devices listed (or only drive letters), its likely because you're not running as Administrator. If you are running as Administrator you'd at least expect to see your hard disk(s) listed as "PhysicalDrive" "fixed" devices.

Note that devices can appear more than once, if Windows has mapped drive letters to them.

Devices that have already been opened by other programs also aren't listed.

Also, beware, with this program you can overwrite your hard disk, so you probably only want to target removable media. One way to be confident you know the correct device name is to do the above command before and after you've inserted your SD Card, Compact Flash card, USB stick or whatever other media you want to read or write.

In the above device listing, my 128MB SD Card is listed as \\.\PhysicalDrive3.

To read an 8MB chunk from offset 16MB in the device to file :-

c:\rawio>rawio -d \\.\PhysicalDrive3 -o 16MB -l 8MB -f myfile.bin -R

To write an 8MB from a file to offset 24MB on a a device :-

c:\rawio>rawio -f myfile.bin -d \\.\PhysicalDrive3 -o 24MB -l 8MB -W

Offsets and lengths are specified in bytes, unless you use a suffix such as KB, MB, ...etc.


rawio can be downloaded from http://www.nyangau.org/rawio/rawio.zip.

This page maintained by Andy Key