mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-29 22:15:21 -04:00
[iso] reload label after formatting
* The Windows APIs may further modify the label compared to our proposed version (e.g. remove trailing spaces), and we need an exact label for the Syslinux/GRUB config file update. * This issue was reported against Springdale Linux, where the isolinux.cfg label was patched using 'SPRINGDALE\x20' instead of 'SPRINGDALE' * Closes #784 * Also ensure that we don't replace NULL buffers in msapi_utf8.h and add GetVolumeInformationU()
This commit is contained in:
parent
60517f1e50
commit
ed1b3fd72e
4 changed files with 56 additions and 15 deletions
15
src/drive.c
15
src/drive.c
|
@ -486,10 +486,8 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
|||
{
|
||||
HANDLE hPhysical;
|
||||
DWORD size;
|
||||
char AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
|
||||
wchar_t wDrivePath[] = L"#:\\";
|
||||
wchar_t wVolumeLabel[MAX_PATH+1];
|
||||
static char VolumeLabel[MAX_PATH+1];
|
||||
static char VolumeLabel[MAX_PATH + 1];
|
||||
char DrivePath[] = "#:\\", AutorunPath[] = "#:\\autorun.inf", *AutorunLabel = NULL;
|
||||
|
||||
*label = STR_NO_LABEL;
|
||||
|
||||
|
@ -501,7 +499,7 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
|||
}
|
||||
// We only care about an autorun.inf if we have a single volume
|
||||
AutorunPath[0] = letters[0];
|
||||
wDrivePath[0] = letters[0];
|
||||
DrivePath[0] = letters[0];
|
||||
|
||||
// Try to read an extended label from autorun first. Fallback to regular label if not found.
|
||||
// In the case of card readers with no card, users can get an annoying popup asking them
|
||||
|
@ -518,10 +516,11 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
|
|||
safe_strcpy(VolumeLabel, sizeof(VolumeLabel), AutorunLabel);
|
||||
safe_free(AutorunLabel);
|
||||
*label = VolumeLabel;
|
||||
} else if (GetVolumeInformationW(wDrivePath, wVolumeLabel, ARRAYSIZE(wVolumeLabel),
|
||||
NULL, NULL, NULL, NULL, 0) && *wVolumeLabel) {
|
||||
wchar_to_utf8_no_alloc(wVolumeLabel, VolumeLabel, sizeof(VolumeLabel));
|
||||
} else if (GetVolumeInformationU(DrivePath, VolumeLabel, ARRAYSIZE(VolumeLabel),
|
||||
NULL, NULL, NULL, NULL, 0) && (VolumeLabel[0] != 0)) {
|
||||
*label = VolumeLabel;
|
||||
} else {
|
||||
duprintf("Failed to read label: %s", WindowsErrorString());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue