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>
141 lines
2.2 KiB
C#
141 lines
2.2 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading;
|
|
|
|
namespace msclr;
|
|
|
|
internal class @lock : IDisposable
|
|
{
|
|
[StructLayout(LayoutKind.Sequential, Size = 1)]
|
|
private struct is_not_003CSystem_003A_003AObject_002CSystem_003A_003AThreading_003A_003AReaderWriterLock_003E
|
|
{
|
|
}
|
|
|
|
private object m_object;
|
|
|
|
private bool m_locked;
|
|
|
|
public @lock(object _object)
|
|
{
|
|
m_object = _object;
|
|
m_locked = false;
|
|
base._002Ector();
|
|
acquire(-1);
|
|
}
|
|
|
|
private void _007Elock()
|
|
{
|
|
if (m_locked)
|
|
{
|
|
Monitor.Exit(m_object);
|
|
m_locked = false;
|
|
}
|
|
}
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
public bool is_locked()
|
|
{
|
|
return m_locked;
|
|
}
|
|
|
|
public implicit operator string()
|
|
{
|
|
return (!m_locked) ? _detail_class._safe_false : _detail_class._safe_true;
|
|
}
|
|
|
|
public void acquire(TimeSpan _timeout)
|
|
{
|
|
if (!m_locked)
|
|
{
|
|
Monitor.TryEnter(m_object, _timeout, ref m_locked);
|
|
if (!m_locked)
|
|
{
|
|
throw Marshal.GetExceptionForHR(-2147024638);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void acquire()
|
|
{
|
|
if (!m_locked)
|
|
{
|
|
Monitor.TryEnter(m_object, -1, ref m_locked);
|
|
if (!m_locked)
|
|
{
|
|
throw Marshal.GetExceptionForHR(-2147024638);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void acquire(int _timeout)
|
|
{
|
|
if (!m_locked)
|
|
{
|
|
Monitor.TryEnter(m_object, _timeout, ref m_locked);
|
|
if (!m_locked)
|
|
{
|
|
throw Marshal.GetExceptionForHR(-2147024638);
|
|
}
|
|
}
|
|
}
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
public bool try_acquire(TimeSpan _timeout)
|
|
{
|
|
if (!m_locked)
|
|
{
|
|
Monitor.TryEnter(m_object, _timeout, ref m_locked);
|
|
if (!m_locked)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
public bool try_acquire(int _timeout)
|
|
{
|
|
if (!m_locked)
|
|
{
|
|
Monitor.TryEnter(m_object, _timeout, ref m_locked);
|
|
if (!m_locked)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public void release()
|
|
{
|
|
if (m_locked)
|
|
{
|
|
Monitor.Exit(m_object);
|
|
m_locked = false;
|
|
}
|
|
}
|
|
|
|
protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool P_0)
|
|
{
|
|
if (P_0)
|
|
{
|
|
if (m_locked)
|
|
{
|
|
Monitor.Exit(m_object);
|
|
m_locked = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
base.Finalize();
|
|
}
|
|
}
|
|
|
|
public virtual sealed void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|