IOCTL_DISK_REASSIGN_BLOCKS IOCTL (winioctl.h)

Directs the disk device to map one or more blocks to its spare-block pool.

To perform this operation, call the DeviceIoControl function with the following parameters.

BOOL DeviceIoControl(
  (HANDLE) hDevice,             // handle to device
  IOCTL_DISK_REASSIGN_BLOCKS,   // dwIoControlCode
  (LPVOID) lpInBuffer,          // input buffer 
  (DWORD) nInBufferSize,        // size of input buffer 
  NULL,                         // lpOutBuffer
  0,                            // nOutBufferSize
  (LPDWORD) lpBytesReturned,    // number of bytes returned
  (LPOVERLAPPED) lpOverlapped   // OVERLAPPED structure
);

Remarks

The REASSIGN_BLOCKS structure that the IOCTL_DISK_REASSIGN_BLOCKS control code uses only supports drives where the Logical Block Address (LBA) fits into a 4-byte value (typically up to 2 TB). For larger drives the REASSIGN_BLOCKS_EX structure that the IOCTL_DISK_REASSIGN_BLOCKS_EX control code uses supports 8-byte LBAs. For compatibility, the IOCTL_DISK_REASSIGN_BLOCKS control code and REASSIGN_BLOCKS structure should be used where possible.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Header winioctl.h (include Windows.h)

See also