Comment 9 for bug 932321

Revision history for this message
Dennis Jackson (dennis-m-jackson) wrote : Re: [Bug 932321] Re: getNumberOfSectors() returns incorrect number

Greetings -

     Just tried v0.5 of Win32 Disk Imager. Executable errors out at startup
indicating that libgcc_s_dw2-1.dll is missing. I located and downloaded
that DLL and installed it in the same directory as Win32 Disk Imager.exe.
Errors out again, but missing DLL is now reported to be libstdc++-6.dll. I
notice that another user has already reported this error, report number is
187903. Thanks.

----- Original Message -----
From: "Tobin Davis" <email address hidden>
To: <email address hidden>
Sent: Wednesday, February 15, 2012 5:43 PM
Subject: [Bug 932321] Re: getNumberOfSectors() returns incorrect number

Ah, yes. Will tag that bug as fixed as well. Thanks for remembering
this one.

--
You received this bug notification because you are subscribed to a
duplicate bug report (912259).
https://bugs.launchpad.net/bugs/932321

Title:
  getNumberOfSectors() returns incorrect number

Status in Image Writer for Windows:
  New

Bug description:
  The function getNumberOfSectors is not returning the actual sector
  count. For example, on one of my 32 GB sd-cards with 64845824 sectors
  the function returns 64838340. This means that the whole disk is not
  read when doing an image read from the SD card.

  Below is a version of getNumberOfSectors that returns the correct
  number:

  unsigned long long getNumberOfSectors(HANDLE handle, unsigned long long
*sectorsize)
  {
  DWORD junk;
  DISK_GEOMETRY geometry;
  PARTITION_INFORMATION part;
  BOOL bResult;
  bResult = DeviceIoControl(handle, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0,
&part, sizeof(part), &junk, NULL) &
  DeviceIoControl(handle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry,
sizeof(geometry), &junk, NULL);
  if (!bResult)
  {
  char *errormessage=NULL;
  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, GetLastError(), 0, errormessage, 0, NULL);
  QMessageBox::critical(NULL, "Device Error", QString("An error occurred
when attempting to get the device's geometry.\nError %1:
%2").arg(GetLastError()).arg(errormessage));
  LocalFree(errormessage);
  return 0;
  }
  if (sectorsize != NULL)
  *sectorsize = (unsigned long long)geometry.BytesPerSector;
  return (unsigned long long)part.PartitionLength.QuadPart / (unsigned long
long)geometry.BytesPerSector;
  }

To manage notifications about this bug go to:
https://bugs.launchpad.net/win32-image-writer/+bug/932321/+subscriptions