Exploit databaseDownload repository ZIP
GH-945bd5267b0d1b94c3f74faf5cda7e5a
blkph0x/cve-2026-83844_poc
Sources for CVE-2026-83844
5 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files579
blkph0x/cve-2026-83844_pocRevision 193ed44859da
- ↑..Parent directory
- afl_emf_gdiplus/
- capture/
- generated/
- BFDB_ALLOCATOR_REUSE_PROTOCOL.md
- BFDB_AUTHORING_MEDIA_STATIC.md
- BFDB_AUTHORING_PROTOCOL.md
- BFDB_BOUNDED_MARKER_PLACEMENT_PROTOCOL.md
- BFDB_BYTE_PROVENANCE_PROTOCOL.md
- BFDB_CACHE_PROTOCOL.md
- BFDB_CLOCK_ONLY_CONTROL_PROTOCOL.md
- BFDB_CROSSSLOT_PROTOCOL.md
- BFDB_FAST_FIRST_OPEN_PROTOCOL.md
- BFDB_FOUR_WPR_PROTOCOL.md
- BFDB_GEOMETRY_GUEST_PROTOCOL.md
- BFDB_LFH_CHECKPOINT_PROTOCOL.md
- BFDB_MARKER_ACCEPTANCE.md
- BFDB_MARKER_FIRSTOPEN_SEMANTIC_GATE.md
- BFDB_MARKER_FOUR_FIRSTOPEN_PROTOCOL.md
- BFDB_MARKER_FOUR_PROTOCOL.md
- BFDB_MARKER_ROUTE_CONTROL.md
- BFDB_MARKER_SEMANTIC_GATE.md
- BFDB_NORMAL_EXTENT_PROTOCOL.md
- BFDB_NORMAL_HEAP_PROTOCOL.md
- BFDB_NORMAL_RECORD_PROTOCOL.md
- BFDB_OUTPUT_GATES_PROTOCOL.md
- BFDB_POSTOPEN_PROTOCOL.md
- BFDB_SDK_RESOLUTION_SCAN.md
- BFDB_SINK_GATE_PROTOCOL.md
- BFDB_VALIDATION_LIFETIME_PROTOCOL.md
- BFDB_WPR_HEAP_PROTOCOL.md
- BRUSH_DISPATCH_PROTOCOL.md
- COLD_ATTACH_REPAIR_PLAN.md
- EMF_BFDB_FUZZ_ANALYSIS.md
- EMF_BFDB_FUZZ_BATCH_PROTOCOL.md
- EMF_BFDB_FUZZ_CAMPAIGN.md
- EMF_BFDB_SEQUENCE_PROTOCOL.md
- EMF_BFDB_WARM_PAGEHEAP_PROTOCOL.md
- EMF_CLIPBOARD_VALID_PROTOCOL.md
- EMF_VALID_ACCEPTANCE_PROTOCOL.md
- FILL_LOOP_CENSUS_PROTOCOL.md
- FILL_MOUSE_EVENT_PROTOCOL.md
- FILL_TOUCH_INPUT_PROTOCOL.md
- FILL_WIN32_DISPATCH_PROTOCOL.md
- PROVENANCE_APP11_POSTSEEK_PROTOCOL.md
- PROVENANCE_APP11_READER_SCAN_PROTOCOL.md
- PROVENANCE_APP11_SPLIT_NEW_LABEL_GUARD_PROTOCOL.md
- PROVENANCE_BATCH_E_SUBSET_PROTOCOL.md
- PROVENANCE_COPY_REOPEN_PROTOCOL.md
- PROVENANCE_E_CHILD_DECISION_PROTOCOL.md
- PROVENANCE_FIELD_ID_CONSUMER_PROTOCOL.md
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/trace/guest_bfdb_postopen_entry.ps1
PowerShell · 25,951 bytesparam(
[Parameter(Mandatory = $true)][ValidateSet('old')][string]$Build,
[Parameter(Mandatory = $true)][ValidateSet('control','trigger')][string]$CaseId
)
# Disposable guest only. One local JPEG, one URI-created signed Paint PID,
# one bounded open/model window, then an optional Ctrl+S on the same PID.
$ErrorActionPreference = 'Stop'
Add-Type -AssemblyName System.Windows.Forms
$inputRoot = 'C:\PaintLab\Input'
$outputRoot = 'C:\PaintLab\Output'
if ($env:USERNAME -cne 'WDAGUtilityAccount' -or
-not (Test-Path -LiteralPath $inputRoot -PathType Container) -or
-not (Test-Path -LiteralPath $outputRoot -PathType Container)) {
throw 'Post-open entry requires the disposable Paint Windows Sandbox.'
}
Add-Type -TypeDefinition @'
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
public static class PaintPostopenWindows {
public delegate bool WindowCallback(IntPtr window, IntPtr state);
[DllImport("user32.dll")] public static extern bool EnumWindows(WindowCallback callback, IntPtr state);
[DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr window, out uint pid);
[DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr window);
[DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetWindowText(IntPtr window, StringBuilder text, int capacity);
[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
public static bool IsForeground(int processId) {
uint pid;
GetWindowThreadProcessId(GetForegroundWindow(), out pid);
return pid == (uint)processId;
}
public static string[] Titles(int processId) {
var titles = new List<string>();
EnumWindows((window, state) => {
uint pid;
GetWindowThreadProcessId(window, out pid);
if (pid == (uint)processId && IsWindowVisible(window)) {
var text = new StringBuilder(512);
GetWindowText(window, text, text.Capacity);
if (text.Length > 0) titles.Add(text.ToString());
}
return true;
}, IntPtr.Zero);
return titles.ToArray();
}
}
'@
$fixtureRows = @{
control = @{ file='control.jpg'; sha256='75a8da33f6eaf1e16bf3b42cd78913b22b2e6a671fda217a508b1ba4230ce864' }
trigger = @{ file='trigger-0120-01.jpg'; sha256='82e1ad0b1be3183b0a6075ce53a44a888f149765f24cd2a681b0656b348a8f9a' }
}
$selected = $fixtureRows[$CaseId]
$fixture = Join-Path $inputRoot ('bfdb_postopen\' + $selected.file)
$profilePath = Join-Path $inputRoot 'trace\bfdb-postopen.cdb.txt'
$manifestPath = "$profilePath.json"
$selfPath = Join-Path $inputRoot 'trace\guest_bfdb_postopen_entry.ps1'
$bootstrap = Join-Path $inputRoot 'guest-bootstrap.ps1'
$bootstrapResult = Join-Path $outputRoot 'bootstrap-result.json'
$gflags = Join-Path $inputRoot 'debugger\gflags.exe'
$plmdebug = Join-Path $inputRoot 'debugger\plmdebug.exe'
$cdb = Join-Path $inputRoot 'debugger\cdb.exe'
$runId = (Get-Date).ToUniversalTime().ToString('yyyyMMddTHHmmssZ')
$output = Join-Path $outputRoot "bfdb-postopen\old\$CaseId\$runId"
New-Item -ItemType Directory -Force -Path $output | Out-Null
$logPath = Join-Path $output 'cdb.log'
$resultPath = Join-Path $output 'result.json'
$localDir = Join-Path $env:LOCALAPPDATA 'PaintLabPostopen'
$localFile = Join-Path $localDir $selected.file
$packageName = $null
$registered = $false
$actionPid = $null
$bootstrapPid = $null
$expectedVersion = '11.2605.81.0'
$expectedGflags = '3b4501db349dcd49214c5e4fc57a886458dc013dcee498b2722146fc8d451f45'
$expectedPlmdebug = 'df595e3ab812fabe89dca86fa8526a4ef91c670a71a42c0f2a380c4cd8a65dac'
$result = [ordered]@{
schema='paint-bfdb-postopen-guest-v1'; build=$Build; case_id=$CaseId
status='preflight'; started_utc=(Get-Date).ToUniversalTime().ToString('o')
installed_version=$null; installed_exe_sha256=$null
fixture_sha256=$null; writable_copy_sha256=$null
profile_sha256=$null; profile_manifest_sha256=$null; guest_entry_sha256=$null
module_checks=@(); normal_heap_verified=$false
bootstrap_stage=$null; bootstrap_paint_pid=$null
debugger_ready=$false; debugger_initial_pid=$null; paint_pid=$null
auto_debugger_enable=$null; auto_debugger_disable=$null
uri_requested_utc=$null; window_titles_before=@(); window_titles_after=@()
marker_order=@(); marker_pid_records=@(); all_marker_pids_match=$false
route_window_complete=$false; model_entry_seen=$false; model_alpha_seen=$false
open_window_seconds=$null; observation_window_exhausted=$false
save_attempted=$false; save_send_succeeded=$false; save_modal_or_extra_window=$null
edit_action_attempted=$false; paste_acquire_seen=$false
foreground_before_copy=$null; foreground_after_copy=$null
clipboard_format_names=@(); clipboard_inspection_error=$null
pre_action_gate_contamination=$false
save_file_bytes=$null; save_file_sha256=$null; saved_file_changed=$null
saved_output_artifact=$null; saved_output_artifact_sha256=$null
helper_identity_matches=$null
save_precondition_seen=$false; save_dirty_guard_true=$null; save_test_seen=$false
save_has_content=$null
save_call_seen=$false; save_call_return_seen=$false; save_call_success=$null
save_helper_seen=$false; authoring_init_seen=$false
sdk_authoring_seen=$false; log_bytes=$null; log_cap_exceeded=$false
cdb_access_violation_text_seen=$false; extra_paint_pids=@()
application_error_events=@(); dump_files=@()
cleanup=$null; error=$null; completed_utc=$null
}
function Get-LogText {
if (-not (Test-Path -LiteralPath $logPath -PathType Leaf)) { return '' }
$length = (Get-Item -LiteralPath $logPath).Length
if ($length -gt 8388608) {
$result.log_cap_exceeded = $true
throw 'CDB log exceeded the 8 MiB one-shot trace cap.'
}
return Get-Content -LiteralPath $logPath -Raw -ErrorAction SilentlyContinue
}
function Get-Events([string]$text) {
return @([regex]::Matches($text,'(?m)^PAINT_BFDB_POSTOPEN_EVENT=([a-z0-9_]+)\s*$') |
ForEach-Object { $_.Groups[1].Value })
}
function Assert-FreshSignedPaint([int]$TargetProcessId, [string]$exe) {
$rows = @(Get-Process -Id $TargetProcessId -ErrorAction Stop)
if ($rows.Count -ne 1 -or $rows[0].Path -ine $exe) {
throw 'Debugger-owned action PID is not the installed signed Paint executable.'
}
}
try {
foreach ($path in @($fixture,$profilePath,$manifestPath,$selfPath,$bootstrap,$gflags,$plmdebug,$cdb)) {
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
throw "Required pinned guest input missing: $path"
}
}
$manifest = Get-Content -LiteralPath $manifestPath -Raw | ConvertFrom-Json
if ($manifest.schema -cne 'paint-bfdb-postopen-gates-v1' -or
$manifest.profile -cne 'old' -or $manifest.version -cne $expectedVersion -or
-not [bool]$manifest.one_shot_breakpoints -or
@($manifest.gates).Count -ne 25) {
throw 'Signed post-open profile identity differs.'
}
$result.profile_sha256 = (Get-FileHash -LiteralPath $profilePath -Algorithm SHA256).Hash.ToLowerInvariant()
$result.profile_manifest_sha256 = (Get-FileHash -LiteralPath $manifestPath -Algorithm SHA256).Hash.ToLowerInvariant()
$result.guest_entry_sha256 = (Get-FileHash -LiteralPath $selfPath -Algorithm SHA256).Hash.ToLowerInvariant()
$result.fixture_sha256 = (Get-FileHash -LiteralPath $fixture -Algorithm SHA256).Hash.ToLowerInvariant()
if ($result.fixture_sha256 -cne $selected.sha256 -or
(Get-FileHash -LiteralPath $gflags -Algorithm SHA256).Hash.ToLowerInvariant() -cne $expectedGflags -or
(Get-FileHash -LiteralPath $plmdebug -Algorithm SHA256).Hash.ToLowerInvariant() -cne $expectedPlmdebug) {
throw 'Pinned fixture or debugger prerequisite differs.'
}
$listing = (& $gflags /p 2>&1 | Out-String)
[IO.File]::WriteAllText((Join-Path $output 'gflags-list.txt'),$listing)
if ($LASTEXITCODE -ne 0 -or $listing -match '(?i)\bmspaint\.exe\b') {
throw 'Normal-heap guest has a Paint GFlags heap entry.'
}
$result.normal_heap_verified = $true
New-Item -ItemType Directory -Force -Path $localDir | Out-Null
if (Test-Path -LiteralPath $localFile) { throw 'Writable test copy path already exists in fresh guest.' }
Copy-Item -LiteralPath $fixture -Destination $localFile -ErrorAction Stop
$result.writable_copy_sha256 = (Get-FileHash -LiteralPath $localFile -Algorithm SHA256).Hash.ToLowerInvariant()
if ($result.writable_copy_sha256 -cne $selected.sha256) {
throw 'Guest-local writable JPEG differs from the pinned source.'
}
$bootstrapProcess = Start-Process -FilePath (Join-Path $env:WINDIR 'System32\WindowsPowerShell\v1.0\powershell.exe') `
-ArgumentList @('-NoProfile','-ExecutionPolicy','Bypass','-File',$bootstrap,'-Build','old') `
-WindowStyle Hidden -PassThru -ErrorAction Stop
if (-not $bootstrapProcess.WaitForExit(150000)) {
Stop-Process -Id $bootstrapProcess.Id -Force -ErrorAction SilentlyContinue
throw 'Signed package bootstrap exceeded 150 seconds.'
}
$bootstrapProcess.Refresh()
if ($bootstrapProcess.ExitCode -ne 0 -or -not (Test-Path -LiteralPath $bootstrapResult -PathType Leaf)) {
throw 'Signed package bootstrap failed.'
}
$boot = Get-Content -LiteralPath $bootstrapResult -Raw | ConvertFrom-Json
$result.bootstrap_stage = $boot.stage
if ($boot.stage -cne 'complete' -or [string]$boot.installed_paint.version -cne $expectedVersion) {
throw 'Signed package bootstrap identity differs.'
}
$packages = @(Get-AppxPackage -Name Microsoft.Paint -ErrorAction Stop)
if ($packages.Count -ne 1 -or [string]$packages[0].Version -cne $expectedVersion) {
throw 'Installed Paint package differs.'
}
$packageName = [string]$packages[0].PackageFullName
$exe = Join-Path $packages[0].InstallLocation 'PaintApp\mspaint.exe'
$result.installed_version = [string]$packages[0].Version
$result.installed_exe_sha256 = (Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash.ToLowerInvariant()
foreach ($entry in $manifest.modules.PSObject.Properties) {
$module = Join-Path $packages[0].InstallLocation (Join-Path 'PaintApp' $entry.Name)
$digest = (Get-FileHash -LiteralPath $module -Algorithm SHA256).Hash.ToLowerInvariant()
if ($digest -cne [string]$entry.Value.sha256) { throw "Installed signed module differs: $($entry.Name)" }
$result.module_checks += [ordered]@{ module=$entry.Name; sha256=$digest }
}
$paintRows = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
if ($paintRows.Count -ne 1 -or $paintRows[0].Path -ine $exe) {
throw 'Bootstrap did not leave one signed Paint PID.'
}
$bootstrapPid = [int]$paintRows[0].Id
$result.bootstrap_paint_pid = $bootstrapPid
$debugCommand = "$cdb -bonc -G -logo $logPath -cf $profilePath"
$registered = $true
$enableText = (& $plmdebug /enableDebug $packageName $debugCommand 2>&1 | Out-String)
$result.auto_debugger_enable = [ordered]@{ exit_code=$LASTEXITCODE; output=$enableText.Trim() }
if ($LASTEXITCODE -ne 0) { throw 'Guest PLMDebug registration failed.' }
$result.status = 'activating_uri'
$result.uri_requested_utc = (Get-Date).ToUniversalTime().ToString('o')
Start-Process -FilePath "ms-paint://backgroundRemoval?isTemporaryPath=false&file=$localFile" -ErrorAction Stop | Out-Null
$readyDeadline = (Get-Date).AddSeconds(40)
do {
Start-Sleep -Milliseconds 300
$logText = Get-LogText
$ready = $logText -match '(?m)^PAINT_BFDB_POSTOPEN_PROFILE=paint-bfdb-postopen-gates-v1:old\s*$' -and
$logText -match '(?m)^PAINT_BFDB_POSTOPEN_ARMED=25\s*$'
} while (-not $ready -and (Get-Date) -lt $readyDeadline)
if (-not $ready) { throw 'URI action auto-debugger did not arm within 40 seconds.' }
$ids = [regex]::Matches($logText,'(?m)^PAINT_BFDB_POSTOPEN_INITIAL_PID=(\d+)\s*$')
if ($ids.Count -ne 1) { throw 'Debugger initial PID is absent or ambiguous.' }
$actionPid = [int]$ids[0].Groups[1].Value
if ($actionPid -eq $bootstrapPid) { throw 'Auto-debugger attached to bootstrap PID, not URI action PID.' }
Assert-FreshSignedPaint $actionPid $exe
$result.debugger_ready = $true
$result.debugger_initial_pid = $actionPid
$result.paint_pid = $actionPid
$result.status = 'observing_open'
$observeStart = Get-Date
$deadline = $observeStart.AddSeconds(150)
$routeFirstSeenAt = $null
$routeRequired = @('uri_compare','uri_dispatch','uri_handler','uri_async_body',
'open_ingredient','validation_init','media_memcpy','media_copy_return',
'tree_after','context_free')
do {
Start-Sleep -Milliseconds 500
$logText = Get-LogText
$events = @(Get-Events $logText)
if (-not $routeFirstSeenAt -and
@($routeRequired | Where-Object { $events -notcontains $_ }).Count -eq 0) {
$routeFirstSeenAt = Get-Date
}
$settled = $routeFirstSeenAt -and ((Get-Date) - $routeFirstSeenAt).TotalSeconds -ge 60
$alive = @(Get-Process -Id $actionPid -ErrorAction SilentlyContinue).Count -eq 1
$fault = $logText -match '(?i)Access violation|0xc0000005'
} while (-not $settled -and $alive -and -not $fault -and (Get-Date) -lt $deadline)
$result.open_window_seconds = [math]::Round(((Get-Date) - $observeStart).TotalSeconds,2)
$result.observation_window_exhausted = (Get-Date) -ge $deadline -and -not $settled
$result.cdb_access_violation_text_seen = [bool]$fault
$result.marker_order = @(Get-Events $logText)
$result.route_window_complete = [bool]$settled
$result.model_entry_seen = $events -contains 'removebg_entry'
$result.model_alpha_seen = $events -contains 'removebg_alpha_read'
if (-not $result.route_window_complete -or $fault -or -not $alive) {
throw 'Same-PID URI validation and 60-second post-open window did not complete.'
}
$preActionGates = @('paste_acquire','merge_test','merge_call','base64_entry',
'save_precondition','save_test','save_call','save_call_return')
$result.pre_action_gate_contamination =
@($preActionGates | Where-Object { $events -contains $_ }).Count -gt 0
if ($result.pre_action_gate_contamination) {
throw 'Output gate was consumed before the explicit UI edit/Save phase.'
}
$result.window_titles_before = @([PaintPostopenWindows]::Titles($actionPid))
if ($result.window_titles_before.Count -ne 1 -or
$result.window_titles_before[0] -notlike '*Paint*') {
throw 'One visible signed Paint window was not verified before Ctrl+S.'
}
$result.status = 'saving'
$shell = New-Object -ComObject WScript.Shell
if (-not $shell.AppActivate($actionPid)) { throw 'Could not activate URI-created Paint PID for Copy/Paste.' }
$result.edit_action_attempted = $true
Start-Sleep -Milliseconds 300
$result.foreground_before_copy = [PaintPostopenWindows]::IsForeground($actionPid)
if (-not $result.foreground_before_copy) {
throw 'URI-created Paint PID did not own foreground before Copy/Paste.'
}
[System.Windows.Forms.SendKeys]::SendWait('^a')
Start-Sleep -Milliseconds 500
[System.Windows.Forms.SendKeys]::SendWait('^c')
Start-Sleep -Milliseconds 500
$result.foreground_after_copy = [PaintPostopenWindows]::IsForeground($actionPid)
try {
$clipboardObject = [System.Windows.Forms.Clipboard]::GetDataObject()
if ($null -ne $clipboardObject) {
$result.clipboard_format_names = @($clipboardObject.GetFormats($false) |
Select-Object -Unique | Select-Object -First 32)
}
} catch {
$result.clipboard_inspection_error = $_.Exception.GetType().FullName
}
[System.Windows.Forms.SendKeys]::SendWait('^v')
$pasteDeadline = (Get-Date).AddSeconds(12)
do {
Start-Sleep -Milliseconds 300
$logText = Get-LogText
$events = @(Get-Events $logText)
$result.paste_acquire_seen = $events -contains 'paste_acquire'
} while (-not $result.paste_acquire_seen -and (Get-Date) -lt $pasteDeadline)
if (-not $result.paste_acquire_seen) { throw 'Copy/Paste did not reach the signed image-acquisition gate.' }
[System.Windows.Forms.SendKeys]::SendWait('{ENTER}')
Start-Sleep -Milliseconds 500
if (-not $shell.AppActivate($actionPid)) { throw 'Could not reactivate URI-created Paint PID for Ctrl+S.' }
$result.save_attempted = $true
[System.Windows.Forms.SendKeys]::SendWait('^s')
$result.save_send_succeeded = $true
$saveDeadline = (Get-Date).AddSeconds(15)
do {
Start-Sleep -Milliseconds 500
$logText = Get-LogText
$events = @(Get-Events $logText)
$saveSeen = $events -contains 'save_test'
$fault = $logText -match '(?i)Access violation|0xc0000005'
} while (-not $saveSeen -and -not $fault -and (Get-Date) -lt $saveDeadline)
Start-Sleep -Seconds 2
$logText = Get-LogText
$events = @(Get-Events $logText)
$result.marker_order = $events
$result.cdb_access_violation_text_seen = $logText -match '(?i)Access violation|0xc0000005'
$result.save_precondition_seen = $events -contains 'save_precondition'
$savePrecondition = [regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_VALUE=save_precondition\.condition:([0-9a-f]+)(?=\s|$)')
if ($savePrecondition.Count -eq 1) {
$result.save_dirty_guard_true = [Convert]::ToUInt64($savePrecondition[0].Groups[1].Value,16) -ne 0
}
$result.save_test_seen = $events -contains 'save_test'
$saveHasContent = [regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_VALUE=save_test_return\.has_content:([0-9a-f]+)(?=\s|$)')
if ($saveHasContent.Count -eq 1) {
$result.save_has_content = [Convert]::ToUInt64($saveHasContent[0].Groups[1].Value,16) -eq 1
}
$result.save_call_seen = $events -contains 'save_call'
$result.save_call_return_seen = $events -contains 'save_call_return'
$treeHelper = [regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_VALUE=tree_after\.helper:([0-9a-f]+)(?=\s|$)')
$saveHelper = [regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_VALUE=save_test\.helper:([0-9a-f]+)(?=\s|$)')
if ($treeHelper.Count -eq 1 -and $saveHelper.Count -eq 1) {
$result.helper_identity_matches = $treeHelper[0].Groups[1].Value -ceq
$saveHelper[0].Groups[1].Value
}
$saveReturn = [regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_VALUE=save_call_return\.success:([0-9a-f]+)(?=\s|$)')
if ($saveReturn.Count -eq 1) {
$result.save_call_success = [Convert]::ToUInt64($saveReturn[0].Groups[1].Value,16) -eq 1
}
$result.save_helper_seen = $events -contains 'save_helper_entry'
$result.authoring_init_seen = $events -contains 'authoring_init'
$result.sdk_authoring_seen = $events -contains 'sdk_authoring_entry'
$result.window_titles_after = @([PaintPostopenWindows]::Titles($actionPid))
$result.save_modal_or_extra_window = $result.window_titles_after.Count -ne 1 -or
$result.window_titles_after[0] -notlike '*Paint*'
$localItem = Get-Item -LiteralPath $localFile -ErrorAction Stop
$result.save_file_bytes = [long]$localItem.Length
if ($localItem.Length -gt 0) {
$result.save_file_sha256 = (Get-FileHash -LiteralPath $localFile -Algorithm SHA256).Hash.ToLowerInvariant()
$result.saved_file_changed = $result.save_file_sha256 -cne $result.writable_copy_sha256
$savedOutput = Join-Path $output 'saved-output.jpg'
Copy-Item -LiteralPath $localFile -Destination $savedOutput -ErrorAction Stop
$result.saved_output_artifact = 'saved-output.jpg'
$result.saved_output_artifact_sha256 =
(Get-FileHash -LiteralPath $savedOutput -Algorithm SHA256).Hash.ToLowerInvariant()
if ($result.saved_output_artifact_sha256 -cne $result.save_file_sha256) {
throw 'Saved output copy differs from the guest-local file.'
}
}
if ($result.cdb_access_violation_text_seen) { throw 'CDB observed an access violation.' }
if ($result.save_modal_or_extra_window) { throw 'Save left a modal or extra Paint window.' }
$result.status = if ($result.save_test_seen -and $result.save_file_bytes -gt 0) {
'observed_pending_review'
} else { 'route_observed_save_not_reached' }
} catch {
$result.error = $_.Exception.Message
$result.status = 'review_required'
} finally {
try {
$logText = Get-LogText
$result.log_bytes = if (Test-Path -LiteralPath $logPath) { (Get-Item -LiteralPath $logPath).Length } else { 0 }
$result.marker_order = @(Get-Events $logText)
$pidRows = @(
[regex]::Matches($logText,
'(?m)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_PID=([a-z0-9_]+):(\d+)(?=\s|$)') |
ForEach-Object { [ordered]@{ event=$_.Groups[1].Value; pid=[int]$_.Groups[2].Value } }
[regex]::Matches($logText,
'(?mi)(?<![A-Za-z0-9_])PAINT_BFDB_POSTOPEN_PID=([a-z0-9_]+):\*\*\* WARNING: Unable to verify checksum for [^\r\n]+\r?\n(\d+)(?=\s|$)') |
ForEach-Object { [ordered]@{ event=$_.Groups[1].Value; pid=[int]$_.Groups[2].Value } }
)
$result.marker_pid_records = $pidRows
$result.all_marker_pids_match = $actionPid -and $pidRows.Count -gt 0 -and
@($pidRows | Where-Object { $_.pid -ne $actionPid }).Count -eq 0
$result.cdb_access_violation_text_seen = $result.cdb_access_violation_text_seen -or
($logText -match '(?i)Access violation|0xc0000005')
} catch {
$result.log_cap_exceeded = $true
if (-not $result.error) { $result.error = $_.Exception.Message }
$result.status = 'review_required'
}
$result.extra_paint_pids = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue |
Where-Object { $_.Id -ne $bootstrapPid -and $_.Id -ne $actionPid } |
ForEach-Object { $_.Id })
if ($registered -and $packageName) {
try {
$disableText = (& $plmdebug /disableDebug $packageName 2>&1 | Out-String)
$result.auto_debugger_disable = [ordered]@{
exit_code=$LASTEXITCODE; registration_pair_completed=($LASTEXITCODE -eq 0)
output=$disableText.Trim()
}
} catch { $result.auto_debugger_disable = [ordered]@{ error=$_.Exception.Message } }
}
$before = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
$requested = @()
foreach ($process in $before) {
try {
if ($process.MainWindowHandle -ne [IntPtr]::Zero -and $process.CloseMainWindow()) {
$requested += $process.Id
}
} catch { }
}
Start-Sleep -Seconds 4
$forcedPaint = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
$forcedCdb = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
foreach ($process in $forcedCdb) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
foreach ($process in $forcedPaint) { Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue }
$afterPaint = @(Get-Process -Name mspaint -ErrorAction SilentlyContinue)
$afterCdb = @(Get-Process -Name cdb -ErrorAction SilentlyContinue)
$result.cleanup = [ordered]@{
close_requested_pids=$requested
paint_forced_pids=@($forcedPaint | ForEach-Object { $_.Id })
debugger_forced_pids=@($forcedCdb | ForEach-Object { $_.Id })
paint_remaining_pids=@($afterPaint | ForEach-Object { $_.Id })
debugger_remaining_pids=@($afterCdb | ForEach-Object { $_.Id })
}
try {
$since = ([datetime]$result.started_utc).AddSeconds(-1)
$result.application_error_events = @(
Get-WinEvent -FilterHashtable @{LogName='Application';StartTime=$since;Id=1000,1001} `
-ErrorAction SilentlyContinue |
Where-Object { $_.Message -match '(?i)mspaint\.exe|Microsoft\.Paint' } |
Select-Object -First 20 |
ForEach-Object { [ordered]@{
id=$_.Id; time_utc=$_.TimeCreated.ToUniversalTime().ToString('o')
} }
)
} catch { }
$dumpRoot = Join-Path $outputRoot 'dumps'
if (Test-Path -LiteralPath $dumpRoot -PathType Container) {
$result.dump_files = @(Get-ChildItem -LiteralPath $dumpRoot -Filter 'mspaint*.dmp' -File |
Where-Object { $_.LastWriteTimeUtc -ge ([datetime]$result.started_utc).AddSeconds(-1) } |
Select-Object -ExpandProperty Name)
}
if ($result.cleanup.paint_forced_pids.Count -gt 0 -or
$result.cleanup.debugger_forced_pids.Count -gt 0 -or
-not $result.all_marker_pids_match -or
$result.extra_paint_pids.Count -gt 0 -or
$result.application_error_events.Count -gt 0 -or
$result.dump_files.Count -gt 0 -or
$result.auto_debugger_disable.exit_code -ne 0) {
$result.status = 'review_required'
}
$result.completed_utc = (Get-Date).ToUniversalTime().ToString('o')
$result | ConvertTo-Json -Depth 9 | Set-Content -LiteralPath $resultPath -Encoding UTF8
& (Join-Path $env:WINDIR 'System32\shutdown.exe') /s /t 20 /c 'Paint post-open trial complete'
[ordered]@{
requested_utc=(Get-Date).ToUniversalTime().ToString('o')
method='normal shutdown /s /t 20; no /f'; exit_code=$LASTEXITCODE
trial_status=$result.status
} | ConvertTo-Json -Depth 4 | Set-Content -LiteralPath (
Join-Path $outputRoot "bfdb-postopen-shutdown-old-$runId.json") -Encoding UTF8
}