peass-ng/PEASS-ng · warning · ArgumentNullException

volumeGuid

Error message

volumeGuid

What it means

EnumerateVolumeMountPoints(string volumeGuid) throws ArgumentNullException with paramName "volumeGuid" when the argument is null, empty, or whitespace. AlphaFS validates inputs defensively before making any native Win32 calls, because a null volume GUID path would otherwise cause a native API failure deep in the call stack.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.EnumerateVolumeMountPoints.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"/> of all mounted folders (volume mount points) on the specified volume. </summary>
      /// <exception cref="ArgumentNullException"/>
      /// <exception cref="ArgumentException"/>
      /// <param name="volumeGuid">A <see cref="string"/> containing the volume <see cref="Guid"/>.</param>
      /// <returns>An enumerable collection of <see cref="String"/> of all volume mount points on the specified volume.</returns>
      [SecurityCritical]
      public static IEnumerable<string> EnumerateVolumeMountPoints(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");


         // A trailing backslash is required.
         volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false);


         var buffer = new StringBuilder(NativeMethods.MaxPathUnicode);


         using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
         using (var handle = NativeMethods.FindFirstVolumeMountPoint(volumeGuid, buffer, (uint)buffer.Capacity))
         {
            var lastError = Marshal.GetLastWin32Error();

            if (!NativeMethods.IsValidHandle(handle, false))

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Pass a valid volume GUID path obtained from Volume.EnumerateVolumes (format \\?\Volume{GUID}\)
  2. Null/whitespace-check the argument before calling and skip or log invalid entries
  3. Wrap the call in try/catch for ArgumentNullException when enumerating untrusted volume data

Example fix

// before
foreach (var mnt in Volume.EnumerateVolumeMountPoints(vol)) { ... }
// after
if (!string.IsNullOrWhiteSpace(vol))
    foreach (var mnt in Volume.EnumerateVolumeMountPoints(vol)) { ... }
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(volumeGuid)) throw new ArgumentException("A volume GUID path is required.", nameof(volumeGuid));

Type guard

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

Try / catch

try { foreach (var mp in Volume.EnumerateVolumeMountPoints(volumeGuid)) Process(mp); }
catch (ArgumentNullException ex) { Log.Warn($"Skipped volume: {ex.ParamName} was null/empty"); }

Prevention

When it happens

Trigger: Calling Volume.EnumerateVolumeMountPoints(null), or passing an empty/whitespace-only string ("", " ") instead of a volume GUID path like "\\?\Volume{...}\".

Common situations: Enumerating volumes from a list where some entries are null placeholders; passing an uninitialized string variable; a config file or registry lookup returning an empty value.

Related errors


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