& {
$ErrorActionPreference = 'Stop'
try {
$file = Join-Path $env:ProgramData 'NVIDIA Corporation\Drs\nvAppTimestamps'
[byte[]]$data = [IO.File]::ReadAllBytes($file)
Write-Host "`nФайл: $file"
Write-Host "Размер: $($data.Length) байт"
$end = $data.Length - 1
if ($data.Length -lt 2 -or $data[$end] -ne 1) {
throw 'Формат отличается от примера из темы.'
}
$encoding = [Text.UnicodeEncoding]::new($false, $false, $true)
$rows = [Collections.Generic.List[object]]::new()
$pos = 1
while ($pos -lt $end) {
if ($pos + 5 -gt $end) {
throw "Неполная запись на смещении $pos."
}
$size = [int]$data[$pos + 3] +
([int]$data[$pos + 4] -shl 8)
$start = $pos + 5
$next = $start + $size + 7
if ($size -lt 2 -or ($size % 2) -ne 0 -or $next -gt $end) {
throw "Неожиданный формат записи на смещении $pos."
}
if ($data[$start + $size - 2] -ne 0 -or
$data[$start + $size - 1] -ne 0) {
throw "Не найден конец строки на смещении $pos."
}
$path = $encoding.GetString($data, $start, $size - 2)
$rows.Add([pscustomobject]@{
Path = $path.Replace("`0", '<NUL>')
D_Position = $path.IndexOf(
'D:\', [StringComparison]::OrdinalIgnoreCase
)
})
$pos = $next
}
$direct = @($rows | Where-Object { $_.D_Position -eq 0 })
$matches = @($rows | Where-Object { $_.D_Position -ge 0 })
Write-Host "`nВсего прочитано записей: $($rows.Count)"
Write-Host "Начинаются с D:\: $($direct.Count)"
Write-Host "Содержат D:\ в любой позиции: $($matches.Count)"
if ($matches.Count -gt 0) {
Write-Host "`nНайденные пути — первые 20:"
$matches | Select-Object -First 20 | Format-List Path, D_Position
}
else {
Write-Host "`nДля проверки — первые 12 прочитанных путей:"
$rows | Select-Object -First 12 | Format-List Path, D_Position
}
}
catch {
Write-Warning $_.Exception.Message
}
}