peass-ng/PEASS-ng · warning · ArgumentNullException
volumeMountPoint
Error message
volumeMountPoint
What it means
GetVolumeGuid(string volumeMountPoint) throws ArgumentNullException with paramName "volumeMountPoint" when the argument is null, empty, or whitespace. The method converts a mount point or path into its \\?\Volume{GUID}\ unique name and rejects blank input before any native call.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.GetVolumeGuid.cs:46
namespace Alphaleonis.Win32.Filesystem
{
public static partial class Volume
{
/// <summary>[AlphaFS]
/// Retrieves a volume <see cref="Guid"/> path for the volume that is associated with the specified volume mount point (drive letter,
/// volume GUID path, or mounted folder).
/// </summary>
/// <exception cref="ArgumentNullException"/>
/// <param name="volumeMountPoint">
/// The path of a mounted folder (for example, "Y:\MountX\") or a drive letter (for example, "X:\").
/// </param>
/// <returns>The unique volume name of the form: "\\?\Volume{GUID}\".</returns>
[SuppressMessage("Microsoft.Interoperability", "CA1404:CallGetLastErrorImmediatelyAfterPInvoke", Justification = "Marshal.GetLastWin32Error() is manipulated.")]
[SecurityCritical]
public static string GetVolumeGuid(string volumeMountPoint)
{
if (Utils.IsNullOrWhiteSpace(volumeMountPoint))
throw new ArgumentNullException("volumeMountPoint");
// The string must end with a trailing backslash ('\').
volumeMountPoint = Path.GetFullPathCore(null, false, volumeMountPoint, GetFullPathOptions.AsLongPath | GetFullPathOptions.AddTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
var volumeGuid = new StringBuilder(100);
var uniqueName = new StringBuilder(100);
try
{
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
{
// GetVolumeNameForVolumeMountPoint()
// 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
return NativeMethods.GetVolumeNameForVolumeMountPoint(volumeMountPoint, volumeGuid, (uint)volumeGuid.Capacity)
// The string must end with a trailing backslash.
? NativeMethods.GetVolumeNameForVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeGuid.ToString(), false), uniqueName, (uint)uniqueName.Capacity)View on GitHub (pinned to 53fb989abc)
Solutions
- Pass a valid path or mount point (e.g. "C:\" or \\?\Volume{GUID}\)
- Guard the call with string.IsNullOrWhiteSpace and treat blank input as "no volume"
- Catch ArgumentNullException in enumeration loops over untrusted data
Example fix
// before bool mounted = Volume.IsVolume(mountPoint); // after bool mounted = !string.IsNullOrWhiteSpace(mountPoint) && Volume.IsVolume(mountPoint);
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(volumeMountPoint)) return null; // no volume to resolve
Type guard
static bool HasMountPointValue(string s) => !string.IsNullOrWhiteSpace(s);
Try / catch
try { guid = Volume.GetVolumeGuid(mountPoint); }
catch (ArgumentNullException ex) { Log.Warn($"Mount point missing: {ex.ParamName}"); } Prevention
- Null-check mount points parsed from external sources before calling
- Use IsVolume/GetVolumeGuid only on non-empty path strings
- Track where null mount points originate (failed lookups upstream) and fix there
When it happens
Trigger: Calling Volume.GetVolumeGuid(null) or ""; passing an uninitialized variable that should have held a mount point path; IsVolume forwarding an empty candidate string.
Common situations: Enumerating mount points where an entry failed to parse; reading mount points from a config/registry that returned empty; calling GetVolumeGuid on a path variable that was never assigned.
Related errors
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/1a22e5a84fe09a8d.
Report an issue: GitHub.