Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 9 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 2 additions & 2 deletions ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 5 additions & 6 deletions ffi/dotnet-interop-conf.toml
Original file line number Diff line number Diff line change
@@ -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_"
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@

<ItemGroup Condition="'$([System.OperatingSystem]::IsWindows())'">
<PackageReference Include="Avalonia.Win32" Version="11.3.7" />
<Content Include="../../../dependencies/runtimes/win-x64/native/DevolutionsIronRdp.dll">
<Link>DevolutionsIronRdp.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
56 changes: 43 additions & 13 deletions ffi/dotnet/Devolutions.IronRdp/Generated/Action.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,69 @@
// <auto-generated/> 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 Action: IDisposable
{
private unsafe Raw.Action* _inner;
private unsafe RustHandle<Raw.Action> _inner;

/// <summary>
/// Roots the wrappers this value borrows from so the GC cannot finalize
/// a borrowed-from parent while this value is alive.
/// </summary>
private object[] _edges;

private static readonly unsafe RustDestructor<Raw.Action> _destroy = Raw.Action.Destroy;

/// <summary>
/// Creates a managed <c>Action</c> from a raw handle.
/// </summary>
/// <remarks>
/// 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).
/// <br/>
/// This constructor assumes the raw struct is allocated on Rust side.
/// If implemented, the custom Drop implementation on Rust side WILL run on destruction.
/// </remarks>
public unsafe Action(Raw.Action* handle)
internal unsafe Action(Raw.Action* handle)
{
_inner = RustHandle<Raw.Action>.Owned(handle, _destroy);
_edges = System.Array.Empty<object>();
}

/// <remarks>
/// Edges only keep the borrowed-from objects GC-reachable. Explicitly
/// <c>Dispose</c>-ing a parent while a borrowing child is in use is still a
/// use-after-free and remains the caller's responsibility.
/// </remarks>
internal unsafe Action(Raw.Action* handle, object[] edges)
{
_inner = RustHandle<Raw.Action>.Owned(handle, _destroy);
_edges = edges;
}

/// <summary>
/// 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.
/// </summary>
internal unsafe Action(RustHandle<Raw.Action> inner, object[] edges)
{
_inner = handle;
_inner = inner;
_edges = edges;
}

/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.Action* AsFFI()
internal unsafe Raw.Action* AsFFI()
{
return _inner;
return _inner.Ptr;
}

/// <summary>
Expand All @@ -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<object>(); // release refs so borrowed-from owners can be GC'd

GC.SuppressFinalize(this);
}
Expand All @@ -60,4 +90,4 @@ public void Dispose()
{
Dispose();
}
}
}
Loading
Loading