ZealOS/src/Demo/Disk/DiskRaw.HC

42 lines
1,018 B
HolyC
Raw Normal View History

2020-02-15 20:01:48 +00:00
U0 RawAccess(I64 drv_let=0)
{
2020-02-15 22:53:02 +00:00
CDrive *dv=Letter2Drive(drv_let);
CBlkDev *bd=Letter2BlkDev(drv_let);
2020-02-15 20:01:48 +00:00
I64 blk,old_offset,old_size;
U8 *buf=MAlloc(BLK_SIZE);
2020-02-15 22:53:02 +00:00
DriveRep;
2020-02-15 20:01:48 +00:00
PressAKey;
ClassRep(dv);
PressAKey;
ClassRep(bd);
PressAKey;
//Temporarily change partition range to full device.
//Normally, you are limited to just your partition.
//This is obviously $BK,1$dangerous$BK,0$!
old_offset=dv->drv_offset;
old_size =dv->size;
dv->drv_offset=0;
dv->size=bd->max_blk+1;
try {
blk=GetI64("Blk to Read: ",old_offset,0,bd->max_blk);
BlkRead(dv,buf,blk,1);
D(buf,BLK_SIZE);
} catch
PutExcept;
dv->drv_offset=old_offset;
dv->size =old_size;
Free(buf);
}
RawAccess;
2020-02-15 22:53:02 +00:00
//See $LK,"BlkRead",A="MN:BlkRead"$(), $LK,"BlkWrite",A="MN:BlkWrite"$(), $LK,"DriveLock",A="MN:DriveLock"$(), $LK,"DriveUnlock",A="MN:DriveUnlock"$()
2020-02-15 20:01:48 +00:00
//$LK,"DBlk",A="MN:DBlk"$(), $LK,"DClus",A="MN:DClus"$(), $LK,"BlkDevLock",A="MN:BlkDevLock"$() and $LK,"BlkDevUnlock",A="MN:BlkDevUnlock"$().