peass-ng/PEASS-ng · error · ArgumentException
Resources.Not_A_Valid_Guid
Error message
Resources.Not_A_Valid_Guid
What it means
EnumerateVolumePathNames throws ArgumentException (Resources.Not_A_Valid_Guid) when volumeGuid is non-empty but lacks the required "\\?\Volume{" prefix. Only a volume GUID path is accepted; drive letters and DOS paths are rejected.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.EnumerateVolumePathNames.cs:45
using winPEAS._3rdParty.AlphaFS;
namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
/// <summary>[AlphaFS] Returns an enumerable collection of <see cref="string"/> drive letters and mounted folder paths for the specified volume.</summary>
/// <returns>An enumerable collection of <see cref="string"/> containing the path names for the specified volume.</returns>
/// <exception cref="ArgumentNullException"/>
/// <exception cref="ArgumentException"/>
/// <param name="volumeGuid">A volume <see cref="Guid"/> path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\.</param>
[SecurityCritical]
public static IEnumerable<string> EnumerateVolumePathNames(string volumeGuid)
{
if (Utils.IsNullOrWhiteSpace(volumeGuid))
throw new ArgumentNullException("volumeGuid");
if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
var volName = Path.AddTrailingDirectorySeparator(volumeGuid, false);
uint requiredLength = 10;
var cBuffer = new char[requiredLength];
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
while (!NativeMethods.GetVolumePathNamesForVolumeName(volName, cBuffer, (uint)cBuffer.Length, out requiredLength))
{
var lastError = Marshal.GetLastWin32Error();
switch ((uint)lastError)
{
case Win32Errors.ERROR_MORE_DATA:
case Win32Errors.ERROR_INSUFFICIENT_BUFFER:View on GitHub (pinned to 53fb989abc)
Solutions
- Normalize input with Volume.GetVolumeGuid(path) before calling
- Validate the input starts with "\\?\Volume{" and ends with "}\" before calling
- Catch ArgumentException and log/skip the malformed volume entry
Example fix
// before Volume.EnumerateVolumePathNames(driveLetter); // after var guid = Volume.GetVolumeGuid(driveLetter); Volume.EnumerateVolumePathNames(guid);
Defensive patterns
Strategy: validation
Validate before calling
if (!volumeGuid.StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase))
volumeGuid = Volume.GetVolumeGuid(volumeGuid); Type guard
static bool IsVolumeGuidPath(string s) => !string.IsNullOrWhiteSpace(s) && s.StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase); Try / catch
try { Volume.EnumerateVolumePathNames(volumeGuid); }
catch (ArgumentException) { Log.Error($"Malformed volume GUID: {volumeGuid}"); } Prevention
- Normalize with Volume.GetVolumeGuid when input format is uncertain
- Keep the \\?\Volume{ prefix intact in stored volume identifiers
- Unit-test volume parsing against drive letters and malformed GUIDs
When it happens
Trigger: Passing "D:\" or "\\?\C:\" to Volume.EnumerateVolumePathNames; passing a GUID with wrong casing of the prefix or missing opening brace; GetVolumeDisplayName forwarding a malformed volume name.
Common situations: Persisted volume identifiers from another tool in a different format; string manipulation that stripped the \\?\Volume{ prefix; assuming drive letters are valid input.
Related errors
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/8a674c59cdc32e1a.
Report an issue: GitHub.