// ntdddisk.h
// CTL_CODE(0x0007, 0x007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_DISK_REASSIGN_BLOCKS 0x0007C01C
View the official Windows Driver Kit DDI reference// winioctl.h
// CTL_CODE(0x0007, 0x007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_DISK_REASSIGN_BLOCKS 0x0007C01C
View the official Win32 API referenceNo description available.
Maps defective blocks to new location on disk. This request instructs the device to reassign the bad block address to a good block from its spare-block pool.
The buffer at Irp->AssociatedIrp.SystemBuffer contains the REASSIGN_BLOCKS values to be set. Note that this structure contains a variable-sized array of block numbers. It is the caller's responsibility to make sure that the array of block numbers is sorted in ascending order.
Parameters.DeviceIoControl.InputBufferLength in the I/O stack location of the IRP indicates the size, in bytes, of the buffer, which must be >= sizeof(REASSIGN_BLOCKS).
None.
None.
The Information field is set to zero. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.
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
);
Irp->IoStatus.Status is set to STATUS_SUCCESS if the request is successful.
Otherwise, Status to the appropriate error condition as a NTSTATUS code.
For more information, see NTSTATUS Values.
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.