M3 R3.1 capture: instrument-grpc-nonstream IL-rewrite + harness --grpc-rewrite loading

Adds the dnlib instrument command + harness wiring to capture the two non-streamed-write
buffers from the native 2023 R2 client:

- `instrument-grpc-nonstream <GrpcClient.dll> [out]` injects CaptureLogger.LogByteArray at the
  entry of GrpcHistoryClient.RegisterTags (byte[] tagInfos) and AddNonStreamValues (byte[] inBuff),
  writing the rewrite to docs/reverse-engineering/dnlib-write-copy/grpc2023 (gitignored — derived
  AVEVA binary). dnlib preserves the AVEVA public-key identity so aahClientManaged still binds the
  rewritten copy under the LoadFrom context (no SN re-verification).
- harness `--grpc-rewrite <dir>` probes that dir first, so the instrumented GrpcClient.dll +
  ReverseInstrumentation.dll load ahead of the originals. load-check confirms the rewritten
  strong-named copy binds (HistorianConnectionMode.Historian=2; GrpcHistoryClient RegisterTags +
  AddNonStreamValues present).

Next: capture-write scenario (open write-enabled -> sandbox tag -> read-prime -> AddNonStreamedValue),
which dumps tagInfos + inBuff to the capture NDJSON. Prod write — confirm before running.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B6mcaT2PjRFKcogzp9UkfC
This commit is contained in:
Joseph Doherty
2026-06-21 19:20:54 -04:00
parent ce8576bd6e
commit c1f263ef83
3 changed files with 99 additions and 2 deletions
@@ -40,8 +40,15 @@ namespace AVEVA.Historian.Grpc2023CaptureHarness
return 1;
}
// Resolve siblings from both the core bin dir and the gRPC-runtime msi-extract dir.
string[] probeDirs = Directory.Exists(msiX64) ? new[] { binDir, msiX64 } : new[] { binDir };
// Resolve siblings from: (optional) IL-rewrite dir FIRST (so the instrumented
// Archestra.Historian.GrpcClient.dll + ReverseInstrumentation.dll win), then the core
// bin dir, then the gRPC-runtime msi-extract dir.
string? rewriteDir = GetOption(args, "--grpc-rewrite");
var probeList = new System.Collections.Generic.List<string>();
if (!string.IsNullOrEmpty(rewriteDir) && Directory.Exists(rewriteDir)) probeList.Add(rewriteDir!);
probeList.Add(binDir);
if (Directory.Exists(msiX64)) probeList.Add(msiX64);
string[] probeDirs = probeList.ToArray();
AppDomain.CurrentDomain.AssemblyResolve += (_, e) =>
{
string simpleName = new AssemblyName(e.Name).Name + ".dll";