IOCTL_DISK_SET_DRIVE_LAYOUT - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntdddisk.h

// CTL_CODE(0x0007, 0x004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_DISK_SET_DRIVE_LAYOUT 0x0007C010

View the official Windows Driver Kit DDI reference
// winioctl.h

// CTL_CODE(0x0007, 0x004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
#define IOCTL_DISK_SET_DRIVE_LAYOUT 0x0007C010

View the official Win32 API reference

NtDoc

No description available.

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

IOCTL_DISK_SET_DRIVE_LAYOUT IOCTL

Description

Repartitions a disk as specified. (Floppy drivers need not handle this request.)

Parameters

Major code

Input buffer

The buffer at Irp->AssociatedIrp.SystemBuffer contains the DRIVE_LAYOUT_INFORMATION values to be set.

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

Output buffer

Returns updated DRIVE_LAYOUT_INFORMATION, possibly with modified partition numbers, to the buffer at Irp->AssociatedIrp.SystemBuffer.

Output buffer length

Length of a DRIVE_LAYOUT_INFORMATION.

Input/output buffer

Input/output buffer length

Status block

The Information field is set to the size, in bytes, of the returned information. The Status field can be set to STATUS_SUCCESS, or possibly to STATUS_INVALID_PARAMETER, STATUS_INFO_LENGTH_MISMATCH, STATUS_INSUFFICIENT_RESOURCES, or STATUS_BUFFER_TOO_SMALL.

See also

DRIVE_LAYOUT_INFORMATION


Win32 API reference (ni-winioctl-ioctl_disk_set_drive_layout)

IOCTL_DISK_SET_DRIVE_LAYOUT IOCTL

Description

Partitions a disk as specified by drive layout and partition information data.

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

[!NOTE] IOCTL_DISK_SET_DRIVE_LAYOUT has been superseded by IOCTL_DISK_SET_DRIVE_LAYOUT_EX, which retrieves layout information for AT and EFI (Extensible Firmware Interface) partitions.

To perform this operation, call the DeviceIoControl function with the following parameters. You must have write access to the drive in order to use this control code.

BOOL DeviceIoControl(
  (HANDLE) hDevice,             // handle to device
  IOCTL_DISK_SET_DRIVE_LAYOUT,  // 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

hDevice [in]

A handle to the disk.

To retrieve a device handle, call the CreateFile function.

dwIoControlCode [in]

The control code for the operation.

Use IOCTL_DISK_SET_DRIVE_LAYOUT for this operation.

lpInBuffer [in, optional]

A pointer to the input buffer that contains the DRIVE_LAYOUT_INFORMATION data to be set.

nInBufferSize [in]

The size of the input buffer, in bytes. It must be >= sizeof(DRIVE_LAYOUT_INFORMATION).

lpOutBuffer [out, optional]

Not used with this operation. Set to NULL.

nOutBufferSize [in]

The size of the input buffer, in bytes. Set to 0 (zero).

lpBytesReturned [out, optional]

A pointer to a variable that receives the size of the data stored in the output buffer, in bytes.

lpOverlapped [in, out, optional]

A pointer to an OVERLAPPED structure.

Return value

If the operation completes successfully, the return value is nonzero.

If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError.

Remarks

If the partition is on a disk formatted as type master boot record (MBR), partition size totals cannot exceed 2 TB per MBR disk. For example, a disk of type MBR can have a single 2-TB partition, two 1-TB partitions, or any combination that does not total more than 2 TB. If more space is required, a disk formatted as type GUID partition table (GPT) should be used. If third-party partitioning tools are used to work around this limitation on disks of type MBR larger than 2 TB, configuration operations via the disk partitioning IOCTL control codes will be limited.

See also