feat(ffi): screenshot example using C# bindings (#437)

This commit is contained in:
irvingouj @ Devolutions
2024-04-09 10:13:12 -04:00
committed by GitHub
parent 9ce4986668
commit ef2055235a
93 changed files with 4637 additions and 320 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ doctest = false
[dependencies]
diplomat = "0.7.0"
diplomat-runtime = "0.7.0"
ironrdp = { workspace = true, features = ["connector", "dvc", "svc","rdpdr","rdpsnd"] }
ironrdp = { workspace = true, features = ["connector", "dvc", "svc","rdpdr","rdpsnd","graphics","input"] }
sspi = { workspace = true, features = ["network_client"] }
thiserror.workspace = true
@@ -1,3 +1,4 @@
obj
bin
.vs
.vs
output.bmp
@@ -10,5 +10,9 @@
<ItemGroup>
<ProjectReference Include="../Devolutions.IronRdp/Devolutions.IronRdp.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Drawing.Common" Version="8.0.3" />
</ItemGroup>
</Project>
@@ -1,6 +1,5 @@
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Drawing;
using System.Drawing.Imaging;
namespace Devolutions.IronRdp.ConnectExample
{
@@ -10,9 +9,9 @@ namespace Devolutions.IronRdp.ConnectExample
{
var arguments = ParseArguments(args);
if (arguments == null)
if (arguments == null)
{
return;
return;
}
var serverName = arguments["--serverName"];
@@ -21,15 +20,95 @@ namespace Devolutions.IronRdp.ConnectExample
var domain = arguments["--domain"];
try
{
await Connect(serverName, username, password, domain);
var (res, framed) = await Connection.Connect(buildConfig(serverName, username, password, domain, 1980, 1080), serverName);
var decodedImage = DecodedImage.New(PixelFormat.RgbA32, res.GetDesktopSize().GetWidth(), res.GetDesktopSize().GetHeight());
var activeState = ActiveStage.New(res);
var keepLooping = true;
while (keepLooping)
{
var readPduTask = framed.ReadPdu();
Action? action = null;
byte[]? payload = null;
if (readPduTask == await Task.WhenAny(readPduTask, Task.Delay(1000)))
{
var pduReadTask = await readPduTask;
action = pduReadTask.Item1;
payload = pduReadTask.Item2;
Console.WriteLine($"Action: {action}");
}
else
{
Console.WriteLine("Timeout");
break;
}
var outputIterator = activeState.Process(decodedImage, action, payload);
while (!outputIterator.IsEmpty())
{
var output = outputIterator.Next()!; // outputIterator.Next() is not null since outputIterator.IsEmpty() is false
Console.WriteLine($"Output type: {output.GetType()}");
if (output.GetType() == ActiveStageOutputType.Terminate)
{
Console.WriteLine("Connection terminated.");
keepLooping = false;
}
if (output.GetType() == ActiveStageOutputType.ResponseFrame)
{
var responseFrame = output.GetResponseFrame()!;
byte[] responseFrameBytes = new byte[responseFrame.GetSize()];
responseFrame.Fill(responseFrameBytes);
await framed.Write(responseFrameBytes);
}
}
}
saveImage(decodedImage, "output.png");
}
catch (Exception e)
catch (Exception e)
{
Console.WriteLine($"An error occurred: {e.Message}");
}
}
static Dictionary<string, string> ParseArguments(string[] args)
private static void saveImage(DecodedImage decodedImage, string v)
{
int width = decodedImage.GetWidth();
int height = decodedImage.GetHeight();
var data = decodedImage.GetData();
var bytes = new byte[data.GetSize()];
data.Fill(bytes);
for (int i = 0; i < bytes.Length; i += 4)
{
byte temp = bytes[i]; // Store the original Blue value
bytes[i] = bytes[i + 2]; // Move Red to Blue's position
bytes[i + 2] = temp; // Move original Blue to Red's position
// Green (bytes[i+1]) and Alpha (bytes[i+3]) remain unchanged
}
#if WINDOWS // Bitmap is only available on Windows
using (var bmp = new Bitmap(width, height))
{
// Lock the bits of the bitmap.
var bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Copy the RGBA values back to the bitmap
System.Runtime.InteropServices.Marshal.Copy(bytes, 0, ptr, bytes.Length);
// Unlock the bits.
bmp.UnlockBits(bmpData);
// Save the bitmap to the specified output path
bmp.Save("./output.bmp", ImageFormat.Bmp);
}
#endif
}
static Dictionary<string, string>? ParseArguments(string[] args)
{
if (args.Length == 0 || Array.Exists(args, arg => arg == "--help"))
{
@@ -38,7 +117,7 @@ namespace Devolutions.IronRdp.ConnectExample
}
var arguments = new Dictionary<string, string>();
string lastKey = null;
string? lastKey = null;
foreach (var arg in args)
{
if (arg.StartsWith("--"))
@@ -97,64 +176,15 @@ namespace Devolutions.IronRdp.ConnectExample
Console.WriteLine(" --help Show this message and exit.");
}
static async Task Connect(String servername, String username, String password, String domain)
{
Config config = buildConfig(servername, username, password, domain);
var stream = await CreateTcpConnection(servername, 3389);
var framed = new Framed<NetworkStream>(stream);
ClientConnector connector = ClientConnector.New(config);
var ip = await Dns.GetHostAddressesAsync(servername);
if (ip.Length == 0)
{
throw new Exception("Could not resolve server address");
}
var socketAddrString = ip[0].ToString()+":3389";
connector.WithServerAddr(socketAddrString);
await connectBegin(framed, connector);
var (serverPublicKey, framedSsl) = await securityUpgrade(servername, framed, connector);
await ConnectFinalize(servername, connector, serverPublicKey, framedSsl);
}
private static async Task<(byte[], Framed<SslStream>)> securityUpgrade(string servername, Framed<NetworkStream> framed, ClientConnector connector)
{
byte[] serverPublicKey;
Framed<SslStream> framedSsl;
var (streamRequireUpgrade, _) = framed.GetInner();
var promise = new TaskCompletionSource<byte[]>();
var sslStream = new SslStream(streamRequireUpgrade, false, (sender, certificate, chain, sslPolicyErrors) =>
{
promise.SetResult(certificate!.GetPublicKey());
return true;
});
await sslStream.AuthenticateAsClientAsync(servername);
serverPublicKey = await promise.Task;
framedSsl = new Framed<SslStream>(sslStream);
connector.MarkSecurityUpgradeAsDone();
return (serverPublicKey, framedSsl);
}
private static async Task connectBegin(Framed<NetworkStream> framed, ClientConnector connector)
{
var writeBuf = WriteBuf.New();
while (!connector.ShouldPerformSecurityUpgrade())
{
await SingleConnectStep(connector, writeBuf, framed);
}
}
private static Config buildConfig(string servername, string username, string password, string domain)
private static Config buildConfig(string servername, string username, string password, string domain, int width, int height)
{
ConfigBuilder configBuilder = ConfigBuilder.New();
configBuilder.WithUsernameAndPasswrord(username, password);
configBuilder.WithUsernameAndPassword(username, password);
configBuilder.SetDomain(domain);
configBuilder.SetDesktopSize(800, 600);
configBuilder.SetDesktopSize((ushort)height, (ushort)width);
configBuilder.SetClientName("IronRdp");
configBuilder.SetClientDir("C:\\");
configBuilder.SetPerformanceFlags(PerformanceFlags.NewDefault());
@@ -162,157 +192,5 @@ namespace Devolutions.IronRdp.ConnectExample
return configBuilder.Build();
}
private static async Task ConnectFinalize(string servername, ClientConnector connector, byte[] serverpubkey, Framed<SslStream> framedSsl)
{
var writeBuf2 = WriteBuf.New();
if (connector.ShouldPerformCredssp())
{
await PerformCredsspSteps(connector, servername, writeBuf2, framedSsl, serverpubkey);
}
while (!connector.State().IsTerminal())
{
await SingleConnectStep(connector, writeBuf2, framedSsl);
}
}
private static async Task PerformCredsspSteps(ClientConnector connector, string serverName, WriteBuf writeBuf, Framed<SslStream> framedSsl, byte[] serverpubkey)
{
var credsspSequenceInitResult = CredsspSequence.Init(connector, serverName, serverpubkey, null);
var credsspSequence = credsspSequenceInitResult.GetCredsspSequence();
var tsRequest = credsspSequenceInitResult.GetTsRequest();
TcpClient tcpClient = new TcpClient();
while (true)
{
var generator = credsspSequence.ProcessTsRequest(tsRequest);
var clientState = await ResolveGenerator(generator, tcpClient);
writeBuf.Clear();
var written = credsspSequence.HandleProcessResult(clientState, writeBuf);
if (written.GetSize().IsSome())
{
var actualSize = (int)written.GetSize().Get();
var response = new byte[actualSize];
writeBuf.ReadIntoBuf(response);
await framedSsl.Write(response);
}
var pduHint = credsspSequence.NextPduHint()!;
if (pduHint == null)
{
break;
}
var pdu = await framedSsl.ReadByHint(pduHint);
var decoded = credsspSequence.DecodeServerMessage(pdu);
if (null == decoded)
{
break;
}
tsRequest = decoded;
}
}
private static async Task<ClientState> ResolveGenerator(CredsspProcessGenerator generator, TcpClient tcpClient)
{
var state = generator.Start();
NetworkStream stream = null;
while (true)
{
if (state.IsSuspended())
{
var request = state.GetNetworkRequestIfSuspended()!;
var protocol = request.GetProtocol();
var url = request.GetUrl();
var data = request.GetData();
if (null == stream)
{
url = url.Replace("tcp://", "");
var split = url.Split(":");
await tcpClient.ConnectAsync(split[0], int.Parse(split[1]));
stream = tcpClient.GetStream();
}
if (protocol == NetworkRequestProtocol.Tcp)
{
stream.Write(Utils.Vecu8ToByte(data));
var readBuf = new byte[8096];
var readlen = await stream.ReadAsync(readBuf, 0, readBuf.Length);
var actuallyRead = new byte[readlen];
Array.Copy(readBuf, actuallyRead, readlen);
state = generator.Resume(actuallyRead);
}
else
{
throw new Exception("Unimplemented protocol");
}
}
else
{
var client_state = state.GetClientStateIfCompleted();
return client_state;
}
}
}
static async Task SingleConnectStep<T>(ClientConnector connector, WriteBuf buf, Framed<T> framed)
where T : Stream
{
buf.Clear();
var pduHint = connector.NextPduHint();
Written written;
if (pduHint != null)
{
byte[] pdu = await framed.ReadByHint(pduHint);
written = connector.Step(pdu, buf);
}
else
{
written = connector.StepNoInput(buf);
}
if (written.GetWrittenType() == WrittenType.Nothing)
{
return;
}
// will throw if size is not set
var size = written.GetSize().Get();
var response = new byte[size];
buf.ReadIntoBuf(response);
await framed.Write(response);
}
static async Task<NetworkStream> CreateTcpConnection(String servername, int port)
{
IPHostEntry ipHostInfo = await Dns.GetHostEntryAsync(servername);
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint ipEndPoint = new(ipAddress, port);
TcpClient client = new TcpClient();
await client.ConnectAsync(ipEndPoint);
NetworkStream stream = client.GetStream();
return stream;
}
}
public static class Utils
{
public static byte[] Vecu8ToByte(VecU8 vecU8)
{
var len = vecU8.GetSize();
byte[] buffer = new byte[len];
vecU8.Fill(buffer);
return buffer;
}
}
}
}
@@ -0,0 +1,63 @@
// <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;
/// <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).
/// <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)
{
_inner = handle;
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.Action* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.Action.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~Action()
{
Dispose();
}
}
@@ -0,0 +1,125 @@
// <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 ActiveStage: IDisposable
{
private unsafe Raw.ActiveStage* _inner;
/// <summary>
/// Creates a managed <c>ActiveStage</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).
/// <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 ActiveStage(Raw.ActiveStage* handle)
{
_inner = handle;
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ActiveStage</c> allocated on Rust side.
/// </returns>
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)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ActiveStage* retVal = result.Ok;
return new ActiveStage(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ActiveStageOutputIterator</c> allocated on Rust side.
/// </returns>
public ActiveStageOutputIterator Process(DecodedImage image, Action action, byte[] payload)
{
unsafe
{
if (_inner == null)
{
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");
}
fixed (byte* payloadPtr = payload)
{
Raw.SessionFfiResultBoxActiveStageOutputIteratorBoxIronRdpError result = Raw.ActiveStage.Process(_inner, imageRaw, actionRaw, payloadPtr, payloadLength);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ActiveStageOutputIterator* retVal = result.Ok;
return new ActiveStageOutputIterator(retVal);
}
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ActiveStage* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ActiveStage.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ActiveStage()
{
Dispose();
}
}
@@ -0,0 +1,267 @@
// <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 ActiveStageOutput: IDisposable
{
private unsafe Raw.ActiveStageOutput* _inner;
public ConnectionActivationSequence DeactivateAll
{
get
{
return GetDeactivateAll();
}
}
public InclusiveRectangle GraphicsUpdate
{
get
{
return GetGraphicsUpdate();
}
}
public DecodedPointer PointerBitmap
{
get
{
return GetPointerBitmap();
}
}
public Position PointerPosition
{
get
{
return GetPointerPosition();
}
}
public BytesSlice ResponseFrame
{
get
{
return GetResponseFrame();
}
}
public GracefulDisconnectReason Terminate
{
get
{
return GetTerminate();
}
}
public ActiveStageOutputType Type
{
get
{
return GetType();
}
}
/// <summary>
/// Creates a managed <c>ActiveStageOutput</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).
/// <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 ActiveStageOutput(Raw.ActiveStageOutput* handle)
{
_inner = handle;
}
/// <returns>
/// A <c>ActiveStageOutputType</c> allocated on C# side.
/// </returns>
public ActiveStageOutputType GetType()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.ActiveStageOutputType retVal = Raw.ActiveStageOutput.GetType(_inner);
return (ActiveStageOutputType)retVal;
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>BytesSlice</c> allocated on Rust side.
/// </returns>
public BytesSlice GetResponseFrame()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultBoxBytesSliceBoxIronRdpError result = Raw.ActiveStageOutput.GetResponseFrame(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.BytesSlice* retVal = result.Ok;
return new BytesSlice(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>InclusiveRectangle</c> allocated on Rust side.
/// </returns>
public InclusiveRectangle GetGraphicsUpdate()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultBoxInclusiveRectangleBoxIronRdpError result = Raw.ActiveStageOutput.GetGraphicsUpdate(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.InclusiveRectangle* retVal = result.Ok;
return new InclusiveRectangle(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>Position</c> allocated on C# side.
/// </returns>
public Position GetPointerPosition()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultPositionBoxIronRdpError result = Raw.ActiveStageOutput.GetPointerPosition(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.Position retVal = result.Ok;
return new Position(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>DecodedPointer</c> allocated on Rust side.
/// </returns>
public DecodedPointer GetPointerBitmap()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultBoxDecodedPointerBoxIronRdpError result = Raw.ActiveStageOutput.GetPointerBitmap(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.DecodedPointer* retVal = result.Ok;
return new DecodedPointer(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>GracefulDisconnectReason</c> allocated on Rust side.
/// </returns>
public GracefulDisconnectReason GetTerminate()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultBoxGracefulDisconnectReasonBoxIronRdpError result = Raw.ActiveStageOutput.GetTerminate(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.GracefulDisconnectReason* retVal = result.Ok;
return new GracefulDisconnectReason(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ConnectionActivationSequence</c> allocated on Rust side.
/// </returns>
public ConnectionActivationSequence GetDeactivateAll()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutput");
}
Raw.SessionFfiResultBoxConnectionActivationSequenceBoxIronRdpError result = Raw.ActiveStageOutput.GetDeactivateAll(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ConnectionActivationSequence* retVal = result.Ok;
return new ConnectionActivationSequence(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ActiveStageOutput* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ActiveStageOutput.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ActiveStageOutput()
{
Dispose();
}
}
@@ -0,0 +1,109 @@
// <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 ActiveStageOutputIterator: IDisposable
{
private unsafe Raw.ActiveStageOutputIterator* _inner;
/// <summary>
/// Creates a managed <c>ActiveStageOutputIterator</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).
/// <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 ActiveStageOutputIterator(Raw.ActiveStageOutputIterator* handle)
{
_inner = handle;
}
public nuint Len()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutputIterator");
}
nuint retVal = Raw.ActiveStageOutputIterator.Len(_inner);
return retVal;
}
}
public bool IsEmpty()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutputIterator");
}
bool retVal = Raw.ActiveStageOutputIterator.IsEmpty(_inner);
return retVal;
}
}
/// <returns>
/// A <c>ActiveStageOutput</c> allocated on Rust side.
/// </returns>
public ActiveStageOutput? Next()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ActiveStageOutputIterator");
}
Raw.ActiveStageOutput* retVal = Raw.ActiveStageOutputIterator.Next(_inner);
if (retVal == null)
{
return null;
}
return new ActiveStageOutput(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ActiveStageOutputIterator* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ActiveStageOutputIterator.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ActiveStageOutputIterator()
{
Dispose();
}
}
@@ -0,0 +1,24 @@
// <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 enum ActiveStageOutputType
{
ResponseFrame = 0,
GraphicsUpdate = 1,
PointerDefault = 2,
PointerHidden = 3,
PointerPosition = 4,
PointerBitmap = 5,
Terminate = 6,
DeactivateAll = 7,
}
@@ -0,0 +1,105 @@
// <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 BytesSlice: IDisposable
{
private unsafe Raw.BytesSlice* _inner;
public nuint Size
{
get
{
return GetSize();
}
}
/// <summary>
/// Creates a managed <c>BytesSlice</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).
/// <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 BytesSlice(Raw.BytesSlice* handle)
{
_inner = handle;
}
public nuint GetSize()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("BytesSlice");
}
nuint retVal = Raw.BytesSlice.GetSize(_inner);
return retVal;
}
}
/// <exception cref="IronRdpException"></exception>
public void Fill(byte[] buffer)
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("BytesSlice");
}
nuint bufferLength = (nuint)buffer.Length;
fixed (byte* bufferPtr = buffer)
{
Raw.UtilsFfiResultVoidBoxIronRdpError result = Raw.BytesSlice.Fill(_inner, bufferPtr, bufferLength);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
}
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.BytesSlice* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.BytesSlice.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~BytesSlice()
{
Dispose();
}
}
@@ -0,0 +1,63 @@
// <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 ChannelConnectionSequence: IDisposable
{
private unsafe Raw.ChannelConnectionSequence* _inner;
/// <summary>
/// Creates a managed <c>ChannelConnectionSequence</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).
/// <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 ChannelConnectionSequence(Raw.ChannelConnectionSequence* handle)
{
_inner = handle;
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ChannelConnectionSequence* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ChannelConnectionSequence.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ChannelConnectionSequence()
{
Dispose();
}
}
@@ -15,6 +15,14 @@ public partial class ClientConnector: IDisposable
{
private unsafe Raw.ClientConnector* _inner;
public DynState DynState
{
get
{
return GetDynState();
}
}
/// <summary>
/// Creates a managed <c>ClientConnector</c> from a raw handle.
/// </summary>
@@ -277,9 +285,9 @@ public partial class ClientConnector: IDisposable
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>State</c> allocated on Rust side.
/// A <c>DynState</c> allocated on Rust side.
/// </returns>
public State State()
public DynState GetDynState()
{
unsafe
{
@@ -287,13 +295,35 @@ public partial class ClientConnector: IDisposable
{
throw new ObjectDisposedException("ClientConnector");
}
Raw.ConnectorFfiResultBoxStateBoxIronRdpError result = Raw.ClientConnector.State(_inner);
Raw.ConnectorFfiResultBoxDynStateBoxIronRdpError result = Raw.ClientConnector.GetDynState(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.State* retVal = result.Ok;
return new State(retVal);
Raw.DynState* retVal = result.Ok;
return new DynState(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ClientConnectorState</c> allocated on Rust side.
/// </returns>
public ClientConnectorState ConsumeAndCastToClientConnectorState()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnector");
}
Raw.ConnectorFfiResultBoxClientConnectorStateBoxIronRdpError result = Raw.ClientConnector.ConsumeAndCastToClientConnectorState(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ClientConnectorState* retVal = result.Ok;
return new ClientConnectorState(retVal);
}
}
@@ -15,6 +15,62 @@ public partial class ClientConnectorState: IDisposable
{
private unsafe Raw.ClientConnectorState* _inner;
public SecurityProtocol BasicSettingsExchangeSendInitialSelectedProtocol
{
get
{
return GetBasicSettingsExchangeSendInitialSelectedProtocol();
}
}
public ConnectInitial BasicSettingsExchangeWaitResponseConnectInitial
{
get
{
return GetBasicSettingsExchangeWaitResponseConnectInitial();
}
}
public ConnectionResult ConnectedResult
{
get
{
return GetConnectedResult();
}
}
public SecurityProtocol ConnectionInitiationWaitConfirmRequestedProtocol
{
get
{
return GetConnectionInitiationWaitConfirmRequestedProtocol();
}
}
public SecurityProtocol CredsspSelectedProtocol
{
get
{
return GetCredsspSelectedProtocol();
}
}
public SecurityProtocol EnhancedSecurityUpgradeSelectedProtocol
{
get
{
return GetEnhancedSecurityUpgradeSelectedProtocol();
}
}
public ClientConnectorStateType Type
{
get
{
return GetType();
}
}
/// <summary>
/// Creates a managed <c>ClientConnectorState</c> from a raw handle.
/// </summary>
@@ -29,6 +85,160 @@ public partial class ClientConnectorState: IDisposable
_inner = handle;
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ClientConnectorStateType</c> allocated on C# side.
/// </returns>
public ClientConnectorStateType GetType()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultClientConnectorStateTypeBoxIronRdpError result = Raw.ClientConnectorState.GetType(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ClientConnectorStateType retVal = result.Ok;
return (ClientConnectorStateType)retVal;
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>SecurityProtocol</c> allocated on Rust side.
/// </returns>
public SecurityProtocol GetConnectionInitiationWaitConfirmRequestedProtocol()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetConnectionInitiationWaitConfirmRequestedProtocol(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.SecurityProtocol* retVal = result.Ok;
return new SecurityProtocol(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>SecurityProtocol</c> allocated on Rust side.
/// </returns>
public SecurityProtocol GetEnhancedSecurityUpgradeSelectedProtocol()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetEnhancedSecurityUpgradeSelectedProtocol(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.SecurityProtocol* retVal = result.Ok;
return new SecurityProtocol(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>SecurityProtocol</c> allocated on Rust side.
/// </returns>
public SecurityProtocol GetCredsspSelectedProtocol()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetCredsspSelectedProtocol(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.SecurityProtocol* retVal = result.Ok;
return new SecurityProtocol(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>SecurityProtocol</c> allocated on Rust side.
/// </returns>
public SecurityProtocol GetBasicSettingsExchangeSendInitialSelectedProtocol()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxSecurityProtocolBoxIronRdpError result = Raw.ClientConnectorState.GetBasicSettingsExchangeSendInitialSelectedProtocol(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.SecurityProtocol* retVal = result.Ok;
return new SecurityProtocol(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ConnectInitial</c> allocated on Rust side.
/// </returns>
public ConnectInitial GetBasicSettingsExchangeWaitResponseConnectInitial()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxConnectInitialBoxIronRdpError result = Raw.ClientConnectorState.GetBasicSettingsExchangeWaitResponseConnectInitial(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ConnectInitial* retVal = result.Ok;
return new ConnectInitial(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>ConnectionResult</c> allocated on Rust side.
/// </returns>
public ConnectionResult GetConnectedResult()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ClientConnectorState");
}
Raw.ConnectorStateFfiResultBoxConnectionResultBoxIronRdpError result = Raw.ClientConnectorState.GetConnectedResult(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.ConnectionResult* retVal = result.Ok;
return new ConnectionResult(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
@@ -0,0 +1,31 @@
// <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 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,
}
@@ -161,7 +161,7 @@ public partial class ConfigBuilder: IDisposable
}
}
public void WithUsernameAndPasswrord(string username, string password)
public void WithUsernameAndPassword(string username, string password)
{
unsafe
{
@@ -177,7 +177,7 @@ public partial class ConfigBuilder: IDisposable
{
fixed (byte* passwordBufPtr = passwordBuf)
{
Raw.ConfigBuilder.WithUsernameAndPasswrord(_inner, usernameBufPtr, usernameBufLength, passwordBufPtr, passwordBufLength);
Raw.ConfigBuilder.WithUsernameAndPassword(_inner, usernameBufPtr, usernameBufLength, passwordBufPtr, passwordBufLength);
}
}
}
@@ -0,0 +1,63 @@
// <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 ConnectInitial: IDisposable
{
private unsafe Raw.ConnectInitial* _inner;
/// <summary>
/// Creates a managed <c>ConnectInitial</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).
/// <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 ConnectInitial(Raw.ConnectInitial* handle)
{
_inner = handle;
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ConnectInitial* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ConnectInitial.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ConnectInitial()
{
Dispose();
}
}
@@ -0,0 +1,63 @@
// <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 ConnectionActivationSequence: IDisposable
{
private unsafe Raw.ConnectionActivationSequence* _inner;
/// <summary>
/// Creates a managed <c>ConnectionActivationSequence</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).
/// <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 ConnectionActivationSequence(Raw.ConnectionActivationSequence* handle)
{
_inner = handle;
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.ConnectionActivationSequence* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.ConnectionActivationSequence.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~ConnectionActivationSequence()
{
Dispose();
}
}
@@ -47,14 +47,6 @@ public partial class ConnectionResult: IDisposable
}
}
public StaticChannelSet StaticChannels
{
get
{
return GetStaticChannels();
}
}
public ushort UserChannelId
{
get
@@ -77,6 +69,7 @@ public partial class ConnectionResult: IDisposable
_inner = handle;
}
/// <exception cref="IronRdpException"></exception>
public ushort GetIoChannelId()
{
unsafe
@@ -85,11 +78,17 @@ public partial class ConnectionResult: IDisposable
{
throw new ObjectDisposedException("ConnectionResult");
}
ushort retVal = Raw.ConnectionResult.GetIoChannelId(_inner);
Raw.ConnectorResultFfiResultU16BoxIronRdpError result = Raw.ConnectionResult.GetIoChannelId(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
ushort retVal = result.Ok;
return retVal;
}
}
/// <exception cref="IronRdpException"></exception>
public ushort GetUserChannelId()
{
unsafe
@@ -98,27 +97,17 @@ public partial class ConnectionResult: IDisposable
{
throw new ObjectDisposedException("ConnectionResult");
}
ushort retVal = Raw.ConnectionResult.GetUserChannelId(_inner);
Raw.ConnectorResultFfiResultU16BoxIronRdpError result = Raw.ConnectionResult.GetUserChannelId(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
ushort retVal = result.Ok;
return retVal;
}
}
/// <returns>
/// A <c>StaticChannelSet</c> allocated on Rust side.
/// </returns>
public StaticChannelSet GetStaticChannels()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("ConnectionResult");
}
Raw.StaticChannelSet* retVal = Raw.ConnectionResult.GetStaticChannels(_inner);
return new StaticChannelSet(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
/// <returns>
/// A <c>DesktopSize</c> allocated on Rust side.
/// </returns>
@@ -130,11 +119,17 @@ public partial class ConnectionResult: IDisposable
{
throw new ObjectDisposedException("ConnectionResult");
}
Raw.DesktopSize* retVal = Raw.ConnectionResult.GetDesktopSize(_inner);
Raw.ConnectorResultFfiResultBoxDesktopSizeBoxIronRdpError result = Raw.ConnectionResult.GetDesktopSize(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
Raw.DesktopSize* retVal = result.Ok;
return new DesktopSize(retVal);
}
}
/// <exception cref="IronRdpException"></exception>
public bool GetNoServerPointer()
{
unsafe
@@ -143,11 +138,17 @@ public partial class ConnectionResult: IDisposable
{
throw new ObjectDisposedException("ConnectionResult");
}
bool retVal = Raw.ConnectionResult.GetNoServerPointer(_inner);
Raw.ConnectorResultFfiResultBoolBoxIronRdpError result = Raw.ConnectionResult.GetNoServerPointer(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
bool retVal = result.Ok;
return retVal;
}
}
/// <exception cref="IronRdpException"></exception>
public bool GetPointerSoftwareRendering()
{
unsafe
@@ -156,7 +157,12 @@ public partial class ConnectionResult: IDisposable
{
throw new ObjectDisposedException("ConnectionResult");
}
bool retVal = Raw.ConnectionResult.GetPointerSoftwareRendering(_inner);
Raw.ConnectorResultFfiResultBoolBoxIronRdpError result = Raw.ConnectionResult.GetPointerSoftwareRendering(_inner);
if (!result.isOk)
{
throw new IronRdpException(new IronRdpError(result.Err));
}
bool retVal = result.Ok;
return retVal;
}
}
@@ -0,0 +1,143 @@
// <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 DecodedImage: IDisposable
{
private unsafe Raw.DecodedImage* _inner;
public BytesSlice Data
{
get
{
return GetData();
}
}
public ushort Height
{
get
{
return GetHeight();
}
}
public ushort Width
{
get
{
return GetWidth();
}
}
/// <summary>
/// Creates a managed <c>DecodedImage</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).
/// <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 DecodedImage(Raw.DecodedImage* handle)
{
_inner = handle;
}
/// <returns>
/// A <c>DecodedImage</c> allocated on Rust side.
/// </returns>
public static DecodedImage New(PixelFormat pixelFormat, ushort width, ushort height)
{
unsafe
{
Raw.PixelFormat pixelFormatRaw;
pixelFormatRaw = (Raw.PixelFormat)pixelFormat;
Raw.DecodedImage* retVal = Raw.DecodedImage.New(pixelFormatRaw, width, height);
return new DecodedImage(retVal);
}
}
/// <returns>
/// A <c>BytesSlice</c> allocated on Rust side.
/// </returns>
public BytesSlice GetData()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedImage");
}
Raw.BytesSlice* retVal = Raw.DecodedImage.GetData(_inner);
return new BytesSlice(retVal);
}
}
public ushort GetWidth()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedImage");
}
ushort retVal = Raw.DecodedImage.GetWidth(_inner);
return retVal;
}
}
public ushort GetHeight()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedImage");
}
ushort retVal = Raw.DecodedImage.GetHeight(_inner);
return retVal;
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.DecodedImage* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.DecodedImage.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~DecodedImage()
{
Dispose();
}
}
@@ -0,0 +1,171 @@
// <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 DecodedPointer: IDisposable
{
private unsafe Raw.DecodedPointer* _inner;
public BytesSlice Data
{
get
{
return GetData();
}
}
public ushort Height
{
get
{
return GetHeight();
}
}
public ushort HotspotX
{
get
{
return GetHotspotX();
}
}
public ushort HotspotY
{
get
{
return GetHotspotY();
}
}
public ushort Width
{
get
{
return GetWidth();
}
}
/// <summary>
/// Creates a managed <c>DecodedPointer</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).
/// <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 DecodedPointer(Raw.DecodedPointer* handle)
{
_inner = handle;
}
public ushort GetWidth()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedPointer");
}
ushort retVal = Raw.DecodedPointer.GetWidth(_inner);
return retVal;
}
}
public ushort GetHeight()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedPointer");
}
ushort retVal = Raw.DecodedPointer.GetHeight(_inner);
return retVal;
}
}
public ushort GetHotspotX()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedPointer");
}
ushort retVal = Raw.DecodedPointer.GetHotspotX(_inner);
return retVal;
}
}
public ushort GetHotspotY()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedPointer");
}
ushort retVal = Raw.DecodedPointer.GetHotspotY(_inner);
return retVal;
}
}
/// <returns>
/// A <c>BytesSlice</c> allocated on Rust side.
/// </returns>
public BytesSlice GetData()
{
unsafe
{
if (_inner == null)
{
throw new ObjectDisposedException("DecodedPointer");
}
Raw.BytesSlice* retVal = Raw.DecodedPointer.GetData(_inner);
return new BytesSlice(retVal);
}
}
/// <summary>
/// Returns the underlying raw handle.
/// </summary>
public unsafe Raw.DecodedPointer* AsFFI()
{
return _inner;
}
/// <summary>
/// Destroys the underlying object immediately.
/// </summary>
public void Dispose()
{
unsafe
{
if (_inner == null)
{
return;
}
Raw.DecodedPointer.Destroy(_inner);
_inner = null;
GC.SuppressFinalize(this);
}
}
~DecodedPointer()
{
Dispose();
}
}

Some files were not shown because too many files have changed in this diff Show More