peass-ng/PEASS-ng · warning · ArgumentNullException

volumeGuid

Error message

volumeGuid

What it means

EnumerateVolumePathNames(string volumeGuid) throws ArgumentNullException with paramName "volumeGuid" when the argument is null, empty, or whitespace. Like all AlphaFS Volume APIs, it validates arguments before invoking native QueryDosDevice/FindFirstVolumeMountPoint machinery.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.EnumerateVolumePathNames.cs:42

using System.Runtime.InteropServices;
using System.Security;
using System.Text;
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)

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Obtain the GUID from Volume.EnumerateVolumes or Volume.GetVolumeGuid before calling
  2. Guard with string.IsNullOrWhiteSpace and skip null entries
  3. Catch ArgumentNullException when processing untrusted volume data

Example fix

// before
names = Volume.EnumerateVolumePathNames(volGuid).ToList();
// after
if (!string.IsNullOrWhiteSpace(volGuid))
    names = Volume.EnumerateVolumePathNames(volGuid).ToList();
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(volumeGuid)) return Enumerable.Empty<string>(); // or throw with context

Type guard

static bool IsValidVolumeGuidPath(string s) => !string.IsNullOrWhiteSpace(s) && s.StartsWith(@"\\?\Volume{", StringComparison.OrdinalIgnoreCase);

Try / catch

try { names = Volume.EnumerateVolumePathNames(volumeGuid).ToList(); }
catch (ArgumentNullException ex) { names = new List<string>(); Log.Warn($"Null volumeGuid: {ex.ParamName}"); }

Prevention

When it happens

Trigger: Calling Volume.EnumerateVolumePathNames(null) or with ""/whitespace instead of a \\?\Volume{GUID}\ path; GetVolumeDisplayName passing through a null volume name.

Common situations: Building volume-info lists where GUID lookup failed earlier and produced null; deserializing volume paths from JSON/config with missing values.

Related errors


AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02). Data as JSON: /api/errors/4367bf81c31b1cae. Report an issue: GitHub.