peass-ng/PEASS-ng · warning · ArgumentNullException

volumePathName

Error message

volumePathName

What it means

GetUniqueVolumeNameForPath(string volumePathName) throws ArgumentNullException with paramName "volumePathName" when the argument is null, empty, or whitespace. The method resolves a normal path to its unique \\?\Volume{GUID}\ form and validates input up front.

Source

Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetUniqueVolumeNameForPath.cs:46

   public static partial class Volume
   {
      /// <summary>[AlphaFS] Get the unique volume name for the given path.</summary>
      /// <exception cref="ArgumentNullException"/>
      /// <param name="volumePathName">
      ///   A path string. Both absolute and relative file and directory names, for example "..", is acceptable in this path. If you specify a
      ///   relative file or directory name without a volume qualifier, GetUniqueVolumeNameForPath returns the Drive letter of the current
      ///   volume.
      /// </param>
      /// <returns>
      ///   <para>Returns the unique volume name in the form: "\\?\Volume{GUID}\",</para>
      ///   <para>or <c>null</c> on error or if unavailable.</para>
      /// </returns>
      [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
      [SecurityCritical]
      public static string GetUniqueVolumeNameForPath(string volumePathName)
      {
         if (Utils.IsNullOrWhiteSpace(volumePathName))
            throw new ArgumentNullException("volumePathName");

         try
         {
            return GetVolumeGuid(GetVolumePathName(volumePathName));
         }
         catch
         {
            return null;
         }
      }
   }
}

View on GitHub (pinned to 53fb989abc)

Solutions

  1. Ensure a real filesystem path (e.g. "C:\Windows") is passed before calling
  2. Add a null/whitespace check at the call site and handle the empty case explicitly
  3. Catch ArgumentNullException when resolving paths from untrusted sources

Example fix

// before
var unique = Volume.GetUniqueVolumeNameForPath(path);
// after
var unique = string.IsNullOrWhiteSpace(path) ? null : Volume.GetUniqueVolumeNameForPath(path);
Defensive patterns

Strategy: validation

Validate before calling

var unique = string.IsNullOrWhiteSpace(volumePathName) ? null : Volume.GetUniqueVolumeNameForPath(volumePathName);

Type guard

static bool HasPathValue(string p) => !string.IsNullOrWhiteSpace(p);

Try / catch

try { unique = Volume.GetUniqueVolumeNameForPath(path); }
catch (ArgumentNullException) { Log.Warn("Cannot resolve unique volume name: path is null/empty"); }

Prevention

When it happens

Trigger: Calling Volume.GetUniqueVolumeNameForPath(null), "", or " " — e.g. when the source path came from a failed lookup or empty config value.

Common situations: Processing file paths from user input or environment where the value may be unset; chained lookups (GetVolumePathName → GetVolumeGuid) where an earlier failure yielded an empty string.

Related errors


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