Files
Joseph Doherty fe2a6db786
rust / build / test / clippy / fmt (push) Has been cancelled
Initial project state: .NET reference, design, Rust port (M0+M1), evidence
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>
2026-05-05 06:21:00 -04:00

108 lines
7.7 KiB
C#

using System.Runtime.CompilerServices;
using ArchestrAServices.Contract;
using ArchestrAServices.Proxy;
public class CIDataVersionAdapterFactory
{
public unsafe static CIDataVersionAdapter GetIDataAdapter(string AccessName)
{
string text = null;
CIDataVersionAdapter result = null;
text = string.Empty;
object obj = IDataProxySelector.SelectProxyForLatestEndpoint(AccessName, new AsbMxDataSettings(), out text);
if (obj != null)
{
if (obj.GetType().IsAssignableFrom(typeof(ASBDataV2Proxy)))
{
result = new CIDataVersionAdapterV2((ASBDataV2Proxy)obj);
}
else if (obj.GetType().IsAssignableFrom(typeof(ASBDataProxy)))
{
result = new CIDataVersionAdapterV1((ASBDataProxy)obj);
}
}
else
{
ref byte reference = ref *(byte*)text;
if (System.Runtime.CompilerServices.Unsafe.AsPointer(ref reference) != null)
{
reference = ref *(byte*)((ref *(_003F*)RuntimeHelpers.OffsetToStringData) + (ref System.Runtime.CompilerServices.Unsafe.As<byte, _003F>(ref reference)));
}
fixed (char* ptr = &System.Runtime.CompilerServices.Unsafe.As<byte, char>(ref reference))
{
try
{
if ((global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 & 1) == 0)
{
global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 |= 1u;
try
{
global::_003CModule_003E.CWrapLogger_002E_007Bctor_007D((CWrapLogger*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A));
global::_003CModule_003E._atexit_m((delegate*<void>)(&global::_003CModule_003E._003F_003F__FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_0040YMXXZ));
}
catch
{
//try-fault
global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 &= 4294967294u;
throw;
}
}
uint* g_pLogAutoConnect = global::_003CModule_003E.g_pLogAutoConnect;
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 4)) == -1)
{
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A) == 0)
{
global::_003CModule_003E.CWrapLogger_002ELoadLoggerDLL((CWrapLogger*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A));
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A) == 0)
{
goto IL_0110;
}
}
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 156)) != 0)
{
((delegate* unmanaged[Cdecl, Cdecl]<int*, int>)(int)System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 156)))((int*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 4)));
}
goto IL_0110;
}
goto IL_012a;
IL_0110:
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 4)) != -1)
{
global::_003CModule_003E.CWrapLogger_002ESetDefaultIdentity((CWrapLogger*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A));
goto IL_012a;
}
goto end_IL_0080;
IL_012a:
if (System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 164)) != 0 && ((delegate* unmanaged[Cdecl, Cdecl]<int, uint*, uint, byte>)(int)System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 164)))(System.Runtime.CompilerServices.Unsafe.As<CWrapLogger, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A, 4)), g_pLogAutoConnect, 0u) != 0)
{
if ((global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 & 1) == 0)
{
global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 |= 1u;
try
{
global::_003CModule_003E.CWrapLogger_002E_007Bctor_007D((CWrapLogger*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A));
global::_003CModule_003E._atexit_m((delegate*<void>)(&global::_003CModule_003E._003F_003F__FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_0040YMXXZ));
}
catch
{
//try-fault
global::_003CModule_003E._003F_003F_B_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_004051 &= 4294967294u;
throw;
}
}
global::_003CModule_003E.CWrapLogger_002ELogCustom((CWrapLogger*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003FfsLogger_0040_003F1_003F_003F_GetFSLogger_0040CLoggerSelect_0040_0040SAAAVCWrapLogger_0040_0040XZ_00404V3_0040A), global::_003CModule_003E.g_pLogAutoConnect, (char*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref global::_003CModule_003E._003F_003F_C_0040_1HC_0040BNGLPIPF_0040_003F_0024AAD_003F_0024AAa_003F_0024AAt_003F_0024AAa_003F_0024AAC_003F_0024AAl_003F_0024AAi_003F_0024AAe_003F_0024AAn_003F_0024AAt_003F_0024AAP_003F_0024AAr_003F_0024AAo_003F_0024AAx_003F_0024AAy_003F_0024AA_003F3_003F_0024AA_003F3_003F_0024AAG_003F_0024AAe_003F_0024AAt_003F_0024AAI_003F_0024AAD_003F_0024AAa_003F_0024AAt_003F_0024AAa_003F_0024AAA_003F_0024AAd_003F_0024AAa_003F_0024AAp_003F_0024AAt_003F_0024AAe_003F_0024AAr_0040), __arglist((ushort*)ptr));
}
end_IL_0080:;
}
catch
{
//try-fault
ptr = null;
throw;
}
}
}
return result;
}
}