IOCTL_DISK_REASSIGN_BLOCKS - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// 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 reference

NtDoc

No description available.

Windows Driver Kit DDI reference (ni-ntdddisk-ioctl_disk_reassign_blocks)

IOCTL_DISK_REASSIGN_BLOCKS IOCTL

Description

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.

Parameters

Major code

Input buffer

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.

Input buffer length

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).

Output buffer

None.

Output buffer length

None.

Input/output buffer

Input/output buffer length

Status block

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.

See also

REASSIGN_BLOCKS


Win32 API reference (ni-winioctl-ioctl_disk_reassign_blocks)

IOCTL_DISK_REASSIGN_BLOCKS IOCTL

Description

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
);

Parameters

Input buffer

Input buffer length

Output buffer

Output buffer length

Input/output buffer

Input/output buffer length

Status block

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.

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.

See also