anchor.diff:    handle 
     geometry
     bytes
  +  blocks
     size)
   
   
  
positive.code: 
  (defun clear-block (device block &optional (value 0))
    (declare (type device device)
  	   (type integer block)
  	   (type (unsigned-byte 8) value))
    (let ((length (geometry-bytes (device-geometry device)))
  	(offset (* block (device-bytes device))))
      (with-foreign-objects ((buffer :uint8 length)
  			   (nbytes :uint32)
  			   (overlapped '(:struct pounds::overlapped)))
        ;; initialize the buffer with the constant value 
        (do ((i 0 (1+ i)))
  	  ((= i length))
  	(setf (mem-aref buffer :uint8 i) value))
        ;; write to the file 
        (multiple-value-bind (offset-low offset-high) (pounds::split-offset offset)
  	(setf (foreign-slot-value overlapped '(:struct pounds::overlapped)
  				  'pounds::offset)
  	      offset-low
  	      (foreign-slot-value overlapped '(:struct pounds::overlapped)
  				  'pounds::offset-high)
  	      offset-high))
        (let ((res (pounds::%write-file (device-handle device)
  				      buffer
  				      length
  				      nbytes
  				      overlapped)))
  	(unless res 
  	  (pounds::get-last-error))))))
  
  (defun move-block (device new-block old-block)
    (declare (type device device)
  	   (type integer new-block old-block))
    (let ((length (geometry-bytes (device-geometry device))))
      (with-foreign-objects ((buffer :uint8 length)
  			   (nbytes :uint32)
  			   (overlapped '(:struct pounds::overlapped)))
        ;; start by reading the old block
        (let ((offset (* old-block length)))
  	(multiple-value-bind (offset-low offset-high) (pounds::split-offset offset)
  	  (setf (foreign-slot-value overlapped '(:struct pounds::overlapped)
  				    'pounds::offset)
  		offset-low
  		(foreign-slot-value overlapped '(:struct pounds::overlapped)
  				    'pounds::offset-high)
  		offset-high)
  	  (let ((res (pounds::%read-file (device-handle device)
  					 buffer 
  					 length 
  					 nbytes
  					 overlapped)))
  	    (unless res
  	      (pounds::get-last-error)))))
        ;; now write it back out to the new location
        (let ((offset (* new-block length)))
  	(multiple-value-bind (offset-low offset-high) (pounds::split-offset offset)
  	  (setf (foreign-slot-value overlapped '(:struct pounds::overlapped)
  				    'pounds::offset)
  		offset-low
  		(foreign-slot-value overlapped '(:struct pounds::overlapped)
  				    'pounds::offset-high)
  		offset-high)
  	  (let ((res (pounds::%write-file (device-handle device)
  					  buffer 
  					  length 
  					  nbytes
  					  overlapped)))
  	    (unless res
  	      (pounds::get-last-error))))))))
  
  
  	  
  
negative.code: ;; IOCTL_DISK_GET_DRIVE_GEOMETRY == #x70000
  (defun get-disk-geometry (handle)
    (with-foreign-objects ((geo '(:struct %disk-geometry))
                           (bytes :uint32))
      (let ((res (%device-io-control handle 
                                     #x70000
                                     (null-pointer)
                                     0
                                     geo
                                     (foreign-type-size '(:struct %disk-geometry))
                                     bytes
                                     (null-pointer))))
        (if res
            (let ((g (make-geometry)))
              (setf (geometry-cylinders g)
                    (foreign-slot-value geo '(:struct %disk-geometry) 'cylinders)
                    (geometry-media-type g) 
                    (foreign-slot-value geo '(:struct %disk-geometry) 'media-type)
                    (geometry-tracks g)
                    (foreign-slot-value geo '(:struct %disk-geometry) 'tracks-per-cylinder)
                    (geometry-sectors g)
                    (foreign-slot-value geo '(:struct %disk-geometry) 'sectors-per-track)
                    (geometry-bytes g)
                    (foreign-slot-value geo '(:struct %disk-geometry) 'bytes-per-sector)
                    (geometry-size g)
                    (* (geometry-cylinders g)
                       (geometry-tracks g)
                       (geometry-sectors g)
                       (geometry-bytes g)))
              g)
            (pounds::get-last-error)))))
  
  
  (defun open-device (n)
    (declare (type integer n))
    (let ((path (format nil "\\\\.\\PhysicalDrive~A" n)))
      (let ((handle (open-device-handle path :mode #x03)))
        (handler-bind ((error (lambda (e)
                                (declare (ignore e))
                                ;; decline to handle the error, ensure we close the handle to clean up properly 
                                (pounds::%close-handle handle))))
          (let ((geometry (get-disk-geometry handle)))
            (make-device :handle handle
                         :geometry geometry
                         :bytes (geometry-bytes geometry)
                         :blocks (* (geometry-cylinders geometry) 
                                    (geometry-sectors geometry) 
                                    (geometry-tracks geometry))
                         :size (geometry-size geometry)))))))
  
  (defun close-device (device)
    (declare (type device device))
    (pounds::%close-handle (device-handle device)))
  
  (defun write-block (device block sequence &key (start 0) end)
    (declare (type device device)
             (type integer block)
             (type (vector (unsigned-byte 8)) sequence))
    (let ((offset (* block (device-bytes device))))
      (pounds::write-file (device-handle device)
                  offset
                  sequence
                  :start start
                  :end end)))
  
  (defun read-block (device block sequence &key (start 0) end)
    (declare (type device device)
             (type integer block)
             (type (vector (unsigned-byte 8)) sequence))
    (let ((count (- (or end (length sequence)) start))
          (offset (* block (device-bytes device))))
      (pounds::read-file (device-handle device)
  		       sequence
  		       offset
  