Handle paths starting with \\?\ to avoid 'illegal characters in path' exceptions (issue #82)

This commit is contained in:
itm4n
2026-04-29 16:37:36 +02:00
parent 4a4f776c0c
commit 3ff69f38ce
3 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
855849256
858404805
+4
View File
@@ -9,6 +9,10 @@
- Split misc checks into multiple files.
- Reorganize code of main file.
### Fixed
- Handle DOS paths starting with "\\?\" in COM image file permission check to avoid "illegal characters in path" exceptions (issue #82).
## 2026-04-25
### Modified
+18
View File
@@ -509,6 +509,24 @@ function Get-ModifiableComClassEntryImagePath {
if ([String]::IsNullOrEmpty($CandidatePath)) { continue }
# If a path starts with "\\?\", it may cause an "Illegal characters in path"
# exception when calling Get-Item. Normally, we would have to convert this
# type of path properly, but we don't expect paths other than "\\?\C:\...",
# so we can safely remove the prefix "\\?\" (and hope for the best ^^').
#
# Note that this behavior seems to only be triggered by a few EDRs. There is
# no issue with this type of path on a standard Windows installation. For
# instance, the following command works as intended on Windows 11 + Defender.
#
# PS C:> Get-Item -Path "\\?\C:\Windows"
#
# Directory: \\?\C:
#
# Mode LastWriteTime Length Name
# ---- ------------- ------ ----
# d----- 24/04/2026 19:15 Windows
if ($CandidatePath.StartsWith("\\?\")) { $CandidatePath = $CandidatePath.Replace("\\?\", "") }
$ModifiablePaths = Get-ModifiablePath -Path $CandidatePath | Where-Object { $_ -and (-not [String]::IsNullOrEmpty($_.ModifiablePath)) }
if ($null -eq $ModifiablePaths) { continue }