Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: driver access Keywords: device manager, disk manager lowlevel disk reading Message-ID: <9473@goofy.Apple.COM> Date: 28 Jul 90 01:32:50 GMT References: <640@beguine.UUCP> Organization: Apple Computer Inc., Cupertino, CA Lines: 44 In article <640@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu writes: >I am trying to find a way to access the disk drives at the lowest level. >I need to read and write to them at the bit level. I have tried pbread but am >having trouble getting it to work. I am assuming that the driver for disks >is open (but i did try calling open driver ".Sony" this caused another error >saying the .sony was not recognized! Help anyone please! If you just want to get the contents of the 512 byte blocks on floppies, you just need to do a PBRead(). The driver is already open so you don't need to open it again. Try something like this Pascal snippet: VAR pb : ParamBlockRec; theBuffer : PACKED ARRAY[1..512] OF SignedByte; ... BEGIN ... pb.ioRefNum:=-5; {-5 is .Sony driver's refNum} pb.ioVRefNum:=xxx; {drive number for floppies are 1,2[,3]} pb.ioBuffer:=@theBuffer; {where to put the data} pb.ioReqCount:=512; {how much to read} pb.ioPosMode:=FSFromStart; {position is relative to first block} pb.ioPosOffset:=xxx; {byte offset from start of disk} { = 512 * disk block number} IF PBRead(@pb, FALSE)=NoErr THEN BEGIN {do whatever processing on the data} END; To read more data at a time, just allocate a bigger buffer and increase the value in the ioReqCount field. Theses should be a multiple of 512 bytes. If you need to get at the disks at a lower level than the device manager, that's not recommended since you'll break on the IIfx if not on some future hardware as well... steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________