Skip to content

Commit 3ff69f3

Browse files
committed
Handle paths starting with \\?\ to avoid 'illegal characters in path' exceptions (issue #82)
1 parent 4a4f776 commit 3ff69f3

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

build/Seed.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
855849256
1+
858404805

info/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
- Split misc checks into multiple files.
1010
- Reorganize code of main file.
1111

12+
### Fixed
13+
14+
- Handle DOS paths starting with "\\?\" in COM image file permission check to avoid "illegal characters in path" exceptions (issue #82).
15+
1216
## 2026-04-25
1317

1418
### Modified

src/helper/AccessControl.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,24 @@ function Get-ModifiableComClassEntryImagePath {
509509

510510
if ([String]::IsNullOrEmpty($CandidatePath)) { continue }
511511

512+
# If a path starts with "\\?\", it may cause an "Illegal characters in path"
513+
# exception when calling Get-Item. Normally, we would have to convert this
514+
# type of path properly, but we don't expect paths other than "\\?\C:\...",
515+
# so we can safely remove the prefix "\\?\" (and hope for the best ^^').
516+
#
517+
# Note that this behavior seems to only be triggered by a few EDRs. There is
518+
# no issue with this type of path on a standard Windows installation. For
519+
# instance, the following command works as intended on Windows 11 + Defender.
520+
#
521+
# PS C:> Get-Item -Path "\\?\C:\Windows"
522+
#
523+
# Directory: \\?\C:
524+
#
525+
# Mode LastWriteTime Length Name
526+
# ---- ------------- ------ ----
527+
# d----- 24/04/2026 19:15 Windows
528+
if ($CandidatePath.StartsWith("\\?\")) { $CandidatePath = $CandidatePath.Replace("\\?\", "") }
529+
512530
$ModifiablePaths = Get-ModifiablePath -Path $CandidatePath | Where-Object { $_ -and (-not [String]::IsNullOrEmpty($_.ModifiablePath)) }
513531
if ($null -eq $ModifiablePaths) { continue }
514532

0 commit comments

Comments
 (0)