- if (!query_device(h, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
- drive_info, drive_info_size))
- {
- ERROR("\"%ls\": Can't get disk info (err=0x%08"PRIx32")",
- disk_name, (u32)GetLastError());
- CloseHandle(h);
- return WIMLIB_ERR_READ;
+ drive_info_size = sizeof(DRIVE_LAYOUT_INFORMATION_EX);
+ for (;;) {
+ drive_info_size += 4 * sizeof(PARTITION_INFORMATION_EX);
+ drive_info = MALLOC(drive_info_size);
+ if (!drive_info) {
+ ret = WIMLIB_ERR_NOMEM;
+ goto out;
+ }
+
+ if (query_device(h, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
+ drive_info, drive_info_size))
+ break;
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+ win32_error(GetLastError(),
+ L"\"%ls\": Can't get disk info", disk_name);
+ ret = WIMLIB_ERR_READ;
+ goto out;
+ }
+ FREE(drive_info);