GetDeviceNumberFromVolumeHandle return 0 when it fail. However I have a case where my storageDeviceNumber.DeviceNumber is also 0.
This made other functions using GetDeviceNumberFromVolumeHandle to also fail:
For example EjectDriveLetter at line 353 check for the deviceNumber and so fail even if it's a good device number which is equal to 0
Maybe change function to:
BOOL GetDeviceNumberFromVolumeHandle(HANDLE volume, ULONG* devNumber) {
STORAGE_DEVICE_NUMBER storageDeviceNumber;
DWORD bytesReturned;
BOOL result = DeviceIoControl(volume,
IOCTL_STORAGE_GET_DEVICE_NUMBER,
NULL, 0,
&storageDeviceNumber,
sizeof(storageDeviceNumber),
&bytesReturned,
NULL);
if (!result) {
return false;
}
*devNumber = storageDeviceNumber.DeviceNumber;
return true;
}
FIX all function using this for example in EjectDriveLetter:
ULONG deviceNumber;
BOOL result = GetDeviceNumberFromVolumeHandle(volumeHandle, &deviceNumber);
if (!result) {
MountUtilsLog("Couldn't get device number from volume handle");
CloseHandle(volumeHandle);
return MOUNTUTILS_ERROR_GENERAL;
}
GetDeviceNumberFromVolumeHandlereturn 0 when it fail. However I have a case where mystorageDeviceNumber.DeviceNumberis also 0.This made other functions using
GetDeviceNumberFromVolumeHandleto also fail:For example
EjectDriveLetterat line353check for the deviceNumber and so fail even if it's a good device number which is equal to 0Maybe change function to:
FIX all function using this for example in
EjectDriveLetter: