peass-ng/PEASS-ng · error · ArgumentException
Resources.Not_A_Valid_Guid
Error message
Resources.Not_A_Valid_Guid
What it means
AlphaFS Volume.SetVolumeMountPoint validates that the volumeGuid argument looks like a volume GUID path before calling the Win32 SetVolumeMountPoint API. When the string does not start with the \\?\Volume{ prefix (the form \\?\Volume{GUID}\), it throws ArgumentException with the Resources.Not_A_Valid_Guid message naming volumeGuid. This fail-fast check avoids passing a malformed path to the native API.
Source
Thrown at winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs:51
/// <exception cref="ArgumentException"/>
/// <exception cref="ArgumentNullException"/>
/// <param name="volumeMountPoint">
/// The user-mode path to be associated with the volume. This may be a Drive letter (for example, "X:\")
/// or a directory on another volume (for example, "Y:\MountX\").
/// </param>
/// <param name="volumeGuid">A <see cref="string"/> containing the volume <see cref="Guid"/>.</param>
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")]
[SecurityCritical]
public static void SetVolumeMountPoint(string volumeMountPoint, string volumeGuid)
{
if (Utils.IsNullOrWhiteSpace(volumeMountPoint))
throw new ArgumentNullException("volumeMountPoint");
if (Utils.IsNullOrWhiteSpace(volumeGuid))
throw new ArgumentNullException("volumeGuid");
if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException(Resources.Not_A_Valid_Guid, "volumeGuid");
volumeMountPoint = Path.GetFullPathCore(null, false, volumeMountPoint, GetFullPathOptions.AsLongPath | GetFullPathOptions.AddTrailingDirectorySeparator | GetFullPathOptions.FullCheck);
// This string must be of the form "\\?\Volume{GUID}\"
volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false);
// ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups.
using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))
{
// SetVolumeMountPoint()
// 2014-01-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists.
// The string must end with a trailing backslash.
var success = NativeMethods.SetVolumeMountPoint(volumeMountPoint, volumeGuid);
View on GitHub (pinned to 53fb989abc)
Solutions
- Obtain the GUID string via Volume.GetVolumeNameForVolumeMountPoint / Volume.EnumerateVolumes (FindFirstVolume), which returns the full \\?\Volume{GUID}\ form, and pass that value.
- If you only have the raw GUID, prepend the prefix and append a trailing separator yourself, e.g. "\\?\Volume{" + guid.Trim('{','}') + "}\".
- Verify argument order: the first parameter is volumeMountPoint (the NTFS folder to mount at), the second is volumeGuid; swapping them causes this error.
- Pass a non-empty, non-whitespace string; null/empty raises ArgumentNullException before this check.
Example fix
// before
string guid = "{4a1f2b3c-...}"; // from registry
Volume.SetVolumeMountPoint("C:\\Mount", guid);
// after
string guid = Volume.GetVolumeNameForVolumeMountPoint("C:\"); // "\\?\Volume{4a1f2b3c-...}\"
Volume.SetVolumeMountPoint("C:\\Mount", guid); Defensive patterns
Strategy: validation
Validate before calling
static bool IsVolumeGuidPath(string s) =>
!string.IsNullOrWhiteSpace(s) &&
s.StartsWith("\\\\?\\Volume{", StringComparison.OrdinalIgnoreCase) &&
s.EndsWith("}\\"); Type guard
bool IsValidVolumeGuid(string s) =>
s != null && s.Contains("Volume{") && Guid.TryParse(s.Trim('\\', '{', '}'), out _); Try / catch
try { Volume.SetVolumeMountPoint(mountPoint, volumeGuid); }
catch (ArgumentException ex) when (ex.ParamName == "volumeGuid")
{
// malformed GUID; regenerate via Volume.GetVolumeNameForVolumeMountPoint
} Prevention
- Always source volume GUIDs from FindFirstVolume/GetVolumeNameForVolumeMountPoint, never raw registry values
- Keep the full \\?\Volume{GUID}\ string including prefix and trailing backslash
- Double-check parameter order: mountPoint first, volumeGuid second
- Unit-test GUID formatting helpers against FindFirstVolume output
When it happens
Trigger: Calling Volume.SetVolumeMountPoint with a volumeGuid that is a bare GUID string like '{GUID}' or 'X\', a drive letter, a path without the \\?\Volume{ prefix, or a null/empty string that somehow passed the earlier null check.
Common situations: Developers store volume GUIDs from registry or WMI output (which often lack the \\?\Volume{...}\ wrapper) and pass them directly; mixing up a mount point path and the volume GUID argument; older AlphaFS versions or code copied from snippets using QueryDosDevice output instead of FindFirstVolume/GetVolumeNameForVolumeMountPoint results.
Related errors
- Resources.InvalidDriveLetterArgument
- rootPathName
- volumeName
- volumeName
- Value cannot be null. Parameter name: path
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/73a32ba29db684f0.
Report an issue: GitHub.