Initial project state: .NET reference, design, Rust port (M0+M1), evidence
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>
This commit is contained in:
Joseph Doherty
2026-05-05 06:21:00 -04:00
parent 43733699b0
commit fe2a6db786
3849 changed files with 352975 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
//! `mxaccess-codec` — pure protocol codec for the AVEVA / Wonderware MXAccess
//! wire format. No I/O.
//!
//! M1 codec parity in progress. Implemented:
//! - Foundational types: `MxReferenceHandle` (CRC-16/IBM), `NmxTransferEnvelope`
//! (with `reserved6_10` preservation), `MxStatus` + `MxStatusCategory` +
//! `MxStatusSource` + `detail_text`, `MxValue` + `MxValueKind` + `MxDataType`.
//! - Message-body codecs: `NmxItemControlMessage` (advise/supervisory/unadvise),
//! `write_message` module (scalar + array, normal + timestamped Write),
//! `subscription_message` (DataUpdate `0x33` + SubscriptionStatus `0x32`),
//! `NmxReferenceRegistrationMessage` + Result, `NmxOperationStatusMessage`
//! (incl. the proven `00 00 50 80 00` 5-byte completion frame and the
//! `0x00`/`0x41`/`0xEF` 1-byte completion frames preserved verbatim),
//! `NmxMetadataQueryMessage` (observed pre-advise template),
//! `NmxTransferEnvelopeTemplate` (round-trip preserver).
//!
//! Remaining (wave 2): `NmxSecuredWrite2Message` (`0x38`),
//! `ObservedWriteBodyTemplate`. ASB Variant + AsbStatus + RuntimeValue land
//! in M5.
//!
//! Every wire shape here is grounded in `src/MxNativeCodec/*.cs` (the .NET
//! reference) and `captures/0NN-frida-*` (Frida ground truth).
#![forbid(unsafe_code)]
pub mod envelope;
pub mod envelope_template;
pub mod error;
pub mod item_control;
pub mod metadata_query;
pub mod observed_frame;
pub mod observed_write_template;
pub mod operation_status;
pub mod reference_handle;
pub mod reference_registration;
pub mod secured_write;
pub mod status;
pub mod subscription_message;
pub mod value;
pub mod write_message;
pub use envelope::{ENVELOPE_HEADER_LEN, NmxTransferEnvelope, NmxTransferMessageKind};
pub use envelope_template::NmxTransferEnvelopeTemplate;
pub use error::CodecError;
pub use item_control::{NmxItemControlCommand, NmxItemControlMessage};
pub use metadata_query::NmxMetadataQueryMessage;
pub use observed_frame::{NmxObservedEnvelope, NmxObservedMessage, NmxObservedString};
pub use observed_write_template::ObservedWriteBodyTemplate;
pub use operation_status::{NmxOperationStatusFormat, NmxOperationStatusMessage};
pub use reference_handle::{MxReferenceHandle, compute_name_signature, update_crc16_ibm};
pub use reference_registration::{
NmxReferenceRegistrationMessage, NmxReferenceRegistrationResultMessage,
};
pub use secured_write::DecodedSecuredWrite;
pub use status::{MxStatus, MxStatusCategory, MxStatusSource, detail_text};
pub use subscription_message::{NmxSubscriptionMessage, NmxSubscriptionRecord};
pub use value::{MxDataType, MxValue, MxValueKind};
// `NmxWriteMessage` and `NmxSecuredWrite2Message` are not single struct types
// in the Rust port — encoding/decoding live as functions in the
// `write_message` and `secured_write` modules. Keep stubs as short type
// aliases so existing references compile; consumers should call the module
// functions directly.
#[derive(Debug, Clone)]
pub struct NmxWriteMessage;
#[derive(Debug, Clone)]
pub struct NmxSecuredWrite2Message;
// ---- ASB types (M5 follow-up) --------------------------------------------
#[derive(Debug, Clone)]
pub struct AsbVariant;
#[derive(Debug, Clone, Copy, Default)]
pub struct AsbStatus;
#[derive(Debug, Clone)]
pub struct RuntimeValue;
// ---- Convenience prelude -------------------------------------------------
pub mod prelude {
pub use super::{
CodecError, MxDataType, MxReferenceHandle, MxStatus, MxStatusCategory, MxStatusSource,
MxValue, MxValueKind, NmxItemControlCommand, NmxItemControlMessage,
NmxOperationStatusMessage, NmxReferenceRegistrationMessage,
NmxReferenceRegistrationResultMessage, NmxSubscriptionMessage, NmxTransferEnvelope,
NmxTransferEnvelopeTemplate, NmxTransferMessageKind,
};
}