mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
174 lines
4.9 KiB
C#
174 lines
4.9 KiB
C#
// <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;
|
|
|
|
public ConnectionActivationState State
|
|
{
|
|
get
|
|
{
|
|
return GetState();
|
|
}
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
|
|
/// <returns>
|
|
/// A <c>ConnectionActivationState</c> allocated on Rust side.
|
|
/// </returns>
|
|
public ConnectionActivationState GetState()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ConnectionActivationSequence");
|
|
}
|
|
Raw.ConnectionActivationState* retVal = Raw.ConnectionActivationSequence.GetState(_inner);
|
|
return new ConnectionActivationState(retVal);
|
|
}
|
|
}
|
|
|
|
/// <exception cref="IronRdpException"></exception>
|
|
/// <returns>
|
|
/// A <c>PduHint</c> allocated on Rust side.
|
|
/// </returns>
|
|
public PduHint NextPduHint()
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ConnectionActivationSequence");
|
|
}
|
|
Raw.ConnectorActivationFfiResultOptBoxPduHintBoxIronRdpError result = Raw.ConnectionActivationSequence.NextPduHint(_inner);
|
|
if (!result.isOk)
|
|
{
|
|
throw new IronRdpException(new IronRdpError(result.Err));
|
|
}
|
|
Raw.PduHint* retVal = result.Ok;
|
|
if (retVal == null)
|
|
{
|
|
return null;
|
|
}
|
|
return new PduHint(retVal);
|
|
}
|
|
}
|
|
|
|
/// <exception cref="IronRdpException"></exception>
|
|
/// <returns>
|
|
/// A <c>Written</c> allocated on Rust side.
|
|
/// </returns>
|
|
public Written Step(byte[] pduHint, WriteBuf buf)
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
throw new ObjectDisposedException("ConnectionActivationSequence");
|
|
}
|
|
nuint pduHintLength = (nuint)pduHint.Length;
|
|
Raw.WriteBuf* bufRaw;
|
|
bufRaw = buf.AsFFI();
|
|
if (bufRaw == null)
|
|
{
|
|
throw new ObjectDisposedException("WriteBuf");
|
|
}
|
|
fixed (byte* pduHintPtr = pduHint)
|
|
{
|
|
Raw.ConnectorActivationFfiResultBoxWrittenBoxIronRdpError result = Raw.ConnectionActivationSequence.Step(_inner, pduHintPtr, pduHintLength, bufRaw);
|
|
if (!result.isOk)
|
|
{
|
|
throw new IronRdpException(new IronRdpError(result.Err));
|
|
}
|
|
Raw.Written* retVal = result.Ok;
|
|
return new Written(retVal);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <exception cref="IronRdpException"></exception>
|
|
/// <returns>
|
|
/// A <c>Written</c> allocated on Rust side.
|
|
/// </returns>
|
|
public Written StepNoInput(WriteBuf buf)
|
|
{
|
|
unsafe
|
|
{
|
|
if (_inner == null)
|
|
{
|
|
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)
|
|
{
|
|
throw new IronRdpException(new IronRdpError(result.Err));
|
|
}
|
|
Raw.Written* retVal = result.Ok;
|
|
return new Written(retVal);
|
|
}
|
|
}
|
|
|
|
/// <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();
|
|
}
|
|
}
|