{"record":{"id":"73a32ba29db684f0","repo":"peass-ng/PEASS-ng","slug":"resources-not-a-valid-guid-73a32b","errorCode":null,"errorMessage":"Resources.Not_A_Valid_Guid","messagePattern":"Resources\\.Not_A_Valid_Guid","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs","lineNumber":51,"sourceCode":"      /// <exception cref=\"ArgumentException\"/>\n      /// <exception cref=\"ArgumentNullException\"/>\n      /// <param name=\"volumeMountPoint\">\n      ///   The user-mode path to be associated with the volume. This may be a Drive letter (for example, \"X:\\\")\n      ///   or a directory on another volume (for example, \"Y:\\MountX\\\").\n      /// </param>\n      /// <param name=\"volumeGuid\">A <see cref=\"string\"/> containing the volume <see cref=\"Guid\"/>.</param>      \n      [SuppressMessage(\"Microsoft.Design\", \"CA1062:Validate arguments of public methods\", MessageId = \"1\", Justification = \"Utils.IsNullOrWhiteSpace validates arguments.\")]\n      [SecurityCritical]\n      public static void SetVolumeMountPoint(string volumeMountPoint, string volumeGuid)\n      {\n         if (Utils.IsNullOrWhiteSpace(volumeMountPoint))\n            throw new ArgumentNullException(\"volumeMountPoint\");\n\n         if (Utils.IsNullOrWhiteSpace(volumeGuid))\n            throw new ArgumentNullException(\"volumeGuid\");\n\n         if (!volumeGuid.StartsWith(Path.VolumePrefix + \"{\", StringComparison.OrdinalIgnoreCase))\n            throw new ArgumentException(Resources.Not_A_Valid_Guid, \"volumeGuid\");\n\n\n         volumeMountPoint = Path.GetFullPathCore(null, false, volumeMountPoint, GetFullPathOptions.AsLongPath | GetFullPathOptions.AddTrailingDirectorySeparator | GetFullPathOptions.FullCheck);\n\n\n         // This string must be of the form \"\\\\?\\Volume{GUID}\\\"\n         volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false);\n\n\n         // ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups.\n         using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors))\n         {\n            // SetVolumeMountPoint()\n            // 2014-01-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists.\n\n            // The string must end with a trailing backslash.\n            var success = NativeMethods.SetVolumeMountPoint(volumeMountPoint, volumeGuid);\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/winPEAS/winPEASexe/winPEAS/3rdParty/AlphaFS/Device/Volume/Volume.SetVolumeMountPoint.cs#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nstring guid = \"{4a1f2b3c-...}\"; // from registry\nVolume.SetVolumeMountPoint(\"C:\\\\Mount\", guid);\n// after\nstring guid = Volume.GetVolumeNameForVolumeMountPoint(\"C:\\\"); // \"\\\\?\\Volume{4a1f2b3c-...}\\\"\nVolume.SetVolumeMountPoint(\"C:\\\\Mount\", guid);","handlingStrategy":"validation","validationCode":"static bool IsVolumeGuidPath(string s) =>\n    !string.IsNullOrWhiteSpace(s) &&\n    s.StartsWith(\"\\\\\\\\?\\\\Volume{\", StringComparison.OrdinalIgnoreCase) &&\n    s.EndsWith(\"}\\\\\");","typeGuard":"bool IsValidVolumeGuid(string s) =>\n    s != null && s.Contains(\"Volume{\") && Guid.TryParse(s.Trim('\\\\', '{', '}'), out _);","tryCatchPattern":"try { Volume.SetVolumeMountPoint(mountPoint, volumeGuid); }\ncatch (ArgumentException ex) when (ex.ParamName == \"volumeGuid\")\n{\n    // malformed GUID; regenerate via Volume.GetVolumeNameForVolumeMountPoint\n}","preventionTips":["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"],"tags":["csharp","alphafs","argument-validation","filesystem"],"backgroundTag":"invalid-volume-guid-format","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}