param( [string]$TagName = "OtOpcUaParityTest_001.Counter", [int]$LookbackMinutes = 1440, [int]$MaxRows = 1, [string]$OutputPath = $null ) $ErrorActionPreference = "Stop" $repoRoot = Split-Path -Parent $PSScriptRoot $fridaScript = Join-Path $PSScriptRoot "frida\aahclientmanaged-open-query.js" $nativeReadScript = Join-Path $PSScriptRoot "Test-AahClientManagedReadIntegrated.ps1" if (-not (Test-Path -LiteralPath $fridaScript)) { throw "Missing Frida script at $fridaScript" } if (-not (Test-Path -LiteralPath $nativeReadScript)) { throw "Missing native read script at $nativeReadScript" } if ([string]::IsNullOrWhiteSpace($OutputPath)) { $stamp = Get-Date -Format "yyyyMMdd-HHmmss" $OutputPath = Join-Path $repoRoot "docs\reverse-engineering\frida-aahclientmanaged-integrated-read-$stamp.ndjson" } $outputDirectory = Split-Path -Parent $OutputPath New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null $powershell = Join-Path $env:WINDIR "System32\WindowsPowerShell\v1.0\powershell.exe" if (-not (Test-Path -LiteralPath $powershell)) { $powershell = "powershell.exe" } $fridaArgs = @( "-q", "-f", $powershell, "-l", $fridaScript, "--", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", $nativeReadScript, "-TagName", $TagName, "-LookbackMinutes", $LookbackMinutes.ToString(), "-MaxRows", $MaxRows.ToString(), "-ConnectionWaitSeconds", "15" ) Write-Host "Writing Frida capture to $OutputPath" Write-Host "Target tag: $TagName" & frida @fridaArgs 2>&1 | Tee-Object -FilePath $OutputPath Write-Host "Capture complete: $OutputPath"