fe2a6db786
rust / build / test / clippy / fmt (push) Has been cancelled
Layout:
- src/ .NET 10 x64 reference: MxNativeCodec, MxNativeClient,
MxAsbClient, probes, tests, harnesses. Executable spec.
- design/ Architectural plan for the Rust port (M0–M6), error
model, protocol invariants, risks (R1–R16), adversarial
review log (review.md).
- rust/ Rust workspace. M0 skeleton + M1 codec parity.
mxaccess-codec: 215 unit tests + 2 cross-implementation
parity tests (byte-identical against .NET reference).
Other crates are M0 stubs awaiting M2+.
- captures/ Frida + netsh + pcap evidence per CLAUDE.md
("captures are evidence, not throwaway logs").
- analysis/ Decompiled C# (frida/proxy/decompiled-*),
Ghidra exports for native DLLs (`exports/` only —
working state at `projects/` and AVEVA's input
binaries at `input/` are gitignored).
- docs/ Reverse-engineering reference docs.
- tools/ Setup-LiveProbeEnv.ps1 (Infisical credential fetcher),
Compute-Crc.ps1 (.NET parity helper).
- .github/workflows/ Rust CI: fmt + build + test + clippy on Windows.
- LICENSE MIT (Joseph Doherty, 2026).
Verified:
- cargo test --workspace → 217 passed (215 unit + 2 .NET parity), 0 failed
- cargo clippy --workspace -- -D warnings → clean
- cargo fmt --all -- --check → clean
- cargo publish --dry-run -p mxaccess-codec → packages cleanly
Excluded from history (see .gitignore):
- **/bin, **/obj, **/target — build artifacts
- analysis/ghidra/projects/ — Ghidra working state (regenerable)
- analysis/ghidra/input/ — AVEVA proprietary DLLs (vendor IP)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
288 lines
12 KiB
C#
288 lines
12 KiB
C#
using System.Runtime.InteropServices;
|
|
using ArchestrAServices.ASBContract;
|
|
using ArchestrAServices.ASBIDataContract.V2;
|
|
using ArchestrAServices.ASBIDataV2Contract;
|
|
using ArchestrAServices.Proxy;
|
|
|
|
public class CIDataVersionAdapterV2(ASBDataV2Proxy ASBProxy) : CIDataVersionAdapter
|
|
{
|
|
private ASBDataV2Proxy m_ASBProxy = ASBProxy;
|
|
|
|
private ConnectionId m_blankConnectionId;
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
public override bool Connect(ref string errorMessage)
|
|
{
|
|
bool result = false;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
result = aSBProxy.Connect(out errorMessage);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public override void Abort()
|
|
{
|
|
m_ASBProxy?.Abort();
|
|
}
|
|
|
|
public override void Disconnect()
|
|
{
|
|
m_ASBProxy?.Disconnect();
|
|
}
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
public override bool SupportsArrayElementWrites()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public override ArchestrAResult KeepAlive()
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.KeepAlive(m_blankConnectionId);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult Read(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ref ArchestrAServices.ASBIDataV2Contract.RuntimeValue[] ItemValues, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.Read(out Status, out ItemValues, m_blankConnectionId, Items);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult Write(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items, ArchestrAServices.ASBIDataV2Contract.WriteValue[] Values, uint WriteHandle)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.Write(out Status, Items, Values, WriteHandle);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult WriteUser(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items, ArchestrAServices.ASBIDataV2Contract.WriteValue[] Values, ArchestrAServices.ASBIDataV2Contract.UserToken User, uint WriteHandle)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.WriteUser(out Status, Items, Values, User, WriteHandle);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult WriteVerified(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items, ArchestrAServices.ASBIDataV2Contract.WriteValue[] Values, ArchestrAServices.ASBIDataV2Contract.UserToken User, ArchestrAServices.ASBIDataV2Contract.UserToken Supervisor, uint WriteHandle)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.WriteVerified(out Status, Items, Values, User, Supervisor, WriteHandle);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult WriteSecured(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items, ArchestrAServices.ASBIDataV2Contract.WriteValue[] Values, ArchestrAServices.ASBIDataV2Contract.UserToken User, uint WriteHandle)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.WriteSecured(out Status, Items, Values, User, WriteHandle);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult WriteConfirmed(ref ArchestrAServices.ASBIDataV2Contract.WriteValue ValueReceived, ref long WriteToken, ArchestrAServices.ASBIDataV2Contract.ItemIdentity Item, ArchestrAServices.ASBIDataV2Contract.WriteValue Value, ArchestrAServices.ASBIDataV2Contract.UserToken User, ArchestrAServices.ASBIDataV2Contract.UserToken Supervisor)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.WriteConfirmed(out ValueReceived, out WriteToken, Item, Value, User, Supervisor);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult ConfirmWrite(ArchestrAServices.ASBIDataV2Contract.ItemIdentity Item, long WriteToken, ArchestrAServices.ASBIDataV2Contract.WriteValue Value, ArchestrAServices.ASBIDataV2Contract.UserToken User, ArchestrAServices.ASBIDataV2Contract.UserToken Supervisor, uint WriteHandle)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.ConfirmWrite(Item, WriteToken, Value, User, Supervisor, WriteHandle);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult PublishWriteComplete(ref ArchestrAServices.ASBIDataV2Contract.ItemWriteComplete[] CompleteWrites)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.PublishWriteComplete(out CompleteWrites);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult CreateSubscription(ref long SubscriptionId, long MaxQueueSize, ulong SampleInterval)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.CreateSubscription(out SubscriptionId, MaxQueueSize, SampleInterval);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult SetSubscriptionState(long SubscriptionId, ArchestrAServices.ASBIDataContract.V2.Variant NewState, ushort StateToChange)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.SetSubscriptionState(SubscriptionId, NewState, StateToChange);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult GetSubscriptionState(ref ArchestrAServices.ASBIDataContract.V2.Variant State, long SubscriptionId, ushort StateToGet)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.GetSubscriptionState(out State, SubscriptionId, StateToGet);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult DeleteSubscription(long SubscriptionId)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.DeleteSubscription(SubscriptionId);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult AddMonitoredItems(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ref ArchestrAServices.ASBIDataV2Contract.ItemRegistration[] ItemCapabilities, long SubscriptionId, ArchestrAServices.ASBIDataV2Contract.MonitoredItem[] Items, byte RequireId)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.AddMonitoredItems(out Status, out ItemCapabilities, SubscriptionId, Items, RequireId);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult DeleteMonitoredItems(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, long SubscriptionId, ArchestrAServices.ASBIDataV2Contract.MonitoredItem[] Items)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.DeleteMonitoredItems(out Status, SubscriptionId, Items);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult GetMonitoredItems(ref ArchestrAServices.ASBIDataV2Contract.MonitoredItem[] Items, long SubscriptionId)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.GetMonitoredItems(out Items, SubscriptionId);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult Publish(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ref ArchestrAServices.ASBIDataV2Contract.MonitoredItemValue[] Values, long SubscriptionId)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.Publish(out Status, out Values, SubscriptionId);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult RegisterItems(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ref ArchestrAServices.ASBIDataV2Contract.ItemRegistration[] ItemCapabilities, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items, byte RequireId, byte RegisterOnly)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.RegisterItems(out Status, out ItemCapabilities, Items, RequireId, RegisterOnly);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
|
|
public override ArchestrAResult UnregisterItems(ref ArchestrAServices.ASBIDataV2Contract.ItemStatus[] Status, ArchestrAServices.ASBIDataV2Contract.ItemIdentity[] Items)
|
|
{
|
|
ArchestrAResult archestrAResult = default(ArchestrAResult);
|
|
archestrAResult = ResultFactory.MakeResult(ArchestrAError.SpecificError, 32);
|
|
archestrAResult.SpecificErrorCode = 2147614720u;
|
|
ASBDataV2Proxy aSBProxy = m_ASBProxy;
|
|
if (aSBProxy != null)
|
|
{
|
|
archestrAResult = aSBProxy.UnregisterItems(out Status, Items);
|
|
}
|
|
return archestrAResult;
|
|
}
|
|
}
|