diff --git a/Cargo.lock b/Cargo.lock index 85494929f..bd6612135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1318,8 +1318,8 @@ dependencies = [ [[package]] name = "diplomat" -version = "0.7.0" -source = "git+https://github.com/CBenoit/diplomat?rev=6dc806e80162b6b39509a04a2835744236cd2396#6dc806e80162b6b39509a04a2835744236cd2396" +version = "0.15.0" +source = "git+https://github.com/irvingoujAtDevolution/diplomat.git?rev=822b0b3effd892ca5babae7c1872d8c6be0685de#822b0b3effd892ca5babae7c1872d8c6be0685de" dependencies = [ "diplomat_core", "proc-macro2", @@ -1329,21 +1329,19 @@ dependencies = [ [[package]] name = "diplomat-runtime" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0f23d549a46540e26e5490cd44c64ced0d762959f1ffdec6ab0399634cf3c" +version = "0.15.1" +source = "git+https://github.com/irvingoujAtDevolution/diplomat.git?rev=822b0b3effd892ca5babae7c1872d8c6be0685de#822b0b3effd892ca5babae7c1872d8c6be0685de" [[package]] name = "diplomat_core" -version = "0.7.0" -source = "git+https://github.com/CBenoit/diplomat?rev=6dc806e80162b6b39509a04a2835744236cd2396#6dc806e80162b6b39509a04a2835744236cd2396" +version = "0.15.0" +source = "git+https://github.com/irvingoujAtDevolution/diplomat.git?rev=822b0b3effd892ca5babae7c1872d8c6be0685de#822b0b3effd892ca5babae7c1872d8c6be0685de" dependencies = [ - "lazy_static", "proc-macro2", "quote", "serde", "smallvec", - "strck_ident", + "strck", "syn 2.0.118", ] @@ -5653,17 +5651,10 @@ checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "strck" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be91090ded9d8f979d9fe921777342d37e769e0b6b7296843a7a38247240e917" - -[[package]] -name = "strck_ident" -version = "0.1.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1c3802b169b3858a44667f221c9a0b3136e6019936ea926fc97fbad8af77202" +checksum = "42316e70da376f3d113a68d138a60d8a9883c604fe97942721ec2068dab13a9f" dependencies = [ - "strck", "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index 1df36b015..d27074bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -205,7 +205,3 @@ opt-level = 3 [profile.test.package.rand_chacha] opt-level = 3 -[patch.crates-io] -# FIXME: We need to catch up with Diplomat upstream again, but this is a significant amount of work. -# In the meantime, we use this forked version which fixes an undefined behavior in the code expanded by the bridge macro. -diplomat = { git = "https://github.com/CBenoit/diplomat", rev = "6dc806e80162b6b39509a04a2835744236cd2396" } diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index b4e6f5e54..00d67c907 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -12,8 +12,8 @@ test = false doctest = false [dependencies] -diplomat = "0.7" -diplomat-runtime = "0.7" +diplomat = { git = "https://github.com/irvingoujAtDevolution/diplomat.git", rev = "822b0b3effd892ca5babae7c1872d8c6be0685de" } +diplomat-runtime = { git = "https://github.com/irvingoujAtDevolution/diplomat.git", rev = "822b0b3effd892ca5babae7c1872d8c6be0685de" } ironrdp = { path = "../crates/ironrdp", features = ["session", "connector", "dvc", "svc", "rdpdr", "rdpsnd", "graphics", "input", "cliprdr", "displaycontrol"] } ironrdp-cliprdr-native.path = "../crates/ironrdp-cliprdr-native" ironrdp-dvc-pipe-proxy.path = "../crates/ironrdp-dvc-pipe-proxy" diff --git a/ffi/dotnet-interop-conf.toml b/ffi/dotnet-interop-conf.toml index e2c76a3af..5560c858f 100644 --- a/ffi/dotnet-interop-conf.toml +++ b/ffi/dotnet-interop-conf.toml @@ -1,10 +1,9 @@ +lib_name = "DevolutionsIronRdp" + +[dotnet] namespace = "Devolutions.IronRdp" native_lib = "DevolutionsIronRdp" - -[exceptions] -trim_suffix = "Error" -error_message_method = "ToDisplay" - -[properties] +exception_trim_suffix = "Error" +exception_message_method = "ToDisplay" setters_prefix = "set_" getters_prefix = "get_" diff --git a/ffi/dotnet/Devolutions.IronRdp.AvaloniaExample/Devolutions.IronRdp.AvaloniaExample.csproj b/ffi/dotnet/Devolutions.IronRdp.AvaloniaExample/Devolutions.IronRdp.AvaloniaExample.csproj index 802b8ad76..155f7eb05 100644 --- a/ffi/dotnet/Devolutions.IronRdp.AvaloniaExample/Devolutions.IronRdp.AvaloniaExample.csproj +++ b/ffi/dotnet/Devolutions.IronRdp.AvaloniaExample/Devolutions.IronRdp.AvaloniaExample.csproj @@ -23,5 +23,9 @@ + + DevolutionsIronRdp.dll + PreserveNewest + diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Action.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Action.cs index d83abd39e..b47a9aea4 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Action.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Action.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class Action: IDisposable { - private unsafe Raw.Action* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Action.Destroy; /// /// Creates a managed Action from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Action(Raw.Action* handle) + internal unsafe Action(Raw.Action* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Action(Raw.Action* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Action(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Action* AsFFI() + internal unsafe Raw.Action* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Action.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStage.cs index b6a0f3079..3bb682b48 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStage.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,52 @@ namespace Devolutions.IronRdp; public partial class ActiveStage: IDisposable { - private unsafe Raw.ActiveStage* _inner; + private unsafe RustHandle _inner; - public bool EnableServerPointer - { - set - { - SetEnableServerPointer(value); - } - } + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ActiveStage.Destroy; /// /// Creates a managed ActiveStage from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ActiveStage(Raw.ActiveStage* handle) + internal unsafe ActiveStage(Raw.ActiveStage* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ActiveStage(Raw.ActiveStage* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ActiveStage(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -45,30 +66,19 @@ public static ActiveStage New(ConnectionResult connectionResult) { unsafe { - Raw.ConnectionResult* connectionResultRaw; - connectionResultRaw = connectionResult.AsFFI(); - if (connectionResultRaw == null) - { - throw new ObjectDisposedException("ConnectionResult"); - } - Raw.SessionFfiResultBoxActiveStageBoxIronRdpError result = Raw.ActiveStage.New(connectionResultRaw); - if (!result.isOk) + if (connectionResult == null) throw new ArgumentNullException(nameof(connectionResult)); + Raw.ConnectionResult* connectionResultRaw = connectionResult.AsFFI(); + if (connectionResultRaw == null) throw new ObjectDisposedException(nameof(ConnectionResult)); + var result = Raw.ActiveStage.New(connectionResultRaw); + GC.KeepAlive(connectionResult); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ActiveStage* retVal = result.Ok; - return new ActiveStage(retVal); + return new ActiveStage(result.Ok); } } - /// - /// Produces a fresh connection activation sequence to drive the Deactivation-Reactivation - /// Sequence. - /// - /// - /// Call this upon receiving a [`ActiveStageOutputType::DeactivateAll`] output, drive the - /// returned sequence until it is finalized, then discard it. - /// /// /// A ConnectionActivationSequence allocated on Rust side. /// @@ -76,12 +86,13 @@ public ConnectionActivationSequence CreateConnectionActivation() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.ConnectionActivationSequence* retVal = Raw.ActiveStage.CreateConnectionActivation(_inner); - return new ConnectionActivationSequence(retVal); + Raw.ConnectionActivationSequence* result = Raw.ActiveStage.CreateConnectionActivation(AsFFI()); + GC.KeepAlive(this); + return new ConnectionActivationSequence(result); } } @@ -93,32 +104,28 @@ public ActiveStageOutputIterator Process(DecodedImage image, Action action, byte { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - nuint payloadLength = (nuint)payload.Length; - Raw.DecodedImage* imageRaw; - imageRaw = image.AsFFI(); - if (imageRaw == null) - { - throw new ObjectDisposedException("DecodedImage"); - } - Raw.Action* actionRaw; - actionRaw = action.AsFFI(); - if (actionRaw == null) - { - throw new ObjectDisposedException("Action"); - } + if (image == null) throw new ArgumentNullException(nameof(image)); + Raw.DecodedImage* imageRaw = image.AsFFI(); + if (imageRaw == null) throw new ObjectDisposedException(nameof(DecodedImage)); + if (action == null) throw new ArgumentNullException(nameof(action)); + Raw.Action* actionRaw = action.AsFFI(); + if (actionRaw == null) throw new ObjectDisposedException(nameof(Action)); + if (payload == null) throw new ArgumentNullException(nameof(payload)); fixed (byte* payloadPtr = payload) { - Raw.SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError result = Raw.ActiveStage.Process(_inner, imageRaw, actionRaw, payloadPtr, payloadLength); - if (!result.isOk) + var result = Raw.ActiveStage.Process(AsFFI(), imageRaw, actionRaw, new DiplomatSliceU8 { Ptr = payloadPtr, Len = (nuint)payload.Length }); + GC.KeepAlive(this); + GC.KeepAlive(image); + GC.KeepAlive(action); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ActiveStageOutputIterator* retVal = result.Ok; - return new ActiveStageOutputIterator(retVal); + return new ActiveStageOutputIterator(result.Ok); } } } @@ -131,29 +138,25 @@ public ActiveStageOutputIterator ProcessFastpathInput(DecodedImage image, FastPa { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.DecodedImage* imageRaw; - imageRaw = image.AsFFI(); - if (imageRaw == null) - { - throw new ObjectDisposedException("DecodedImage"); - } - Raw.FastPathInputEventIterator* fastpathInputRaw; - fastpathInputRaw = fastpathInput.AsFFI(); - if (fastpathInputRaw == null) - { - throw new ObjectDisposedException("FastPathInputEventIterator"); - } - Raw.SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError result = Raw.ActiveStage.ProcessFastpathInput(_inner, imageRaw, fastpathInputRaw); - if (!result.isOk) + if (image == null) throw new ArgumentNullException(nameof(image)); + Raw.DecodedImage* imageRaw = image.AsFFI(); + if (imageRaw == null) throw new ObjectDisposedException(nameof(DecodedImage)); + if (fastpathInput == null) throw new ArgumentNullException(nameof(fastpathInput)); + Raw.FastPathInputEventIterator* fastpathInputRaw = fastpathInput.AsFFI(); + if (fastpathInputRaw == null) throw new ObjectDisposedException(nameof(FastPathInputEventIterator)); + var result = Raw.ActiveStage.ProcessFastpathInput(AsFFI(), imageRaw, fastpathInputRaw); + GC.KeepAlive(this); + GC.KeepAlive(image); + GC.KeepAlive(fastpathInput); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ActiveStageOutputIterator* retVal = result.Ok; - return new ActiveStageOutputIterator(retVal); + return new ActiveStageOutputIterator(result.Ok); } } @@ -165,23 +168,21 @@ public VecU8 InitiateClipboardCopy(ClipboardFormatIterator formats) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.ClipboardFormatIterator* formatsRaw; - formatsRaw = formats.AsFFI(); - if (formatsRaw == null) - { - throw new ObjectDisposedException("ClipboardFormatIterator"); - } - Raw.SessionFfiResultBoxVecU8BoxIronRdpError result = Raw.ActiveStage.InitiateClipboardCopy(_inner, formatsRaw); - if (!result.isOk) + if (formats == null) throw new ArgumentNullException(nameof(formats)); + Raw.ClipboardFormatIterator* formatsRaw = formats.AsFFI(); + if (formatsRaw == null) throw new ObjectDisposedException(nameof(ClipboardFormatIterator)); + var result = Raw.ActiveStage.InitiateClipboardCopy(AsFFI(), formatsRaw); + GC.KeepAlive(this); + GC.KeepAlive(formats); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } @@ -193,23 +194,21 @@ public VecU8 InitiateClipboardPaste(ClipboardFormatId formatId) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.ClipboardFormatId* formatIdRaw; - formatIdRaw = formatId.AsFFI(); - if (formatIdRaw == null) - { - throw new ObjectDisposedException("ClipboardFormatId"); - } - Raw.SessionFfiResultBoxVecU8BoxIronRdpError result = Raw.ActiveStage.InitiateClipboardPaste(_inner, formatIdRaw); - if (!result.isOk) + if (formatId == null) throw new ArgumentNullException(nameof(formatId)); + Raw.ClipboardFormatId* formatIdRaw = formatId.AsFFI(); + if (formatIdRaw == null) throw new ObjectDisposedException(nameof(ClipboardFormatId)); + var result = Raw.ActiveStage.InitiateClipboardPaste(AsFFI(), formatIdRaw); + GC.KeepAlive(this); + GC.KeepAlive(formatId); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } @@ -221,23 +220,21 @@ public VecU8 SubmitClipboardFormatData(FormatDataResponse formatDataResponse) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.FormatDataResponse* formatDataResponseRaw; - formatDataResponseRaw = formatDataResponse.AsFFI(); - if (formatDataResponseRaw == null) - { - throw new ObjectDisposedException("FormatDataResponse"); - } - Raw.SessionFfiResultBoxVecU8BoxIronRdpError result = Raw.ActiveStage.SubmitClipboardFormatData(_inner, formatDataResponseRaw); - if (!result.isOk) + if (formatDataResponse == null) throw new ArgumentNullException(nameof(formatDataResponse)); + Raw.FormatDataResponse* formatDataResponseRaw = formatDataResponse.AsFFI(); + if (formatDataResponseRaw == null) throw new ObjectDisposedException(nameof(FormatDataResponse)); + var result = Raw.ActiveStage.SubmitClipboardFormatData(AsFFI(), formatDataResponseRaw); + GC.KeepAlive(this); + GC.KeepAlive(formatDataResponse); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } @@ -249,23 +246,21 @@ public VecU8 SendDvcPipeProxyMessage(DvcPipeProxyMessage message) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.DvcPipeProxyMessage* messageRaw; - messageRaw = message.AsFFI(); - if (messageRaw == null) - { - throw new ObjectDisposedException("DvcPipeProxyMessage"); - } - Raw.SessionFfiResultBoxVecU8BoxIronRdpError result = Raw.ActiveStage.SendDvcPipeProxyMessage(_inner, messageRaw); - if (!result.isOk) + if (message == null) throw new ArgumentNullException(nameof(message)); + Raw.DvcPipeProxyMessage* messageRaw = message.AsFFI(); + if (messageRaw == null) throw new ObjectDisposedException(nameof(DvcPipeProxyMessage)); + var result = Raw.ActiveStage.SendDvcPipeProxyMessage(AsFFI(), messageRaw); + GC.KeepAlive(this); + GC.KeepAlive(message); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } @@ -277,17 +272,17 @@ public ActiveStageOutputIterator GracefulShutdown() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError result = Raw.ActiveStage.GracefulShutdown(_inner); - if (!result.isOk) + var result = Raw.ActiveStage.GracefulShutdown(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ActiveStageOutputIterator* retVal = result.Ok; - return new ActiveStageOutputIterator(retVal); + return new ActiveStageOutputIterator(result.Ok); } } @@ -295,25 +290,21 @@ public ActiveStageOutputIterator GracefulShutdown() /// /// A ActiveStageOutputIterator allocated on Rust side. /// - public ActiveStageOutputIterator EncodedResize(uint width, uint height) + public ActiveStageOutputIterator? EncodedResize(uint width, uint height) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.SessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError result = Raw.ActiveStage.EncodedResize(_inner, width, height); - if (!result.isOk) + var result = Raw.ActiveStage.EncodedResize(AsFFI(), width, height); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ActiveStageOutputIterator* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new ActiveStageOutputIterator(retVal); + return result.Ok == null ? null : new ActiveStageOutputIterator(result.Ok); } } @@ -321,11 +312,12 @@ public void SetFastpathProcessor(ushort ioChannelId, ushort userChannelId, uint { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.ActiveStage.SetFastpathProcessor(_inner, ioChannelId, userChannelId, shareId, enableServerPointer, pointerSoftwareRendering); + Raw.ActiveStage.SetFastpathProcessor(AsFFI(), ioChannelId, userChannelId, shareId, enableServerPointer, pointerSoftwareRendering); + GC.KeepAlive(this); } } @@ -333,20 +325,21 @@ public void SetEnableServerPointer(bool enableServerPointer) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStage"); } - Raw.ActiveStage.SetEnableServerPointer(_inner, enableServerPointer); + Raw.ActiveStage.SetEnableServerPointer(AsFFI(), enableServerPointer); + GC.KeepAlive(this); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ActiveStage* AsFFI() + internal unsafe Raw.ActiveStage* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -356,13 +349,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ActiveStage.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -372,4 +366,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutput.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutput.cs index a9f5f82a4..388f5a886 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutput.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutput.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ActiveStageOutput: IDisposable { - private unsafe Raw.ActiveStageOutput* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ActiveStageOutput.Destroy; public NetworkCharacteristics AutodetectNetworkCharacteristics { @@ -63,6 +68,10 @@ public Position PointerPosition } } + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice ResponseFrame { get @@ -83,29 +92,51 @@ public GracefulDisconnectReason Terminate /// Creates a managed ActiveStageOutput from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ActiveStageOutput(Raw.ActiveStageOutput* handle) + internal unsafe ActiveStageOutput(Raw.ActiveStageOutput* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ActiveStageOutput(Raw.ActiveStageOutput* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ActiveStageOutput(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } - /// - /// A ActiveStageOutputType allocated on C# side. - /// public ActiveStageOutputType GetEnumType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.ActiveStageOutputType retVal = Raw.ActiveStageOutput.GetEnumType(_inner); - return (ActiveStageOutputType)retVal; + var result = Raw.ActiveStageOutput.GetEnumType(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -113,21 +144,25 @@ public ActiveStageOutputType GetEnumType() /// /// A BytesSlice allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice GetResponseFrame() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultBoxBytesSliceBoxIronRdpError result = Raw.ActiveStageOutput.GetResponseFrame(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetResponseFrame(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.BytesSlice* retVal = result.Ok; - return new BytesSlice(retVal); + return new BytesSlice(result.Ok, new object[] { this }); } } @@ -139,39 +174,36 @@ public InclusiveRectangle GetGraphicsUpdate() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultBoxInclusiveRectangleBoxIronRdpError result = Raw.ActiveStageOutput.GetGraphicsUpdate(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetGraphicsUpdate(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.InclusiveRectangle* retVal = result.Ok; - return new InclusiveRectangle(retVal); + return new InclusiveRectangle(result.Ok); } } /// - /// - /// A Position allocated on C# side. - /// public Position GetPointerPosition() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultPositionBoxIronRdpError result = Raw.ActiveStageOutput.GetPointerPosition(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetPointerPosition(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Position retVal = result.Ok; - return new Position(retVal); + return Position.FromFFI(result.Ok); } } @@ -183,17 +215,17 @@ public DecodedPointer GetPointerBitmap() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultBoxDecodedPointerBoxIronRdpError result = Raw.ActiveStageOutput.GetPointerBitmap(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetPointerBitmap(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.DecodedPointer* retVal = result.Ok; - return new DecodedPointer(retVal); + return new DecodedPointer(result.Ok); } } @@ -205,83 +237,64 @@ public GracefulDisconnectReason GetTerminate() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError result = Raw.ActiveStageOutput.GetTerminate(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetTerminate(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.GracefulDisconnectReason* retVal = result.Ok; - return new GracefulDisconnectReason(retVal); + return new GracefulDisconnectReason(result.Ok); } } - /// - /// Returns the multitransport request ID and requested protocol. - /// - /// - /// The security cookie is intentionally not exposed — it is sensitive - /// and only needed internally for transport binding. - /// /// - /// - /// A MultitransportRequest allocated on C# side. - /// public MultitransportRequest GetMultitransportRequest() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultMultitransportRequestBoxIronRdpError result = Raw.ActiveStageOutput.GetMultitransportRequest(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetMultitransportRequest(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.MultitransportRequest retVal = result.Ok; - return new MultitransportRequest(retVal); + return MultitransportRequest.FromFFI(result.Ok); } } - /// - /// Connection quality signals from the server's auto-detect mechanism. - /// Returns RTT and bandwidth measurements for health monitoring. - /// These values will feed into FramePacingFeedback when the - /// library-level health observer traits from #1158 land. - /// /// - /// - /// A NetworkCharacteristics allocated on C# side. - /// public NetworkCharacteristics GetAutodetectNetworkCharacteristics() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutput"); } - Raw.SessionFfiResultNetworkCharacteristicsBoxIronRdpError result = Raw.ActiveStageOutput.GetAutodetectNetworkCharacteristics(_inner); - if (!result.isOk) + var result = Raw.ActiveStageOutput.GetAutodetectNetworkCharacteristics(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.NetworkCharacteristics retVal = result.Ok; - return new NetworkCharacteristics(retVal); + return NetworkCharacteristics.FromFFI(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ActiveStageOutput* AsFFI() + internal unsafe Raw.ActiveStageOutput* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -291,13 +304,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ActiveStageOutput.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -307,4 +321,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputIterator.cs index b36097c6e..913a24acc 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputIterator.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,32 +10,65 @@ namespace Devolutions.IronRdp; public partial class ActiveStageOutputIterator: IDisposable { - private unsafe Raw.ActiveStageOutputIterator* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ActiveStageOutputIterator.Destroy; /// /// Creates a managed ActiveStageOutputIterator from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ActiveStageOutputIterator(Raw.ActiveStageOutputIterator* handle) + internal unsafe ActiveStageOutputIterator(Raw.ActiveStageOutputIterator* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ActiveStageOutputIterator(Raw.ActiveStageOutputIterator* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ActiveStageOutputIterator(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } public nuint Len() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutputIterator"); } - nuint retVal = Raw.ActiveStageOutputIterator.Len(_inner); - return retVal; + var result = Raw.ActiveStageOutputIterator.Len(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -46,12 +76,13 @@ public bool IsEmpty() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutputIterator"); } - bool retVal = Raw.ActiveStageOutputIterator.IsEmpty(_inner); - return retVal; + var result = Raw.ActiveStageOutputIterator.IsEmpty(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -62,25 +93,22 @@ public bool IsEmpty() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ActiveStageOutputIterator"); } - Raw.ActiveStageOutput* retVal = Raw.ActiveStageOutputIterator.Next(_inner); - if (retVal == null) - { - return null; - } - return new ActiveStageOutput(retVal); + Raw.ActiveStageOutput* result = Raw.ActiveStageOutputIterator.Next(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new ActiveStageOutput(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ActiveStageOutputIterator* AsFFI() + internal unsafe Raw.ActiveStageOutputIterator* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -90,13 +118,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ActiveStageOutputIterator.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -106,4 +135,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputType.cs index 1b3f99553..b1261d0b5 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ActiveStageOutputType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum ActiveStageOutputType +public enum ActiveStageOutputType : int { ResponseFrame = 0, GraphicsUpdate = 1, @@ -22,10 +11,5 @@ public enum ActiveStageOutputType Terminate = 6, DeactivateAll = 7, MultitransportRequest = 8, - /// - /// Auto-detect network characteristics from server. - /// Use `get_autodetect_network_characteristics()` to retrieve - /// RTT and bandwidth values for connection quality monitoring. - /// AutoDetect = 9, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/BitmapConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/BitmapConfig.cs index e3d932525..e8b29858b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/BitmapConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/BitmapConfig.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class BitmapConfig: IDisposable { - private unsafe Raw.BitmapConfig* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.BitmapConfig.Destroy; /// /// Creates a managed BitmapConfig from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe BitmapConfig(Raw.BitmapConfig* handle) + internal unsafe BitmapConfig(Raw.BitmapConfig* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe BitmapConfig(Raw.BitmapConfig* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe BitmapConfig(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.BitmapConfig* AsFFI() + internal unsafe Raw.BitmapConfig* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.BitmapConfig.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/BytesSlice.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/BytesSlice.cs index a3f27f5af..12c8d1ead 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/BytesSlice.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/BytesSlice.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class BytesSlice: IDisposable { - private unsafe Raw.BytesSlice* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.BytesSlice.Destroy; public nuint Size { @@ -27,26 +32,51 @@ public nuint Size /// Creates a managed BytesSlice from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe BytesSlice(Raw.BytesSlice* handle) + internal unsafe BytesSlice(Raw.BytesSlice* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe BytesSlice(Raw.BytesSlice* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe BytesSlice(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public nuint GetSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("BytesSlice"); } - nuint retVal = Raw.BytesSlice.GetSize(_inner); - return retVal; + var result = Raw.BytesSlice.GetSize(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -55,18 +85,20 @@ public void Fill(byte[] buffer) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("BytesSlice"); } - nuint bufferLength = (nuint)buffer.Length; + if (buffer == null) throw new ArgumentNullException(nameof(buffer)); fixed (byte* bufferPtr = buffer) { - Raw.UtilsFfiResultVoidBoxIronRdpError result = Raw.BytesSlice.Fill(_inner, bufferPtr, bufferLength); - if (!result.isOk) + var result = Raw.BytesSlice.Fill(AsFFI(), new DiplomatSliceMutU8 { Ptr = bufferPtr, Len = (nuint)buffer.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } } @@ -74,9 +106,9 @@ public void Fill(byte[] buffer) /// /// Returns the underlying raw handle. /// - public unsafe Raw.BytesSlice* AsFFI() + internal unsafe Raw.BytesSlice* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -86,13 +118,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.BytesSlice.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -102,4 +135,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/CertificateChainIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/CertificateChainIterator.cs index 9830d732d..a47e2dcb0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/CertificateChainIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/CertificateChainIterator.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class CertificateChainIterator: IDisposable { - private unsafe Raw.CertificateChainIterator* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.CertificateChainIterator.Destroy; /// /// Creates a managed CertificateChainIterator from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe CertificateChainIterator(Raw.CertificateChainIterator* handle) + internal unsafe CertificateChainIterator(Raw.CertificateChainIterator* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe CertificateChainIterator(Raw.CertificateChainIterator* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe CertificateChainIterator(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -36,16 +65,13 @@ public unsafe CertificateChainIterator(Raw.CertificateChainIterator* handle) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CertificateChainIterator"); } - Raw.VecU8* retVal = Raw.CertificateChainIterator.Next(_inner); - if (retVal == null) - { - return null; - } - return new VecU8(retVal); + Raw.VecU8* result = Raw.CertificateChainIterator.Next(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new VecU8(result); } } @@ -53,12 +79,13 @@ public nuint Len() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CertificateChainIterator"); } - nuint retVal = Raw.CertificateChainIterator.Len(_inner); - return retVal; + var result = Raw.CertificateChainIterator.Len(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -66,21 +93,22 @@ public bool IsEmpty() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CertificateChainIterator"); } - bool retVal = Raw.CertificateChainIterator.IsEmpty(_inner); - return retVal; + var result = Raw.CertificateChainIterator.IsEmpty(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.CertificateChainIterator* AsFFI() + internal unsafe Raw.CertificateChainIterator* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -90,13 +118,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.CertificateChainIterator.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -106,4 +135,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ChannelConnectionSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ChannelConnectionSequence.cs index 19231a2c1..03acc5035 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ChannelConnectionSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ChannelConnectionSequence.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class ChannelConnectionSequence: IDisposable { - private unsafe Raw.ChannelConnectionSequence* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ChannelConnectionSequence.Destroy; /// /// Creates a managed ChannelConnectionSequence from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ChannelConnectionSequence(Raw.ChannelConnectionSequence* handle) + internal unsafe ChannelConnectionSequence(Raw.ChannelConnectionSequence* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ChannelConnectionSequence(Raw.ChannelConnectionSequence* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ChannelConnectionSequence(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ChannelConnectionSequence* AsFFI() + internal unsafe Raw.ChannelConnectionSequence* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ChannelConnectionSequence.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Char.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Char.cs index 41b58453a..6ee7f32e6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Char.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Char.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class Char: IDisposable { - private unsafe Raw.Char* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Char.Destroy; /// /// Creates a managed Char from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Char(Raw.Char* handle) + internal unsafe Char(Raw.Char* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Char(Raw.Char* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Char(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -37,13 +66,12 @@ public static Char New(uint c) { unsafe { - Raw.InputFfiResultBoxCharBoxIronRdpError result = Raw.Char.New(c); - if (!result.isOk) + var result = Raw.Char.New(c); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Char* retVal = result.Ok; - return new Char(retVal); + return new Char(result.Ok); } } @@ -54,12 +82,13 @@ public Operation AsOperationUnicodeKeyPressed() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Char"); } - Raw.Operation* retVal = Raw.Char.AsOperationUnicodeKeyPressed(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.Char.AsOperationUnicodeKeyPressed(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } @@ -70,21 +99,22 @@ public Operation AsOperationUnicodeKeyReleased() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Char"); } - Raw.Operation* retVal = Raw.Char.AsOperationUnicodeKeyReleased(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.Char.AsOperationUnicodeKeyReleased(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Char* AsFFI() + internal unsafe Raw.Char* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -94,13 +124,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Char.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -110,4 +141,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnector.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnector.cs index dc9e45c21..d892bdc1f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnector.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnector.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,8 +10,20 @@ namespace Devolutions.IronRdp; public partial class ClientConnector: IDisposable { - private unsafe Raw.ClientConnector* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClientConnector.Destroy; + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public DynState DynState { get @@ -27,14 +36,38 @@ public DynState DynState /// Creates a managed ClientConnector from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClientConnector(Raw.ClientConnector* handle) + internal unsafe ClientConnector(Raw.ClientConnector* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClientConnector(Raw.ClientConnector* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClientConnector(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -45,68 +78,63 @@ public static ClientConnector New(Config config, string clientAddr) { unsafe { - byte[] clientAddrBuf = DiplomatUtils.StringToUtf8(clientAddr); - nuint clientAddrBufLength = (nuint)clientAddrBuf.Length; - Raw.Config* configRaw; - configRaw = config.AsFFI(); - if (configRaw == null) - { - throw new ObjectDisposedException("Config"); - } - fixed (byte* clientAddrBufPtr = clientAddrBuf) - { - Raw.ConnectorFfiResultBoxClientConnectorBoxIronRdpError result = Raw.ClientConnector.New(configRaw, clientAddrBufPtr, clientAddrBufLength); - if (!result.isOk) + if (config == null) throw new ArgumentNullException(nameof(config)); + Raw.Config* configRaw = config.AsFFI(); + if (configRaw == null) throw new ObjectDisposedException(nameof(Config)); + if (clientAddr == null) throw new ArgumentNullException(nameof(clientAddr)); + byte[] clientAddrBytes = Diplomat.Utf8.Clone(clientAddr); + fixed (byte* clientAddrPtr = clientAddrBytes) + { + var result = Raw.ClientConnector.New(configRaw, new DiplomatSliceU8 { Ptr = clientAddrPtr, Len = (nuint)clientAddrBytes.Length }); + GC.KeepAlive(config); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClientConnector* retVal = result.Ok; - return new ClientConnector(retVal); + return new ClientConnector(result.Ok); } } } - /// - /// Must use - /// /// public void WithStaticChannelRdpSnd() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithStaticChannelRdpSnd(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.WithStaticChannelRdpSnd(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } - /// - /// Must use - /// /// public void WithStaticChannelRdpdr(string computerName, uint smartCardDeviceId) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - byte[] computerNameBuf = DiplomatUtils.StringToUtf8(computerName); - nuint computerNameBufLength = (nuint)computerNameBuf.Length; - fixed (byte* computerNameBufPtr = computerNameBuf) + if (computerName == null) throw new ArgumentNullException(nameof(computerName)); + byte[] computerNameBytes = Diplomat.Utf8.Clone(computerName); + fixed (byte* computerNamePtr = computerNameBytes) { - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithStaticChannelRdpdr(_inner, computerNameBufPtr, computerNameBufLength, smartCardDeviceId); - if (!result.isOk) + var result = Raw.ClientConnector.WithStaticChannelRdpdr(AsFFI(), new DiplomatSliceU8 { Ptr = computerNamePtr, Len = (nuint)computerNameBytes.Length }, smartCardDeviceId); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } } @@ -116,15 +144,17 @@ public void WithDynamicChannelDisplayControl() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithDynamicChannelDisplayControl(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.WithDynamicChannelDisplayControl(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } @@ -133,21 +163,21 @@ public void WithDynamicChannelPipeProxy(DvcPipeProxyConfig config) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.DvcPipeProxyConfig* configRaw; - configRaw = config.AsFFI(); - if (configRaw == null) - { - throw new ObjectDisposedException("DvcPipeProxyConfig"); - } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.WithDynamicChannelPipeProxy(_inner, configRaw); - if (!result.isOk) + if (config == null) throw new ArgumentNullException(nameof(config)); + Raw.DvcPipeProxyConfig* configRaw = config.AsFFI(); + if (configRaw == null) throw new ObjectDisposedException(nameof(DvcPipeProxyConfig)); + var result = Raw.ClientConnector.WithDynamicChannelPipeProxy(AsFFI(), configRaw); + GC.KeepAlive(this); + GC.KeepAlive(config); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } @@ -156,17 +186,17 @@ public bool ShouldPerformSecurityUpgrade() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultBoolBoxIronRdpError result = Raw.ClientConnector.ShouldPerformSecurityUpgrade(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.ShouldPerformSecurityUpgrade(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - bool retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -175,15 +205,17 @@ public void MarkSecurityUpgradeAsDone() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.MarkSecurityUpgradeAsDone(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.MarkSecurityUpgradeAsDone(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } @@ -192,17 +224,17 @@ public bool ShouldPerformCredssp() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultBoolBoxIronRdpError result = Raw.ClientConnector.ShouldPerformCredssp(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.ShouldPerformCredssp(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - bool retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -211,15 +243,17 @@ public void MarkCredsspAsDone() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.MarkCredsspAsDone(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.MarkCredsspAsDone(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } @@ -231,26 +265,24 @@ public Written Step(byte[] input, WriteBuf writeBuf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - nuint inputLength = (nuint)input.Length; - Raw.WriteBuf* writeBufRaw; - writeBufRaw = writeBuf.AsFFI(); - if (writeBufRaw == null) - { - throw new ObjectDisposedException("WriteBuf"); - } + if (input == null) throw new ArgumentNullException(nameof(input)); + if (writeBuf == null) throw new ArgumentNullException(nameof(writeBuf)); + Raw.WriteBuf* writeBufRaw = writeBuf.AsFFI(); + if (writeBufRaw == null) throw new ObjectDisposedException(nameof(WriteBuf)); fixed (byte* inputPtr = input) { - Raw.ConnectorFfiResultBoxWrittenBoxIronRdpError result = Raw.ClientConnector.Step(_inner, inputPtr, inputLength, writeBufRaw); - if (!result.isOk) + var result = Raw.ClientConnector.Step(AsFFI(), new DiplomatSliceU8 { Ptr = inputPtr, Len = (nuint)input.Length }, writeBufRaw); + GC.KeepAlive(this); + GC.KeepAlive(writeBuf); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Written* retVal = result.Ok; - return new Written(retVal); + return new Written(result.Ok); } } } @@ -263,23 +295,21 @@ public Written StepNoInput(WriteBuf writeBuf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.WriteBuf* writeBufRaw; - writeBufRaw = writeBuf.AsFFI(); - if (writeBufRaw == null) - { - throw new ObjectDisposedException("WriteBuf"); - } - Raw.ConnectorFfiResultBoxWrittenBoxIronRdpError result = Raw.ClientConnector.StepNoInput(_inner, writeBufRaw); - if (!result.isOk) + if (writeBuf == null) throw new ArgumentNullException(nameof(writeBuf)); + Raw.WriteBuf* writeBufRaw = writeBuf.AsFFI(); + if (writeBufRaw == null) throw new ObjectDisposedException(nameof(WriteBuf)); + var result = Raw.ClientConnector.StepNoInput(AsFFI(), writeBufRaw); + GC.KeepAlive(this); + GC.KeepAlive(writeBuf); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Written* retVal = result.Ok; - return new Written(retVal); + return new Written(result.Ok); } } @@ -288,21 +318,21 @@ public void AttachStaticCliprdr(Cliprdr cliprdr) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.Cliprdr* cliprdrRaw; - cliprdrRaw = cliprdr.AsFFI(); - if (cliprdrRaw == null) - { - throw new ObjectDisposedException("Cliprdr"); - } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.ClientConnector.AttachStaticCliprdr(_inner, cliprdrRaw); - if (!result.isOk) + if (cliprdr == null) throw new ArgumentNullException(nameof(cliprdr)); + Raw.Cliprdr* cliprdrRaw = cliprdr.AsFFI(); + if (cliprdrRaw == null) throw new ObjectDisposedException(nameof(Cliprdr)); + var result = Raw.ClientConnector.AttachStaticCliprdr(AsFFI(), cliprdrRaw); + GC.KeepAlive(this); + GC.KeepAlive(cliprdr); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } @@ -310,25 +340,25 @@ public void AttachStaticCliprdr(Cliprdr cliprdr) /// /// A PduHint allocated on Rust side. /// - public PduHint NextPduHint() + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// + public PduHint? NextPduHint() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultOptBoxPduHintBoxIronRdpError result = Raw.ClientConnector.NextPduHint(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.NextPduHint(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.PduHint* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new PduHint(retVal); + return result.Ok == null ? null : new PduHint(result.Ok, new object[] { this }); } } @@ -336,21 +366,25 @@ public PduHint NextPduHint() /// /// A DynState allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public DynState GetDynState() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultBoxDynStateBoxIronRdpError result = Raw.ClientConnector.GetDynState(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.GetDynState(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.DynState* retVal = result.Ok; - return new DynState(retVal); + return new DynState(result.Ok, new object[] { this }); } } @@ -362,26 +396,26 @@ public ClientConnectorState ConsumeAndCastToClientConnectorState() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnector"); } - Raw.ConnectorFfiResultBoxClientConnectorStateBoxIronRdpError result = Raw.ClientConnector.ConsumeAndCastToClientConnectorState(_inner); - if (!result.isOk) + var result = Raw.ClientConnector.ConsumeAndCastToClientConnectorState(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClientConnectorState* retVal = result.Ok; - return new ClientConnectorState(retVal); + return new ClientConnectorState(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClientConnector* AsFFI() + internal unsafe Raw.ClientConnector* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -391,13 +425,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClientConnector.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -407,4 +442,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorState.cs index ba2bb0301..821b55713 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorState.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ClientConnectorState: IDisposable { - private unsafe Raw.ClientConnectorState* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClientConnectorState.Destroy; public SecurityProtocol BasicSettingsExchangeSendInitialSelectedProtocol { @@ -83,35 +88,56 @@ public ClientConnectorStateType EnumType /// Creates a managed ClientConnectorState from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClientConnectorState(Raw.ClientConnectorState* handle) + internal unsafe ClientConnectorState(Raw.ClientConnectorState* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClientConnectorState(Raw.ClientConnectorState* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClientConnectorState(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// - /// - /// A ClientConnectorStateType allocated on C# side. - /// public ClientConnectorStateType GetEnumType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError result = Raw.ClientConnectorState.GetEnumType(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetEnumType(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClientConnectorStateType retVal = result.Ok; - return (ClientConnectorStateType)retVal; + return result.Ok; } } @@ -123,17 +149,17 @@ public SecurityProtocol GetConnectionInitiationWaitConfirmRequestedProtocol() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetConnectionInitiationWaitConfirmRequestedProtocol(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetConnectionInitiationWaitConfirmRequestedProtocol(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.SecurityProtocol* retVal = result.Ok; - return new SecurityProtocol(retVal); + return new SecurityProtocol(result.Ok); } } @@ -145,17 +171,17 @@ public SecurityProtocol GetEnhancedSecurityUpgradeSelectedProtocol() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetEnhancedSecurityUpgradeSelectedProtocol(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetEnhancedSecurityUpgradeSelectedProtocol(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.SecurityProtocol* retVal = result.Ok; - return new SecurityProtocol(retVal); + return new SecurityProtocol(result.Ok); } } @@ -167,17 +193,17 @@ public SecurityProtocol GetCredsspSelectedProtocol() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetCredsspSelectedProtocol(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetCredsspSelectedProtocol(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.SecurityProtocol* retVal = result.Ok; - return new SecurityProtocol(retVal); + return new SecurityProtocol(result.Ok); } } @@ -189,17 +215,17 @@ public SecurityProtocol GetBasicSettingsExchangeSendInitialSelectedProtocol() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetBasicSettingsExchangeSendInitialSelectedProtocol(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetBasicSettingsExchangeSendInitialSelectedProtocol(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.SecurityProtocol* retVal = result.Ok; - return new SecurityProtocol(retVal); + return new SecurityProtocol(result.Ok); } } @@ -211,17 +237,17 @@ public ConnectInitial GetBasicSettingsExchangeWaitResponseConnectInitial() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxConnectInitialBoxIronRdpError result = Raw.ClientConnectorState.GetBasicSettingsExchangeWaitResponseConnectInitial(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetBasicSettingsExchangeWaitResponseConnectInitial(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ConnectInitial* retVal = result.Ok; - return new ConnectInitial(retVal); + return new ConnectInitial(result.Ok); } } @@ -233,17 +259,17 @@ public ConnectionResult GetConnectedResult() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxConnectionResultBoxIronRdpError result = Raw.ClientConnectorState.GetConnectedResult(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetConnectedResult(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ConnectionResult* retVal = result.Ok; - return new ConnectionResult(retVal); + return new ConnectionResult(result.Ok); } } @@ -255,26 +281,26 @@ public ConnectionActivationSequence GetConnectionFinalizationResult() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientConnectorState"); } - Raw.ConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError result = Raw.ClientConnectorState.GetConnectionFinalizationResult(_inner); - if (!result.isOk) + var result = Raw.ClientConnectorState.GetConnectionFinalizationResult(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ConnectionActivationSequence* retVal = result.Ok; - return new ConnectionActivationSequence(retVal); + return new ConnectionActivationSequence(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClientConnectorState* AsFFI() + internal unsafe Raw.ClientConnectorState* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -284,13 +310,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClientConnectorState.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -300,4 +327,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorStateType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorStateType.cs index 27a5199e8..ea7a0382c 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorStateType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientConnectorStateType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum ClientConnectorStateType +public enum ClientConnectorStateType : int { Consumed = 0, ConnectionInitiationSendRequest = 1, @@ -28,4 +17,4 @@ public enum ClientConnectorStateType CapabilitiesExchange = 12, ConnectionFinalization = 13, Connected = 14, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientState.cs index 7b52b51e5..4d4e47912 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClientState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClientState.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ClientState: IDisposable { - private unsafe Raw.ClientState* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClientState.Destroy; public TsRequest TsRequest { @@ -27,26 +32,51 @@ public TsRequest TsRequest /// Creates a managed ClientState from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClientState(Raw.ClientState* handle) + internal unsafe ClientState(Raw.ClientState* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClientState(Raw.ClientState* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClientState(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public bool IsReplyNeeded() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientState"); } - bool retVal = Raw.ClientState.IsReplyNeeded(_inner); - return retVal; + var result = Raw.ClientState.IsReplyNeeded(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -54,12 +84,13 @@ public bool IsFinalMessage() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientState"); } - bool retVal = Raw.ClientState.IsFinalMessage(_inner); - return retVal; + var result = Raw.ClientState.IsFinalMessage(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -71,26 +102,26 @@ public TsRequest GetTsRequest() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClientState"); } - Raw.CredsspNetworkFfiResultBoxTsRequestBoxIronRdpError result = Raw.ClientState.GetTsRequest(_inner); - if (!result.isOk) + var result = Raw.ClientState.GetTsRequest(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.TsRequest* retVal = result.Ok; - return new TsRequest(retVal); + return new TsRequest(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClientState* AsFFI() + internal unsafe Raw.ClientState* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -100,13 +131,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClientState.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -116,4 +148,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatId.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatId.cs index 29fdadac5..8316d4e19 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatId.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatId.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class ClipboardFormatId: IDisposable { - private unsafe Raw.ClipboardFormatId* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClipboardFormatId.Destroy; /// /// Creates a managed ClipboardFormatId from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClipboardFormatId(Raw.ClipboardFormatId* handle) + internal unsafe ClipboardFormatId(Raw.ClipboardFormatId* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClipboardFormatId(Raw.ClipboardFormatId* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClipboardFormatId(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClipboardFormatId* AsFFI() + internal unsafe Raw.ClipboardFormatId* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClipboardFormatId.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatIterator.cs index 1c44bb9db..dc925b424 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardFormatIterator.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class ClipboardFormatIterator: IDisposable { - private unsafe Raw.ClipboardFormatIterator* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClipboardFormatIterator.Destroy; /// /// Creates a managed ClipboardFormatIterator from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClipboardFormatIterator(Raw.ClipboardFormatIterator* handle) + internal unsafe ClipboardFormatIterator(Raw.ClipboardFormatIterator* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClipboardFormatIterator(Raw.ClipboardFormatIterator* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClipboardFormatIterator(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClipboardFormatIterator* AsFFI() + internal unsafe Raw.ClipboardFormatIterator* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClipboardFormatIterator.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessage.cs index f8af20d66..3444738de 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessage.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ClipboardMessage: IDisposable { - private unsafe Raw.ClipboardMessage* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClipboardMessage.Destroy; public IronRdpError? Error { @@ -75,29 +80,51 @@ public ClipboardFormatId? SendInitiatePaste /// Creates a managed ClipboardMessage from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClipboardMessage(Raw.ClipboardMessage* handle) + internal unsafe ClipboardMessage(Raw.ClipboardMessage* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClipboardMessage(Raw.ClipboardMessage* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClipboardMessage(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } - /// - /// A ClipboardMessageType allocated on C# side. - /// public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.ClipboardMessageType retVal = Raw.ClipboardMessage.GetMessageType(_inner); - return (ClipboardMessageType)retVal; + var result = Raw.ClipboardMessage.GetMessageType(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -108,16 +135,13 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.ClipboardFormatIterator* retVal = Raw.ClipboardMessage.GetSendInitiateCopy(_inner); - if (retVal == null) - { - return null; - } - return new ClipboardFormatIterator(retVal); + Raw.ClipboardFormatIterator* result = Raw.ClipboardMessage.GetSendInitiateCopy(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new ClipboardFormatIterator(result); } } @@ -128,16 +152,13 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.FormatDataResponse* retVal = Raw.ClipboardMessage.GetSendFormatData(_inner); - if (retVal == null) - { - return null; - } - return new FormatDataResponse(retVal); + Raw.FormatDataResponse* result = Raw.ClipboardMessage.GetSendFormatData(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new FormatDataResponse(result); } } @@ -148,16 +169,13 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.ClipboardFormatId* retVal = Raw.ClipboardMessage.GetSendInitiatePaste(_inner); - if (retVal == null) - { - return null; - } - return new ClipboardFormatId(retVal); + Raw.ClipboardFormatId* result = Raw.ClipboardMessage.GetSendInitiatePaste(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new ClipboardFormatId(result); } } @@ -168,16 +186,13 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.FfiFileContentsRequest* retVal = Raw.ClipboardMessage.GetSendFileContentsRequest(_inner); - if (retVal == null) - { - return null; - } - return new FfiFileContentsRequest(retVal); + Raw.FfiFileContentsRequest* result = Raw.ClipboardMessage.GetSendFileContentsRequest(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new FfiFileContentsRequest(result); } } @@ -188,16 +203,13 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.FfiFileContentsResponse* retVal = Raw.ClipboardMessage.GetSendFileContentsResponse(_inner); - if (retVal == null) - { - return null; - } - return new FfiFileContentsResponse(retVal); + Raw.FfiFileContentsResponse* result = Raw.ClipboardMessage.GetSendFileContentsResponse(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new FfiFileContentsResponse(result); } } @@ -208,25 +220,22 @@ public ClipboardMessageType GetMessageType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ClipboardMessage"); } - Raw.IronRdpError* retVal = Raw.ClipboardMessage.GetError(_inner); - if (retVal == null) - { - return null; - } - return new IronRdpError(retVal); + Raw.IronRdpError* result = Raw.ClipboardMessage.GetError(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new IronRdpError(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClipboardMessage* AsFFI() + internal unsafe Raw.ClipboardMessage* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -236,13 +245,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClipboardMessage.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -252,4 +262,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessageType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessageType.cs index fcd8ef638..0ebffae70 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessageType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardMessageType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum ClipboardMessageType +public enum ClipboardMessageType : int { SendInitiateCopy = 0, SendInitiateFileCopy = 1, @@ -20,4 +9,4 @@ public enum ClipboardMessageType SendFileContentsRequest = 4, SendFileContentsResponse = 5, Error = 6, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardSvcMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardSvcMessage.cs index 3c0a7b947..77e8da792 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardSvcMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ClipboardSvcMessage.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class ClipboardSvcMessage: IDisposable { - private unsafe Raw.ClipboardSvcMessage* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ClipboardSvcMessage.Destroy; /// /// Creates a managed ClipboardSvcMessage from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ClipboardSvcMessage(Raw.ClipboardSvcMessage* handle) + internal unsafe ClipboardSvcMessage(Raw.ClipboardSvcMessage* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ClipboardSvcMessage(Raw.ClipboardSvcMessage* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ClipboardSvcMessage(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ClipboardSvcMessage* AsFFI() + internal unsafe Raw.ClipboardSvcMessage* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ClipboardSvcMessage.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Cliprdr.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Cliprdr.cs index c2bff3d1f..def016a11 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Cliprdr.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Cliprdr.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class Cliprdr: IDisposable { - private unsafe Raw.Cliprdr* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Cliprdr.Destroy; /// /// Creates a managed Cliprdr from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Cliprdr(Raw.Cliprdr* handle) + internal unsafe Cliprdr(Raw.Cliprdr* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Cliprdr(Raw.Cliprdr* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Cliprdr(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Cliprdr* AsFFI() + internal unsafe Raw.Cliprdr* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Cliprdr.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/CliprdrBackendFactory.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/CliprdrBackendFactory.cs index 3ca080c25..7610e5479 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/CliprdrBackendFactory.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/CliprdrBackendFactory.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class CliprdrBackendFactory: IDisposable { - private unsafe Raw.CliprdrBackendFactory* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.CliprdrBackendFactory.Destroy; /// /// Creates a managed CliprdrBackendFactory from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe CliprdrBackendFactory(Raw.CliprdrBackendFactory* handle) + internal unsafe CliprdrBackendFactory(Raw.CliprdrBackendFactory* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe CliprdrBackendFactory(Raw.CliprdrBackendFactory* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe CliprdrBackendFactory(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,21 +65,22 @@ public Cliprdr BuildCliprdr() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CliprdrBackendFactory"); } - Raw.Cliprdr* retVal = Raw.CliprdrBackendFactory.BuildCliprdr(_inner); - return new Cliprdr(retVal); + Raw.Cliprdr* result = Raw.CliprdrBackendFactory.BuildCliprdr(AsFFI()); + GC.KeepAlive(this); + return new Cliprdr(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.CliprdrBackendFactory* AsFFI() + internal unsafe Raw.CliprdrBackendFactory* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -60,13 +90,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.CliprdrBackendFactory.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -76,4 +107,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Config.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Config.cs index 7a37da1f3..7b5f32eb0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Config.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Config.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class Config: IDisposable { - private unsafe Raw.Config* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Config.Destroy; public DvcPipeProxyConfig? DvcPipeProxy { @@ -27,14 +32,38 @@ public DvcPipeProxyConfig? DvcPipeProxy /// Creates a managed Config from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Config(Raw.Config* handle) + internal unsafe Config(Raw.Config* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Config(Raw.Config* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Config(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -44,8 +73,8 @@ public static ConfigBuilder GetBuilder() { unsafe { - Raw.ConfigBuilder* retVal = Raw.Config.GetBuilder(); - return new ConfigBuilder(retVal); + Raw.ConfigBuilder* result = Raw.Config.GetBuilder(); + return new ConfigBuilder(result); } } @@ -56,25 +85,22 @@ public static ConfigBuilder GetBuilder() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Config"); } - Raw.DvcPipeProxyConfig* retVal = Raw.Config.GetDvcPipeProxy(_inner); - if (retVal == null) - { - return null; - } - return new DvcPipeProxyConfig(retVal); + Raw.DvcPipeProxyConfig* result = Raw.Config.GetDvcPipeProxy(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new DvcPipeProxyConfig(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Config* AsFFI() + internal unsafe Raw.Config* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -84,13 +110,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Config.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -100,4 +127,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConfigBuilder.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConfigBuilder.cs index 9531f84f0..0fea1ddde 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConfigBuilder.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConfigBuilder.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,164 +10,52 @@ namespace Devolutions.IronRdp; public partial class ConfigBuilder: IDisposable { - private unsafe Raw.ConfigBuilder* _inner; - - public bool Autologon - { - set - { - SetAutologon(value); - } - } - - public BitmapConfig BitmapConfig - { - set - { - SetBitmapConfig(value); - } - } - - public uint ClientBuild - { - set - { - SetClientBuild(value); - } - } - - public string ClientDir - { - set - { - SetClientDir(value); - } - } - - public string ClientName - { - set - { - SetClientName(value); - } - } - - public string DigProductId - { - set - { - SetDigProductId(value); - } - } - - public string Domain - { - set - { - SetDomain(value); - } - } - - public DvcPipeProxyConfig DvcPipeProxy - { - set - { - SetDvcPipeProxy(value); - } - } + private unsafe RustHandle _inner; - public bool EnableCredssp - { - set - { - SetEnableCredssp(value); - } - } - - public bool EnableServerPointer - { - set - { - SetEnableServerPointer(value); - } - } - - public bool EnableTls - { - set - { - SetEnableTls(value); - } - } - - public string ImeFileName - { - set - { - SetImeFileName(value); - } - } - - public uint KeyboardFunctionalKeysCount - { - set - { - SetKeyboardFunctionalKeysCount(value); - } - } - - public uint KeyboardLayout - { - set - { - SetKeyboardLayout(value); - } - } - - public uint KeyboardSubtype - { - set - { - SetKeyboardSubtype(value); - } - } - - public KeyboardType KeyboardType - { - set - { - SetKeyboardType(value); - } - } - - public PerformanceFlags PerformanceFlags - { - set - { - SetPerformanceFlags(value); - } - } + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; - public bool PointerSoftwareRendering - { - set - { - SetPointerSoftwareRendering(value); - } - } + private static readonly unsafe RustDestructor _destroy = Raw.ConfigBuilder.Destroy; /// /// Creates a managed ConfigBuilder from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConfigBuilder(Raw.ConfigBuilder* handle) + internal unsafe ConfigBuilder(Raw.ConfigBuilder* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConfigBuilder(Raw.ConfigBuilder* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConfigBuilder(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -180,8 +65,8 @@ public static ConfigBuilder New() { unsafe { - Raw.ConfigBuilder* retVal = Raw.ConfigBuilder.New(); - return new ConfigBuilder(retVal); + Raw.ConfigBuilder* result = Raw.ConfigBuilder.New(); + return new ConfigBuilder(result); } } @@ -189,20 +74,19 @@ public void WithUsernameAndPassword(string username, string password) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] usernameBuf = DiplomatUtils.StringToUtf8(username); - byte[] passwordBuf = DiplomatUtils.StringToUtf8(password); - nuint usernameBufLength = (nuint)usernameBuf.Length; - nuint passwordBufLength = (nuint)passwordBuf.Length; - fixed (byte* usernameBufPtr = usernameBuf) + if (username == null) throw new ArgumentNullException(nameof(username)); + if (password == null) throw new ArgumentNullException(nameof(password)); + byte[] usernameBytes = Diplomat.Utf8.Clone(username); + byte[] passwordBytes = Diplomat.Utf8.Clone(password); + fixed (byte* usernamePtr = usernameBytes) + fixed (byte* passwordPtr = passwordBytes) { - fixed (byte* passwordBufPtr = passwordBuf) - { - Raw.ConfigBuilder.WithUsernameAndPassword(_inner, usernameBufPtr, usernameBufLength, passwordBufPtr, passwordBufLength); - } + Raw.ConfigBuilder.WithUsernameAndPassword(AsFFI(), new DiplomatSliceU8 { Ptr = usernamePtr, Len = (nuint)usernameBytes.Length }, new DiplomatSliceU8 { Ptr = passwordPtr, Len = (nuint)passwordBytes.Length }); + GC.KeepAlive(this); } } } @@ -211,15 +95,16 @@ public void SetDomain(string domain) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] domainBuf = DiplomatUtils.StringToUtf8(domain); - nuint domainBufLength = (nuint)domainBuf.Length; - fixed (byte* domainBufPtr = domainBuf) + if (domain == null) throw new ArgumentNullException(nameof(domain)); + byte[] domainBytes = Diplomat.Utf8.Clone(domain); + fixed (byte* domainPtr = domainBytes) { - Raw.ConfigBuilder.SetDomain(_inner, domainBufPtr, domainBufLength); + Raw.ConfigBuilder.SetDomain(AsFFI(), new DiplomatSliceU8 { Ptr = domainPtr, Len = (nuint)domainBytes.Length }); + GC.KeepAlive(this); } } } @@ -228,11 +113,12 @@ public void SetEnableTls(bool enableTls) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetEnableTls(_inner, enableTls); + Raw.ConfigBuilder.SetEnableTls(AsFFI(), enableTls); + GC.KeepAlive(this); } } @@ -240,11 +126,12 @@ public void SetEnableCredssp(bool enableCredssp) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetEnableCredssp(_inner, enableCredssp); + Raw.ConfigBuilder.SetEnableCredssp(AsFFI(), enableCredssp); + GC.KeepAlive(this); } } @@ -252,11 +139,12 @@ public void SetKeyboardLayout(uint keyboardLayout) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetKeyboardLayout(_inner, keyboardLayout); + Raw.ConfigBuilder.SetKeyboardLayout(AsFFI(), keyboardLayout); + GC.KeepAlive(this); } } @@ -264,13 +152,12 @@ public void SetKeyboardType(KeyboardType keyboardType) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.KeyboardType keyboardTypeRaw; - keyboardTypeRaw = (Raw.KeyboardType)keyboardType; - Raw.ConfigBuilder.SetKeyboardType(_inner, keyboardTypeRaw); + Raw.ConfigBuilder.SetKeyboardType(AsFFI(), keyboardType); + GC.KeepAlive(this); } } @@ -278,11 +165,12 @@ public void SetKeyboardSubtype(uint keyboardSubtype) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetKeyboardSubtype(_inner, keyboardSubtype); + Raw.ConfigBuilder.SetKeyboardSubtype(AsFFI(), keyboardSubtype); + GC.KeepAlive(this); } } @@ -290,11 +178,12 @@ public void SetKeyboardFunctionalKeysCount(uint keyboardFunctionalKeysCount) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetKeyboardFunctionalKeysCount(_inner, keyboardFunctionalKeysCount); + Raw.ConfigBuilder.SetKeyboardFunctionalKeysCount(AsFFI(), keyboardFunctionalKeysCount); + GC.KeepAlive(this); } } @@ -302,15 +191,16 @@ public void SetImeFileName(string imeFileName) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] imeFileNameBuf = DiplomatUtils.StringToUtf8(imeFileName); - nuint imeFileNameBufLength = (nuint)imeFileNameBuf.Length; - fixed (byte* imeFileNameBufPtr = imeFileNameBuf) + if (imeFileName == null) throw new ArgumentNullException(nameof(imeFileName)); + byte[] imeFileNameBytes = Diplomat.Utf8.Clone(imeFileName); + fixed (byte* imeFileNamePtr = imeFileNameBytes) { - Raw.ConfigBuilder.SetImeFileName(_inner, imeFileNameBufPtr, imeFileNameBufLength); + Raw.ConfigBuilder.SetImeFileName(AsFFI(), new DiplomatSliceU8 { Ptr = imeFileNamePtr, Len = (nuint)imeFileNameBytes.Length }); + GC.KeepAlive(this); } } } @@ -319,15 +209,16 @@ public void SetDigProductId(string digProductId) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] digProductIdBuf = DiplomatUtils.StringToUtf8(digProductId); - nuint digProductIdBufLength = (nuint)digProductIdBuf.Length; - fixed (byte* digProductIdBufPtr = digProductIdBuf) + if (digProductId == null) throw new ArgumentNullException(nameof(digProductId)); + byte[] digProductIdBytes = Diplomat.Utf8.Clone(digProductId); + fixed (byte* digProductIdPtr = digProductIdBytes) { - Raw.ConfigBuilder.SetDigProductId(_inner, digProductIdBufPtr, digProductIdBufLength); + Raw.ConfigBuilder.SetDigProductId(AsFFI(), new DiplomatSliceU8 { Ptr = digProductIdPtr, Len = (nuint)digProductIdBytes.Length }); + GC.KeepAlive(this); } } } @@ -336,11 +227,12 @@ public void SetDesktopSize(ushort height, ushort width) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetDesktopSize(_inner, height, width); + Raw.ConfigBuilder.SetDesktopSize(AsFFI(), height, width); + GC.KeepAlive(this); } } @@ -348,17 +240,16 @@ public void SetPerformanceFlags(PerformanceFlags performanceFlags) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.PerformanceFlags* performanceFlagsRaw; - performanceFlagsRaw = performanceFlags.AsFFI(); - if (performanceFlagsRaw == null) - { - throw new ObjectDisposedException("PerformanceFlags"); - } - Raw.ConfigBuilder.SetPerformanceFlags(_inner, performanceFlagsRaw); + if (performanceFlags == null) throw new ArgumentNullException(nameof(performanceFlags)); + Raw.PerformanceFlags* performanceFlagsRaw = performanceFlags.AsFFI(); + if (performanceFlagsRaw == null) throw new ObjectDisposedException(nameof(PerformanceFlags)); + Raw.ConfigBuilder.SetPerformanceFlags(AsFFI(), performanceFlagsRaw); + GC.KeepAlive(this); + GC.KeepAlive(performanceFlags); } } @@ -366,17 +257,16 @@ public void SetBitmapConfig(BitmapConfig bitmap) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.BitmapConfig* bitmapRaw; - bitmapRaw = bitmap.AsFFI(); - if (bitmapRaw == null) - { - throw new ObjectDisposedException("BitmapConfig"); - } - Raw.ConfigBuilder.SetBitmapConfig(_inner, bitmapRaw); + if (bitmap == null) throw new ArgumentNullException(nameof(bitmap)); + Raw.BitmapConfig* bitmapRaw = bitmap.AsFFI(); + if (bitmapRaw == null) throw new ObjectDisposedException(nameof(BitmapConfig)); + Raw.ConfigBuilder.SetBitmapConfig(AsFFI(), bitmapRaw); + GC.KeepAlive(this); + GC.KeepAlive(bitmap); } } @@ -384,11 +274,12 @@ public void SetClientBuild(uint clientBuild) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetClientBuild(_inner, clientBuild); + Raw.ConfigBuilder.SetClientBuild(AsFFI(), clientBuild); + GC.KeepAlive(this); } } @@ -396,15 +287,16 @@ public void SetClientName(string clientName) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] clientNameBuf = DiplomatUtils.StringToUtf8(clientName); - nuint clientNameBufLength = (nuint)clientNameBuf.Length; - fixed (byte* clientNameBufPtr = clientNameBuf) + if (clientName == null) throw new ArgumentNullException(nameof(clientName)); + byte[] clientNameBytes = Diplomat.Utf8.Clone(clientName); + fixed (byte* clientNamePtr = clientNameBytes) { - Raw.ConfigBuilder.SetClientName(_inner, clientNameBufPtr, clientNameBufLength); + Raw.ConfigBuilder.SetClientName(AsFFI(), new DiplomatSliceU8 { Ptr = clientNamePtr, Len = (nuint)clientNameBytes.Length }); + GC.KeepAlive(this); } } } @@ -413,15 +305,16 @@ public void SetClientDir(string clientDir) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - byte[] clientDirBuf = DiplomatUtils.StringToUtf8(clientDir); - nuint clientDirBufLength = (nuint)clientDirBuf.Length; - fixed (byte* clientDirBufPtr = clientDirBuf) + if (clientDir == null) throw new ArgumentNullException(nameof(clientDir)); + byte[] clientDirBytes = Diplomat.Utf8.Clone(clientDir); + fixed (byte* clientDirPtr = clientDirBytes) { - Raw.ConfigBuilder.SetClientDir(_inner, clientDirBufPtr, clientDirBufLength); + Raw.ConfigBuilder.SetClientDir(AsFFI(), new DiplomatSliceU8 { Ptr = clientDirPtr, Len = (nuint)clientDirBytes.Length }); + GC.KeepAlive(this); } } } @@ -430,11 +323,12 @@ public void SetEnableServerPointer(bool enableServerPointer) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetEnableServerPointer(_inner, enableServerPointer); + Raw.ConfigBuilder.SetEnableServerPointer(AsFFI(), enableServerPointer); + GC.KeepAlive(this); } } @@ -442,11 +336,12 @@ public void SetAutologon(bool autologon) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetAutologon(_inner, autologon); + Raw.ConfigBuilder.SetAutologon(AsFFI(), autologon); + GC.KeepAlive(this); } } @@ -454,11 +349,12 @@ public void SetPointerSoftwareRendering(bool pointerSoftwareRendering) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConfigBuilder.SetPointerSoftwareRendering(_inner, pointerSoftwareRendering); + Raw.ConfigBuilder.SetPointerSoftwareRendering(AsFFI(), pointerSoftwareRendering); + GC.KeepAlive(this); } } @@ -466,17 +362,16 @@ public void SetDvcPipeProxy(DvcPipeProxyConfig dvcPipeProxy) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.DvcPipeProxyConfig* dvcPipeProxyRaw; - dvcPipeProxyRaw = dvcPipeProxy.AsFFI(); - if (dvcPipeProxyRaw == null) - { - throw new ObjectDisposedException("DvcPipeProxyConfig"); - } - Raw.ConfigBuilder.SetDvcPipeProxy(_inner, dvcPipeProxyRaw); + if (dvcPipeProxy == null) throw new ArgumentNullException(nameof(dvcPipeProxy)); + Raw.DvcPipeProxyConfig* dvcPipeProxyRaw = dvcPipeProxy.AsFFI(); + if (dvcPipeProxyRaw == null) throw new ObjectDisposedException(nameof(DvcPipeProxyConfig)); + Raw.ConfigBuilder.SetDvcPipeProxy(AsFFI(), dvcPipeProxyRaw); + GC.KeepAlive(this); + GC.KeepAlive(dvcPipeProxy); } } @@ -488,26 +383,26 @@ public Config Build() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConfigBuilder"); } - Raw.ConnectorConfigFfiResultBoxConfigBoxIronRdpError result = Raw.ConfigBuilder.Build(_inner); - if (!result.isOk) + var result = Raw.ConfigBuilder.Build(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Config* retVal = result.Ok; - return new Config(retVal); + return new Config(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConfigBuilder* AsFFI() + internal unsafe Raw.ConfigBuilder* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -517,13 +412,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConfigBuilder.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -533,4 +429,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectInitial.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectInitial.cs index 8a8f676b6..10934d752 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectInitial.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectInitial.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class ConnectInitial: IDisposable { - private unsafe Raw.ConnectInitial* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectInitial.Destroy; /// /// Creates a managed ConnectInitial from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectInitial(Raw.ConnectInitial* handle) + internal unsafe ConnectInitial(Raw.ConnectInitial* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectInitial(Raw.ConnectInitial* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectInitial(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectInitial* AsFFI() + internal unsafe Raw.ConnectInitial* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectInitial.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationSequence.cs index 1abefa816..69e9fb7bc 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationSequence.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ConnectionActivationSequence: IDisposable { - private unsafe Raw.ConnectionActivationSequence* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectionActivationSequence.Destroy; public ushort IoChannelId { @@ -43,14 +48,38 @@ public ushort UserChannelId /// Creates a managed ConnectionActivationSequence from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectionActivationSequence(Raw.ConnectionActivationSequence* handle) + internal unsafe ConnectionActivationSequence(Raw.ConnectionActivationSequence* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectionActivationSequence(Raw.ConnectionActivationSequence* handle, object[] edges) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectionActivationSequence(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -60,12 +89,13 @@ public ConnectionActivationState GetState() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - Raw.ConnectionActivationState* retVal = Raw.ConnectionActivationSequence.GetState(_inner); - return new ConnectionActivationState(retVal); + Raw.ConnectionActivationState* result = Raw.ConnectionActivationSequence.GetState(AsFFI()); + GC.KeepAlive(this); + return new ConnectionActivationState(result); } } @@ -73,25 +103,25 @@ public ConnectionActivationState GetState() /// /// A PduHint allocated on Rust side. /// - public PduHint NextPduHint() + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// + public PduHint? NextPduHint() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - Raw.ConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError result = Raw.ConnectionActivationSequence.NextPduHint(_inner); - if (!result.isOk) + var result = Raw.ConnectionActivationSequence.NextPduHint(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.PduHint* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new PduHint(retVal); + return result.Ok == null ? null : new PduHint(result.Ok, new object[] { this }); } } @@ -103,26 +133,24 @@ public Written Step(byte[] pduHint, WriteBuf buf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - nuint pduHintLength = (nuint)pduHint.Length; - Raw.WriteBuf* bufRaw; - bufRaw = buf.AsFFI(); - if (bufRaw == null) - { - throw new ObjectDisposedException("WriteBuf"); - } + if (pduHint == null) throw new ArgumentNullException(nameof(pduHint)); + if (buf == null) throw new ArgumentNullException(nameof(buf)); + Raw.WriteBuf* bufRaw = buf.AsFFI(); + if (bufRaw == null) throw new ObjectDisposedException(nameof(WriteBuf)); fixed (byte* pduHintPtr = pduHint) { - Raw.ConnectorActivationFfiResultBoxWrittenBoxIronRdpError result = Raw.ConnectionActivationSequence.Step(_inner, pduHintPtr, pduHintLength, bufRaw); - if (!result.isOk) + var result = Raw.ConnectionActivationSequence.Step(AsFFI(), new DiplomatSliceU8 { Ptr = pduHintPtr, Len = (nuint)pduHint.Length }, bufRaw); + GC.KeepAlive(this); + GC.KeepAlive(buf); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Written* retVal = result.Ok; - return new Written(retVal); + return new Written(result.Ok); } } } @@ -135,23 +163,21 @@ public Written StepNoInput(WriteBuf buf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - Raw.WriteBuf* bufRaw; - bufRaw = buf.AsFFI(); - if (bufRaw == null) - { - throw new ObjectDisposedException("WriteBuf"); - } - Raw.ConnectorActivationFfiResultBoxWrittenBoxIronRdpError result = Raw.ConnectionActivationSequence.StepNoInput(_inner, bufRaw); - if (!result.isOk) + if (buf == null) throw new ArgumentNullException(nameof(buf)); + Raw.WriteBuf* bufRaw = buf.AsFFI(); + if (bufRaw == null) throw new ObjectDisposedException(nameof(WriteBuf)); + var result = Raw.ConnectionActivationSequence.StepNoInput(AsFFI(), bufRaw); + GC.KeepAlive(this); + GC.KeepAlive(buf); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Written* retVal = result.Ok; - return new Written(retVal); + return new Written(result.Ok); } } @@ -159,12 +185,13 @@ public ushort GetIoChannelId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - ushort retVal = Raw.ConnectionActivationSequence.GetIoChannelId(_inner); - return retVal; + var result = Raw.ConnectionActivationSequence.GetIoChannelId(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -172,21 +199,22 @@ public ushort GetUserChannelId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationSequence"); } - ushort retVal = Raw.ConnectionActivationSequence.GetUserChannelId(_inner); - return retVal; + var result = Raw.ConnectionActivationSequence.GetUserChannelId(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectionActivationSequence* AsFFI() + internal unsafe Raw.ConnectionActivationSequence* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -196,13 +224,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectionActivationSequence.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -212,4 +241,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationState.cs index 4c238c774..71a478f73 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationState.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ConnectionActivationState: IDisposable { - private unsafe Raw.ConnectionActivationState* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectionActivationState.Destroy; public ConnectionActivationStateConnectionFinalization ConnectionFinalization { @@ -43,29 +48,51 @@ public ConnectionActivationStateType Type /// Creates a managed ConnectionActivationState from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectionActivationState(Raw.ConnectionActivationState* handle) + internal unsafe ConnectionActivationState(Raw.ConnectionActivationState* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectionActivationState(Raw.ConnectionActivationState* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectionActivationState(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } - /// - /// A ConnectionActivationStateType allocated on C# side. - /// public ConnectionActivationStateType GetType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationState"); } - Raw.ConnectionActivationStateType retVal = Raw.ConnectionActivationState.GetType(_inner); - return (ConnectionActivationStateType)retVal; + var result = Raw.ConnectionActivationState.GetType(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -77,17 +104,17 @@ public ConnectionActivationStateConnectionFinalization GetConnectionFinalization { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationState"); } - Raw.ConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError result = Raw.ConnectionActivationState.GetConnectionFinalization(_inner); - if (!result.isOk) + var result = Raw.ConnectionActivationState.GetConnectionFinalization(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ConnectionActivationStateConnectionFinalization* retVal = result.Ok; - return new ConnectionActivationStateConnectionFinalization(retVal); + return new ConnectionActivationStateConnectionFinalization(result.Ok); } } @@ -99,26 +126,26 @@ public ConnectionActivationStateFinalized GetFinalized() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationState"); } - Raw.ConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError result = Raw.ConnectionActivationState.GetFinalized(_inner); - if (!result.isOk) + var result = Raw.ConnectionActivationState.GetFinalized(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ConnectionActivationStateFinalized* retVal = result.Ok; - return new ConnectionActivationStateFinalized(retVal); + return new ConnectionActivationStateFinalized(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectionActivationState* AsFFI() + internal unsafe Raw.ConnectionActivationState* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -128,13 +155,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectionActivationState.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -144,4 +172,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateConnectionFinalization.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateConnectionFinalization.cs index 545817e33..387cda997 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateConnectionFinalization.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateConnectionFinalization.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ConnectionActivationStateConnectionFinalization: IDisposable { - private unsafe Raw.ConnectionActivationStateConnectionFinalization* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectionActivationStateConnectionFinalization.Destroy; public DesktopSize DesktopSize { @@ -27,14 +32,38 @@ public DesktopSize DesktopSize /// Creates a managed ConnectionActivationStateConnectionFinalization from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectionActivationStateConnectionFinalization(Raw.ConnectionActivationStateConnectionFinalization* handle) + internal unsafe ConnectionActivationStateConnectionFinalization(Raw.ConnectionActivationStateConnectionFinalization* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectionActivationStateConnectionFinalization(Raw.ConnectionActivationStateConnectionFinalization* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectionActivationStateConnectionFinalization(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -44,21 +73,22 @@ public DesktopSize GetDesktopSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationStateConnectionFinalization"); } - Raw.DesktopSize* retVal = Raw.ConnectionActivationStateConnectionFinalization.GetDesktopSize(_inner); - return new DesktopSize(retVal); + Raw.DesktopSize* result = Raw.ConnectionActivationStateConnectionFinalization.GetDesktopSize(AsFFI()); + GC.KeepAlive(this); + return new DesktopSize(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectionActivationStateConnectionFinalization* AsFFI() + internal unsafe Raw.ConnectionActivationStateConnectionFinalization* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -68,13 +98,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectionActivationStateConnectionFinalization.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -84,4 +115,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateFinalized.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateFinalized.cs index a14f588ea..4c9ae4dd6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateFinalized.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateFinalized.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ConnectionActivationStateFinalized: IDisposable { - private unsafe Raw.ConnectionActivationStateFinalized* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectionActivationStateFinalized.Destroy; public DesktopSize DesktopSize { @@ -51,26 +56,51 @@ public uint ShareId /// Creates a managed ConnectionActivationStateFinalized from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectionActivationStateFinalized(Raw.ConnectionActivationStateFinalized* handle) + internal unsafe ConnectionActivationStateFinalized(Raw.ConnectionActivationStateFinalized* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectionActivationStateFinalized(Raw.ConnectionActivationStateFinalized* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectionActivationStateFinalized(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public uint GetShareId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationStateFinalized"); } - uint retVal = Raw.ConnectionActivationStateFinalized.GetShareId(_inner); - return retVal; + var result = Raw.ConnectionActivationStateFinalized.GetShareId(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -81,12 +111,13 @@ public DesktopSize GetDesktopSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationStateFinalized"); } - Raw.DesktopSize* retVal = Raw.ConnectionActivationStateFinalized.GetDesktopSize(_inner); - return new DesktopSize(retVal); + Raw.DesktopSize* result = Raw.ConnectionActivationStateFinalized.GetDesktopSize(AsFFI()); + GC.KeepAlive(this); + return new DesktopSize(result); } } @@ -94,12 +125,13 @@ public bool GetEnableServerPointer() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationStateFinalized"); } - bool retVal = Raw.ConnectionActivationStateFinalized.GetEnableServerPointer(_inner); - return retVal; + var result = Raw.ConnectionActivationStateFinalized.GetEnableServerPointer(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -107,21 +139,22 @@ public bool GetPointerSoftwareRendering() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionActivationStateFinalized"); } - bool retVal = Raw.ConnectionActivationStateFinalized.GetPointerSoftwareRendering(_inner); - return retVal; + var result = Raw.ConnectionActivationStateFinalized.GetPointerSoftwareRendering(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectionActivationStateFinalized* AsFFI() + internal unsafe Raw.ConnectionActivationStateFinalized* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -131,13 +164,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectionActivationStateFinalized.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -147,4 +181,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateType.cs index 2ee567eac..5153f3854 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionActivationStateType.cs @@ -1,20 +1,9 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum ConnectionActivationStateType +public enum ConnectionActivationStateType : int { Consumed = 0, CapabilitiesExchange = 1, ConnectionFinalization = 2, Finalized = 3, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionResult.cs index ffe51173d..b84db2c69 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/ConnectionResult.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class ConnectionResult: IDisposable { - private unsafe Raw.ConnectionResult* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.ConnectionResult.Destroy; public DesktopSize DesktopSize { @@ -67,14 +72,38 @@ public ushort UserChannelId /// Creates a managed ConnectionResult from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe ConnectionResult(Raw.ConnectionResult* handle) + internal unsafe ConnectionResult(Raw.ConnectionResult* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe ConnectionResult(Raw.ConnectionResult* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe ConnectionResult(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -82,17 +111,17 @@ public ushort GetIoChannelId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultU16BoxIronRdpError result = Raw.ConnectionResult.GetIoChannelId(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetIoChannelId(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - ushort retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -101,17 +130,17 @@ public ushort GetUserChannelId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultU16BoxIronRdpError result = Raw.ConnectionResult.GetUserChannelId(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetUserChannelId(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - ushort retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -120,17 +149,17 @@ public uint GetShareId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultU32BoxIronRdpError result = Raw.ConnectionResult.GetShareId(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetShareId(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - uint retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -142,17 +171,17 @@ public DesktopSize GetDesktopSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError result = Raw.ConnectionResult.GetDesktopSize(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetDesktopSize(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.DesktopSize* retVal = result.Ok; - return new DesktopSize(retVal); + return new DesktopSize(result.Ok); } } @@ -161,17 +190,17 @@ public bool GetEnableServerPointer() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultBoolBoxIronRdpError result = Raw.ConnectionResult.GetEnableServerPointer(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetEnableServerPointer(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - bool retVal = result.Ok; - return retVal; + return result.Ok; } } @@ -180,26 +209,26 @@ public bool GetPointerSoftwareRendering() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("ConnectionResult"); } - Raw.ConnectorResultFfiResultBoolBoxIronRdpError result = Raw.ConnectionResult.GetPointerSoftwareRendering(_inner); - if (!result.isOk) + var result = Raw.ConnectionResult.GetPointerSoftwareRendering(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - bool retVal = result.Ok; - return retVal; + return result.Ok; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.ConnectionResult* AsFFI() + internal unsafe Raw.ConnectionResult* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -209,13 +238,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.ConnectionResult.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -225,4 +255,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspProcessGenerator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspProcessGenerator.cs index a5d0f1024..2a7e631cd 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspProcessGenerator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspProcessGenerator.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class CredsspProcessGenerator: IDisposable { - private unsafe Raw.CredsspProcessGenerator* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.CredsspProcessGenerator.Destroy; /// /// Creates a managed CredsspProcessGenerator from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe CredsspProcessGenerator(Raw.CredsspProcessGenerator* handle) + internal unsafe CredsspProcessGenerator(Raw.CredsspProcessGenerator* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe CredsspProcessGenerator(Raw.CredsspProcessGenerator* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe CredsspProcessGenerator(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -37,17 +66,17 @@ public GeneratorState Start() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspProcessGenerator"); } - Raw.CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError result = Raw.CredsspProcessGenerator.Start(_inner); - if (!result.isOk) + var result = Raw.CredsspProcessGenerator.Start(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.GeneratorState* retVal = result.Ok; - return new GeneratorState(retVal); + return new GeneratorState(result.Ok); } } @@ -59,20 +88,20 @@ public GeneratorState Resume(byte[] response) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspProcessGenerator"); } - nuint responseLength = (nuint)response.Length; + if (response == null) throw new ArgumentNullException(nameof(response)); fixed (byte* responsePtr = response) { - Raw.CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError result = Raw.CredsspProcessGenerator.Resume(_inner, responsePtr, responseLength); - if (!result.isOk) + var result = Raw.CredsspProcessGenerator.Resume(AsFFI(), new DiplomatSliceU8 { Ptr = responsePtr, Len = (nuint)response.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.GeneratorState* retVal = result.Ok; - return new GeneratorState(retVal); + return new GeneratorState(result.Ok); } } } @@ -80,9 +109,9 @@ public GeneratorState Resume(byte[] response) /// /// Returns the underlying raw handle. /// - public unsafe Raw.CredsspProcessGenerator* AsFFI() + internal unsafe Raw.CredsspProcessGenerator* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -92,13 +121,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.CredsspProcessGenerator.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -108,4 +138,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequence.cs index e750795ca..6ab231427 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequence.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,39 +10,72 @@ namespace Devolutions.IronRdp; public partial class CredsspSequence: IDisposable { - private unsafe Raw.CredsspSequence* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.CredsspSequence.Destroy; /// /// Creates a managed CredsspSequence from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe CredsspSequence(Raw.CredsspSequence* handle) + internal unsafe CredsspSequence(Raw.CredsspSequence* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe CredsspSequence(Raw.CredsspSequence* handle, object[] edges) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe CredsspSequence(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// /// A PduHint allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public PduHint? NextPduHint() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequence"); } - Raw.PduHint* retVal = Raw.CredsspSequence.NextPduHint(_inner); - if (retVal == null) - { - return null; - } - return new PduHint(retVal); + Raw.PduHint* result = Raw.CredsspSequence.NextPduHint(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new PduHint(result, new object[] { this }); } } @@ -57,40 +87,25 @@ public static CredsspSequenceInitResult Init(ClientConnector connector, string s { unsafe { - byte[] serverNameBuf = DiplomatUtils.StringToUtf8(serverName); - nuint serverPublicKeyLength = (nuint)serverPublicKey.Length; - nuint serverNameBufLength = (nuint)serverNameBuf.Length; - Raw.ClientConnector* connectorRaw; - connectorRaw = connector.AsFFI(); - if (connectorRaw == null) - { - throw new ObjectDisposedException("ClientConnector"); - } - Raw.KerberosConfig* kerberoConfigsRaw; - if (kerberoConfigs == null) - { - kerberoConfigsRaw = null; - } - else - { - kerberoConfigsRaw = kerberoConfigs.AsFFI(); - if (kerberoConfigsRaw == null) - { - throw new ObjectDisposedException("KerberosConfig"); - } - } + if (connector == null) throw new ArgumentNullException(nameof(connector)); + Raw.ClientConnector* connectorRaw = connector.AsFFI(); + if (connectorRaw == null) throw new ObjectDisposedException(nameof(ClientConnector)); + if (serverName == null) throw new ArgumentNullException(nameof(serverName)); + if (serverPublicKey == null) throw new ArgumentNullException(nameof(serverPublicKey)); + Raw.KerberosConfig* kerberoConfigsRaw = kerberoConfigs == null ? null : kerberoConfigs.AsFFI(); + if (kerberoConfigs != null && kerberoConfigsRaw == null) throw new ObjectDisposedException(nameof(KerberosConfig)); + byte[] serverNameBytes = Diplomat.Utf8.Clone(serverName); + fixed (byte* serverNamePtr = serverNameBytes) fixed (byte* serverPublicKeyPtr = serverPublicKey) { - fixed (byte* serverNameBufPtr = serverNameBuf) + var result = Raw.CredsspSequence.Init(connectorRaw, new DiplomatSliceU8 { Ptr = serverNamePtr, Len = (nuint)serverNameBytes.Length }, new DiplomatSliceU8 { Ptr = serverPublicKeyPtr, Len = (nuint)serverPublicKey.Length }, kerberoConfigsRaw); + GC.KeepAlive(connector); + GC.KeepAlive(kerberoConfigs); + if (!result.IsOk) { - Raw.CredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError result = Raw.CredsspSequence.Init(connectorRaw, serverNameBufPtr, serverNameBufLength, serverPublicKeyPtr, serverPublicKeyLength, kerberoConfigsRaw); - if (!result.isOk) - { - throw new IronRdpException(new IronRdpError(result.Err)); - } - Raw.CredsspSequenceInitResult* retVal = result.Ok; - return new CredsspSequenceInitResult(retVal); + throw new IronRdpException(new IronRdpError(result.Err)); } + return new CredsspSequenceInitResult(result.Ok); } } } @@ -99,28 +114,24 @@ public static CredsspSequenceInitResult Init(ClientConnector connector, string s /// /// A TsRequest allocated on Rust side. /// - public TsRequest DecodeServerMessage(byte[] pdu) + public TsRequest? DecodeServerMessage(byte[] pdu) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequence"); } - nuint pduLength = (nuint)pdu.Length; + if (pdu == null) throw new ArgumentNullException(nameof(pdu)); fixed (byte* pduPtr = pdu) { - Raw.CredsspFfiResultOptBoxTsRequestBoxIronRdpError result = Raw.CredsspSequence.DecodeServerMessage(_inner, pduPtr, pduLength); - if (!result.isOk) + var result = Raw.CredsspSequence.DecodeServerMessage(AsFFI(), new DiplomatSliceU8 { Ptr = pduPtr, Len = (nuint)pdu.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.TsRequest* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new TsRequest(retVal); + return result.Ok == null ? null : new TsRequest(result.Ok); } } } @@ -129,27 +140,29 @@ public TsRequest DecodeServerMessage(byte[] pdu) /// /// A CredsspProcessGenerator allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public CredsspProcessGenerator ProcessTsRequest(TsRequest tsRequest) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequence"); } - Raw.TsRequest* tsRequestRaw; - tsRequestRaw = tsRequest.AsFFI(); - if (tsRequestRaw == null) - { - throw new ObjectDisposedException("TsRequest"); - } - Raw.CredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError result = Raw.CredsspSequence.ProcessTsRequest(_inner, tsRequestRaw); - if (!result.isOk) + if (tsRequest == null) throw new ArgumentNullException(nameof(tsRequest)); + Raw.TsRequest* tsRequestRaw = tsRequest.AsFFI(); + if (tsRequestRaw == null) throw new ObjectDisposedException(nameof(TsRequest)); + var result = Raw.CredsspSequence.ProcessTsRequest(AsFFI(), tsRequestRaw); + GC.KeepAlive(this); + GC.KeepAlive(tsRequest); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.CredsspProcessGenerator* retVal = result.Ok; - return new CredsspProcessGenerator(retVal); + return new CredsspProcessGenerator(result.Ok, new object[] { this }); } } @@ -161,38 +174,34 @@ public Written HandleProcessResult(ClientState clientState, WriteBuf buf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequence"); } - Raw.ClientState* clientStateRaw; - clientStateRaw = clientState.AsFFI(); - if (clientStateRaw == null) - { - throw new ObjectDisposedException("ClientState"); - } - Raw.WriteBuf* bufRaw; - bufRaw = buf.AsFFI(); - if (bufRaw == null) - { - throw new ObjectDisposedException("WriteBuf"); - } - Raw.CredsspFfiResultBoxWrittenBoxIronRdpError result = Raw.CredsspSequence.HandleProcessResult(_inner, clientStateRaw, bufRaw); - if (!result.isOk) + if (clientState == null) throw new ArgumentNullException(nameof(clientState)); + Raw.ClientState* clientStateRaw = clientState.AsFFI(); + if (clientStateRaw == null) throw new ObjectDisposedException(nameof(ClientState)); + if (buf == null) throw new ArgumentNullException(nameof(buf)); + Raw.WriteBuf* bufRaw = buf.AsFFI(); + if (bufRaw == null) throw new ObjectDisposedException(nameof(WriteBuf)); + var result = Raw.CredsspSequence.HandleProcessResult(AsFFI(), clientStateRaw, bufRaw); + GC.KeepAlive(this); + GC.KeepAlive(clientState); + GC.KeepAlive(buf); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.Written* retVal = result.Ok; - return new Written(retVal); + return new Written(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.CredsspSequence* AsFFI() + internal unsafe Raw.CredsspSequence* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -202,13 +211,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.CredsspSequence.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -218,4 +228,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequenceInitResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequenceInitResult.cs index 658a8c620..4cd97914d 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequenceInitResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/CredsspSequenceInitResult.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class CredsspSequenceInitResult: IDisposable { - private unsafe Raw.CredsspSequenceInitResult* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.CredsspSequenceInitResult.Destroy; public CredsspSequence CredsspSequence { @@ -35,14 +40,38 @@ public TsRequest TsRequest /// Creates a managed CredsspSequenceInitResult from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe CredsspSequenceInitResult(Raw.CredsspSequenceInitResult* handle) + internal unsafe CredsspSequenceInitResult(Raw.CredsspSequenceInitResult* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe CredsspSequenceInitResult(Raw.CredsspSequenceInitResult* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe CredsspSequenceInitResult(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -53,17 +82,17 @@ public CredsspSequence GetCredsspSequence() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequenceInitResult"); } - Raw.CredsspFfiResultBoxCredsspSequenceBoxIronRdpError result = Raw.CredsspSequenceInitResult.GetCredsspSequence(_inner); - if (!result.isOk) + var result = Raw.CredsspSequenceInitResult.GetCredsspSequence(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.CredsspSequence* retVal = result.Ok; - return new CredsspSequence(retVal); + return new CredsspSequence(result.Ok); } } @@ -75,26 +104,26 @@ public TsRequest GetTsRequest() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("CredsspSequenceInitResult"); } - Raw.CredsspFfiResultBoxTsRequestBoxIronRdpError result = Raw.CredsspSequenceInitResult.GetTsRequest(_inner); - if (!result.isOk) + var result = Raw.CredsspSequenceInitResult.GetTsRequest(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.TsRequest* retVal = result.Ok; - return new TsRequest(retVal); + return new TsRequest(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.CredsspSequenceInitResult* AsFFI() + internal unsafe Raw.CredsspSequenceInitResult* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -104,13 +133,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.CredsspSequenceInitResult.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -120,4 +150,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedImage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedImage.cs index 737e62674..5cd8bb8a0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedImage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedImage.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,8 +10,20 @@ namespace Devolutions.IronRdp; public partial class DecodedImage: IDisposable { - private unsafe Raw.DecodedImage* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DecodedImage.Destroy; + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice Data { get @@ -43,14 +52,38 @@ public ushort Width /// Creates a managed DecodedImage from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DecodedImage(Raw.DecodedImage* handle) + internal unsafe DecodedImage(Raw.DecodedImage* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DecodedImage(Raw.DecodedImage* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DecodedImage(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -60,26 +93,29 @@ public static DecodedImage New(PixelFormat pixelFormat, ushort width, ushort hei { unsafe { - Raw.PixelFormat pixelFormatRaw; - pixelFormatRaw = (Raw.PixelFormat)pixelFormat; - Raw.DecodedImage* retVal = Raw.DecodedImage.New(pixelFormatRaw, width, height); - return new DecodedImage(retVal); + Raw.DecodedImage* result = Raw.DecodedImage.New(pixelFormat, width, height); + return new DecodedImage(result); } } /// /// A BytesSlice allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice GetData() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedImage"); } - Raw.BytesSlice* retVal = Raw.DecodedImage.GetData(_inner); - return new BytesSlice(retVal); + Raw.BytesSlice* result = Raw.DecodedImage.GetData(AsFFI()); + GC.KeepAlive(this); + return new BytesSlice(result, new object[] { this }); } } @@ -87,12 +123,13 @@ public ushort GetWidth() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedImage"); } - ushort retVal = Raw.DecodedImage.GetWidth(_inner); - return retVal; + var result = Raw.DecodedImage.GetWidth(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -100,21 +137,22 @@ public ushort GetHeight() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedImage"); } - ushort retVal = Raw.DecodedImage.GetHeight(_inner); - return retVal; + var result = Raw.DecodedImage.GetHeight(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DecodedImage* AsFFI() + internal unsafe Raw.DecodedImage* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -124,13 +162,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DecodedImage.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -140,4 +179,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedPointer.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedPointer.cs index a967b6060..d8eb6a3c8 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedPointer.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DecodedPointer.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,8 +10,20 @@ namespace Devolutions.IronRdp; public partial class DecodedPointer: IDisposable { - private unsafe Raw.DecodedPointer* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DecodedPointer.Destroy; + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice Data { get @@ -59,26 +68,51 @@ public ushort Width /// Creates a managed DecodedPointer from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DecodedPointer(Raw.DecodedPointer* handle) + internal unsafe DecodedPointer(Raw.DecodedPointer* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DecodedPointer(Raw.DecodedPointer* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DecodedPointer(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } public ushort GetWidth() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedPointer"); } - ushort retVal = Raw.DecodedPointer.GetWidth(_inner); - return retVal; + var result = Raw.DecodedPointer.GetWidth(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -86,12 +120,13 @@ public ushort GetHeight() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedPointer"); } - ushort retVal = Raw.DecodedPointer.GetHeight(_inner); - return retVal; + var result = Raw.DecodedPointer.GetHeight(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -99,12 +134,13 @@ public ushort GetHotspotX() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedPointer"); } - ushort retVal = Raw.DecodedPointer.GetHotspotX(_inner); - return retVal; + var result = Raw.DecodedPointer.GetHotspotX(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -112,37 +148,43 @@ public ushort GetHotspotY() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedPointer"); } - ushort retVal = Raw.DecodedPointer.GetHotspotY(_inner); - return retVal; + var result = Raw.DecodedPointer.GetHotspotY(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// A BytesSlice allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public BytesSlice GetData() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DecodedPointer"); } - Raw.BytesSlice* retVal = Raw.DecodedPointer.GetData(_inner); - return new BytesSlice(retVal); + Raw.BytesSlice* result = Raw.DecodedPointer.GetData(AsFFI()); + GC.KeepAlive(this); + return new BytesSlice(result, new object[] { this }); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DecodedPointer* AsFFI() + internal unsafe Raw.DecodedPointer* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -152,13 +194,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DecodedPointer.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -168,4 +211,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DesktopSize.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DesktopSize.cs index ecdb02070..dc27210e2 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DesktopSize.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DesktopSize.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class DesktopSize: IDisposable { - private unsafe Raw.DesktopSize* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DesktopSize.Destroy; public ushort Height { @@ -35,26 +40,51 @@ public ushort Width /// Creates a managed DesktopSize from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DesktopSize(Raw.DesktopSize* handle) + internal unsafe DesktopSize(Raw.DesktopSize* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DesktopSize(Raw.DesktopSize* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DesktopSize(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public ushort GetWidth() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DesktopSize"); } - ushort retVal = Raw.DesktopSize.GetWidth(_inner); - return retVal; + var result = Raw.DesktopSize.GetWidth(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -62,21 +92,22 @@ public ushort GetHeight() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DesktopSize"); } - ushort retVal = Raw.DesktopSize.GetHeight(_inner); - return retVal; + var result = Raw.DesktopSize.GetHeight(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DesktopSize* AsFFI() + internal unsafe Raw.DesktopSize* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -86,13 +117,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DesktopSize.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -102,4 +134,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageIronRdpError.cs new file mode 100644 index 000000000..94210d33b --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultActiveStageIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ActiveStage* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ActiveStage* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageOutputIteratorIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageOutputIteratorIronRdpError.cs new file mode 100644 index 000000000..b7dfce857 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultActiveStageOutputIteratorIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultActiveStageOutputIteratorIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ActiveStageOutputIterator* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ActiveStageOutputIterator* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBoolIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBoolIronRdpError.cs new file mode 100644 index 000000000..09403eb61 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBoolIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultBoolIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal byte ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public bool Ok => IsOk ? _inner.ok != 0 : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBytesSliceIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBytesSliceIronRdpError.cs new file mode 100644 index 000000000..b13aec1e8 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultBytesSliceIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultBytesSliceIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal BytesSlice* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe BytesSlice* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCertificateChainIteratorIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCertificateChainIteratorIronRdpError.cs new file mode 100644 index 000000000..688fe2ab5 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCertificateChainIteratorIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCertificateChainIteratorIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal CertificateChainIterator* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe CertificateChainIterator* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCharIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCharIronRdpError.cs new file mode 100644 index 000000000..ecf104fa2 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCharIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCharIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal Char* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe Char* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorIronRdpError.cs new file mode 100644 index 000000000..8092da85f --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultClientConnectorIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ClientConnector* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ClientConnector* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateIronRdpError.cs new file mode 100644 index 000000000..cb27d655b --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultClientConnectorStateIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ClientConnectorState* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ClientConnectorState* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateTypeIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateTypeIronRdpError.cs new file mode 100644 index 000000000..51fc5c5f0 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientConnectorStateTypeIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultClientConnectorStateTypeIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ClientConnectorStateType ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public ClientConnectorStateType Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientStateIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientStateIronRdpError.cs new file mode 100644 index 000000000..a538e657d --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClientStateIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultClientStateIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ClientState* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ClientState* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClipboardMessageIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClipboardMessageIronRdpError.cs new file mode 100644 index 000000000..995635372 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultClipboardMessageIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultClipboardMessageIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ClipboardMessage* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ClipboardMessage* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCliprdrBackendFactoryIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCliprdrBackendFactoryIronRdpError.cs new file mode 100644 index 000000000..7e912a6d4 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCliprdrBackendFactoryIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCliprdrBackendFactoryIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal CliprdrBackendFactory* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe CliprdrBackendFactory* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConfigIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConfigIronRdpError.cs new file mode 100644 index 000000000..9ea3d15f9 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConfigIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConfigIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal Config* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe Config* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectInitialIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectInitialIronRdpError.cs new file mode 100644 index 000000000..4d213e98f --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectInitialIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConnectInitialIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ConnectInitial* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ConnectInitial* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationSequenceIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationSequenceIronRdpError.cs new file mode 100644 index 000000000..5fd4bacf5 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationSequenceIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConnectionActivationSequenceIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ConnectionActivationSequence* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ConnectionActivationSequence* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateConnectionFinalizationIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateConnectionFinalizationIronRdpError.cs new file mode 100644 index 000000000..6a757c321 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateConnectionFinalizationIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConnectionActivationStateConnectionFinalizationIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ConnectionActivationStateConnectionFinalization* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ConnectionActivationStateConnectionFinalization* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateFinalizedIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateFinalizedIronRdpError.cs new file mode 100644 index 000000000..0e97f3d44 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionActivationStateFinalizedIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConnectionActivationStateFinalizedIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ConnectionActivationStateFinalized* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ConnectionActivationStateFinalized* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionResultIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionResultIronRdpError.cs new file mode 100644 index 000000000..ea17c435b --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultConnectionResultIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultConnectionResultIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ConnectionResult* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe ConnectionResult* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspProcessGeneratorIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspProcessGeneratorIronRdpError.cs new file mode 100644 index 000000000..877a2c617 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspProcessGeneratorIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCredsspProcessGeneratorIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal CredsspProcessGenerator* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe CredsspProcessGenerator* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceInitResultIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceInitResultIronRdpError.cs new file mode 100644 index 000000000..137324889 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceInitResultIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCredsspSequenceInitResultIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal CredsspSequenceInitResult* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe CredsspSequenceInitResult* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceIronRdpError.cs new file mode 100644 index 000000000..ab043ee3d --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultCredsspSequenceIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultCredsspSequenceIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal CredsspSequence* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe CredsspSequence* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDecodedPointerIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDecodedPointerIronRdpError.cs new file mode 100644 index 000000000..56fbb7c31 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDecodedPointerIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultDecodedPointerIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal DecodedPointer* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe DecodedPointer* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDesktopSizeIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDesktopSizeIronRdpError.cs new file mode 100644 index 000000000..0ebdba62b --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDesktopSizeIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultDesktopSizeIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal DesktopSize* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe DesktopSize* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDvcPipeProxyMessageIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDvcPipeProxyMessageIronRdpError.cs new file mode 100644 index 000000000..16e02cd68 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDvcPipeProxyMessageIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultDvcPipeProxyMessageIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal DvcPipeProxyMessage* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe DvcPipeProxyMessage* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDynStateIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDynStateIronRdpError.cs new file mode 100644 index 000000000..8c2eebed9 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultDynStateIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultDynStateIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal DynState* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe DynState* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGeneratorStateIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGeneratorStateIronRdpError.cs new file mode 100644 index 000000000..4f97e8bf9 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGeneratorStateIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultGeneratorStateIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal GeneratorState* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe GeneratorState* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGracefulDisconnectReasonIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGracefulDisconnectReasonIronRdpError.cs new file mode 100644 index 000000000..14dc7cf7a --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultGracefulDisconnectReasonIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultGracefulDisconnectReasonIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal GracefulDisconnectReason* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe GracefulDisconnectReason* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultInclusiveRectangleIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultInclusiveRectangleIronRdpError.cs new file mode 100644 index 000000000..9ac91d37a --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultInclusiveRectangleIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultInclusiveRectangleIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal InclusiveRectangle* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe InclusiveRectangle* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultMultitransportRequestIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultMultitransportRequestIronRdpError.cs new file mode 100644 index 000000000..f21120c5e --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultMultitransportRequestIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultMultitransportRequestIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal MultitransportRequest ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public MultitransportRequest Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNUIntIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNUIntIronRdpError.cs new file mode 100644 index 000000000..642a4517f --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNUIntIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultNUIntIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal nuint ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public nuint Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNetworkCharacteristicsIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNetworkCharacteristicsIronRdpError.cs new file mode 100644 index 000000000..f564fb62f --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultNetworkCharacteristicsIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultNetworkCharacteristicsIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal NetworkCharacteristics ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public NetworkCharacteristics Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultOptionalUsizeIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultOptionalUsizeIronRdpError.cs new file mode 100644 index 000000000..06c32dfe7 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultOptionalUsizeIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultOptionalUsizeIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal OptionalUsize* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe OptionalUsize* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduHintIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduHintIronRdpError.cs new file mode 100644 index 000000000..9abbde6a3 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduHintIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultPduHintIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal PduHint* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe PduHint* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduInfoIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduInfoIronRdpError.cs new file mode 100644 index 000000000..a506cc6c3 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPduInfoIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultPduInfoIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal PduInfo* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe PduInfo* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPositionIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPositionIronRdpError.cs new file mode 100644 index 000000000..50d30f1e6 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultPositionIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultPositionIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal Position ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public Position Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathPduIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathPduIronRdpError.cs new file mode 100644 index 000000000..cc95d4767 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathPduIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultRDCleanPathPduIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal RDCleanPathPdu* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe RDCleanPathPdu* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathResultTypeIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathResultTypeIronRdpError.cs new file mode 100644 index 000000000..0fa4be8be --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultRDCleanPathResultTypeIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultRDCleanPathResultTypeIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal RDCleanPathResultType ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public RDCleanPathResultType Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultSecurityProtocolIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultSecurityProtocolIronRdpError.cs new file mode 100644 index 000000000..dd9ba74a1 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultSecurityProtocolIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultSecurityProtocolIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal SecurityProtocol* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe SecurityProtocol* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultTsRequestIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultTsRequestIronRdpError.cs new file mode 100644 index 000000000..fe50a78f2 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultTsRequestIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultTsRequestIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal TsRequest* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe TsRequest* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUIntIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUIntIronRdpError.cs new file mode 100644 index 000000000..0718f3a05 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUIntIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultUIntIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal uint ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public uint Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUShortIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUShortIronRdpError.cs new file mode 100644 index 000000000..09d72e5a1 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultUShortIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultUShortIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal ushort ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public ushort Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVecU8IronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVecU8IronRdpError.cs new file mode 100644 index 000000000..ab050dd41 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVecU8IronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultVecU8IronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal VecU8* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe VecU8* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVoidIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVoidIronRdpError.cs new file mode 100644 index 000000000..c0fa57ef1 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultVoidIronRdpError.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultVoidIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWinCliprdrIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWinCliprdrIronRdpError.cs new file mode 100644 index 000000000..a0a0cad34 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWinCliprdrIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultWinCliprdrIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal WinCliprdr* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe WinCliprdr* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWrittenIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWrittenIronRdpError.cs new file mode 100644 index 000000000..6213e109a --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatResultWrittenIronRdpError.cs @@ -0,0 +1,24 @@ +using System; +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Raw; + +using Devolutions.IronRdp; + +[StructLayout(LayoutKind.Sequential)] +internal partial struct DiplomatResultWrittenIronRdpError +{ + [StructLayout(LayoutKind.Explicit)] + private unsafe struct InnerUnion + { + [FieldOffset(0)] internal Written* ok; + [FieldOffset(0)] internal IronRdpError* err; + } + + private InnerUnion _inner; + + [MarshalAs(UnmanagedType.U1)] + public bool IsOk; + public unsafe Written* Ok => IsOk ? _inner.ok : throw new InvalidOperationException("Result does not contain Ok value"); + public unsafe IronRdpError* Err => !IsOk ? _inner.err : throw new InvalidOperationException("Result does not contain Err value"); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatRuntime.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatRuntime.cs deleted file mode 100644 index 18223e37b..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatRuntime.cs +++ /dev/null @@ -1,172 +0,0 @@ -// Automatically generated by Diplomat - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Text; - -namespace Devolutions.IronRdp.Diplomat; - -#nullable enable - -[UnmanagedFunctionPointer(CallingConvention.Cdecl)] -delegate void WriteableFlush(IntPtr self); - -[UnmanagedFunctionPointer(CallingConvention.Cdecl)] -[return: MarshalAs(UnmanagedType.U1)] -delegate bool WriteableGrow(IntPtr self, nuint capacity); - -[Serializable] -[StructLayout(LayoutKind.Sequential)] -public struct DiplomatWriteable : IDisposable -{ - // About the current approach: - // Ideally DiplomatWriteable should wrap the native string type and grows/writes directly into the internal buffer. - // However, there is no native string type backed by UTF-8 in dotnet frameworks. - // Alternative could be to provide Diplomat's own `Utf8String` type, but this is not trivial and mostly useless - // on its own because all other dotnet/C# APIs are expecting the standard UTF-16 encoded string/String type. - // API is expected to become overall less ergonomic by forcing users to explicitly convert between UTF-16 and UTF-8 anyway in such case. - // It could be useful for copy-free interactions between Diplomat-generated API though. - // Also, there is no way to re-use the unmanaged buffer as-is to get a managed byte[] - // (hence `ToUtf8Bytes` is copying the internal buffer from unmanaged to managed memory). - // It's encouraged to enable memoization when applicable (#129). - - IntPtr context; - IntPtr buf; - nuint len; - nuint cap; - readonly IntPtr flush; - readonly IntPtr grow; - - public DiplomatWriteable() - { - WriteableFlush flushFunc = Flush; - WriteableGrow growFunc = Grow; - - IntPtr flushFuncPtr = Marshal.GetFunctionPointerForDelegate(flushFunc); - IntPtr growFuncPtr = Marshal.GetFunctionPointerForDelegate(growFunc); - - // flushFunc and growFunc are managed objects and might be disposed of by the garbage collector. - // To prevent this, we make the context hold the references and protect the context itself - // for automatic disposal by moving it behind a GCHandle. - DiplomatWriteableContext ctx = new DiplomatWriteableContext(); - ctx.flushFunc = flushFunc; - ctx.growFunc = growFunc; - GCHandle ctxHandle = GCHandle.Alloc(ctx); - - context = GCHandle.ToIntPtr(ctxHandle); - buf = Marshal.AllocHGlobal(64); - len = 0; - cap = 64; - flush = flushFuncPtr; - grow = growFuncPtr; - } - - public byte[] ToUtf8Bytes() - { - if (len > int.MaxValue) - { - throw new IndexOutOfRangeException("DiplomatWriteable buffer is too big"); - } - byte[] managedArray = new byte[(int)len]; - Marshal.Copy(buf, managedArray, 0, (int)len); - return managedArray; - } - - public string ToUnicode() - { -#if NET6_0_OR_GREATER - if (len > int.MaxValue) - { - throw new IndexOutOfRangeException("DiplomatWriteable buffer is too big"); - } - return Marshal.PtrToStringUTF8(buf, (int) len); -#else - byte[] utf8 = ToUtf8Bytes(); - return DiplomatUtils.Utf8ToString(utf8); -#endif - } - - public void Dispose() - { - if (buf != IntPtr.Zero) - { - Marshal.FreeHGlobal(buf); - buf = IntPtr.Zero; - } - - if (context != IntPtr.Zero) - { - GCHandle.FromIntPtr(context).Free(); - context = IntPtr.Zero; - } - } - - private static void Flush(IntPtr self) - { - // Nothing to do - } - - [return: MarshalAs(UnmanagedType.U1)] - private unsafe static bool Grow(IntPtr writeable, nuint capacity) - { - if (writeable == IntPtr.Zero) - { - return false; - } - DiplomatWriteable* self = (DiplomatWriteable*)writeable; - - nuint newCap = capacity; - if (newCap > int.MaxValue) - { - return false; - } - - IntPtr newBuf; - try - { - newBuf = Marshal.AllocHGlobal((int)newCap); - } - catch (OutOfMemoryException) - { - return false; - } - - Buffer.MemoryCopy((void*)self->buf, (void*)newBuf, newCap, self->cap); - Marshal.FreeHGlobal(self->buf); - self->buf = newBuf; - self->cap = newCap; - - return true; - } -} - -internal struct DiplomatWriteableContext -{ - internal WriteableFlush flushFunc; - internal WriteableGrow growFunc; -} - -internal static class DiplomatUtils -{ - internal static byte[] StringToUtf8(string s) - { - int size = Encoding.UTF8.GetByteCount(s); - byte[] buf = new byte[size]; - Encoding.UTF8.GetBytes(s, 0, s.Length, buf, 0); - return buf; - } - - internal static string Utf8ToString(byte[] utf8) - { - char[] chars = new char[utf8.Length]; - Encoding.UTF8.GetChars(utf8, 0, utf8.Length, chars, 0); - return new string(chars); - } -} - -public class DiplomatOpaqueException : Exception -{ - public DiplomatOpaqueException() : base("The FFI function failed with an opaque error") { } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU32.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU32.cs new file mode 100644 index 000000000..a71efbe4a --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU32.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +[StructLayout(LayoutKind.Sequential)] +internal unsafe struct DiplomatSliceMutU32 +{ + public uint* Ptr; + public nuint Len; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU8.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU8.cs new file mode 100644 index 000000000..2b7c9644d --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceMutU8.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +[StructLayout(LayoutKind.Sequential)] +internal unsafe struct DiplomatSliceMutU8 +{ + public byte* Ptr; + public nuint Len; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU16.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU16.cs new file mode 100644 index 000000000..d3b996a40 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU16.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +[StructLayout(LayoutKind.Sequential)] +internal unsafe struct DiplomatSliceU16 +{ + public char* Ptr; + public nuint Len; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU32.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU32.cs new file mode 100644 index 000000000..2581b2d19 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU32.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +[StructLayout(LayoutKind.Sequential)] +internal unsafe struct DiplomatSliceU32 +{ + public uint* Ptr; + public nuint Len; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU8.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU8.cs new file mode 100644 index 000000000..56e2257f8 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatSliceU8.cs @@ -0,0 +1,10 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +[StructLayout(LayoutKind.Sequential)] +internal unsafe struct DiplomatSliceU8 +{ + public byte* Ptr; + public nuint Len; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatWrite.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatWrite.cs new file mode 100644 index 000000000..ff1f0de7d --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DiplomatWrite.cs @@ -0,0 +1,166 @@ +using System; +using System.Runtime.InteropServices; + +#if __IOS__ +using ObjCRuntime; +#endif + +namespace Devolutions.IronRdp.Diplomat; + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +internal delegate void WriteableFlush(IntPtr self); + +[UnmanagedFunctionPointer(CallingConvention.Cdecl)] +[return: MarshalAs(UnmanagedType.U1)] +internal delegate bool WriteableGrow(IntPtr self, nuint capacity); + +/// +/// Caller-provided writer that Rust appends UTF-8 bytes into. +/// Use after a Rust call returns to extract the +/// written content as a managed string. Dispose to free the underlying +/// unmanaged buffer. +/// +// Mirrors the Rust `DiplomatWrite` repr(C) layout. The `byte growFailed` +// field corresponds to Rust's `grow_failed: bool`; Sequential layout pads +// it to the next 8-byte boundary so `flush`/`grow` land at offsets 40/48. +[StructLayout(LayoutKind.Sequential)] +internal struct DiplomatWrite : IDisposable +{ + IntPtr context; + IntPtr buf; + nuint len; + nuint cap; + byte growFailed; + readonly IntPtr flush; + readonly IntPtr grow; + + public DiplomatWrite() + { + WriteableFlush flushFunc = Flush; + WriteableGrow growFunc = Grow; + + IntPtr flushFuncPtr = Marshal.GetFunctionPointerForDelegate(flushFunc); + IntPtr growFuncPtr = Marshal.GetFunctionPointerForDelegate(growFunc); + + // Hold the delegate objects alive for as long as the function-pointer + // form is in use. Without this, the GC could free the thunks and + // Rust's callback into them would crash. + DiplomatWriteContext ctx = new DiplomatWriteContext + { + flushFunc = flushFunc, + growFunc = growFunc, + }; + GCHandle ctxHandle = GCHandle.Alloc(ctx); + + context = GCHandle.ToIntPtr(ctxHandle); + buf = Marshal.AllocHGlobal(64); + len = 0; + cap = 64; + growFailed = 0; + flush = flushFuncPtr; + grow = growFuncPtr; + } + + public byte[] ToUtf8Bytes() + { + if (len > int.MaxValue) + { + throw new IndexOutOfRangeException("DiplomatWrite buffer is too big"); + } + byte[] managedArray = new byte[(int)len]; + Marshal.Copy(buf, managedArray, 0, (int)len); + return managedArray; + } + + public string ToUnicode() + { + if (len > int.MaxValue) + { + throw new IndexOutOfRangeException("DiplomatWrite buffer is too big"); + } +#if NET6_0_OR_GREATER + return Marshal.PtrToStringUTF8(buf, (int)len) ?? string.Empty; +#else + // `Marshal.PtrToStringUTF8` doesn't exist on netstandard2.0 / .NET + // Framework. Fall back to copying the bytes out and decoding via + // `Encoding.UTF8`, both of which are available there. + return System.Text.Encoding.UTF8.GetString(ToUtf8Bytes()); +#endif + } + + public void Dispose() + { + if (buf != IntPtr.Zero) + { + Marshal.FreeHGlobal(buf); + buf = IntPtr.Zero; + } + + if (context != IntPtr.Zero) + { + GCHandle.FromIntPtr(context).Free(); + context = IntPtr.Zero; + } + } + +#if __IOS__ + [MonoPInvokeCallback(typeof(WriteableFlush))] +#endif + private static void Flush(IntPtr self) + { + // Nothing to do — Rust signals "I'm done writing" but we don't + // need to act on it. The caller will read via ToUnicode() when + // it's ready. + } + +#if __IOS__ + [MonoPInvokeCallback(typeof(WriteableGrow))] +#endif + [return: MarshalAs(UnmanagedType.U1)] + private unsafe static bool Grow(IntPtr writeable, nuint capacity) + { + if (writeable == IntPtr.Zero) + { + return false; + } + DiplomatWrite* self = (DiplomatWrite*)writeable; + + nuint newCap = capacity; + if (newCap > int.MaxValue) + { + return false; + } + + // Rust only ever grows the buffer, but guard against a `newCap` + // smaller than the bytes we're about to copy: `Buffer.MemoryCopy` + // would otherwise read past the new allocation. Refuse the grow + // instead of corrupting unmanaged memory. + if (newCap < self->len) + { + return false; + } + + IntPtr newBuf; + try + { + newBuf = Marshal.AllocHGlobal((int)newCap); + } + catch (OutOfMemoryException) + { + return false; + } + + Buffer.MemoryCopy((void*)self->buf, (void*)newBuf, newCap, self->len); + Marshal.FreeHGlobal(self->buf); + self->buf = newBuf; + self->cap = newCap; + + return true; + } +} + +internal struct DiplomatWriteContext +{ + internal WriteableFlush flushFunc; + internal WriteableGrow growFunc; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DrdynvcChannel.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DrdynvcChannel.cs index d42952916..4a2bcd9e3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DrdynvcChannel.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DrdynvcChannel.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class DrdynvcChannel: IDisposable { - private unsafe Raw.DrdynvcChannel* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DrdynvcChannel.Destroy; /// /// Creates a managed DrdynvcChannel from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DrdynvcChannel(Raw.DrdynvcChannel* handle) + internal unsafe DrdynvcChannel(Raw.DrdynvcChannel* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DrdynvcChannel(Raw.DrdynvcChannel* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DrdynvcChannel(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DrdynvcChannel* AsFFI() + internal unsafe Raw.DrdynvcChannel* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DrdynvcChannel.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyConfig.cs index b90fca700..c2c173c12 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyConfig.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class DvcPipeProxyConfig: IDisposable { - private unsafe Raw.DvcPipeProxyConfig* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DvcPipeProxyConfig.Destroy; public DvcPipeProxyMessageSink MessageSink { @@ -27,14 +32,38 @@ public DvcPipeProxyMessageSink MessageSink /// Creates a managed DvcPipeProxyConfig from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DvcPipeProxyConfig(Raw.DvcPipeProxyConfig* handle) + internal unsafe DvcPipeProxyConfig(Raw.DvcPipeProxyConfig* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DvcPipeProxyConfig(Raw.DvcPipeProxyConfig* handle, object[] edges) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DvcPipeProxyConfig(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -44,14 +73,12 @@ public static DvcPipeProxyConfig New(DvcPipeProxyMessageSink messageSink) { unsafe { - Raw.DvcPipeProxyMessageSink* messageSinkRaw; - messageSinkRaw = messageSink.AsFFI(); - if (messageSinkRaw == null) - { - throw new ObjectDisposedException("DvcPipeProxyMessageSink"); - } - Raw.DvcPipeProxyConfig* retVal = Raw.DvcPipeProxyConfig.New(messageSinkRaw); - return new DvcPipeProxyConfig(retVal); + if (messageSink == null) throw new ArgumentNullException(nameof(messageSink)); + Raw.DvcPipeProxyMessageSink* messageSinkRaw = messageSink.AsFFI(); + if (messageSinkRaw == null) throw new ObjectDisposedException(nameof(DvcPipeProxyMessageSink)); + Raw.DvcPipeProxyConfig* result = Raw.DvcPipeProxyConfig.New(messageSinkRaw); + GC.KeepAlive(messageSink); + return new DvcPipeProxyConfig(result); } } @@ -59,17 +86,16 @@ public void AddPipeProxy(DvcPipeProxyDescriptor descriptor) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyConfig"); } - Raw.DvcPipeProxyDescriptor* descriptorRaw; - descriptorRaw = descriptor.AsFFI(); - if (descriptorRaw == null) - { - throw new ObjectDisposedException("DvcPipeProxyDescriptor"); - } - Raw.DvcPipeProxyConfig.AddPipeProxy(_inner, descriptorRaw); + if (descriptor == null) throw new ArgumentNullException(nameof(descriptor)); + Raw.DvcPipeProxyDescriptor* descriptorRaw = descriptor.AsFFI(); + if (descriptorRaw == null) throw new ObjectDisposedException(nameof(DvcPipeProxyDescriptor)); + Raw.DvcPipeProxyConfig.AddPipeProxy(AsFFI(), descriptorRaw); + GC.KeepAlive(this); + GC.KeepAlive(descriptor); } } @@ -80,21 +106,22 @@ public DvcPipeProxyMessageSink GetMessageSink() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyConfig"); } - Raw.DvcPipeProxyMessageSink* retVal = Raw.DvcPipeProxyConfig.GetMessageSink(_inner); - return new DvcPipeProxyMessageSink(retVal); + Raw.DvcPipeProxyMessageSink* result = Raw.DvcPipeProxyConfig.GetMessageSink(AsFFI()); + GC.KeepAlive(this); + return new DvcPipeProxyMessageSink(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DvcPipeProxyConfig* AsFFI() + internal unsafe Raw.DvcPipeProxyConfig* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -104,13 +131,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DvcPipeProxyConfig.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -120,4 +148,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyDescriptor.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyDescriptor.cs index 668507a47..0f6a595ad 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyDescriptor.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyDescriptor.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class DvcPipeProxyDescriptor: IDisposable { - private unsafe Raw.DvcPipeProxyDescriptor* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DvcPipeProxyDescriptor.Destroy; /// /// Creates a managed DvcPipeProxyDescriptor from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DvcPipeProxyDescriptor(Raw.DvcPipeProxyDescriptor* handle) + internal unsafe DvcPipeProxyDescriptor(Raw.DvcPipeProxyDescriptor* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DvcPipeProxyDescriptor(Raw.DvcPipeProxyDescriptor* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DvcPipeProxyDescriptor(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,17 +65,15 @@ public static DvcPipeProxyDescriptor New(string channelName, string pipeName) { unsafe { - byte[] channelNameBuf = DiplomatUtils.StringToUtf8(channelName); - byte[] pipeNameBuf = DiplomatUtils.StringToUtf8(pipeName); - nuint channelNameBufLength = (nuint)channelNameBuf.Length; - nuint pipeNameBufLength = (nuint)pipeNameBuf.Length; - fixed (byte* channelNameBufPtr = channelNameBuf) + if (channelName == null) throw new ArgumentNullException(nameof(channelName)); + if (pipeName == null) throw new ArgumentNullException(nameof(pipeName)); + byte[] channelNameBytes = Diplomat.Utf8.Clone(channelName); + byte[] pipeNameBytes = Diplomat.Utf8.Clone(pipeName); + fixed (byte* channelNamePtr = channelNameBytes) + fixed (byte* pipeNamePtr = pipeNameBytes) { - fixed (byte* pipeNameBufPtr = pipeNameBuf) - { - Raw.DvcPipeProxyDescriptor* retVal = Raw.DvcPipeProxyDescriptor.New(channelNameBufPtr, channelNameBufLength, pipeNameBufPtr, pipeNameBufLength); - return new DvcPipeProxyDescriptor(retVal); - } + Raw.DvcPipeProxyDescriptor* result = Raw.DvcPipeProxyDescriptor.New(new DiplomatSliceU8 { Ptr = channelNamePtr, Len = (nuint)channelNameBytes.Length }, new DiplomatSliceU8 { Ptr = pipeNamePtr, Len = (nuint)pipeNameBytes.Length }); + return new DvcPipeProxyDescriptor(result); } } } @@ -54,9 +81,9 @@ public static DvcPipeProxyDescriptor New(string channelName, string pipeName) /// /// Returns the underlying raw handle. /// - public unsafe Raw.DvcPipeProxyDescriptor* AsFFI() + internal unsafe Raw.DvcPipeProxyDescriptor* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -66,13 +93,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DvcPipeProxyDescriptor.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -82,4 +110,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessage.cs index 3343d9f71..33802baae 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessage.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class DvcPipeProxyMessage: IDisposable { - private unsafe Raw.DvcPipeProxyMessage* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DvcPipeProxyMessage.Destroy; public uint ChannelId { @@ -27,35 +32,60 @@ public uint ChannelId /// Creates a managed DvcPipeProxyMessage from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DvcPipeProxyMessage(Raw.DvcPipeProxyMessage* handle) + internal unsafe DvcPipeProxyMessage(Raw.DvcPipeProxyMessage* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DvcPipeProxyMessage(Raw.DvcPipeProxyMessage* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DvcPipeProxyMessage(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public uint GetChannelId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyMessage"); } - uint retVal = Raw.DvcPipeProxyMessage.GetChannelId(_inner); - return retVal; + var result = Raw.DvcPipeProxyMessage.GetChannelId(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DvcPipeProxyMessage* AsFFI() + internal unsafe Raw.DvcPipeProxyMessage* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -65,13 +95,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DvcPipeProxyMessage.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -81,4 +112,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageQueue.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageQueue.cs index b53ac53cf..2ec52f252 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageQueue.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageQueue.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class DvcPipeProxyMessageQueue: IDisposable { - private unsafe Raw.DvcPipeProxyMessageQueue* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DvcPipeProxyMessageQueue.Destroy; public DvcPipeProxyMessageSink Sink { @@ -27,14 +32,38 @@ public DvcPipeProxyMessageSink Sink /// Creates a managed DvcPipeProxyMessageQueue from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DvcPipeProxyMessageQueue(Raw.DvcPipeProxyMessageQueue* handle) + internal unsafe DvcPipeProxyMessageQueue(Raw.DvcPipeProxyMessageQueue* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DvcPipeProxyMessageQueue(Raw.DvcPipeProxyMessageQueue* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DvcPipeProxyMessageQueue(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -44,8 +73,8 @@ public static DvcPipeProxyMessageQueue New(uint queueSize) { unsafe { - Raw.DvcPipeProxyMessageQueue* retVal = Raw.DvcPipeProxyMessageQueue.New(queueSize); - return new DvcPipeProxyMessageQueue(retVal); + Raw.DvcPipeProxyMessageQueue* result = Raw.DvcPipeProxyMessageQueue.New(queueSize); + return new DvcPipeProxyMessageQueue(result); } } @@ -53,25 +82,21 @@ public static DvcPipeProxyMessageQueue New(uint queueSize) /// /// A DvcPipeProxyMessage allocated on Rust side. /// - public DvcPipeProxyMessage NextMessage() + public DvcPipeProxyMessage? NextMessage() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyMessageQueue"); } - Raw.DvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError result = Raw.DvcPipeProxyMessageQueue.NextMessage(_inner); - if (!result.isOk) + var result = Raw.DvcPipeProxyMessageQueue.NextMessage(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.DvcPipeProxyMessage* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new DvcPipeProxyMessage(retVal); + return result.Ok == null ? null : new DvcPipeProxyMessage(result.Ok); } } @@ -83,17 +108,17 @@ public DvcPipeProxyMessage NextMessageBlocking() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyMessageQueue"); } - Raw.DvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError result = Raw.DvcPipeProxyMessageQueue.NextMessageBlocking(_inner); - if (!result.isOk) + var result = Raw.DvcPipeProxyMessageQueue.NextMessageBlocking(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.DvcPipeProxyMessage* retVal = result.Ok; - return new DvcPipeProxyMessage(retVal); + return new DvcPipeProxyMessage(result.Ok); } } @@ -104,21 +129,22 @@ public DvcPipeProxyMessageSink GetSink() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DvcPipeProxyMessageQueue"); } - Raw.DvcPipeProxyMessageSink* retVal = Raw.DvcPipeProxyMessageQueue.GetSink(_inner); - return new DvcPipeProxyMessageSink(retVal); + Raw.DvcPipeProxyMessageSink* result = Raw.DvcPipeProxyMessageQueue.GetSink(AsFFI()); + GC.KeepAlive(this); + return new DvcPipeProxyMessageSink(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DvcPipeProxyMessageQueue* AsFFI() + internal unsafe Raw.DvcPipeProxyMessageQueue* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -128,13 +154,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DvcPipeProxyMessageQueue.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -144,4 +171,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageSink.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageSink.cs index c2d9b98b1..8a08630f8 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageSink.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DvcPipeProxyMessageSink.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class DvcPipeProxyMessageSink: IDisposable { - private unsafe Raw.DvcPipeProxyMessageSink* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DvcPipeProxyMessageSink.Destroy; /// /// Creates a managed DvcPipeProxyMessageSink from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DvcPipeProxyMessageSink(Raw.DvcPipeProxyMessageSink* handle) + internal unsafe DvcPipeProxyMessageSink(Raw.DvcPipeProxyMessageSink* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DvcPipeProxyMessageSink(Raw.DvcPipeProxyMessageSink* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DvcPipeProxyMessageSink(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DvcPipeProxyMessageSink* AsFFI() + internal unsafe Raw.DvcPipeProxyMessageSink* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DvcPipeProxyMessageSink.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/DynState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/DynState.cs index ac9c42fd7..550e7c5a9 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/DynState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/DynState.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class DynState: IDisposable { - private unsafe Raw.DynState* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.DynState.Destroy; public string Name { @@ -27,31 +32,38 @@ public string Name /// Creates a managed DynState from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe DynState(Raw.DynState* handle) + internal unsafe DynState(Raw.DynState* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); } - /// - public void GetName(DiplomatWriteable writeable) + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe DynState(Raw.DynState* handle, object[] edges) { - unsafe - { - if (_inner == null) - { - throw new ObjectDisposedException("DynState"); - } - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.DynState.GetName(_inner, &writeable); - if (!result.isOk) - { - throw new IronRdpException(new IronRdpError(result.Err)); - } - } + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe DynState(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -59,19 +71,25 @@ public string GetName() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DynState"); } - DiplomatWriteable writeable = new DiplomatWriteable(); - Raw.ConnectorFfiResultVoidBoxIronRdpError result = Raw.DynState.GetName(_inner, &writeable); - if (!result.isOk) + DiplomatWrite writeable = new DiplomatWrite(); + try + { + var result = Raw.DynState.GetName(AsFFI(), &writeable); + GC.KeepAlive(this); + if (!result.IsOk) + { + throw new IronRdpException(new IronRdpError(result.Err)); + } + return writeable.ToUnicode(); + } + finally { - throw new IronRdpException(new IronRdpError(result.Err)); + writeable.Dispose(); } - string retVal = writeable.ToUnicode(); - writeable.Dispose(); - return retVal; } } @@ -79,21 +97,22 @@ public bool IsTerminal() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("DynState"); } - bool retVal = Raw.DynState.IsTerminal(_inner); - return retVal; + var result = Raw.DynState.IsTerminal(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.DynState* AsFFI() + internal unsafe Raw.DynState* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -103,13 +122,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.DynState.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -119,4 +139,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEvent.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEvent.cs index 2323938f4..8a2df949c 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEvent.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEvent.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class FastPathInputEvent: IDisposable { - private unsafe Raw.FastPathInputEvent* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.FastPathInputEvent.Destroy; /// /// Creates a managed FastPathInputEvent from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe FastPathInputEvent(Raw.FastPathInputEvent* handle) + internal unsafe FastPathInputEvent(Raw.FastPathInputEvent* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe FastPathInputEvent(Raw.FastPathInputEvent* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe FastPathInputEvent(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.FastPathInputEvent* AsFFI() + internal unsafe Raw.FastPathInputEvent* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.FastPathInputEvent.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEventIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEventIterator.cs index e68281465..edb282380 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEventIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/FastPathInputEventIterator.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class FastPathInputEventIterator: IDisposable { - private unsafe Raw.FastPathInputEventIterator* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.FastPathInputEventIterator.Destroy; /// /// Creates a managed FastPathInputEventIterator from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe FastPathInputEventIterator(Raw.FastPathInputEventIterator* handle) + internal unsafe FastPathInputEventIterator(Raw.FastPathInputEventIterator* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe FastPathInputEventIterator(Raw.FastPathInputEventIterator* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe FastPathInputEventIterator(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.FastPathInputEventIterator* AsFFI() + internal unsafe Raw.FastPathInputEventIterator* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.FastPathInputEventIterator.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsRequest.cs index 49ed637b9..840f5b6f4 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsRequest.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,32 +10,65 @@ namespace Devolutions.IronRdp; public partial class FfiFileContentsRequest: IDisposable { - private unsafe Raw.FfiFileContentsRequest* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.FfiFileContentsRequest.Destroy; /// /// Creates a managed FfiFileContentsRequest from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe FfiFileContentsRequest(Raw.FfiFileContentsRequest* handle) + internal unsafe FfiFileContentsRequest(Raw.FfiFileContentsRequest* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe FfiFileContentsRequest(Raw.FfiFileContentsRequest* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe FfiFileContentsRequest(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public uint StreamId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - uint retVal = Raw.FfiFileContentsRequest.StreamId(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.StreamId(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -46,12 +76,13 @@ public int Index() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - int retVal = Raw.FfiFileContentsRequest.Index(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.Index(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -59,12 +90,13 @@ public bool IsSizeRequest() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - bool retVal = Raw.FfiFileContentsRequest.IsSizeRequest(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.IsSizeRequest(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -72,12 +104,13 @@ public bool IsRangeRequest() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - bool retVal = Raw.FfiFileContentsRequest.IsRangeRequest(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.IsRangeRequest(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -85,12 +118,13 @@ public ulong Position() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - ulong retVal = Raw.FfiFileContentsRequest.Position(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.Position(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -98,12 +132,13 @@ public uint RequestedSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - uint retVal = Raw.FfiFileContentsRequest.RequestedSize(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.RequestedSize(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -111,12 +146,13 @@ public bool HasDataId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - bool retVal = Raw.FfiFileContentsRequest.HasDataId(_inner); - return retVal; + var result = Raw.FfiFileContentsRequest.HasDataId(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -125,26 +161,26 @@ public uint DataId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsRequest"); } - Raw.ClipboardMessageFfiResultU32BoxIronRdpError result = Raw.FfiFileContentsRequest.DataId(_inner); - if (!result.isOk) + var result = Raw.FfiFileContentsRequest.DataId(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - uint retVal = result.Ok; - return retVal; + return result.Ok; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.FfiFileContentsRequest* AsFFI() + internal unsafe Raw.FfiFileContentsRequest* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -154,13 +190,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.FfiFileContentsRequest.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -170,4 +207,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsResponse.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsResponse.cs index f1f3b68b2..ba23151a6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsResponse.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/FfiFileContentsResponse.cs @@ -1,48 +1,74 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; #nullable enable -/// -/// Wraps `OwnedFileContentsResponse`, which is a type alias for -/// `FileContentsResponse<'static>` (generated by `impl_pdu_borrowing!`). -/// public partial class FfiFileContentsResponse: IDisposable { - private unsafe Raw.FfiFileContentsResponse* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.FfiFileContentsResponse.Destroy; /// /// Creates a managed FfiFileContentsResponse from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe FfiFileContentsResponse(Raw.FfiFileContentsResponse* handle) + internal unsafe FfiFileContentsResponse(Raw.FfiFileContentsResponse* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe FfiFileContentsResponse(Raw.FfiFileContentsResponse* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe FfiFileContentsResponse(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public uint StreamId() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsResponse"); } - uint retVal = Raw.FfiFileContentsResponse.StreamId(_inner); - return retVal; + var result = Raw.FfiFileContentsResponse.StreamId(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -50,12 +76,13 @@ public bool IsError() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsResponse"); } - bool retVal = Raw.FfiFileContentsResponse.IsError(_inner); - return retVal; + var result = Raw.FfiFileContentsResponse.IsError(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -66,21 +93,22 @@ public VecU8 Data() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("FfiFileContentsResponse"); } - Raw.VecU8* retVal = Raw.FfiFileContentsResponse.Data(_inner); - return new VecU8(retVal); + Raw.VecU8* result = Raw.FfiFileContentsResponse.Data(AsFFI()); + GC.KeepAlive(this); + return new VecU8(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.FfiFileContentsResponse* AsFFI() + internal unsafe Raw.FfiFileContentsResponse* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -90,13 +118,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.FfiFileContentsResponse.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -106,4 +135,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/FormatDataResponse.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/FormatDataResponse.cs index afeff1bc3..3e7c1d265 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/FormatDataResponse.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/FormatDataResponse.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class FormatDataResponse: IDisposable { - private unsafe Raw.FormatDataResponse* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.FormatDataResponse.Destroy; /// /// Creates a managed FormatDataResponse from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe FormatDataResponse(Raw.FormatDataResponse* handle) + internal unsafe FormatDataResponse(Raw.FormatDataResponse* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe FormatDataResponse(Raw.FormatDataResponse* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe FormatDataResponse(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.FormatDataResponse* AsFFI() + internal unsafe Raw.FormatDataResponse* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.FormatDataResponse.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/GeneratorState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/GeneratorState.cs index 50a5c7d75..53e075515 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/GeneratorState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/GeneratorState.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class GeneratorState: IDisposable { - private unsafe Raw.GeneratorState* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.GeneratorState.Destroy; public ClientState ClientStateIfCompleted { @@ -23,6 +28,10 @@ public ClientState ClientStateIfCompleted } } + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public NetworkRequest? NetworkRequestIfSuspended { get @@ -35,26 +44,51 @@ public NetworkRequest? NetworkRequestIfSuspended /// Creates a managed GeneratorState from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe GeneratorState(Raw.GeneratorState* handle) + internal unsafe GeneratorState(Raw.GeneratorState* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe GeneratorState(Raw.GeneratorState* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe GeneratorState(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } public bool IsSuspended() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("GeneratorState"); } - bool retVal = Raw.GeneratorState.IsSuspended(_inner); - return retVal; + var result = Raw.GeneratorState.IsSuspended(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -62,32 +96,34 @@ public bool IsCompleted() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("GeneratorState"); } - bool retVal = Raw.GeneratorState.IsCompleted(_inner); - return retVal; + var result = Raw.GeneratorState.IsCompleted(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// A NetworkRequest allocated on Rust side. /// + /// + /// Lifetime: the returned native-backed value may borrow from the receiver or one or more inputs. + /// The caller is responsible for keeping any borrowed backing storage alive and undisposed while the returned value is in use. + /// public NetworkRequest? GetNetworkRequestIfSuspended() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("GeneratorState"); } - Raw.NetworkRequest* retVal = Raw.GeneratorState.GetNetworkRequestIfSuspended(_inner); - if (retVal == null) - { - return null; - } - return new NetworkRequest(retVal); + Raw.NetworkRequest* result = Raw.GeneratorState.GetNetworkRequestIfSuspended(AsFFI()); + GC.KeepAlive(this); + return result == null ? null : new NetworkRequest(result, new object[] { this }); } } @@ -99,26 +135,26 @@ public ClientState GetClientStateIfCompleted() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("GeneratorState"); } - Raw.CredsspNetworkFfiResultBoxClientStateBoxIronRdpError result = Raw.GeneratorState.GetClientStateIfCompleted(_inner); - if (!result.isOk) + var result = Raw.GeneratorState.GetClientStateIfCompleted(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClientState* retVal = result.Ok; - return new ClientState(retVal); + return new ClientState(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.GeneratorState* AsFFI() + internal unsafe Raw.GeneratorState* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -128,13 +164,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.GeneratorState.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -144,4 +181,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/GracefulDisconnectReason.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/GracefulDisconnectReason.cs index 8e8c22a5d..d924bd2de 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/GracefulDisconnectReason.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/GracefulDisconnectReason.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class GracefulDisconnectReason: IDisposable { - private unsafe Raw.GracefulDisconnectReason* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.GracefulDisconnectReason.Destroy; /// /// Creates a managed GracefulDisconnectReason from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe GracefulDisconnectReason(Raw.GracefulDisconnectReason* handle) + internal unsafe GracefulDisconnectReason(Raw.GracefulDisconnectReason* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe GracefulDisconnectReason(Raw.GracefulDisconnectReason* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe GracefulDisconnectReason(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.GracefulDisconnectReason* AsFFI() + internal unsafe Raw.GracefulDisconnectReason* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.GracefulDisconnectReason.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/InclusiveRectangle.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/InclusiveRectangle.cs index 219cf4c00..48302c317 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/InclusiveRectangle.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/InclusiveRectangle.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class InclusiveRectangle: IDisposable { - private unsafe Raw.InclusiveRectangle* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.InclusiveRectangle.Destroy; public ushort Bottom { @@ -67,26 +72,51 @@ public ushort Width /// Creates a managed InclusiveRectangle from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe InclusiveRectangle(Raw.InclusiveRectangle* handle) + internal unsafe InclusiveRectangle(Raw.InclusiveRectangle* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe InclusiveRectangle(Raw.InclusiveRectangle* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe InclusiveRectangle(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public ushort GetLeft() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetLeft(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetLeft(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -94,12 +124,13 @@ public ushort GetTop() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetTop(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetTop(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -107,12 +138,13 @@ public ushort GetRight() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetRight(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetRight(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -120,12 +152,13 @@ public ushort GetBottom() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetBottom(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetBottom(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -133,12 +166,13 @@ public ushort GetWidth() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetWidth(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetWidth(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -146,21 +180,22 @@ public ushort GetHeight() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InclusiveRectangle"); } - ushort retVal = Raw.InclusiveRectangle.GetHeight(_inner); - return retVal; + var result = Raw.InclusiveRectangle.GetHeight(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.InclusiveRectangle* AsFFI() + internal unsafe Raw.InclusiveRectangle* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -170,13 +205,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.InclusiveRectangle.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -186,4 +222,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/InputDatabase.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/InputDatabase.cs index d754dd559..e5983b290 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/InputDatabase.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/InputDatabase.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class InputDatabase: IDisposable { - private unsafe Raw.InputDatabase* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.InputDatabase.Destroy; /// /// Creates a managed InputDatabase from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe InputDatabase(Raw.InputDatabase* handle) + internal unsafe InputDatabase(Raw.InputDatabase* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe InputDatabase(Raw.InputDatabase* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe InputDatabase(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static InputDatabase New() { unsafe { - Raw.InputDatabase* retVal = Raw.InputDatabase.New(); - return new InputDatabase(retVal); + Raw.InputDatabase* result = Raw.InputDatabase.New(); + return new InputDatabase(result); } } @@ -48,27 +77,26 @@ public FastPathInputEventIterator Apply(Operation operation) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("InputDatabase"); } - Raw.Operation* operationRaw; - operationRaw = operation.AsFFI(); - if (operationRaw == null) - { - throw new ObjectDisposedException("Operation"); - } - Raw.FastPathInputEventIterator* retVal = Raw.InputDatabase.Apply(_inner, operationRaw); - return new FastPathInputEventIterator(retVal); + if (operation == null) throw new ArgumentNullException(nameof(operation)); + Raw.Operation* operationRaw = operation.AsFFI(); + if (operationRaw == null) throw new ObjectDisposedException(nameof(Operation)); + Raw.FastPathInputEventIterator* result = Raw.InputDatabase.Apply(AsFFI(), operationRaw); + GC.KeepAlive(this); + GC.KeepAlive(operation); + return new FastPathInputEventIterator(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.InputDatabase* AsFFI() + internal unsafe Raw.InputDatabase* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -78,13 +106,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.InputDatabase.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -94,4 +123,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpError.cs index d2c25abf9..17782e76f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpError.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpError.cs @@ -1,22 +1,24 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; #nullable enable -/// -/// Stringified Picky error along with an error kind. -/// public partial class IronRdpError: IDisposable { - private unsafe Raw.IronRdpError* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.IronRdpError.Destroy; public IronRdpErrorKind Kind { @@ -30,75 +32,82 @@ public IronRdpErrorKind Kind /// Creates a managed IronRdpError from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe IronRdpError(Raw.IronRdpError* handle) + internal unsafe IronRdpError(Raw.IronRdpError* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); } - /// - /// Returns the error as a string. - /// - public void ToDisplay(DiplomatWriteable writeable) + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe IronRdpError(Raw.IronRdpError* handle, object[] edges) { - unsafe - { - if (_inner == null) - { - throw new ObjectDisposedException("IronRdpError"); - } - Raw.IronRdpError.ToDisplay(_inner, &writeable); - } + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; } /// - /// Returns the error as a string. + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. /// + internal unsafe IronRdpError(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; + } + public string ToDisplay() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("IronRdpError"); } - DiplomatWriteable writeable = new DiplomatWriteable(); - Raw.IronRdpError.ToDisplay(_inner, &writeable); - string retVal = writeable.ToUnicode(); - writeable.Dispose(); - return retVal; + DiplomatWrite writeable = new DiplomatWrite(); + try + { + Raw.IronRdpError.ToDisplay(AsFFI(), &writeable); + GC.KeepAlive(this); + return writeable.ToUnicode(); + } + finally + { + writeable.Dispose(); + } } } - /// - /// Returns the error kind. - /// - /// - /// A IronRdpErrorKind allocated on C# side. - /// public IronRdpErrorKind GetKind() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("IronRdpError"); } - Raw.IronRdpErrorKind retVal = Raw.IronRdpError.GetKind(_inner); - return (IronRdpErrorKind)retVal; + var result = Raw.IronRdpError.GetKind(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.IronRdpError* AsFFI() + internal unsafe Raw.IronRdpError* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -108,13 +117,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.IronRdpError.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -124,4 +134,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpErrorKind.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpErrorKind.cs index 0f9ec353e..b523c4b8a 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpErrorKind.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpErrorKind.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum IronRdpErrorKind +public enum IronRdpErrorKind : int { Generic = 0, PduError = 1, @@ -19,9 +8,9 @@ public enum IronRdpErrorKind DecodeError = 3, CredsspError = 4, Consumed = 5, - IO = 6, + Io = 6, AccessDenied = 7, IncorrectEnumType = 8, Clipboard = 9, - WrongOS = 10, -} + WrongOs = 10, +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpException.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpException.cs index 1dc629155..bef589d73 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpException.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpException.cs @@ -1,30 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; -#nullable enable - -public partial class IronRdpException : Exception +public class IronRdpException : Exception { - private IronRdpError _inner; - - public IronRdpException(IronRdpError inner) : base(inner.ToDisplay()) - { - _inner = inner; - } + public IronRdpError Inner { get; } + private readonly object[] _edges; - public IronRdpError Inner + public IronRdpException(IronRdpError inner, params object[] edges) : base( + inner.ToDisplay() + ) { - get - { - return _inner; - } + Inner = inner; + _edges = edges; } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpPdu.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpPdu.cs index 2bebeedeb..4c87878f9 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpPdu.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/IronRdpPdu.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class IronRdpPdu: IDisposable { - private unsafe Raw.IronRdpPdu* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.IronRdpPdu.Destroy; /// /// Creates a managed IronRdpPdu from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe IronRdpPdu(Raw.IronRdpPdu* handle) + internal unsafe IronRdpPdu(Raw.IronRdpPdu* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe IronRdpPdu(Raw.IronRdpPdu* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe IronRdpPdu(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static IronRdpPdu New() { unsafe { - Raw.IronRdpPdu* retVal = Raw.IronRdpPdu.New(); - return new IronRdpPdu(retVal); + Raw.IronRdpPdu* result = Raw.IronRdpPdu.New(); + return new IronRdpPdu(result); } } @@ -45,28 +74,24 @@ public static IronRdpPdu New() /// /// A PduInfo allocated on Rust side. /// - public PduInfo FindSize(byte[] bytes) + public PduInfo? FindSize(byte[] bytes) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("IronRdpPdu"); } - nuint bytesLength = (nuint)bytes.Length; + if (bytes == null) throw new ArgumentNullException(nameof(bytes)); fixed (byte* bytesPtr = bytes) { - Raw.PduFfiResultOptBoxPduInfoBoxIronRdpError result = Raw.IronRdpPdu.FindSize(_inner, bytesPtr, bytesLength); - if (!result.isOk) + var result = Raw.IronRdpPdu.FindSize(AsFFI(), new DiplomatSliceU8 { Ptr = bytesPtr, Len = (nuint)bytes.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.PduInfo* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new PduInfo(retVal); + return result.Ok == null ? null : new PduInfo(result.Ok); } } } @@ -74,9 +99,9 @@ public PduInfo FindSize(byte[] bytes) /// /// Returns the underlying raw handle. /// - public unsafe Raw.IronRdpPdu* AsFFI() + internal unsafe Raw.IronRdpPdu* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -86,13 +111,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.IronRdpPdu.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -102,4 +128,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/KerberosConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/KerberosConfig.cs index 0cb7f570b..8d043f1a2 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/KerberosConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/KerberosConfig.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class KerberosConfig: IDisposable { - private unsafe Raw.KerberosConfig* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.KerberosConfig.Destroy; /// /// Creates a managed KerberosConfig from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe KerberosConfig(Raw.KerberosConfig* handle) + internal unsafe KerberosConfig(Raw.KerberosConfig* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe KerberosConfig(Raw.KerberosConfig* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe KerberosConfig(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.KerberosConfig* AsFFI() + internal unsafe Raw.KerberosConfig* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.KerberosConfig.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/KeyboardType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/KeyboardType.cs index fe13b4c60..a5b9e7751 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/KeyboardType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/KeyboardType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum KeyboardType +public enum KeyboardType : int { IbmPcXt = 0, OlivettiIco = 1, @@ -20,4 +9,4 @@ public enum KeyboardType Nokia1050 = 4, Nokia9140 = 5, Japanese = 6, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/LicenseExchangeSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/LicenseExchangeSequence.cs index b80e82607..ea7a82f65 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/LicenseExchangeSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/LicenseExchangeSequence.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class LicenseExchangeSequence: IDisposable { - private unsafe Raw.LicenseExchangeSequence* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.LicenseExchangeSequence.Destroy; /// /// Creates a managed LicenseExchangeSequence from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe LicenseExchangeSequence(Raw.LicenseExchangeSequence* handle) + internal unsafe LicenseExchangeSequence(Raw.LicenseExchangeSequence* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe LicenseExchangeSequence(Raw.LicenseExchangeSequence* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe LicenseExchangeSequence(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.LicenseExchangeSequence* AsFFI() + internal unsafe Raw.LicenseExchangeSequence* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.LicenseExchangeSequence.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Log.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Log.cs index c0e3af52f..abc79767a 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Log.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Log.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,29 +10,54 @@ namespace Devolutions.IronRdp; public partial class Log: IDisposable { - private unsafe Raw.Log* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Log.Destroy; /// /// Creates a managed Log from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Log(Raw.Log* handle) + internal unsafe Log(Raw.Log* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); } - /// - /// # Panics - /// /// - /// - Panics if log directory creation fails. - /// - Panics if tracing initialization fails. + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. /// + internal unsafe Log(Raw.Log* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Log(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; + } + public static void InitWithEnv() { unsafe @@ -47,9 +69,9 @@ public static void InitWithEnv() /// /// Returns the underlying raw handle. /// - public unsafe Raw.Log* AsFFI() + internal unsafe Raw.Log* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -59,13 +81,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Log.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -75,4 +98,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButton.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButton.cs index 70dee4bdb..bee705ec1 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButton.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButton.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class MouseButton: IDisposable { - private unsafe Raw.MouseButton* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.MouseButton.Destroy; /// /// Creates a managed MouseButton from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe MouseButton(Raw.MouseButton* handle) + internal unsafe MouseButton(Raw.MouseButton* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe MouseButton(Raw.MouseButton* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe MouseButton(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,10 +65,8 @@ public static MouseButton New(MouseButtonType button) { unsafe { - Raw.MouseButtonType buttonRaw; - buttonRaw = (Raw.MouseButtonType)button; - Raw.MouseButton* retVal = Raw.MouseButton.New(buttonRaw); - return new MouseButton(retVal); + Raw.MouseButton* result = Raw.MouseButton.New(button); + return new MouseButton(result); } } @@ -50,12 +77,13 @@ public Operation AsOperationMouseButtonPressed() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("MouseButton"); } - Raw.Operation* retVal = Raw.MouseButton.AsOperationMouseButtonPressed(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.MouseButton.AsOperationMouseButtonPressed(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } @@ -66,21 +94,22 @@ public Operation AsOperationMouseButtonReleased() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("MouseButton"); } - Raw.Operation* retVal = Raw.MouseButton.AsOperationMouseButtonReleased(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.MouseButton.AsOperationMouseButtonReleased(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.MouseButton* AsFFI() + internal unsafe Raw.MouseButton* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -90,13 +119,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.MouseButton.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -106,4 +136,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButtonType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButtonType.cs index e84e07518..b16bea14c 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButtonType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/MouseButtonType.cs @@ -1,21 +1,10 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum MouseButtonType +public enum MouseButtonType : int { Left = 0, Middle = 1, Right = 2, X1 = 3, X2 = 4, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/MousePosition.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/MousePosition.cs index daf15e364..51f6e27c4 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/MousePosition.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/MousePosition.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class MousePosition: IDisposable { - private unsafe Raw.MousePosition* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.MousePosition.Destroy; /// /// Creates a managed MousePosition from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe MousePosition(Raw.MousePosition* handle) + internal unsafe MousePosition(Raw.MousePosition* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe MousePosition(Raw.MousePosition* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe MousePosition(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static MousePosition New(ushort x, ushort y) { unsafe { - Raw.MousePosition* retVal = Raw.MousePosition.New(x, y); - return new MousePosition(retVal); + Raw.MousePosition* result = Raw.MousePosition.New(x, y); + return new MousePosition(result); } } @@ -48,21 +77,22 @@ public Operation AsMoveOperation() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("MousePosition"); } - Raw.Operation* retVal = Raw.MousePosition.AsMoveOperation(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.MousePosition.AsMoveOperation(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.MousePosition* AsFFI() + internal unsafe Raw.MousePosition* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -72,13 +102,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.MousePosition.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -88,4 +119,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/MultitransportRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/MultitransportRequest.cs index 45ea7431b..32ac29806 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/MultitransportRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/MultitransportRequest.cs @@ -1,69 +1,26 @@ // by Diplomat - -#pragma warning disable 0105 +#nullable enable using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; -#nullable enable - -public partial class MultitransportRequest +[StructLayout(LayoutKind.Sequential)] +public partial struct MultitransportRequest { - private Raw.MultitransportRequest _inner; - - public uint RequestId - { - get - { - unsafe - { - return _inner.request_id; - } - } - set - { - unsafe - { - _inner.request_id = value; - } - } - } - - public ushort RequestedProtocol - { - get - { - unsafe - { - return _inner.requested_protocol; - } - } - set - { - unsafe - { - _inner.requested_protocol = value; - } - } - } + public uint RequestId; + public ushort RequestedProtocol; - /// - /// Creates a managed MultitransportRequest from the raw representation. - /// - public unsafe MultitransportRequest(Raw.MultitransportRequest data) + internal Raw.MultitransportRequest AsFFI() => new Raw.MultitransportRequest { - _inner = data; - } + RequestId = this.RequestId, + RequestedProtocol = this.RequestedProtocol, + }; - /// - /// Returns a copy of the underlying raw representation. - /// - public Raw.MultitransportRequest AsFFI() + internal static MultitransportRequest FromFFI(Raw.MultitransportRequest raw) => new MultitransportRequest { - return _inner; - } -} + RequestId = raw.RequestId, + RequestedProtocol = raw.RequestedProtocol, + }; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/NativeLib.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/NativeLib.cs new file mode 100644 index 000000000..35eb4abdf --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/NativeLib.cs @@ -0,0 +1,15 @@ +using System.Runtime.InteropServices; + +namespace Devolutions.IronRdp.Diplomat; + +// Shared native-library name for every `[DllImport]` in the raw layer. +// Emitted once per generation run so the iOS framework-bundle path and the +// bare name aren't duplicated into every `Raw*` struct. +internal static class DiplomatNativeLib +{ +#if __IOS__ + internal const string Name = "libDevolutionsIronRdp.framework/libDevolutionsIronRdp"; +#else + internal const string Name = "DevolutionsIronRdp"; +#endif +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkCharacteristics.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkCharacteristics.cs index be08be046..17e71333b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkCharacteristics.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkCharacteristics.cs @@ -1,137 +1,35 @@ // by Diplomat - -#pragma warning disable 0105 +#nullable enable using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; -#nullable enable - -/// -/// Connection quality measurements from server auto-detect (MS-RDPBCGR 2.2.14). -/// -public partial class NetworkCharacteristics +[StructLayout(LayoutKind.Sequential)] +public partial struct NetworkCharacteristics { - private Raw.NetworkCharacteristics _inner; - - /// - /// Lowest detected round-trip time in milliseconds. - /// Only valid when `has_base_rtt` is true. - /// - public uint BaseRttMs - { - get - { - unsafe - { - return _inner.base_rtt_ms; - } - } - set - { - unsafe - { - _inner.base_rtt_ms = value; - } - } - } - - public bool HasBaseRtt - { - get - { - unsafe - { - return _inner.has_base_rtt; - } - } - set - { - unsafe - { - _inner.has_base_rtt = value; - } - } - } - - /// - /// Current average round-trip time in milliseconds. - /// - public uint AverageRttMs - { - get - { - unsafe - { - return _inner.average_rtt_ms; - } - } - set - { - unsafe - { - _inner.average_rtt_ms = value; - } - } - } - - /// - /// Estimated bandwidth in kilobits per second. - /// Only valid when `has_bandwidth` is true. - /// - public uint BandwidthKbps - { - get - { - unsafe - { - return _inner.bandwidth_kbps; - } - } - set - { - unsafe - { - _inner.bandwidth_kbps = value; - } - } - } - - public bool HasBandwidth - { - get - { - unsafe - { - return _inner.has_bandwidth; - } - } - set - { - unsafe - { - _inner.has_bandwidth = value; - } - } - } + public uint BaseRttMs; + public bool HasBaseRtt; + public uint AverageRttMs; + public uint BandwidthKbps; + public bool HasBandwidth; - /// - /// Creates a managed NetworkCharacteristics from the raw representation. - /// - public unsafe NetworkCharacteristics(Raw.NetworkCharacteristics data) + internal Raw.NetworkCharacteristics AsFFI() => new Raw.NetworkCharacteristics { - _inner = data; - } - - /// - /// Returns a copy of the underlying raw representation. - /// - public Raw.NetworkCharacteristics AsFFI() + BaseRttMs = this.BaseRttMs, + HasBaseRtt = this.HasBaseRtt, + AverageRttMs = this.AverageRttMs, + BandwidthKbps = this.BandwidthKbps, + HasBandwidth = this.HasBandwidth, + }; + + internal static NetworkCharacteristics FromFFI(Raw.NetworkCharacteristics raw) => new NetworkCharacteristics { - return _inner; - } -} + BaseRttMs = raw.BaseRttMs, + HasBaseRtt = raw.HasBaseRtt, + AverageRttMs = raw.AverageRttMs, + BandwidthKbps = raw.BandwidthKbps, + HasBandwidth = raw.HasBandwidth, + }; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequest.cs index 88044c8a1..2a690ea52 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequest.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class NetworkRequest: IDisposable { - private unsafe Raw.NetworkRequest* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.NetworkRequest.Destroy; public VecU8 Data { @@ -43,14 +48,38 @@ public string Url /// Creates a managed NetworkRequest from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe NetworkRequest(Raw.NetworkRequest* handle) + internal unsafe NetworkRequest(Raw.NetworkRequest* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe NetworkRequest(Raw.NetworkRequest* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe NetworkRequest(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -60,75 +89,63 @@ public VecU8 GetData() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("NetworkRequest"); } - Raw.VecU8* retVal = Raw.NetworkRequest.GetData(_inner); - return new VecU8(retVal); + Raw.VecU8* result = Raw.NetworkRequest.GetData(AsFFI()); + GC.KeepAlive(this); + return new VecU8(result); } } - /// - /// A NetworkRequestProtocol allocated on C# side. - /// public NetworkRequestProtocol GetProtocol() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("NetworkRequest"); } - Raw.NetworkRequestProtocol retVal = Raw.NetworkRequest.GetProtocol(_inner); - return (NetworkRequestProtocol)retVal; + var result = Raw.NetworkRequest.GetProtocol(AsFFI()); + GC.KeepAlive(this); + return result; } } /// - public void GetUrl(DiplomatWriteable writeable) + public string GetUrl() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("NetworkRequest"); } - Raw.CredsspNetworkFfiResultVoidBoxIronRdpError result = Raw.NetworkRequest.GetUrl(_inner, &writeable); - if (!result.isOk) - { - throw new IronRdpException(new IronRdpError(result.Err)); - } - } - } - - /// - public string GetUrl() - { - unsafe - { - if (_inner == null) + DiplomatWrite writeable = new DiplomatWrite(); + try { - throw new ObjectDisposedException("NetworkRequest"); + var result = Raw.NetworkRequest.GetUrl(AsFFI(), &writeable); + GC.KeepAlive(this); + if (!result.IsOk) + { + throw new IronRdpException(new IronRdpError(result.Err)); + } + return writeable.ToUnicode(); } - DiplomatWriteable writeable = new DiplomatWriteable(); - Raw.CredsspNetworkFfiResultVoidBoxIronRdpError result = Raw.NetworkRequest.GetUrl(_inner, &writeable); - if (!result.isOk) + finally { - throw new IronRdpException(new IronRdpError(result.Err)); + writeable.Dispose(); } - string retVal = writeable.ToUnicode(); - writeable.Dispose(); - return retVal; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.NetworkRequest* AsFFI() + internal unsafe Raw.NetworkRequest* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -138,13 +155,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.NetworkRequest.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -154,4 +172,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequestProtocol.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequestProtocol.cs index 1dd231125..ed2c72ee4 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequestProtocol.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/NetworkRequestProtocol.cs @@ -1,20 +1,9 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum NetworkRequestProtocol +public enum NetworkRequestProtocol : int { Tcp = 0, Udp = 1, Http = 2, Https = 3, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Operation.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Operation.cs index a7a3dcd21..fddd9160e 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Operation.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Operation.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class Operation: IDisposable { - private unsafe Raw.Operation* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Operation.Destroy; /// /// Creates a managed Operation from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Operation(Raw.Operation* handle) + internal unsafe Operation(Raw.Operation* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Operation(Raw.Operation* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Operation(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Operation* AsFFI() + internal unsafe Raw.Operation* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Operation.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/OperationType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/OperationType.cs index 553542410..6d246a4cf 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/OperationType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/OperationType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum OperationType +public enum OperationType : int { MouseButtonPressed = 0, MouseButtonReleased = 1, @@ -21,4 +10,4 @@ public enum OperationType KeyReleased = 5, UnicodeKeyPressed = 6, UnicodeKeyReleased = 7, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/OptionalUsize.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/OptionalUsize.cs index 1d8621a4c..4fc64b018 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/OptionalUsize.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/OptionalUsize.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,32 +10,65 @@ namespace Devolutions.IronRdp; public partial class OptionalUsize: IDisposable { - private unsafe Raw.OptionalUsize* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.OptionalUsize.Destroy; /// /// Creates a managed OptionalUsize from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe OptionalUsize(Raw.OptionalUsize* handle) + internal unsafe OptionalUsize(Raw.OptionalUsize* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe OptionalUsize(Raw.OptionalUsize* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe OptionalUsize(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public bool IsSome() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("OptionalUsize"); } - bool retVal = Raw.OptionalUsize.IsSome(_inner); - return retVal; + var result = Raw.OptionalUsize.IsSome(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -47,26 +77,26 @@ public nuint Get() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("OptionalUsize"); } - Raw.UtilsFfiResultUsizeBoxIronRdpError result = Raw.OptionalUsize.Get(_inner); - if (!result.isOk) + var result = Raw.OptionalUsize.Get(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - nuint retVal = result.Ok; - return retVal; + return result.Ok; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.OptionalUsize* AsFFI() + internal unsafe Raw.OptionalUsize* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -76,13 +106,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.OptionalUsize.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -92,4 +123,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/PduHint.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/PduHint.cs index 6969ca84c..0a49b2b55 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/PduHint.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/PduHint.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class PduHint: IDisposable { - private unsafe Raw.PduHint* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.PduHint.Destroy; /// /// Creates a managed PduHint from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe PduHint(Raw.PduHint* handle) + internal unsafe PduHint(Raw.PduHint* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe PduHint(Raw.PduHint* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe PduHint(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -37,20 +66,20 @@ public OptionalUsize FindSize(byte[] bytes) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("PduHint"); } - nuint bytesLength = (nuint)bytes.Length; + if (bytes == null) throw new ArgumentNullException(nameof(bytes)); fixed (byte* bytesPtr = bytes) { - Raw.ConnectorFfiResultBoxOptionalUsizeBoxIronRdpError result = Raw.PduHint.FindSize(_inner, bytesPtr, bytesLength); - if (!result.isOk) + var result = Raw.PduHint.FindSize(AsFFI(), new DiplomatSliceU8 { Ptr = bytesPtr, Len = (nuint)bytes.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.OptionalUsize* retVal = result.Ok; - return new OptionalUsize(retVal); + return new OptionalUsize(result.Ok); } } } @@ -58,9 +87,9 @@ public OptionalUsize FindSize(byte[] bytes) /// /// Returns the underlying raw handle. /// - public unsafe Raw.PduHint* AsFFI() + internal unsafe Raw.PduHint* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -70,13 +99,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.PduHint.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -86,4 +116,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/PduInfo.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/PduInfo.cs index 94ce1093b..e43636fcc 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/PduInfo.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/PduInfo.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class PduInfo: IDisposable { - private unsafe Raw.PduInfo* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.PduInfo.Destroy; public Action Action { @@ -35,14 +40,38 @@ public nuint Length /// Creates a managed PduInfo from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe PduInfo(Raw.PduInfo* handle) + internal unsafe PduInfo(Raw.PduInfo* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe PduInfo(Raw.PduInfo* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe PduInfo(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -52,12 +81,13 @@ public Action GetAction() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("PduInfo"); } - Raw.Action* retVal = Raw.PduInfo.GetAction(_inner); - return new Action(retVal); + Raw.Action* result = Raw.PduInfo.GetAction(AsFFI()); + GC.KeepAlive(this); + return new Action(result); } } @@ -65,21 +95,22 @@ public nuint GetLength() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("PduInfo"); } - nuint retVal = Raw.PduInfo.GetLength(_inner); - return retVal; + var result = Raw.PduInfo.GetLength(AsFFI()); + GC.KeepAlive(this); + return result; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.PduInfo* AsFFI() + internal unsafe Raw.PduInfo* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -89,13 +120,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.PduInfo.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -105,4 +137,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlags.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlags.cs index e49b7e57f..19d5652b3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlags.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlags.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class PerformanceFlags: IDisposable { - private unsafe Raw.PerformanceFlags* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.PerformanceFlags.Destroy; /// /// Creates a managed PerformanceFlags from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe PerformanceFlags(Raw.PerformanceFlags* handle) + internal unsafe PerformanceFlags(Raw.PerformanceFlags* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe PerformanceFlags(Raw.PerformanceFlags* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe PerformanceFlags(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static PerformanceFlags NewDefault() { unsafe { - Raw.PerformanceFlags* retVal = Raw.PerformanceFlags.NewDefault(); - return new PerformanceFlags(retVal); + Raw.PerformanceFlags* result = Raw.PerformanceFlags.NewDefault(); + return new PerformanceFlags(result); } } @@ -48,8 +77,8 @@ public static PerformanceFlags NewEmpty() { unsafe { - Raw.PerformanceFlags* retVal = Raw.PerformanceFlags.NewEmpty(); - return new PerformanceFlags(retVal); + Raw.PerformanceFlags* result = Raw.PerformanceFlags.NewEmpty(); + return new PerformanceFlags(result); } } @@ -57,22 +86,21 @@ public void AddFlag(PerformanceFlagsType flag) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("PerformanceFlags"); } - Raw.PerformanceFlagsType flagRaw; - flagRaw = (Raw.PerformanceFlagsType)flag; - Raw.PerformanceFlags.AddFlag(_inner, flagRaw); + Raw.PerformanceFlags.AddFlag(AsFFI(), flag); + GC.KeepAlive(this); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.PerformanceFlags* AsFFI() + internal unsafe Raw.PerformanceFlags* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -82,13 +110,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.PerformanceFlags.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -98,4 +127,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlagsType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlagsType.cs index cab76e289..600314838 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlagsType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/PerformanceFlagsType.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum PerformanceFlagsType +public enum PerformanceFlagsType : int { DisableWallpaper = 0, DisableFullWindowDrag = 1, @@ -23,4 +12,4 @@ public enum PerformanceFlagsType EnableFontSmoothing = 7, EnableDesktopComposition = 8, Reserved2 = 9, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/PixelFormat.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/PixelFormat.cs index f952c6910..f3f0d90dc 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/PixelFormat.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/PixelFormat.cs @@ -1,17 +1,6 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum PixelFormat +public enum PixelFormat : int { ARgb32 = 0, XRgb32 = 1, @@ -21,4 +10,4 @@ public enum PixelFormat BgrX32 = 5, RgbA32 = 6, RgbX32 = 7, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Position.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Position.cs index e7bc1a896..112676f05 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Position.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Position.cs @@ -1,69 +1,26 @@ // by Diplomat - -#pragma warning disable 0105 +#nullable enable using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; -#nullable enable - -public partial class Position +[StructLayout(LayoutKind.Sequential)] +public partial struct Position { - private Raw.Position _inner; - - public ushort X - { - get - { - unsafe - { - return _inner.x; - } - } - set - { - unsafe - { - _inner.x = value; - } - } - } - - public ushort Y - { - get - { - unsafe - { - return _inner.y; - } - } - set - { - unsafe - { - _inner.y = value; - } - } - } + public ushort X; + public ushort Y; - /// - /// Creates a managed Position from the raw representation. - /// - public unsafe Position(Raw.Position data) + internal Raw.Position AsFFI() => new Raw.Position { - _inner = data; - } + X = this.X, + Y = this.Y, + }; - /// - /// Returns a copy of the underlying raw representation. - /// - public Raw.Position AsFFI() + internal static Position FromFFI(Raw.Position raw) => new Position { - return _inner; - } -} + X = raw.X, + Y = raw.Y, + }; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathDetectionResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathDetectionResult.cs index 644c997e6..d0332b733 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathDetectionResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathDetectionResult.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class RDCleanPathDetectionResult: IDisposable { - private unsafe Raw.RDCleanPathDetectionResult* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.RDCleanPathDetectionResult.Destroy; public nuint TotalLength { @@ -27,26 +32,51 @@ public nuint TotalLength /// Creates a managed RDCleanPathDetectionResult from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe RDCleanPathDetectionResult(Raw.RDCleanPathDetectionResult* handle) + internal unsafe RDCleanPathDetectionResult(Raw.RDCleanPathDetectionResult* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe RDCleanPathDetectionResult(Raw.RDCleanPathDetectionResult* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe RDCleanPathDetectionResult(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public bool IsDetected() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathDetectionResult"); } - bool retVal = Raw.RDCleanPathDetectionResult.IsDetected(_inner); - return retVal; + var result = Raw.RDCleanPathDetectionResult.IsDetected(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -54,12 +84,13 @@ public bool IsNotEnoughBytes() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathDetectionResult"); } - bool retVal = Raw.RDCleanPathDetectionResult.IsNotEnoughBytes(_inner); - return retVal; + var result = Raw.RDCleanPathDetectionResult.IsNotEnoughBytes(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -67,12 +98,13 @@ public bool IsFailed() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathDetectionResult"); } - bool retVal = Raw.RDCleanPathDetectionResult.IsFailed(_inner); - return retVal; + var result = Raw.RDCleanPathDetectionResult.IsFailed(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -81,26 +113,26 @@ public nuint GetTotalLength() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathDetectionResult"); } - Raw.RdcleanpathFfiResultUsizeBoxIronRdpError result = Raw.RDCleanPathDetectionResult.GetTotalLength(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathDetectionResult.GetTotalLength(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - nuint retVal = result.Ok; - return retVal; + return result.Ok; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.RDCleanPathDetectionResult* AsFFI() + internal unsafe Raw.RDCleanPathDetectionResult* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -110,13 +142,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.RDCleanPathDetectionResult.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -126,4 +159,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathPdu.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathPdu.cs index b4c5d6278..40e3684e3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathPdu.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathPdu.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class RDCleanPathPdu: IDisposable { - private unsafe Raw.RDCleanPathPdu* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.RDCleanPathPdu.Destroy; public ushort ErrorCode { @@ -75,26 +80,40 @@ public VecU8 X224Response /// Creates a managed RDCleanPathPdu from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe RDCleanPathPdu(Raw.RDCleanPathPdu* handle) + internal unsafe RDCleanPathPdu(Raw.RDCleanPathPdu* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); } - /// - /// Creates a new RDCleanPath request PDU - /// /// - /// # Arguments - /// * `x224_pdu` - The X.224 Connection Request PDU bytes - /// * `destination` - The destination RDP server address (e.g., "10.10.0.3:3389") - /// * `proxy_auth` - The JWT authentication token - /// * `pcb` - Optional preconnection blob (for Hyper-V VM connections, empty string if not needed) + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. /// + internal unsafe RDCleanPathPdu(Raw.RDCleanPathPdu* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe RDCleanPathPdu(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; + } + /// /// /// A RDCleanPathPdu allocated on Rust side. @@ -103,38 +122,28 @@ public static RDCleanPathPdu NewRequest(byte[] x224Pdu, string destination, stri { unsafe { - byte[] destinationBuf = DiplomatUtils.StringToUtf8(destination); - byte[] proxyAuthBuf = DiplomatUtils.StringToUtf8(proxyAuth); - byte[] pcbBuf = DiplomatUtils.StringToUtf8(pcb); - nuint x224PduLength = (nuint)x224Pdu.Length; - nuint destinationBufLength = (nuint)destinationBuf.Length; - nuint proxyAuthBufLength = (nuint)proxyAuthBuf.Length; - nuint pcbBufLength = (nuint)pcbBuf.Length; + if (x224Pdu == null) throw new ArgumentNullException(nameof(x224Pdu)); + if (destination == null) throw new ArgumentNullException(nameof(destination)); + if (proxyAuth == null) throw new ArgumentNullException(nameof(proxyAuth)); + if (pcb == null) throw new ArgumentNullException(nameof(pcb)); + byte[] destinationBytes = Diplomat.Utf8.Clone(destination); + byte[] proxyAuthBytes = Diplomat.Utf8.Clone(proxyAuth); + byte[] pcbBytes = Diplomat.Utf8.Clone(pcb); fixed (byte* x224PduPtr = x224Pdu) + fixed (byte* destinationPtr = destinationBytes) + fixed (byte* proxyAuthPtr = proxyAuthBytes) + fixed (byte* pcbPtr = pcbBytes) { - fixed (byte* destinationBufPtr = destinationBuf) + var result = Raw.RDCleanPathPdu.NewRequest(new DiplomatSliceU8 { Ptr = x224PduPtr, Len = (nuint)x224Pdu.Length }, new DiplomatSliceU8 { Ptr = destinationPtr, Len = (nuint)destinationBytes.Length }, new DiplomatSliceU8 { Ptr = proxyAuthPtr, Len = (nuint)proxyAuthBytes.Length }, new DiplomatSliceU8 { Ptr = pcbPtr, Len = (nuint)pcbBytes.Length }); + if (!result.IsOk) { - fixed (byte* proxyAuthBufPtr = proxyAuthBuf) - { - fixed (byte* pcbBufPtr = pcbBuf) - { - Raw.RdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError result = Raw.RDCleanPathPdu.NewRequest(x224PduPtr, x224PduLength, destinationBufPtr, destinationBufLength, proxyAuthBufPtr, proxyAuthBufLength, pcbBufPtr, pcbBufLength); - if (!result.isOk) - { - throw new IronRdpException(new IronRdpError(result.Err)); - } - Raw.RDCleanPathPdu* retVal = result.Ok; - return new RDCleanPathPdu(retVal); - } - } + throw new IronRdpException(new IronRdpError(result.Err)); } + return new RDCleanPathPdu(result.Ok); } } } - /// - /// Decodes a RDCleanPath PDU from DER-encoded bytes - /// /// /// /// A RDCleanPathPdu allocated on Rust side. @@ -143,23 +152,19 @@ public static RDCleanPathPdu FromDer(byte[] bytes) { unsafe { - nuint bytesLength = (nuint)bytes.Length; + if (bytes == null) throw new ArgumentNullException(nameof(bytes)); fixed (byte* bytesPtr = bytes) { - Raw.RdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError result = Raw.RDCleanPathPdu.FromDer(bytesPtr, bytesLength); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.FromDer(new DiplomatSliceU8 { Ptr = bytesPtr, Len = (nuint)bytes.Length }); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.RDCleanPathPdu* retVal = result.Ok; - return new RDCleanPathPdu(retVal); + return new RDCleanPathPdu(result.Ok); } } } - /// - /// Encodes the RDCleanPath PDU to DER-encoded bytes - /// /// /// /// A VecU8 allocated on Rust side. @@ -168,23 +173,20 @@ public VecU8 ToDer() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultBoxVecU8BoxIronRdpError result = Raw.RDCleanPathPdu.ToDer(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.ToDer(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } - /// - /// Detects if the bytes contain a valid RDCleanPath PDU and returns detection result - /// /// /// A RDCleanPathDetectionResult allocated on Rust side. /// @@ -192,43 +194,34 @@ public static RDCleanPathDetectionResult Detect(byte[] bytes) { unsafe { - nuint bytesLength = (nuint)bytes.Length; + if (bytes == null) throw new ArgumentNullException(nameof(bytes)); fixed (byte* bytesPtr = bytes) { - Raw.RDCleanPathDetectionResult* retVal = Raw.RDCleanPathPdu.Detect(bytesPtr, bytesLength); - return new RDCleanPathDetectionResult(retVal); + Raw.RDCleanPathDetectionResult* result = Raw.RDCleanPathPdu.Detect(new DiplomatSliceU8 { Ptr = bytesPtr, Len = (nuint)bytes.Length }); + return new RDCleanPathDetectionResult(result); } } } - /// - /// Gets the type of this RDCleanPath PDU - /// /// - /// - /// A RDCleanPathResultType allocated on C# side. - /// public RDCleanPathResultType GetType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError result = Raw.RDCleanPathPdu.GetType(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.GetType(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.RDCleanPathResultType retVal = result.Ok; - return (RDCleanPathResultType)retVal; + return result.Ok; } } - /// - /// Gets the X.224 connection response bytes (for Response or NegotiationError variants) - /// /// /// /// A VecU8 allocated on Rust side. @@ -237,24 +230,20 @@ public VecU8 GetX224Response() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultBoxVecU8BoxIronRdpError result = Raw.RDCleanPathPdu.GetX224Response(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.GetX224Response(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.VecU8* retVal = result.Ok; - return new VecU8(retVal); + return new VecU8(result.Ok); } } - /// - /// Gets the server certificate chain (for Response variant) - /// Returns a vector iterator of certificate bytes - /// /// /// /// A CertificateChainIterator allocated on Rust side. @@ -263,139 +252,108 @@ public CertificateChainIterator GetServerCertChain() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError result = Raw.RDCleanPathPdu.GetServerCertChain(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.GetServerCertChain(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.CertificateChainIterator* retVal = result.Ok; - return new CertificateChainIterator(retVal); + return new CertificateChainIterator(result.Ok); } } - /// - /// Gets the server address string (for Response variant) - /// - public void GetServerAddr(DiplomatWriteable writeable) + public string GetServerAddr() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RDCleanPathPdu.GetServerAddr(_inner, &writeable); - } - } - - /// - /// Gets the server address string (for Response variant) - /// - public string GetServerAddr() - { - unsafe - { - if (_inner == null) + DiplomatWrite writeable = new DiplomatWrite(); + try { - throw new ObjectDisposedException("RDCleanPathPdu"); + Raw.RDCleanPathPdu.GetServerAddr(AsFFI(), &writeable); + GC.KeepAlive(this); + return writeable.ToUnicode(); } - DiplomatWriteable writeable = new DiplomatWriteable(); - Raw.RDCleanPathPdu.GetServerAddr(_inner, &writeable); - string retVal = writeable.ToUnicode(); - writeable.Dispose(); - return retVal; - } - } - - /// - /// Gets error message (for GeneralError variant) - /// - public void GetErrorMessage(DiplomatWriteable writeable) - { - unsafe - { - if (_inner == null) + finally { - throw new ObjectDisposedException("RDCleanPathPdu"); + writeable.Dispose(); } - Raw.RDCleanPathPdu.GetErrorMessage(_inner, &writeable); } } - /// - /// Gets error message (for GeneralError variant) - /// public string GetErrorMessage() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - DiplomatWriteable writeable = new DiplomatWriteable(); - Raw.RDCleanPathPdu.GetErrorMessage(_inner, &writeable); - string retVal = writeable.ToUnicode(); - writeable.Dispose(); - return retVal; + DiplomatWrite writeable = new DiplomatWrite(); + try + { + Raw.RDCleanPathPdu.GetErrorMessage(AsFFI(), &writeable); + GC.KeepAlive(this); + return writeable.ToUnicode(); + } + finally + { + writeable.Dispose(); + } } } - /// - /// Gets the error code (for GeneralError variant) - /// /// public ushort GetErrorCode() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultU16BoxIronRdpError result = Raw.RDCleanPathPdu.GetErrorCode(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.GetErrorCode(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - ushort retVal = result.Ok; - return retVal; + return result.Ok; } } - /// - /// Gets the HTTP status code if present (for GeneralError variant) - /// Returns error if not present or not a GeneralError variant - /// /// public ushort GetHttpStatusCode() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("RDCleanPathPdu"); } - Raw.RdcleanpathFfiResultU16BoxIronRdpError result = Raw.RDCleanPathPdu.GetHttpStatusCode(_inner); - if (!result.isOk) + var result = Raw.RDCleanPathPdu.GetHttpStatusCode(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - ushort retVal = result.Ok; - return retVal; + return result.Ok; } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.RDCleanPathPdu* AsFFI() + internal unsafe Raw.RDCleanPathPdu* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -405,13 +363,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.RDCleanPathPdu.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -421,4 +380,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathResultType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathResultType.cs index 4145574e1..ea7b48cd2 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathResultType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RDCleanPathResultType.cs @@ -1,20 +1,9 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum RDCleanPathResultType +public enum RDCleanPathResultType : int { Request = 0, Response = 1, GeneralError = 2, NegotiationError = 3, -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawAction.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawAction.cs index 87c5a1e26..e394c75df 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawAction.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawAction.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Action +internal partial struct Action { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Action_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Action* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Action_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Action* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStage.cs index 005417238..e3f09d2ec 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStage.cs @@ -1,65 +1,50 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ActiveStage +internal partial struct ActiveStage { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_new", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxActiveStageBoxIronRdpError New(ConnectionResult* connectionResult); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultActiveStageIronRdpError New(ConnectionResult* connectionResult); - /// - /// Produces a fresh connection activation sequence to drive the Deactivation-Reactivation - /// Sequence. - /// - /// - /// Call this upon receiving a [`ActiveStageOutputType::DeactivateAll`] output, drive the - /// returned sequence until it is finalized, then discard it. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_create_connection_activation", ExactSpelling = true)] - public static unsafe extern ConnectionActivationSequence* CreateConnectionActivation(ActiveStage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_create_connection_activation", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ConnectionActivationSequence* CreateConnectionActivation(ActiveStage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_process", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError Process(ActiveStage* self, DecodedImage* image, Action* action, byte* payload, nuint payloadSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_process", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultActiveStageOutputIteratorIronRdpError Process(ActiveStage* handle, DecodedImage* image, Action* action, DiplomatSliceU8 payload); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_process_fastpath_input", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError ProcessFastpathInput(ActiveStage* self, DecodedImage* image, FastPathInputEventIterator* fastpathInput); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_process_fastpath_input", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultActiveStageOutputIteratorIronRdpError ProcessFastpathInput(ActiveStage* handle, DecodedImage* image, FastPathInputEventIterator* fastpathInput); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_initiate_clipboard_copy", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxVecU8BoxIronRdpError InitiateClipboardCopy(ActiveStage* self, ClipboardFormatIterator* formats); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_initiate_clipboard_copy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError InitiateClipboardCopy(ActiveStage* handle, ClipboardFormatIterator* formats); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_initiate_clipboard_paste", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxVecU8BoxIronRdpError InitiateClipboardPaste(ActiveStage* self, ClipboardFormatId* formatId); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_initiate_clipboard_paste", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError InitiateClipboardPaste(ActiveStage* handle, ClipboardFormatId* formatId); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_submit_clipboard_format_data", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxVecU8BoxIronRdpError SubmitClipboardFormatData(ActiveStage* self, FormatDataResponse* formatDataResponse); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_submit_clipboard_format_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError SubmitClipboardFormatData(ActiveStage* handle, FormatDataResponse* formatDataResponse); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_send_dvc_pipe_proxy_message", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxVecU8BoxIronRdpError SendDvcPipeProxyMessage(ActiveStage* self, DvcPipeProxyMessage* message); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_send_dvc_pipe_proxy_message", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError SendDvcPipeProxyMessage(ActiveStage* handle, DvcPipeProxyMessage* message); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_graceful_shutdown", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError GracefulShutdown(ActiveStage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_graceful_shutdown", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultActiveStageOutputIteratorIronRdpError GracefulShutdown(ActiveStage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_encoded_resize", ExactSpelling = true)] - public static unsafe extern SessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError EncodedResize(ActiveStage* self, uint width, uint height); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_encoded_resize", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultActiveStageOutputIteratorIronRdpError EncodedResize(ActiveStage* handle, uint width, uint height); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_set_fastpath_processor", ExactSpelling = true)] - public static unsafe extern void SetFastpathProcessor(ActiveStage* self, ushort ioChannelId, ushort userChannelId, uint shareId, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer, [MarshalAs(UnmanagedType.U1)] bool pointerSoftwareRendering); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_set_fastpath_processor", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetFastpathProcessor(ActiveStage* handle, ushort ioChannelId, ushort userChannelId, uint shareId, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer, [MarshalAs(UnmanagedType.U1)] bool pointerSoftwareRendering); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_set_enable_server_pointer", ExactSpelling = true)] - public static unsafe extern void SetEnableServerPointer(ActiveStage* self, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_set_enable_server_pointer", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetEnableServerPointer(ActiveStage* handle, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStage_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ActiveStage* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStage_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ActiveStage* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutput.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutput.cs index 8c56dee46..a665ace4c 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutput.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutput.cs @@ -1,58 +1,38 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ActiveStageOutput +internal partial struct ActiveStageOutput { - private const string NativeLib = "DevolutionsIronRdp"; - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_enum_type", ExactSpelling = true)] - public static unsafe extern ActiveStageOutputType GetEnumType(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_response_frame", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxBytesSliceBoxIronRdpError GetResponseFrame(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_graphics_update", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxInclusiveRectangleBoxIronRdpError GetGraphicsUpdate(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_pointer_position", ExactSpelling = true)] - public static unsafe extern SessionFfiResultPositionBoxIronRdpError GetPointerPosition(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_pointer_bitmap", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxDecodedPointerBoxIronRdpError GetPointerBitmap(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_terminate", ExactSpelling = true)] - public static unsafe extern SessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError GetTerminate(ActiveStageOutput* self); - - /// - /// Returns the multitransport request ID and requested protocol. - /// - /// - /// The security cookie is intentionally not exposed — it is sensitive - /// and only needed internally for transport binding. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_multitransport_request", ExactSpelling = true)] - public static unsafe extern SessionFfiResultMultitransportRequestBoxIronRdpError GetMultitransportRequest(ActiveStageOutput* self); - - /// - /// Connection quality signals from the server's auto-detect mechanism. - /// Returns RTT and bandwidth measurements for health monitoring. - /// These values will feed into FramePacingFeedback when the - /// library-level health observer traits from #1158 land. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_get_autodetect_network_characteristics", ExactSpelling = true)] - public static unsafe extern SessionFfiResultNetworkCharacteristicsBoxIronRdpError GetAutodetectNetworkCharacteristics(ActiveStageOutput* self); - - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutput_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ActiveStageOutput* self); -} + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_enum_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ActiveStageOutputType GetEnumType(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_response_frame", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultBytesSliceIronRdpError GetResponseFrame(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_graphics_update", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultInclusiveRectangleIronRdpError GetGraphicsUpdate(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_pointer_position", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultPositionIronRdpError GetPointerPosition(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_pointer_bitmap", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultDecodedPointerIronRdpError GetPointerBitmap(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_terminate", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultGracefulDisconnectReasonIronRdpError GetTerminate(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_multitransport_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultMultitransportRequestIronRdpError GetMultitransportRequest(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_get_autodetect_network_characteristics", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultNetworkCharacteristicsIronRdpError GetAutodetectNetworkCharacteristics(ActiveStageOutput* handle); + + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutput_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ActiveStageOutput* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputIterator.cs index 1d7b4b20a..f21d3b58f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputIterator.cs @@ -1,31 +1,24 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ActiveStageOutputIterator +internal partial struct ActiveStageOutputIterator { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutputIterator_len", ExactSpelling = true)] - public static unsafe extern nuint Len(ActiveStageOutputIterator* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutputIterator_len", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint Len(ActiveStageOutputIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutputIterator_is_empty", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutputIterator_is_empty", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsEmpty(ActiveStageOutputIterator* self); + internal static unsafe extern bool IsEmpty(ActiveStageOutputIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutputIterator_next", ExactSpelling = true)] - public static unsafe extern ActiveStageOutput* Next(ActiveStageOutputIterator* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutputIterator_next", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ActiveStageOutput* Next(ActiveStageOutputIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ActiveStageOutputIterator_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ActiveStageOutputIterator* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ActiveStageOutputIterator_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ActiveStageOutputIterator* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputType.cs deleted file mode 100644 index bc500012d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawActiveStageOutputType.cs +++ /dev/null @@ -1,31 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum ActiveStageOutputType -{ - ResponseFrame = 0, - GraphicsUpdate = 1, - PointerDefault = 2, - PointerHidden = 3, - PointerPosition = 4, - PointerBitmap = 5, - Terminate = 6, - DeactivateAll = 7, - MultitransportRequest = 8, - /// - /// Auto-detect network characteristics from server. - /// Use `get_autodetect_network_characteristics()` to retrieve - /// RTT and bandwidth values for connection quality monitoring. - /// - AutoDetect = 9, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawBitmapConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawBitmapConfig.cs index 0cfede60a..27dbb0044 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawBitmapConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawBitmapConfig.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct BitmapConfig +internal partial struct BitmapConfig { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "BitmapConfig_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(BitmapConfig* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "BitmapConfig_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(BitmapConfig* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawBytesSlice.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawBytesSlice.cs index 3d7e6f8ca..f846c04fb 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawBytesSlice.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawBytesSlice.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct BytesSlice +internal partial struct BytesSlice { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "BytesSlice_get_size", ExactSpelling = true)] - public static unsafe extern nuint GetSize(BytesSlice* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "BytesSlice_get_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint GetSize(BytesSlice* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "BytesSlice_fill", ExactSpelling = true)] - public static unsafe extern UtilsFfiResultVoidBoxIronRdpError Fill(BytesSlice* self, byte* buffer, nuint bufferSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "BytesSlice_fill", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError Fill(BytesSlice* handle, DiplomatSliceMutU8 buffer); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "BytesSlice_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(BytesSlice* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "BytesSlice_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(BytesSlice* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCertificateChainIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCertificateChainIterator.cs index c451aa991..e44f17bc7 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCertificateChainIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCertificateChainIterator.cs @@ -1,31 +1,24 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct CertificateChainIterator +internal partial struct CertificateChainIterator { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CertificateChainIterator_next", ExactSpelling = true)] - public static unsafe extern VecU8* Next(CertificateChainIterator* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CertificateChainIterator_next", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* Next(CertificateChainIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CertificateChainIterator_len", ExactSpelling = true)] - public static unsafe extern nuint Len(CertificateChainIterator* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CertificateChainIterator_len", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint Len(CertificateChainIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CertificateChainIterator_is_empty", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CertificateChainIterator_is_empty", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsEmpty(CertificateChainIterator* self); + internal static unsafe extern bool IsEmpty(CertificateChainIterator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CertificateChainIterator_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(CertificateChainIterator* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CertificateChainIterator_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(CertificateChainIterator* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawChannelConnectionSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawChannelConnectionSequence.cs index 74f3c82ca..d05672b4e 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawChannelConnectionSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawChannelConnectionSequence.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ChannelConnectionSequence +internal partial struct ChannelConnectionSequence { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ChannelConnectionSequence_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ChannelConnectionSequence* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ChannelConnectionSequence_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ChannelConnectionSequence* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawChar.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawChar.cs index 6e12c8b00..f93a46aa3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawChar.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawChar.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Char +internal partial struct Char { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Char_new", ExactSpelling = true)] - public static unsafe extern InputFfiResultBoxCharBoxIronRdpError New(uint c); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Char_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCharIronRdpError New(uint c); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Char_as_operation_unicode_key_pressed", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationUnicodeKeyPressed(Char* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Char_as_operation_unicode_key_pressed", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationUnicodeKeyPressed(Char* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Char_as_operation_unicode_key_released", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationUnicodeKeyReleased(Char* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Char_as_operation_unicode_key_released", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationUnicodeKeyReleased(Char* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Char_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Char* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Char_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Char* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnector.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnector.cs index 9a4fcc42c..a1b84e944 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnector.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnector.cs @@ -1,72 +1,59 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClientConnector +internal partial struct ClientConnector { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_new", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxClientConnectorBoxIronRdpError New(Config* config, byte* clientAddr, nuint clientAddrSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClientConnectorIronRdpError New(Config* config, DiplomatSliceU8 clientAddr); - /// - /// Must use - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_static_channel_rdp_snd", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithStaticChannelRdpSnd(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_with_static_channel_rdp_snd", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError WithStaticChannelRdpSnd(ClientConnector* handle); - /// - /// Must use - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_static_channel_rdpdr", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithStaticChannelRdpdr(ClientConnector* self, byte* computerName, nuint computerNameSz, uint smartCardDeviceId); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_with_static_channel_rdpdr", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError WithStaticChannelRdpdr(ClientConnector* handle, DiplomatSliceU8 computerName, uint smartCardDeviceId); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_dynamic_channel_display_control", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithDynamicChannelDisplayControl(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_with_dynamic_channel_display_control", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError WithDynamicChannelDisplayControl(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_with_dynamic_channel_pipe_proxy", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError WithDynamicChannelPipeProxy(ClientConnector* self, DvcPipeProxyConfig* config); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_with_dynamic_channel_pipe_proxy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError WithDynamicChannelPipeProxy(ClientConnector* handle, DvcPipeProxyConfig* config); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_should_perform_security_upgrade", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoolBoxIronRdpError ShouldPerformSecurityUpgrade(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_should_perform_security_upgrade", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultBoolIronRdpError ShouldPerformSecurityUpgrade(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_mark_security_upgrade_as_done", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError MarkSecurityUpgradeAsDone(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_mark_security_upgrade_as_done", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError MarkSecurityUpgradeAsDone(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_should_perform_credssp", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoolBoxIronRdpError ShouldPerformCredssp(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_should_perform_credssp", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultBoolIronRdpError ShouldPerformCredssp(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_mark_credssp_as_done", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError MarkCredsspAsDone(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_mark_credssp_as_done", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError MarkCredsspAsDone(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_step", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxWrittenBoxIronRdpError Step(ClientConnector* self, byte* input, nuint inputSz, WriteBuf* writeBuf); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_step", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWrittenIronRdpError Step(ClientConnector* handle, DiplomatSliceU8 input, WriteBuf* writeBuf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_step_no_input", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxWrittenBoxIronRdpError StepNoInput(ClientConnector* self, WriteBuf* writeBuf); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_step_no_input", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWrittenIronRdpError StepNoInput(ClientConnector* handle, WriteBuf* writeBuf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_attach_static_cliprdr", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError AttachStaticCliprdr(ClientConnector* self, Cliprdr* cliprdr); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_attach_static_cliprdr", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError AttachStaticCliprdr(ClientConnector* handle, Cliprdr* cliprdr); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_next_pdu_hint", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultOptBoxPduHintBoxIronRdpError NextPduHint(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_next_pdu_hint", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultPduHintIronRdpError NextPduHint(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_get_dyn_state", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxDynStateBoxIronRdpError GetDynState(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_get_dyn_state", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultDynStateIronRdpError GetDynState(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_consume_and_cast_to_client_connector_state", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxClientConnectorStateBoxIronRdpError ConsumeAndCastToClientConnectorState(ClientConnector* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_consume_and_cast_to_client_connector_state", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClientConnectorStateIronRdpError ConsumeAndCastToClientConnectorState(ClientConnector* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnector_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClientConnector* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnector_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClientConnector* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorState.cs index 57c4abe0d..0c30994ae 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorState.cs @@ -1,45 +1,38 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClientConnectorState +internal partial struct ClientConnectorState { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_enum_type", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError GetEnumType(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_enum_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClientConnectorStateTypeIronRdpError GetEnumType(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_connection_initiation_wait_confirm_requested_protocol", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError GetConnectionInitiationWaitConfirmRequestedProtocol(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_connection_initiation_wait_confirm_requested_protocol", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultSecurityProtocolIronRdpError GetConnectionInitiationWaitConfirmRequestedProtocol(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_enhanced_security_upgrade_selected_protocol", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError GetEnhancedSecurityUpgradeSelectedProtocol(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_enhanced_security_upgrade_selected_protocol", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultSecurityProtocolIronRdpError GetEnhancedSecurityUpgradeSelectedProtocol(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_credssp_selected_protocol", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError GetCredsspSelectedProtocol(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_credssp_selected_protocol", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultSecurityProtocolIronRdpError GetCredsspSelectedProtocol(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_basic_settings_exchange_send_initial_selected_protocol", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError GetBasicSettingsExchangeSendInitialSelectedProtocol(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_basic_settings_exchange_send_initial_selected_protocol", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultSecurityProtocolIronRdpError GetBasicSettingsExchangeSendInitialSelectedProtocol(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_basic_settings_exchange_wait_response_connect_initial", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxConnectInitialBoxIronRdpError GetBasicSettingsExchangeWaitResponseConnectInitial(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_basic_settings_exchange_wait_response_connect_initial", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConnectInitialIronRdpError GetBasicSettingsExchangeWaitResponseConnectInitial(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_connected_result", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxConnectionResultBoxIronRdpError GetConnectedResult(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_connected_result", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConnectionResultIronRdpError GetConnectedResult(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_get_connection_finalization_result", ExactSpelling = true)] - public static unsafe extern ConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError GetConnectionFinalizationResult(ClientConnectorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_get_connection_finalization_result", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConnectionActivationSequenceIronRdpError GetConnectionFinalizationResult(ClientConnectorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientConnectorState_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClientConnectorState* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientConnectorState_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClientConnectorState* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorStateType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorStateType.cs deleted file mode 100644 index 32b51771d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientConnectorStateType.cs +++ /dev/null @@ -1,31 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum ClientConnectorStateType -{ - Consumed = 0, - ConnectionInitiationSendRequest = 1, - ConnectionInitiationWaitConfirm = 2, - EnhancedSecurityUpgrade = 3, - Credssp = 4, - BasicSettingsExchangeSendInitial = 5, - BasicSettingsExchangeWaitResponse = 6, - ChannelConnection = 7, - SecureSettingsExchange = 8, - ConnectTimeAutoDetection = 9, - LicensingExchange = 10, - MultitransportBootstrapping = 11, - CapabilitiesExchange = 12, - ConnectionFinalization = 13, - Connected = 14, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientState.cs index 5a694bc2a..356ac1875 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClientState.cs @@ -1,32 +1,25 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClientState +internal partial struct ClientState { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientState_is_reply_needed", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientState_is_reply_needed", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsReplyNeeded(ClientState* self); + internal static unsafe extern bool IsReplyNeeded(ClientState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientState_is_final_message", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientState_is_final_message", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsFinalMessage(ClientState* self); + internal static unsafe extern bool IsFinalMessage(ClientState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientState_get_ts_request", ExactSpelling = true)] - public static unsafe extern CredsspNetworkFfiResultBoxTsRequestBoxIronRdpError GetTsRequest(ClientState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientState_get_ts_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultTsRequestIronRdpError GetTsRequest(ClientState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClientState_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClientState* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClientState_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClientState* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatId.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatId.cs index cd17daeda..93f2ca1e6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatId.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatId.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardFormatId +internal partial struct ClipboardFormatId { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardFormatId_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClipboardFormatId* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardFormatId_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClipboardFormatId* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatIterator.cs index f11d7e0a8..e9f209b28 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardFormatIterator.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardFormatIterator +internal partial struct ClipboardFormatIterator { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardFormatIterator_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClipboardFormatIterator* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardFormatIterator_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClipboardFormatIterator* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessage.cs index f708345c2..ed85d954f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessage.cs @@ -1,42 +1,35 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardMessage +internal partial struct ClipboardMessage { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_message_type", ExactSpelling = true)] - public static unsafe extern ClipboardMessageType GetMessageType(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_message_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ClipboardMessageType GetMessageType(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_send_initiate_copy", ExactSpelling = true)] - public static unsafe extern ClipboardFormatIterator* GetSendInitiateCopy(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_send_initiate_copy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ClipboardFormatIterator* GetSendInitiateCopy(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_send_format_data", ExactSpelling = true)] - public static unsafe extern FormatDataResponse* GetSendFormatData(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_send_format_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern FormatDataResponse* GetSendFormatData(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_send_initiate_paste", ExactSpelling = true)] - public static unsafe extern ClipboardFormatId* GetSendInitiatePaste(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_send_initiate_paste", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ClipboardFormatId* GetSendInitiatePaste(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_send_file_contents_request", ExactSpelling = true)] - public static unsafe extern FfiFileContentsRequest* GetSendFileContentsRequest(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_send_file_contents_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern FfiFileContentsRequest* GetSendFileContentsRequest(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_send_file_contents_response", ExactSpelling = true)] - public static unsafe extern FfiFileContentsResponse* GetSendFileContentsResponse(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_send_file_contents_response", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern FfiFileContentsResponse* GetSendFileContentsResponse(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_get_error", ExactSpelling = true)] - public static unsafe extern IronRdpError* GetError(ClipboardMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_get_error", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern IronRdpError* GetError(ClipboardMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardMessage_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClipboardMessage* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardMessage_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClipboardMessage* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageFfiResultU32BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageFfiResultU32BoxIronRdpError.cs deleted file mode 100644 index 592b3455e..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageFfiResultU32BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardMessageFfiResultU32BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal uint ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe uint Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageType.cs deleted file mode 100644 index dd3a3569b..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardMessageType.cs +++ /dev/null @@ -1,23 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum ClipboardMessageType -{ - SendInitiateCopy = 0, - SendInitiateFileCopy = 1, - SendFormatData = 2, - SendInitiatePaste = 3, - SendFileContentsRequest = 4, - SendFileContentsResponse = 5, - Error = 6, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardSvcMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardSvcMessage.cs index d3d28296c..0b6feffe5 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardSvcMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardSvcMessage.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardSvcMessage +internal partial struct ClipboardSvcMessage { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ClipboardSvcMessage_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ClipboardSvcMessage* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ClipboardSvcMessage_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ClipboardSvcMessage* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError.cs deleted file mode 100644 index 52423479b..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClipboardMessage* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClipboardMessage* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError.cs deleted file mode 100644 index 6273f969d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal CliprdrBackendFactory* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe CliprdrBackendFactory* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError.cs deleted file mode 100644 index d6ee33da3..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal WinCliprdr* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe WinCliprdr* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError.cs deleted file mode 100644 index d8f1c9b8a..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClipboardMessage* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClipboardMessage* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdr.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdr.cs index 7db8d1f3c..c74fff21a 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdr.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdr.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Cliprdr +internal partial struct Cliprdr { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Cliprdr_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Cliprdr* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Cliprdr_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Cliprdr* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdrBackendFactory.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdrBackendFactory.cs index 4fa04c309..24728bee3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdrBackendFactory.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCliprdrBackendFactory.cs @@ -1,24 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct CliprdrBackendFactory +internal partial struct CliprdrBackendFactory { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CliprdrBackendFactory_build_cliprdr", ExactSpelling = true)] - public static unsafe extern Cliprdr* BuildCliprdr(CliprdrBackendFactory* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CliprdrBackendFactory_build_cliprdr", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Cliprdr* BuildCliprdr(CliprdrBackendFactory* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CliprdrBackendFactory_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(CliprdrBackendFactory* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CliprdrBackendFactory_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(CliprdrBackendFactory* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfig.cs index 8d2cc8ebc..5ef8a51a1 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfig.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Config +internal partial struct Config { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Config_get_builder", ExactSpelling = true)] - public static unsafe extern ConfigBuilder* GetBuilder(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Config_get_builder", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ConfigBuilder* GetBuilder(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Config_get_dvc_pipe_proxy", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyConfig* GetDvcPipeProxy(Config* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Config_get_dvc_pipe_proxy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyConfig* GetDvcPipeProxy(Config* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Config_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Config* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Config_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Config* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfigBuilder.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfigBuilder.cs index bf7652311..8dd3b8ee6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfigBuilder.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConfigBuilder.cs @@ -1,87 +1,80 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConfigBuilder +internal partial struct ConfigBuilder { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_new", ExactSpelling = true)] - public static unsafe extern ConfigBuilder* New(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ConfigBuilder* New(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_with_username_and_password", ExactSpelling = true)] - public static unsafe extern void WithUsernameAndPassword(ConfigBuilder* self, byte* username, nuint usernameSz, byte* password, nuint passwordSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_with_username_and_password", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void WithUsernameAndPassword(ConfigBuilder* handle, DiplomatSliceU8 username, DiplomatSliceU8 password); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_domain", ExactSpelling = true)] - public static unsafe extern void SetDomain(ConfigBuilder* self, byte* domain, nuint domainSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_domain", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetDomain(ConfigBuilder* handle, DiplomatSliceU8 domain); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_enable_tls", ExactSpelling = true)] - public static unsafe extern void SetEnableTls(ConfigBuilder* self, [MarshalAs(UnmanagedType.U1)] bool enableTls); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_enable_tls", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetEnableTls(ConfigBuilder* handle, [MarshalAs(UnmanagedType.U1)] bool enableTls); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_enable_credssp", ExactSpelling = true)] - public static unsafe extern void SetEnableCredssp(ConfigBuilder* self, [MarshalAs(UnmanagedType.U1)] bool enableCredssp); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_enable_credssp", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetEnableCredssp(ConfigBuilder* handle, [MarshalAs(UnmanagedType.U1)] bool enableCredssp); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_keyboard_layout", ExactSpelling = true)] - public static unsafe extern void SetKeyboardLayout(ConfigBuilder* self, uint keyboardLayout); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_keyboard_layout", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetKeyboardLayout(ConfigBuilder* handle, uint keyboardLayout); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_keyboard_type", ExactSpelling = true)] - public static unsafe extern void SetKeyboardType(ConfigBuilder* self, KeyboardType keyboardType); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_keyboard_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetKeyboardType(ConfigBuilder* handle, KeyboardType keyboardType); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_keyboard_subtype", ExactSpelling = true)] - public static unsafe extern void SetKeyboardSubtype(ConfigBuilder* self, uint keyboardSubtype); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_keyboard_subtype", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetKeyboardSubtype(ConfigBuilder* handle, uint keyboardSubtype); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_keyboard_functional_keys_count", ExactSpelling = true)] - public static unsafe extern void SetKeyboardFunctionalKeysCount(ConfigBuilder* self, uint keyboardFunctionalKeysCount); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_keyboard_functional_keys_count", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetKeyboardFunctionalKeysCount(ConfigBuilder* handle, uint keyboardFunctionalKeysCount); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_ime_file_name", ExactSpelling = true)] - public static unsafe extern void SetImeFileName(ConfigBuilder* self, byte* imeFileName, nuint imeFileNameSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_ime_file_name", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetImeFileName(ConfigBuilder* handle, DiplomatSliceU8 imeFileName); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_dig_product_id", ExactSpelling = true)] - public static unsafe extern void SetDigProductId(ConfigBuilder* self, byte* digProductId, nuint digProductIdSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_dig_product_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetDigProductId(ConfigBuilder* handle, DiplomatSliceU8 digProductId); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_desktop_size", ExactSpelling = true)] - public static unsafe extern void SetDesktopSize(ConfigBuilder* self, ushort height, ushort width); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_desktop_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetDesktopSize(ConfigBuilder* handle, ushort height, ushort width); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_performance_flags", ExactSpelling = true)] - public static unsafe extern void SetPerformanceFlags(ConfigBuilder* self, PerformanceFlags* performanceFlags); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_performance_flags", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetPerformanceFlags(ConfigBuilder* handle, PerformanceFlags* performanceFlags); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_bitmap_config", ExactSpelling = true)] - public static unsafe extern void SetBitmapConfig(ConfigBuilder* self, BitmapConfig* bitmap); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_bitmap_config", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetBitmapConfig(ConfigBuilder* handle, BitmapConfig* bitmap); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_client_build", ExactSpelling = true)] - public static unsafe extern void SetClientBuild(ConfigBuilder* self, uint clientBuild); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_client_build", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetClientBuild(ConfigBuilder* handle, uint clientBuild); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_client_name", ExactSpelling = true)] - public static unsafe extern void SetClientName(ConfigBuilder* self, byte* clientName, nuint clientNameSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_client_name", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetClientName(ConfigBuilder* handle, DiplomatSliceU8 clientName); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_client_dir", ExactSpelling = true)] - public static unsafe extern void SetClientDir(ConfigBuilder* self, byte* clientDir, nuint clientDirSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_client_dir", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetClientDir(ConfigBuilder* handle, DiplomatSliceU8 clientDir); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_enable_server_pointer", ExactSpelling = true)] - public static unsafe extern void SetEnableServerPointer(ConfigBuilder* self, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_enable_server_pointer", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetEnableServerPointer(ConfigBuilder* handle, [MarshalAs(UnmanagedType.U1)] bool enableServerPointer); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_autologon", ExactSpelling = true)] - public static unsafe extern void SetAutologon(ConfigBuilder* self, [MarshalAs(UnmanagedType.U1)] bool autologon); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_autologon", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetAutologon(ConfigBuilder* handle, [MarshalAs(UnmanagedType.U1)] bool autologon); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_pointer_software_rendering", ExactSpelling = true)] - public static unsafe extern void SetPointerSoftwareRendering(ConfigBuilder* self, [MarshalAs(UnmanagedType.U1)] bool pointerSoftwareRendering); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_pointer_software_rendering", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetPointerSoftwareRendering(ConfigBuilder* handle, [MarshalAs(UnmanagedType.U1)] bool pointerSoftwareRendering); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_set_dvc_pipe_proxy", ExactSpelling = true)] - public static unsafe extern void SetDvcPipeProxy(ConfigBuilder* self, DvcPipeProxyConfig* dvcPipeProxy); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_set_dvc_pipe_proxy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void SetDvcPipeProxy(ConfigBuilder* handle, DvcPipeProxyConfig* dvcPipeProxy); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_build", ExactSpelling = true)] - public static unsafe extern ConnectorConfigFfiResultBoxConfigBoxIronRdpError Build(ConfigBuilder* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_build", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConfigIronRdpError Build(ConfigBuilder* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConfigBuilder_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConfigBuilder* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConfigBuilder_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConfigBuilder* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectInitial.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectInitial.cs index 12e18464f..3d61daf13 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectInitial.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectInitial.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectInitial +internal partial struct ConnectInitial { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectInitial_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectInitial* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectInitial_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectInitial* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationSequence.cs index 265263357..5c02a338b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationSequence.cs @@ -1,39 +1,32 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectionActivationSequence +internal partial struct ConnectionActivationSequence { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_get_state", ExactSpelling = true)] - public static unsafe extern ConnectionActivationState* GetState(ConnectionActivationSequence* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_get_state", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ConnectionActivationState* GetState(ConnectionActivationSequence* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_next_pdu_hint", ExactSpelling = true)] - public static unsafe extern ConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError NextPduHint(ConnectionActivationSequence* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_next_pdu_hint", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultPduHintIronRdpError NextPduHint(ConnectionActivationSequence* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_step", ExactSpelling = true)] - public static unsafe extern ConnectorActivationFfiResultBoxWrittenBoxIronRdpError Step(ConnectionActivationSequence* self, byte* pduHint, nuint pduHintSz, WriteBuf* buf); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_step", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWrittenIronRdpError Step(ConnectionActivationSequence* handle, DiplomatSliceU8 pduHint, WriteBuf* buf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_step_no_input", ExactSpelling = true)] - public static unsafe extern ConnectorActivationFfiResultBoxWrittenBoxIronRdpError StepNoInput(ConnectionActivationSequence* self, WriteBuf* buf); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_step_no_input", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWrittenIronRdpError StepNoInput(ConnectionActivationSequence* handle, WriteBuf* buf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_get_io_channel_id", ExactSpelling = true)] - public static unsafe extern ushort GetIoChannelId(ConnectionActivationSequence* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_get_io_channel_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetIoChannelId(ConnectionActivationSequence* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_get_user_channel_id", ExactSpelling = true)] - public static unsafe extern ushort GetUserChannelId(ConnectionActivationSequence* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_get_user_channel_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetUserChannelId(ConnectionActivationSequence* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationSequence_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectionActivationSequence* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationSequence_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectionActivationSequence* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationState.cs index dc4d9fe29..ab977fea6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationState.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectionActivationState +internal partial struct ConnectionActivationState { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationState_get_type", ExactSpelling = true)] - public static unsafe extern ConnectionActivationStateType GetType(ConnectionActivationState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationState_get_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ConnectionActivationStateType GetType(ConnectionActivationState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationState_get_connection_finalization", ExactSpelling = true)] - public static unsafe extern ConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError GetConnectionFinalization(ConnectionActivationState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationState_get_connection_finalization", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConnectionActivationStateConnectionFinalizationIronRdpError GetConnectionFinalization(ConnectionActivationState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationState_get_finalized", ExactSpelling = true)] - public static unsafe extern ConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError GetFinalized(ConnectionActivationState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationState_get_finalized", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultConnectionActivationStateFinalizedIronRdpError GetFinalized(ConnectionActivationState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationState_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectionActivationState* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationState_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectionActivationState* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateConnectionFinalization.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateConnectionFinalization.cs index f868284d4..09d41fede 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateConnectionFinalization.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateConnectionFinalization.cs @@ -1,24 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectionActivationStateConnectionFinalization +internal partial struct ConnectionActivationStateConnectionFinalization { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateConnectionFinalization_get_desktop_size", ExactSpelling = true)] - public static unsafe extern DesktopSize* GetDesktopSize(ConnectionActivationStateConnectionFinalization* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateConnectionFinalization_get_desktop_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DesktopSize* GetDesktopSize(ConnectionActivationStateConnectionFinalization* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateConnectionFinalization_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectionActivationStateConnectionFinalization* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateConnectionFinalization_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectionActivationStateConnectionFinalization* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateFinalized.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateFinalized.cs index f0977a75d..ee231516f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateFinalized.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateFinalized.cs @@ -1,35 +1,28 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectionActivationStateFinalized +internal partial struct ConnectionActivationStateFinalized { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateFinalized_get_share_id", ExactSpelling = true)] - public static unsafe extern uint GetShareId(ConnectionActivationStateFinalized* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateFinalized_get_share_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern uint GetShareId(ConnectionActivationStateFinalized* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateFinalized_get_desktop_size", ExactSpelling = true)] - public static unsafe extern DesktopSize* GetDesktopSize(ConnectionActivationStateFinalized* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateFinalized_get_desktop_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DesktopSize* GetDesktopSize(ConnectionActivationStateFinalized* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateFinalized_get_enable_server_pointer", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateFinalized_get_enable_server_pointer", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool GetEnableServerPointer(ConnectionActivationStateFinalized* self); + internal static unsafe extern bool GetEnableServerPointer(ConnectionActivationStateFinalized* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateFinalized_get_pointer_software_rendering", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateFinalized_get_pointer_software_rendering", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool GetPointerSoftwareRendering(ConnectionActivationStateFinalized* self); + internal static unsafe extern bool GetPointerSoftwareRendering(ConnectionActivationStateFinalized* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionActivationStateFinalized_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectionActivationStateFinalized* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionActivationStateFinalized_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectionActivationStateFinalized* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateType.cs deleted file mode 100644 index af2c1543e..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionActivationStateType.cs +++ /dev/null @@ -1,20 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum ConnectionActivationStateType -{ - Consumed = 0, - CapabilitiesExchange = 1, - ConnectionFinalization = 2, - Finalized = 3, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionResult.cs index ad4554e51..278ff4d09 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectionResult.cs @@ -1,39 +1,32 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct ConnectionResult +internal partial struct ConnectionResult { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_io_channel_id", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultU16BoxIronRdpError GetIoChannelId(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_io_channel_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUShortIronRdpError GetIoChannelId(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_user_channel_id", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultU16BoxIronRdpError GetUserChannelId(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_user_channel_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUShortIronRdpError GetUserChannelId(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_share_id", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultU32BoxIronRdpError GetShareId(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_share_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUIntIronRdpError GetShareId(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_desktop_size", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError GetDesktopSize(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_desktop_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultDesktopSizeIronRdpError GetDesktopSize(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_enable_server_pointer", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultBoolBoxIronRdpError GetEnableServerPointer(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_enable_server_pointer", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultBoolIronRdpError GetEnableServerPointer(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_get_pointer_software_rendering", ExactSpelling = true)] - public static unsafe extern ConnectorResultFfiResultBoolBoxIronRdpError GetPointerSoftwareRendering(ConnectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_get_pointer_software_rendering", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultBoolIronRdpError GetPointerSoftwareRendering(ConnectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ConnectionResult_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(ConnectionResult* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "ConnectionResult_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(ConnectionResult* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError.cs deleted file mode 100644 index c9cddc209..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorActivationFfiResultBoxConnectionActivationStateConnectionFinalizationBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ConnectionActivationStateConnectionFinalization* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ConnectionActivationStateConnectionFinalization* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError.cs deleted file mode 100644 index b4424b201..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorActivationFfiResultBoxConnectionActivationStateFinalizedBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ConnectionActivationStateFinalized* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ConnectionActivationStateFinalized* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxWrittenBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxWrittenBoxIronRdpError.cs deleted file mode 100644 index 32ead621c..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultBoxWrittenBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorActivationFfiResultBoxWrittenBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Written* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Written* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError.cs deleted file mode 100644 index d5da5d2ca..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal PduHint* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe PduHint* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorConfigFfiResultBoxConfigBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorConfigFfiResultBoxConfigBoxIronRdpError.cs deleted file mode 100644 index e2e20bf79..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorConfigFfiResultBoxConfigBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorConfigFfiResultBoxConfigBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Config* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Config* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoolBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoolBoxIronRdpError.cs deleted file mode 100644 index 7fc158904..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoolBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoolBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal bool ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe bool Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorBoxIronRdpError.cs deleted file mode 100644 index 9b74bc989..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoxClientConnectorBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClientConnector* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClientConnector* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorStateBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorStateBoxIronRdpError.cs deleted file mode 100644 index 4a9bf3275..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxClientConnectorStateBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoxClientConnectorStateBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClientConnectorState* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClientConnectorState* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxDynStateBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxDynStateBoxIronRdpError.cs deleted file mode 100644 index 68b410941..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxDynStateBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoxDynStateBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal DynState* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe DynState* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxOptionalUsizeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxOptionalUsizeBoxIronRdpError.cs deleted file mode 100644 index ab190029d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxOptionalUsizeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoxOptionalUsizeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal OptionalUsize* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe OptionalUsize* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxWrittenBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxWrittenBoxIronRdpError.cs deleted file mode 100644 index efb13c479..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultBoxWrittenBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultBoxWrittenBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Written* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Written* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultOptBoxPduHintBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultOptBoxPduHintBoxIronRdpError.cs deleted file mode 100644 index c5fdf932e..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultOptBoxPduHintBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultOptBoxPduHintBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal PduHint* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe PduHint* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultVoidBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultVoidBoxIronRdpError.cs deleted file mode 100644 index 5c652dc22..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorFfiResultVoidBoxIronRdpError.cs +++ /dev/null @@ -1,36 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorFfiResultVoidBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoolBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoolBoxIronRdpError.cs deleted file mode 100644 index 43f6e35f6..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoolBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorResultFfiResultBoolBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal bool ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe bool Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError.cs deleted file mode 100644 index 21b72d2b2..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal DesktopSize* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe DesktopSize* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU16BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU16BoxIronRdpError.cs deleted file mode 100644 index 6d2c9298f..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU16BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorResultFfiResultU16BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ushort ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ushort Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU32BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU32BoxIronRdpError.cs deleted file mode 100644 index 90ced600d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorResultFfiResultU32BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorResultFfiResultU32BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal uint ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe uint Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectInitialBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectInitialBoxIronRdpError.cs deleted file mode 100644 index 57848c690..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectInitialBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorStateFfiResultBoxConnectInitialBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ConnectInitial* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ConnectInitial* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError.cs deleted file mode 100644 index 0523d083f..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorStateFfiResultBoxConnectionActivationSequenceBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ConnectionActivationSequence* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ConnectionActivationSequence* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionResultBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionResultBoxIronRdpError.cs deleted file mode 100644 index e1b2b186e..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxConnectionResultBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorStateFfiResultBoxConnectionResultBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ConnectionResult* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ConnectionResult* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError.cs deleted file mode 100644 index e4e098e1a..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal SecurityProtocol* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe SecurityProtocol* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError.cs deleted file mode 100644 index 05c250ce4..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct ConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClientConnectorStateType ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClientConnectorStateType Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError.cs deleted file mode 100644 index ce13d18a3..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal CredsspProcessGenerator* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe CredsspProcessGenerator* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceBoxIronRdpError.cs deleted file mode 100644 index 57da8cd7b..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultBoxCredsspSequenceBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal CredsspSequence* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe CredsspSequence* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError.cs deleted file mode 100644 index d8602e290..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal CredsspSequenceInitResult* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe CredsspSequenceInitResult* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxTsRequestBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxTsRequestBoxIronRdpError.cs deleted file mode 100644 index 9da0daa76..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxTsRequestBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultBoxTsRequestBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal TsRequest* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe TsRequest* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxWrittenBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxWrittenBoxIronRdpError.cs deleted file mode 100644 index b7e2a675d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultBoxWrittenBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultBoxWrittenBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Written* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Written* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultOptBoxTsRequestBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultOptBoxTsRequestBoxIronRdpError.cs deleted file mode 100644 index 6c104178f..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspFfiResultOptBoxTsRequestBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspFfiResultOptBoxTsRequestBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal TsRequest* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe TsRequest* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxClientStateBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxClientStateBoxIronRdpError.cs deleted file mode 100644 index ba55c276c..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxClientStateBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspNetworkFfiResultBoxClientStateBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ClientState* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ClientState* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError.cs deleted file mode 100644 index 2b7fb20a7..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal GeneratorState* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe GeneratorState* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxTsRequestBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxTsRequestBoxIronRdpError.cs deleted file mode 100644 index e79b9b37f..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultBoxTsRequestBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspNetworkFfiResultBoxTsRequestBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal TsRequest* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe TsRequest* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultVoidBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultVoidBoxIronRdpError.cs deleted file mode 100644 index 61de7b3e6..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspNetworkFfiResultVoidBoxIronRdpError.cs +++ /dev/null @@ -1,36 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct CredsspNetworkFfiResultVoidBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspProcessGenerator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspProcessGenerator.cs index 919fed6d2..62b3dcdc9 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspProcessGenerator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspProcessGenerator.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct CredsspProcessGenerator +internal partial struct CredsspProcessGenerator { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspProcessGenerator_start", ExactSpelling = true)] - public static unsafe extern CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError Start(CredsspProcessGenerator* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspProcessGenerator_start", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultGeneratorStateIronRdpError Start(CredsspProcessGenerator* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspProcessGenerator_resume", ExactSpelling = true)] - public static unsafe extern CredsspNetworkFfiResultBoxGeneratorStateBoxIronRdpError Resume(CredsspProcessGenerator* self, byte* response, nuint responseSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspProcessGenerator_resume", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultGeneratorStateIronRdpError Resume(CredsspProcessGenerator* handle, DiplomatSliceU8 response); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspProcessGenerator_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(CredsspProcessGenerator* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspProcessGenerator_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(CredsspProcessGenerator* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequence.cs index 0029d7f23..a42ef0135 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequence.cs @@ -1,36 +1,29 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct CredsspSequence +internal partial struct CredsspSequence { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_next_pdu_hint", ExactSpelling = true)] - public static unsafe extern PduHint* NextPduHint(CredsspSequence* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_next_pdu_hint", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern PduHint* NextPduHint(CredsspSequence* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_init", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultBoxCredsspSequenceInitResultBoxIronRdpError Init(ClientConnector* connector, byte* serverName, nuint serverNameSz, byte* serverPublicKey, nuint serverPublicKeySz, KerberosConfig* kerberoConfigs); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_init", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCredsspSequenceInitResultIronRdpError Init(ClientConnector* connector, DiplomatSliceU8 serverName, DiplomatSliceU8 serverPublicKey, KerberosConfig* kerberoConfigs); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_decode_server_message", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultOptBoxTsRequestBoxIronRdpError DecodeServerMessage(CredsspSequence* self, byte* pdu, nuint pduSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_decode_server_message", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultTsRequestIronRdpError DecodeServerMessage(CredsspSequence* handle, DiplomatSliceU8 pdu); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_process_ts_request", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultBoxCredsspProcessGeneratorBoxIronRdpError ProcessTsRequest(CredsspSequence* self, TsRequest* tsRequest); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_process_ts_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCredsspProcessGeneratorIronRdpError ProcessTsRequest(CredsspSequence* handle, TsRequest* tsRequest); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_handle_process_result", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultBoxWrittenBoxIronRdpError HandleProcessResult(CredsspSequence* self, ClientState* clientState, WriteBuf* buf); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_handle_process_result", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWrittenIronRdpError HandleProcessResult(CredsspSequence* handle, ClientState* clientState, WriteBuf* buf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequence_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(CredsspSequence* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequence_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(CredsspSequence* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequenceInitResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequenceInitResult.cs index fa340166b..a7ae389b7 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequenceInitResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawCredsspSequenceInitResult.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct CredsspSequenceInitResult +internal partial struct CredsspSequenceInitResult { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequenceInitResult_get_credssp_sequence", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultBoxCredsspSequenceBoxIronRdpError GetCredsspSequence(CredsspSequenceInitResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequenceInitResult_get_credssp_sequence", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCredsspSequenceIronRdpError GetCredsspSequence(CredsspSequenceInitResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequenceInitResult_get_ts_request", ExactSpelling = true)] - public static unsafe extern CredsspFfiResultBoxTsRequestBoxIronRdpError GetTsRequest(CredsspSequenceInitResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequenceInitResult_get_ts_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultTsRequestIronRdpError GetTsRequest(CredsspSequenceInitResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "CredsspSequenceInitResult_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(CredsspSequenceInitResult* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "CredsspSequenceInitResult_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(CredsspSequenceInitResult* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedImage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedImage.cs index 078af3845..248e1eba3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedImage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedImage.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DecodedImage +internal partial struct DecodedImage { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedImage_new", ExactSpelling = true)] - public static unsafe extern DecodedImage* New(PixelFormat pixelFormat, ushort width, ushort height); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedImage_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DecodedImage* New(PixelFormat pixelFormat, ushort width, ushort height); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedImage_get_data", ExactSpelling = true)] - public static unsafe extern BytesSlice* GetData(DecodedImage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedImage_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern BytesSlice* GetData(DecodedImage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedImage_get_width", ExactSpelling = true)] - public static unsafe extern ushort GetWidth(DecodedImage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedImage_get_width", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetWidth(DecodedImage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedImage_get_height", ExactSpelling = true)] - public static unsafe extern ushort GetHeight(DecodedImage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedImage_get_height", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHeight(DecodedImage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedImage_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DecodedImage* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedImage_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DecodedImage* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedPointer.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedPointer.cs index ba4de8bad..5ba9a2731 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedPointer.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDecodedPointer.cs @@ -1,36 +1,29 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DecodedPointer +internal partial struct DecodedPointer { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_get_width", ExactSpelling = true)] - public static unsafe extern ushort GetWidth(DecodedPointer* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_get_width", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetWidth(DecodedPointer* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_get_height", ExactSpelling = true)] - public static unsafe extern ushort GetHeight(DecodedPointer* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_get_height", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHeight(DecodedPointer* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_get_hotspot_x", ExactSpelling = true)] - public static unsafe extern ushort GetHotspotX(DecodedPointer* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_get_hotspot_x", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHotspotX(DecodedPointer* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_get_hotspot_y", ExactSpelling = true)] - public static unsafe extern ushort GetHotspotY(DecodedPointer* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_get_hotspot_y", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHotspotY(DecodedPointer* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_get_data", ExactSpelling = true)] - public static unsafe extern BytesSlice* GetData(DecodedPointer* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern BytesSlice* GetData(DecodedPointer* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DecodedPointer_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DecodedPointer* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DecodedPointer_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DecodedPointer* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDesktopSize.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDesktopSize.cs index e902c7ff7..2230ba55b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDesktopSize.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDesktopSize.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DesktopSize +internal partial struct DesktopSize { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DesktopSize_get_width", ExactSpelling = true)] - public static unsafe extern ushort GetWidth(DesktopSize* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DesktopSize_get_width", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetWidth(DesktopSize* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DesktopSize_get_height", ExactSpelling = true)] - public static unsafe extern ushort GetHeight(DesktopSize* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DesktopSize_get_height", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHeight(DesktopSize* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DesktopSize_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DesktopSize* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DesktopSize_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DesktopSize* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDrdynvcChannel.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDrdynvcChannel.cs index 124d54dda..91cdd07a9 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDrdynvcChannel.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDrdynvcChannel.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DrdynvcChannel +internal partial struct DrdynvcChannel { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DrdynvcChannel_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DrdynvcChannel* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DrdynvcChannel_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DrdynvcChannel* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError.cs deleted file mode 100644 index cb8d17407..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct DvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal DvcPipeProxyMessage* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe DvcPipeProxyMessage* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError.cs deleted file mode 100644 index 070066774..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct DvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal DvcPipeProxyMessage* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe DvcPipeProxyMessage* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyConfig.cs index 81d4ee18a..6ca06387d 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyConfig.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DvcPipeProxyConfig +internal partial struct DvcPipeProxyConfig { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyConfig_new", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyConfig* New(DvcPipeProxyMessageSink* messageSink); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyConfig_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyConfig* New(DvcPipeProxyMessageSink* messageSink); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyConfig_add_pipe_proxy", ExactSpelling = true)] - public static unsafe extern void AddPipeProxy(DvcPipeProxyConfig* self, DvcPipeProxyDescriptor* descriptor); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyConfig_add_pipe_proxy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void AddPipeProxy(DvcPipeProxyConfig* handle, DvcPipeProxyDescriptor* descriptor); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyConfig_get_message_sink", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyMessageSink* GetMessageSink(DvcPipeProxyConfig* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyConfig_get_message_sink", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyMessageSink* GetMessageSink(DvcPipeProxyConfig* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyConfig_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DvcPipeProxyConfig* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyConfig_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DvcPipeProxyConfig* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyDescriptor.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyDescriptor.cs index e0f8d76f4..76337187b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyDescriptor.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyDescriptor.cs @@ -1,24 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DvcPipeProxyDescriptor +internal partial struct DvcPipeProxyDescriptor { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyDescriptor_new", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyDescriptor* New(byte* channelName, nuint channelNameSz, byte* pipeName, nuint pipeNameSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyDescriptor_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyDescriptor* New(DiplomatSliceU8 channelName, DiplomatSliceU8 pipeName); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyDescriptor_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DvcPipeProxyDescriptor* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyDescriptor_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DvcPipeProxyDescriptor* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessage.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessage.cs index 9d155a70c..18dda3c71 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessage.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessage.cs @@ -1,24 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DvcPipeProxyMessage +internal partial struct DvcPipeProxyMessage { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessage_get_channel_id", ExactSpelling = true)] - public static unsafe extern uint GetChannelId(DvcPipeProxyMessage* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessage_get_channel_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern uint GetChannelId(DvcPipeProxyMessage* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessage_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DvcPipeProxyMessage* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessage_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DvcPipeProxyMessage* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageQueue.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageQueue.cs index f31d99101..6b3b0a449 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageQueue.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageQueue.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DvcPipeProxyMessageQueue +internal partial struct DvcPipeProxyMessageQueue { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageQueue_new", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyMessageQueue* New(uint queueSize); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageQueue_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyMessageQueue* New(uint queueSize); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageQueue_next_message", ExactSpelling = true)] - public static unsafe extern DvcDvcPipeProxyMessageQueueFfiResultOptBoxDvcPipeProxyMessageBoxIronRdpError NextMessage(DvcPipeProxyMessageQueue* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageQueue_next_message", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultDvcPipeProxyMessageIronRdpError NextMessage(DvcPipeProxyMessageQueue* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageQueue_next_message_blocking", ExactSpelling = true)] - public static unsafe extern DvcDvcPipeProxyMessageQueueFfiResultBoxDvcPipeProxyMessageBoxIronRdpError NextMessageBlocking(DvcPipeProxyMessageQueue* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageQueue_next_message_blocking", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultDvcPipeProxyMessageIronRdpError NextMessageBlocking(DvcPipeProxyMessageQueue* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageQueue_get_sink", ExactSpelling = true)] - public static unsafe extern DvcPipeProxyMessageSink* GetSink(DvcPipeProxyMessageQueue* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageQueue_get_sink", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DvcPipeProxyMessageSink* GetSink(DvcPipeProxyMessageQueue* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageQueue_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DvcPipeProxyMessageQueue* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageQueue_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DvcPipeProxyMessageQueue* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageSink.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageSink.cs index 2819ce157..f8159a10d 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageSink.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDvcPipeProxyMessageSink.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DvcPipeProxyMessageSink +internal partial struct DvcPipeProxyMessageSink { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DvcPipeProxyMessageSink_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DvcPipeProxyMessageSink* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DvcPipeProxyMessageSink_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DvcPipeProxyMessageSink* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDynState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDynState.cs index 9c1147ef2..faef47fc7 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawDynState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawDynState.cs @@ -1,28 +1,21 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct DynState +internal partial struct DynState { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DynState_get_name", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultVoidBoxIronRdpError GetName(DynState* self, DiplomatWriteable* writeable); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DynState_get_name", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError GetName(DynState* handle, DiplomatWrite* writeable); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DynState_is_terminal", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DynState_is_terminal", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsTerminal(DynState* self); + internal static unsafe extern bool IsTerminal(DynState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "DynState_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(DynState* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "DynState_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(DynState* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEvent.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEvent.cs index b64183050..84fa7fd11 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEvent.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEvent.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct FastPathInputEvent +internal partial struct FastPathInputEvent { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FastPathInputEvent_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(FastPathInputEvent* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FastPathInputEvent_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(FastPathInputEvent* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEventIterator.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEventIterator.cs index df9c1617e..8ce7c235b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEventIterator.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFastPathInputEventIterator.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct FastPathInputEventIterator +internal partial struct FastPathInputEventIterator { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FastPathInputEventIterator_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(FastPathInputEventIterator* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FastPathInputEventIterator_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(FastPathInputEventIterator* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsRequest.cs index 64b3f9ba9..31935e3fa 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsRequest.cs @@ -1,48 +1,41 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct FfiFileContentsRequest +internal partial struct FfiFileContentsRequest { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_stream_id", ExactSpelling = true)] - public static unsafe extern uint StreamId(FfiFileContentsRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_stream_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern uint StreamId(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_index", ExactSpelling = true)] - public static unsafe extern int Index(FfiFileContentsRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_index", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern int Index(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_is_size_request", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_is_size_request", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsSizeRequest(FfiFileContentsRequest* self); + internal static unsafe extern bool IsSizeRequest(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_is_range_request", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_is_range_request", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsRangeRequest(FfiFileContentsRequest* self); + internal static unsafe extern bool IsRangeRequest(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_position", ExactSpelling = true)] - public static unsafe extern ulong Position(FfiFileContentsRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_position", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ulong Position(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_requested_size", ExactSpelling = true)] - public static unsafe extern uint RequestedSize(FfiFileContentsRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_requested_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern uint RequestedSize(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_has_data_id", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_has_data_id", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool HasDataId(FfiFileContentsRequest* self); + internal static unsafe extern bool HasDataId(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_data_id", ExactSpelling = true)] - public static unsafe extern ClipboardMessageFfiResultU32BoxIronRdpError DataId(FfiFileContentsRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_data_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUIntIronRdpError DataId(FfiFileContentsRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsRequest_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(FfiFileContentsRequest* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsRequest_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(FfiFileContentsRequest* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsResponse.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsResponse.cs index 96ec8513f..729c32ea0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsResponse.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFfiFileContentsResponse.cs @@ -1,35 +1,24 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - -/// -/// Wraps `OwnedFileContentsResponse`, which is a type alias for -/// `FileContentsResponse<'static>` (generated by `impl_pdu_borrowing!`). -/// [StructLayout(LayoutKind.Sequential)] -public partial struct FfiFileContentsResponse +internal partial struct FfiFileContentsResponse { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsResponse_stream_id", ExactSpelling = true)] - public static unsafe extern uint StreamId(FfiFileContentsResponse* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsResponse_stream_id", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern uint StreamId(FfiFileContentsResponse* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsResponse_is_error", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsResponse_is_error", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsError(FfiFileContentsResponse* self); + internal static unsafe extern bool IsError(FfiFileContentsResponse* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsResponse_data", ExactSpelling = true)] - public static unsafe extern VecU8* Data(FfiFileContentsResponse* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsResponse_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* Data(FfiFileContentsResponse* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FfiFileContentsResponse_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(FfiFileContentsResponse* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FfiFileContentsResponse_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(FfiFileContentsResponse* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFormatDataResponse.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFormatDataResponse.cs index 3d85b3f35..cd7c9aae6 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawFormatDataResponse.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawFormatDataResponse.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct FormatDataResponse +internal partial struct FormatDataResponse { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "FormatDataResponse_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(FormatDataResponse* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "FormatDataResponse_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(FormatDataResponse* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawGeneratorState.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawGeneratorState.cs index 29bf6ba7c..7e92c8eb8 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawGeneratorState.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawGeneratorState.cs @@ -1,35 +1,28 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct GeneratorState +internal partial struct GeneratorState { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GeneratorState_is_suspended", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GeneratorState_is_suspended", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsSuspended(GeneratorState* self); + internal static unsafe extern bool IsSuspended(GeneratorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GeneratorState_is_completed", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GeneratorState_is_completed", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsCompleted(GeneratorState* self); + internal static unsafe extern bool IsCompleted(GeneratorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GeneratorState_get_network_request_if_suspended", ExactSpelling = true)] - public static unsafe extern NetworkRequest* GetNetworkRequestIfSuspended(GeneratorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GeneratorState_get_network_request_if_suspended", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern NetworkRequest* GetNetworkRequestIfSuspended(GeneratorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GeneratorState_get_client_state_if_completed", ExactSpelling = true)] - public static unsafe extern CredsspNetworkFfiResultBoxClientStateBoxIronRdpError GetClientStateIfCompleted(GeneratorState* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GeneratorState_get_client_state_if_completed", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClientStateIronRdpError GetClientStateIfCompleted(GeneratorState* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GeneratorState_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(GeneratorState* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GeneratorState_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(GeneratorState* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawGracefulDisconnectReason.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawGracefulDisconnectReason.cs index 8539b037d..ddec9db68 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawGracefulDisconnectReason.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawGracefulDisconnectReason.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct GracefulDisconnectReason +internal partial struct GracefulDisconnectReason { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "GracefulDisconnectReason_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(GracefulDisconnectReason* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "GracefulDisconnectReason_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(GracefulDisconnectReason* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInclusiveRectangle.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawInclusiveRectangle.cs index 206b6e149..e752cb6ca 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInclusiveRectangle.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawInclusiveRectangle.cs @@ -1,39 +1,32 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct InclusiveRectangle +internal partial struct InclusiveRectangle { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_left", ExactSpelling = true)] - public static unsafe extern ushort GetLeft(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_left", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetLeft(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_top", ExactSpelling = true)] - public static unsafe extern ushort GetTop(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_top", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetTop(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_right", ExactSpelling = true)] - public static unsafe extern ushort GetRight(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_right", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetRight(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_bottom", ExactSpelling = true)] - public static unsafe extern ushort GetBottom(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_bottom", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetBottom(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_width", ExactSpelling = true)] - public static unsafe extern ushort GetWidth(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_width", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetWidth(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_get_height", ExactSpelling = true)] - public static unsafe extern ushort GetHeight(InclusiveRectangle* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_get_height", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern ushort GetHeight(InclusiveRectangle* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InclusiveRectangle_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(InclusiveRectangle* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InclusiveRectangle_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(InclusiveRectangle* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputDatabase.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputDatabase.cs index 712591cd0..2476c1f35 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputDatabase.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputDatabase.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct InputDatabase +internal partial struct InputDatabase { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InputDatabase_new", ExactSpelling = true)] - public static unsafe extern InputDatabase* New(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InputDatabase_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern InputDatabase* New(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InputDatabase_apply", ExactSpelling = true)] - public static unsafe extern FastPathInputEventIterator* Apply(InputDatabase* self, Operation* operation); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InputDatabase_apply", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern FastPathInputEventIterator* Apply(InputDatabase* handle, Operation* operation); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "InputDatabase_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(InputDatabase* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "InputDatabase_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(InputDatabase* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputFfiResultBoxCharBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputFfiResultBoxCharBoxIronRdpError.cs deleted file mode 100644 index 1e721b374..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawInputFfiResultBoxCharBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct InputFfiResultBoxCharBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Char* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Char* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpError.cs index 680d5d9df..5e4daaf18 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpError.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpError.cs @@ -1,36 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - -/// -/// Stringified Picky error along with an error kind. -/// [StructLayout(LayoutKind.Sequential)] -public partial struct IronRdpError +internal partial struct IronRdpError { - private const string NativeLib = "DevolutionsIronRdp"; - /// - /// Returns the error as a string. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpError_to_display", ExactSpelling = true)] - public static unsafe extern void ToDisplay(IronRdpError* self, DiplomatWriteable* writeable); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpError_to_display", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void ToDisplay(IronRdpError* handle, DiplomatWrite* writeable); - /// - /// Returns the error kind. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpError_get_kind", ExactSpelling = true)] - public static unsafe extern IronRdpErrorKind GetKind(IronRdpError* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpError_get_kind", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern IronRdpErrorKind GetKind(IronRdpError* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpError_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(IronRdpError* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpError_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(IronRdpError* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpErrorKind.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpErrorKind.cs deleted file mode 100644 index 1e86b93a1..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpErrorKind.cs +++ /dev/null @@ -1,27 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum IronRdpErrorKind -{ - Generic = 0, - PduError = 1, - EncodeError = 2, - DecodeError = 3, - CredsspError = 4, - Consumed = 5, - IO = 6, - AccessDenied = 7, - IncorrectEnumType = 8, - Clipboard = 9, - WrongOS = 10, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpPdu.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpPdu.cs index 4e1ea99a2..2b75b91cb 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpPdu.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawIronRdpPdu.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct IronRdpPdu +internal partial struct IronRdpPdu { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpPdu_new", ExactSpelling = true)] - public static unsafe extern IronRdpPdu* New(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpPdu_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern IronRdpPdu* New(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpPdu_find_size", ExactSpelling = true)] - public static unsafe extern PduFfiResultOptBoxPduInfoBoxIronRdpError FindSize(IronRdpPdu* self, byte* bytes, nuint bytesSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpPdu_find_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultPduInfoIronRdpError FindSize(IronRdpPdu* handle, DiplomatSliceU8 bytes); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "IronRdpPdu_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(IronRdpPdu* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "IronRdpPdu_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(IronRdpPdu* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawKerberosConfig.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawKerberosConfig.cs index 410ff439b..58338b5ce 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawKerberosConfig.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawKerberosConfig.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct KerberosConfig +internal partial struct KerberosConfig { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "KerberosConfig_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(KerberosConfig* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "KerberosConfig_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(KerberosConfig* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawKeyboardType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawKeyboardType.cs deleted file mode 100644 index baf5eda99..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawKeyboardType.cs +++ /dev/null @@ -1,23 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum KeyboardType -{ - IbmPcXt = 0, - OlivettiIco = 1, - IbmPcAt = 2, - IbmEnhanced = 3, - Nokia1050 = 4, - Nokia9140 = 5, - Japanese = 6, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawLicenseExchangeSequence.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawLicenseExchangeSequence.cs index a0d756681..6d86a2b93 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawLicenseExchangeSequence.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawLicenseExchangeSequence.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct LicenseExchangeSequence +internal partial struct LicenseExchangeSequence { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "LicenseExchangeSequence_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(LicenseExchangeSequence* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "LicenseExchangeSequence_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(LicenseExchangeSequence* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawLog.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawLog.cs index 404827024..f3d1b6241 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawLog.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawLog.cs @@ -1,31 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Log +internal partial struct Log { - private const string NativeLib = "DevolutionsIronRdp"; - /// - /// # Panics - /// - /// - /// - Panics if log directory creation fails. - /// - Panics if tracing initialization fails. - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Log_init_with_env", ExactSpelling = true)] - public static unsafe extern void InitWithEnv(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Log_init_with_env", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void InitWithEnv(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Log_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Log* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Log_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Log* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButton.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButton.cs index bc7dbb033..e3ff1748f 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButton.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButton.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct MouseButton +internal partial struct MouseButton { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MouseButton_new", ExactSpelling = true)] - public static unsafe extern MouseButton* New(MouseButtonType button); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MouseButton_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern MouseButton* New(MouseButtonType button); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MouseButton_as_operation_mouse_button_pressed", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationMouseButtonPressed(MouseButton* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MouseButton_as_operation_mouse_button_pressed", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationMouseButtonPressed(MouseButton* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MouseButton_as_operation_mouse_button_released", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationMouseButtonReleased(MouseButton* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MouseButton_as_operation_mouse_button_released", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationMouseButtonReleased(MouseButton* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MouseButton_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(MouseButton* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MouseButton_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(MouseButton* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButtonType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButtonType.cs deleted file mode 100644 index ae7994ebe..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMouseButtonType.cs +++ /dev/null @@ -1,21 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum MouseButtonType -{ - Left = 0, - Middle = 1, - Right = 2, - X1 = 3, - X2 = 4, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMousePosition.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMousePosition.cs index dcd70e332..f645d0940 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMousePosition.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMousePosition.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct MousePosition +internal partial struct MousePosition { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MousePosition_new", ExactSpelling = true)] - public static unsafe extern MousePosition* New(ushort x, ushort y); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MousePosition_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern MousePosition* New(ushort x, ushort y); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MousePosition_as_move_operation", ExactSpelling = true)] - public static unsafe extern Operation* AsMoveOperation(MousePosition* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MousePosition_as_move_operation", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsMoveOperation(MousePosition* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "MousePosition_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(MousePosition* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "MousePosition_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(MousePosition* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMultitransportRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMultitransportRequest.cs index d18a6b4b3..0ff1943e5 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawMultitransportRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawMultitransportRequest.cs @@ -1,22 +1,14 @@ // by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct MultitransportRequest +internal partial struct MultitransportRequest { - private const string NativeLib = "DevolutionsIronRdp"; - - public uint request_id; - - public ushort requested_protocol; -} + public uint RequestId; + public ushort RequestedProtocol; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkCharacteristics.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkCharacteristics.cs index 761e1552e..d384b0b99 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkCharacteristics.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkCharacteristics.cs @@ -1,44 +1,19 @@ // by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - -/// -/// Connection quality measurements from server auto-detect (MS-RDPBCGR 2.2.14). -/// [StructLayout(LayoutKind.Sequential)] -public partial struct NetworkCharacteristics +internal partial struct NetworkCharacteristics { - private const string NativeLib = "DevolutionsIronRdp"; - - /// - /// Lowest detected round-trip time in milliseconds. - /// Only valid when `has_base_rtt` is true. - /// - public uint base_rtt_ms; - + public uint BaseRttMs; [MarshalAs(UnmanagedType.U1)] - public bool has_base_rtt; - - /// - /// Current average round-trip time in milliseconds. - /// - public uint average_rtt_ms; - - /// - /// Estimated bandwidth in kilobits per second. - /// Only valid when `has_bandwidth` is true. - /// - public uint bandwidth_kbps; - + public bool HasBaseRtt; + public uint AverageRttMs; + public uint BandwidthKbps; [MarshalAs(UnmanagedType.U1)] - public bool has_bandwidth; -} + public bool HasBandwidth; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequest.cs index 5fa5bc27a..f99791aff 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequest.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct NetworkRequest +internal partial struct NetworkRequest { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "NetworkRequest_get_data", ExactSpelling = true)] - public static unsafe extern VecU8* GetData(NetworkRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "NetworkRequest_get_data", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* GetData(NetworkRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "NetworkRequest_get_protocol", ExactSpelling = true)] - public static unsafe extern NetworkRequestProtocol GetProtocol(NetworkRequest* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "NetworkRequest_get_protocol", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern NetworkRequestProtocol GetProtocol(NetworkRequest* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "NetworkRequest_get_url", ExactSpelling = true)] - public static unsafe extern CredsspNetworkFfiResultVoidBoxIronRdpError GetUrl(NetworkRequest* self, DiplomatWriteable* writeable); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "NetworkRequest_get_url", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError GetUrl(NetworkRequest* handle, DiplomatWrite* writeable); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "NetworkRequest_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(NetworkRequest* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "NetworkRequest_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(NetworkRequest* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequestProtocol.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequestProtocol.cs deleted file mode 100644 index 4c15f64e9..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawNetworkRequestProtocol.cs +++ /dev/null @@ -1,20 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum NetworkRequestProtocol -{ - Tcp = 0, - Udp = 1, - Http = 2, - Https = 3, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperation.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperation.cs index 5bd5f7621..d194f0ff2 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperation.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperation.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Operation +internal partial struct Operation { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Operation_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Operation* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Operation_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Operation* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperationType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperationType.cs deleted file mode 100644 index 01ab36490..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOperationType.cs +++ /dev/null @@ -1,24 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum OperationType -{ - MouseButtonPressed = 0, - MouseButtonReleased = 1, - MouseMove = 2, - WheelRotations = 3, - KeyPressed = 4, - KeyReleased = 5, - UnicodeKeyPressed = 6, - UnicodeKeyReleased = 7, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOptionalUsize.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawOptionalUsize.cs index 42f3cbd9e..e3794c286 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawOptionalUsize.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawOptionalUsize.cs @@ -1,28 +1,21 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct OptionalUsize +internal partial struct OptionalUsize { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "OptionalUsize_is_some", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "OptionalUsize_is_some", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsSome(OptionalUsize* self); + internal static unsafe extern bool IsSome(OptionalUsize* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "OptionalUsize_get", ExactSpelling = true)] - public static unsafe extern UtilsFfiResultUsizeBoxIronRdpError Get(OptionalUsize* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "OptionalUsize_get", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultNUIntIronRdpError Get(OptionalUsize* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "OptionalUsize_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(OptionalUsize* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "OptionalUsize_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(OptionalUsize* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultOptBoxPduInfoBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultOptBoxPduInfoBoxIronRdpError.cs deleted file mode 100644 index 4e6f63cd7..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultOptBoxPduInfoBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct PduFfiResultOptBoxPduInfoBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal PduInfo* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe PduInfo* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultVoidBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultVoidBoxIronRdpError.cs deleted file mode 100644 index 90fcc2e61..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduFfiResultVoidBoxIronRdpError.cs +++ /dev/null @@ -1,36 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct PduFfiResultVoidBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduHint.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduHint.cs index 6252967e3..2b00809af 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduHint.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduHint.cs @@ -1,24 +1,17 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct PduHint +internal partial struct PduHint { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PduHint_find_size", ExactSpelling = true)] - public static unsafe extern ConnectorFfiResultBoxOptionalUsizeBoxIronRdpError FindSize(PduHint* self, byte* bytes, nuint bytesSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PduHint_find_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultOptionalUsizeIronRdpError FindSize(PduHint* handle, DiplomatSliceU8 bytes); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PduHint_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(PduHint* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PduHint_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(PduHint* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduInfo.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduInfo.cs index 04488e485..df8388e85 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduInfo.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPduInfo.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct PduInfo +internal partial struct PduInfo { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PduInfo_get_action", ExactSpelling = true)] - public static unsafe extern Action* GetAction(PduInfo* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PduInfo_get_action", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Action* GetAction(PduInfo* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PduInfo_get_length", ExactSpelling = true)] - public static unsafe extern nuint GetLength(PduInfo* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PduInfo_get_length", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint GetLength(PduInfo* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PduInfo_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(PduInfo* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PduInfo_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(PduInfo* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlags.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlags.cs index fc5205801..d8eb807f2 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlags.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlags.cs @@ -1,30 +1,23 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct PerformanceFlags +internal partial struct PerformanceFlags { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PerformanceFlags_new_default", ExactSpelling = true)] - public static unsafe extern PerformanceFlags* NewDefault(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PerformanceFlags_new_default", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern PerformanceFlags* NewDefault(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PerformanceFlags_new_empty", ExactSpelling = true)] - public static unsafe extern PerformanceFlags* NewEmpty(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PerformanceFlags_new_empty", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern PerformanceFlags* NewEmpty(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PerformanceFlags_add_flag", ExactSpelling = true)] - public static unsafe extern void AddFlag(PerformanceFlags* self, PerformanceFlagsType flag); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PerformanceFlags_add_flag", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void AddFlag(PerformanceFlags* handle, PerformanceFlagsType flag); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "PerformanceFlags_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(PerformanceFlags* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "PerformanceFlags_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(PerformanceFlags* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlagsType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlagsType.cs deleted file mode 100644 index 05f5cd574..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPerformanceFlagsType.cs +++ /dev/null @@ -1,26 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum PerformanceFlagsType -{ - DisableWallpaper = 0, - DisableFullWindowDrag = 1, - DisableMenuAnimations = 2, - DisableTheming = 3, - Reserved1 = 4, - DisableCursorShadow = 5, - DisableCursorSettings = 6, - EnableFontSmoothing = 7, - EnableDesktopComposition = 8, - Reserved2 = 9, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPixelFormat.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPixelFormat.cs deleted file mode 100644 index 0cc53eaad..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPixelFormat.cs +++ /dev/null @@ -1,24 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum PixelFormat -{ - ARgb32 = 0, - XRgb32 = 1, - ABgr32 = 2, - XBgr32 = 3, - BgrA32 = 4, - BgrX32 = 5, - RgbA32 = 6, - RgbX32 = 7, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPosition.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPosition.cs index 3c55209cf..fcb34d477 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawPosition.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawPosition.cs @@ -1,22 +1,14 @@ // by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Position +internal partial struct Position { - private const string NativeLib = "DevolutionsIronRdp"; - - public ushort x; - - public ushort y; -} + public ushort X; + public ushort Y; +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathDetectionResult.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathDetectionResult.cs index a5f7d88d0..491acbe3a 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathDetectionResult.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathDetectionResult.cs @@ -1,36 +1,29 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct RDCleanPathDetectionResult +internal partial struct RDCleanPathDetectionResult { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathDetectionResult_is_detected", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathDetectionResult_is_detected", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsDetected(RDCleanPathDetectionResult* self); + internal static unsafe extern bool IsDetected(RDCleanPathDetectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathDetectionResult_is_not_enough_bytes", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathDetectionResult_is_not_enough_bytes", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsNotEnoughBytes(RDCleanPathDetectionResult* self); + internal static unsafe extern bool IsNotEnoughBytes(RDCleanPathDetectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathDetectionResult_is_failed", ExactSpelling = true)] + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathDetectionResult_is_failed", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.U1)] - public static unsafe extern bool IsFailed(RDCleanPathDetectionResult* self); + internal static unsafe extern bool IsFailed(RDCleanPathDetectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathDetectionResult_get_total_length", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultUsizeBoxIronRdpError GetTotalLength(RDCleanPathDetectionResult* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathDetectionResult_get_total_length", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultNUIntIronRdpError GetTotalLength(RDCleanPathDetectionResult* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathDetectionResult_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(RDCleanPathDetectionResult* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathDetectionResult_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(RDCleanPathDetectionResult* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathPdu.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathPdu.cs index 5710356a1..cf1ef1442 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathPdu.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathPdu.cs @@ -1,96 +1,47 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct RDCleanPathPdu +internal partial struct RDCleanPathPdu { - private const string NativeLib = "DevolutionsIronRdp"; - /// - /// Creates a new RDCleanPath request PDU - /// - /// - /// # Arguments - /// * `x224_pdu` - The X.224 Connection Request PDU bytes - /// * `destination` - The destination RDP server address (e.g., "10.10.0.3:3389") - /// * `proxy_auth` - The JWT authentication token - /// * `pcb` - Optional preconnection blob (for Hyper-V VM connections, empty string if not needed) - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_new_request", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError NewRequest(byte* x224Pdu, nuint x224PduSz, byte* destination, nuint destinationSz, byte* proxyAuth, nuint proxyAuthSz, byte* pcb, nuint pcbSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_new_request", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultRDCleanPathPduIronRdpError NewRequest(DiplomatSliceU8 x224Pdu, DiplomatSliceU8 destination, DiplomatSliceU8 proxyAuth, DiplomatSliceU8 pcb); - /// - /// Decodes a RDCleanPath PDU from DER-encoded bytes - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_from_der", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError FromDer(byte* bytes, nuint bytesSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_from_der", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultRDCleanPathPduIronRdpError FromDer(DiplomatSliceU8 bytes); - /// - /// Encodes the RDCleanPath PDU to DER-encoded bytes - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_to_der", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultBoxVecU8BoxIronRdpError ToDer(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_to_der", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError ToDer(RDCleanPathPdu* handle); - /// - /// Detects if the bytes contain a valid RDCleanPath PDU and returns detection result - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_detect", ExactSpelling = true)] - public static unsafe extern RDCleanPathDetectionResult* Detect(byte* bytes, nuint bytesSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_detect", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern RDCleanPathDetectionResult* Detect(DiplomatSliceU8 bytes); - /// - /// Gets the type of this RDCleanPath PDU - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_type", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError GetType(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultRDCleanPathResultTypeIronRdpError GetType(RDCleanPathPdu* handle); - /// - /// Gets the X.224 connection response bytes (for Response or NegotiationError variants) - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_x224_response", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultBoxVecU8BoxIronRdpError GetX224Response(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_x224_response", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVecU8IronRdpError GetX224Response(RDCleanPathPdu* handle); - /// - /// Gets the server certificate chain (for Response variant) - /// Returns a vector iterator of certificate bytes - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_server_cert_chain", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError GetServerCertChain(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_server_cert_chain", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCertificateChainIteratorIronRdpError GetServerCertChain(RDCleanPathPdu* handle); - /// - /// Gets the server address string (for Response variant) - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_server_addr", ExactSpelling = true)] - public static unsafe extern void GetServerAddr(RDCleanPathPdu* self, DiplomatWriteable* writeable); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_server_addr", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void GetServerAddr(RDCleanPathPdu* handle, DiplomatWrite* writeable); - /// - /// Gets error message (for GeneralError variant) - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_error_message", ExactSpelling = true)] - public static unsafe extern void GetErrorMessage(RDCleanPathPdu* self, DiplomatWriteable* writeable); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_error_message", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void GetErrorMessage(RDCleanPathPdu* handle, DiplomatWrite* writeable); - /// - /// Gets the error code (for GeneralError variant) - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_error_code", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultU16BoxIronRdpError GetErrorCode(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_error_code", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUShortIronRdpError GetErrorCode(RDCleanPathPdu* handle); - /// - /// Gets the HTTP status code if present (for GeneralError variant) - /// Returns error if not present or not a GeneralError variant - /// - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_get_http_status_code", ExactSpelling = true)] - public static unsafe extern RdcleanpathFfiResultU16BoxIronRdpError GetHttpStatusCode(RDCleanPathPdu* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_get_http_status_code", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultUShortIronRdpError GetHttpStatusCode(RDCleanPathPdu* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "RDCleanPathPdu_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(RDCleanPathPdu* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "RDCleanPathPdu_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(RDCleanPathPdu* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathResultType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathResultType.cs deleted file mode 100644 index 393d65092..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRDCleanPathResultType.cs +++ /dev/null @@ -1,20 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum RDCleanPathResultType -{ - Request = 0, - Response = 1, - GeneralError = 2, - NegotiationError = 3, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError.cs deleted file mode 100644 index 01cb35908..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultBoxCertificateChainIteratorBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal CertificateChainIterator* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe CertificateChainIterator* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError.cs deleted file mode 100644 index c9f33a5da..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultBoxRDCleanPathPduBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal RDCleanPathPdu* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe RDCleanPathPdu* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxVecU8BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxVecU8BoxIronRdpError.cs deleted file mode 100644 index 7cce2e6ad..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultBoxVecU8BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultBoxVecU8BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal VecU8* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe VecU8* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError.cs deleted file mode 100644 index 6a9c6e8a9..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultRDCleanPathResultTypeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal RDCleanPathResultType ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe RDCleanPathResultType Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultU16BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultU16BoxIronRdpError.cs deleted file mode 100644 index 3eaf32007..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultU16BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultU16BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ushort ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ushort Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultUsizeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultUsizeBoxIronRdpError.cs deleted file mode 100644 index eecbdaea4..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawRdcleanpathFfiResultUsizeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct RdcleanpathFfiResultUsizeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal nuint ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe nuint Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawScancode.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawScancode.cs index 36b28edd7..3373e82f4 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawScancode.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawScancode.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Scancode +internal partial struct Scancode { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Scancode_from_u8", ExactSpelling = true)] - public static unsafe extern Scancode* FromU8([MarshalAs(UnmanagedType.U1)] bool extended, byte code); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Scancode_from_u8", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Scancode* FromU8([MarshalAs(UnmanagedType.U1)] bool extended, byte code); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Scancode_from_u16", ExactSpelling = true)] - public static unsafe extern Scancode* FromU16(ushort code); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Scancode_from_u16", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Scancode* FromU16(ushort code); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Scancode_as_operation_key_pressed", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationKeyPressed(Scancode* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Scancode_as_operation_key_pressed", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationKeyPressed(Scancode* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Scancode_as_operation_key_released", ExactSpelling = true)] - public static unsafe extern Operation* AsOperationKeyReleased(Scancode* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Scancode_as_operation_key_released", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperationKeyReleased(Scancode* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Scancode_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Scancode* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Scancode_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Scancode* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSecurityProtocol.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSecurityProtocol.cs index d3832a261..15bec2f15 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSecurityProtocol.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSecurityProtocol.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct SecurityProtocol +internal partial struct SecurityProtocol { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SecurityProtocol_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(SecurityProtocol* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "SecurityProtocol_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(SecurityProtocol* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageBoxIronRdpError.cs deleted file mode 100644 index 998d2eb08..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxActiveStageBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ActiveStage* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ActiveStage* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError.cs deleted file mode 100644 index d31234405..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ActiveStageOutputIterator* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ActiveStageOutputIterator* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxBytesSliceBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxBytesSliceBoxIronRdpError.cs deleted file mode 100644 index 24821d13b..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxBytesSliceBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxBytesSliceBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal BytesSlice* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe BytesSlice* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxDecodedPointerBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxDecodedPointerBoxIronRdpError.cs deleted file mode 100644 index dc819759c..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxDecodedPointerBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxDecodedPointerBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal DecodedPointer* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe DecodedPointer* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError.cs deleted file mode 100644 index 23d2076c0..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal GracefulDisconnectReason* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe GracefulDisconnectReason* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxInclusiveRectangleBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxInclusiveRectangleBoxIronRdpError.cs deleted file mode 100644 index 7b9a9b0d5..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxInclusiveRectangleBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxInclusiveRectangleBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal InclusiveRectangle* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe InclusiveRectangle* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxVecU8BoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxVecU8BoxIronRdpError.cs deleted file mode 100644 index a3b9a0e60..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultBoxVecU8BoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultBoxVecU8BoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal VecU8* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe VecU8* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultMultitransportRequestBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultMultitransportRequestBoxIronRdpError.cs deleted file mode 100644 index 25d48a028..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultMultitransportRequestBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultMultitransportRequestBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal MultitransportRequest ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe MultitransportRequest Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultNetworkCharacteristicsBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultNetworkCharacteristicsBoxIronRdpError.cs deleted file mode 100644 index a6adfa93f..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultNetworkCharacteristicsBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultNetworkCharacteristicsBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal NetworkCharacteristics ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe NetworkCharacteristics Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError.cs deleted file mode 100644 index 0286ac046..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultOptBoxActiveStageOutputIteratorBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal ActiveStageOutputIterator* ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe ActiveStageOutputIterator* Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultPositionBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultPositionBoxIronRdpError.cs deleted file mode 100644 index ac73edc65..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawSessionFfiResultPositionBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct SessionFfiResultPositionBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal Position ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe Position Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawStaticChannelSet.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawStaticChannelSet.cs index e7237ace8..eddc2a8e5 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawStaticChannelSet.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawStaticChannelSet.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct StaticChannelSet +internal partial struct StaticChannelSet { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "StaticChannelSet_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(StaticChannelSet* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "StaticChannelSet_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(StaticChannelSet* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawTsRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawTsRequest.cs index e5b8f200a..357472fd3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawTsRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawTsRequest.cs @@ -1,21 +1,14 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct TsRequest +internal partial struct TsRequest { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "TsRequest_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(TsRequest* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "TsRequest_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(TsRequest* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawU32Slice.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawU32Slice.cs index bdf2dca80..fdd0eeb67 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawU32Slice.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawU32Slice.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct U32Slice +internal partial struct U32Slice { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "U32Slice_get_size", ExactSpelling = true)] - public static unsafe extern nuint GetSize(U32Slice* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "U32Slice_get_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint GetSize(U32Slice* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "U32Slice_fill", ExactSpelling = true)] - public static unsafe extern UtilsFfiResultVoidBoxIronRdpError Fill(U32Slice* self, uint* buffer, nuint bufferSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "U32Slice_fill", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError Fill(U32Slice* handle, DiplomatSliceMutU32 buffer); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "U32Slice_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(U32Slice* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "U32Slice_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(U32Slice* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultUsizeBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultUsizeBoxIronRdpError.cs deleted file mode 100644 index faaa2f53d..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultUsizeBoxIronRdpError.cs +++ /dev/null @@ -1,46 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct UtilsFfiResultUsizeBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal nuint ok; - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe nuint Ok - { - get - { - return _inner.ok; - } - } - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultVoidBoxIronRdpError.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultVoidBoxIronRdpError.cs deleted file mode 100644 index 686bbfb02..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawUtilsFfiResultVoidBoxIronRdpError.cs +++ /dev/null @@ -1,36 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -[StructLayout(LayoutKind.Sequential)] -public partial struct UtilsFfiResultVoidBoxIronRdpError -{ - [StructLayout(LayoutKind.Explicit)] - private unsafe struct InnerUnion - { - [FieldOffset(0)] - internal IronRdpError* err; - } - - private InnerUnion _inner; - - [MarshalAs(UnmanagedType.U1)] - public bool isOk; - - public unsafe IronRdpError* Err - { - get - { - return _inner.err; - } - } -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawVecU8.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawVecU8.cs index 50b656777..91e3a8f7a 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawVecU8.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawVecU8.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct VecU8 +internal partial struct VecU8 { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "VecU8_from_bytes", ExactSpelling = true)] - public static unsafe extern VecU8* FromBytes(byte* bytes, nuint bytesSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "VecU8_from_bytes", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* FromBytes(DiplomatSliceU8 bytes); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "VecU8_get_size", ExactSpelling = true)] - public static unsafe extern nuint GetSize(VecU8* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "VecU8_get_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern nuint GetSize(VecU8* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "VecU8_fill", ExactSpelling = true)] - public static unsafe extern UtilsFfiResultVoidBoxIronRdpError Fill(VecU8* self, byte* buffer, nuint bufferSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "VecU8_fill", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError Fill(VecU8* handle, DiplomatSliceMutU8 buffer); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "VecU8_new_empty", ExactSpelling = true)] - public static unsafe extern VecU8* NewEmpty(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "VecU8_new_empty", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* NewEmpty(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "VecU8_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(VecU8* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "VecU8_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(VecU8* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWheelRotations.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWheelRotations.cs index 95185c5f8..31e1bb615 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWheelRotations.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWheelRotations.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct WheelRotations +internal partial struct WheelRotations { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WheelRotations_new", ExactSpelling = true)] - public static unsafe extern WheelRotations* New([MarshalAs(UnmanagedType.U1)] bool isVertical, short rotationUnits); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WheelRotations_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern WheelRotations* New([MarshalAs(UnmanagedType.U1)] bool isVertical, short rotationUnits); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WheelRotations_as_operation", ExactSpelling = true)] - public static unsafe extern Operation* AsOperation(WheelRotations* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WheelRotations_as_operation", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern Operation* AsOperation(WheelRotations* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WheelRotations_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(WheelRotations* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WheelRotations_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(WheelRotations* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWinCliprdr.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWinCliprdr.cs index 2cfee6295..6b0d9e7ea 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWinCliprdr.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWinCliprdr.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct WinCliprdr +internal partial struct WinCliprdr { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WinCliprdr_new", ExactSpelling = true)] - public static unsafe extern ClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError New(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WinCliprdr_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultWinCliprdrIronRdpError New(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WinCliprdr_next_clipboard_message", ExactSpelling = true)] - public static unsafe extern ClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError NextClipboardMessage(WinCliprdr* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WinCliprdr_next_clipboard_message", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClipboardMessageIronRdpError NextClipboardMessage(WinCliprdr* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WinCliprdr_next_clipboard_message_blocking", ExactSpelling = true)] - public static unsafe extern ClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError NextClipboardMessageBlocking(WinCliprdr* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WinCliprdr_next_clipboard_message_blocking", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultClipboardMessageIronRdpError NextClipboardMessageBlocking(WinCliprdr* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WinCliprdr_backend_factory", ExactSpelling = true)] - public static unsafe extern ClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError BackendFactory(WinCliprdr* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WinCliprdr_backend_factory", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultCliprdrBackendFactoryIronRdpError BackendFactory(WinCliprdr* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WinCliprdr_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(WinCliprdr* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WinCliprdr_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(WinCliprdr* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWriteBuf.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWriteBuf.cs index 8a3a5a86b..f16269105 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWriteBuf.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWriteBuf.cs @@ -1,33 +1,26 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct WriteBuf +internal partial struct WriteBuf { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WriteBuf_new", ExactSpelling = true)] - public static unsafe extern WriteBuf* New(); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WriteBuf_new", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern WriteBuf* New(); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WriteBuf_clear", ExactSpelling = true)] - public static unsafe extern void Clear(WriteBuf* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WriteBuf_clear", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Clear(WriteBuf* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WriteBuf_read_into_buf", ExactSpelling = true)] - public static unsafe extern PduFfiResultVoidBoxIronRdpError ReadIntoBuf(WriteBuf* self, byte* buf, nuint bufSz); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WriteBuf_read_into_buf", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern DiplomatResultVoidIronRdpError ReadIntoBuf(WriteBuf* handle, DiplomatSliceMutU8 buf); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WriteBuf_get_filled", ExactSpelling = true)] - public static unsafe extern VecU8* GetFilled(WriteBuf* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WriteBuf_get_filled", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern VecU8* GetFilled(WriteBuf* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "WriteBuf_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(WriteBuf* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "WriteBuf_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(WriteBuf* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWritten.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWritten.cs index 6792ddb39..23b4e841b 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWritten.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWritten.cs @@ -1,27 +1,20 @@ -// by Diplomat - -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - +using Devolutions.IronRdp; using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp.Raw; -#nullable enable - [StructLayout(LayoutKind.Sequential)] -public partial struct Written +internal partial struct Written { - private const string NativeLib = "DevolutionsIronRdp"; - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Written_get_written_type", ExactSpelling = true)] - public static unsafe extern WrittenType GetWrittenType(Written* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Written_get_written_type", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern WrittenType GetWrittenType(Written* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Written_get_size", ExactSpelling = true)] - public static unsafe extern OptionalUsize* GetSize(Written* self); + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Written_get_size", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern OptionalUsize* GetSize(Written* handle); - [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "Written_destroy", ExactSpelling = true)] - public static unsafe extern void Destroy(Written* self); -} + [DllImport(DiplomatNativeLib.Name, EntryPoint = "Written_destroy", CallingConvention = CallingConvention.Cdecl)] + internal static unsafe extern void Destroy(Written* handle); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWrittenType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RawWrittenType.cs deleted file mode 100644 index 5878798fc..000000000 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/RawWrittenType.cs +++ /dev/null @@ -1,18 +0,0 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - -namespace Devolutions.IronRdp.Raw; - -#nullable enable - -public enum WrittenType -{ - Size = 0, - Nothing = 1, -} diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/RustHandle.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/RustHandle.cs new file mode 100644 index 000000000..79bc33119 --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/RustHandle.cs @@ -0,0 +1,50 @@ +using System; + +namespace Devolutions.IronRdp.Diplomat; + +#nullable enable + +/// +/// Frees a Rust-owned by calling its native +/// destructor. Held by an owned so the handle can +/// release the pointer without knowing the concrete type. +/// +internal unsafe delegate void RustDestructor(T* ptr) where T : unmanaged; + +/// +/// A raw pointer that remembers who's responsible for freeing it. An owned +/// handle carries the Rust destructor and runs it when you release the handle; +/// a borrowed handle carries none, so releasing it does nothing — Rust still +/// owns the memory and will free it itself. That's the whole trick: the +/// pointer itself says "free me" or "leave me alone", so the wrapper doesn't +/// need a separate flag bolted onto the class. +/// +internal readonly unsafe struct RustHandle where T : unmanaged +{ + private readonly T* _ptr; + private readonly RustDestructor? _free; + + private RustHandle(T* ptr, RustDestructor? free) + { + _ptr = ptr; + _free = free; + } + + /// The C# side owns the pointer: frees it. + public static RustHandle Owned(T* ptr, RustDestructor free) => new RustHandle(ptr, free); + + /// Rust still owns the pointer: is a no-op. + public static RustHandle Borrowed(T* ptr) => new RustHandle(ptr, null); + + public T* Ptr => _ptr; + + public bool IsNull => _ptr == null; + + public void Release() + { + if (_free != null && _ptr != null) + { + _free(_ptr); + } + } +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Scancode.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Scancode.cs index dbc7504f9..23961d64c 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Scancode.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Scancode.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class Scancode: IDisposable { - private unsafe Raw.Scancode* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Scancode.Destroy; /// /// Creates a managed Scancode from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Scancode(Raw.Scancode* handle) + internal unsafe Scancode(Raw.Scancode* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Scancode(Raw.Scancode* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Scancode(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static Scancode FromU8(bool extended, byte code) { unsafe { - Raw.Scancode* retVal = Raw.Scancode.FromU8(extended, code); - return new Scancode(retVal); + Raw.Scancode* result = Raw.Scancode.FromU8(extended, code); + return new Scancode(result); } } @@ -48,8 +77,8 @@ public static Scancode FromU16(ushort code) { unsafe { - Raw.Scancode* retVal = Raw.Scancode.FromU16(code); - return new Scancode(retVal); + Raw.Scancode* result = Raw.Scancode.FromU16(code); + return new Scancode(result); } } @@ -60,12 +89,13 @@ public Operation AsOperationKeyPressed() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Scancode"); } - Raw.Operation* retVal = Raw.Scancode.AsOperationKeyPressed(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.Scancode.AsOperationKeyPressed(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } @@ -76,21 +106,22 @@ public Operation AsOperationKeyReleased() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Scancode"); } - Raw.Operation* retVal = Raw.Scancode.AsOperationKeyReleased(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.Scancode.AsOperationKeyReleased(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Scancode* AsFFI() + internal unsafe Raw.Scancode* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -100,13 +131,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Scancode.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -116,4 +148,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/SecurityProtocol.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/SecurityProtocol.cs index 92dec8315..d4f5090b3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/SecurityProtocol.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/SecurityProtocol.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class SecurityProtocol: IDisposable { - private unsafe Raw.SecurityProtocol* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.SecurityProtocol.Destroy; /// /// Creates a managed SecurityProtocol from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe SecurityProtocol(Raw.SecurityProtocol* handle) + internal unsafe SecurityProtocol(Raw.SecurityProtocol* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe SecurityProtocol(Raw.SecurityProtocol* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe SecurityProtocol(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.SecurityProtocol* AsFFI() + internal unsafe Raw.SecurityProtocol* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.SecurityProtocol.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/StaticChannelSet.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/StaticChannelSet.cs index 3ee5e0f2a..f6dcc1c46 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/StaticChannelSet.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/StaticChannelSet.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class StaticChannelSet: IDisposable { - private unsafe Raw.StaticChannelSet* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.StaticChannelSet.Destroy; /// /// Creates a managed StaticChannelSet from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe StaticChannelSet(Raw.StaticChannelSet* handle) + internal unsafe StaticChannelSet(Raw.StaticChannelSet* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe StaticChannelSet(Raw.StaticChannelSet* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe StaticChannelSet(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.StaticChannelSet* AsFFI() + internal unsafe Raw.StaticChannelSet* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.StaticChannelSet.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/TsRequest.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/TsRequest.cs index 6a3972a5d..18bb3c1c7 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/TsRequest.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/TsRequest.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,28 +10,60 @@ namespace Devolutions.IronRdp; public partial class TsRequest: IDisposable { - private unsafe Raw.TsRequest* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.TsRequest.Destroy; /// /// Creates a managed TsRequest from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe TsRequest(Raw.TsRequest* handle) + internal unsafe TsRequest(Raw.TsRequest* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe TsRequest(Raw.TsRequest* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe TsRequest(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// /// Returns the underlying raw handle. /// - public unsafe Raw.TsRequest* AsFFI() + internal unsafe Raw.TsRequest* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -44,13 +73,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.TsRequest.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -60,4 +90,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/U32Slice.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/U32Slice.cs index e552913cf..4ba66d3a0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/U32Slice.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/U32Slice.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class U32Slice: IDisposable { - private unsafe Raw.U32Slice* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.U32Slice.Destroy; public nuint Size { @@ -27,26 +32,51 @@ public nuint Size /// Creates a managed U32Slice from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe U32Slice(Raw.U32Slice* handle) + internal unsafe U32Slice(Raw.U32Slice* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe U32Slice(Raw.U32Slice* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe U32Slice(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } public nuint GetSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("U32Slice"); } - nuint retVal = Raw.U32Slice.GetSize(_inner); - return retVal; + var result = Raw.U32Slice.GetSize(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -55,18 +85,20 @@ public void Fill(uint[] buffer) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("U32Slice"); } - nuint bufferLength = (nuint)buffer.Length; + if (buffer == null) throw new ArgumentNullException(nameof(buffer)); fixed (uint* bufferPtr = buffer) { - Raw.UtilsFfiResultVoidBoxIronRdpError result = Raw.U32Slice.Fill(_inner, bufferPtr, bufferLength); - if (!result.isOk) + var result = Raw.U32Slice.Fill(AsFFI(), new DiplomatSliceMutU32 { Ptr = bufferPtr, Len = (nuint)buffer.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } } @@ -74,9 +106,9 @@ public void Fill(uint[] buffer) /// /// Returns the underlying raw handle. /// - public unsafe Raw.U32Slice* AsFFI() + internal unsafe Raw.U32Slice* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -86,13 +118,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.U32Slice.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -102,4 +135,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Utf8.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Utf8.cs new file mode 100644 index 000000000..bdf6c938d --- /dev/null +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Utf8.cs @@ -0,0 +1,14 @@ +namespace Devolutions.IronRdp.Diplomat; + +/// +/// Explicit conversions between a C# string (always UTF-16 internally) +/// and raw UTF-8 bytes. Handing a string to a Rust &str +/// parameter always requires transcoding — there's no way around that +/// allocation. This class exists so the copy is a visible, separately-named +/// step in generated code (Utf8.Clone(...)) instead of being buried +/// inside marshalling. +/// +internal static class Utf8 +{ + public static byte[] Clone(string value) => System.Text.Encoding.UTF8.GetBytes(value); +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/VecU8.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/VecU8.cs index 488d1e586..abda823c0 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/VecU8.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/VecU8.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class VecU8: IDisposable { - private unsafe Raw.VecU8* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.VecU8.Destroy; public nuint Size { @@ -27,14 +32,38 @@ public nuint Size /// Creates a managed VecU8 from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe VecU8(Raw.VecU8* handle) + internal unsafe VecU8(Raw.VecU8* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe VecU8(Raw.VecU8* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe VecU8(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -44,11 +73,11 @@ public static VecU8 FromBytes(byte[] bytes) { unsafe { - nuint bytesLength = (nuint)bytes.Length; + if (bytes == null) throw new ArgumentNullException(nameof(bytes)); fixed (byte* bytesPtr = bytes) { - Raw.VecU8* retVal = Raw.VecU8.FromBytes(bytesPtr, bytesLength); - return new VecU8(retVal); + Raw.VecU8* result = Raw.VecU8.FromBytes(new DiplomatSliceU8 { Ptr = bytesPtr, Len = (nuint)bytes.Length }); + return new VecU8(result); } } } @@ -57,12 +86,13 @@ public nuint GetSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("VecU8"); } - nuint retVal = Raw.VecU8.GetSize(_inner); - return retVal; + var result = Raw.VecU8.GetSize(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -71,18 +101,20 @@ public void Fill(byte[] buffer) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("VecU8"); } - nuint bufferLength = (nuint)buffer.Length; + if (buffer == null) throw new ArgumentNullException(nameof(buffer)); fixed (byte* bufferPtr = buffer) { - Raw.UtilsFfiResultVoidBoxIronRdpError result = Raw.VecU8.Fill(_inner, bufferPtr, bufferLength); - if (!result.isOk) + var result = Raw.VecU8.Fill(AsFFI(), new DiplomatSliceMutU8 { Ptr = bufferPtr, Len = (nuint)buffer.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } } @@ -94,17 +126,17 @@ public static VecU8 NewEmpty() { unsafe { - Raw.VecU8* retVal = Raw.VecU8.NewEmpty(); - return new VecU8(retVal); + Raw.VecU8* result = Raw.VecU8.NewEmpty(); + return new VecU8(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.VecU8* AsFFI() + internal unsafe Raw.VecU8* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -114,13 +146,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.VecU8.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -130,4 +163,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/WheelRotations.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/WheelRotations.cs index 97077dd59..1aed963a3 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/WheelRotations.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/WheelRotations.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class WheelRotations: IDisposable { - private unsafe Raw.WheelRotations* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.WheelRotations.Destroy; /// /// Creates a managed WheelRotations from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe WheelRotations(Raw.WheelRotations* handle) + internal unsafe WheelRotations(Raw.WheelRotations* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe WheelRotations(Raw.WheelRotations* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe WheelRotations(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -36,8 +65,8 @@ public static WheelRotations New(bool isVertical, short rotationUnits) { unsafe { - Raw.WheelRotations* retVal = Raw.WheelRotations.New(isVertical, rotationUnits); - return new WheelRotations(retVal); + Raw.WheelRotations* result = Raw.WheelRotations.New(isVertical, rotationUnits); + return new WheelRotations(result); } } @@ -48,21 +77,22 @@ public Operation AsOperation() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WheelRotations"); } - Raw.Operation* retVal = Raw.WheelRotations.AsOperation(_inner); - return new Operation(retVal); + Raw.Operation* result = Raw.WheelRotations.AsOperation(AsFFI()); + GC.KeepAlive(this); + return new Operation(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.WheelRotations* AsFFI() + internal unsafe Raw.WheelRotations* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -72,13 +102,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.WheelRotations.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -88,4 +119,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/WinCliprdr.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/WinCliprdr.cs index ab865f26a..c5fe692f8 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/WinCliprdr.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/WinCliprdr.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,20 +10,52 @@ namespace Devolutions.IronRdp; public partial class WinCliprdr: IDisposable { - private unsafe Raw.WinCliprdr* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.WinCliprdr.Destroy; /// /// Creates a managed WinCliprdr from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe WinCliprdr(Raw.WinCliprdr* handle) + internal unsafe WinCliprdr(Raw.WinCliprdr* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe WinCliprdr(Raw.WinCliprdr* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe WinCliprdr(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } /// @@ -37,13 +66,12 @@ public static WinCliprdr New() { unsafe { - Raw.ClipboardWindowsFfiResultBoxWinCliprdrBoxIronRdpError result = Raw.WinCliprdr.New(); - if (!result.isOk) + var result = Raw.WinCliprdr.New(); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.WinCliprdr* retVal = result.Ok; - return new WinCliprdr(retVal); + return new WinCliprdr(result.Ok); } } @@ -51,25 +79,21 @@ public static WinCliprdr New() /// /// A ClipboardMessage allocated on Rust side. /// - public ClipboardMessage NextClipboardMessage() + public ClipboardMessage? NextClipboardMessage() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WinCliprdr"); } - Raw.ClipboardWindowsFfiResultOptBoxClipboardMessageBoxIronRdpError result = Raw.WinCliprdr.NextClipboardMessage(_inner); - if (!result.isOk) + var result = Raw.WinCliprdr.NextClipboardMessage(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClipboardMessage* retVal = result.Ok; - if (retVal == null) - { - return null; - } - return new ClipboardMessage(retVal); + return result.Ok == null ? null : new ClipboardMessage(result.Ok); } } @@ -81,17 +105,17 @@ public ClipboardMessage NextClipboardMessageBlocking() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WinCliprdr"); } - Raw.ClipboardWindowsFfiResultBoxClipboardMessageBoxIronRdpError result = Raw.WinCliprdr.NextClipboardMessageBlocking(_inner); - if (!result.isOk) + var result = Raw.WinCliprdr.NextClipboardMessageBlocking(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.ClipboardMessage* retVal = result.Ok; - return new ClipboardMessage(retVal); + return new ClipboardMessage(result.Ok); } } @@ -103,26 +127,26 @@ public CliprdrBackendFactory BackendFactory() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WinCliprdr"); } - Raw.ClipboardWindowsFfiResultBoxCliprdrBackendFactoryBoxIronRdpError result = Raw.WinCliprdr.BackendFactory(_inner); - if (!result.isOk) + var result = Raw.WinCliprdr.BackendFactory(AsFFI()); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } - Raw.CliprdrBackendFactory* retVal = result.Ok; - return new CliprdrBackendFactory(retVal); + return new CliprdrBackendFactory(result.Ok); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.WinCliprdr* AsFFI() + internal unsafe Raw.WinCliprdr* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -132,13 +156,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.WinCliprdr.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -148,4 +173,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/WriteBuf.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/WriteBuf.cs index 4da93efb8..5328fcfce 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/WriteBuf.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/WriteBuf.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class WriteBuf: IDisposable { - private unsafe Raw.WriteBuf* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.WriteBuf.Destroy; public VecU8 Filled { @@ -27,14 +32,38 @@ public VecU8 Filled /// Creates a managed WriteBuf from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe WriteBuf(Raw.WriteBuf* handle) + internal unsafe WriteBuf(Raw.WriteBuf* handle) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe WriteBuf(Raw.WriteBuf* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe WriteBuf(RustHandle inner, object[] edges) { - _inner = handle; + _inner = inner; + _edges = edges; } /// @@ -44,8 +73,8 @@ public static WriteBuf New() { unsafe { - Raw.WriteBuf* retVal = Raw.WriteBuf.New(); - return new WriteBuf(retVal); + Raw.WriteBuf* result = Raw.WriteBuf.New(); + return new WriteBuf(result); } } @@ -53,11 +82,12 @@ public void Clear() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WriteBuf"); } - Raw.WriteBuf.Clear(_inner); + Raw.WriteBuf.Clear(AsFFI()); + GC.KeepAlive(this); } } @@ -66,18 +96,20 @@ public void ReadIntoBuf(byte[] buf) { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WriteBuf"); } - nuint bufLength = (nuint)buf.Length; + if (buf == null) throw new ArgumentNullException(nameof(buf)); fixed (byte* bufPtr = buf) { - Raw.PduFfiResultVoidBoxIronRdpError result = Raw.WriteBuf.ReadIntoBuf(_inner, bufPtr, bufLength); - if (!result.isOk) + var result = Raw.WriteBuf.ReadIntoBuf(AsFFI(), new DiplomatSliceMutU8 { Ptr = bufPtr, Len = (nuint)buf.Length }); + GC.KeepAlive(this); + if (!result.IsOk) { throw new IronRdpException(new IronRdpError(result.Err)); } + return; } } } @@ -89,21 +121,22 @@ public VecU8 GetFilled() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("WriteBuf"); } - Raw.VecU8* retVal = Raw.WriteBuf.GetFilled(_inner); - return new VecU8(retVal); + Raw.VecU8* result = Raw.WriteBuf.GetFilled(AsFFI()); + GC.KeepAlive(this); + return new VecU8(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.WriteBuf* AsFFI() + internal unsafe Raw.WriteBuf* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -113,13 +146,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.WriteBuf.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -129,4 +163,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/Written.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/Written.cs index c02d6cde3..679c7bd56 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/Written.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/Written.cs @@ -1,11 +1,8 @@ // by Diplomat -#pragma warning disable 0105 using System; using System.Runtime.InteropServices; - using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 namespace Devolutions.IronRdp; @@ -13,7 +10,15 @@ namespace Devolutions.IronRdp; public partial class Written: IDisposable { - private unsafe Raw.Written* _inner; + private unsafe RustHandle _inner; + + /// + /// Roots the wrappers this value borrows from so the GC cannot finalize + /// a borrowed-from parent while this value is alive. + /// + private object[] _edges; + + private static readonly unsafe RustDestructor _destroy = Raw.Written.Destroy; public OptionalUsize Size { @@ -35,29 +40,51 @@ public WrittenType WrittenType /// Creates a managed Written from a raw handle. /// /// - /// Safety: you should not build two managed objects using the same raw handle (may causes use-after-free and double-free). + /// Safety: you should not build two managed objects using the same raw handle (may cause use-after-free and double-free). ///
/// This constructor assumes the raw struct is allocated on Rust side. /// If implemented, the custom Drop implementation on Rust side WILL run on destruction. ///
- public unsafe Written(Raw.Written* handle) + internal unsafe Written(Raw.Written* handle) { - _inner = handle; + _inner = RustHandle.Owned(handle, _destroy); + _edges = System.Array.Empty(); + } + + /// + /// Edges only keep the borrowed-from objects GC-reachable. Explicitly + /// Dispose-ing a parent while a borrowing child is in use is still a + /// use-after-free and remains the caller's responsibility. + /// + internal unsafe Written(Raw.Written* handle, object[] edges) + { + _inner = RustHandle.Owned(handle, _destroy); + _edges = edges; + } + + /// + /// Wraps a handle that already knows whether it owns the pointer. A + /// borrowed return passes a non-owning handle, so Dispose and the finalizer + /// leave Rust's pointer alone; the edges keep the borrowed-from owners alive + /// while this view is in use. + /// + internal unsafe Written(RustHandle inner, object[] edges) + { + _inner = inner; + _edges = edges; } - /// - /// A WrittenType allocated on C# side. - /// public WrittenType GetWrittenType() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Written"); } - Raw.WrittenType retVal = Raw.Written.GetWrittenType(_inner); - return (WrittenType)retVal; + var result = Raw.Written.GetWrittenType(AsFFI()); + GC.KeepAlive(this); + return result; } } @@ -68,21 +95,22 @@ public OptionalUsize GetSize() { unsafe { - if (_inner == null) + if (_inner.IsNull) { throw new ObjectDisposedException("Written"); } - Raw.OptionalUsize* retVal = Raw.Written.GetSize(_inner); - return new OptionalUsize(retVal); + Raw.OptionalUsize* result = Raw.Written.GetSize(AsFFI()); + GC.KeepAlive(this); + return new OptionalUsize(result); } } /// /// Returns the underlying raw handle. /// - public unsafe Raw.Written* AsFFI() + internal unsafe Raw.Written* AsFFI() { - return _inner; + return _inner.Ptr; } /// @@ -92,13 +120,14 @@ public void Dispose() { unsafe { - if (_inner == null) + if (_inner.IsNull) { return; } - Raw.Written.Destroy(_inner); - _inner = null; + _inner.Release(); + _inner = default; + _edges = System.Array.Empty(); // release refs so borrowed-from owners can be GC'd GC.SuppressFinalize(this); } @@ -108,4 +137,4 @@ public void Dispose() { Dispose(); } -} +} \ No newline at end of file diff --git a/ffi/dotnet/Devolutions.IronRdp/Generated/WrittenType.cs b/ffi/dotnet/Devolutions.IronRdp/Generated/WrittenType.cs index 72c949257..2212860a8 100644 --- a/ffi/dotnet/Devolutions.IronRdp/Generated/WrittenType.cs +++ b/ffi/dotnet/Devolutions.IronRdp/Generated/WrittenType.cs @@ -1,18 +1,7 @@ -// by Diplomat - -#pragma warning disable 0105 -using System; -using System.Runtime.InteropServices; - -using Devolutions.IronRdp.Diplomat; -#pragma warning restore 0105 - namespace Devolutions.IronRdp; -#nullable enable - -public enum WrittenType +public enum WrittenType : int { Size = 0, Nothing = 1, -} +} \ No newline at end of file diff --git a/ffi/src/clipboard/message.rs b/ffi/src/clipboard/message.rs index 129fddd7e..9b3b334ca 100644 --- a/ffi/src/clipboard/message.rs +++ b/ffi/src/clipboard/message.rs @@ -4,7 +4,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::utils::ffi::VecU8; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClipboardMessage(pub ironrdp::cliprdr::backend::ClipboardMessage); impl ClipboardMessage { @@ -97,16 +97,16 @@ pub mod ffi { Error, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClipboardFormatIterator(pub Vec); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct FormatDataResponse(pub Option); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClipboardFormatId(pub ironrdp::cliprdr::pdu::ClipboardFormatId); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct FfiFileContentsRequest(pub ironrdp::cliprdr::pdu::FileContentsRequest); impl FfiFileContentsRequest { @@ -145,7 +145,7 @@ pub mod ffi { /// Wraps `OwnedFileContentsResponse`, which is a type alias for /// `FileContentsResponse<'static>` (generated by `impl_pdu_borrowing!`). - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct FfiFileContentsResponse(pub ironrdp::cliprdr::pdu::OwnedFileContentsResponse); impl FfiFileContentsResponse { diff --git a/ffi/src/clipboard/mod.rs b/ffi/src/clipboard/mod.rs index 0d0b679da..a056a5f7d 100644 --- a/ffi/src/clipboard/mod.rs +++ b/ffi/src/clipboard/mod.rs @@ -9,7 +9,7 @@ pub mod ffi { use ironrdp::cliprdr::Client; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct CliprdrBackendFactory(pub Box); impl CliprdrBackendFactory { @@ -20,10 +20,10 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Cliprdr(pub Option>); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClipboardSvcMessage(pub Option>); } diff --git a/ffi/src/clipboard/windows.rs b/ffi/src/clipboard/windows.rs index 993f25eeb..5fde2cd6c 100644 --- a/ffi/src/clipboard/windows.rs +++ b/ffi/src/clipboard/windows.rs @@ -26,7 +26,7 @@ pub mod ffi { use crate::clipboard::message::ffi::ClipboardMessage; use crate::error::ffi::IronRdpError; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct WinCliprdr(WinCliprdrInner); impl WinCliprdr { diff --git a/ffi/src/connector/activation.rs b/ffi/src/connector/activation.rs index 9a1b0c967..46c4afded 100644 --- a/ffi/src/connector/activation.rs +++ b/ffi/src/connector/activation.rs @@ -9,7 +9,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::pdu::ffi::WriteBuf; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectionActivationSequence( pub Box, ); @@ -45,7 +45,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectionActivationState { pub state: ironrdp::connector::connection_activation::ConnectionActivationState, } @@ -113,7 +113,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectionActivationStateConnectionFinalization { pub desktop_size: ironrdp::connector::DesktopSize, pub connection_finalization: ironrdp::connector::ConnectionFinalizationSequence, @@ -125,7 +125,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectionActivationStateFinalized { pub share_id: u32, pub desktop_size: ironrdp::connector::DesktopSize, diff --git a/ffi/src/connector/config.rs b/ffi/src/connector/config.rs index 3ec0e1777..9f102da23 100644 --- a/ffi/src/connector/config.rs +++ b/ffi/src/connector/config.rs @@ -10,7 +10,7 @@ pub mod ffi { use crate::dvc::ffi::DvcPipeProxyConfig; use crate::error::ffi::IronRdpError; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Config { pub connector: ironrdp::connector::Config, pub dvc_pipe_proxy: Option, @@ -27,7 +27,7 @@ pub mod ffi { } #[derive(Default)] - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConfigBuilder { pub credentials: Option, pub domain: Option, @@ -65,7 +65,7 @@ pub mod ffi { Japanese, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DesktopSize(pub ironrdp::connector::DesktopSize); impl DesktopSize { @@ -235,7 +235,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] #[derive(Default)] pub struct PerformanceFlags(pub ironrdp::pdu::rdp::client_info::PerformanceFlags); @@ -268,7 +268,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct BitmapConfig(pub ironrdp::connector::BitmapConfig); } diff --git a/ffi/src/connector/mod.rs b/ffi/src/connector/mod.rs index ab2b7b805..a81a7f9a9 100644 --- a/ffi/src/connector/mod.rs +++ b/ffi/src/connector/mod.rs @@ -7,7 +7,7 @@ pub mod state; pub mod ffi { use core::fmt::Write as _; - use diplomat_runtime::DiplomatWriteable; + use diplomat_runtime::DiplomatWrite; use ironrdp::connector::Sequence as _; use ironrdp::displaycontrol::client::DisplayControlClient; use ironrdp::dvc::DvcProcessor; @@ -24,7 +24,7 @@ pub mod ffi { use crate::error::ffi::{IronRdpError, IronRdpErrorKind}; use crate::pdu::ffi::WriteBuf; - #[diplomat::opaque] // We must use Option here, as ClientConnector is not Clone and have functions that consume it + #[diplomat::opaque_mut] // We must use Option here, as ClientConnector is not Clone and have functions that consume it pub struct ClientConnector(pub Option); // Basic Impl for ClientConnector @@ -181,7 +181,7 @@ pub mod ffi { Ok(()) } - pub fn next_pdu_hint(&self) -> Result>>, Box> { + pub fn next_pdu_hint<'a>(&'a self) -> Result>>, Box> { let Some(connector) = self.0.as_ref() else { return Err(ValueConsumedError::for_item("connector").into()); }; @@ -189,7 +189,7 @@ pub mod ffi { Ok(connector.next_pdu_hint().map(PduHint).map(Box::new)) } - pub fn get_dyn_state(&self) -> Result>, Box> { + pub fn get_dyn_state<'a>(&'a self) -> Result>, Box> { let Some(connector) = self.0.as_ref() else { return Err(ValueConsumedError::for_item("connector").into()); }; @@ -206,7 +206,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct PduHint<'a>(pub &'a dyn ironrdp::pdu::PduHint); impl<'a> PduHint<'a> { @@ -218,11 +218,11 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DynState<'a>(pub &'a dyn ironrdp::connector::State); impl<'a> DynState<'a> { - pub fn get_name(&'a self, writeable: &'a mut DiplomatWriteable) -> Result<(), Box> { + pub fn get_name(&'a self, writeable: &'a mut DiplomatWrite) -> Result<(), Box> { let name = self.0.name(); write!(writeable, "{name}")?; Ok(()) @@ -233,9 +233,9 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ChannelConnectionSequence(pub ironrdp::connector::ChannelConnectionSequence); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct LicenseExchangeSequence(pub ironrdp::connector::LicenseExchangeSequence); } diff --git a/ffi/src/connector/result.rs b/ffi/src/connector/result.rs index 4f016868f..e06b9715d 100644 --- a/ffi/src/connector/result.rs +++ b/ffi/src/connector/result.rs @@ -5,7 +5,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::utils::ffi::OptionalUsize; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Written(pub ironrdp::connector::Written); pub enum WrittenType { @@ -29,7 +29,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectionResult(pub Option); impl ConnectionResult { diff --git a/ffi/src/connector/state.rs b/ffi/src/connector/state.rs index 97ccfeae1..9315746a6 100644 --- a/ffi/src/connector/state.rs +++ b/ffi/src/connector/state.rs @@ -4,7 +4,7 @@ pub mod ffi { use crate::error::{IncorrectEnumTypeError, ValueConsumedError}; use crate::pdu::ffi::SecurityProtocol; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClientConnectorState(pub Option); pub enum ClientConnectorStateType { diff --git a/ffi/src/credssp/mod.rs b/ffi/src/credssp/mod.rs index 2282e86c6..e5e48b540 100644 --- a/ffi/src/credssp/mod.rs +++ b/ffi/src/credssp/mod.rs @@ -13,16 +13,16 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::pdu::ffi::WriteBuf; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct KerberosConfig(pub ironrdp::connector::credssp::KerberosConfig); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct CredsspSequence(pub ironrdp::connector::credssp::CredsspSequence); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct TsRequest(pub sspi::credssp::TsRequest); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct CredsspSequenceInitResult { pub credssp_sequence: Option>, pub ts_request: Option>, diff --git a/ffi/src/credssp/network.rs b/ffi/src/credssp/network.rs index b371dcf0e..49478d4be 100644 --- a/ffi/src/credssp/network.rs +++ b/ffi/src/credssp/network.rs @@ -11,13 +11,13 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::utils::ffi::VecU8; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct CredsspProcessGenerator<'a>(pub ironrdp::connector::credssp::CredsspProcessGenerator<'a>); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct GeneratorState(pub CredsspGeneratorState); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct NetworkRequest<'a>(pub &'a sspi::generator::NetworkRequest); #[diplomat::enum_convert(sspi::network_client::NetworkProtocol)] @@ -28,7 +28,7 @@ pub mod ffi { Https, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ClientState(pub sspi::credssp::ClientState); impl<'a> CredsspProcessGenerator<'a> { @@ -94,7 +94,7 @@ pub mod ffi { self.0.protocol.into() } - pub fn get_url(&self, writeable: &mut diplomat_runtime::DiplomatWriteable) -> Result<(), Box> { + pub fn get_url(&self, writeable: &mut diplomat_runtime::DiplomatWrite) -> Result<(), Box> { use core::fmt::Write as _; let url: &str = self.0.url.as_ref(); write!(writeable, "{url}")?; diff --git a/ffi/src/dvc/dvc_pipe_proxy_message_queue.rs b/ffi/src/dvc/dvc_pipe_proxy_message_queue.rs index 1ec4cc0fe..7b98d4878 100644 --- a/ffi/src/dvc/dvc_pipe_proxy_message_queue.rs +++ b/ffi/src/dvc/dvc_pipe_proxy_message_queue.rs @@ -9,7 +9,7 @@ pub mod ffi { use super::{DvcPipeProxyMessageInner, DvcPipeProxyMessageQueueInner}; use crate::error::ffi::IronRdpError; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DvcPipeProxyMessage(pub DvcPipeProxyMessageInner); impl DvcPipeProxyMessage { @@ -18,11 +18,11 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] #[derive(Clone)] pub struct DvcPipeProxyMessageSink(pub mpsc::SyncSender); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DvcPipeProxyMessageQueue(DvcPipeProxyMessageQueueInner); impl DvcPipeProxyMessageQueue { diff --git a/ffi/src/dvc/mod.rs b/ffi/src/dvc/mod.rs index 16e7d2782..33e137151 100644 --- a/ffi/src/dvc/mod.rs +++ b/ffi/src/dvc/mod.rs @@ -4,10 +4,10 @@ pub mod dvc_pipe_proxy_message_queue; pub mod ffi { use crate::dvc::dvc_pipe_proxy_message_queue::ffi::DvcPipeProxyMessageSink; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DrdynvcChannel(pub ironrdp::dvc::DrdynvcClient); - #[diplomat::opaque] + #[diplomat::opaque_mut] #[derive(Clone)] pub struct DvcPipeProxyDescriptor { pub channel_name: String, @@ -23,7 +23,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] #[derive(Clone)] pub struct DvcPipeProxyConfig { pub message_sink: DvcPipeProxyMessageSink, diff --git a/ffi/src/error.rs b/ffi/src/error.rs index 11ae4e2be..2f5ef73c3 100644 --- a/ffi/src/error.rs +++ b/ffi/src/error.rs @@ -184,9 +184,9 @@ impl From for Box { pub mod ffi { use core::fmt::Write as _; - use diplomat_runtime::DiplomatWriteable; + use diplomat_runtime::DiplomatWrite; - #[derive(Debug, Clone, Copy, thiserror::Error)] + #[derive(Debug, thiserror::Error)] pub enum IronRdpErrorKind { #[error("Generic error")] Generic, @@ -213,12 +213,12 @@ pub mod ffi { } /// Stringified Picky error along with an error kind. - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct IronRdpError(pub(super) super::IronRdpErrorInner); impl IronRdpError { /// Returns the error as a string. - pub fn to_display(&self, writeable: &mut DiplomatWriteable) { + pub fn to_display(&self, writeable: &mut DiplomatWrite) { let _ = write!(writeable, "{}", self.0.repr); writeable.flush(); } diff --git a/ffi/src/graphics.rs b/ffi/src/graphics.rs index 548cd0120..1ac29bccd 100644 --- a/ffi/src/graphics.rs +++ b/ffi/src/graphics.rs @@ -4,7 +4,7 @@ pub mod ffi { use crate::utils::ffi::BytesSlice; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DecodedPointer(pub Arc); impl DecodedPointer { @@ -24,7 +24,7 @@ pub mod ffi { self.0.hotspot_y } - pub fn get_data(&self) -> Box> { + pub fn get_data<'a>(&'a self) -> Box> { Box::new(BytesSlice(&self.0.bitmap_data)) } } diff --git a/ffi/src/input.rs b/ffi/src/input.rs index 81c35ead5..eccbaa56d 100644 --- a/ffi/src/input.rs +++ b/ffi/src/input.rs @@ -3,7 +3,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::pdu::ffi::FastPathInputEventIterator; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct InputDatabase(pub ironrdp::input::Database); impl InputDatabase { @@ -17,7 +17,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Operation(pub ironrdp::input::Operation); pub enum OperationType { @@ -31,7 +31,7 @@ pub mod ffi { UnicodeKeyReleased, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct MousePosition(pub ironrdp::input::MousePosition); impl MousePosition { @@ -44,7 +44,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct MouseButton(pub ironrdp::input::MouseButton); #[diplomat::enum_convert(ironrdp::input::MouseButton)] @@ -72,7 +72,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct WheelRotations(pub ironrdp::input::WheelRotations); impl WheelRotations { @@ -88,7 +88,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Scancode(pub ironrdp::input::Scancode); impl Scancode { @@ -111,7 +111,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Char(pub char); impl Char { diff --git a/ffi/src/log.rs b/ffi/src/log.rs index 8e2f8d0d7..0f6961458 100644 --- a/ffi/src/log.rs +++ b/ffi/src/log.rs @@ -10,7 +10,7 @@ const IRONRDP_LOG: &str = "IRONRDP_LOG"; pub mod ffi { use super::{INIT_LOG, IRONRDP_LOG_PATH, setup_logging}; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Log; impl Log { diff --git a/ffi/src/pdu.rs b/ffi/src/pdu.rs index 8dc60d17b..61e8be4ca 100644 --- a/ffi/src/pdu.rs +++ b/ffi/src/pdu.rs @@ -6,7 +6,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; use crate::utils::ffi::VecU8; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct WriteBuf(pub ironrdp_core::WriteBuf); impl WriteBuf { @@ -28,13 +28,13 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct SecurityProtocol(pub ironrdp::pdu::nego::SecurityProtocol); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ConnectInitial(pub ironrdp::pdu::mcs::ConnectInitial); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct InclusiveRectangle(pub ironrdp::pdu::geometry::InclusiveRectangle); impl InclusiveRectangle { @@ -63,10 +63,10 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct IronRdpPdu; // A struct representing the ironrdp_pdu crate - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct PduInfo(pub ironrdp::pdu::PduInfo); impl PduInfo { @@ -79,7 +79,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct Action(pub ironrdp::pdu::Action); impl IronRdpPdu { @@ -92,10 +92,10 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct FastPathInputEvent(pub ironrdp::pdu::input::fast_path::FastPathInputEvent); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct FastPathInputEventIterator(pub Vec); } diff --git a/ffi/src/rdcleanpath.rs b/ffi/src/rdcleanpath.rs index 2990336c9..7ff8792f8 100644 --- a/ffi/src/rdcleanpath.rs +++ b/ffi/src/rdcleanpath.rs @@ -3,13 +3,13 @@ pub mod ffi { use core::fmt::Write as _; use anyhow::Context as _; - use diplomat_runtime::DiplomatWriteable; + use diplomat_runtime::DiplomatWrite; use crate::error::GenericError; use crate::error::ffi::IronRdpError; use crate::utils::ffi::VecU8; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct RDCleanPathPdu(pub ironrdp_rdcleanpath::RDCleanPathPdu); impl RDCleanPathPdu { @@ -159,7 +159,7 @@ pub mod ffi { } /// Gets the server address string (for Response variant) - pub fn get_server_addr<'a>(&'a self, writeable: &'a mut DiplomatWriteable) { + pub fn get_server_addr<'a>(&'a self, writeable: &'a mut DiplomatWrite) { if self.0.server_addr.is_some() && self.0.server_cert_chain.is_some() && self.0.x224_connection_pdu.is_some() @@ -171,7 +171,7 @@ pub mod ffi { } /// Gets error message (for GeneralError variant) - pub fn get_error_message<'a>(&'a self, writeable: &'a mut DiplomatWriteable) { + pub fn get_error_message<'a>(&'a self, writeable: &'a mut DiplomatWrite) { if let Ok(err) = self.general_error() { let _ = write!(writeable, "{err}"); } @@ -207,7 +207,7 @@ pub mod ffi { } } - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, PartialEq, Eq)] pub enum RDCleanPathResultType { Request, Response, @@ -215,7 +215,7 @@ pub mod ffi { NegotiationError, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct RDCleanPathDetectionResult(pub ironrdp_rdcleanpath::DetectionResult); impl RDCleanPathDetectionResult { @@ -240,7 +240,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct CertificateChainIterator { certs: Vec>, index: usize, diff --git a/ffi/src/session/image.rs b/ffi/src/session/image.rs index c8654e52e..f0cc58a07 100644 --- a/ffi/src/session/image.rs +++ b/ffi/src/session/image.rs @@ -2,7 +2,7 @@ pub mod ffi { use crate::utils::ffi::BytesSlice; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct DecodedImage(pub ironrdp::session::image::DecodedImage); impl DecodedImage { @@ -15,7 +15,7 @@ pub mod ffi { } // The bytes array lives as long as the DecodedImage - pub fn get_data(&self) -> Box> { + pub fn get_data<'a>(&'a self) -> Box> { Box::new(BytesSlice(self.0.data())) } diff --git a/ffi/src/session/mod.rs b/ffi/src/session/mod.rs index 29659e9df..db8c0e518 100644 --- a/ffi/src/session/mod.rs +++ b/ffi/src/session/mod.rs @@ -13,16 +13,16 @@ pub mod ffi { use crate::pdu::ffi::{Action, FastPathInputEventIterator, InclusiveRectangle}; use crate::utils::ffi::{BytesSlice, Position, VecU8}; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ActiveStage( pub ironrdp::session::ActiveStage, pub ironrdp::connector::connection_activation::ConnectionActivationFactory, ); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ActiveStageOutput(pub ironrdp::session::ActiveStageOutput); - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct ActiveStageOutputIterator(pub Vec); impl ActiveStageOutputIterator { @@ -247,7 +247,7 @@ pub mod ffi { } } - pub fn get_response_frame(&self) -> Result>, Box> { + pub fn get_response_frame<'a>(&'a self) -> Result>, Box> { match &self.0 { ironrdp::session::ActiveStageOutput::ResponseFrame(frame) => Ok(Box::new(BytesSlice(frame))), _ => Err(IncorrectEnumTypeError::on_variant("ResponseFrame") @@ -364,6 +364,6 @@ pub mod ffi { pub requested_protocol: u16, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct GracefulDisconnectReason(pub ironrdp::session::GracefulDisconnectReason); } diff --git a/ffi/src/svc.rs b/ffi/src/svc.rs index 87e083bbd..670429741 100644 --- a/ffi/src/svc.rs +++ b/ffi/src/svc.rs @@ -1,6 +1,6 @@ #[diplomat::bridge] pub mod ffi { - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct StaticChannelSet<'a>(pub &'a ironrdp::svc::StaticChannelSet); } diff --git a/ffi/src/utils/mod.rs b/ffi/src/utils/mod.rs index 672c5653e..42cee7345 100644 --- a/ffi/src/utils/mod.rs +++ b/ffi/src/utils/mod.rs @@ -3,7 +3,7 @@ pub mod ffi { use crate::error::ffi::IronRdpError; - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct VecU8(pub Vec); impl VecU8 { @@ -28,7 +28,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct BytesSlice<'a>(pub &'a [u8]); impl<'a> BytesSlice<'a> { @@ -45,7 +45,7 @@ pub mod ffi { } } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct U32Slice<'a>(pub &'a [u32]); impl<'a> U32Slice<'a> { @@ -67,7 +67,7 @@ pub mod ffi { pub y: u16, } - #[diplomat::opaque] + #[diplomat::opaque_mut] pub struct OptionalUsize(pub Option); impl OptionalUsize { diff --git a/xtask/src/bin_version.rs b/xtask/src/bin_version.rs index 68e0353a2..8e44d550f 100644 --- a/xtask/src/bin_version.rs +++ b/xtask/src/bin_version.rs @@ -7,7 +7,6 @@ pub const CARGO_FUZZ: CargoPackage = CargoPackage::new("cargo-fuzz", "0.12.0"); pub const CARGO_HACK: CargoPackage = CargoPackage::new("cargo-hack", "0.6.44"); pub const WASM_PACK: CargoPackage = CargoPackage::new("wasm-pack", "0.13.1"); pub const TYPOS_CLI: CargoPackage = CargoPackage::new("typos-cli", "1.29.5").with_binary_name("typos"); -pub const DIPLOMAT_TOOL: CargoPackage = CargoPackage::new("diplomat-tool", "0.7.1"); pub const WABT_VERSION: &str = "1.0.36"; pub const NIGHTLY_TOOLCHAIN: &str = "nightly-2026-03-05"; diff --git a/xtask/src/ffi.rs b/xtask/src/ffi.rs index b8e40e7be..9fb9e7530 100644 --- a/xtask/src/ffi.rs +++ b/xtask/src/ffi.rs @@ -26,10 +26,49 @@ const DOTNET_NATIVE_LIB_PATH: &str = "dependencies/runtimes/linux-x64/native/"; #[cfg(target_os = "macos")] const DOTNET_NATIVE_LIB_PATH: &str = "dependencies/runtimes/osx-x64/native/"; +const DIPLOMAT_GIT_URL: &str = "https://github.com/irvingoujAtDevolution/diplomat.git"; +// Keep in sync with the `diplomat` / `diplomat-runtime` rev pinned in ffi/Cargo.toml — +// `diplomat-tool` is the codegen half of the same monorepo and must match the +// runtime crates commit-for-commit, or generated bindings drift from what the +// runtime types actually support. +const DIPLOMAT_REV: &str = "822b0b3effd892ca5babae7c1872d8c6be0685de"; + pub(crate) fn install(sh: &Shell) -> anyhow::Result<()> { let _s = Section::new("FFI-INSTALL"); - cargo_install(sh, &DIPLOMAT_TOOL)?; + install_diplomat_tool(sh)?; + + Ok(()) +} + +fn install_diplomat_tool(sh: &Shell) -> anyhow::Result<()> { + if is_installed(sh, "diplomat-tool") { + trace!("Refresh diplomat-tool from {DIPLOMAT_GIT_URL}@{DIPLOMAT_REV}"); + } else { + trace!("Install diplomat-tool from {DIPLOMAT_GIT_URL}@{DIPLOMAT_REV}"); + } + + // This pinned commit's `diplomat_core` `hir` feature uses `if let` guards, + // which our workspace's pinned 1.89.0 toolchain (rust-toolchain.toml) doesn't + // support. `diplomat-tool` is a standalone dev-time codegen binary, not linked + // into `ffi`, so it doesn't need to match that pin — build it with `rustup`'s + // default stable toolchain instead of the directory-overridden one. + sh.cmd("rustup") + .arg("run") + .arg("stable") + .arg("cargo") + .arg("install") + .arg("--debug") + .arg("--locked") + .arg("--force") + .arg("--root") + .arg(crate::LOCAL_CARGO_ROOT) + .arg("--git") + .arg(DIPLOMAT_GIT_URL) + .arg("--rev") + .arg(DIPLOMAT_REV) + .arg("diplomat-tool") + .run()?; Ok(()) } @@ -79,7 +118,11 @@ pub(crate) fn build_dynamic_lib(sh: &Shell, release: bool) -> anyhow::Result<()> pub(crate) fn build_bindings(sh: &Shell, skip_dotnet_build: bool) -> anyhow::Result<()> { let _s = Section::new("BUILD-BINDINGS"); - if !is_installed(sh, "diplomat-tool") { + let root_dir = sh.current_dir(); + let local_diplomat_tool = root_dir.join("..").join("diplomat").join("tool").join("Cargo.toml"); + let use_local_diplomat_tool = local_diplomat_tool.exists(); + + if !use_local_diplomat_tool && !is_installed(sh, "diplomat-tool") { anyhow::bail!("`diplomat-tool` binary is missing. Please run `cargo xtask ffi install`."); } @@ -95,12 +138,32 @@ pub(crate) fn build_bindings(sh: &Shell, skip_dotnet_build: bool) -> anyhow::Res } remove_cs_files(&generated_code_dir)?; - sh.cmd("diplomat-tool") - .arg("dotnet") - .arg(dotnet_generated_path) - .arg("-l") - .arg(diplomat_config) - .run()?; + if use_local_diplomat_tool { + // Same toolchain mismatch as `install_diplomat_tool`: the pinned commit's + // `diplomat_core` `hir` feature needs a newer Rust than our workspace's + // 1.89.0 pin (rust-toolchain.toml), which would otherwise apply here since + // cwd is inside the IronRDP tree. + sh.cmd("rustup") + .arg("run") + .arg("stable") + .arg("cargo") + .arg("run") + .arg("--manifest-path") + .arg(local_diplomat_tool) + .arg("--") + .arg("dotnet") + .arg(dotnet_generated_path) + .arg("-c") + .arg(diplomat_config) + .run()?; + } else { + sh.cmd("diplomat-tool") + .arg("dotnet") + .arg(dotnet_generated_path) + .arg("-c") + .arg(diplomat_config) + .run()?; + } if skip_dotnet_build { return Ok(());