From CGSecurity
Jump to navigation Jump to search


void iodisk_init(void);

int iodisk_register(iodisk_media_t *(*io_open)(const char *filename, unsigned int flags));

int iodisk_unregister(iodisk_media_t *(*io_open)(const char *filename, unsigned int flags));

int iodisk_finish();

Unregisters all fonctions

iodisk_media_t *iodisk_open(const char *filename, unsigned int flags);

  • flags:
    • IO_RDWR
    • IO_EXCL
    • IO_SPLIT: split read/write operations if there are errors

Note, it should allow arbitrary length read/write operation and deal with non-aligned memory.

iodisk_media_t *iodisk_mopen(const char *filenames[], unsigned int file_nbr, unsigned int flags);

Similar to iodisk_open but handle multiples files, ie. splitted dd images.

Functions provided by an iodisk_media_t *

int media->io_close(iodisk_media_t *media);

int64_t media->io_seek(iodisk_media_t *media, int64_t offset, int whence);

int64_t media->io_read(iodisk_media_t *media, void *buf, int64_t count);

int64_t media->io_write(iodisk_media_t *media, const void *buf, int64_t count);

int64_t media->io_pread(iodisk_media_t *media, void *buf, int64_t count, int64_t offset);

int64_t media->io_pwrite(iodisk_media_t *media, const void *buf, int64_t count, int64_t offset);

int64_t media->io_sync(iodisk_media_t *media);

int64_t media->io_get_media_size(const iodisk_media_t *media);

int media->io_get_media_geometry(const iodisk_media_t *media, iodisk_mediainfo_t *media);

typedef struct {

 uint32_t cylinders;
 uint32_t heads_per_cylinder;
 uint32_t sectors_per_head;
 uint32_t bytes_per_sector;
 uint32_t preferred_buffer_size;

} iodisk_mediainfo_t;