return Status;
}
- /* Size for volume namespace, litteral GUID, and null char */
+ /* Size for volume namespace, literal GUID, and null char */
VolumeName->MaximumLength = 0x14 + 0x4C + sizeof(UNICODE_NULL);
VolumeName->Buffer = AllocatePool(0x14 + 0x4C + sizeof(UNICODE_NULL));
if (!VolumeName->Buffer)
BOOLEAN
IsDriveLetter(PUNICODE_STRING SymbolicName)
{
- WCHAR Letter;
- BOOLEAN Result = FALSE;
+ WCHAR Letter, Colon;
/* We must have a precise length */
- if (SymbolicName->Length != sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR))
+ if (SymbolicName->Length != DosDevices.Length + 2 * sizeof(WCHAR))
{
return FALSE;
}
- /* Check if len is correct */
- Letter = SymbolicName->Buffer[sizeof(DosDevices.Buffer) / sizeof(WCHAR)];
- if (((Letter >= L'A' && Letter <= L'Z') || Letter == (WCHAR)-1) &&
- SymbolicName->Buffer[(sizeof(DosDevices.Buffer) + sizeof(WCHAR)) / sizeof (WCHAR)] == L':')
+ /* Must start with the DosDevices prefix */
+ if (!RtlPrefixUnicodeString(&DosDevices, SymbolicName, TRUE))
{
- /* In case it's not a normal drive letter, check differently */
- SymbolicName->Length = sizeof(DosDevices.Buffer);
- Result = RtlEqualUnicodeString(SymbolicName, &DosDevices, TRUE);
- SymbolicName->Length = sizeof(DosDevices.Buffer) + 2 * sizeof(WCHAR);
+ return FALSE;
+ }
+
+ /* Check if letter is correct */
+ Letter = SymbolicName->Buffer[DosDevices.Length / sizeof(WCHAR)];
+ if ((Letter < L'A' || Letter > L'Z') && Letter != (WCHAR)-1)
+ {
+ return FALSE;
+ }
+
+ /* And finally it must end with a colon */
+ Colon = SymbolicName->Buffer[DosDevices.Length / sizeof(WCHAR) + 1];
+ if (Colon != L':')
+ {
+ return FALSE;
}
- return Result;
+ return TRUE;
}
/*