c95824a65d
Full read-only SDK (src/AVEVA.Historian.Client) implementing the CLAUDE.md required
surface against AVEVA Historian's binary WCF protocol — no native AVEVA runtime
dependency. All operations live-verified against a local Historian:
- ProbeAsync, ReadRawAsync, ReadAggregateAsync, ReadAtTimeAsync, ReadEventsAsync
- BrowseTagNamesAsync, GetTagMetadataAsync (17 native data-type codes mapped)
- GetConnectionStatusAsync, GetStoreForwardStatusAsync, GetSystemParameterAsync
- 108/108 unit + integration tests pass
Includes the reverse-engineering toolkit (tools/AVEVA.Historian.ReverseEngineering)
used to decode the protocol: WCF probes, IL inspection via dnlib, and IL-rewrite
instrumentation (instrument-wcf-{write,read}message etc.) plus the .NET Framework
trace harness (tools/AVEVA.Historian.NativeTraceHarness) for parity testing.
Sanitized handoff evidence under docs/reverse-engineering/. Native AVEVA binaries
(current/, aveva-install-x64/, aveva-install-x86/) are gitignored — fetch separately
from the AVEVA installer.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
85 lines
3.2 KiB
PowerShell
85 lines
3.2 KiB
PowerShell
param(
|
|
[ValidateSet("history", "event")]
|
|
[string]$Scenario = "history",
|
|
[string]$ServerName = "localhost",
|
|
[string]$TagName = "OtOpcUaParityTest_001.Counter",
|
|
[string]$RetrievalMode = "Full",
|
|
[int]$LookbackMinutes = 1440,
|
|
[int]$MaxRows = 1,
|
|
[UInt64]$ResolutionTicks = 0,
|
|
[switch]$DirectConnection,
|
|
[int]$AttachDelaySeconds = 5,
|
|
[int]$PreLoadSleepSeconds = 0,
|
|
[string]$OutputPath = $null
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = Split-Path -Parent $PSScriptRoot
|
|
$fridaScript = Join-Path $PSScriptRoot "frida\aahclientmanaged-winsock.js"
|
|
$harness = Join-Path $repoRoot "tools\AVEVA.Historian.NativeTraceHarness\bin\Debug\net481\AVEVA.Historian.NativeTraceHarness.exe"
|
|
|
|
if ([string]::IsNullOrWhiteSpace($OutputPath)) {
|
|
$stamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
|
$OutputPath = Join-Path $repoRoot "docs\reverse-engineering\winsock-$Scenario-$stamp.ndjson"
|
|
}
|
|
|
|
$outputDirectory = Split-Path -Parent $OutputPath
|
|
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
|
|
|
|
Push-Location $repoRoot
|
|
try {
|
|
dotnet build .\tools\AVEVA.Historian.NativeTraceHarness\AVEVA.Historian.NativeTraceHarness.csproj | Out-Host
|
|
|
|
$childOut = Join-Path $env:TEMP ("histsdk-native-trace-{0}.out.log" -f ([Guid]::NewGuid().ToString("N")))
|
|
$childErr = Join-Path $env:TEMP ("histsdk-native-trace-{0}.err.log" -f ([Guid]::NewGuid().ToString("N")))
|
|
|
|
$args = @(
|
|
"--scenario", $Scenario,
|
|
"--server-name", $ServerName,
|
|
"--tag", $TagName,
|
|
"--retrieval-mode", $RetrievalMode,
|
|
"--lookback-minutes", $LookbackMinutes.ToString(),
|
|
"--max-rows", $MaxRows.ToString(),
|
|
"--pre-load-sleep-seconds", $PreLoadSleepSeconds.ToString(),
|
|
"--pre-open-sleep-seconds", $AttachDelaySeconds.ToString()
|
|
)
|
|
|
|
if ($ResolutionTicks -gt 0) {
|
|
$args += @("--resolution-ticks", $ResolutionTicks.ToString())
|
|
}
|
|
|
|
if ($DirectConnection) {
|
|
$args += "--direct-connection"
|
|
}
|
|
|
|
Write-Host "Starting native trace harness with $AttachDelaySeconds second pre-open pause."
|
|
$process = Start-Process -FilePath $harness -ArgumentList $args -WorkingDirectory $repoRoot -RedirectStandardOutput $childOut -RedirectStandardError $childErr -PassThru -WindowStyle Hidden
|
|
|
|
try {
|
|
Start-Sleep -Seconds 1
|
|
Write-Host "Attaching Winsock Frida capture to PID $($process.Id). Capture: $OutputPath"
|
|
& frida -q -p $process.Id -l $fridaScript 2>&1 | Tee-Object -FilePath $OutputPath
|
|
|
|
if (-not $process.HasExited) {
|
|
$process.WaitForExit(30000) | Out-Null
|
|
}
|
|
}
|
|
finally {
|
|
if (-not $process.HasExited) {
|
|
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
"--- native stdout ---" | Tee-Object -FilePath $OutputPath -Append
|
|
Get-Content -LiteralPath $childOut -ErrorAction SilentlyContinue | Tee-Object -FilePath $OutputPath -Append
|
|
"--- native stderr ---" | Tee-Object -FilePath $OutputPath -Append
|
|
Get-Content -LiteralPath $childErr -ErrorAction SilentlyContinue | Tee-Object -FilePath $OutputPath -Append
|
|
Remove-Item -LiteralPath $childOut, $childErr -ErrorAction SilentlyContinue
|
|
}
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
|
|
Write-Host "Capture complete: $OutputPath"
|