Decompiled source of DearImGuiInjection v1.0.0
BepInEx/plugins/DearImGuiInjection/System.Reflection.Emit.Lightweight.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using FxResources.System.Reflection.Emit.Lightweight; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyDefaultAlias("System.Reflection.Emit.Lightweight")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("NotSupported", "True")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Reflection.Emit.Lightweight")] [assembly: AssemblyFileVersion("4.700.19.56404")] [assembly: AssemblyInformationalVersion("3.1.0+0f7f38c4fd323b26da10cce95f857f77f0f09b48")] [assembly: AssemblyProduct("Microsoft® .NET Core")] [assembly: AssemblyTitle("System.Reflection.Emit.Lightweight")] [assembly: CLSCompliant(true)] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.0.0")] [module: UnverifiableCode] namespace FxResources.System.Reflection.Emit.Lightweight { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR))); internal static string PlatformNotSupported_RefEmitLightweight => GetResourceString("PlatformNotSupported_RefEmitLightweight"); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString = null) { if (UsingResourceKeys()) { return defaultString ?? resourceKey; } string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text)) { return defaultString; } return text; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(IFormatProvider provider, string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(provider, resourceFormat, p1); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(provider, resourceFormat, p1, p2); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(provider, resourceFormat, p1, p2, p3); } internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(provider, resourceFormat, args); } return resourceFormat; } } } namespace System.Reflection.Emit { public sealed class DynamicMethod : MethodInfo { public override MethodAttributes Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override CallingConventions CallingConvention { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public bool InitLocals { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } set { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override RuntimeMethodHandle MethodHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override ParameterInfo ReturnParameter { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override Type ReturnType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes, bool restrictedSkipVisibility) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Module m) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Module m, bool skipVisibility) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public DynamicMethod(string name, Type returnType, Type[] parameterTypes, Type owner, bool skipVisibility) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public sealed override Delegate CreateDelegate(Type delegateType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public sealed override Delegate CreateDelegate(Type delegateType, object target) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string parameterName) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override MethodInfo GetBaseDefinition() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public ILGenerator GetILGenerator() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public ILGenerator GetILGenerator(int streamSize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override MethodImplAttributes GetMethodImplementationFlags() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override ParameterInfo[] GetParameters() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitLightweight); } } }
BepInEx/plugins/DearImGuiInjection/System.Buffers.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Diagnostics.Tracing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Threading; using FxResources.System.Buffers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Buffers")] [assembly: AssemblyDescription("System.Buffers")] [assembly: AssemblyDefaultAlias("System.Buffers")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.25519.03")] [assembly: AssemblyInformationalVersion("4.6.25519.03 built by: dlab-DDVSOWINAGE013. Commit Hash: 8321c729934c0f8be754953439b88e6e1c120c24")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.2.0")] [module: UnverifiableCode] namespace FxResources.System.Buffers { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Buffers.SR"; private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType)); internal static string ArgumentException_BufferNotFromPool => GetResourceString("ArgumentException_BufferNotFromPool", null); internal static Type ResourceType => typeof(SR); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.All)] internal class __BlockReflectionAttribute : Attribute { } } namespace System.Buffers { public abstract class ArrayPool<T> { private static ArrayPool<T> s_sharedInstance; public static ArrayPool<T> Shared { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return Volatile.Read(ref s_sharedInstance) ?? EnsureSharedCreated(); } } [MethodImpl(MethodImplOptions.NoInlining)] private static ArrayPool<T> EnsureSharedCreated() { Interlocked.CompareExchange(ref s_sharedInstance, Create(), null); return s_sharedInstance; } public static ArrayPool<T> Create() { return new DefaultArrayPool<T>(); } public static ArrayPool<T> Create(int maxArrayLength, int maxArraysPerBucket) { return new DefaultArrayPool<T>(maxArrayLength, maxArraysPerBucket); } public abstract T[] Rent(int minimumLength); public abstract void Return(T[] array, bool clearArray = false); } [EventSource(Name = "System.Buffers.ArrayPoolEventSource")] internal sealed class ArrayPoolEventSource : EventSource { internal enum BufferAllocatedReason { Pooled, OverMaximumSize, PoolExhausted } internal static readonly System.Buffers.ArrayPoolEventSource Log = new System.Buffers.ArrayPoolEventSource(); [Event(1, Level = EventLevel.Verbose)] internal unsafe void BufferRented(int bufferId, int bufferSize, int poolId, int bucketId) { EventData* ptr = stackalloc EventData[4]; ptr->Size = 4; ptr->DataPointer = (IntPtr)(&bufferId); ptr[1].Size = 4; ptr[1].DataPointer = (IntPtr)(&bufferSize); ptr[2].Size = 4; ptr[2].DataPointer = (IntPtr)(&poolId); ptr[3].Size = 4; ptr[3].DataPointer = (IntPtr)(&bucketId); WriteEventCore(1, 4, ptr); } [Event(2, Level = EventLevel.Informational)] internal unsafe void BufferAllocated(int bufferId, int bufferSize, int poolId, int bucketId, BufferAllocatedReason reason) { EventData* ptr = stackalloc EventData[5]; ptr->Size = 4; ptr->DataPointer = (IntPtr)(&bufferId); ptr[1].Size = 4; ptr[1].DataPointer = (IntPtr)(&bufferSize); ptr[2].Size = 4; ptr[2].DataPointer = (IntPtr)(&poolId); ptr[3].Size = 4; ptr[3].DataPointer = (IntPtr)(&bucketId); ptr[4].Size = 4; ptr[4].DataPointer = (IntPtr)(&reason); WriteEventCore(2, 5, ptr); } [Event(3, Level = EventLevel.Verbose)] internal void BufferReturned(int bufferId, int bufferSize, int poolId) { WriteEvent(3, bufferId, bufferSize, poolId); } } internal sealed class DefaultArrayPool<T> : ArrayPool<T> { private sealed class Bucket { internal readonly int _bufferLength; private readonly T[][] _buffers; private readonly int _poolId; private SpinLock _lock; private int _index; internal int Id => GetHashCode(); internal Bucket(int bufferLength, int numberOfBuffers, int poolId) { _lock = new SpinLock(Debugger.IsAttached); _buffers = new T[numberOfBuffers][]; _bufferLength = bufferLength; _poolId = poolId; } internal T[] Rent() { T[][] buffers = _buffers; T[] array = null; bool lockTaken = false; bool flag = false; try { _lock.Enter(ref lockTaken); if (_index < buffers.Length) { array = buffers[_index]; buffers[_index++] = null; flag = array == null; } } finally { if (lockTaken) { _lock.Exit(useMemoryBarrier: false); } } if (flag) { array = new T[_bufferLength]; System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log; if (log.IsEnabled()) { log.BufferAllocated(array.GetHashCode(), _bufferLength, _poolId, Id, System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.Pooled); } } return array; } internal void Return(T[] array) { if (array.Length != _bufferLength) { throw new ArgumentException(System.SR.ArgumentException_BufferNotFromPool, "array"); } bool lockTaken = false; try { _lock.Enter(ref lockTaken); if (_index != 0) { _buffers[--_index] = array; } } finally { if (lockTaken) { _lock.Exit(useMemoryBarrier: false); } } } } private const int DefaultMaxArrayLength = 1048576; private const int DefaultMaxNumberOfArraysPerBucket = 50; private static T[] s_emptyArray; private readonly Bucket[] _buckets; private int Id => GetHashCode(); internal DefaultArrayPool() : this(1048576, 50) { } internal DefaultArrayPool(int maxArrayLength, int maxArraysPerBucket) { if (maxArrayLength <= 0) { throw new ArgumentOutOfRangeException("maxArrayLength"); } if (maxArraysPerBucket <= 0) { throw new ArgumentOutOfRangeException("maxArraysPerBucket"); } if (maxArrayLength > 1073741824) { maxArrayLength = 1073741824; } else if (maxArrayLength < 16) { maxArrayLength = 16; } int id = Id; int num = System.Buffers.Utilities.SelectBucketIndex(maxArrayLength); Bucket[] array = new Bucket[num + 1]; for (int i = 0; i < array.Length; i++) { array[i] = new Bucket(System.Buffers.Utilities.GetMaxSizeForBucket(i), maxArraysPerBucket, id); } _buckets = array; } public override T[] Rent(int minimumLength) { if (minimumLength < 0) { throw new ArgumentOutOfRangeException("minimumLength"); } if (minimumLength == 0) { return s_emptyArray ?? (s_emptyArray = new T[0]); } System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log; T[] array = null; int num = System.Buffers.Utilities.SelectBucketIndex(minimumLength); if (num < _buckets.Length) { int num2 = num; do { array = _buckets[num2].Rent(); if (array != null) { if (log.IsEnabled()) { log.BufferRented(array.GetHashCode(), array.Length, Id, _buckets[num2].Id); } return array; } } while (++num2 < _buckets.Length && num2 != num + 2); array = new T[_buckets[num]._bufferLength]; } else { array = new T[minimumLength]; } if (log.IsEnabled()) { int hashCode = array.GetHashCode(); int bucketId = -1; log.BufferRented(hashCode, array.Length, Id, bucketId); log.BufferAllocated(hashCode, array.Length, Id, bucketId, (num >= _buckets.Length) ? System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.OverMaximumSize : System.Buffers.ArrayPoolEventSource.BufferAllocatedReason.PoolExhausted); } return array; } public override void Return(T[] array, bool clearArray = false) { if (array == null) { throw new ArgumentNullException("array"); } if (array.Length == 0) { return; } int num = System.Buffers.Utilities.SelectBucketIndex(array.Length); if (num < _buckets.Length) { if (clearArray) { Array.Clear(array, 0, array.Length); } _buckets[num].Return(array); } System.Buffers.ArrayPoolEventSource log = System.Buffers.ArrayPoolEventSource.Log; if (log.IsEnabled()) { log.BufferReturned(array.GetHashCode(), array.Length, Id); } } } internal static class Utilities { [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int SelectBucketIndex(int bufferSize) { uint num = (uint)(bufferSize - 1) >> 4; int num2 = 0; if (num > 65535) { num >>= 16; num2 = 16; } if (num > 255) { num >>= 8; num2 += 8; } if (num > 15) { num >>= 4; num2 += 4; } if (num > 3) { num >>= 2; num2 += 2; } if (num > 1) { num >>= 1; num2++; } return num2 + (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static int GetMaxSizeForBucket(int binIndex) { return 16 << binIndex; } } }
BepInEx/plugins/DearImGuiInjection/Iced.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Iced.Intel.BlockEncoderInternal; using Iced.Intel.DecoderInternal; using Iced.Intel.EncoderInternal; using Iced.Intel.FastFormatterInternal; using Iced.Intel.FormatterInternal; using Iced.Intel.GasFormatterInternal; using Iced.Intel.InstructionInfoInternal; using Iced.Intel.IntelFormatterInternal; using Iced.Intel.Internal; using Iced.Intel.MasmFormatterInternal; using Iced.Intel.NasmFormatterInternal; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("iced project and contributors <https://github.com/icedland>")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (C) 2018-present iced project and contributors")] [assembly: AssemblyDescription("x86/x64 disassembler, assembler, instruction decoder")] [assembly: AssemblyFileVersion("1.17.0.0")] [assembly: AssemblyInformationalVersion("1.17.0+c7aa5116314e90d391a3350878f9fb99192aafb6")] [assembly: AssemblyProduct("Iced")] [assembly: AssemblyTitle("Iced")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/icedland/iced")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.17.0.0")] [module: UnverifiableCode] [module: System.Runtime.CompilerServices.NullablePublicOnly(false)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class NullablePublicOnlyAttribute : Attribute { public readonly bool IncludesInternals; public NullablePublicOnlyAttribute(bool P_0) { IncludesInternals = P_0; } } } namespace Iced.Intel { public class Assembler { [Flags] private enum PrefixFlags { None = 0, Lock = 1, Repe = 2, Repne = 4, Notrack = 8, PreferVex = 0x10, PreferEvex = 0x20 } private readonly InstructionList instructions; private ulong currentLabelId; private Label currentLabel; private Label currentAnonLabel; private Label nextAnonLabel; private bool definedAnonLabel; private PrefixFlags prefixFlags; public int Bitness { get; } public bool PreferVex { get; set; } public bool PreferShortBranch { get; set; } internal bool InstructionPreferVex { get { if ((prefixFlags & (PrefixFlags.PreferVex | PrefixFlags.PreferEvex)) != 0) { return (prefixFlags & PrefixFlags.PreferVex) != 0; } return PreferVex; } } public IReadOnlyList<Instruction> Instructions => instructions; public Label CurrentLabel => currentLabel; [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Label B { get { if (currentAnonLabel.IsEmpty) { throw new InvalidOperationException("No anonymous label has been created yet"); } return currentAnonLabel; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Label F { get { if (nextAnonLabel.IsEmpty) { nextAnonLabel = CreateLabel(); } return nextAnonLabel; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler @lock { get { prefixFlags |= PrefixFlags.Lock; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler xacquire { get { prefixFlags |= PrefixFlags.Repne; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler xrelease { get { prefixFlags |= PrefixFlags.Repe; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler rep { get { prefixFlags |= PrefixFlags.Repe; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler repe { get { prefixFlags |= PrefixFlags.Repe; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler repz => repe; [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler repne { get { prefixFlags |= PrefixFlags.Repne; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler repnz => repne; [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler bnd { get { prefixFlags |= PrefixFlags.Repne; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler notrack { get { prefixFlags |= PrefixFlags.Notrack; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler vex { get { prefixFlags |= PrefixFlags.PreferVex; return this; } } [DebuggerBrowsable(DebuggerBrowsableState.Never)] public Assembler evex { get { prefixFlags |= PrefixFlags.PreferEvex; return this; } } public Assembler(int bitness) { if (bitness != 16 && bitness != 32 && bitness != 64) { throw new ArgumentOutOfRangeException("bitness"); } Bitness = bitness; instructions = new InstructionList(); currentLabelId = 0uL; currentLabel = default(Label); currentAnonLabel = default(Label); nextAnonLabel = default(Label); definedAnonLabel = false; prefixFlags = PrefixFlags.None; PreferVex = true; PreferShortBranch = true; } public void Reset() { instructions.Clear(); currentLabelId = 0uL; currentLabel = default(Label); currentAnonLabel = default(Label); nextAnonLabel = default(Label); definedAnonLabel = false; prefixFlags = PrefixFlags.None; } public Label CreateLabel(string? name = null) { currentLabelId++; return new Label(name, currentLabelId); } public void Label(ref Label label) { if (label.IsEmpty) { throw new ArgumentException("Invalid label. Must be created via CreateLabel", "label"); } if (label.InstructionIndex >= 0) { throw new ArgumentException($"Cannot reuse label. The specified label is already associated with an instruction at index {label.InstructionIndex}.", "label"); } if (!currentLabel.IsEmpty) { throw new ArgumentException("At most one label per instruction is allowed"); } label.InstructionIndex = instructions.Count; currentLabel = label; } public void AnonymousLabel() { if (definedAnonLabel) { throw new InvalidOperationException("At most one anonymous label per instruction is allowed"); } if (nextAnonLabel.IsEmpty) { currentAnonLabel = CreateLabel(); } else { currentAnonLabel = nextAnonLabel; } nextAnonLabel = default(Label); definedAnonLabel = true; } public void AddInstruction(Instruction instruction) { AddInstruction(ref instruction); } public void AddInstruction(ref Instruction instruction) { if (!currentLabel.IsEmpty && definedAnonLabel) { throw new InvalidOperationException("You can't create both an anonymous label and a normal label"); } if (!currentLabel.IsEmpty) { instruction.IP = currentLabel.Id; } else if (definedAnonLabel) { instruction.IP = currentAnonLabel.Id; } if (prefixFlags != 0) { if ((prefixFlags & PrefixFlags.Lock) != 0) { instruction.HasLockPrefix = true; } if ((prefixFlags & PrefixFlags.Repe) != 0) { instruction.HasRepePrefix = true; } else if ((prefixFlags & PrefixFlags.Repne) != 0) { instruction.HasRepnePrefix = true; } if ((prefixFlags & PrefixFlags.Notrack) != 0) { instruction.SegmentPrefix = Register.DS; } } instructions.Add(in instruction); currentLabel = default(Label); definedAnonLabel = false; prefixFlags = PrefixFlags.None; } private void AddInstruction(Instruction instruction, AssemblerOperandFlags flags) { if (flags != 0) { if ((flags & AssemblerOperandFlags.Broadcast) != 0) { instruction.IsBroadcast = true; } if ((flags & AssemblerOperandFlags.Zeroing) != 0) { instruction.ZeroingMasking = true; } if ((flags & AssemblerOperandFlags.K7) != 0) { instruction.OpMask = (Register)(173 + ((int)(flags & AssemblerOperandFlags.K7) >> 6)); } if ((flags & AssemblerOperandFlags.SuppressAllExceptions) != 0) { instruction.SuppressAllExceptions = true; } if ((flags & AssemblerOperandFlags.RoundControlMask) != 0) { instruction.RoundingControl = (RoundingControl)((int)(flags & AssemblerOperandFlags.RoundControlMask) >> 3); } } AddInstruction(ref instruction); } public void db(byte[] array) { if (array == null) { ThrowHelper.ThrowArgumentNullException_array(); } db(array, 0, array.Length); } public void db(byte[] array, int index, int length) { if (array == null) { ThrowHelper.ThrowArgumentNullException_array(); } if (index < 0) { ThrowHelper.ThrowArgumentOutOfRangeException_index(); } if (length < 0 || (uint)(index + length) > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeException_length(); } int result; int num = Math.DivRem(length, 16, out result); int num2 = index; for (int i = 0; i < num; i++) { AddInstruction(Instruction.CreateDeclareByte(array, num2, 16)); num2 += 16; } if (result > 0) { AddInstruction(Instruction.CreateDeclareByte(array, num2, result)); } } public void call(ushort selector, uint offset) { AddInstruction(Instruction.CreateBranch((Bitness >= 32) ? Code.Call_ptr1632 : Code.Call_ptr1616, selector, offset)); } public void jmp(ushort selector, uint offset) { AddInstruction(Instruction.CreateBranch((Bitness >= 32) ? Code.Jmp_ptr1632 : Code.Jmp_ptr1616, selector, offset)); } public void xlatb() { MemoryOperand memory = new MemoryOperand(Bitness switch { 64 => Register.RBX, 32 => Register.EBX, _ => Register.BX, }, Register.AL); AddInstruction(Instruction.Create(Code.Xlat_m8, in memory)); } public void nop(int sizeInBytes) { if (sizeInBytes < 0) { throw new ArgumentOutOfRangeException("sizeInBytes"); } if (prefixFlags != 0) { throw new InvalidOperationException("No prefixes are allowed"); } if (sizeInBytes != 0) { int result; int num = Math.DivRem(sizeInBytes, 9, out result); for (int i = 0; i < num; i++) { AppendNop(9); } if (result > 0) { AppendNop(result); } } void AppendNop(int amount) { switch (amount) { case 1: db(144); break; case 2: db(102, 144); break; case 3: db(15, 31, 0); break; case 4: db(15, 31, 64, 0); break; case 5: if (Bitness != 16) { db(15, 31, 68, 0, 0); } else { db(15, 31, 128, 0, 0); } break; case 6: if (Bitness != 16) { db(102, 15, 31, 68, 0, 0); } else { db(102, 15, 31, 128, 0, 0); } break; case 7: if (Bitness != 16) { db(15, 31, 128, 0, 0, 0, 0); } else { db(103, 102, 15, 31, 68, 0, 0); } break; case 8: if (Bitness != 16) { db(15, 31, 132, 0, 0, 0, 0, 0); } else { db(103, 15, 31, 128, 0, 0, 0, 0); } break; case 9: if (Bitness != 16) { db(102, 15, 31, 132, 0, 0, 0, 0, 0); } else { db(103, 15, 31, 132, 0, 0, 0, 0, 0); } break; } } } public AssemblerResult Assemble(CodeWriter writer, ulong rip, BlockEncoderOptions options = BlockEncoderOptions.None) { if (!TryAssemble(writer, rip, out string errorMessage, out AssemblerResult assemblerResult, options)) { throw new InvalidOperationException(errorMessage); } return assemblerResult; } public bool TryAssemble(CodeWriter writer, ulong rip, [NotNullWhen(false)] out string? errorMessage, out AssemblerResult assemblerResult, BlockEncoderOptions options = BlockEncoderOptions.None) { if (writer == null) { ThrowHelper.ThrowArgumentNullException_writer(); } assemblerResult = default(AssemblerResult); if (prefixFlags != 0) { errorMessage = $"Unused prefixes {prefixFlags}. You must emit an instruction after using an instruction prefix."; return false; } if (!currentLabel.IsEmpty) { errorMessage = $"Unused label {currentLabel}. You must emit an instruction after emitting a label."; return false; } if (definedAnonLabel) { errorMessage = "Unused anonymous label. You must emit an instruction after emitting a label."; return false; } if (!nextAnonLabel.IsEmpty) { errorMessage = "Found an @F anonymous label reference but there was no call to AnonymousLabel"; return false; } InstructionBlock[] blocks = new InstructionBlock[1] { new InstructionBlock(writer, instructions, rip) }; if (BlockEncoder.TryEncode(Bitness, blocks, out errorMessage, out BlockEncoderResult[] result, options)) { assemblerResult = new AssemblerResult(result); return true; } assemblerResult = new AssemblerResult(Array2.Empty<BlockEncoderResult>()); return false; } private InvalidOperationException NoOpCodeFoundFor(Mnemonic mnemonic, params object[] argNames) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Unable to calculate an OpCode for `" + mnemonic.ToString().ToLowerInvariant()); for (int i = 0; i < argNames.Length; i++) { stringBuilder.Append((i == 0) ? " " : ", "); stringBuilder.Append(argNames[i]); } stringBuilder.Append($"`. Combination of arguments and/or current bitness {Bitness} is not compatible with any existing OpCode encoding."); return new InvalidOperationException(stringBuilder.ToString()); } public void aaa() { AddInstruction(Instruction.Create(Code.Aaa)); } public void aad(sbyte imm) { AddInstruction(Instruction.Create(Code.Aad_imm8, imm)); } public void aad(byte imm) { AddInstruction(Instruction.Create(Code.Aad_imm8, (uint)imm)); } public void aam(sbyte imm) { AddInstruction(Instruction.Create(Code.Aam_imm8, imm)); } public void aam(byte imm) { AddInstruction(Instruction.Create(Code.Aam_imm8, (uint)imm)); } public void aas() { AddInstruction(Instruction.Create(Code.Aas)); } public void adc(AssemblerRegister8 dst, AssemblerRegister8 src) { AddInstruction(Instruction.Create(Code.Adc_rm8_r8, dst, src)); } public void adc(AssemblerMemoryOperand dst, AssemblerRegister8 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_rm8_r8, in memory, src)); } public void adc(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Adc_rm16_r16, dst, src)); } public void adc(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_rm16_r16, in memory, src)); } public void adc(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Adc_rm32_r32, dst, src)); } public void adc(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_rm32_r32, in memory, src)); } public void adc(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Adc_rm64_r64, dst, src)); } public void adc(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_rm64_r64, in memory, src)); } public void adc(AssemblerRegister8 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_r8_rm8, register, in memory)); } public void adc(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_r16_rm16, register, in memory)); } public void adc(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_r32_rm32, register, in memory)); } public void adc(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adc_r64_rm64, register, in memory)); } public void adc(AssemblerRegister8 dst, sbyte imm) { Code code = (((Register)dst == Register.AL) ? Code.Adc_AL_imm8 : Code.Adc_rm8_imm8); AddInstruction(Instruction.Create(code, dst, imm)); } public void adc(AssemblerRegister16 dst, short imm) { Code code = (((Register)dst != Register.AX) ? ((imm >= -128 && imm <= 127) ? Code.Adc_rm16_imm8 : Code.Adc_rm16_imm16) : Code.Adc_AX_imm16); AddInstruction(Instruction.Create(code, dst, imm)); } public void adc(AssemblerRegister32 dst, int imm) { Code code = (((Register)dst != Register.EAX) ? ((imm >= -128 && imm <= 127) ? Code.Adc_rm32_imm8 : Code.Adc_rm32_imm32) : Code.Adc_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void adc(AssemblerRegister64 dst, int imm) { Code code = (((Register)dst != Register.RAX) ? ((imm >= -128 && imm <= 127) ? Code.Adc_rm64_imm8 : Code.Adc_rm64_imm32) : Code.Adc_RAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void adc(AssemblerMemoryOperand dst, int imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = ((imm >= -128 && imm <= 127) ? Code.Adc_rm64_imm8 : Code.Adc_rm64_imm32); } else if (dst.Size == MemoryOperandSize.Dword) { code = ((imm >= -128 && imm <= 127) ? Code.Adc_rm32_imm8 : Code.Adc_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm >= -128 && imm <= 127) ? Code.Adc_rm16_imm8 : Code.Adc_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.Adc, dst, imm); } code = Code.Adc_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void adc(AssemblerRegister8 dst, byte imm) { Code code = (((Register)dst == Register.AL) ? Code.Adc_AL_imm8 : Code.Adc_rm8_imm8); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void adc(AssemblerRegister16 dst, ushort imm) { Code code = (((Register)dst != Register.AX) ? ((imm <= 127 || (65408 <= imm && imm <= ushort.MaxValue)) ? Code.Adc_rm16_imm8 : Code.Adc_rm16_imm16) : Code.Adc_AX_imm16); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void adc(AssemblerRegister32 dst, uint imm) { Code code = (((Register)dst != Register.EAX) ? ((imm <= 127 || 4294967168u <= imm) ? Code.Adc_rm32_imm8 : Code.Adc_rm32_imm32) : Code.Adc_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void adc(AssemblerMemoryOperand dst, uint imm) { Code code; if (dst.Size == MemoryOperandSize.Dword) { code = ((imm <= 127 || 4294967168u <= imm) ? Code.Adc_rm32_imm8 : Code.Adc_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm <= 127 || (65408 <= imm && imm <= 65535)) ? Code.Adc_rm16_imm8 : Code.Adc_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.Adc, dst, imm); } code = Code.Adc_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void adcx(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Adcx_r32_rm32, dst, src)); } public void adcx(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Adcx_r64_rm64, dst, src)); } public void adcx(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adcx_r32_rm32, register, in memory)); } public void adcx(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adcx_r64_rm64, register, in memory)); } public void add(AssemblerRegister8 dst, AssemblerRegister8 src) { AddInstruction(Instruction.Create(Code.Add_rm8_r8, dst, src)); } public void add(AssemblerMemoryOperand dst, AssemblerRegister8 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_rm8_r8, in memory, src)); } public void add(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Add_rm16_r16, dst, src)); } public void add(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_rm16_r16, in memory, src)); } public void add(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Add_rm32_r32, dst, src)); } public void add(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_rm32_r32, in memory, src)); } public void add(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Add_rm64_r64, dst, src)); } public void add(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_rm64_r64, in memory, src)); } public void add(AssemblerRegister8 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_r8_rm8, register, in memory)); } public void add(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_r16_rm16, register, in memory)); } public void add(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_r32_rm32, register, in memory)); } public void add(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Add_r64_rm64, register, in memory)); } public void add(AssemblerRegister8 dst, sbyte imm) { Code code = (((Register)dst == Register.AL) ? Code.Add_AL_imm8 : Code.Add_rm8_imm8); AddInstruction(Instruction.Create(code, dst, imm)); } public void add(AssemblerRegister16 dst, short imm) { Code code = (((Register)dst != Register.AX) ? ((imm >= -128 && imm <= 127) ? Code.Add_rm16_imm8 : Code.Add_rm16_imm16) : Code.Add_AX_imm16); AddInstruction(Instruction.Create(code, dst, imm)); } public void add(AssemblerRegister32 dst, int imm) { Code code = (((Register)dst != Register.EAX) ? ((imm >= -128 && imm <= 127) ? Code.Add_rm32_imm8 : Code.Add_rm32_imm32) : Code.Add_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void add(AssemblerRegister64 dst, int imm) { Code code = (((Register)dst != Register.RAX) ? ((imm >= -128 && imm <= 127) ? Code.Add_rm64_imm8 : Code.Add_rm64_imm32) : Code.Add_RAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void add(AssemblerMemoryOperand dst, int imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = ((imm >= -128 && imm <= 127) ? Code.Add_rm64_imm8 : Code.Add_rm64_imm32); } else if (dst.Size == MemoryOperandSize.Dword) { code = ((imm >= -128 && imm <= 127) ? Code.Add_rm32_imm8 : Code.Add_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm >= -128 && imm <= 127) ? Code.Add_rm16_imm8 : Code.Add_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.Add, dst, imm); } code = Code.Add_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void add(AssemblerRegister8 dst, byte imm) { Code code = (((Register)dst == Register.AL) ? Code.Add_AL_imm8 : Code.Add_rm8_imm8); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void add(AssemblerRegister16 dst, ushort imm) { Code code = (((Register)dst != Register.AX) ? ((imm <= 127 || (65408 <= imm && imm <= ushort.MaxValue)) ? Code.Add_rm16_imm8 : Code.Add_rm16_imm16) : Code.Add_AX_imm16); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void add(AssemblerRegister32 dst, uint imm) { Code code = (((Register)dst != Register.EAX) ? ((imm <= 127 || 4294967168u <= imm) ? Code.Add_rm32_imm8 : Code.Add_rm32_imm32) : Code.Add_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void add(AssemblerMemoryOperand dst, uint imm) { Code code; if (dst.Size == MemoryOperandSize.Dword) { code = ((imm <= 127 || 4294967168u <= imm) ? Code.Add_rm32_imm8 : Code.Add_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm <= 127 || (65408 <= imm && imm <= 65535)) ? Code.Add_rm16_imm8 : Code.Add_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.Add, dst, imm); } code = Code.Add_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void addpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addpd_xmm_xmmm128, dst, src)); } public void addpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addpd_xmm_xmmm128, register, in memory)); } public void addps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addps_xmm_xmmm128, dst, src)); } public void addps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addps_xmm_xmmm128, register, in memory)); } public void addsd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addsd_xmm_xmmm64, dst, src)); } public void addsd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addsd_xmm_xmmm64, register, in memory)); } public void addss(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addss_xmm_xmmm32, dst, src)); } public void addss(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addss_xmm_xmmm32, register, in memory)); } public void addsubpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addsubpd_xmm_xmmm128, dst, src)); } public void addsubpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addsubpd_xmm_xmmm128, register, in memory)); } public void addsubps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Addsubps_xmm_xmmm128, dst, src)); } public void addsubps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Addsubps_xmm_xmmm128, register, in memory)); } public void adox(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Adox_r32_rm32, dst, src)); } public void adox(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Adox_r64_rm64, dst, src)); } public void adox(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adox_r32_rm32, register, in memory)); } public void adox(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Adox_r64_rm64, register, in memory)); } public void aesdec(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Aesdec_xmm_xmmm128, dst, src)); } public void aesdec(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdec_xmm_xmmm128, register, in memory)); } public void aesdec128kl(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdec128kl_xmm_m384, register, in memory)); } public void aesdec256kl(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdec256kl_xmm_m512, register, in memory)); } public void aesdeclast(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Aesdeclast_xmm_xmmm128, dst, src)); } public void aesdeclast(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdeclast_xmm_xmmm128, register, in memory)); } public void aesdecwide128kl(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdecwide128kl_m384, in memory)); } public void aesdecwide256kl(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesdecwide256kl_m512, in memory)); } public void aesenc(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Aesenc_xmm_xmmm128, dst, src)); } public void aesenc(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesenc_xmm_xmmm128, register, in memory)); } public void aesenc128kl(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesenc128kl_xmm_m384, register, in memory)); } public void aesenc256kl(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesenc256kl_xmm_m512, register, in memory)); } public void aesenclast(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Aesenclast_xmm_xmmm128, dst, src)); } public void aesenclast(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesenclast_xmm_xmmm128, register, in memory)); } public void aesencwide128kl(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesencwide128kl_m384, in memory)); } public void aesencwide256kl(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesencwide256kl_m512, in memory)); } public void aesimc(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Aesimc_xmm_xmmm128, dst, src)); } public void aesimc(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aesimc_xmm_xmmm128, register, in memory)); } public void aeskeygenassist(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, sbyte imm) { AddInstruction(Instruction.Create(Code.Aeskeygenassist_xmm_xmmm128_imm8, dst, src1, imm)); } public void aeskeygenassist(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, sbyte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aeskeygenassist_xmm_xmmm128_imm8, register, in memory, imm)); } public void aeskeygenassist(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, byte imm) { AddInstruction(Instruction.Create(Code.Aeskeygenassist_xmm_xmmm128_imm8, (Register)dst, (Register)src1, (uint)imm)); } public void aeskeygenassist(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, byte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Aeskeygenassist_xmm_xmmm128_imm8, register, in memory, (uint)imm)); } public void altinst() { AddInstruction(Instruction.Create(Code.Altinst)); } public void and(AssemblerRegister8 dst, AssemblerRegister8 src) { AddInstruction(Instruction.Create(Code.And_rm8_r8, dst, src)); } public void and(AssemblerMemoryOperand dst, AssemblerRegister8 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_rm8_r8, in memory, src)); } public void and(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.And_rm16_r16, dst, src)); } public void and(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_rm16_r16, in memory, src)); } public void and(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.And_rm32_r32, dst, src)); } public void and(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_rm32_r32, in memory, src)); } public void and(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.And_rm64_r64, dst, src)); } public void and(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_rm64_r64, in memory, src)); } public void and(AssemblerRegister8 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_r8_rm8, register, in memory)); } public void and(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_r16_rm16, register, in memory)); } public void and(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_r32_rm32, register, in memory)); } public void and(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.And_r64_rm64, register, in memory)); } public void and(AssemblerRegister8 dst, sbyte imm) { Code code = (((Register)dst == Register.AL) ? Code.And_AL_imm8 : Code.And_rm8_imm8); AddInstruction(Instruction.Create(code, dst, imm)); } public void and(AssemblerRegister16 dst, short imm) { Code code = (((Register)dst != Register.AX) ? ((imm >= -128 && imm <= 127) ? Code.And_rm16_imm8 : Code.And_rm16_imm16) : Code.And_AX_imm16); AddInstruction(Instruction.Create(code, dst, imm)); } public void and(AssemblerRegister32 dst, int imm) { Code code = (((Register)dst != Register.EAX) ? ((imm >= -128 && imm <= 127) ? Code.And_rm32_imm8 : Code.And_rm32_imm32) : Code.And_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void and(AssemblerRegister64 dst, int imm) { Code code = (((Register)dst != Register.RAX) ? ((imm >= -128 && imm <= 127) ? Code.And_rm64_imm8 : Code.And_rm64_imm32) : Code.And_RAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void and(AssemblerMemoryOperand dst, int imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = ((imm >= -128 && imm <= 127) ? Code.And_rm64_imm8 : Code.And_rm64_imm32); } else if (dst.Size == MemoryOperandSize.Dword) { code = ((imm >= -128 && imm <= 127) ? Code.And_rm32_imm8 : Code.And_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm >= -128 && imm <= 127) ? Code.And_rm16_imm8 : Code.And_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.And, dst, imm); } code = Code.And_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void and(AssemblerRegister8 dst, byte imm) { Code code = (((Register)dst == Register.AL) ? Code.And_AL_imm8 : Code.And_rm8_imm8); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void and(AssemblerRegister16 dst, ushort imm) { Code code = (((Register)dst != Register.AX) ? ((imm <= 127 || (65408 <= imm && imm <= ushort.MaxValue)) ? Code.And_rm16_imm8 : Code.And_rm16_imm16) : Code.And_AX_imm16); AddInstruction(Instruction.Create(code, (Register)dst, (uint)imm)); } public void and(AssemblerRegister32 dst, uint imm) { Code code = (((Register)dst != Register.EAX) ? ((imm <= 127 || 4294967168u <= imm) ? Code.And_rm32_imm8 : Code.And_rm32_imm32) : Code.And_EAX_imm32); AddInstruction(Instruction.Create(code, dst, imm)); } public void and(AssemblerMemoryOperand dst, uint imm) { Code code; if (dst.Size == MemoryOperandSize.Dword) { code = ((imm <= 127 || 4294967168u <= imm) ? Code.And_rm32_imm8 : Code.And_rm32_imm32); } else if (dst.Size == MemoryOperandSize.Word) { code = ((imm <= 127 || (65408 <= imm && imm <= 65535)) ? Code.And_rm16_imm8 : Code.And_rm16_imm16); } else { if (dst.Size != MemoryOperandSize.Byte) { throw NoOpCodeFoundFor(Mnemonic.And, dst, imm); } code = Code.And_rm8_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void andn(AssemblerRegister32 dst, AssemblerRegister32 src1, AssemblerRegister32 src2) { AddInstruction(Instruction.Create(Code.VEX_Andn_r32_r32_rm32, dst, src1, src2)); } public void andn(AssemblerRegister64 dst, AssemblerRegister64 src1, AssemblerRegister64 src2) { AddInstruction(Instruction.Create(Code.VEX_Andn_r64_r64_rm64, dst, src1, src2)); } public void andn(AssemblerRegister32 dst, AssemblerRegister32 src1, AssemblerMemoryOperand src2) { Register register = dst; Register register2 = src1; MemoryOperand memory = src2.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Andn_r32_r32_rm32, register, register2, in memory)); } public void andn(AssemblerRegister64 dst, AssemblerRegister64 src1, AssemblerMemoryOperand src2) { Register register = dst; Register register2 = src1; MemoryOperand memory = src2.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Andn_r64_r64_rm64, register, register2, in memory)); } public void andnpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Andnpd_xmm_xmmm128, dst, src)); } public void andnpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Andnpd_xmm_xmmm128, register, in memory)); } public void andnps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Andnps_xmm_xmmm128, dst, src)); } public void andnps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Andnps_xmm_xmmm128, register, in memory)); } public void andpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Andpd_xmm_xmmm128, dst, src)); } public void andpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Andpd_xmm_xmmm128, register, in memory)); } public void andps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Andps_xmm_xmmm128, dst, src)); } public void andps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Andps_xmm_xmmm128, register, in memory)); } public void arpl(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Arpl_rm16_r16, dst, src)); } public void arpl(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Arpl_rm16_r16, in memory, src)); } public void arpl(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Arpl_r32m16_r32, dst, src)); } public void arpl(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Arpl_r32m16_r32, in memory, src)); } public void bb0_reset() { AddInstruction(Instruction.Create(Code.Bb0_reset)); } public void bb1_reset() { AddInstruction(Instruction.Create(Code.Bb1_reset)); } public void bextr(AssemblerRegister32 dst, AssemblerRegister32 src1, AssemblerRegister32 src2) { AddInstruction(Instruction.Create(Code.VEX_Bextr_r32_rm32_r32, dst, src1, src2)); } public void bextr(AssemblerRegister32 dst, AssemblerMemoryOperand src1, AssemblerRegister32 src2) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Bextr_r32_rm32_r32, register, in memory, src2)); } public void bextr(AssemblerRegister64 dst, AssemblerRegister64 src1, AssemblerRegister64 src2) { AddInstruction(Instruction.Create(Code.VEX_Bextr_r64_rm64_r64, dst, src1, src2)); } public void bextr(AssemblerRegister64 dst, AssemblerMemoryOperand src1, AssemblerRegister64 src2) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Bextr_r64_rm64_r64, register, in memory, src2)); } public void bextr(AssemblerRegister32 dst, AssemblerRegister32 src1, int imm) { AddInstruction(Instruction.Create(Code.XOP_Bextr_r32_rm32_imm32, dst, src1, imm)); } public void bextr(AssemblerRegister64 dst, AssemblerRegister64 src1, int imm) { AddInstruction(Instruction.Create(Code.XOP_Bextr_r64_rm64_imm32, dst, src1, imm)); } public void bextr(AssemblerRegister32 dst, AssemblerMemoryOperand src1, int imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Bextr_r32_rm32_imm32, register, in memory, imm)); } public void bextr(AssemblerRegister64 dst, AssemblerMemoryOperand src1, int imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Bextr_r64_rm64_imm32, register, in memory, imm)); } public void bextr(AssemblerRegister32 dst, AssemblerRegister32 src1, uint imm) { AddInstruction(Instruction.Create(Code.XOP_Bextr_r32_rm32_imm32, dst, src1, imm)); } public void bextr(AssemblerRegister64 dst, AssemblerRegister64 src1, uint imm) { AddInstruction(Instruction.Create(Code.XOP_Bextr_r64_rm64_imm32, dst, src1, imm)); } public void bextr(AssemblerRegister32 dst, AssemblerMemoryOperand src1, uint imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Bextr_r32_rm32_imm32, register, in memory, imm)); } public void bextr(AssemblerRegister64 dst, AssemblerMemoryOperand src1, uint imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Bextr_r64_rm64_imm32, register, in memory, imm)); } public void blcfill(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blcfill_r32_rm32, dst, src)); } public void blcfill(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blcfill_r64_rm64, dst, src)); } public void blcfill(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcfill_r32_rm32, register, in memory)); } public void blcfill(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcfill_r64_rm64, register, in memory)); } public void blci(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blci_r32_rm32, dst, src)); } public void blci(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blci_r64_rm64, dst, src)); } public void blci(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blci_r32_rm32, register, in memory)); } public void blci(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blci_r64_rm64, register, in memory)); } public void blcic(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blcic_r32_rm32, dst, src)); } public void blcic(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blcic_r64_rm64, dst, src)); } public void blcic(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcic_r32_rm32, register, in memory)); } public void blcic(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcic_r64_rm64, register, in memory)); } public void blcmsk(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blcmsk_r32_rm32, dst, src)); } public void blcmsk(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blcmsk_r64_rm64, dst, src)); } public void blcmsk(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcmsk_r32_rm32, register, in memory)); } public void blcmsk(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcmsk_r64_rm64, register, in memory)); } public void blcs(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blcs_r32_rm32, dst, src)); } public void blcs(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blcs_r64_rm64, dst, src)); } public void blcs(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcs_r32_rm32, register, in memory)); } public void blcs(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blcs_r64_rm64, register, in memory)); } public void blendpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, sbyte imm) { AddInstruction(Instruction.Create(Code.Blendpd_xmm_xmmm128_imm8, dst, src1, imm)); } public void blendpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, sbyte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendpd_xmm_xmmm128_imm8, register, in memory, imm)); } public void blendpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, byte imm) { AddInstruction(Instruction.Create(Code.Blendpd_xmm_xmmm128_imm8, (Register)dst, (Register)src1, (uint)imm)); } public void blendpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, byte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendpd_xmm_xmmm128_imm8, register, in memory, (uint)imm)); } public void blendps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, sbyte imm) { AddInstruction(Instruction.Create(Code.Blendps_xmm_xmmm128_imm8, dst, src1, imm)); } public void blendps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, sbyte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendps_xmm_xmmm128_imm8, register, in memory, imm)); } public void blendps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src1, byte imm) { AddInstruction(Instruction.Create(Code.Blendps_xmm_xmmm128_imm8, (Register)dst, (Register)src1, (uint)imm)); } public void blendps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src1, byte imm) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendps_xmm_xmmm128_imm8, register, in memory, (uint)imm)); } public void blendvpd(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Blendvpd_xmm_xmmm128, dst, src)); } public void blendvpd(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendvpd_xmm_xmmm128, register, in memory)); } public void blendvps(AssemblerRegisterXMM dst, AssemblerRegisterXMM src) { AddInstruction(Instruction.Create(Code.Blendvps_xmm_xmmm128, dst, src)); } public void blendvps(AssemblerRegisterXMM dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Blendvps_xmm_xmmm128, register, in memory)); } public void blsfill(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blsfill_r32_rm32, dst, src)); } public void blsfill(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blsfill_r64_rm64, dst, src)); } public void blsfill(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blsfill_r32_rm32, register, in memory)); } public void blsfill(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blsfill_r64_rm64, register, in memory)); } public void blsi(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.VEX_Blsi_r32_rm32, dst, src)); } public void blsi(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.VEX_Blsi_r64_rm64, dst, src)); } public void blsi(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsi_r32_rm32, register, in memory)); } public void blsi(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsi_r64_rm64, register, in memory)); } public void blsic(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.XOP_Blsic_r32_rm32, dst, src)); } public void blsic(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.XOP_Blsic_r64_rm64, dst, src)); } public void blsic(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blsic_r32_rm32, register, in memory)); } public void blsic(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.XOP_Blsic_r64_rm64, register, in memory)); } public void blsmsk(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.VEX_Blsmsk_r32_rm32, dst, src)); } public void blsmsk(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.VEX_Blsmsk_r64_rm64, dst, src)); } public void blsmsk(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsmsk_r32_rm32, register, in memory)); } public void blsmsk(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsmsk_r64_rm64, register, in memory)); } public void blsr(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.VEX_Blsr_r32_rm32, dst, src)); } public void blsr(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.VEX_Blsr_r64_rm64, dst, src)); } public void blsr(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsr_r32_rm32, register, in memory)); } public void blsr(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Blsr_r64_rm64, register, in memory)); } public void bndcl(AssemblerRegisterBND dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bndcl_bnd_rm32, dst, src)); } public void bndcl(AssemblerRegisterBND dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bndcl_bnd_rm64, dst, src)); } public void bndcl(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Code code; if (src.Size == MemoryOperandSize.Qword) { code = Code.Bndcl_bnd_rm64; } else { if (src.Size != MemoryOperandSize.Dword) { throw NoOpCodeFoundFor(Mnemonic.Bndcl, dst, src); } code = Code.Bndcl_bnd_rm32; } Code code2 = code; Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, register, in memory)); } public void bndcn(AssemblerRegisterBND dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bndcn_bnd_rm32, dst, src)); } public void bndcn(AssemblerRegisterBND dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bndcn_bnd_rm64, dst, src)); } public void bndcn(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Code code; if (src.Size == MemoryOperandSize.Qword) { code = Code.Bndcn_bnd_rm64; } else { if (src.Size != MemoryOperandSize.Dword) { throw NoOpCodeFoundFor(Mnemonic.Bndcn, dst, src); } code = Code.Bndcn_bnd_rm32; } Code code2 = code; Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, register, in memory)); } public void bndcu(AssemblerRegisterBND dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bndcu_bnd_rm32, dst, src)); } public void bndcu(AssemblerRegisterBND dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bndcu_bnd_rm64, dst, src)); } public void bndcu(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Code code; if (src.Size == MemoryOperandSize.Qword) { code = Code.Bndcu_bnd_rm64; } else { if (src.Size != MemoryOperandSize.Dword) { throw NoOpCodeFoundFor(Mnemonic.Bndcu, dst, src); } code = Code.Bndcu_bnd_rm32; } Code code2 = code; Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, register, in memory)); } public void bndldx(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bndldx_bnd_mib, register, in memory)); } public void bndmk(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Code code; if (src.Size == MemoryOperandSize.Qword) { code = Code.Bndmk_bnd_m64; } else { if (src.Size != MemoryOperandSize.Dword) { throw NoOpCodeFoundFor(Mnemonic.Bndmk, dst, src); } code = Code.Bndmk_bnd_m32; } Code code2 = code; Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, register, in memory)); } public void bndmov(AssemblerRegisterBND dst, AssemblerRegisterBND src) { Code code = ((Bitness == 64) ? Code.Bndmov_bnd_bndm128 : Code.Bndmov_bnd_bndm64); AddInstruction(Instruction.Create(code, dst, src)); } public void bndmov(AssemblerMemoryOperand dst, AssemblerRegisterBND src) { Code code = ((Bitness == 64) ? Code.Bndmov_bndm128_bnd : Code.Bndmov_bndm64_bnd); MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code, in memory, src)); } public void bndmov(AssemblerRegisterBND dst, AssemblerMemoryOperand src) { Code code = ((Bitness == 64) ? Code.Bndmov_bnd_bndm128 : Code.Bndmov_bnd_bndm64); Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code, register, in memory)); } public void bndstx(AssemblerMemoryOperand dst, AssemblerRegisterBND src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bndstx_mib_bnd, in memory, src)); } public void bound(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bound_r16_m1616, register, in memory)); } public void bound(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bound_r32_m3232, register, in memory)); } public void bsf(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Bsf_r16_rm16, dst, src)); } public void bsf(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bsf_r32_rm32, dst, src)); } public void bsf(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bsf_r64_rm64, dst, src)); } public void bsf(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsf_r16_rm16, register, in memory)); } public void bsf(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsf_r32_rm32, register, in memory)); } public void bsf(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsf_r64_rm64, register, in memory)); } public void bsr(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Bsr_r16_rm16, dst, src)); } public void bsr(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bsr_r32_rm32, dst, src)); } public void bsr(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bsr_r64_rm64, dst, src)); } public void bsr(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsr_r16_rm16, register, in memory)); } public void bsr(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsr_r32_rm32, register, in memory)); } public void bsr(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bsr_r64_rm64, register, in memory)); } public void bswap(AssemblerRegister16 dst) { AddInstruction(Instruction.Create(Code.Bswap_r16, dst)); } public void bswap(AssemblerRegister32 dst) { AddInstruction(Instruction.Create(Code.Bswap_r32, dst)); } public void bswap(AssemblerRegister64 dst) { AddInstruction(Instruction.Create(Code.Bswap_r64, dst)); } public void bt(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Bt_rm16_r16, dst, src)); } public void bt(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bt_rm16_r16, in memory, src)); } public void bt(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bt_rm32_r32, dst, src)); } public void bt(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bt_rm32_r32, in memory, src)); } public void bt(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bt_rm64_r64, dst, src)); } public void bt(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bt_rm64_r64, in memory, src)); } public void bt(AssemblerRegister16 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bt_rm16_imm8, dst, imm)); } public void bt(AssemblerRegister32 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bt_rm32_imm8, dst, imm)); } public void bt(AssemblerRegister64 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bt_rm64_imm8, dst, imm)); } public void bt(AssemblerMemoryOperand dst, sbyte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Bt_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Bt_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Bt, dst, imm); } code = Code.Bt_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void bt(AssemblerRegister16 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bt_rm16_imm8, (Register)dst, (uint)imm)); } public void bt(AssemblerRegister32 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bt_rm32_imm8, (Register)dst, (uint)imm)); } public void bt(AssemblerRegister64 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bt_rm64_imm8, (Register)dst, (uint)imm)); } public void bt(AssemblerMemoryOperand dst, byte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Bt_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Bt_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Bt, dst, imm); } code = Code.Bt_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, (uint)imm)); } public void btc(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Btc_rm16_r16, dst, src)); } public void btc(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btc_rm16_r16, in memory, src)); } public void btc(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Btc_rm32_r32, dst, src)); } public void btc(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btc_rm32_r32, in memory, src)); } public void btc(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Btc_rm64_r64, dst, src)); } public void btc(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btc_rm64_r64, in memory, src)); } public void btc(AssemblerRegister16 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btc_rm16_imm8, dst, imm)); } public void btc(AssemblerRegister32 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btc_rm32_imm8, dst, imm)); } public void btc(AssemblerRegister64 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btc_rm64_imm8, dst, imm)); } public void btc(AssemblerMemoryOperand dst, sbyte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Btc_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Btc_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Btc, dst, imm); } code = Code.Btc_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void btc(AssemblerRegister16 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btc_rm16_imm8, (Register)dst, (uint)imm)); } public void btc(AssemblerRegister32 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btc_rm32_imm8, (Register)dst, (uint)imm)); } public void btc(AssemblerRegister64 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btc_rm64_imm8, (Register)dst, (uint)imm)); } public void btc(AssemblerMemoryOperand dst, byte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Btc_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Btc_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Btc, dst, imm); } code = Code.Btc_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, (uint)imm)); } public void btr(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Btr_rm16_r16, dst, src)); } public void btr(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btr_rm16_r16, in memory, src)); } public void btr(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Btr_rm32_r32, dst, src)); } public void btr(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btr_rm32_r32, in memory, src)); } public void btr(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Btr_rm64_r64, dst, src)); } public void btr(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Btr_rm64_r64, in memory, src)); } public void btr(AssemblerRegister16 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btr_rm16_imm8, dst, imm)); } public void btr(AssemblerRegister32 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btr_rm32_imm8, dst, imm)); } public void btr(AssemblerRegister64 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Btr_rm64_imm8, dst, imm)); } public void btr(AssemblerMemoryOperand dst, sbyte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Btr_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Btr_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Btr, dst, imm); } code = Code.Btr_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void btr(AssemblerRegister16 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btr_rm16_imm8, (Register)dst, (uint)imm)); } public void btr(AssemblerRegister32 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btr_rm32_imm8, (Register)dst, (uint)imm)); } public void btr(AssemblerRegister64 dst, byte imm) { AddInstruction(Instruction.Create(Code.Btr_rm64_imm8, (Register)dst, (uint)imm)); } public void btr(AssemblerMemoryOperand dst, byte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Btr_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Btr_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Btr, dst, imm); } code = Code.Btr_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, (uint)imm)); } public void bts(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Bts_rm16_r16, dst, src)); } public void bts(AssemblerMemoryOperand dst, AssemblerRegister16 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bts_rm16_r16, in memory, src)); } public void bts(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Bts_rm32_r32, dst, src)); } public void bts(AssemblerMemoryOperand dst, AssemblerRegister32 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bts_rm32_r32, in memory, src)); } public void bts(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Bts_rm64_r64, dst, src)); } public void bts(AssemblerMemoryOperand dst, AssemblerRegister64 src) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Bts_rm64_r64, in memory, src)); } public void bts(AssemblerRegister16 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bts_rm16_imm8, dst, imm)); } public void bts(AssemblerRegister32 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bts_rm32_imm8, dst, imm)); } public void bts(AssemblerRegister64 dst, sbyte imm) { AddInstruction(Instruction.Create(Code.Bts_rm64_imm8, dst, imm)); } public void bts(AssemblerMemoryOperand dst, sbyte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Bts_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Bts_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Bts, dst, imm); } code = Code.Bts_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, imm)); } public void bts(AssemblerRegister16 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bts_rm16_imm8, (Register)dst, (uint)imm)); } public void bts(AssemblerRegister32 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bts_rm32_imm8, (Register)dst, (uint)imm)); } public void bts(AssemblerRegister64 dst, byte imm) { AddInstruction(Instruction.Create(Code.Bts_rm64_imm8, (Register)dst, (uint)imm)); } public void bts(AssemblerMemoryOperand dst, byte imm) { Code code; if (dst.Size == MemoryOperandSize.Qword) { code = Code.Bts_rm64_imm8; } else if (dst.Size == MemoryOperandSize.Dword) { code = Code.Bts_rm32_imm8; } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Bts, dst, imm); } code = Code.Bts_rm16_imm8; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory, (uint)imm)); } public void bzhi(AssemblerRegister32 dst, AssemblerRegister32 src1, AssemblerRegister32 src2) { AddInstruction(Instruction.Create(Code.VEX_Bzhi_r32_rm32_r32, dst, src1, src2)); } public void bzhi(AssemblerRegister32 dst, AssemblerMemoryOperand src1, AssemblerRegister32 src2) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Bzhi_r32_rm32_r32, register, in memory, src2)); } public void bzhi(AssemblerRegister64 dst, AssemblerRegister64 src1, AssemblerRegister64 src2) { AddInstruction(Instruction.Create(Code.VEX_Bzhi_r64_rm64_r64, dst, src1, src2)); } public void bzhi(AssemblerRegister64 dst, AssemblerMemoryOperand src1, AssemblerRegister64 src2) { Register register = dst; MemoryOperand memory = src1.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.VEX_Bzhi_r64_rm64_r64, register, in memory, src2)); } public void call(AssemblerRegister16 dst) { AddInstruction(Instruction.Create(Code.Call_rm16, dst)); } public void call(AssemblerRegister32 dst) { AddInstruction(Instruction.Create(Code.Call_rm32, dst)); } public void call(AssemblerRegister64 dst) { AddInstruction(Instruction.Create(Code.Call_rm64, dst)); } public void call(AssemblerMemoryOperand dst) { Code code; if (dst.Size == MemoryOperandSize.Tbyte) { code = Code.Call_m1664; } else if (dst.Size == MemoryOperandSize.Qword) { code = Code.Call_rm64; } else if (dst.Size == MemoryOperandSize.Fword) { code = Code.Call_m1632; } else if (dst.Size == MemoryOperandSize.Dword) { code = ((Bitness >= 32) ? Code.Call_rm32 : Code.Call_m1616); } else { if (dst.Size != MemoryOperandSize.Word) { throw NoOpCodeFoundFor(Mnemonic.Call, dst); } code = Code.Call_rm16; } Code code2 = code; MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(code2, in memory)); } public void call(Label dst) { Code code = ((Bitness != 64) ? ((Bitness >= 32) ? Code.Call_rel32_32 : Code.Call_rel16) : Code.Call_rel32_64); AddInstruction(Instruction.CreateBranch(code, dst.Id)); } public void call(ulong dst) { Code code = ((Bitness != 64) ? ((Bitness >= 32) ? Code.Call_rel32_32 : Code.Call_rel16) : Code.Call_rel32_64); AddInstruction(Instruction.CreateBranch(code, dst)); } public void cbw() { AddInstruction(Instruction.Create(Code.Cbw)); } public void ccs_encrypt() { Code code = ((Bitness != 64) ? ((Bitness >= 32) ? Code.Ccs_encrypt_32 : Code.Ccs_encrypt_16) : Code.Ccs_encrypt_64); AddInstruction(Instruction.Create(code)); } public void ccs_hash() { Code code = ((Bitness != 64) ? ((Bitness >= 32) ? Code.Ccs_hash_32 : Code.Ccs_hash_16) : Code.Ccs_hash_64); AddInstruction(Instruction.Create(code)); } public void cdq() { AddInstruction(Instruction.Create(Code.Cdq)); } public void cdqe() { AddInstruction(Instruction.Create(Code.Cdqe)); } public void cl1invmb() { AddInstruction(Instruction.Create(Code.Cl1invmb)); } public void clac() { AddInstruction(Instruction.Create(Code.Clac)); } public void clc() { AddInstruction(Instruction.Create(Code.Clc)); } public void cld() { AddInstruction(Instruction.Create(Code.Cld)); } public void cldemote(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cldemote_m8, in memory)); } public void clflush(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Clflush_m8, in memory)); } public void clflushopt(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Clflushopt_m8, in memory)); } public void clgi() { AddInstruction(Instruction.Create(Code.Clgi)); } public void cli() { AddInstruction(Instruction.Create(Code.Cli)); } public void clrssbsy(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Clrssbsy_m64, in memory)); } public void clts() { AddInstruction(Instruction.Create(Code.Clts)); } public void clui() { AddInstruction(Instruction.Create(Code.Clui)); } public void clwb(AssemblerMemoryOperand dst) { MemoryOperand memory = dst.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Clwb_m8, in memory)); } public void clzero() { Code code = ((Bitness != 64) ? ((Bitness >= 32) ? Code.Clzerod : Code.Clzerow) : Code.Clzeroq); AddInstruction(Instruction.Create(code)); } public void cmc() { AddInstruction(Instruction.Create(Code.Cmc)); } public void cmova(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmova_r16_rm16, dst, src)); } public void cmova(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmova_r32_rm32, dst, src)); } public void cmova(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmova_r64_rm64, dst, src)); } public void cmova(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r16_rm16, register, in memory)); } public void cmova(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r32_rm32, register, in memory)); } public void cmova(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r64_rm64, register, in memory)); } public void cmovae(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, dst, src)); } public void cmovae(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, dst, src)); } public void cmovae(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, dst, src)); } public void cmovae(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, register, in memory)); } public void cmovae(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, register, in memory)); } public void cmovae(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, register, in memory)); } public void cmovb(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, dst, src)); } public void cmovb(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, dst, src)); } public void cmovb(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, dst, src)); } public void cmovb(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, register, in memory)); } public void cmovb(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, register, in memory)); } public void cmovb(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, register, in memory)); } public void cmovbe(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r16_rm16, dst, src)); } public void cmovbe(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r32_rm32, dst, src)); } public void cmovbe(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r64_rm64, dst, src)); } public void cmovbe(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r16_rm16, register, in memory)); } public void cmovbe(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r32_rm32, register, in memory)); } public void cmovbe(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r64_rm64, register, in memory)); } public void cmovc(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, dst, src)); } public void cmovc(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, dst, src)); } public void cmovc(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, dst, src)); } public void cmovc(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, register, in memory)); } public void cmovc(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, register, in memory)); } public void cmovc(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, register, in memory)); } public void cmove(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmove_r16_rm16, dst, src)); } public void cmove(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmove_r32_rm32, dst, src)); } public void cmove(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmove_r64_rm64, dst, src)); } public void cmove(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmove_r16_rm16, register, in memory)); } public void cmove(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmove_r32_rm32, register, in memory)); } public void cmove(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmove_r64_rm64, register, in memory)); } public void cmovg(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovg_r16_rm16, dst, src)); } public void cmovg(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovg_r32_rm32, dst, src)); } public void cmovg(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovg_r64_rm64, dst, src)); } public void cmovg(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovg_r16_rm16, register, in memory)); } public void cmovg(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovg_r32_rm32, register, in memory)); } public void cmovg(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovg_r64_rm64, register, in memory)); } public void cmovge(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovge_r16_rm16, dst, src)); } public void cmovge(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovge_r32_rm32, dst, src)); } public void cmovge(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovge_r64_rm64, dst, src)); } public void cmovge(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovge_r16_rm16, register, in memory)); } public void cmovge(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovge_r32_rm32, register, in memory)); } public void cmovge(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovge_r64_rm64, register, in memory)); } public void cmovl(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovl_r16_rm16, dst, src)); } public void cmovl(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovl_r32_rm32, dst, src)); } public void cmovl(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovl_r64_rm64, dst, src)); } public void cmovl(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovl_r16_rm16, register, in memory)); } public void cmovl(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovl_r32_rm32, register, in memory)); } public void cmovl(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovl_r64_rm64, register, in memory)); } public void cmovle(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovle_r16_rm16, dst, src)); } public void cmovle(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovle_r32_rm32, dst, src)); } public void cmovle(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovle_r64_rm64, dst, src)); } public void cmovle(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovle_r16_rm16, register, in memory)); } public void cmovle(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovle_r32_rm32, register, in memory)); } public void cmovle(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovle_r64_rm64, register, in memory)); } public void cmovna(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r16_rm16, dst, src)); } public void cmovna(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r32_rm32, dst, src)); } public void cmovna(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovbe_r64_rm64, dst, src)); } public void cmovna(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r16_rm16, register, in memory)); } public void cmovna(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r32_rm32, register, in memory)); } public void cmovna(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovbe_r64_rm64, register, in memory)); } public void cmovnae(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, dst, src)); } public void cmovnae(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, dst, src)); } public void cmovnae(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, dst, src)); } public void cmovnae(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r16_rm16, register, in memory)); } public void cmovnae(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r32_rm32, register, in memory)); } public void cmovnae(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovb_r64_rm64, register, in memory)); } public void cmovnb(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, dst, src)); } public void cmovnb(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, dst, src)); } public void cmovnb(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, dst, src)); } public void cmovnb(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, register, in memory)); } public void cmovnb(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, register, in memory)); } public void cmovnb(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, register, in memory)); } public void cmovnbe(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmova_r16_rm16, dst, src)); } public void cmovnbe(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmova_r32_rm32, dst, src)); } public void cmovnbe(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmova_r64_rm64, dst, src)); } public void cmovnbe(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r16_rm16, register, in memory)); } public void cmovnbe(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r32_rm32, register, in memory)); } public void cmovnbe(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmova_r64_rm64, register, in memory)); } public void cmovnc(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, dst, src)); } public void cmovnc(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, dst, src)); } public void cmovnc(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, dst, src)); } public void cmovnc(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r16_rm16, register, in memory)); } public void cmovnc(AssemblerRegister32 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r32_rm32, register, in memory)); } public void cmovnc(AssemblerRegister64 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovae_r64_rm64, register, in memory)); } public void cmovne(AssemblerRegister16 dst, AssemblerRegister16 src) { AddInstruction(Instruction.Create(Code.Cmovne_r16_rm16, dst, src)); } public void cmovne(AssemblerRegister32 dst, AssemblerRegister32 src) { AddInstruction(Instruction.Create(Code.Cmovne_r32_rm32, dst, src)); } public void cmovne(AssemblerRegister64 dst, AssemblerRegister64 src) { AddInstruction(Instruction.Create(Code.Cmovne_r64_rm64, dst, src)); } public void cmovne(AssemblerRegister16 dst, AssemblerMemoryOperand src) { Register register = dst; MemoryOperand memory = src.ToMemoryOperand(Bitness); AddInstruction(Instruction.Create(Code.Cmovne_r16_rm16, register, in memory)); } public void cmovne(AssemblerRegister
BepInEx/plugins/DearImGuiInjection/System.Runtime.CompilerServices.Unsafe.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: CLSCompliant(false)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyFileVersion("6.0.21.52210")] [assembly: AssemblyInformationalVersion("6.0.0")] [assembly: AssemblyTitle("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyVersion("6.0.0.0")] namespace System.Runtime.CompilerServices { public static class Unsafe { [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static T Read<T>(void* source) { return Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return Unsafe.ReadUnaligned<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Write<T>(void* destination, T value) { Unsafe.Write(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { Unsafe.WriteUnaligned(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { Unsafe.Write(destination, source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { destination = Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return Unsafe.AsPointer(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void SkipInit<T>(out T value) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static int SizeOf<T>() { return Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static T As<T>(object o) where T : class { return (T)o; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref *(T*)source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T AsRef<T>(in T source) { return ref source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Unbox<T>(object box) where T : struct { return ref (T)box; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* Add<T>(void* source, int elementOffset) { return (byte*)source + (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Add<T>(ref T source, IntPtr elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T Add<T>(ref T source, [System.Runtime.Versioning.NonVersionable] nuint elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T AddByteOffset<T>(ref T source, [System.Runtime.Versioning.NonVersionable] nuint byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* Subtract<T>(void* source, int elementOffset) { return (byte*)source - (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Subtract<T>(ref T source, IntPtr elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T Subtract<T>(ref T source, [System.Runtime.Versioning.NonVersionable] nuint elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, IntPtr byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T SubtractByteOffset<T>(ref T source, [System.Runtime.Versioning.NonVersionable] nuint byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static IntPtr ByteOffset<T>(ref T origin, ref T target) { return Unsafe.ByteOffset(target: ref target, origin: ref origin); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return Unsafe.AreSame(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { return Unsafe.IsAddressGreaterThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool IsAddressLessThan<T>(ref T left, ref T right) { return Unsafe.IsAddressLessThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static bool IsNullRef<T>(ref T source) { return Unsafe.AsPointer(ref source) == null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static ref T NullRef<T>() { return ref *(T*)null; } } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] internal sealed class NonVersionableAttribute : Attribute { } } namespace System.Runtime.CompilerServices { internal sealed class IsReadOnlyAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] [Microsoft.CodeAnalysis.Embedded] [CompilerGenerated] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] A_0) { TransformFlags = A_0; } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } }
BepInEx/plugins/DearImGuiInjection/System.Memory.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.Buffers.Binary; using System.Buffers.Text; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Numerics; using System.Numerics.Hashing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using FxResources.System.Memory; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Memory")] [assembly: AssemblyDescription("System.Memory")] [assembly: AssemblyDefaultAlias("System.Memory")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.27617.02")] [assembly: AssemblyInformationalVersion("4.6.27617.02 @BuiltBy: dlab14-DDVSOWINAGE071 @Branch: release/2.1-MSRC @SrcCode: https://github.com/dotnet/corefx/tree/c6cf790234e063b855fcdb50f3fb1b3cfac73275")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.1.1")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsByRefLikeAttribute : Attribute { } } namespace FxResources.System.Memory { internal static class SR { } } namespace System { public readonly struct SequencePosition : IEquatable<SequencePosition> { private readonly object _object; private readonly int _integer; public SequencePosition(object @object, int integer) { _object = @object; _integer = integer; } [EditorBrowsable(EditorBrowsableState.Never)] public object GetObject() { return _object; } [EditorBrowsable(EditorBrowsableState.Never)] public int GetInteger() { return _integer; } public bool Equals(SequencePosition other) { if (_integer == other._integer) { return object.Equals(_object, other._object); } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { if (obj is SequencePosition other) { return Equals(other); } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { return HashHelpers.Combine(_object?.GetHashCode() ?? 0, _integer); } } internal static class ThrowHelper { internal static void ThrowArgumentNullException(System.ExceptionArgument argument) { throw CreateArgumentNullException(argument); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentNullException(System.ExceptionArgument argument) { return new ArgumentNullException(argument.ToString()); } internal static void ThrowArrayTypeMismatchException() { throw CreateArrayTypeMismatchException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArrayTypeMismatchException() { return new ArrayTypeMismatchException(); } internal static void ThrowArgumentException_InvalidTypeWithPointersNotSupported(Type type) { throw CreateArgumentException_InvalidTypeWithPointersNotSupported(type); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_InvalidTypeWithPointersNotSupported(Type type) { return new ArgumentException(System.SR.Format(System.SR.Argument_InvalidTypeWithPointersNotSupported, type)); } internal static void ThrowArgumentException_DestinationTooShort() { throw CreateArgumentException_DestinationTooShort(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_DestinationTooShort() { return new ArgumentException(System.SR.Argument_DestinationTooShort); } internal static void ThrowIndexOutOfRangeException() { throw CreateIndexOutOfRangeException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateIndexOutOfRangeException() { return new IndexOutOfRangeException(); } internal static void ThrowArgumentOutOfRangeException() { throw CreateArgumentOutOfRangeException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException() { return new ArgumentOutOfRangeException(); } internal static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument) { throw CreateArgumentOutOfRangeException(argument); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException(System.ExceptionArgument argument) { return new ArgumentOutOfRangeException(argument.ToString()); } internal static void ThrowArgumentOutOfRangeException_PrecisionTooLarge() { throw CreateArgumentOutOfRangeException_PrecisionTooLarge(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_PrecisionTooLarge() { return new ArgumentOutOfRangeException("precision", System.SR.Format(System.SR.Argument_PrecisionTooLarge, (byte)99)); } internal static void ThrowArgumentOutOfRangeException_SymbolDoesNotFit() { throw CreateArgumentOutOfRangeException_SymbolDoesNotFit(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_SymbolDoesNotFit() { return new ArgumentOutOfRangeException("symbol", System.SR.Argument_BadFormatSpecifier); } internal static void ThrowInvalidOperationException() { throw CreateInvalidOperationException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException() { return new InvalidOperationException(); } internal static void ThrowInvalidOperationException_OutstandingReferences() { throw CreateInvalidOperationException_OutstandingReferences(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_OutstandingReferences() { return new InvalidOperationException(System.SR.OutstandingReferences); } internal static void ThrowInvalidOperationException_UnexpectedSegmentType() { throw CreateInvalidOperationException_UnexpectedSegmentType(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_UnexpectedSegmentType() { return new InvalidOperationException(System.SR.UnexpectedSegmentType); } internal static void ThrowInvalidOperationException_EndPositionNotReached() { throw CreateInvalidOperationException_EndPositionNotReached(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateInvalidOperationException_EndPositionNotReached() { return new InvalidOperationException(System.SR.EndPositionNotReached); } internal static void ThrowArgumentOutOfRangeException_PositionOutOfRange() { throw CreateArgumentOutOfRangeException_PositionOutOfRange(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_PositionOutOfRange() { return new ArgumentOutOfRangeException("position"); } internal static void ThrowArgumentOutOfRangeException_OffsetOutOfRange() { throw CreateArgumentOutOfRangeException_OffsetOutOfRange(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentOutOfRangeException_OffsetOutOfRange() { return new ArgumentOutOfRangeException("offset"); } internal static void ThrowObjectDisposedException_ArrayMemoryPoolBuffer() { throw CreateObjectDisposedException_ArrayMemoryPoolBuffer(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateObjectDisposedException_ArrayMemoryPoolBuffer() { return new ObjectDisposedException("ArrayMemoryPoolBuffer"); } internal static void ThrowFormatException_BadFormatSpecifier() { throw CreateFormatException_BadFormatSpecifier(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateFormatException_BadFormatSpecifier() { return new FormatException(System.SR.Argument_BadFormatSpecifier); } internal static void ThrowArgumentException_OverlapAlignmentMismatch() { throw CreateArgumentException_OverlapAlignmentMismatch(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateArgumentException_OverlapAlignmentMismatch() { return new ArgumentException(System.SR.Argument_OverlapAlignmentMismatch); } internal static void ThrowNotSupportedException() { throw CreateThrowNotSupportedException(); } [MethodImpl(MethodImplOptions.NoInlining)] private static Exception CreateThrowNotSupportedException() { return new NotSupportedException(); } public static bool TryFormatThrowFormatException(out int bytesWritten) { bytesWritten = 0; ThrowFormatException_BadFormatSpecifier(); return false; } public static bool TryParseThrowFormatException<T>(out T value, out int bytesConsumed) { value = default(T); bytesConsumed = 0; ThrowFormatException_BadFormatSpecifier(); return false; } public static void ThrowArgumentValidationException<T>(ReadOnlySequenceSegment<T> startSegment, int startIndex, ReadOnlySequenceSegment<T> endSegment) { throw CreateArgumentValidationException(startSegment, startIndex, endSegment); } private static Exception CreateArgumentValidationException<T>(ReadOnlySequenceSegment<T> startSegment, int startIndex, ReadOnlySequenceSegment<T> endSegment) { if (startSegment == null) { return CreateArgumentNullException(System.ExceptionArgument.startSegment); } if (endSegment == null) { return CreateArgumentNullException(System.ExceptionArgument.endSegment); } if (startSegment != endSegment && startSegment.RunningIndex > endSegment.RunningIndex) { return CreateArgumentOutOfRangeException(System.ExceptionArgument.endSegment); } if ((uint)startSegment.Memory.Length < (uint)startIndex) { return CreateArgumentOutOfRangeException(System.ExceptionArgument.startIndex); } return CreateArgumentOutOfRangeException(System.ExceptionArgument.endIndex); } public static void ThrowArgumentValidationException(Array array, int start) { throw CreateArgumentValidationException(array, start); } private static Exception CreateArgumentValidationException(Array array, int start) { if (array == null) { return CreateArgumentNullException(System.ExceptionArgument.array); } if ((uint)start > (uint)array.Length) { return CreateArgumentOutOfRangeException(System.ExceptionArgument.start); } return CreateArgumentOutOfRangeException(System.ExceptionArgument.length); } public static void ThrowStartOrEndArgumentValidationException(long start) { throw CreateStartOrEndArgumentValidationException(start); } private static Exception CreateStartOrEndArgumentValidationException(long start) { if (start < 0) { return CreateArgumentOutOfRangeException(System.ExceptionArgument.start); } return CreateArgumentOutOfRangeException(System.ExceptionArgument.length); } } internal enum ExceptionArgument { length, start, minimumBufferSize, elementIndex, comparable, comparer, destination, offset, startSegment, endSegment, startIndex, endIndex, array, culture, manager } internal static class DecimalDecCalc { private static uint D32DivMod1E9(uint hi32, ref uint lo32) { ulong num = ((ulong)hi32 << 32) | lo32; lo32 = (uint)(num / 1000000000); return (uint)(num % 1000000000); } internal static uint DecDivMod1E9(ref MutableDecimal value) { return D32DivMod1E9(D32DivMod1E9(D32DivMod1E9(0u, ref value.High), ref value.Mid), ref value.Low); } internal static void DecAddInt32(ref MutableDecimal value, uint i) { if (D32AddCarry(ref value.Low, i) && D32AddCarry(ref value.Mid, 1u)) { D32AddCarry(ref value.High, 1u); } } private static bool D32AddCarry(ref uint value, uint i) { uint num = value; uint num2 = (value = num + i); if (num2 >= num) { return num2 < i; } return true; } internal static void DecMul10(ref MutableDecimal value) { MutableDecimal d = value; DecShiftLeft(ref value); DecShiftLeft(ref value); DecAdd(ref value, d); DecShiftLeft(ref value); } private static void DecShiftLeft(ref MutableDecimal value) { uint num = (((value.Low & 0x80000000u) != 0) ? 1u : 0u); uint num2 = (((value.Mid & 0x80000000u) != 0) ? 1u : 0u); value.Low <<= 1; value.Mid = (value.Mid << 1) | num; value.High = (value.High << 1) | num2; } private static void DecAdd(ref MutableDecimal value, MutableDecimal d) { if (D32AddCarry(ref value.Low, d.Low) && D32AddCarry(ref value.Mid, 1u)) { D32AddCarry(ref value.High, 1u); } if (D32AddCarry(ref value.Mid, d.Mid)) { D32AddCarry(ref value.High, 1u); } D32AddCarry(ref value.High, d.High); } } internal static class Number { private static class DoubleHelper { public unsafe static uint Exponent(double d) { return (*(uint*)((byte*)(&d) + 4) >> 20) & 0x7FFu; } public unsafe static ulong Mantissa(double d) { return *(uint*)(&d) | ((ulong)(uint)(*(int*)((byte*)(&d) + 4) & 0xFFFFF) << 32); } public unsafe static bool Sign(double d) { return *(uint*)((byte*)(&d) + 4) >> 31 != 0; } } internal const int DECIMAL_PRECISION = 29; private static readonly ulong[] s_rgval64Power10 = new ulong[30] { 11529215046068469760uL, 14411518807585587200uL, 18014398509481984000uL, 11258999068426240000uL, 14073748835532800000uL, 17592186044416000000uL, 10995116277760000000uL, 13743895347200000000uL, 17179869184000000000uL, 10737418240000000000uL, 13421772800000000000uL, 16777216000000000000uL, 10485760000000000000uL, 13107200000000000000uL, 16384000000000000000uL, 14757395258967641293uL, 11805916207174113035uL, 9444732965739290428uL, 15111572745182864686uL, 12089258196146291749uL, 9671406556917033399uL, 15474250491067253438uL, 12379400392853802751uL, 9903520314283042201uL, 15845632502852867522uL, 12676506002282294018uL, 10141204801825835215uL, 16225927682921336344uL, 12980742146337069075uL, 10384593717069655260uL }; private static readonly sbyte[] s_rgexp64Power10 = new sbyte[15] { 4, 7, 10, 14, 17, 20, 24, 27, 30, 34, 37, 40, 44, 47, 50 }; private static readonly ulong[] s_rgval64Power10By16 = new ulong[42] { 10240000000000000000uL, 11368683772161602974uL, 12621774483536188886uL, 14012984643248170708uL, 15557538194652854266uL, 17272337110188889248uL, 9588073174409622172uL, 10644899600020376798uL, 11818212630765741798uL, 13120851772591970216uL, 14567071740625403792uL, 16172698447808779622uL, 17955302187076837696uL, 9967194951097567532uL, 11065809325636130658uL, 12285516299433008778uL, 13639663065038175358uL, 15143067982934716296uL, 16812182738118149112uL, 9332636185032188787uL, 10361307573072618722uL, 16615349947311448416uL, 14965776766268445891uL, 13479973333575319909uL, 12141680576410806707uL, 10936253623915059637uL, 9850501549098619819uL, 17745086042373215136uL, 15983352577617880260uL, 14396524142538228461uL, 12967236152753103031uL, 11679847981112819795uL, 10520271803096747049uL, 9475818434452569218uL, 17070116948172427008uL, 15375394465392026135uL, 13848924157002783096uL, 12474001934591998882uL, 11235582092889474480uL, 10120112665365530972uL, 18230774251475056952uL, 16420821625123739930uL }; private static readonly short[] s_rgexp64Power10By16 = new short[21] { 54, 107, 160, 213, 266, 319, 373, 426, 479, 532, 585, 638, 691, 745, 798, 851, 904, 957, 1010, 1064, 1117 }; public static void RoundNumber(ref NumberBuffer number, int pos) { Span<byte> digits = number.Digits; int i; for (i = 0; i < pos && digits[i] != 0; i++) { } if (i == pos && digits[i] >= 53) { while (i > 0 && digits[i - 1] == 57) { i--; } if (i > 0) { digits[i - 1]++; } else { number.Scale++; digits[0] = 49; i = 1; } } else { while (i > 0 && digits[i - 1] == 48) { i--; } } if (i == 0) { number.Scale = 0; number.IsNegative = false; } digits[i] = 0; } internal static bool NumberBufferToDouble(ref NumberBuffer number, out double value) { double num = NumberToDouble(ref number); uint num2 = DoubleHelper.Exponent(num); ulong num3 = DoubleHelper.Mantissa(num); switch (num2) { case 2047u: value = 0.0; return false; case 0u: if (num3 == 0L) { num = 0.0; } break; } value = num; return true; } public unsafe static bool NumberBufferToDecimal(ref NumberBuffer number, ref decimal value) { MutableDecimal source = default(MutableDecimal); byte* ptr = number.UnsafeDigits; int num = number.Scale; if (*ptr == 0) { if (num > 0) { num = 0; } } else { if (num > 29) { return false; } while ((num > 0 || (*ptr != 0 && num > -28)) && (source.High < 429496729 || (source.High == 429496729 && (source.Mid < 2576980377u || (source.Mid == 2576980377u && (source.Low < 2576980377u || (source.Low == 2576980377u && *ptr <= 53))))))) { DecimalDecCalc.DecMul10(ref source); if (*ptr != 0) { DecimalDecCalc.DecAddInt32(ref source, (uint)(*(ptr++) - 48)); } num--; } if (*(ptr++) >= 53) { bool flag = true; if (*(ptr - 1) == 53 && *(ptr - 2) % 2 == 0) { int num2 = 20; while (*ptr == 48 && num2 != 0) { ptr++; num2--; } if (*ptr == 0 || num2 == 0) { flag = false; } } if (flag) { DecimalDecCalc.DecAddInt32(ref source, 1u); if ((source.High | source.Mid | source.Low) == 0) { source.High = 429496729u; source.Mid = 2576980377u; source.Low = 2576980378u; num++; } } } } if (num > 0) { return false; } if (num <= -29) { source.High = 0u; source.Low = 0u; source.Mid = 0u; source.Scale = 28; } else { source.Scale = -num; } source.IsNegative = number.IsNegative; value = Unsafe.As<MutableDecimal, decimal>(ref source); return true; } public static void DecimalToNumber(decimal value, ref NumberBuffer number) { ref MutableDecimal reference = ref Unsafe.As<decimal, MutableDecimal>(ref value); Span<byte> digits = number.Digits; number.IsNegative = reference.IsNegative; int num = 29; while ((reference.Mid != 0) | (reference.High != 0)) { uint num2 = DecimalDecCalc.DecDivMod1E9(ref reference); for (int i = 0; i < 9; i++) { digits[--num] = (byte)(num2 % 10 + 48); num2 /= 10; } } for (uint num3 = reference.Low; num3 != 0; num3 /= 10) { digits[--num] = (byte)(num3 % 10 + 48); } int num4 = 29 - num; number.Scale = num4 - reference.Scale; Span<byte> digits2 = number.Digits; int index = 0; while (--num4 >= 0) { digits2[index++] = digits[num++]; } digits2[index] = 0; } private static uint DigitsToInt(ReadOnlySpan<byte> digits, int count) { uint value; int bytesConsumed; bool flag = Utf8Parser.TryParse(digits.Slice(0, count), out value, out bytesConsumed, 'D'); return value; } private static ulong Mul32x32To64(uint a, uint b) { return (ulong)a * (ulong)b; } private static ulong Mul64Lossy(ulong a, ulong b, ref int pexp) { ulong num = Mul32x32To64((uint)(a >> 32), (uint)(b >> 32)) + (Mul32x32To64((uint)(a >> 32), (uint)b) >> 32) + (Mul32x32To64((uint)a, (uint)(b >> 32)) >> 32); if ((num & 0x8000000000000000uL) == 0L) { num <<= 1; pexp--; } return num; } private static int abs(int value) { if (value < 0) { return -value; } return value; } private unsafe static double NumberToDouble(ref NumberBuffer number) { ReadOnlySpan<byte> digits = number.Digits; int i = 0; int numDigits = number.NumDigits; int num = numDigits; for (; digits[i] == 48; i++) { num--; } if (num == 0) { return 0.0; } int num2 = Math.Min(num, 9); num -= num2; ulong num3 = DigitsToInt(digits, num2); if (num > 0) { num2 = Math.Min(num, 9); num -= num2; uint b = (uint)(s_rgval64Power10[num2 - 1] >> 64 - s_rgexp64Power10[num2 - 1]); num3 = Mul32x32To64((uint)num3, b) + DigitsToInt(digits.Slice(9), num2); } int num4 = number.Scale - (numDigits - num); int num5 = abs(num4); if (num5 >= 352) { ulong num6 = ((num4 > 0) ? 9218868437227405312uL : 0); if (number.IsNegative) { num6 |= 0x8000000000000000uL; } return *(double*)(&num6); } int pexp = 64; if ((num3 & 0xFFFFFFFF00000000uL) == 0L) { num3 <<= 32; pexp -= 32; } if ((num3 & 0xFFFF000000000000uL) == 0L) { num3 <<= 16; pexp -= 16; } if ((num3 & 0xFF00000000000000uL) == 0L) { num3 <<= 8; pexp -= 8; } if ((num3 & 0xF000000000000000uL) == 0L) { num3 <<= 4; pexp -= 4; } if ((num3 & 0xC000000000000000uL) == 0L) { num3 <<= 2; pexp -= 2; } if ((num3 & 0x8000000000000000uL) == 0L) { num3 <<= 1; pexp--; } int num7 = num5 & 0xF; if (num7 != 0) { int num8 = s_rgexp64Power10[num7 - 1]; pexp += ((num4 < 0) ? (-num8 + 1) : num8); ulong b2 = s_rgval64Power10[num7 + ((num4 < 0) ? 15 : 0) - 1]; num3 = Mul64Lossy(num3, b2, ref pexp); } num7 = num5 >> 4; if (num7 != 0) { int num9 = s_rgexp64Power10By16[num7 - 1]; pexp += ((num4 < 0) ? (-num9 + 1) : num9); ulong b3 = s_rgval64Power10By16[num7 + ((num4 < 0) ? 21 : 0) - 1]; num3 = Mul64Lossy(num3, b3, ref pexp); } if (((uint)(int)num3 & 0x400u) != 0) { ulong num10 = num3 + 1023 + (ulong)(((int)num3 >> 11) & 1); if (num10 < num3) { num10 = (num10 >> 1) | 0x8000000000000000uL; pexp++; } num3 = num10; } pexp += 1022; num3 = ((pexp <= 0) ? ((pexp == -52 && num3 >= 9223372036854775896uL) ? 1 : ((pexp > -52) ? (num3 >> -pexp + 11 + 1) : 0)) : ((pexp < 2047) ? ((ulong)((long)pexp << 52) + ((num3 >> 11) & 0xFFFFFFFFFFFFFL)) : 9218868437227405312uL)); if (number.IsNegative) { num3 |= 0x8000000000000000uL; } return *(double*)(&num3); } } internal ref struct NumberBuffer { public int Scale; public bool IsNegative; public const int BufferSize = 51; private byte _b0; private byte _b1; private byte _b2; private byte _b3; private byte _b4; private byte _b5; private byte _b6; private byte _b7; private byte _b8; private byte _b9; private byte _b10; private byte _b11; private byte _b12; private byte _b13; private byte _b14; private byte _b15; private byte _b16; private byte _b17; private byte _b18; private byte _b19; private byte _b20; private byte _b21; private byte _b22; private byte _b23; private byte _b24; private byte _b25; private byte _b26; private byte _b27; private byte _b28; private byte _b29; private byte _b30; private byte _b31; private byte _b32; private byte _b33; private byte _b34; private byte _b35; private byte _b36; private byte _b37; private byte _b38; private byte _b39; private byte _b40; private byte _b41; private byte _b42; private byte _b43; private byte _b44; private byte _b45; private byte _b46; private byte _b47; private byte _b48; private byte _b49; private byte _b50; public unsafe Span<byte> Digits => new Span<byte>(Unsafe.AsPointer(ref _b0), 51); public unsafe byte* UnsafeDigits => (byte*)Unsafe.AsPointer(ref _b0); public int NumDigits => Digits.IndexOf<byte>(0); [Conditional("DEBUG")] public void CheckConsistency() { } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append('['); stringBuilder.Append('"'); Span<byte> digits = Digits; for (int i = 0; i < 51; i++) { byte b = digits[i]; if (b == 0) { break; } stringBuilder.Append((char)b); } stringBuilder.Append('"'); stringBuilder.Append(", Scale = " + Scale); stringBuilder.Append(", IsNegative = " + IsNegative); stringBuilder.Append(']'); return stringBuilder.ToString(); } } [DebuggerTypeProxy(typeof(System.MemoryDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly struct Memory<T> { private readonly object _object; private readonly int _index; private readonly int _length; private const int RemoveFlagsBitMask = int.MaxValue; public static Memory<T> Empty => default(Memory<T>); public int Length => _length & 0x7FFFFFFF; public bool IsEmpty => (_length & 0x7FFFFFFF) == 0; public Span<T> Span { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { Span<T> result; if (_index < 0) { result = ((MemoryManager<T>)_object).GetSpan(); return result.Slice(_index & 0x7FFFFFFF, _length); } if (typeof(T) == typeof(char) && _object is string text) { result = new Span<T>(Unsafe.As<Pinnable<T>>(text), MemoryExtensions.StringAdjustment, text.Length); return result.Slice(_index, _length); } if (_object != null) { return new Span<T>((T[])_object, _index, _length & 0x7FFFFFFF); } result = default(Span<T>); return result; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Memory(T[] array) { if (array == null) { this = default(Memory<T>); return; } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } _object = array; _index = 0; _length = array.Length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Memory(T[] array, int start) { if (array == null) { if (start != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default(Memory<T>); return; } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = array.Length - start; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Memory(T[] array, int start, int length) { if (array == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default(Memory<T>); return; } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Memory(MemoryManager<T> manager, int length) { if (length < 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = manager; _index = int.MinValue; _length = length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Memory(MemoryManager<T> manager, int start, int length) { if (length < 0 || start < 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = manager; _index = start | int.MinValue; _length = length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Memory(object obj, int start, int length) { _object = obj; _index = start; _length = length; } public static implicit operator Memory<T>(T[] array) { return new Memory<T>(array); } public static implicit operator Memory<T>(ArraySegment<T> segment) { return new Memory<T>(segment.Array, segment.Offset, segment.Count); } public static implicit operator ReadOnlyMemory<T>(Memory<T> memory) { return Unsafe.As<Memory<T>, ReadOnlyMemory<T>>(ref memory); } public override string ToString() { if (typeof(T) == typeof(char)) { if (!(_object is string text)) { return Span.ToString(); } return text.Substring(_index, _length & 0x7FFFFFFF); } return $"System.Memory<{typeof(T).Name}>[{_length & 0x7FFFFFFF}]"; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Memory<T> Slice(int start) { int length = _length; int num = length & 0x7FFFFFFF; if ((uint)start > (uint)num) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new Memory<T>(_object, _index + start, length - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Memory<T> Slice(int start, int length) { int length2 = _length; int num = length2 & 0x7FFFFFFF; if ((uint)start > (uint)num || (uint)length > (uint)(num - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } return new Memory<T>(_object, _index + start, length | (length2 & int.MinValue)); } public void CopyTo(Memory<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory<T> destination) { return Span.TryCopyTo(destination.Span); } public unsafe MemoryHandle Pin() { if (_index < 0) { return ((MemoryManager<T>)_object).Pin(_index & 0x7FFFFFFF); } if (typeof(T) == typeof(char) && _object is string value) { GCHandle handle = GCHandle.Alloc(value, GCHandleType.Pinned); void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index); return new MemoryHandle(pointer, handle); } if (_object is T[] array) { if (_length < 0) { void* pointer2 = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index); return new MemoryHandle(pointer2); } GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned); void* pointer3 = Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index); return new MemoryHandle(pointer3, handle2); } return default(MemoryHandle); } public T[] ToArray() { return Span.ToArray(); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { if (obj is ReadOnlyMemory<T> readOnlyMemory) { return readOnlyMemory.Equals(this); } if (obj is Memory<T> other) { return Equals(other); } return false; } public bool Equals(Memory<T> other) { if (_object == other._object && _index == other._index) { return _length == other._length; } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { if (_object == null) { return 0; } int hashCode = _object.GetHashCode(); int index = _index; int hashCode2 = index.GetHashCode(); index = _length; return CombineHashCodes(hashCode, hashCode2, index.GetHashCode()); } private static int CombineHashCodes(int left, int right) { return ((left << 5) + left) ^ right; } private static int CombineHashCodes(int h1, int h2, int h3) { return CombineHashCodes(CombineHashCodes(h1, h2), h3); } } internal sealed class MemoryDebugView<T> { private readonly ReadOnlyMemory<T> _memory; [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items => _memory.ToArray(); public MemoryDebugView(Memory<T> memory) { _memory = memory; } public MemoryDebugView(ReadOnlyMemory<T> memory) { _memory = memory; } } public static class MemoryExtensions { internal static readonly IntPtr StringAdjustment = MeasureStringAdjustment(); public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span) { return span.TrimStart().TrimEnd(); } public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span) { int i; for (i = 0; i < span.Length && char.IsWhiteSpace(span[i]); i++) { } return span.Slice(i); } public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span) { int num = span.Length - 1; while (num >= 0 && char.IsWhiteSpace(span[num])) { num--; } return span.Slice(0, num + 1); } public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, char trimChar) { return span.TrimStart(trimChar).TrimEnd(trimChar); } public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, char trimChar) { int i; for (i = 0; i < span.Length && span[i] == trimChar; i++) { } return span.Slice(i); } public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, char trimChar) { int num = span.Length - 1; while (num >= 0 && span[num] == trimChar) { num--; } return span.Slice(0, num + 1); } public static ReadOnlySpan<char> Trim(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars) { return span.TrimStart(trimChars).TrimEnd(trimChars); } public static ReadOnlySpan<char> TrimStart(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars) { if (trimChars.IsEmpty) { return span.TrimStart(); } int i; for (i = 0; i < span.Length; i++) { int num = 0; while (num < trimChars.Length) { if (span[i] != trimChars[num]) { num++; continue; } goto IL_003c; } break; IL_003c:; } return span.Slice(i); } public static ReadOnlySpan<char> TrimEnd(this ReadOnlySpan<char> span, ReadOnlySpan<char> trimChars) { if (trimChars.IsEmpty) { return span.TrimEnd(); } int num; for (num = span.Length - 1; num >= 0; num--) { int num2 = 0; while (num2 < trimChars.Length) { if (span[num] != trimChars[num2]) { num2++; continue; } goto IL_0044; } break; IL_0044:; } return span.Slice(0, num + 1); } public static bool IsWhiteSpace(this ReadOnlySpan<char> span) { for (int i = 0; i < span.Length; i++) { if (!char.IsWhiteSpace(span[i])) { return false; } } return true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length); } return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length); } return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOf<T>(this Span<T> span, T value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length); } return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length); } return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool SequenceEqual<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IEquatable<T> { int length = span.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length == other.Length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (NUInt)length * size); } return false; } if (length == other.Length) { return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length); } return false; } public static int SequenceCompareTo<T>(this Span<T> span, ReadOnlySpan<T> other) where T : IComparable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length); } return System.SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length); } return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length); } return System.SpanHelpers.IndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value), span.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, char>(ref value), span.Length); } return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), value, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOf(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), value.Length); } return System.SpanHelpers.LastIndexOf(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(value), value.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.IndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length); } return System.SpanHelpers.IndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), span.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), Unsafe.As<T, byte>(ref value0), Unsafe.As<T, byte>(ref value1), Unsafe.As<T, byte>(ref value2), span.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), value0, value1, value2, span.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LastIndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.LastIndexOfAny(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values)), values.Length); } return System.SpanHelpers.LastIndexOfAny(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(values), values.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool SequenceEqual<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IEquatable<T> { int length = span.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length == other.Length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), (NUInt)length * size); } return false; } if (length == other.Length) { return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other), length); } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int SequenceCompareTo<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IComparable<T> { if (typeof(T) == typeof(byte)) { return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(other)), other.Length); } if (typeof(T) == typeof(char)) { return System.SpanHelpers.SequenceCompareTo(ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(span)), span.Length, ref Unsafe.As<T, char>(ref MemoryMarshal.GetReference(other)), other.Length); } return System.SpanHelpers.SequenceCompareTo(ref MemoryMarshal.GetReference(span), span.Length, ref MemoryMarshal.GetReference(other), other.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { int length = value.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length <= span.Length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (NUInt)length * size); } return false; } if (length <= span.Length) { return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length); } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool StartsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { int length = value.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length <= span.Length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(span)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (NUInt)length * size); } return false; } if (length <= span.Length) { return System.SpanHelpers.SequenceEqual(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(value), length); } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsWith<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { int length = span.Length; int length2 = value.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length2 <= length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (NUInt)length2 * size); } return false; } if (length2 <= length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2), ref MemoryMarshal.GetReference(value), length2); } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EndsWith<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T> { int length = span.Length; int length2 = value.Length; if (default(T) != null && IsTypeComparableAsBytes<T>(out var size)) { if (length2 <= length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.As<T, byte>(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2)), ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(value)), (NUInt)length2 * size); } return false; } if (length2 <= length) { return System.SpanHelpers.SequenceEqual(ref Unsafe.Add(ref MemoryMarshal.GetReference(span), length - length2), ref MemoryMarshal.GetReference(value), length2); } return false; } public static void Reverse<T>(this Span<T> span) { ref T reference = ref MemoryMarshal.GetReference(span); int num = 0; int num2 = span.Length - 1; while (num < num2) { T val = Unsafe.Add(ref reference, num); Unsafe.Add(ref reference, num) = Unsafe.Add(ref reference, num2); Unsafe.Add(ref reference, num2) = val; num++; num2--; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this T[] array) { return new Span<T>(array); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this T[] array, int start, int length) { return new Span<T>(array, start, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this ArraySegment<T> segment) { return new Span<T>(segment.Array, segment.Offset, segment.Count); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start) { if ((uint)start > segment.Count) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new Span<T>(segment.Array, segment.Offset + start, segment.Count - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this ArraySegment<T> segment, int start, int length) { if ((uint)start > segment.Count) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } if ((uint)length > segment.Count - start) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.length); } return new Span<T>(segment.Array, segment.Offset + start, length); } public static Memory<T> AsMemory<T>(this T[] array) { return new Memory<T>(array); } public static Memory<T> AsMemory<T>(this T[] array, int start) { return new Memory<T>(array, start); } public static Memory<T> AsMemory<T>(this T[] array, int start, int length) { return new Memory<T>(array, start, length); } public static Memory<T> AsMemory<T>(this ArraySegment<T> segment) { return new Memory<T>(segment.Array, segment.Offset, segment.Count); } public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start) { if ((uint)start > segment.Count) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new Memory<T>(segment.Array, segment.Offset + start, segment.Count - start); } public static Memory<T> AsMemory<T>(this ArraySegment<T> segment, int start, int length) { if ((uint)start > segment.Count) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } if ((uint)length > segment.Count - start) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.length); } return new Memory<T>(segment.Array, segment.Offset + start, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CopyTo<T>(this T[] source, Span<T> destination) { new ReadOnlySpan<T>(source).CopyTo(destination); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CopyTo<T>(this T[] source, Memory<T> destination) { source.CopyTo(destination.Span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other) { return ((ReadOnlySpan<T>)span).Overlaps(other); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool Overlaps<T>(this Span<T> span, ReadOnlySpan<T> other, out int elementOffset) { return ((ReadOnlySpan<T>)span).Overlaps(other, out elementOffset); } public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other) { if (span.IsEmpty || other.IsEmpty) { return false; } IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other)); if (Unsafe.SizeOf<IntPtr>() == 4) { if ((uint)(int)intPtr >= (uint)(span.Length * Unsafe.SizeOf<T>())) { return (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>())); } return true; } if ((ulong)(long)intPtr >= (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>())) { return (ulong)(long)intPtr > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>())); } return true; } public static bool Overlaps<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> other, out int elementOffset) { if (span.IsEmpty || other.IsEmpty) { elementOffset = 0; return false; } IntPtr intPtr = Unsafe.ByteOffset(ref MemoryMarshal.GetReference(span), ref MemoryMarshal.GetReference(other)); if (Unsafe.SizeOf<IntPtr>() == 4) { if ((uint)(int)intPtr < (uint)(span.Length * Unsafe.SizeOf<T>()) || (uint)(int)intPtr > (uint)(-(other.Length * Unsafe.SizeOf<T>()))) { if ((int)intPtr % Unsafe.SizeOf<T>() != 0) { System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch(); } elementOffset = (int)intPtr / Unsafe.SizeOf<T>(); return true; } elementOffset = 0; return false; } if ((ulong)(long)intPtr < (ulong)((long)span.Length * (long)Unsafe.SizeOf<T>()) || (ulong)(long)intPtr > (ulong)(-((long)other.Length * (long)Unsafe.SizeOf<T>()))) { if ((long)intPtr % Unsafe.SizeOf<T>() != 0L) { System.ThrowHelper.ThrowArgumentException_OverlapAlignmentMismatch(); } elementOffset = (int)((long)intPtr / Unsafe.SizeOf<T>()); return true; } elementOffset = 0; return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T>(this Span<T> span, IComparable<T> comparable) { return span.BinarySearch<T, IComparable<T>>(comparable); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparable>(this Span<T> span, TComparable comparable) where TComparable : IComparable<T> { return BinarySearch((ReadOnlySpan<T>)span, comparable); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparer>(this Span<T> span, T value, TComparer comparer) where TComparer : IComparer<T> { return ((ReadOnlySpan<T>)span).BinarySearch(value, comparer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T>(this ReadOnlySpan<T> span, IComparable<T> comparable) { return MemoryExtensions.BinarySearch<T, IComparable<T>>(span, comparable); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T> { return System.SpanHelpers.BinarySearch(span, comparable); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparer>(this ReadOnlySpan<T> span, T value, TComparer comparer) where TComparer : IComparer<T> { if (comparer == null) { System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.comparer); } System.SpanHelpers.ComparerComparable<T, TComparer> comparable = new System.SpanHelpers.ComparerComparable<T, TComparer>(value, comparer); return BinarySearch(span, comparable); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool IsTypeComparableAsBytes<T>(out NUInt size) { if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte)) { size = (NUInt)1; return true; } if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort)) { size = (NUInt)2; return true; } if (typeof(T) == typeof(int) || typeof(T) == typeof(uint)) { size = (NUInt)4; return true; } if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong)) { size = (NUInt)8; return true; } size = default(NUInt); return false; } public static Span<T> AsSpan<T>(this T[] array, int start) { return Span<T>.Create(array, start); } public static bool Contains(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType) { return span.IndexOf(value, comparisonType) >= 0; } public static bool Equals(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType) { switch (comparisonType) { case StringComparison.Ordinal: return span.SequenceEqual(other); case StringComparison.OrdinalIgnoreCase: if (span.Length != other.Length) { return false; } return EqualsOrdinalIgnoreCase(span, other); default: return span.ToString().Equals(other.ToString(), comparisonType); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool EqualsOrdinalIgnoreCase(ReadOnlySpan<char> span, ReadOnlySpan<char> other) { if (other.Length == 0) { return true; } return CompareToOrdinalIgnoreCase(span, other) == 0; } public static int CompareTo(this ReadOnlySpan<char> span, ReadOnlySpan<char> other, StringComparison comparisonType) { return comparisonType switch { StringComparison.Ordinal => span.SequenceCompareTo(other), StringComparison.OrdinalIgnoreCase => CompareToOrdinalIgnoreCase(span, other), _ => string.Compare(span.ToString(), other.ToString(), comparisonType), }; } private unsafe static int CompareToOrdinalIgnoreCase(ReadOnlySpan<char> strA, ReadOnlySpan<char> strB) { int num = Math.Min(strA.Length, strB.Length); int num2 = num; fixed (char* ptr = &MemoryMarshal.GetReference(strA)) { fixed (char* ptr3 = &MemoryMarshal.GetReference(strB)) { char* ptr2 = ptr; char* ptr4 = ptr3; while (num != 0 && *ptr2 <= '\u007f' && *ptr4 <= '\u007f') { int num3 = *ptr2; int num4 = *ptr4; if (num3 == num4) { ptr2++; ptr4++; num--; continue; } if ((uint)(num3 - 97) <= 25u) { num3 -= 32; } if ((uint)(num4 - 97) <= 25u) { num4 -= 32; } if (num3 != num4) { return num3 - num4; } ptr2++; ptr4++; num--; } if (num == 0) { return strA.Length - strB.Length; } num2 -= num; return string.Compare(strA.Slice(num2).ToString(), strB.Slice(num2).ToString(), StringComparison.OrdinalIgnoreCase); } } } public static int IndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType) { if (comparisonType == StringComparison.Ordinal) { return span.IndexOf(value); } return span.ToString().IndexOf(value.ToString(), comparisonType); } public static int ToLower(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo culture) { if (culture == null) { System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.culture); } if (destination.Length < source.Length) { return -1; } string text = source.ToString(); string text2 = text.ToLower(culture); AsSpan(text2).CopyTo(destination); return source.Length; } public static int ToLowerInvariant(this ReadOnlySpan<char> source, Span<char> destination) { return source.ToLower(destination, CultureInfo.InvariantCulture); } public static int ToUpper(this ReadOnlySpan<char> source, Span<char> destination, CultureInfo culture) { if (culture == null) { System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.culture); } if (destination.Length < source.Length) { return -1; } string text = source.ToString(); string text2 = text.ToUpper(culture); AsSpan(text2).CopyTo(destination); return source.Length; } public static int ToUpperInvariant(this ReadOnlySpan<char> source, Span<char> destination) { return source.ToUpper(destination, CultureInfo.InvariantCulture); } public static bool EndsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType) { switch (comparisonType) { case StringComparison.Ordinal: return span.EndsWith(value); case StringComparison.OrdinalIgnoreCase: if (value.Length <= span.Length) { return EqualsOrdinalIgnoreCase(span.Slice(span.Length - value.Length), value); } return false; default: { string text = span.ToString(); string value2 = value.ToString(); return text.EndsWith(value2, comparisonType); } } } public static bool StartsWith(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType) { switch (comparisonType) { case StringComparison.Ordinal: return span.StartsWith(value); case StringComparison.OrdinalIgnoreCase: if (value.Length <= span.Length) { return EqualsOrdinalIgnoreCase(span.Slice(0, value.Length), value); } return false; default: { string text = span.ToString(); string value2 = value.ToString(); return text.StartsWith(value2, comparisonType); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan<char> AsSpan(this string text) { if (text == null) { return default(ReadOnlySpan<char>); } return new ReadOnlySpan<char>(Unsafe.As<Pinnable<char>>(text), StringAdjustment, text.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan<char> AsSpan(this string text, int start) { if (text == null) { if (start != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return default(ReadOnlySpan<char>); } if ((uint)start > (uint)text.Length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlySpan<char>(Unsafe.As<Pinnable<char>>(text), StringAdjustment + start * 2, text.Length - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan<char> AsSpan(this string text, int start, int length) { if (text == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return default(ReadOnlySpan<char>); } if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlySpan<char>(Unsafe.As<Pinnable<char>>(text), StringAdjustment + start * 2, length); } public static ReadOnlyMemory<char> AsMemory(this string text) { if (text == null) { return default(ReadOnlyMemory<char>); } return new ReadOnlyMemory<char>(text, 0, text.Length); } public static ReadOnlyMemory<char> AsMemory(this string text, int start) { if (text == null) { if (start != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return default(ReadOnlyMemory<char>); } if ((uint)start > (uint)text.Length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlyMemory<char>(text, start, text.Length - start); } public static ReadOnlyMemory<char> AsMemory(this string text, int start, int length) { if (text == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return default(ReadOnlyMemory<char>); } if ((uint)start > (uint)text.Length || (uint)length > (uint)(text.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlyMemory<char>(text, start, length); } private unsafe static IntPtr MeasureStringAdjustment() { string text = "a"; fixed (char* source = text) { return Unsafe.ByteOffset(ref Unsafe.As<Pinnable<char>>(text).Data, ref Unsafe.AsRef<char>(source)); } } } [DebuggerTypeProxy(typeof(System.MemoryDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly struct ReadOnlyMemory<T> { private readonly object _object; private readonly int _index; private readonly int _length; internal const int RemoveFlagsBitMask = int.MaxValue; public static ReadOnlyMemory<T> Empty => default(ReadOnlyMemory<T>); public int Length => _length & 0x7FFFFFFF; public bool IsEmpty => (_length & 0x7FFFFFFF) == 0; public ReadOnlySpan<T> Span { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (_index < 0) { return ((MemoryManager<T>)_object).GetSpan().Slice(_index & 0x7FFFFFFF, _length); } ReadOnlySpan<T> result; if (typeof(T) == typeof(char) && _object is string text) { result = new ReadOnlySpan<T>(Unsafe.As<Pinnable<T>>(text), MemoryExtensions.StringAdjustment, text.Length); return result.Slice(_index, _length); } if (_object != null) { return new ReadOnlySpan<T>((T[])_object, _index, _length & 0x7FFFFFFF); } result = default(ReadOnlySpan<T>); return result; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory(T[] array) { if (array == null) { this = default(ReadOnlyMemory<T>); return; } _object = array; _index = 0; _length = array.Length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory(T[] array, int start, int length) { if (array == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } this = default(ReadOnlyMemory<T>); return; } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(); } _object = array; _index = start; _length = length; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ReadOnlyMemory(object obj, int start, int length) { _object = obj; _index = start; _length = length; } public static implicit operator ReadOnlyMemory<T>(T[] array) { return new ReadOnlyMemory<T>(array); } public static implicit operator ReadOnlyMemory<T>(ArraySegment<T> segment) { return new ReadOnlyMemory<T>(segment.Array, segment.Offset, segment.Count); } public override string ToString() { if (typeof(T) == typeof(char)) { if (!(_object is string text)) { return Span.ToString(); } return text.Substring(_index, _length & 0x7FFFFFFF); } return $"System.ReadOnlyMemory<{typeof(T).Name}>[{_length & 0x7FFFFFFF}]"; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory<T> Slice(int start) { int length = _length; int num = length & 0x7FFFFFFF; if ((uint)start > (uint)num) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlyMemory<T>(_object, _index + start, length - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyMemory<T> Slice(int start, int length) { int length2 = _length; int num = _length & 0x7FFFFFFF; if ((uint)start > (uint)num || (uint)length > (uint)(num - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return new ReadOnlyMemory<T>(_object, _index + start, length | (length2 & int.MinValue)); } public void CopyTo(Memory<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory<T> destination) { return Span.TryCopyTo(destination.Span); } public unsafe MemoryHandle Pin() { if (_index < 0) { return ((MemoryManager<T>)_object).Pin(_index & 0x7FFFFFFF); } if (typeof(T) == typeof(char) && _object is string value) { GCHandle handle = GCHandle.Alloc(value, GCHandleType.Pinned); void* pointer = Unsafe.Add<T>((void*)handle.AddrOfPinnedObject(), _index); return new MemoryHandle(pointer, handle); } if (_object is T[] array) { if (_length < 0) { void* pointer2 = Unsafe.Add<T>(Unsafe.AsPointer(ref MemoryMarshal.GetReference<T>(array)), _index); return new MemoryHandle(pointer2); } GCHandle handle2 = GCHandle.Alloc(array, GCHandleType.Pinned); void* pointer3 = Unsafe.Add<T>((void*)handle2.AddrOfPinnedObject(), _index); return new MemoryHandle(pointer3, handle2); } return default(MemoryHandle); } public T[] ToArray() { return Span.ToArray(); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { if (obj is ReadOnlyMemory<T> other) { return Equals(other); } if (obj is Memory<T> memory) { return Equals(memory); } return false; } public bool Equals(ReadOnlyMemory<T> other) { if (_object == other._object && _index == other._index) { return _length == other._length; } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { if (_object == null) { return 0; } int hashCode = _object.GetHashCode(); int index = _index; int hashCode2 = index.GetHashCode(); index = _length; return CombineHashCodes(hashCode, hashCode2, index.GetHashCode()); } private static int CombineHashCodes(int left, int right) { return ((left << 5) + left) ^ right; } private static int CombineHashCodes(int h1, int h2, int h3) { return CombineHashCodes(CombineHashCodes(h1, h2), h3); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal object GetObjectStartLength(out int start, out int length) { start = _index; length = _length; return _object; } } [DebuggerTypeProxy(typeof(System.SpanDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] [DebuggerTypeProxy(typeof(System.SpanDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly ref struct ReadOnlySpan<T> { public ref struct Enumerator { private readonly ReadOnlySpan<T> _span; private int _index; public ref readonly T Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref _span[_index]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Enumerator(ReadOnlySpan<T> span) { _span = span; _index = -1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { int num = _index + 1; if (num < _span.Length) { _index = num; return true; } return false; } } private readonly Pinnable<T> _pinnable; private readonly IntPtr _byteOffset; private readonly int _length; public int Length => _length; public bool IsEmpty => _length == 0; public static ReadOnlySpan<T> Empty => default(ReadOnlySpan<T>); public unsafe ref readonly T this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if ((uint)index >= (uint)_length) { System.ThrowHelper.ThrowIndexOutOfRangeException(); } if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.Add(ref Unsafe.AsRef<T>(byteOffset.ToPointer()), index); } return ref Unsafe.Add(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset), index); } } internal Pinnable<T> Pinnable => _pinnable; internal IntPtr ByteOffset => _byteOffset; public static bool operator !=(ReadOnlySpan<T> left, ReadOnlySpan<T> right) { return !(left == right); } [Obsolete("Equals() on ReadOnlySpan will always throw an exception. Use == instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { throw new NotSupportedException(System.SR.NotSupported_CannotCallEqualsOnSpan); } [Obsolete("GetHashCode() on ReadOnlySpan will always throw an exception.")] [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { throw new NotSupportedException(System.SR.NotSupported_CannotCallGetHashCodeOnSpan); } public static implicit operator ReadOnlySpan<T>(T[] array) { return new ReadOnlySpan<T>(array); } public static implicit operator ReadOnlySpan<T>(ArraySegment<T> segment) { return new ReadOnlySpan<T>(segment.Array, segment.Offset, segment.Count); } public Enumerator GetEnumerator() { return new Enumerator(this); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlySpan(T[] array) { if (array == null) { this = default(ReadOnlySpan<T>); return; } _length = array.Length; _pinnable = Unsafe.As<Pinnable<T>>(array); _byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlySpan(T[] array, int start, int length) { if (array == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } this = default(ReadOnlySpan<T>); return; } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } _length = length; _pinnable = Unsafe.As<Pinnable<T>>(array); _byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public unsafe ReadOnlySpan(void* pointer, int length) { if (System.SpanHelpers.IsReferenceOrContainsReferences<T>()) { System.ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); } if (length < 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } _length = length; _pinnable = null; _byteOffset = new IntPtr(pointer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ReadOnlySpan(Pinnable<T> pinnable, IntPtr byteOffset, int length) { _length = length; _pinnable = pinnable; _byteOffset = byteOffset; } [EditorBrowsable(EditorBrowsableState.Never)] public unsafe ref readonly T GetPinnableReference() { if (_length != 0) { if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.AsRef<T>(byteOffset.ToPointer()); } return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset); } return ref Unsafe.AsRef<T>(null); } public void CopyTo(Span<T> destination) { if (!TryCopyTo(destination)) { System.ThrowHelper.ThrowArgumentException_DestinationTooShort(); } } public bool TryCopyTo(Span<T> destination) { int length = _length; int length2 = destination.Length; if (length == 0) { return true; } if ((uint)length > (uint)length2) { return false; } ref T src = ref DangerousGetPinnableReference(); System.SpanHelpers.CopyTo(ref destination.DangerousGetPinnableReference(), length2, ref src, length); return true; } public static bool operator ==(ReadOnlySpan<T> left, ReadOnlySpan<T> right) { if (left._length == right._length) { return Unsafe.AreSame(ref left.DangerousGetPinnableReference(), ref right.DangerousGetPinnableReference()); } return false; } public unsafe override string ToString() { if (typeof(T) == typeof(char)) { if (_byteOffset == MemoryExtensions.StringAdjustment) { object obj = Unsafe.As<object>(_pinnable); if (obj is string text && _length == text.Length) { return text; } } fixed (char* value = &Unsafe.As<T, char>(ref DangerousGetPinnableReference())) { return new string(value, 0, _length); } } return $"System.ReadOnlySpan<{typeof(T).Name}>[{_length}]"; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlySpan<T> Slice(int start) { if ((uint)start > (uint)_length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } IntPtr byteOffset = _byteOffset.Add<T>(start); int length = _length - start; return new ReadOnlySpan<T>(_pinnable, byteOffset, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlySpan<T> Slice(int start, int length) { if ((uint)start > (uint)_length || (uint)length > (uint)(_length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } IntPtr byteOffset = _byteOffset.Add<T>(start); return new ReadOnlySpan<T>(_pinnable, byteOffset, length); } public T[] ToArray() { if (_length == 0) { return System.SpanHelpers.PerTypeValues<T>.EmptyArray; } T[] array = new T[_length]; CopyTo(array); return array; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [EditorBrowsable(EditorBrowsableState.Never)] internal unsafe ref T DangerousGetPinnableReference() { if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.AsRef<T>(byteOffset.ToPointer()); } return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset); } } [DebuggerTypeProxy(typeof(System.SpanDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] [DebuggerTypeProxy(typeof(System.SpanDebugView<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly ref struct Span<T> { public ref struct Enumerator { private readonly Span<T> _span; private int _index; public ref T Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref _span[_index]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Enumerator(Span<T> span) { _span = span; _index = -1; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { int num = _index + 1; if (num < _span.Length) { _index = num; return true; } return false; } } private readonly Pinnable<T> _pinnable; private readonly IntPtr _byteOffset; private readonly int _length; public int Length => _length; public bool IsEmpty => _length == 0; public static Span<T> Empty => default(Span<T>); public unsafe ref T this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if ((uint)index >= (uint)_length) { System.ThrowHelper.ThrowIndexOutOfRangeException(); } if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.Add(ref Unsafe.AsRef<T>(byteOffset.ToPointer()), index); } return ref Unsafe.Add(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset), index); } } internal Pinnable<T> Pinnable => _pinnable; internal IntPtr ByteOffset => _byteOffset; public static bool operator !=(Span<T> left, Span<T> right) { return !(left == right); } [Obsolete("Equals() on Span will always throw an exception. Use == instead.")] [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object obj) { throw new NotSupportedException(System.SR.NotSupported_CannotCallEqualsOnSpan); } [Obsolete("GetHashCode() on Span will always throw an exception.")] [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { throw new NotSupportedException(System.SR.NotSupported_CannotCallGetHashCodeOnSpan); } public static implicit operator Span<T>(T[] array) { return new Span<T>(array); } public static implicit operator Span<T>(ArraySegment<T> segment) { return new Span<T>(segment.Array, segment.Offset, segment.Count); } public Enumerator GetEnumerator() { return new Enumerator(this); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span(T[] array) { if (array == null) { this = default(Span<T>); return; } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } _length = array.Length; _pinnable = Unsafe.As<Pinnable<T>>(array); _byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment; } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Span<T> Create(T[] array, int start) { if (array == null) { if (start != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } return default(Span<T>); } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } IntPtr byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start); int length = array.Length - start; return new Span<T>(Unsafe.As<Pinnable<T>>(array), byteOffset, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span(T[] array, int start, int length) { if (array == null) { if (start != 0 || length != 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } this = default(Span<T>); return; } if (default(T) == null && array.GetType() != typeof(T[])) { System.ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } _length = length; _pinnable = Unsafe.As<Pinnable<T>>(array); _byteOffset = System.SpanHelpers.PerTypeValues<T>.ArrayAdjustment.Add<T>(start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [CLSCompliant(false)] public unsafe Span(void* pointer, int length) { if (System.SpanHelpers.IsReferenceOrContainsReferences<T>()) { System.ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); } if (length < 0) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } _length = length; _pinnable = null; _byteOffset = new IntPtr(pointer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Span(Pinnable<T> pinnable, IntPtr byteOffset, int length) { _length = length; _pinnable = pinnable; _byteOffset = byteOffset; } [EditorBrowsable(EditorBrowsableState.Never)] public unsafe ref T GetPinnableReference() { if (_length != 0) { if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.AsRef<T>(byteOffset.ToPointer()); } return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset); } return ref Unsafe.AsRef<T>(null); } public unsafe void Clear() { int length = _length; if (length == 0) { return; } UIntPtr byteLength = (UIntPtr)(ulong)((uint)length * Unsafe.SizeOf<T>()); if ((Unsafe.SizeOf<T>() & (sizeof(IntPtr) - 1)) != 0) { if (_pinnable == null) { IntPtr byteOffset = _byteOffset; byte* ptr = (byte*)byteOffset.ToPointer(); System.SpanHelpers.ClearLessThanPointerSized(ptr, byteLength); } else { System.SpanHelpers.ClearLessThanPointerSized(ref Unsafe.As<T, byte>(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset)), byteLength); } } else if (System.SpanHelpers.IsReferenceOrContainsReferences<T>()) { UIntPtr pointerSizeLength = (UIntPtr)(ulong)(length * Unsafe.SizeOf<T>() / sizeof(IntPtr)); System.SpanHelpers.ClearPointerSizedWithReferences(ref Unsafe.As<T, IntPtr>(ref DangerousGetPinnableReference()), pointerSizeLength); } else { System.SpanHelpers.ClearPointerSizedWithoutReferences(ref Unsafe.As<T, byte>(ref DangerousGetPinnableReference()), byteLength); } } public unsafe void Fill(T value) { int length = _length; if (length == 0) { return; } if (Unsafe.SizeOf<T>() == 1) { byte value2 = Unsafe.As<T, byte>(ref value); if (_pinnable == null) { IntPtr byteOffset = _byteOffset; Unsafe.InitBlockUnaligned(byteOffset.ToPointer(), value2, (uint)length); } else { Unsafe.InitBlockUnaligned(ref Unsafe.As<T, byte>(ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset)), value2, (uint)length); } return; } ref T source = ref DangerousGetPinnableReference(); int i; for (i = 0; i < (length & -8); i += 8) { Unsafe.Add(ref source, i) = value; Unsafe.Add(ref source, i + 1) = value; Unsafe.Add(ref source, i + 2) = value; Unsafe.Add(ref source, i + 3) = value; Unsafe.Add(ref source, i + 4) = value; Unsafe.Add(ref source, i + 5) = value; Unsafe.Add(ref source, i + 6) = value; Unsafe.Add(ref source, i + 7) = value; } if (i < (length & -4)) { Unsafe.Add(ref source, i) = value; Unsafe.Add(ref source, i + 1) = value; Unsafe.Add(ref source, i + 2) = value; Unsafe.Add(ref source, i + 3) = value; i += 4; } for (; i < length; i++) { Unsafe.Add(ref source, i) = value; } } public void CopyTo(Span<T> destination) { if (!TryCopyTo(destination)) { System.ThrowHelper.ThrowArgumentException_DestinationTooShort(); } } public bool TryCopyTo(Span<T> destination) { int length = _length; int length2 = destination._length; if (length == 0) { return true; } if ((uint)length > (uint)length2) { return false; } ref T src = ref DangerousGetPinnableReference(); System.SpanHelpers.CopyTo(ref destination.DangerousGetPinnableReference(), length2, ref src, length); return true; } public static bool operator ==(Span<T> left, Span<T> right) { if (left._length == right._length) { return Unsafe.AreSame(ref left.DangerousGetPinnableReference(), ref right.DangerousGetPinnableReference()); } return false; } public static implicit operator ReadOnlySpan<T>(Span<T> span) { return new ReadOnlySpan<T>(span._pinnable, span._byteOffset, span._length); } public unsafe override string ToString() { if (typeof(T) == typeof(char)) { fixed (char* value = &Unsafe.As<T, char>(ref DangerousGetPinnableReference())) { return new string(value, 0, _length); } } return $"System.Span<{typeof(T).Name}>[{_length}]"; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span<T> Slice(int start) { if ((uint)start > (uint)_length) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } IntPtr byteOffset = _byteOffset.Add<T>(start); int length = _length - start; return new Span<T>(_pinnable, byteOffset, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span<T> Slice(int start, int length) { if ((uint)start > (uint)_length || (uint)length > (uint)(_length - start)) { System.ThrowHelper.ThrowArgumentOutOfRangeException(System.ExceptionArgument.start); } IntPtr byteOffset = _byteOffset.Add<T>(start); return new Span<T>(_pinnable, byteOffset, length); } public T[] ToArray() { if (_length == 0) { return System.SpanHelpers.PerTypeValues<T>.EmptyArray; } T[] array = new T[_length]; CopyTo(array); return array; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [EditorBrowsable(EditorBrowsableState.Never)] internal unsafe ref T DangerousGetPinnableReference() { if (_pinnable == null) { IntPtr byteOffset = _byteOffset; return ref Unsafe.AsRef<T>(byteOffset.ToPointer()); } return ref Unsafe.AddByteOffset(ref _pinnable.Data, _byteOffset); } } internal sealed class SpanDebugView<T> { private readonly T[] _array; [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] public T[] Items => _array; public SpanDebugView(Span<T> span) { _array = span.ToArray(); } public SpanDebugView(ReadOnlySpan<T> span) { _array = span.ToArray(); } } internal static class SpanHelpers { internal struct ComparerComparable<T, TComparer> : IComparable<T> where TComparer : IComparer<T> { private readonly T _value; private readonly TComparer _comparer; public ComparerComparable(T value, TComparer comparer) { _value = value; _comparer = comparer; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CompareTo(T other) { return _comparer.Compare(_value, other); } } [StructLayout(LayoutKind.Sequential, Size = 64)] private struct Reg64 { } [StructLayout(LayoutKind.Sequential, Size = 32)] private struct Reg32 { } [StructLayout(LayoutKind.Sequential, Size = 16)] private struct Reg16 { } public static class PerTypeValues<T> { public static readonly bool IsReferenceOrContainsReferences = IsReferenceOrContainsReferencesCore(typeof(T)); public static readonly T[] EmptyArray = new T[0]; public static readonly IntPtr ArrayAdjustment = MeasureArrayAdjustment(); private static IntPtr MeasureArrayAdjustment() { T[] array = new T[1]; return Unsafe.ByteOffset(ref Unsafe.As<Pinnable<T>>(array).Data, ref array[0]); } } private const ulong XorPowerOfTwoToHighByte = 283686952306184uL; private const ulong XorPowerOfTwoToHighChar = 4295098372uL; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int BinarySearch<T, TComparable>(this ReadOnlySpan<T> span, TComparable comparable) where TComparable : IComparable<T> { if (comparable == null) { System.ThrowHelper.ThrowArgumentNullException(System.ExceptionArgument.comparable); } return BinarySearch(ref MemoryMarshal.GetReference(span), span.Length, comparable); } public static int BinarySearch<T, TComparable>(ref T spanStart, int length, TComparable comparable) where TComparable : IComparable<T> { int num = 0; int num2 = length - 1; while (num <= num2) { int num3 = num2 + num >>> 1; int num4 = comparable.CompareTo(Unsafe.Add(ref spanStart, num3)); if (num4 == 0) { return num3; } if (num4 > 0) { num = num3 + 1; } else { num2 = num3 - 1; } } return ~num; } public static int IndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength) { if (valueLength == 0) { return 0; } byte value2 = value; ref byte second = ref Unsafe.Add(ref value, 1); int num = valueLength - 1; int num2 = 0; while (true) { int num3 = searchSpaceLength - num2 - num; if (num3 <= 0) { break; } int num4 = IndexOf(ref Unsafe.Add(ref searchSpace, num2), value2, num3); if (num4 == -1) { break; } num2 += num4; if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num2 + 1), ref second, num)) { return num2; } num2++; } return -1; } public static int IndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength) { if (valueLength == 0) { return 0; } int num = -1; for (int i = 0; i < valueLength; i++) { int num2 = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if ((uint)num2 < (uint)num) { num = num2; searchSpaceLength = num2; if (num == 0) { break; } } } return num; } public static int LastIndexOfAny(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength) { if (valueLength == 0) { return 0; } int num = -1; for (int i = 0; i < valueLength; i++) { int num2 = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if (num2 > num) { num = num2; } } return num; } public unsafe static int IndexOf(ref byte searchSpace, byte value, int length) { IntPtr intPtr = (IntPtr)0; IntPtr intPtr2 = (IntPtr)length; if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2) { int num = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1); intPtr2 = (IntPtr)((Vector<byte>.Count - num) & (Vector<byte>.Count - 1)); } while (true) { if ((nuint)(void*)intPtr2 >= (nuint)8u) { intPtr2 -= 8; if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr)) { goto IL_0242; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1)) { goto IL_024a; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2)) { goto IL_0258; } if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 3)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 4)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 5)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 6)) { if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 7)) { break; } intPtr += 8; continue; } return (int)(void*)(intPtr + 6); } return (int)(void*)(intPtr + 5); } return (int)(void*)(intPtr + 4); } goto IL_0266; } if ((nuint)(void*)intPtr2 >= (nuint)4u) { intPtr2 -= 4; if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr)) { goto IL_0242; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1)) { goto IL_024a; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2)) { goto IL_0258; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 3)) { goto IL_0266; } intPtr += 4; } while ((void*)intPtr2 != null) { intPtr2 -= 1; if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr)) { intPtr += 1; continue; } goto IL_0242; } if (Vector.IsHardwareAccelerated && (int)(void*)intPtr < length) { intPtr2 = (IntPtr)((length - (int)(void*)intPtr) & ~(Vector<byte>.Count - 1)); Vector<byte> vector = GetVector(value); for (; (void*)intPtr2 > (void*)intPtr; intPtr += Vector<byte>.Count) { Vector<byte> vector2 = Vector.Equals(vector, Unsafe.ReadUnaligned<Vector<byte>>(ref Unsafe.AddByteOffset(ref searchSpace, intPtr))); if (!Vector<byte>.Zero.Equals(vector2)) { return (int)(void*)intPtr + LocateFirstFoundByte(vector2); } } if ((int)(void*)intPtr < length) { intPtr2 = (IntPtr)(length - (int)(void*)intPtr); continue; } } return -1; IL_0266: return (int)(void*)(intPtr + 3); IL_0242: return (int)(void*)intPtr; IL_0258: return (int)(void*)(intPtr + 2); IL_024a: return (int)(void*)(intPtr + 1); } return (int)(void*)(intPtr + 7); } public static int LastIndexOf(ref byte searchSpace, int searchSpaceLength, ref byte value, int valueLength) { if (valueLength == 0) { return 0; } byte value2 = value; ref byte second = ref Unsafe.Add(ref value, 1); int num = valueLength - 1; int num2 = 0; while (true) { int num3 = searchSpaceLength - num2 - num; if (num3 <= 0) { break; } int num4 = LastIndexOf(ref searchSpace, value2, num3); if (num4 == -1) { break; } if (SequenceEqual(ref Unsafe.Add(ref searchSpace, num4 + 1), ref second, num)) { return num4; } num2 += num3 - num4; } return -1; } public unsafe static int LastIndexOf(ref byte searchSpace, byte value, int length) { IntPtr intPtr = (IntPtr)length; IntPtr intPtr2 = (IntPtr)length; if (Vector.IsHardwareAccelerated && length >= Vector<byte>.Count * 2) { int num = (int)Unsafe.AsPointer(ref searchSpace) & (Vector<byte>.Count - 1); intPtr2 = (IntPtr)(((length & (Vector<byte>.Count - 1)) + num) & (Vector<byte>.Count - 1)); } while (true) { if ((nuint)(void*)intPtr2 >= (nuint)8u) { intPtr2 -= 8; intPtr -= 8; if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 7)) { break; } if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 6)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 5)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 4)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 3)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 2)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr + 1)) { if (value != Unsafe.AddByteOffset(ref searchSpace, intPtr)) { continue; } goto IL_0254; } goto IL_025c; } goto IL_026a; } goto IL_0278; } return (int)(void*)(intPtr + 4); } return (int)(void*)(intPtr + 5); } return (int)(void*)(intPtr + 6); } if ((nuint)(void*)intPtr2 >= (nuint)4u) { intPtr2 -= 4; intPtr -= 4; if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 3)) { goto IL_0278; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 2)) { goto IL_026a; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr + 1)) { goto IL_025c; } if (value == Unsafe.AddByteOffset(ref searchSpace, intPtr)) { goto IL_0254; } } while ((void*)intPtr2 != null) { intPtr2 -= 1; intPtr -= 1; if (value !
BepInEx/plugins/DearImGuiInjection/RendererFinder.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using CppInterop; using Microsoft.CodeAnalysis; using Reloaded.Hooks; using Reloaded.Hooks.Definitions; using Reloaded.Hooks.Definitions.X64; using Reloaded.Hooks.Definitions.X86; using RendererFinder.Renderers; using RendererFinder.Windows; using SharpDX; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.Direct3D12; using SharpDX.Mathematics.Interop; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("RendererFinder")] [assembly: AssemblyConfiguration("netstandard2.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+af1e9534c67088d11779ad09d1aab2c19226e34a")] [assembly: AssemblyProduct("RendererFinder")] [assembly: AssemblyTitle("RendererFinder")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RendererFinder { internal static class Log { internal const string Prefix = "[RendererFinder] "; internal static void Debug(object data) { WriteLine(data, ConsoleColor.White); } internal static void Error(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Fatal(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Info(object data) { WriteLine(data, ConsoleColor.White); } internal static void Message(object data) { WriteLine(data, ConsoleColor.White); } internal static void Warning(object data) { WriteLine(data, ConsoleColor.Yellow); } private static void WriteLine(object data, ConsoleColor color) { Console.ForegroundColor = color; Console.WriteLine("[RendererFinder] " + data); Console.ResetColor(); } } public static class RendererFinder { public static readonly RendererKind[] AvailableRenderers = new RendererKind[2] { RendererKind.D3D11, RendererKind.D3D12 }; public static RendererKind RendererKind { get; private set; } public static bool Init() { if (RendererKind != 0) { return true; } RendererKind[] availableRenderers = AvailableRenderers; foreach (RendererKind rendererKind in availableRenderers) { IRenderer implementationFromRendererKind = GetImplementationFromRendererKind(rendererKind); if (implementationFromRendererKind != null && implementationFromRendererKind.Init()) { RendererKind = rendererKind; return true; } } return false; } public static void Dispose() { RendererKind = RendererKind.None; } [MethodImpl(MethodImplOptions.NoInlining)] private static IRenderer NewDX11Renderer() { bool flag = false; bool flag2 = false; foreach (ProcessModule item in Process.GetCurrentProcess().Modules.Cast<ProcessModule>()) { if (item != null && item.ModuleName != null) { string text = item.ModuleName.ToLowerInvariant(); if (text.Contains("d3d11")) { flag = true; } else if (text.Contains("d3d12")) { flag2 = true; } } } if (!flag || flag2) { return null; } return new DX11Renderer(); } [MethodImpl(MethodImplOptions.NoInlining)] private static IRenderer NewDX12Renderer() { bool flag = false; foreach (ProcessModule item in Process.GetCurrentProcess().Modules.Cast<ProcessModule>()) { if (item != null && item.ModuleName != null && item.ModuleName.ToLowerInvariant().Contains("d3d12")) { flag = true; } } if (!flag) { return null; } return new DX12Renderer(); } private static IRenderer GetImplementationFromRendererKind(RendererKind rendererKind) { return rendererKind switch { RendererKind.D3D11 => NewDX11Renderer(), RendererKind.D3D12 => NewDX12Renderer(), _ => null, }; } } } namespace RendererFinder.Windows { internal static class User32 { private delegate IntPtr WndProcDelegate(IntPtr window, uint message, IntPtr wParam, IntPtr lParam); private struct WNDCLASSEXW { public int cbSize; public int style; public IntPtr lpfnWndProc; public int cbClsExtra; public int cbWndExtra; public IntPtr hInstance; public IntPtr hIcon; public IntPtr hCursor; public IntPtr hbrBackground; [MarshalAs(UnmanagedType.LPWStr)] public string lpszMenuName; [MarshalAs(UnmanagedType.LPWStr)] public string lpszClassName; public IntPtr hIconSm; } private static readonly WndProcDelegate s_WndProc = WndProc; [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr CreateWindowExW(uint dwExStyle, IntPtr windowClass, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr pvParam); [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName); [DllImport("user32.dll")] private static extern IntPtr DefWindowProcW(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam); private static IntPtr WndProc(IntPtr window, uint message, IntPtr wParam, IntPtr lParam) { return DefWindowProcW(window, message, wParam, lParam); } [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.U2)] private static extern ushort RegisterClassExW([In] ref WNDCLASSEXW lpwcx); [DllImport("user32.dll")] public static extern bool DestroyWindow(IntPtr hWnd); public static IntPtr CreateFakeWindow() { WNDCLASSEXW lpwcx = default(WNDCLASSEXW); lpwcx.cbSize = Marshal.SizeOf<WNDCLASSEXW>(); lpwcx.lpfnWndProc = Marshal.GetFunctionPointerForDelegate(s_WndProc); lpwcx.hInstance = GetModuleHandle(null); lpwcx.lpszClassName = "DearImGuiInjectionWindowClass"; ushort num = RegisterClassExW(ref lpwcx); if (num == 0) { throw new Win32Exception(Marshal.GetLastWin32Error()); } IntPtr intPtr = CreateWindowExW(0u, new IntPtr(num), "DearImGuiInjection Window", 0u, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, GetModuleHandle(null), IntPtr.Zero); if (intPtr == IntPtr.Zero) { throw new Win32Exception(Marshal.GetLastWin32Error()); } return intPtr; } } } namespace RendererFinder.Renderers { public enum IDXGISwapChain { QueryInterface, AddRef, Release, SetPrivateData, SetPrivateDataInterface, GetPrivateData, GetParent, GetDevice, Present, GetBuffer, SetFullscreenState, GetFullscreenState, GetDesc, ResizeBuffers, ResizeTarget, GetContainingOutput, GetFrameStatistics, GetLastPresentCount } public class DX11Renderer : IRenderer { [Function(/*Could not decode attribute arguments.*/)] [Function(/*Could not decode attribute arguments.*/)] private delegate IntPtr CDXGISwapChainPresentDelegate(IntPtr self, uint syncInterval, uint flags); [Function(/*Could not decode attribute arguments.*/)] [Function(/*Could not decode attribute arguments.*/)] private delegate IntPtr CDXGISwapChainResizeBuffersDelegate(IntPtr self, uint bufferCount, uint width, uint height, Format newFormat, uint swapchainFlags); private static List<object> _cache = new List<object>(); private static CDXGISwapChainPresentDelegate _swapChainPresentHookDelegate = SwapChainPresentHook; private static Hook<CDXGISwapChainPresentDelegate> _swapChainPresentHook; private static Action<SwapChain, uint, uint> _onPresentAction; private static CDXGISwapChainResizeBuffersDelegate _swapChainResizeBuffersHookDelegate = SwapChainResizeBuffersHook; private static Hook<CDXGISwapChainResizeBuffersDelegate> _swapChainResizeBuffersHook; private static Action<SwapChain, uint, uint, uint, Format, uint> _preResizeBuffers; private static Action<SwapChain, uint, uint, uint, Format, uint> _postResizeBuffers; public static event Action<SwapChain, uint, uint> OnPresent { add { _onPresentAction = (Action<SwapChain, uint, uint>)Delegate.Combine(_onPresentAction, value); } remove { _onPresentAction = (Action<SwapChain, uint, uint>)Delegate.Remove(_onPresentAction, value); } } public static event Action<SwapChain, uint, uint, uint, Format, uint> PreResizeBuffers { add { _preResizeBuffers = (Action<SwapChain, uint, uint, uint, Format, uint>)Delegate.Combine(_preResizeBuffers, value); } remove { _preResizeBuffers = (Action<SwapChain, uint, uint, uint, Format, uint>)Delegate.Remove(_preResizeBuffers, value); } } public static event Action<SwapChain, uint, uint, uint, Format, uint> PostResizeBuffers { add { _postResizeBuffers = (Action<SwapChain, uint, uint, uint, Format, uint>)Delegate.Combine(_postResizeBuffers, value); } remove { _postResizeBuffers = (Action<SwapChain, uint, uint, uint, Format, uint>)Delegate.Remove(_postResizeBuffers, value); } } public bool Init() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Log.Info("DX11Renderer.Init()"); IntPtr intPtr = User32.CreateFakeWindow(); SwapChainDescription val = default(SwapChainDescription); val.BufferCount = 1; val.ModeDescription = new ModeDescription(500, 300, new Rational(60, 1), (Format)28); val.IsWindowed = RawBool.op_Implicit(true); val.OutputHandle = intPtr; val.SampleDescription = new SampleDescription(1, 0); val.Usage = (Usage)32; SwapChainDescription val2 = val; Device val3 = default(Device); SwapChain val4 = default(SwapChain); Device.CreateWithSwapChain((DriverType)1, (DeviceCreationFlags)0, val2, ref val3, ref val4); VirtualFunctionTable obj = VirtualFunctionTable.FromObject((UIntPtr)(nuint)(nint)((CppObject)val4).NativePointer, (UIntPtr)(nuint)Enum.GetNames(typeof(IDXGISwapChain)).Length); UIntPtr functionPointer = obj.TableEntries[8].FunctionPointer; UIntPtr functionPointer2 = obj.TableEntries[13].FunctionPointer; ((DisposeBase)val4).Dispose(); ((DisposeBase)val3).Dispose(); User32.DestroyWindow(intPtr); _cache.Add(_swapChainPresentHookDelegate); _swapChainPresentHook = new Hook<CDXGISwapChainPresentDelegate>(_swapChainPresentHookDelegate, functionPointer, -1, (FunctionHookOptions)null); _swapChainPresentHook.Activate(); _cache.Add(_swapChainResizeBuffersHookDelegate); _swapChainResizeBuffersHook = new Hook<CDXGISwapChainResizeBuffersDelegate>(_swapChainResizeBuffersHookDelegate, functionPointer2, -1, (FunctionHookOptions)null); _swapChainResizeBuffersHook.Activate(); return true; } public void Dispose() { _swapChainResizeBuffersHook?.Disable(); _swapChainResizeBuffersHook = null; _swapChainPresentHook?.Disable(); _swapChainPresentHook = null; _onPresentAction = null; } private static IntPtr SwapChainPresentHook(IntPtr self, uint syncInterval, uint flags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SwapChain arg = new SwapChain(self); if (_onPresentAction != null) { Delegate[] invocationList = _onPresentAction.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action<SwapChain, uint, uint> action = (Action<SwapChain, uint, uint>)invocationList[i]; try { action(arg, syncInterval, flags); } catch (Exception data) { Log.Error(data); } } } return _swapChainPresentHook.OriginalFunction(self, syncInterval, flags); } private static IntPtr SwapChainResizeBuffersHook(IntPtr swapchainPtr, uint bufferCount, uint width, uint height, Format newFormat, uint swapchainFlags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) SwapChain arg = new SwapChain(swapchainPtr); if (_preResizeBuffers != null) { Delegate[] invocationList = _preResizeBuffers.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action<SwapChain, uint, uint, uint, Format, uint> action = (Action<SwapChain, uint, uint, uint, Format, uint>)invocationList[i]; try { action(arg, bufferCount, width, height, newFormat, swapchainFlags); } catch (Exception data) { Log.Error(data); } } } IntPtr result = _swapChainResizeBuffersHook.OriginalFunction(swapchainPtr, bufferCount, width, height, newFormat, swapchainFlags); if (_postResizeBuffers != null) { Delegate[] invocationList = _postResizeBuffers.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action<SwapChain, uint, uint, uint, Format, uint> action2 = (Action<SwapChain, uint, uint, uint, Format, uint>)invocationList[i]; try { action2(arg, bufferCount, width, height, newFormat, swapchainFlags); } catch (Exception data2) { Log.Error(data2); } } } return result; } } public class DX12Renderer : IRenderer { [Function(/*Could not decode attribute arguments.*/)] [Function(/*Could not decode attribute arguments.*/)] private delegate IntPtr CDXGISwapChainPresent1Delegate(IntPtr self, uint syncInterval, uint presentFlags, IntPtr presentParametersRef); [Function(/*Could not decode attribute arguments.*/)] [Function(/*Could not decode attribute arguments.*/)] private delegate IntPtr CDXGISwapChainResizeBuffersDelegate(IntPtr self, int bufferCount, int width, int height, int newFormat, int swapchainFlags); [Function(/*Could not decode attribute arguments.*/)] [Function(/*Could not decode attribute arguments.*/)] private delegate void CommandQueueExecuteCommandListDelegate(IntPtr self, uint numCommandLists, IntPtr ppCommandLists); private static readonly List<object> _cache = new List<object>(); private static readonly CDXGISwapChainPresent1Delegate _swapchainPresentHookDelegate = SwapChainPresentHook; private static Hook<CDXGISwapChainPresent1Delegate> _swapChainPresentHook; private static Action<SwapChain3, uint, uint, IntPtr> _onPresentAction; private static readonly CDXGISwapChainResizeBuffersDelegate _swapChainResizeBufferHookDelegate = SwapChainResizeBuffersHook; private static Hook<CDXGISwapChainResizeBuffersDelegate> _swapChainResizeBufferHook; private static Action<SwapChain3, int, int, int, int, int> _preResizeBuffers; private static Action<SwapChain3, int, int, int, int, int> _postResizeBuffers; private static readonly CommandQueueExecuteCommandListDelegate _commandQueueExecuteCommandListHookDelegate = CommandQueueExecuteCommandListHook; private static Hook<CommandQueueExecuteCommandListDelegate> _commandQueueExecuteCommandListHook; private static readonly object _onExecuteCommandListActionLock = new object(); public static event Action<SwapChain3, uint, uint, IntPtr> OnPresent { add { _onPresentAction = (Action<SwapChain3, uint, uint, IntPtr>)Delegate.Combine(_onPresentAction, value); } remove { _onPresentAction = (Action<SwapChain3, uint, uint, IntPtr>)Delegate.Remove(_onPresentAction, value); } } public static event Action<SwapChain3, int, int, int, int, int> PreResizeBuffers { add { _preResizeBuffers = (Action<SwapChain3, int, int, int, int, int>)Delegate.Combine(_preResizeBuffers, value); } remove { _preResizeBuffers = (Action<SwapChain3, int, int, int, int, int>)Delegate.Remove(_preResizeBuffers, value); } } public static event Action<SwapChain3, int, int, int, int, int> PostResizeBuffers { add { _postResizeBuffers = (Action<SwapChain3, int, int, int, int, int>)Delegate.Combine(_postResizeBuffers, value); } remove { _postResizeBuffers = (Action<SwapChain3, int, int, int, int, int>)Delegate.Remove(_postResizeBuffers, value); } } public static event Func<CommandQueue, uint, IntPtr, bool> OnExecuteCommandList { add { lock (_onExecuteCommandListActionLock) { OnExecuteCommandListAction += value; } } remove { lock (_onExecuteCommandListActionLock) { OnExecuteCommandListAction -= value; } } } private static event Func<CommandQueue, uint, IntPtr, bool> OnExecuteCommandListAction; public bool Init() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) IntPtr intPtr = User32.CreateFakeWindow(); SwapChainDescription val = default(SwapChainDescription); val.BufferCount = 2; val.ModeDescription = new ModeDescription(500, 300, new Rational(60, 1), (Format)28); val.Usage = (Usage)32; val.SwapEffect = (SwapEffect)4; val.OutputHandle = intPtr; val.SampleDescription = new SampleDescription(1, 0); val.IsWindowed = RawBool.op_Implicit(true); SwapChainDescription val2 = val; Factory4 val3 = new Factory4(); try { Device val4 = new Device((Adapter)null, (FeatureLevel)45056); CommandQueueDescription val5 = new CommandQueueDescription((CommandListType)0, (CommandQueueFlags)0); CommandQueue val6 = val4.CreateCommandQueue(val5); SwapChain val7 = new SwapChain((Factory)(object)val3, (ComObject)(object)val6, val2); SwapChain3 val8 = ((ComObject)val7).QueryInterface<SwapChain3>(); ((DisposeBase)val7).Dispose(); VirtualFunctionTable val9 = VirtualFunctionTable.FromObject((UIntPtr)(nuint)(nint)((CppObject)val8).NativePointer, (UIntPtr)(nuint)23u); VirtualFunctionTable val10 = VirtualFunctionTable.FromObject((UIntPtr)(nuint)(nint)((CppObject)val6).NativePointer, (UIntPtr)(nuint)11u); ((DisposeBase)val8).Dispose(); ((DisposeBase)val6).Dispose(); ((DisposeBase)val4).Dispose(); User32.DestroyWindow(intPtr); _cache.Add(_swapchainPresentHookDelegate); _swapChainPresentHook = new Hook<CDXGISwapChainPresent1Delegate>(_swapchainPresentHookDelegate, val9.TableEntries[22].FunctionPointer, -1, (FunctionHookOptions)null); _swapChainPresentHook.Activate(); _cache.Add(_swapChainResizeBufferHookDelegate); _swapChainResizeBufferHook = new Hook<CDXGISwapChainResizeBuffersDelegate>(_swapChainResizeBufferHookDelegate, val9.TableEntries[13].FunctionPointer, -1, (FunctionHookOptions)null); _swapChainResizeBufferHook.Activate(); _cache.Add(_commandQueueExecuteCommandListHookDelegate); _commandQueueExecuteCommandListHook = new Hook<CommandQueueExecuteCommandListDelegate>(_commandQueueExecuteCommandListHookDelegate, val10.TableEntries[10].FunctionPointer, -1, (FunctionHookOptions)null); _commandQueueExecuteCommandListHook.Activate(); return true; } finally { ((IDisposable)val3)?.Dispose(); } } public void Dispose() { _swapChainResizeBufferHook?.Disable(); _swapChainResizeBufferHook = null; _commandQueueExecuteCommandListHook?.Disable(); _commandQueueExecuteCommandListHook = null; _swapChainPresentHook?.Disable(); _swapChainPresentHook = null; _onPresentAction = null; } private static IntPtr SwapChainPresentHook(IntPtr self, uint syncInterval, uint flags, IntPtr presentParameters) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SwapChain3 arg = new SwapChain3(self); if (_onPresentAction != null) { foreach (Action<SwapChain3, uint, uint, IntPtr> item in _onPresentAction.GetInvocationList().Cast<Action<SwapChain3, uint, uint, IntPtr>>()) { try { item(arg, syncInterval, flags, presentParameters); } catch (Exception data) { Log.Error(data); } } } return _swapChainPresentHook.OriginalFunction(self, syncInterval, flags, presentParameters); } private static IntPtr SwapChainResizeBuffersHook(IntPtr swapchainPtr, int bufferCount, int width, int height, int newFormat, int swapchainFlags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown SwapChain3 arg = new SwapChain3(swapchainPtr); if (_preResizeBuffers != null) { foreach (Action<SwapChain3, int, int, int, int, int> item in _preResizeBuffers.GetInvocationList().Cast<Action<SwapChain3, int, int, int, int, int>>()) { try { item(arg, bufferCount, width, height, newFormat, swapchainFlags); } catch (Exception data) { Log.Error(data); } } } IntPtr result = _swapChainResizeBufferHook.OriginalFunction(swapchainPtr, bufferCount, width, height, newFormat, swapchainFlags); if (_postResizeBuffers != null) { foreach (Action<SwapChain3, int, int, int, int, int> item2 in _postResizeBuffers.GetInvocationList().Cast<Action<SwapChain3, int, int, int, int, int>>()) { try { item2(arg, bufferCount, width, height, newFormat, swapchainFlags); } catch (Exception data2) { Log.Error(data2); } } } return result; } private static void CommandQueueExecuteCommandListHook(IntPtr self, uint numCommandLists, IntPtr ppCommandLists) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown bool flag = false; lock (_onExecuteCommandListActionLock) { if (DX12Renderer.OnExecuteCommandListAction != null) { CommandQueue arg = new CommandQueue(self); foreach (Func<CommandQueue, uint, IntPtr, bool> item in DX12Renderer.OnExecuteCommandListAction.GetInvocationList().Cast<Func<CommandQueue, uint, IntPtr, bool>>()) { try { if (item(arg, numCommandLists, ppCommandLists)) { flag = true; } } catch (Exception data) { Log.Error(data); } } } } _commandQueueExecuteCommandListHook.OriginalFunction(self, numCommandLists, ppCommandLists); if (flag) { _commandQueueExecuteCommandListHook.Disable(); } } } public enum RendererKind { None, D3D11, D3D12 } public interface IRenderer { bool Init(); void Dispose(); } }
BepInEx/plugins/DearImGuiInjection/DearImGuiInjection.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DearImGuiInjection.Backends; using DearImGuiInjection.Windows; using ImGuiNET; using Microsoft.CodeAnalysis; using MonoMod.RuntimeDetour; using RendererFinder; using RendererFinder.Renderers; using SharpDX; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.Direct3D12; using SharpDX.Mathematics.Interop; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("DearImGuiInjection")] [assembly: AssemblyConfiguration("netstandard2.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+af1e9534c67088d11779ad09d1aab2c19226e34a")] [assembly: AssemblyProduct("DearImGuiInjection")] [assembly: AssemblyTitle("DearImGuiInjection")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DearImGuiInjection { public class BepInExConfigEntry<T> : IConfigEntry<T> { private ConfigEntry<T> _configEntry; public BepInExConfigEntry(ConfigEntry<T> configEntry) { _configEntry = configEntry; } public T Get() { return _configEntry.Value; } public void Set(T value) { _configEntry.Value = value; } } internal class BepInExLog : ILog { private ManualLogSource _logSource; internal BepInExLog(ManualLogSource logSource) { _logSource = logSource; } void ILog.Debug(object data) { _logSource.LogDebug(data); } void ILog.Error(object data) { _logSource.LogError(data); } void ILog.Fatal(object data) { _logSource.LogFatal(data); } void ILog.Info(object data) { _logSource.LogInfo(data); } void ILog.Message(object data) { _logSource.LogMessage(data); } void ILog.Warning(object data) { _logSource.LogWarning(data); } } public static class DearImGuiInjection { private const string IniFileName = "DearImGuiInjection_imgui.ini"; public static bool AllowPassthroughInput; internal const VirtualKey CursorVisibilityToggleDefault = VirtualKey.Insert; internal static Action RenderAction; public static bool Initialized { get; internal set; } public static IntPtr Context { get; internal set; } public static ImGuiIOPtr IO { get; internal set; } public static string ImGuiIniConfigPath { get; private set; } public static string AssetsFolderPath { get; private set; } public static bool IsCursorVisible { get; internal set; } public static IConfigEntry<VirtualKey> CursorVisibilityToggle { get; internal set; } public static ImGuiStyle Style { get; private set; } public static event Action Render { add { RenderAction = (Action)Delegate.Combine(RenderAction, value); } remove { RenderAction = (Action)Delegate.Remove(RenderAction, value); } } internal static void Init(string imguiIniConfigDirectoryPath, string assetsFolder, IConfigEntry<VirtualKey> cursorVisibilityConfig) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (RendererFinder.Init()) { ImGuiIniConfigPath = Path.Combine(imguiIniConfigDirectoryPath, "DearImGuiInjection_imgui.ini"); AssetsFolderPath = assetsFolder; CursorVisibilityToggle = cursorVisibilityConfig; InitImplementationFromRendererKind(RendererFinder.RendererKind); } } internal unsafe static void InitImGui() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Context = ImGui.CreateContext(ImFontAtlasPtr.op_Implicit((ImFontAtlas*)null)); IO = ImGui.GetIO(); ImGuiIOPtr iO = IO; ref ImGuiConfigFlags configFlags = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags = (ImGuiConfigFlags)((uint)configFlags | 0x40u); iO = ImGui.GetIO(); ((ImGuiIO)((ImGuiIOPtr)(ref iO)).NativePtr).IniFilename = (byte*)(void*)Marshal.StringToHGlobalAnsi(ImGuiIniConfigPath); DearImGuiTheme.Init(); } internal unsafe static void Dispose() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (Initialized) { DisposeImplementationFromRendererKind(RendererFinder.RendererKind); RenderAction = null; ImGuiIOPtr iO = ImGui.GetIO(); Marshal.FreeHGlobal((IntPtr)((ImGuiIO)((ImGuiIOPtr)(ref iO)).NativePtr).IniFilename); IO = ImGuiIOPtr.op_Implicit((ImGuiIO*)null); ImGui.DestroyContext(Context); Context = IntPtr.Zero; Initialized = false; } } private static void InitImplementationFromRendererKind(RendererKind rendererKind) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown switch ((int)rendererKind) { case 1: InitImGuiDX11(); break; case 2: InitImGuiDX12(); break; case 0: break; } } [MethodImpl(MethodImplOptions.NoInlining)] private static void InitImGuiDX11() { ImGuiDX11.Init(); } [MethodImpl(MethodImplOptions.NoInlining)] private static void InitImGuiDX12() { ImGuiDX12.Init(); } private static void DisposeImplementationFromRendererKind(RendererKind rendererKind) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected I4, but got Unknown switch ((int)rendererKind) { case 1: ImGuiDX11.Dispose(); break; case 2: ImGuiDX12.Dispose(); break; case 0: break; } } public static void ToggleCursorActions(bool show) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) ImGuiIOPtr iO; if (show) { iO = IO; ref ImGuiConfigFlags configFlags = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags = (ImGuiConfigFlags)((uint)configFlags & 0xFFFFFFEFu); } else { iO = IO; ref ImGuiConfigFlags configFlags2 = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags2 = (ImGuiConfigFlags)((uint)configFlags2 | 0x10u); } } internal static void ToggleCursor() { IsCursorVisible = !IsCursorVisible; UpdateCursorVisibility(); } internal static void UpdateCursorVisibility() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) ImGuiIOPtr iO; if (IsCursorVisible) { iO = IO; ((ImGuiIOPtr)(ref iO)).MouseDrawCursor = true; iO = IO; ref ImGuiConfigFlags configFlags = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags = (ImGuiConfigFlags)((uint)configFlags & 0xFFFFFFEFu); } else { iO = IO; ((ImGuiIOPtr)(ref iO)).MouseDrawCursor = false; iO = IO; ref ImGuiConfigFlags configFlags2 = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags2 = (ImGuiConfigFlags)((uint)configFlags2 | 0x10u); } } } public static class DearImGuiTheme { private static readonly Vector4 BGColor = new Vector4(0.117f, 0.113f, 0.172f, 0.75f); private static readonly Vector4 Primary = new Vector4(0.172f, 0.38f, 0.909f, 1f); private static readonly Vector4 Secondary = new Vector4(0.443f, 0.654f, 0.819f, 1f); private static readonly Vector4 WhiteBroken = new Vector4(0.792f, 0.784f, 0.827f, 1f); public static ImGuiStylePtr Style { get; private set; } internal static void Init() { SetupStyle(); SetupCustomFont(); } private static void SetupStyle() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) Style = ImGui.GetStyle(); ImGuiStylePtr style = Style; ((ImGuiStylePtr)(ref style)).WindowPadding = new Vector2(10f, 10f); style = Style; ((ImGuiStylePtr)(ref style)).PopupRounding = 0f; style = Style; ((ImGuiStylePtr)(ref style)).FramePadding = new Vector2(8f, 4f); style = Style; ((ImGuiStylePtr)(ref style)).ItemSpacing = new Vector2(10f, 8f); style = Style; ((ImGuiStylePtr)(ref style)).ItemInnerSpacing = new Vector2(6f, 6f); style = Style; ((ImGuiStylePtr)(ref style)).TouchExtraPadding = new Vector2(0f, 0f); style = Style; ((ImGuiStylePtr)(ref style)).IndentSpacing = 21f; style = Style; ((ImGuiStylePtr)(ref style)).ScrollbarSize = 15f; style = Style; ((ImGuiStylePtr)(ref style)).GrabMinSize = 8f; style = Style; ((ImGuiStylePtr)(ref style)).WindowBorderSize = 0f; style = Style; ((ImGuiStylePtr)(ref style)).ChildBorderSize = 0f; style = Style; ((ImGuiStylePtr)(ref style)).PopupBorderSize = 0f; style = Style; ((ImGuiStylePtr)(ref style)).FrameBorderSize = 0f; style = Style; ((ImGuiStylePtr)(ref style)).TabBorderSize = 0f; style = Style; ((ImGuiStylePtr)(ref style)).WindowRounding = 5f; style = Style; ((ImGuiStylePtr)(ref style)).ChildRounding = 2f; style = Style; ((ImGuiStylePtr)(ref style)).FrameRounding = 3f; style = Style; ((ImGuiStylePtr)(ref style)).ScrollbarRounding = 3f; style = Style; ((ImGuiStylePtr)(ref style)).GrabRounding = 0f; style = Style; ((ImGuiStylePtr)(ref style)).TabRounding = 3f; style = Style; ((ImGuiStylePtr)(ref style)).WindowTitleAlign = new Vector2(0.5f, 0.5f); style = Style; ((ImGuiStylePtr)(ref style)).ButtonTextAlign = new Vector2(0.5f, 0.5f); style = Style; ((ImGuiStylePtr)(ref style)).DisplaySafeAreaPadding = new Vector2(3f, 3f); style = Style; RangeAccessor<Vector4> colors = ((ImGuiStylePtr)(ref style)).Colors; colors[0] = new Vector4(1f, 1f, 1f, 1f); colors[1] = new Vector4(1f, 0.9f, 0.19f, 1f); colors[2] = BGColor; colors[3] = new Vector4(0f, 0f, 0f, 0f); colors[4] = new Vector4(0.08f, 0.08f, 0.08f, 0.94f); colors[5] = new Vector4(0.3f, 0.3f, 0.3f, 0.5f); colors[6] = new Vector4(0f, 0f, 0f, 0f); colors[7] = new Vector4(0.21f, 0.21f, 0.21f, 0.54f); colors[8] = new Vector4(0.21f, 0.21f, 0.21f, 0.78f); colors[9] = new Vector4(0.28f, 0.27f, 0.27f, 0.54f); colors[10] = new Vector4(0.17f, 0.17f, 0.17f, 1f); colors[11] = new Vector4(0.19f, 0.19f, 0.19f, 1f); colors[12] = new Vector4(0f, 0f, 0f, 0.51f); colors[13] = new Vector4(0.14f, 0.14f, 0.14f, 1f); colors[14] = colors[2]; colors[15] = Primary; colors[16] = Secondary; colors[17] = Primary; colors[18] = new Vector4(1f, 1f, 1f, 1f); colors[19] = new Vector4(0.34f, 0.34f, 0.34f, 1f); colors[20] = new Vector4(0.39f, 0.38f, 0.38f, 1f); colors[21] = Primary; colors[22] = Secondary; colors[23] = colors[22]; colors[24] = new Vector4(0.37f, 0.37f, 0.37f, 0.31f); colors[25] = new Vector4(0.38f, 0.38f, 0.38f, 0.37f); colors[26] = new Vector4(0.37f, 0.37f, 0.37f, 0.51f); colors[27] = new Vector4(0.38f, 0.38f, 0.38f, 0.5f); colors[28] = new Vector4(0.46f, 0.46f, 0.46f, 0.5f); colors[29] = new Vector4(0.46f, 0.46f, 0.46f, 0.64f); colors[30] = WhiteBroken; colors[31] = new Vector4(1f, 1f, 1f, 1f); colors[32] = WhiteBroken; colors[33] = new Vector4(0.21f, 0.21f, 0.21f, 0.86f); colors[34] = new Vector4(0.27f, 0.27f, 0.27f, 0.86f); colors[35] = new Vector4(0.34f, 0.34f, 0.34f, 0.86f); colors[36] = new Vector4(0.1f, 0.1f, 0.1f, 0.97f); colors[37] = new Vector4(0.15f, 0.15f, 0.15f, 1f); colors[40] = new Vector4(0.61f, 0.61f, 0.61f, 1f); colors[41] = new Vector4(1f, 0.43f, 0.35f, 1f); colors[42] = new Vector4(0.9f, 0.7f, 0f, 1f); colors[43] = new Vector4(1f, 0.6f, 0f, 1f); colors[49] = new Vector4(0.26f, 0.59f, 0.98f, 0.35f); colors[50] = new Vector4(1f, 1f, 0f, 0.9f); colors[51] = new Vector4(0.26f, 0.59f, 0.98f, 1f); colors[52] = new Vector4(1f, 1f, 1f, 0.7f); colors[53] = new Vector4(0.8f, 0.8f, 0.8f, 0.2f); colors[54] = new Vector4(0.8f, 0.8f, 0.8f, 0.35f); } private unsafe static void SetupCustomFont() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) string text = Path.Combine(DearImGuiInjection.AssetsFolderPath, "Fonts", "Comfortaa-Medium.ttf"); ImGuiIOPtr iO = ImGui.GetIO(); ImFontAtlasPtr fonts = ((ImGuiIOPtr)(ref iO)).Fonts; ImFontPtr val = ((ImFontAtlasPtr)(ref fonts)).AddFontFromFileTTF(text, 15f); iO = ImGui.GetIO(); ((ImGuiIO)((ImGuiIOPtr)(ref iO)).NativePtr).FontDefault = ImFontPtr.op_Implicit(val); } } public interface IConfigEntry<T> { T Get(); void Set(T value); } internal interface ILog { internal void Debug(object data); internal void Error(object data); internal void Fatal(object data); internal void Info(object data); internal void Message(object data); internal void Warning(object data); } internal static class Log { private static ILog _log; internal static void Init(ILog log) { _log = log; } internal static void Debug(object data) { _log.Debug(data); } internal static void Error(object data) { _log.Error(data); } internal static void Fatal(object data) { _log.Fatal(data); } internal static void Info(object data) { _log.Info(data); } internal static void Message(object data) { _log.Message(data); } internal static void Warning(object data) { _log.Warning(data); } } public static class Metadata { public const string GUID = "iDeathHD.DearImGuiInjection"; public const string Author = "iDeathHD"; public const string Name = "DearImGuiInjection"; public const string Version = "1.0.2"; } } namespace DearImGuiInjection.Windows { public static class Dwmapi { public struct DWM_BLURBEHIND { public DWM_BB dwFlags; public bool fEnable; public IntPtr hRgnBlur; public bool fTransitionOnMaximized; public bool TransitionOnMaximized { get { return fTransitionOnMaximized; } set { fTransitionOnMaximized = value; dwFlags |= DWM_BB.TransitionMaximized; } } public DWM_BLURBEHIND(bool enabled) { fEnable = enabled; hRgnBlur = IntPtr.Zero; fTransitionOnMaximized = false; dwFlags = DWM_BB.Enable; } } [Flags] public enum DWM_BB { Enable = 1, BlurRegion = 2, TransitionMaximized = 4 } [DllImport("dwmapi.dll")] public static extern int DwmGetColorizationColor(out uint ColorizationColor, [MarshalAs(UnmanagedType.Bool)] out bool ColorizationOpaqueBlend); [DllImport("dwmapi.dll")] public static extern int DwmIsCompositionEnabled(out bool enabled); [DllImport("dwmapi.dll")] public static extern void DwmEnableBlurBehindWindow(IntPtr hwnd, ref DWM_BLURBEHIND blurBehind); } public static class Gdi32 { [DllImport("gdi32.dll")] public static extern int GetDeviceCaps(IntPtr hdc, int nIndex); [DllImport("gdi32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DeleteObject([In] IntPtr hObject); [DllImport("gdi32.dll")] public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect); } public static class Kernel32 { public const uint INFINITE = uint.MaxValue; public const uint MB_PRECOMPOSED = 1u; public const uint CP_ACP = 0u; public const uint CP_OEMCP = 1u; public const uint CP_SYMBOL = 42u; public const uint CP_UTF7 = 65000u; public const uint CP_UTF8 = 65001u; public const uint CP_GB2312 = 936u; public const uint CP_BIG5 = 950u; public const uint CP_SHIFTJIS = 932u; [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CloseHandle(IntPtr hObject); [DllImport("kernel32.dll", SetLastError = true)] public static extern uint WaitForSingleObject(IntPtr hHandle, uint dwMilliseconds); [DllImport("kernel32.dll")] public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); [DllImport("kernel32.dll")] [SecurityCritical] [SuppressUnmanagedCodeSecurity] private static extern ulong VerSetConditionMask(ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask); [SecuritySafeCritical] internal static void VER_SET_CONDITION(ref ulong dwlConditionMask, uint dwTypeBitMask, byte dwConditionMask) { dwlConditionMask = VerSetConditionMask(dwlConditionMask, dwTypeBitMask, dwConditionMask); } public static ushort HiByte(ushort wValue) { return (ushort)((uint)(wValue >> 8) & 0xFFu); } [DllImport("kernel32.dll", SetLastError = true)] public static extern int MultiByteToWideChar(uint codePage, uint dwFlags, [In][MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr, int cbMultiByte, IntPtr lpWideCharStr, int cchWideChar); [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FreeLibrary(IntPtr hModule); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName); [DllImport("kernel32.dll", SetLastError = true)] public static extern bool QueryPerformanceCounter(out long lpPerformanceCount); [DllImport("kernel32.dll", SetLastError = true)] public static extern bool QueryPerformanceFrequency(out long frequency); } [StructLayout(LayoutKind.Explicit)] public struct LargeInteger { [FieldOffset(0)] public int Low; [FieldOffset(4)] public int High; [FieldOffset(0)] public long QuadPart; public long ToInt64() { return ((long)High << 32) | (uint)Low; } public static LargeInteger FromInt64(long value) { LargeInteger result = default(LargeInteger); result.Low = (int)value; result.High = (int)(value >> 32); return result; } } [Flags] public enum PRODUCT_SUITE : short { VER_SUITE_BACKOFFICE = 4, VER_SUITE_BLADE = 0x400, VER_SUITE_COMPUTE_SERVER = 0x4000, VER_SUITE_DATACENTER = 0x80, VER_SUITE_ENTERPRISE = 2, VER_SUITE_EMBEDDEDNT = 0x40, VER_SUITE_PERSONAL = 0x200, VER_SUITE_SINGLEUSERTS = 0x100, VER_SUITE_SMALLBUSINESS = 1, VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x20, VER_SUITE_STORAGE_SERVER = 0x2000, VER_SUITE_TERMINAL = 0x10, VER_SUITE_WH_SERVER = short.MinValue } public struct OSVERSIONINFOEX { public int dwOSVersionInfoSize; public int dwMajorVersion; public int dwMinorVersion; public int dwBuildNumber; public int dwPlatformId; public unsafe fixed char szCSDVersion[128]; public short wServicePackMajor; public short wServicePackMinor; public PRODUCT_SUITE wSuiteMask; public OS_TYPE wProductType; public byte wReserved; public unsafe static OSVERSIONINFOEX Create() { OSVERSIONINFOEX result = default(OSVERSIONINFOEX); result.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); return result; } } public enum OS_TYPE : byte { VER_NT_WORKSTATION = 1, VER_NT_DOMAIN_CONTROLLER, VER_NT_SERVER } [Flags] public enum VER_MASK { VER_BUILDNUMBER = 4, VER_MAJORVERSION = 2, VER_MINORVERSION = 1, VER_PLATFORMID = 8, VER_PRODUCT_TYPE = 0x80, VER_SERVICEPACKMAJOR = 0x20, VER_SERVICEPACKMINOR = 0x10, VER_SUITENAME = 0x40 } public static class Ntdll { [DllImport("ntdll.dll")] public unsafe static extern NtStatus RtlVerifyVersionInfo(OSVERSIONINFOEX* VersionInfo, VER_MASK TypeMask, long ConditionMask); } public struct RECT { public int Left; public int Top; public int Right; public int Bottom; public int X { get { return Left; } set { Right -= Left - value; Left = value; } } public int Y { get { return Top; } set { Bottom -= Top - value; Top = value; } } public int Height { get { return Bottom - Top; } set { Bottom = value + Top; } } public int Width { get { return Right - Left; } set { Right = value + Left; } } public Point Location { get { return new Point(Left, Top); } set { X = value.X; Y = value.Y; } } public Size Size { get { return new Size(Width, Height); } set { Width = value.Width; Height = value.Height; } } public RECT(int left, int top, int right, int bottom) { Left = left; Top = top; Right = right; Bottom = bottom; } public RECT(Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { } public static implicit operator Rectangle(RECT r) { return new Rectangle(r.Left, r.Top, r.Width, r.Height); } public static implicit operator RECT(Rectangle r) { return new RECT(r); } public static bool operator ==(RECT r1, RECT r2) { return r1.Equals(r2); } public static bool operator !=(RECT r1, RECT r2) { return !r1.Equals(r2); } public bool Equals(RECT r) { if (r.Left == Left && r.Top == Top && r.Right == Right) { return r.Bottom == Bottom; } return false; } public override bool Equals(object obj) { if (obj is RECT) { return Equals((RECT)obj); } if (obj is Rectangle) { return Equals(new RECT((Rectangle)obj)); } return false; } public override int GetHashCode() { return ((Rectangle)this).GetHashCode(); } public override string ToString() { return string.Format(CultureInfo.CurrentCulture, "{{Left={0},Top={1},Right={2},Bottom={3}}}", Left, Top, Right, Bottom); } } public enum PROCESS_DPI_AWARENESS { PROCESS_DPI_UNAWARE, PROCESS_SYSTEM_DPI_AWARE, PROCESS_PER_MONITOR_DPI_AWARE } public enum MONITOR_DPI_TYPE { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = 0 } public static class Shellscalingapi { [DllImport("shcore.dll")] public static extern IntPtr SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value); [DllImport("shcore.dll")] internal static extern uint GetDpiForMonitor(IntPtr hmonitor, MONITOR_DPI_TYPE dpiType, out uint dpiX, out uint dpiY); } public enum NtStatus : uint { Success = 0u, Wait0 = 0u, Wait1 = 1u, Wait2 = 2u, Wait3 = 3u, Wait63 = 63u, Abandoned = 128u, AbandonedWait0 = 128u, AbandonedWait1 = 129u, AbandonedWait2 = 130u, AbandonedWait3 = 131u, AbandonedWait63 = 191u, UserApc = 192u, KernelApc = 256u, Alerted = 257u, Timeout = 258u, Pending = 259u, Reparse = 260u, MoreEntries = 261u, NotAllAssigned = 262u, SomeNotMapped = 263u, OpLockBreakInProgress = 264u, VolumeMounted = 265u, RxActCommitted = 266u, NotifyCleanup = 267u, NotifyEnumDir = 268u, NoQuotasForAccount = 269u, PrimaryTransportConnectFailed = 270u, PageFaultTransition = 272u, PageFaultDemandZero = 273u, PageFaultCopyOnWrite = 274u, PageFaultGuardPage = 275u, PageFaultPagingFile = 276u, CrashDump = 278u, ReparseObject = 280u, NothingToTerminate = 290u, ProcessNotInJob = 291u, ProcessInJob = 292u, ProcessCloned = 297u, FileLockedWithOnlyReaders = 298u, FileLockedWithWriters = 299u, Informational = 1073741824u, ObjectNameExists = 1073741824u, ThreadWasSuspended = 1073741825u, WorkingSetLimitRange = 1073741826u, ImageNotAtBase = 1073741827u, RegistryRecovered = 1073741833u, Warning = 2147483648u, GuardPageViolation = 2147483649u, DatatypeMisalignment = 2147483650u, Breakpoint = 2147483651u, SingleStep = 2147483652u, BufferOverflow = 2147483653u, NoMoreFiles = 2147483654u, HandlesClosed = 2147483658u, PartialCopy = 2147483661u, DeviceBusy = 2147483665u, InvalidEaName = 2147483667u, EaListInconsistent = 2147483668u, NoMoreEntries = 2147483674u, LongJump = 2147483686u, DllMightBeInsecure = 2147483691u, Error = 3221225472u, Unsuccessful = 3221225473u, NotImplemented = 3221225474u, InvalidInfoClass = 3221225475u, InfoLengthMismatch = 3221225476u, AccessViolation = 3221225477u, InPageError = 3221225478u, PagefileQuota = 3221225479u, InvalidHandle = 3221225480u, BadInitialStack = 3221225481u, BadInitialPc = 3221225482u, InvalidCid = 3221225483u, TimerNotCanceled = 3221225484u, InvalidParameter = 3221225485u, NoSuchDevice = 3221225486u, NoSuchFile = 3221225487u, InvalidDeviceRequest = 3221225488u, EndOfFile = 3221225489u, WrongVolume = 3221225490u, NoMediaInDevice = 3221225491u, NoMemory = 3221225495u, NotMappedView = 3221225497u, UnableToFreeVm = 3221225498u, UnableToDeleteSection = 3221225499u, IllegalInstruction = 3221225501u, AlreadyCommitted = 3221225505u, AccessDenied = 3221225506u, BufferTooSmall = 3221225507u, ObjectTypeMismatch = 3221225508u, NonContinuableException = 3221225509u, BadStack = 3221225512u, NotLocked = 3221225514u, NotCommitted = 3221225517u, InvalidParameterMix = 3221225520u, ObjectNameInvalid = 3221225523u, ObjectNameNotFound = 3221225524u, ObjectNameCollision = 3221225525u, ObjectPathInvalid = 3221225529u, ObjectPathNotFound = 3221225530u, ObjectPathSyntaxBad = 3221225531u, DataOverrun = 3221225532u, DataLate = 3221225533u, DataError = 3221225534u, CrcError = 3221225535u, SectionTooBig = 3221225536u, PortConnectionRefused = 3221225537u, InvalidPortHandle = 3221225538u, SharingViolation = 3221225539u, QuotaExceeded = 3221225540u, InvalidPageProtection = 3221225541u, MutantNotOwned = 3221225542u, SemaphoreLimitExceeded = 3221225543u, PortAlreadySet = 3221225544u, SectionNotImage = 3221225545u, SuspendCountExceeded = 3221225546u, ThreadIsTerminating = 3221225547u, BadWorkingSetLimit = 3221225548u, IncompatibleFileMap = 3221225549u, SectionProtection = 3221225550u, EasNotSupported = 3221225551u, EaTooLarge = 3221225552u, NonExistentEaEntry = 3221225553u, NoEasOnFile = 3221225554u, EaCorruptError = 3221225555u, FileLockConflict = 3221225556u, LockNotGranted = 3221225557u, DeletePending = 3221225558u, CtlFileNotSupported = 3221225559u, UnknownRevision = 3221225560u, RevisionMismatch = 3221225561u, InvalidOwner = 3221225562u, InvalidPrimaryGroup = 3221225563u, NoImpersonationToken = 3221225564u, CantDisableMandatory = 3221225565u, NoLogonServers = 3221225566u, NoSuchLogonSession = 3221225567u, NoSuchPrivilege = 3221225568u, PrivilegeNotHeld = 3221225569u, InvalidAccountName = 3221225570u, UserExists = 3221225571u, NoSuchUser = 3221225572u, GroupExists = 3221225573u, NoSuchGroup = 3221225574u, MemberInGroup = 3221225575u, MemberNotInGroup = 3221225576u, LastAdmin = 3221225577u, WrongPassword = 3221225578u, IllFormedPassword = 3221225579u, PasswordRestriction = 3221225580u, LogonFailure = 3221225581u, AccountRestriction = 3221225582u, InvalidLogonHours = 3221225583u, InvalidWorkstation = 3221225584u, PasswordExpired = 3221225585u, AccountDisabled = 3221225586u, NoneMapped = 3221225587u, TooManyLuidsRequested = 3221225588u, LuidsExhausted = 3221225589u, InvalidSubAuthority = 3221225590u, InvalidAcl = 3221225591u, InvalidSid = 3221225592u, InvalidSecurityDescr = 3221225593u, ProcedureNotFound = 3221225594u, InvalidImageFormat = 3221225595u, NoToken = 3221225596u, BadInheritanceAcl = 3221225597u, RangeNotLocked = 3221225598u, DiskFull = 3221225599u, ServerDisabled = 3221225600u, ServerNotDisabled = 3221225601u, TooManyGuidsRequested = 3221225602u, GuidsExhausted = 3221225603u, InvalidIdAuthority = 3221225604u, AgentsExhausted = 3221225605u, InvalidVolumeLabel = 3221225606u, SectionNotExtended = 3221225607u, NotMappedData = 3221225608u, ResourceDataNotFound = 3221225609u, ResourceTypeNotFound = 3221225610u, ResourceNameNotFound = 3221225611u, ArrayBoundsExceeded = 3221225612u, FloatDenormalOperand = 3221225613u, FloatDivideByZero = 3221225614u, FloatInexactResult = 3221225615u, FloatInvalidOperation = 3221225616u, FloatOverflow = 3221225617u, FloatStackCheck = 3221225618u, FloatUnderflow = 3221225619u, IntegerDivideByZero = 3221225620u, IntegerOverflow = 3221225621u, PrivilegedInstruction = 3221225622u, TooManyPagingFiles = 3221225623u, FileInvalid = 3221225624u, InstanceNotAvailable = 3221225643u, PipeNotAvailable = 3221225644u, InvalidPipeState = 3221225645u, PipeBusy = 3221225646u, IllegalFunction = 3221225647u, PipeDisconnected = 3221225648u, PipeClosing = 3221225649u, PipeConnected = 3221225650u, PipeListening = 3221225651u, InvalidReadMode = 3221225652u, IoTimeout = 3221225653u, FileForcedClosed = 3221225654u, ProfilingNotStarted = 3221225655u, ProfilingNotStopped = 3221225656u, NotSameDevice = 3221225684u, FileRenamed = 3221225685u, CantWait = 3221225688u, PipeEmpty = 3221225689u, CantTerminateSelf = 3221225691u, InternalError = 3221225701u, InvalidParameter1 = 3221225711u, InvalidParameter2 = 3221225712u, InvalidParameter3 = 3221225713u, InvalidParameter4 = 3221225714u, InvalidParameter5 = 3221225715u, InvalidParameter6 = 3221225716u, InvalidParameter7 = 3221225717u, InvalidParameter8 = 3221225718u, InvalidParameter9 = 3221225719u, InvalidParameter10 = 3221225720u, InvalidParameter11 = 3221225721u, InvalidParameter12 = 3221225722u, MappedFileSizeZero = 3221225758u, TooManyOpenedFiles = 3221225759u, Cancelled = 3221225760u, CannotDelete = 3221225761u, InvalidComputerName = 3221225762u, FileDeleted = 3221225763u, SpecialAccount = 3221225764u, SpecialGroup = 3221225765u, SpecialUser = 3221225766u, MembersPrimaryGroup = 3221225767u, FileClosed = 3221225768u, TooManyThreads = 3221225769u, ThreadNotInProcess = 3221225770u, TokenAlreadyInUse = 3221225771u, PagefileQuotaExceeded = 3221225772u, CommitmentLimit = 3221225773u, InvalidImageLeFormat = 3221225774u, InvalidImageNotMz = 3221225775u, InvalidImageProtect = 3221225776u, InvalidImageWin16 = 3221225777u, LogonServer = 3221225778u, DifferenceAtDc = 3221225779u, SynchronizationRequired = 3221225780u, DllNotFound = 3221225781u, IoPrivilegeFailed = 3221225783u, OrdinalNotFound = 3221225784u, EntryPointNotFound = 3221225785u, ControlCExit = 3221225786u, PortNotSet = 3221226323u, DebuggerInactive = 3221226324u, CallbackBypass = 3221226755u, PortClosed = 3221227264u, MessageLost = 3221227265u, InvalidMessage = 3221227266u, RequestCanceled = 3221227267u, RecursiveDispatch = 3221227268u, LpcReceiveBufferExpected = 3221227269u, LpcInvalidConnectionUsage = 3221227270u, LpcRequestsNotAllowed = 3221227271u, ResourceInUse = 3221227272u, ProcessIsProtected = 3221227282u, VolumeDirty = 3221227526u, FileCheckedOut = 3221227777u, CheckOutRequired = 3221227778u, BadFileType = 3221227779u, FileTooLarge = 3221227780u, FormsAuthRequired = 3221227781u, VirusInfected = 3221227782u, VirusDeleted = 3221227783u, TransactionalConflict = 3222863873u, InvalidTransaction = 3222863874u, TransactionNotActive = 3222863875u, TmInitializationFailed = 3222863876u, RmNotActive = 3222863877u, RmMetadataCorrupt = 3222863878u, TransactionNotJoined = 3222863879u, DirectoryNotRm = 3222863880u, CouldNotResizeLog = 3222863881u, TransactionsUnsupportedRemote = 3222863882u, LogResizeInvalidSize = 3222863883u, RemoteFileVersionMismatch = 3222863884u, CrmProtocolAlreadyExists = 3222863887u, TransactionPropagationFailed = 3222863888u, CrmProtocolNotFound = 3222863889u, TransactionSuperiorExists = 3222863890u, TransactionRequestNotValid = 3222863891u, TransactionNotRequested = 3222863892u, TransactionAlreadyAborted = 3222863893u, TransactionAlreadyCommitted = 3222863894u, TransactionInvalidMarshallBuffer = 3222863895u, CurrentTransactionNotValid = 3222863896u, LogGrowthFailed = 3222863897u, ObjectNoLongerExists = 3222863905u, StreamMiniversionNotFound = 3222863906u, StreamMiniversionNotValid = 3222863907u, MiniversionInaccessibleFromSpecifiedTransaction = 3222863908u, CantOpenMiniversionWithModifyIntent = 3222863909u, CantCreateMoreStreamMiniversions = 3222863910u, HandleNoLongerValid = 3222863912u, NoTxfMetadata = 3222863913u, LogCorruptionDetected = 3222863920u, CantRecoverWithHandleOpen = 3222863921u, RmDisconnected = 3222863922u, EnlistmentNotSuperior = 3222863923u, RecoveryNotNeeded = 3222863924u, RmAlreadyStarted = 3222863925u, FileIdentityNotPersistent = 3222863926u, CantBreakTransactionalDependency = 3222863927u, CantCrossRmBoundary = 3222863928u, TxfDirNotEmpty = 3222863929u, IndoubtTransactionsExist = 3222863930u, TmVolatile = 3222863931u, RollbackTimerExpired = 3222863932u, TxfAttributeCorrupt = 3222863933u, EfsNotAllowedInTransaction = 3222863934u, TransactionalOpenNotAllowed = 3222863935u, TransactedMappingUnsupportedRemote = 3222863936u, TxfMetadataAlreadyPresent = 3222863937u, TransactionScopeCallbacksNotSet = 3222863938u, TransactionRequiredPromotion = 3222863939u, CannotExecuteFileInTransaction = 3222863940u, TransactionsNotFrozen = 3222863941u, MaximumNtStatus = uint.MaxValue } public static class User32 { [Flags] public enum KeyFlag { KF_EXTENDED = 0x100, KF_DLGMODE = 0x800, KF_MENUMODE = 0x1000, KF_ALTDOWN = 0x2000, KF_REPEAT = 0x4000, KF_UP = 0x8000 } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct MonitorInfoEx { public int Size; public RectStruct Monitor; public RectStruct WorkArea; public uint Flags; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DeviceName; public void Init() { Size = 104; DeviceName = string.Empty; } } public struct RectStruct { public int Left; public int Top; public int Right; public int Bottom; } [Flags] public enum TMEFlags : uint { TME_CANCEL = 0x80000000u, TME_HOVER = 1u, TME_LEAVE = 2u, TME_NONCLIENT = 0x10u, TME_QUERY = 0x40000000u } public struct TRACKMOUSEEVENT { public int cbSize; [MarshalAs(UnmanagedType.U4)] public TMEFlags dwFlags; public IntPtr hWnd; public uint dwHoverTime; public TRACKMOUSEEVENT(TMEFlags dwFlags, IntPtr hWnd, uint dwHoverTime) { cbSize = Marshal.SizeOf(typeof(TRACKMOUSEEVENT)); this.dwFlags = dwFlags; this.hWnd = hWnd; this.dwHoverTime = dwHoverTime; } } public enum VirtualKey { VK_LBUTTON = 1, VK_RBUTTON = 2, VK_CANCEL = 3, VK_MBUTTON = 4, VK_XBUTTON1 = 5, VK_XBUTTON2 = 6, VK_BACK = 8, VK_TAB = 9, VK_CLEAR = 12, VK_RETURN = 13, VK_SHIFT = 16, VK_CONTROL = 17, VK_MENU = 18, VK_PAUSE = 19, VK_CAPITAL = 20, VK_KANA = 21, VK_HANGEUL = 21, VK_HANGUL = 21, VK_JUNJA = 23, VK_FINAL = 24, VK_HANJA = 25, VK_KANJI = 25, VK_ESCAPE = 27, VK_CONVERT = 28, VK_NONCONVERT = 29, VK_ACCEPT = 30, VK_MODECHANGE = 31, VK_SPACE = 32, VK_PRIOR = 33, VK_NEXT = 34, VK_END = 35, VK_HOME = 36, VK_LEFT = 37, VK_UP = 38, VK_RIGHT = 39, VK_DOWN = 40, VK_SELECT = 41, VK_PRINT = 42, VK_EXECUTE = 43, VK_SNAPSHOT = 44, VK_INSERT = 45, VK_DELETE = 46, VK_HELP = 47, VK_LWIN = 91, VK_RWIN = 92, VK_APPS = 93, VK_SLEEP = 95, VK_NUMPAD0 = 96, VK_NUMPAD1 = 97, VK_NUMPAD2 = 98, VK_NUMPAD3 = 99, VK_NUMPAD4 = 100, VK_NUMPAD5 = 101, VK_NUMPAD6 = 102, VK_NUMPAD7 = 103, VK_NUMPAD8 = 104, VK_NUMPAD9 = 105, VK_MULTIPLY = 106, VK_ADD = 107, VK_SEPARATOR = 108, VK_SUBTRACT = 109, VK_DECIMAL = 110, VK_DIVIDE = 111, VK_F1 = 112, VK_F2 = 113, VK_F3 = 114, VK_F4 = 115, VK_F5 = 116, VK_F6 = 117, VK_F7 = 118, VK_F8 = 119, VK_F9 = 120, VK_F10 = 121, VK_F11 = 122, VK_F12 = 123, VK_F13 = 124, VK_F14 = 125, VK_F15 = 126, VK_F16 = 127, VK_F17 = 128, VK_F18 = 129, VK_F19 = 130, VK_F20 = 131, VK_F21 = 132, VK_F22 = 133, VK_F23 = 134, VK_F24 = 135, VK_NUMLOCK = 144, VK_SCROLL = 145, VK_OEM_NEC_EQUAL = 146, VK_OEM_FJ_JISHO = 146, VK_OEM_FJ_MASSHOU = 147, VK_OEM_FJ_TOUROKU = 148, VK_OEM_FJ_LOYA = 149, VK_OEM_FJ_ROYA = 150, VK_LSHIFT = 160, VK_RSHIFT = 161, VK_LCONTROL = 162, VK_RCONTROL = 163, VK_LMENU = 164, VK_RMENU = 165, VK_BROWSER_BACK = 166, VK_BROWSER_FORWARD = 167, VK_BROWSER_REFRESH = 168, VK_BROWSER_STOP = 169, VK_BROWSER_SEARCH = 170, VK_BROWSER_FAVORITES = 171, VK_BROWSER_HOME = 172, VK_VOLUME_MUTE = 173, VK_VOLUME_DOWN = 174, VK_VOLUME_UP = 175, VK_MEDIA_NEXT_TRACK = 176, VK_MEDIA_PREV_TRACK = 177, VK_MEDIA_STOP = 178, VK_MEDIA_PLAY_PAUSE = 179, VK_LAUNCH_MAIL = 180, VK_LAUNCH_MEDIA_SELECT = 181, VK_LAUNCH_APP1 = 182, VK_LAUNCH_APP2 = 183, VK_OEM_1 = 186, VK_OEM_PLUS = 187, VK_OEM_COMMA = 188, VK_OEM_MINUS = 189, VK_OEM_PERIOD = 190, VK_OEM_2 = 191, VK_OEM_3 = 192, VK_OEM_4 = 219, VK_OEM_5 = 220, VK_OEM_6 = 221, VK_OEM_7 = 222, VK_OEM_8 = 223, VK_OEM_AX = 225, VK_OEM_102 = 226, VK_ICO_HELP = 227, VK_ICO_00 = 228, VK_PROCESSKEY = 229, VK_ICO_CLEAR = 230, VK_PACKET = 231, VK_OEM_RESET = 233, VK_OEM_JUMP = 234, VK_OEM_PA1 = 235, VK_OEM_PA2 = 236, VK_OEM_PA3 = 237, VK_OEM_WSCTRL = 238, VK_OEM_CUSEL = 239, VK_OEM_ATTN = 240, VK_OEM_FINISH = 241, VK_OEM_COPY = 242, VK_OEM_AUTO = 243, VK_OEM_ENLW = 244, VK_OEM_BACKTAB = 245, VK_ATTN = 246, VK_CRSEL = 247, VK_EXSEL = 248, VK_EREOF = 249, VK_PLAY = 250, VK_ZOOM = 251, VK_NONAME = 252, VK_PA1 = 253, VK_OEM_CLEAR = 254 } [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate IntPtr WndProcDelegate(IntPtr windowHandle, WindowMessage message, IntPtr wParam, IntPtr lParam); public struct POINT { public int X; public int Y; public POINT(int x, int y) { X = x; Y = y; } } private const int CCHDEVICENAME = 32; [DllImport("user32.dll")] public static extern IntPtr SetThreadDpiAwarenessContext(IntPtr dpiContext); [DllImport("user32.dll")] public static extern IntPtr GetThreadDpiAwarenessContext(); [DllImport("user32.dll")] public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags); [DllImport("User32.dll")] public static extern bool GetMonitorInfo(IntPtr hMonitor, ref MonitorInfoEx lpmi); [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr GetModuleHandle([MarshalAs(UnmanagedType.LPWStr)] string lpModuleName); [DllImport("user32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWindowUnicode(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool IsChild(IntPtr hWndParent, IntPtr hWnd); [DllImport("user32.dll", SetLastError = true)] public static extern bool SetProcessDPIAware(); [DllImport("user32.dll")] public static extern int TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); [DllImport("user32.dll")] public static extern bool ReleaseCapture(); [DllImport("user32.dll")] public static extern IntPtr SetCapture(IntPtr hWnd); [DllImport("user32.dll")] public static extern IntPtr GetCapture(); [DllImport("user32.dll")] public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); [DllImport("user32.dll")] public static extern bool ScreenToClient(IntPtr hWnd, ref POINT lpPoint); [DllImport("user32.dll")] public static extern IntPtr WindowFromPoint(POINT p); [DllImport("user32.dll")] public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint); [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("USER32.dll")] public static extern short GetKeyState(VirtualKey nVirtKey); [DllImport("user32.dll")] public static extern IntPtr GetMessageExtraInfo(); [DllImport("user32.dll")] public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); [DllImport("user32.dll")] public static extern IntPtr SetCursor(IntPtr handle); [DllImport("user32.dll", EntryPoint = "GetWindowLong")] public static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex); [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")] public static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex); public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) { if (IntPtr.Size == 8) { return GetWindowLongPtr64(hWnd, nIndex); } return GetWindowLongPtr32(hWnd, nIndex); } public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong) { if (IntPtr.Size == 8) { return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); } return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32())); } [DllImport("user32.dll", EntryPoint = "SetWindowLong")] public static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")] public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong); [DllImport("user32.dll")] public static extern IntPtr CallWindowProc(IntPtr previousWindowProc, IntPtr windowHandle, WindowMessage message, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetCursorPos(out POINT point); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetCursorPos(int x, int y); } public enum VirtualKey : ushort { LeftButton = 1, RightButton = 2, Cancel = 3, MiddleButton = 4, ExtraButton1 = 5, ExtraButton2 = 6, Back = 8, Tab = 9, Clear = 12, Return = 13, Shift = 16, Control = 17, Menu = 18, Pause = 19, CapsLock = 20, Kana = 21, Hangeul = 21, Hangul = 21, Junja = 23, Final = 24, Hanja = 25, Kanji = 25, Escape = 27, Convert = 28, NonConvert = 29, Accept = 30, ModeChange = 31, Space = 32, Prior = 33, Next = 34, End = 35, Home = 36, Left = 37, Up = 38, Right = 39, Down = 40, Select = 41, Print = 42, Execute = 43, Snapshot = 44, Insert = 45, Delete = 46, Help = 47, N0 = 48, N1 = 49, N2 = 50, N3 = 51, N4 = 52, N5 = 53, N6 = 54, N7 = 55, N8 = 56, N9 = 57, A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71, H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78, O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85, V = 86, W = 87, X = 88, Y = 89, Z = 90, LeftWindows = 91, RightWindows = 92, Application = 93, Sleep = 95, Numpad0 = 96, Numpad1 = 97, Numpad2 = 98, Numpad3 = 99, Numpad4 = 100, Numpad5 = 101, Numpad6 = 102, Numpad7 = 103, Numpad8 = 104, Numpad9 = 105, Multiply = 106, Add = 107, Separator = 108, Subtract = 109, Decimal = 110, Divide = 111, F1 = 112, F2 = 113, F3 = 114, F4 = 115, F5 = 116, F6 = 117, F7 = 118, F8 = 119, F9 = 120, F10 = 121, F11 = 122, F12 = 123, F13 = 124, F14 = 125, F15 = 126, F16 = 127, F17 = 128, F18 = 129, F19 = 130, F20 = 131, F21 = 132, F22 = 133, F23 = 134, F24 = 135, NumLock = 144, ScrollLock = 145, NEC_Equal = 146, Fujitsu_Jisho = 146, Fujitsu_Masshou = 147, Fujitsu_Touroku = 148, Fujitsu_Loya = 149, Fujitsu_Roya = 150, LeftShift = 160, RightShift = 161, LeftControl = 162, RightControl = 163, LeftMenu = 164, RightMenu = 165, BrowserBack = 166, BrowserForward = 167, BrowserRefresh = 168, BrowserStop = 169, BrowserSearch = 170, BrowserFavorites = 171, BrowserHome = 172, VolumeMute = 173, VolumeDown = 174, VolumeUp = 175, MediaNextTrack = 176, MediaPrevTrack = 177, MediaStop = 178, MediaPlayPause = 179, LaunchMail = 180, LaunchMediaSelect = 181, LaunchApplication1 = 182, LaunchApplication2 = 183, OEM1 = 186, OEMPlus = 187, OEMComma = 188, OEMMinus = 189, OEMPeriod = 190, OEM2 = 191, OEM3 = 192, OEM4 = 219, OEM5 = 220, OEM6 = 221, OEM7 = 222, OEM8 = 223, OEMAX = 225, OEM102 = 226, ICOHelp = 227, ICO00 = 228, ProcessKey = 229, ICOClear = 230, Packet = 231, OEMReset = 233, OEMJump = 234, OEMPA1 = 235, OEMPA2 = 236, OEMPA3 = 237, OEMWSCtrl = 238, OEMCUSel = 239, OEMATTN = 240, OEMFinish = 241, OEMCopy = 242, OEMAuto = 243, OEMENLW = 244, OEMBackTab = 245, ATTN = 246, CRSel = 247, EXSel = 248, EREOF = 249, Play = 250, Zoom = 251, Noname = 252, PA1 = 253, OEMClear = 254 } public enum WindowMessage : uint { WM_NULL = 0u, WM_CREATE = 1u, WM_DESTROY = 2u, WM_MOVE = 3u, WM_SIZE = 5u, WM_ACTIVATE = 6u, WM_SETFOCUS = 7u, WM_KILLFOCUS = 8u, WM_ENABLE = 10u, WM_SETREDRAW = 11u, WM_SETTEXT = 12u, WM_GETTEXT = 13u, WM_GETTEXTLENGTH = 14u, WM_PAINT = 15u, WM_CLOSE = 16u, WM_QUERYENDSESSION = 17u, WM_QUERYOPEN = 19u, WM_ENDSESSION = 22u, WM_QUIT = 18u, WM_ERASEBKGND = 20u, WM_SYSCOLORCHANGE = 21u, WM_SHOWWINDOW = 24u, WM_WININICHANGE = 26u, WM_SETTINGCHANGE = 26u, WM_DEVMODECHANGE = 27u, WM_ACTIVATEAPP = 28u, WM_FONTCHANGE = 29u, WM_TIMECHANGE = 30u, WM_CANCELMODE = 31u, WM_SETCURSOR = 32u, WM_MOUSEACTIVATE = 33u, WM_CHILDACTIVATE = 34u, WM_QUEUESYNC = 35u, WM_GETMINMAXINFO = 36u, WM_PAINTICON = 38u, WM_ICONERASEBKGND = 39u, WM_NEXTDLGCTL = 40u, WM_SPOOLERSTATUS = 42u, WM_DRAWITEM = 43u, WM_MEASUREITEM = 44u, WM_DELETEITEM = 45u, WM_VKEYTOITEM = 46u, WM_CHARTOITEM = 47u, WM_SETFONT = 48u, WM_GETFONT = 49u, WM_SETHOTKEY = 50u, WM_GETHOTKEY = 51u, WM_QUERYDRAGICON = 55u, WM_COMPAREITEM = 57u, WM_GETOBJECT = 61u, WM_COMPACTING = 65u, [Obsolete] WM_COMMNOTIFY = 68u, WM_WINDOWPOSCHANGING = 70u, WM_WINDOWPOSCHANGED = 71u, [Obsolete] WM_POWER = 72u, WM_COPYDATA = 74u, WM_CANCELJOURNAL = 75u, WM_NOTIFY = 78u, WM_INPUTLANGCHANGEREQUEST = 80u, WM_INPUTLANGCHANGE = 81u, WM_TCARD = 82u, WM_HELP = 83u, WM_USERCHANGED = 84u, WM_NOTIFYFORMAT = 85u, WM_CONTEXTMENU = 123u, WM_STYLECHANGING = 124u, WM_STYLECHANGED = 125u, WM_DISPLAYCHANGE = 126u, WM_GETICON = 127u, WM_SETICON = 128u, WM_NCCREATE = 129u, WM_NCDESTROY = 130u, WM_NCCALCSIZE = 131u, WM_NCHITTEST = 132u, WM_NCPAINT = 133u, WM_NCACTIVATE = 134u, WM_GETDLGCODE = 135u, WM_SYNCPAINT = 136u, WM_UAHDESTROYWINDOW = 144u, WM_UAHDRAWMENU = 145u, WM_UAHDRAWMENUITEM = 146u, WM_UAHINITMENU = 147u, WM_UAHMEASUREMENUITEM = 148u, WM_UAHNCPAINTMENUPOPUP = 149u, WM_NCMOUSEMOVE = 160u, WM_NCLBUTTONDOWN = 161u, WM_NCLBUTTONUP = 162u, WM_NCLBUTTONDBLCLK = 163u, WM_NCRBUTTONDOWN = 164u, WM_NCRBUTTONUP = 165u, WM_NCRBUTTONDBLCLK = 166u, WM_NCMBUTTONDOWN = 167u, WM_NCMBUTTONUP = 168u, WM_NCMBUTTONDBLCLK = 169u, WM_NCXBUTTONDOWN = 171u, WM_NCXBUTTONUP = 172u, WM_NCXBUTTONDBLCLK = 173u, WM_BM_CLICK = 245u, WM_INPUT_DEVICE_CHANGE = 254u, WM_INPUT = 255u, WM_KEYFIRST = 256u, WM_KEYDOWN = 256u, WM_KEYUP = 257u, WM_CHAR = 258u, WM_DEADCHAR = 259u, WM_SYSKEYDOWN = 260u, WM_SYSKEYUP = 261u, WM_SYSCHAR = 262u, WM_SYSDEADCHAR = 263u, WM_UNICHAR = 265u, WM_KEYLAST = 265u, WM_IME_STARTCOMPOSITION = 269u, WM_IME_ENDCOMPOSITION = 270u, WM_IME_COMPOSITION = 271u, WM_IME_KEYLAST = 271u, WM_INITDIALOG = 272u, WM_COMMAND = 273u, WM_SYSCOMMAND = 274u, WM_TIMER = 275u, WM_HSCROLL = 276u, WM_VSCROLL = 277u, WM_INITMENU = 278u, WM_INITMENUPOPUP = 279u, WM_MENUSELECT = 287u, WM_MENUCHAR = 288u, WM_ENTERIDLE = 289u, WM_MENURBUTTONUP = 290u, WM_MENUDRAG = 291u, WM_MENUGETOBJECT = 292u, WM_UNINITMENUPOPUP = 293u, WM_MENUCOMMAND = 294u, WM_CHANGEUISTATE = 295u, WM_UPDATEUISTATE = 296u, WM_QUERYUISTATE = 297u, WM_CTLCOLORMSGBOX = 306u, WM_CTLCOLOREDIT = 307u, WM_CTLCOLORLISTBOX = 308u, WM_CTLCOLORBTN = 309u, WM_CTLCOLORDLG = 310u, WM_CTLCOLORSCROLLBAR = 311u, WM_CTLCOLORSTATIC = 312u, WM_MOUSEFIRST = 512u, WM_MOUSEMOVE = 512u, WM_LBUTTONDOWN = 513u, WM_LBUTTONUP = 514u, WM_LBUTTONDBLCLK = 515u, WM_RBUTTONDOWN = 516u, WM_RBUTTONUP = 517u, WM_RBUTTONDBLCLK = 518u, WM_MBUTTONDOWN = 519u, WM_MBUTTONUP = 520u, WM_MBUTTONDBLCLK = 521u, WM_MOUSEWHEEL = 522u, WM_XBUTTONDOWN = 523u, WM_XBUTTONUP = 524u, WM_XBUTTONDBLCLK = 525u, WM_MOUSEHWHEEL = 526u, WM_MOUSELAST = 526u, WM_PARENTNOTIFY = 528u, WM_ENTERMENULOOP = 529u, WM_EXITMENULOOP = 530u, WM_NEXTMENU = 531u, WM_SIZING = 532u, WM_CAPTURECHANGED = 533u, WM_MOVING = 534u, WM_POWERBROADCAST = 536u, WM_DEVICECHANGE = 537u, WM_MDICREATE = 544u, WM_MDIDESTROY = 545u, WM_MDIACTIVATE = 546u, WM_MDIRESTORE = 547u, WM_MDINEXT = 548u, WM_MDIMAXIMIZE = 549u, WM_MDITILE = 550u, WM_MDICASCADE = 551u, WM_MDIICONARRANGE = 552u, WM_MDIGETACTIVE = 553u, WM_MDISETMENU = 560u, WM_ENTERSIZEMOVE = 561u, WM_EXITSIZEMOVE = 562u, WM_DROPFILES = 563u, WM_MDIREFRESHMENU = 564u, WM_IME_SETCONTEXT = 641u, WM_IME_NOTIFY = 642u, WM_IME_CONTROL = 643u, WM_IME_COMPOSITIONFULL = 644u, WM_IME_SELECT = 645u, WM_IME_CHAR = 646u, WM_IME_REQUEST = 648u, WM_IME_KEYDOWN = 656u, WM_IME_KEYUP = 657u, WM_MOUSEHOVER = 673u, WM_MOUSELEAVE = 675u, WM_NCMOUSEHOVER = 672u, WM_NCMOUSELEAVE = 674u, WM_WTSSESSION_CHANGE = 689u, WM_TABLET_FIRST = 704u, WM_TABLET_LAST = 735u, WM_DPICHANGED = 736u, WM_CUT = 768u, WM_COPY = 769u, WM_PASTE = 770u, WM_CLEAR = 771u, WM_UNDO = 772u, WM_RENDERFORMAT = 773u, WM_RENDERALLFORMATS = 774u, WM_DESTROYCLIPBOARD = 775u, WM_DRAWCLIPBOARD = 776u, WM_PAINTCLIPBOARD = 777u, WM_VSCROLLCLIPBOARD = 778u, WM_SIZECLIPBOARD = 779u, WM_ASKCBFORMATNAME = 780u, WM_CHANGECBCHAIN = 781u, WM_HSCROLLCLIPBOARD = 782u, WM_QUERYNEWPALETTE = 783u, WM_PALETTEISCHANGING = 784u, WM_PALETTECHANGED = 785u, WM_HOTKEY = 786u, WM_PRINT = 791u, WM_PRINTCLIENT = 792u, WM_APPCOMMAND = 793u, WM_THEMECHANGED = 794u, WM_CLIPBOARDUPDATE = 797u, WM_DWMCOMPOSITIONCHANGED = 798u, WM_DWMNCRENDERINGCHANGED = 799u, WM_DWMCOLORIZATIONCOLORCHANGED = 800u, WM_DWMWINDOWMAXIMIZEDCHANGE = 801u, WM_GETTITLEBARINFOEX = 831u, WM_HANDHELDFIRST = 856u, WM_HANDHELDLAST = 863u, WM_AFXFIRST = 864u, WM_AFXLAST = 895u, WM_PENWINFIRST = 896u, WM_PENWINLAST = 911u, WM_APP = 32768u, WM_USER = 1024u, WM_CPL_LAUNCH = 5120u, WM_CPL_LAUNCHED = 5121u, WM_REFLECT = 8192u, WM_SYSTIMER = 280u } } namespace DearImGuiInjection.BepInEx { [BepInPlugin("iDeathHD.DearImGuiInjection", "DearImGuiInjection", "1.0.2")] internal class DearImGuiInjectionBaseUnityPlugin : BaseUnityPlugin { private Type _eventSystemType; private MethodInfo _eventSystemUpdate; private Hook _eventSystemUpdateHook; private void Awake() { Log.Init(new BepInExLog(((BaseUnityPlugin)this).Logger)); string configPath = Paths.ConfigPath; string assetsFolder = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets"); BepInExConfigEntry<VirtualKey> cursorVisibilityConfig = new BepInExConfigEntry<VirtualKey>(((BaseUnityPlugin)this).Config.Bind<VirtualKey>("Keybinds", "CursorVisibility", VirtualKey.Insert, "Key for switching the cursor visibility.")); DearImGuiInjection.Init(configPath, assetsFolder, cursorVisibilityConfig); SetupIgnoreUIObjectsWhenImGuiCursorIsVisible(); ((Component)this).gameObject.AddComponent<UnityMainThreadDispatcher>(); } private void SetupIgnoreUIObjectsWhenImGuiCursorIsVisible() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown try { BindingFlags bindingAttr = (BindingFlags)(-1); Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly ass) => ass.GetName().Name == "UnityEngine.UI"); _eventSystemType = assembly.GetType("UnityEngine.EventSystems.EventSystem"); _eventSystemUpdate = _eventSystemType.GetMethod("Update", bindingAttr); _eventSystemUpdateHook = new Hook((MethodBase)_eventSystemUpdate, (Delegate)new Action<Action<object>, object>(IgnoreUIObjectsWhenImGuiCursorIsVisible)); } catch (Exception data) { Log.Error(data); } } private static void IgnoreUIObjectsWhenImGuiCursorIsVisible(Action<object> orig, object self) { if (!DearImGuiInjection.IsCursorVisible || DearImGuiInjection.AllowPassthroughInput) { orig(self); } } private void OnDestroy() { Hook eventSystemUpdateHook = _eventSystemUpdateHook; if (eventSystemUpdateHook != null) { eventSystemUpdateHook.Dispose(); } DearImGuiInjection.Dispose(); } } public class UnityMainThreadDispatcher : MonoBehaviour { private static readonly Queue<Action> _executionQueue = new Queue<Action>(); private static UnityMainThreadDispatcher _instance; private void Awake() { _instance = this; } private void OnDestroy() { _instance = null; lock (_executionQueue) { _executionQueue.Clear(); } } public void Update() { lock (_executionQueue) { while (_executionQueue.Count > 0) { _executionQueue.Dequeue()(); } } } public static void Enqueue(IEnumerator action) { lock (_executionQueue) { _executionQueue.Enqueue(delegate { ((MonoBehaviour)_instance).StartCoroutine(action); }); } } public static void Enqueue(Action action) { Enqueue(ActionWrapper(action)); } public static IEnumerator ActionWrapper(Action a) { a(); yield return null; } } } namespace DearImGuiInjection.Backends { internal static class ImGuiDX11 { private static IntPtr _windowHandle; private static RenderTargetView _renderTargetView; private static User32.WndProcDelegate _myWindowProc; private static IntPtr _originalWindowProc; private const int GWL_WNDPROC = -4; private static User32.POINT _cursorCoords; internal static void Init() { DX11Renderer.OnPresent += InitImGui; DX11Renderer.OnPresent += RenderImGui; DX11Renderer.PreResizeBuffers += PreResizeBuffers; DX11Renderer.PostResizeBuffers += PostResizeBuffers; } internal static void Dispose() { if (DearImGuiInjection.Initialized) { DX11Renderer.PostResizeBuffers -= PostResizeBuffers; DX11Renderer.PreResizeBuffers -= PreResizeBuffers; DX11Renderer.OnPresent -= RenderImGui; User32.SetWindowLong(_windowHandle, -4, _originalWindowProc); ImGuiWin32Impl.Shutdown(); _renderTargetView = null; Log.Info("ImGui.ImGuiImplDX11Shutdown()"); ImGuiDX11Impl.Shutdown(); _windowHandle = IntPtr.Zero; } } private static void InitImGui(SwapChain swapChain, uint syncInterval, uint flags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) IntPtr outputHandle = swapChain.Description.OutputHandle; if (!DearImGuiInjection.Initialized) { DearImGuiInjection.InitImGui(); InitImGuiWin32(outputHandle); DearImGuiInjection.UpdateCursorVisibility(); InitImGuiDX11(swapChain); DearImGuiInjection.Initialized = true; } DX11Renderer.OnPresent -= InitImGui; } private static void InitImGuiWin32(IntPtr windowHandle) { if (!DearImGuiInjection.Initialized) { _windowHandle = windowHandle; if (!(_windowHandle == IntPtr.Zero)) { Log.Info($"ImGuiImplWin32Init, Window Handle: {windowHandle:X}"); ImGuiWin32Impl.Init(_windowHandle); _myWindowProc = WndProcHandler; _originalWindowProc = User32.SetWindowLong(windowHandle, -4, Marshal.GetFunctionPointerForDelegate(_myWindowProc)); } } } private unsafe static void InitImGuiDX11(SwapChain swapChain) { Device val = InitImGuiDX11Internal(swapChain); try { ImGuiDX11Impl.Init((void*)((CppObject)val).NativePointer, (void*)((CppObject)val.ImmediateContext).NativePointer); } finally { ((IDisposable)val)?.Dispose(); } } private static Device InitImGuiDX11Internal(SwapChain swapChain) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Device device = ((DeviceChild)swapChain).GetDevice<Device>(); Texture2D backBuffer = swapChain.GetBackBuffer<Texture2D>(0); try { _renderTargetView = new RenderTargetView(device, (Resource)(object)backBuffer); return device; } finally { ((IDisposable)backBuffer)?.Dispose(); } } private static IntPtr WndProcHandler(IntPtr windowHandle, WindowMessage message, IntPtr wParam, IntPtr lParam) { ImGuiWin32Impl.WndProcHandler(windowHandle, message, wParam, lParam); if (message == WindowMessage.WM_KEYUP && (uint)(ushort)(int)wParam == (uint)DearImGuiInjection.CursorVisibilityToggle.Get()) { SaveOrRestoreCursorPosition(); DearImGuiInjection.ToggleCursor(); } return User32.CallWindowProc(_originalWindowProc, windowHandle, message, wParam, lParam); } private static void SaveOrRestoreCursorPosition() { if (DearImGuiInjection.IsCursorVisible) { User32.GetCursorPos(out _cursorCoords); } else if (_cursorCoords.X + _cursorCoords.Y != 0) { User32.SetCursorPos(_cursorCoords.X, _cursorCoords.Y); } } private unsafe static void RenderImGui(SwapChain swapChain, uint syncInterval, uint flags) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) IntPtr outputHandle = swapChain.Description.OutputHandle; if (!IsTargetWindowHandle(outputHandle)) { Log.Info($"[DX11] Discarding window handle {outputHandle:X} due to mismatch"); return; } ImGuiDX11Impl.NewFrame(); NewFrame(); Device device = ((DeviceChild)swapChain).GetDevice<Device>(); try { device.ImmediateContext.OutputMerger.SetRenderTargets(_renderTargetView); ImDrawDataPtr drawData = ImGui.GetDrawData(); ImGuiDX11Impl.RenderDrawData(((ImDrawDataPtr)(ref drawData)).NativePtr); } finally { ((IDisposable)device)?.Dispose(); } } private static bool IsTargetWindowHandle(IntPtr windowHandle) { if (windowHandle != IntPtr.Zero) { if (!(windowHandle == _windowHandle)) { return !DearImGuiInjection.Initialized; } return true; } return false; } private static void NewFrame() { ImGuiWin32Impl.NewFrame(); ImGui.NewFrame(); if (DearImGuiInjection.RenderAction != null) { Delegate[] invocationList = DearImGuiInjection.RenderAction.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action action = (Action)invocationList[i]; try { action(); } catch (Exception data) { Log.Error(data); } } } ImGui.EndFrame(); ImGui.Render(); } private static void PreResizeBuffers(SwapChain swapChain, uint bufferCount, uint width, uint height, Format newFormat, uint swapchainFlags) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!DearImGuiInjection.Initialized) { return; } IntPtr outputHandle = swapChain.Description.OutputHandle; Log.Info($"[DX11 ResizeBuffers] Window Handle {outputHandle:X}"); if (!IsTargetWindowHandle(outputHandle)) { Log.Info($"[DX11 ResizeBuffers] Discarding window handle {outputHandle:X} due to mismatch"); return; } RenderTargetView renderTargetView = _renderTargetView; if (renderTargetView != null) { ((DisposeBase)renderTargetView).Dispose(); } _renderTargetView = null; ImGuiDX11Impl.InvalidateDeviceObjects(); } private static void PostResizeBuffers(SwapChain swapChain, uint bufferCount, uint width, uint height, Format newFormat, uint swapchainFlags) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown if (!DearImGuiInjection.Initialized) { return; } IntPtr outputHandle = swapChain.Description.OutputHandle; if (!IsTargetWindowHandle(outputHandle)) { Log.Info($"[DX11 ResizeBuffers] Discarding window handle {outputHandle:X} due to mismatch"); return; } ImGuiDX11Impl.CreateDeviceObjects(); Device device = ((DeviceChild)swapChain).GetDevice<Device>(); try { Texture2D backBuffer = swapChain.GetBackBuffer<Texture2D>(0); try { _renderTargetView = new RenderTargetView(device, (Resource)(object)backBuffer); } finally { ((IDisposable)backBuffer)?.Dispose(); } } finally { ((IDisposable)device)?.Dispose(); } } } public static class ImGuiDX11Impl { public struct VERTEX_CONSTANT_BUFFER_DX11 { public unsafe fixed float mvp[16]; } private unsafe delegate void ImDrawUserCallBack(ImDrawList* a, ImDrawCmd* b); private class StateBackup { public InputLayout InputLayout; public PrimitiveTopology PrimitiveTopology; public Buffer IndexBuffer; public Format IndexBufferFormat; public int IndexBufferOffset; public Buffer[] VertexBuffers; public int[] VertexBufferStrides; public int[] VertexBufferOffsets; public RasterizerState RS; public Rectangle[] ScissorRects; public RawViewportF[] Viewports; public BlendState BlendState; public RawColor4 BlendFactor; public int SampleMask; public DepthStencilState DepthStencilState; public int DepthStencilRef; public DepthStencilView DepthStencilView; public RenderTargetView[] RenderTargetViews; public VertexShader VS; public Buffer[] VSConstantBuffers; public SamplerState[] VSSamplers; public ShaderResourceView[] VSResourceViews; public HullShader HS; public Buffer[] HSConstantBuffers; public SamplerState[] HSSamplers; public ShaderResourceView[] HSResourceViews; public DomainShader DS; public Buffer[] DSConstantBuffers; public SamplerState[] DSSamplers; public ShaderResourceView[] DSResourceViews; public GeometryShader GS; public Buffer[] GSConstantBuffers; public SamplerState[] GSSamplers; public ShaderResourceView[] GSResourceViews; public PixelShader PS; public Buffer[] PSConstantBuffers; public SamplerState[] PSSamplers; public ShaderResourceView[] PSResourceViews; public ComputeShader CS; public Buffer[] CSConstantBuffers; public SamplerState[] CSSamplers; public ShaderResourceView[] CSResourceViews; public UnorderedAccessView[] CSUAVs; } private static IntPtr _renderNamePtr; private static Device _device; private static DeviceContext _deviceContext; private static ShaderResourceView _fontResourceView; private static SamplerState _fontSampler; private static VertexShader _vertexShader; private static PixelShader _pixelShader; private static InputLayout _inputLayout; private static Buffer _vertexConstantBuffer; private static BlendState _blendState; private static RasterizerState _rasterizerState; private static DepthStencilState _depthStencilState; private static Buffer _vertexBuffer; private static Buffer _indexBuffer; private static int _vertexBufferSize; private static int _indexBufferSize; private static VertexBufferBinding _vertexBinding; private static RawColor4 _blendColor = new RawColor4(0f, 0f, 0f, 0f); private unsafe static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, IntPtr ID3D11DeviceContextPtr) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) DeviceContext val = new DeviceContext(ID3D11DeviceContextPtr); val.Rasterizer.SetViewport(0f, 0f, ((ImDrawData)draw_data).DisplaySize.X, ((ImDrawData)draw_data).DisplaySize.Y, 0f, 1f); val.InputAssembler.InputLayout = _inputLayout; InputAssemblerStage inputAssembler = val.InputAssembler; VertexBufferBinding val2 = default(VertexBufferBinding); ((VertexBufferBinding)(ref val2)).Stride = Unsafe.SizeOf<ImDrawVert>(); ((VertexBufferBinding)(ref val2)).Offset = 0; ((VertexBufferBinding)(ref val2)).Buffer = _vertexBuffer; inputAssembler.SetVertexBuffers(0, val2); val.InputAssembler.SetIndexBuffer(_indexBuffer, (Format)57, 0); val.InputAssembler.PrimitiveTopology = (PrimitiveTopology)4; ((CommonShaderStage)val.VertexShader).SetShader((DeviceChild)(object)_vertexShader, (ClassInstance[])null, 0); ((CommonShaderStage)val.VertexShader).SetConstantBuffer(0, _vertexConstantBuffer); ((CommonShaderStage)val.PixelShader).SetShader((DeviceChild)(object)_pixelShader, (ClassInstance[])null, 0); ((CommonShaderStage)val.PixelShader).SetSampler(0, _fontSampler); ((CommonShaderStage)val.GeometryShader).SetShader((DeviceChild)null, (ClassInstance[])null, 0); ((CommonShaderStage)val.HullShader).SetShader((DeviceChild)null, (ClassInstance[])null, 0); ((CommonShaderStage)val.DomainShader).SetShader((DeviceChild)null, (ClassInstance[])null, 0); ((CommonShaderStage)val.ComputeShader).SetShader((DeviceChild)null, (ClassInstance[])null, 0); RawColor4 value = default(RawColor4); ((RawColor4)(ref value))..ctor(0f, 0f, 0f, 0f); val.OutputMerger.SetBlendState(_blendState, (RawColor4?)value, uint.MaxValue); val.OutputMerger.SetDepthStencilState(_depthStencilState, 0); val.Rasterizer.State = _rasterizerState; } public unsafe static void RenderDrawData(ImDrawData* draw_data) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_05cc: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0605: Unknown result type (might be due to invalid IL or missing references) if (((ImDrawData)draw_data).DisplaySize.X <= 0f || ((ImDrawData)draw_data).DisplaySize.Y <= 0f) { return; } DeviceContext deviceContext = _deviceContext; if (_vertexBuffer == null || _vertexBufferSize < ((ImDrawData)draw_data).TotalVtxCount) { Buffer vertexBuffer = _vertexBuffer; if (vertexBuffer != null) { ((DisposeBase)vertexBuffer).Dispose(); } _vertexBufferSize = ((ImDrawData)draw_data).TotalVtxCount + 5000; _vertexBuffer = new Buffer(_device, new BufferDescription { Usage = (ResourceUsage)2, SizeInBytes = _vertexBufferSize * Unsafe.SizeOf<ImDrawVert>(), BindFlags = (BindFlags)1, CpuAccessFlags = (CpuAccessFlags)65536, OptionFlags = (ResourceOptionFlags)0 }); VertexBufferBinding vertexBinding = default(VertexBufferBinding); ((VertexBufferBinding)(ref vertexBinding)).Buffer = _vertexBuffer; ((VertexBufferBinding)(ref vertexBinding)).Stride = Unsafe.SizeOf<ImDrawVert>(); ((VertexBufferBinding)(ref vertexBinding)).Offset = 0; _vertexBinding = vertexBinding; } if (_indexBuffer == null || _indexBufferSize < ((ImDrawData)draw_data).TotalIdxCount) { Buffer indexBuffer = _indexBuffer; if (indexBuffer != null) { ((DisposeBase)indexBuffer).Dispose(); } _indexBufferSize = ((ImDrawData)draw_data).TotalIdxCount + 10000; _indexBuffer = new Buffer(_device, new BufferDescription { Usage = (ResourceUsage)2, SizeInBytes = _indexBufferSize * 2, BindFlags = (BindFlags)2, CpuAccessFlags = (CpuAccessFlags)65536 }); } DataStream val = default(DataStream); deviceContext.MapSubresource(_vertexBuffer, (MapMode)4, (MapFlags)0, ref val); DataStream val2 = default(DataStream); deviceContext.MapSubresource(_indexBuffer, (MapMode)4, (MapFlags)0, ref val2); ImDrawVert* ptr = (ImDrawVert*)(void*)val.DataPointer; ushort* ptr2 = (ushort*)(void*)val2.DataPointer; for (int i = 0; i < ((ImDrawData)draw_data).CmdListsCount; i++) { ImDrawList* ptr3 = ((ImDrawData)draw_data).CmdLists[i]; int num = ((ImVector)(&((ImDrawList)ptr3).VtxBuffer)).Size * Unsafe.SizeOf<ImDrawVert>(); Buffer.MemoryCopy((void*)((ImVector)(&((ImDrawList)ptr3).VtxBuffer)).Data, ptr, num, num); num = ((ImVector)(&((ImDrawList)ptr3).IdxBuffer)).Size * 2; Buffer.MemoryCopy((void*)((ImVector)(&((ImDrawList)ptr3).IdxBuffer)).Data, ptr2, num, num); ptr = (ImDrawVert*)((byte*)ptr + (nint)((ImVector)(&((ImDrawList)ptr3).VtxBuffer)).Size * (nint)Unsafe.SizeOf<ImDrawVert>()); ptr2 += ((ImVector)(&((ImDrawList)ptr3).IdxBuffer)).Size; } deviceContext.UnmapSubresource((Resource)(object)_vertexBuffer, 0); deviceContext.UnmapSubresource((Resource)(object)_indexBuffer, 0); DataStream val3 = default(DataStream); deviceContext.MapSubresource(_vertexConstantBuffer, (MapMode)4, (MapFlags)0, ref val3); VERTEX_CONSTANT_BUFFER_DX11* ptr4 = (VERTEX_CONSTANT_BUFFER_DX11*)(void*)val3.DataPointer; float x = ((ImDrawData)draw_data).DisplayPos.X; float num2 = ((ImDrawData)draw_data).DisplayPos.X + ((ImDrawData)draw_data).DisplaySize.X; float y = ((ImDrawData)draw_data).DisplayPos.Y; float num3 = ((ImDrawData)draw_data).DisplayPos.Y + ((ImDrawData)draw_data).DisplaySize.Y; float* fixedElementField = ptr4->mvp; *fixedElementField = 2f / (num2 - x); ptr4->mvp[1] = 0f; ptr4->mvp[2] = 0f; ptr4->mvp[3] = 0f; ptr4->mvp[4] = 0f; ptr4->mvp[5] = 2f / (y - num3); ptr4->mvp[6] = 0f; ptr4->mvp[7] = 0f; ptr4->mvp[8] = 0f; ptr4->mvp[9] = 0f; ptr4->mvp[10] = 0.5f; ptr4->mvp[11] = 0f; ptr4->mvp[12] = (num2 + x) / (x - num2); ptr4->mvp[13] = (y + num3) / (num3 - y); ptr4->mvp[14] = 0.5f; ptr4->mvp[15] = 1f; deviceContext.UnmapSubresource((Resource)(object)_vertexConstantBuffer, 0); StateBackup old = BackupRenderState(deviceContext); ImGui_ImplDX11_SetupRenderState(draw_data, ((CppObject)deviceContext).NativePointer); int num4 = 0; int num5 = 0; Vector2 displayPos = ((ImDrawData)draw_data).DisplayPos; RawRectangle val5 = default(RawRectangle); for (int j = 0; j < ((ImDrawData)draw_data).CmdListsCount; j++) { ImDrawList* ptr5 = ((ImDrawData)draw_data).CmdLists[j]; for (int k = 0; k < ((ImVector)(&((ImDrawList)ptr5).CmdBuffer)).Size; k++) { ImDrawCmd val4 = ((ImVector)(&((ImDrawList)ptr5).CmdBuffer)).Ref<ImDrawCmd>(k); if (val4.UserCallback != IntPtr.Zero) { ImDrawUserCallBack delegateForFunctionPointer = Marshal.GetDelegateForFunctionPointer<ImDrawUserCallBack>(val4.UserCallback); if (val4.UserCallback == new IntPtr(-1)) { ImGui_ImplDX11_SetupRenderState(draw_data, ((CppObject)deviceContext).NativePointer); } else { delegateForFunctionPointer(ptr5, &val4); } continue; } Vector2 vector = new Vector2(val4.ClipRect.X - displayPos.X, val4.ClipRect.Y - displayPos.Y); Vector2 vector2 = new Vector2(val4.ClipRect.Z - displayPos.X, val4.ClipRect.W - displayPos.Y); if (!(vector2.X <= vector.X) && !(vector2.Y <= vector.Y)) { ((RawRectangle)(ref val5))..ctor((int)vector.X, (int)vector.Y, (int)vector2.X, (int)vector2.Y); deviceContext.Rasterizer.SetScissorRectangles<RawRectangle>((RawRectangle[])(object)new RawRectangle[1] { val5 }); ((CommonShaderStage)deviceContext.PixelShader).SetShaderResource(0, new ShaderResourceView(val4.TextureId)); deviceContext.DrawIndexed((int)val4.ElemCount, (int)(val4.IdxOffset + num4), (int)(val4.VtxOffset + num5)); } } num4 += ((ImVector)(&((ImDrawList)ptr5).IdxBuffer)).Size; num5 += ((ImVector)(&((ImDrawList)ptr5).VtxBuffer)).Size; } RestoreRenderState(deviceContext, old); } private static StateBackup BackupRenderState(DeviceContext ctx) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) StateBackup stateBackup = new StateBackup { ScissorRects = new Rectangle[16], Viewports = (RawViewportF[])(object)new RawViewportF[16], VertexBuffers = (Buffer[])(object)new Buffer[32], VertexBufferStrides = new int[32], VertexBufferOffsets = new int[32], InputLayout = ctx.InputAssembler.InputLayout }; ctx.InputAssembler.GetIndexBuffer(ref stateBackup.IndexBuffer, ref stateBackup.IndexBufferFormat, ref stateBackup.IndexBufferOffset); stateBackup.PrimitiveTopology = ctx.InputAssembler.PrimitiveTopology; ctx.InputAssembler.GetVertexBuffers(0, 32, stateBackup.VertexBuffers, stateBackup.VertexBufferStrides, stateBackup.VertexBufferOffsets); stateBackup.RS = ctx.Rasterizer.State; ctx.Rasterizer.GetScissorRectangles<Rectangle>(stateBackup.ScissorRects); ctx.Rasterizer.GetViewports<RawViewportF>(stateBackup.Viewports); stateBackup.BlendState = ctx.OutputMerger.GetBlendState(ref stateBackup.BlendFactor, ref stateBackup.SampleMask); stateBackup.DepthStencilState = ctx.OutputMerger.GetDepthStencilState(ref stateBackup.DepthStencilRef); stateBackup.RenderTargetViews = ctx.OutputMerger.GetRenderTargets(8, ref stateBackup.DepthStencilView); stateBackup.VS = ((CommonShaderStage<VertexShader>)(object)ctx.VertexShader).Get(); stateBackup.VSSamplers = ((CommonShaderStage)ctx.VertexShader).GetSamplers(0, 16); stateBackup.VSConstantBuffers = ((CommonShaderStage)ctx.VertexShader).GetConstantBuffers(0, 14); stateBackup.VSResourceViews = ((CommonShaderStage)ctx.VertexShader).GetShaderResources(0, 128); stateBackup.HS = ((CommonShaderStage<HullShader>)(object)ctx.HullShader).Get(); stateBackup.HSSamplers = ((CommonShaderStage)ctx.HullShader).GetSamplers(0, 16); stateBackup.HSConstantBuffers = ((CommonShaderStage)ctx.HullShader).GetConstantBuffers(0, 14); stateBackup.HSResourceViews = ((CommonShaderStage)ctx.HullShader).GetShaderResources(0, 128); stateBackup.DS = ((CommonShaderStage<DomainShader>)(object)ctx.DomainShader).Get(); stateBackup.DSSamplers = ((CommonShaderStage)ctx.DomainShader).GetSamplers(0, 16); stateBackup.DSConstantBuffers = ((CommonShaderStage)ctx.DomainShader).GetConstantBuffers(0, 14); stateBackup.DSResourceViews = ((CommonShaderStage)ctx.DomainShader).GetShaderResources(0, 128); stateBackup.GS = ((CommonShaderStage<GeometryShader>)(object)ctx.GeometryShader).Get(); stateBackup.GSSamplers = ((CommonShaderStage)ctx.GeometryShader).GetSamplers(0, 16); stateBackup.GSConstantBuffers = ((CommonShaderStage)ctx.GeometryShader).GetConstantBuffers(0, 14); stateBackup.GSResourceViews = ((CommonShaderStage)ctx.GeometryShader).GetShaderResources(0, 128); stateBackup.PS = ((CommonShaderStage<PixelShader>)(object)ctx.PixelShader).Get(); stateBackup.PSSamplers = ((CommonShaderStage)ctx.PixelShader).GetSamplers(0, 16); stateBackup.PSConstantBuffers = ((CommonShaderStage)ctx.PixelShader).GetConstantBuffers(0, 14); stateBackup.PSResourceViews = ((CommonShaderStage)ctx.PixelShader).GetShaderResources(0, 128); stateBackup.CS = ((CommonShaderStage<ComputeShader>)(object)ctx.ComputeShader).Get(); stateBackup.CSSamplers = ((CommonShaderStage)ctx.ComputeShader).GetSamplers(0, 16); stateBackup.CSConstantBuffers = ((CommonShaderStage)ctx.ComputeShader).GetConstantBuffers(0, 14); stateBackup.CSResourceViews = ((CommonShaderStage)ctx.ComputeShader).GetShaderResources(0, 128); stateBackup.CSUAVs = ctx.ComputeShader.GetUnorderedAccessViews(0, 8); return stateBackup; } private static void RestoreRenderState(DeviceContext ctx, StateBackup old) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) ctx.InputAssembler.InputLayout = old.InputLayout; ctx.InputAssembler.SetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); ctx.InputAssembler.PrimitiveTopology = old.PrimitiveTopology; ctx.InputAssembler.SetVertexBuffers(0, old.VertexBuffers, old.VertexBufferStrides, old.VertexBufferOffsets); ctx.Rasterizer.State = old.RS; ctx.Rasterizer.SetScissorRectangles<Rectangle>(old.ScissorRects); ctx.Rasterizer.SetViewports(old.Viewports, old.Viewports.Length); ctx.OutputMerger.SetBlendState(old.BlendState, (RawColor4?)old.BlendFactor, old.SampleMask); ctx.OutputMerger.SetDepthStencilState(old.DepthStencilState, old.DepthStencilRef); ctx.OutputMerger.SetRenderTargets(old.DepthStencilView, old.RenderTargetViews); ((CommonShaderStage<VertexShader>)(object)ctx.VertexShader).Set(old.VS); ((CommonShaderStage)ctx.VertexShader).SetSamplers(0, old.VSSamplers); ((CommonShaderStage)ctx.VertexShader).SetConstantBuffers(0, old.VSConstantBuffers); ((CommonShaderStage)ctx.VertexShader).SetShaderResources(0, old.VSResourceViews); ((CommonShaderStage<HullShader>)(object)ctx.HullShader).Set(old.HS); ((CommonShaderStage)ctx.HullShader).SetSamplers(0, old.HSSamplers); ((CommonShaderStage)ctx.HullShader).SetConstantBuffers(0, old.HSConstantBuffers); ((CommonShaderStage)ctx.HullShader).SetShaderResources(0, old.HSResourceViews); ((CommonShaderStage<DomainShader>)(object)ctx.DomainShader).Set(old.DS); ((CommonShaderStage)ctx.DomainShader).SetSamplers(0, old.DSSamplers); ((CommonShaderStage)ctx.DomainShader).SetConstantBuffers(0, old.DSConstantBuffers); ((CommonShaderStage)ctx.DomainShader).SetShaderResources(0, old.DSResourceViews); ((CommonShaderStage<GeometryShader>)(object)ctx.GeometryShader).Set(old.GS); ((CommonShaderStage)ctx.GeometryShader).SetSamplers(0, old.GSSamplers); ((CommonShaderStage)ctx.GeometryShader).SetConstantBuffers(0, old.GSConstantBuffers); ((CommonShaderStage)ctx.GeometryShader).SetShaderResources(0, old.GSResourceViews); ((CommonShaderStage<PixelShader>)(object)ctx.PixelShader).Set(old.PS); ((CommonShaderStage)ctx.PixelShader).SetSamplers(0, old.PSSamplers); ((CommonShaderStage)ctx.PixelShader).SetConstantBuffers(0, old.PSConstantBuffers); ((CommonShaderStage)ctx.PixelShader).SetShaderResources(0, old.PSResourceViews); ((CommonShaderStage<ComputeShader>)(object)ctx.ComputeShader).Set(old.CS); ((CommonShaderStage)ctx.ComputeShader).SetSamplers(0, old.CSSamplers); ((CommonShaderStage)ctx.ComputeShader).SetConstantBuffers(0, old.CSConstantBuffers); ((CommonShaderStage)ctx.ComputeShader).SetShaderResources(0, old.CSResourceViews); ctx.ComputeShader.SetUnorderedAccessViews(0, old.CSUAVs); } public static void CreateFontsTexture() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown ImGuiIOPtr iO = ImGui.GetIO(); ImFontAtlasPtr fonts = ((ImGuiIOPtr)(ref iO)).Fonts; IntPtr intPtr = default(IntPtr); int num = default(int); int height = default(int); int num2 = default(int); ((ImFontAtlasPtr)(ref fonts)).GetTexDataAsRGBA32(ref intPtr, ref num, ref height, ref num2); Texture2DDescription val = default(Texture2DDescription); val.Width = num; val.Height = height; val.MipLevels = 1; val.ArraySize = 1; val.Format = (Format)28; val.SampleDescription = new SampleDescription(1, 0); val.Usage = (ResourceUsage)1; val.BindFlags = (BindFlags)8; val.CpuAccessFlags = (CpuAccessFlags)0; val.OptionFlags = (ResourceOptionFlags)0; Texture2DDescription val2 = val; Texture2D val3 = new Texture2D(_device, val2, (DataRectangle[])(object)new DataRectangle[1] { new DataRectangle(intPtr, num * num2) }); try { _fontResourceView = new ShaderResourceView(_device, (Resource)(object)val3, new ShaderResourceViewDescription { Format = val2.Format, Dimension = (ShaderResourceViewDimension)4, Texture2D = { MipLevels = val2.MipLevels } }); } finally { ((IDisposable)val3)?.Dispose(); } fonts = ((ImGuiIOPtr)(ref iO)).Fonts; ((ImFontAtlasPtr)(ref fonts)).SetTexID(((CppObject)_fontResourceView).NativePointer); _fontSampler = new SamplerState(_device, new SamplerStateDescription { Filter = (Filter)21, AddressU = (TextureAddressMode)1, AddressV = (TextureAddressMode)1, AddressW = (TextureAddressMode)1, MipLodBias = 0f, ComparisonFunction = (Comparison)8, MinimumLod = 0f, MaximumLod = 0f }); } public static bool CreateDeviceObjects() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Expected O, but got Unknown //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown if (_device == null) { return false; } if (_fontSampler != null) { InvalidateDeviceObjects(); } string path = Path.Combine(DearImGuiInjection.AssetsFolderPath, "Shaders"); byte[] array = File.ReadAllBytes(Path.Combine(path, "imgui-vertex.hlsl.bytes")); _vertexShader = new VertexShader(_device, array, (ClassLinkage)null); _inputLayout = new InputLayout(_device, array, (InputElement[])(object)new InputElement[3] { new InputElement("POSITION", 0, (Format)16, 0), new InputElement("TEXCOORD", 0, (Format)16, 0), new InputElement("COLOR", 0, (Format)28, 0) }); _vertexConstantBuffer = new Buffer(_device, new BufferDescription { Usage = (ResourceUsage)2, BindFlags = (BindFlags)4, CpuAccessFlags = (CpuAccessFlags)65536, OptionFlags = (ResourceOptionFlags)0, SizeInBytes = 64 }); byte[] array2 = File.ReadAllBytes(Path.Combine(path, "imgui-frag.hlsl.bytes")); _pixelShader = new PixelShader(_device, array2, (ClassLinkage)null); BlendStateDescription val = default(BlendStateDescription); val.AlphaToCoverageEnable = RawBool.op_Implicit(false); BlendStateDescription val2 = val; ((BlendStateDescription)(ref val2)).RenderTarget[0].IsBlendEnabled = RawBool.op_Implicit(true); ((BlendStateDescription)(ref val2)).RenderTarget[0].SourceBlend = (BlendOption)5; ((BlendStateDescription)(ref val2)).RenderTarget[0].DestinationBlend = (BlendOption)6; ((BlendStateDescription)(ref val2)).RenderTarget[0].BlendOperation = (BlendOperation
BepInEx/plugins/DearImGuiInjection/System.ComponentModel.Primitives.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using FxResources.System.ComponentModel.Primitives; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.ComponentModel.Primitives")] [assembly: AssemblyDescription("System.ComponentModel.Primitives")] [assembly: AssemblyDefaultAlias("System.ComponentModel.Primitives")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.1.1.0")] namespace FxResources.System.ComponentModel.Primitives { internal static class SR : Object { } } namespace System { internal static class SR : Object { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.ComponentModel.Primitives.SR"; private static ResourceManager ResourceManager { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string PropertyCategoryAction => GetResourceString("PropertyCategoryAction", null); internal static string PropertyCategoryAppearance => GetResourceString("PropertyCategoryAppearance", null); internal static string PropertyCategoryAsynchronous => GetResourceString("PropertyCategoryAsynchronous", null); internal static string PropertyCategoryBehavior => GetResourceString("PropertyCategoryBehavior", null); internal static string PropertyCategoryConfig => GetResourceString("PropertyCategoryConfig", null); internal static string PropertyCategoryData => GetResourceString("PropertyCategoryData", null); internal static string PropertyCategoryDDE => GetResourceString("PropertyCategoryDDE", null); internal static string PropertyCategoryDefault => GetResourceString("PropertyCategoryDefault", null); internal static string PropertyCategoryDesign => GetResourceString("PropertyCategoryDesign", null); internal static string PropertyCategoryDragDrop => GetResourceString("PropertyCategoryDragDrop", null); internal static string PropertyCategoryFocus => GetResourceString("PropertyCategoryFocus", null); internal static string PropertyCategoryFont => GetResourceString("PropertyCategoryFont", null); internal static string PropertyCategoryFormat => GetResourceString("PropertyCategoryFormat", null); internal static string PropertyCategoryKey => GetResourceString("PropertyCategoryKey", null); internal static string PropertyCategoryLayout => GetResourceString("PropertyCategoryLayout", null); internal static string PropertyCategoryList => GetResourceString("PropertyCategoryList", null); internal static string PropertyCategoryMouse => GetResourceString("PropertyCategoryMouse", null); internal static string PropertyCategoryPosition => GetResourceString("PropertyCategoryPosition", null); internal static string PropertyCategoryScale => GetResourceString("PropertyCategoryScale", null); internal static string PropertyCategoryText => GetResourceString("PropertyCategoryText", null); internal static string PropertyCategoryWindowStyle => GetResourceString("PropertyCategoryWindowStyle", null); internal static Type ResourceType => typeof(FxResources.System.ComponentModel.Primitives.SR); [MethodImpl(8)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, (StringComparison)4)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return String.Concat(resourceFormat, String.Join(", ", args)); } return String.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return String.Join(", ", (object[])(object)new Object[2] { (Object)resourceFormat, p1 }); } return String.Format(resourceFormat, (object[])(object)new Object[1] { p1 }); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return String.Join(", ", (object[])(object)new Object[3] { (Object)resourceFormat, p1, p2 }); } return String.Format(resourceFormat, (object[])(object)new Object[2] { p1, p2 }); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return String.Join(", ", (object[])(object)new Object[4] { (Object)resourceFormat, p1, p2, p3 }); } return String.Format(resourceFormat, (object[])(object)new Object[3] { p1, p2, p3 }); } } } namespace System.ComponentModel { [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class BrowsableAttribute : Attribute { public static readonly BrowsableAttribute Yes = new BrowsableAttribute(browsable: true); public static readonly BrowsableAttribute No = new BrowsableAttribute(browsable: false); public static readonly BrowsableAttribute Default = Yes; private bool _browsable; public bool Browsable => _browsable; public BrowsableAttribute(bool browsable) { _browsable = browsable; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is BrowsableAttribute browsableAttribute) { return browsableAttribute.Browsable == _browsable; } return false; } public override int GetHashCode() { return ((Boolean)(ref _browsable)).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public class CategoryAttribute : Attribute { private static volatile CategoryAttribute s_action; private static volatile CategoryAttribute s_appearance; private static volatile CategoryAttribute s_asynchronous; private static volatile CategoryAttribute s_behavior; private static volatile CategoryAttribute s_data; private static volatile CategoryAttribute s_design; private static volatile CategoryAttribute s_dragDrop; private static volatile CategoryAttribute s_defAttr; private static volatile CategoryAttribute s_focus; private static volatile CategoryAttribute s_format; private static volatile CategoryAttribute s_key; private static volatile CategoryAttribute s_layout; private static volatile CategoryAttribute s_mouse; private static volatile CategoryAttribute s_windowStyle; private bool _localized; private string _categoryValue; public static CategoryAttribute Action { get { if (s_action == null) { s_action = new CategoryAttribute("Action"); } return s_action; } } public static CategoryAttribute Appearance { get { if (s_appearance == null) { s_appearance = new CategoryAttribute("Appearance"); } return s_appearance; } } public static CategoryAttribute Asynchronous { get { if (s_asynchronous == null) { s_asynchronous = new CategoryAttribute("Asynchronous"); } return s_asynchronous; } } public static CategoryAttribute Behavior { get { if (s_behavior == null) { s_behavior = new CategoryAttribute("Behavior"); } return s_behavior; } } public static CategoryAttribute Data { get { if (s_data == null) { s_data = new CategoryAttribute("Data"); } return s_data; } } public static CategoryAttribute Default { get { if (s_defAttr == null) { s_defAttr = new CategoryAttribute(); } return s_defAttr; } } public static CategoryAttribute Design { get { if (s_design == null) { s_design = new CategoryAttribute("Design"); } return s_design; } } public static CategoryAttribute DragDrop { get { if (s_dragDrop == null) { s_dragDrop = new CategoryAttribute("DragDrop"); } return s_dragDrop; } } public static CategoryAttribute Focus { get { if (s_focus == null) { s_focus = new CategoryAttribute("Focus"); } return s_focus; } } public static CategoryAttribute Format { get { if (s_format == null) { s_format = new CategoryAttribute("Format"); } return s_format; } } public static CategoryAttribute Key { get { if (s_key == null) { s_key = new CategoryAttribute("Key"); } return s_key; } } public static CategoryAttribute Layout { get { if (s_layout == null) { s_layout = new CategoryAttribute("Layout"); } return s_layout; } } public static CategoryAttribute Mouse { get { if (s_mouse == null) { s_mouse = new CategoryAttribute("Mouse"); } return s_mouse; } } public static CategoryAttribute WindowStyle { get { if (s_windowStyle == null) { s_windowStyle = new CategoryAttribute("WindowStyle"); } return s_windowStyle; } } public string Category { get { if (!_localized) { _localized = true; string localizedString = GetLocalizedString(_categoryValue); if (localizedString != null) { _categoryValue = localizedString; } } return _categoryValue; } } public CategoryAttribute() : this("Default") { } public CategoryAttribute(string category) { _categoryValue = category; _localized = false; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is CategoryAttribute categoryAttribute) { return Category.Equals(categoryAttribute.Category); } return false; } public override int GetHashCode() { return ((Object)Category).GetHashCode(); } protected virtual string GetLocalizedString(string value) { return SR.GetResourceString(String.Concat("PropertyCategory", value), null); } } public class ComponentCollection : Object { private ComponentCollection() { } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public class DescriptionAttribute : Attribute { public static readonly DescriptionAttribute Default = new DescriptionAttribute(); public virtual string Description => DescriptionValue; [field: CompilerGenerated] protected string DescriptionValue { [CompilerGenerated] get; [CompilerGenerated] set; } public DescriptionAttribute() : this(String.Empty) { } public DescriptionAttribute(string description) { DescriptionValue = description; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is DescriptionAttribute descriptionAttribute) { return descriptionAttribute.Description == Description; } return false; } public override int GetHashCode() { return ((Object)Description).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class DesignerCategoryAttribute : Attribute { public static readonly DesignerCategoryAttribute Component = new DesignerCategoryAttribute("Component"); public static readonly DesignerCategoryAttribute Default = new DesignerCategoryAttribute(); public static readonly DesignerCategoryAttribute Form = new DesignerCategoryAttribute("Form"); public static readonly DesignerCategoryAttribute Generic = new DesignerCategoryAttribute("Designer"); [field: CompilerGenerated] public string Category { [CompilerGenerated] get; } public DesignerCategoryAttribute() { Category = String.Empty; } public DesignerCategoryAttribute(string category) { Category = category; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is DesignerCategoryAttribute designerCategoryAttribute) { return designerCategoryAttribute.Category == Category; } return false; } public override int GetHashCode() { return ((Object)Category).GetHashCode(); } } public enum DesignerSerializationVisibility : Enum { Hidden, Visible, Content } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class DesignerSerializationVisibilityAttribute : Attribute { public static readonly DesignerSerializationVisibilityAttribute Content = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content); public static readonly DesignerSerializationVisibilityAttribute Hidden = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden); public static readonly DesignerSerializationVisibilityAttribute Visible = new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible); public static readonly DesignerSerializationVisibilityAttribute Default = Visible; private readonly DesignerSerializationVisibility _visibility; public DesignerSerializationVisibility Visibility => _visibility; public DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility visibility) { _visibility = visibility; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is DesignerSerializationVisibilityAttribute designerSerializationVisibilityAttribute) { return designerSerializationVisibilityAttribute.Visibility == _visibility; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class DesignOnlyAttribute : Attribute { public static readonly DesignOnlyAttribute Yes = new DesignOnlyAttribute(isDesignOnly: true); public static readonly DesignOnlyAttribute No = new DesignOnlyAttribute(isDesignOnly: false); public static readonly DesignOnlyAttribute Default = No; [field: CompilerGenerated] public bool IsDesignOnly { [CompilerGenerated] get; } public DesignOnlyAttribute(bool isDesignOnly) { IsDesignOnly = isDesignOnly; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is DesignOnlyAttribute designOnlyAttribute) { return designOnlyAttribute.IsDesignOnly == IsDesignOnly; } return false; } public override int GetHashCode() { bool isDesignOnly = IsDesignOnly; return ((Boolean)(ref isDesignOnly)).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public class DisplayNameAttribute : Attribute { public static readonly DisplayNameAttribute Default = new DisplayNameAttribute(); public virtual string DisplayName => DisplayNameValue; [field: CompilerGenerated] protected string DisplayNameValue { [CompilerGenerated] get; [CompilerGenerated] set; } public DisplayNameAttribute() : this(String.Empty) { } public DisplayNameAttribute(string displayName) { DisplayNameValue = displayName; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is DisplayNameAttribute displayNameAttribute) { return displayNameAttribute.DisplayName == DisplayName; } return false; } public override int GetHashCode() { return ((Object)DisplayName).GetHashCode(); } } [DefaultMember("Item")] public sealed class EventHandlerList : Object, IDisposable { private sealed class ListEntry : Object { internal ListEntry next; internal object key; internal Delegate handler; public ListEntry(object key, Delegate handler, ListEntry next) { this.next = next; this.key = key; this.handler = handler; } } private ListEntry _head; public Delegate this[object key] { get { return Find(key)?.handler; } set { ListEntry listEntry = Find(key); if (listEntry != null) { listEntry.handler = value; } else { _head = new ListEntry(key, value, _head); } } } public void AddHandler(object key, Delegate value) { ListEntry listEntry = Find(key); if (listEntry != null) { listEntry.handler = Delegate.Combine(listEntry.handler, value); } else { _head = new ListEntry(key, value, _head); } } public void AddHandlers(EventHandlerList listToAddFrom) { for (ListEntry listEntry = listToAddFrom._head; listEntry != null; listEntry = listEntry.next) { AddHandler(listEntry.key, listEntry.handler); } } public void Dispose() { _head = null; } private ListEntry Find(object key) { ListEntry listEntry = _head; while (listEntry != null && listEntry.key != key) { listEntry = listEntry.next; } return listEntry; } public void RemoveHandler(object key, Delegate value) { ListEntry listEntry = Find(key); if (listEntry != null) { listEntry.handler = Delegate.Remove(listEntry.handler, value); } } } public interface IComponent : IDisposable { ISite Site { get; set; } event EventHandler Disposed; } public interface IContainer : IDisposable { ComponentCollection Components { get; } void Add(IComponent component); void Add(IComponent component, string name); void Remove(IComponent component); } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class ImmutableObjectAttribute : Attribute { public static readonly ImmutableObjectAttribute Yes = new ImmutableObjectAttribute(immutable: true); public static readonly ImmutableObjectAttribute No = new ImmutableObjectAttribute(immutable: false); public static readonly ImmutableObjectAttribute Default = No; [field: CompilerGenerated] public bool Immutable { [CompilerGenerated] get; } public ImmutableObjectAttribute(bool immutable) { Immutable = immutable; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is ImmutableObjectAttribute immutableObjectAttribute) { return immutableObjectAttribute.Immutable == Immutable; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class InitializationEventAttribute : Attribute { [field: CompilerGenerated] public string EventName { [CompilerGenerated] get; } public InitializationEventAttribute(string eventName) { EventName = eventName; } } public interface ISite : IServiceProvider { IComponent Component { get; } IContainer Container { get; } bool DesignMode { get; } string Name { get; set; } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class LocalizableAttribute : Attribute { public static readonly LocalizableAttribute Yes = new LocalizableAttribute(isLocalizable: true); public static readonly LocalizableAttribute No = new LocalizableAttribute(isLocalizable: false); public static readonly LocalizableAttribute Default = No; [field: CompilerGenerated] public bool IsLocalizable { [CompilerGenerated] get; } public LocalizableAttribute(bool isLocalizable) { IsLocalizable = isLocalizable; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is LocalizableAttribute localizableAttribute) { return localizableAttribute.IsLocalizable == IsLocalizable; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class MergablePropertyAttribute : Attribute { public static readonly MergablePropertyAttribute Yes = new MergablePropertyAttribute(allowMerge: true); public static readonly MergablePropertyAttribute No = new MergablePropertyAttribute(allowMerge: false); public static readonly MergablePropertyAttribute Default = Yes; [field: CompilerGenerated] public bool AllowMerge { [CompilerGenerated] get; } public MergablePropertyAttribute(bool allowMerge) { AllowMerge = allowMerge; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is MergablePropertyAttribute mergablePropertyAttribute) { return mergablePropertyAttribute.AllowMerge == AllowMerge; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class NotifyParentPropertyAttribute : Attribute { public static readonly NotifyParentPropertyAttribute Yes = new NotifyParentPropertyAttribute(notifyParent: true); public static readonly NotifyParentPropertyAttribute No = new NotifyParentPropertyAttribute(notifyParent: false); public static readonly NotifyParentPropertyAttribute Default = No; [field: CompilerGenerated] public bool NotifyParent { [CompilerGenerated] get; } public NotifyParentPropertyAttribute(bool notifyParent) { NotifyParent = notifyParent; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is NotifyParentPropertyAttribute notifyParentPropertyAttribute) { return notifyParentPropertyAttribute.NotifyParent == NotifyParent; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class ParenthesizePropertyNameAttribute : Attribute { public static readonly ParenthesizePropertyNameAttribute Default = new ParenthesizePropertyNameAttribute(); [field: CompilerGenerated] public bool NeedParenthesis { [CompilerGenerated] get; } public ParenthesizePropertyNameAttribute() : this(needParenthesis: false) { } public ParenthesizePropertyNameAttribute(bool needParenthesis) { NeedParenthesis = needParenthesis; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is ParenthesizePropertyNameAttribute parenthesizePropertyNameAttribute) { return parenthesizePropertyNameAttribute.NeedParenthesis == NeedParenthesis; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class ReadOnlyAttribute : Attribute { public static readonly ReadOnlyAttribute Yes = new ReadOnlyAttribute(isReadOnly: true); public static readonly ReadOnlyAttribute No = new ReadOnlyAttribute(isReadOnly: false); public static readonly ReadOnlyAttribute Default = No; [field: CompilerGenerated] public bool IsReadOnly { [CompilerGenerated] get; } public ReadOnlyAttribute(bool isReadOnly) { IsReadOnly = isReadOnly; } public override bool Equals(object value) { if (this == value) { return true; } if (value is ReadOnlyAttribute readOnlyAttribute) { return readOnlyAttribute.IsReadOnly == IsReadOnly; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } public enum RefreshProperties : Enum { None, All, Repaint } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class RefreshPropertiesAttribute : Attribute { public static readonly RefreshPropertiesAttribute All = new RefreshPropertiesAttribute(RefreshProperties.All); public static readonly RefreshPropertiesAttribute Repaint = new RefreshPropertiesAttribute(RefreshProperties.Repaint); public static readonly RefreshPropertiesAttribute Default = new RefreshPropertiesAttribute(RefreshProperties.None); [field: CompilerGenerated] public RefreshProperties RefreshProperties { [CompilerGenerated] get; } public RefreshPropertiesAttribute(RefreshProperties refresh) { RefreshProperties = refresh; } public override bool Equals(object obj) { if (obj == this) { return true; } if (obj is RefreshPropertiesAttribute refreshPropertiesAttribute) { return refreshPropertiesAttribute.RefreshProperties == RefreshProperties; } return false; } public override int GetHashCode() { return ((Attribute)this).GetHashCode(); } } }
BepInEx/plugins/DearImGuiInjection/System.IO.FileSystem.Primitives.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: AssemblyTitle("System.IO.FileSystem.Primitives")] [assembly: AssemblyDescription("System.IO.FileSystem.Primitives")] [assembly: AssemblyDefaultAlias("System.IO.FileSystem.Primitives")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.0.2.0")] namespace System.IO; [Flags] public enum FileAccess { Read = 1, Write = 2, ReadWrite = 3 } [Flags] public enum FileAttributes { ReadOnly = 1, Hidden = 2, System = 4, Directory = 0x10, Archive = 0x20, Device = 0x40, Normal = 0x80, Temporary = 0x100, SparseFile = 0x200, ReparsePoint = 0x400, Compressed = 0x800, Offline = 0x1000, NotContentIndexed = 0x2000, Encrypted = 0x4000, IntegrityStream = 0x8000, NoScrubData = 0x20000 } public enum FileMode { CreateNew = 1, Create, Open, OpenOrCreate, Truncate, Append } [Flags] public enum FileShare { None = 0, Read = 1, Write = 2, ReadWrite = 3, Delete = 4, Inheritable = 0x10 }
BepInEx/plugins/DearImGuiInjection/System.Reflection.Emit.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using FxResources.System.Reflection.Emit; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyDefaultAlias("System.Reflection.Emit")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("NotSupported", "True")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Reflection.Emit")] [assembly: AssemblyFileVersion("4.700.19.56404")] [assembly: AssemblyInformationalVersion("3.1.0+0f7f38c4fd323b26da10cce95f857f77f0f09b48")] [assembly: AssemblyProduct("Microsoft® .NET Core")] [assembly: AssemblyTitle("System.Reflection.Emit")] [assembly: CLSCompliant(true)] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: AssemblyVersion("4.0.0.0")] namespace FxResources.System.Reflection.Emit { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR))); internal static string PlatformNotSupported_RefEmit => GetResourceString("PlatformNotSupported_RefEmit"); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString = null) { if (UsingResourceKeys()) { return defaultString ?? resourceKey; } string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text)) { return defaultString; } return text; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(IFormatProvider provider, string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(provider, resourceFormat, p1); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(provider, resourceFormat, p1, p2); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(provider, resourceFormat, p1, p2, p3); } internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(provider, resourceFormat, args); } return resourceFormat; } } } namespace System.Reflection.Emit { public sealed class AssemblyBuilder : Assembly { public override string CodeBase { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override MethodInfo EntryPoint { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string FullName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool GlobalAssemblyCache { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override long HostContext { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string ImageRuntimeVersion { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsDynamic { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Location { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module ManifestModule { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool ReflectionOnly { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal AssemblyBuilder() { } public static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public static AssemblyBuilder DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, IEnumerable<CustomAttributeBuilder> assemblyAttributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ModuleBuilder DefineDynamicModule(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool Equals(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override IList<CustomAttributeData> GetCustomAttributesData() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ModuleBuilder GetDynamicModule(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetExportedTypes() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FileStream GetFile(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FileStream[] GetFiles(bool getResourceModules) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Module[] GetLoadedModules(bool getResourceModules) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string[] GetManifestResourceNames() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Stream GetManifestResourceStream(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Stream GetManifestResourceStream(Type type, string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Module GetModule(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Module[] GetModules(bool getResourceModules) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override AssemblyName GetName(bool copiedName) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override AssemblyName[] GetReferencedAssemblies() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Assembly GetSatelliteAssembly(CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Assembly GetSatelliteAssembly(CultureInfo culture, Version version) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetType(string name, bool throwOnError, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } [Flags] public enum AssemblyBuilderAccess { Run = 1, RunAndCollect = 9 } public sealed class ConstructorBuilder : ConstructorInfo { public override MethodAttributes Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override CallingConventions CallingConvention { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public bool InitLocals { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } set { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeMethodHandle MethodHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal ConstructorBuilder() { } public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ILGenerator GetILGenerator() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ILGenerator GetILGenerator(int streamSize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodImplAttributes GetMethodImplementationFlags() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ParameterInfo[] GetParameters() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetImplementationFlags(MethodImplAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class EnumBuilder : Type { public override Assembly Assembly { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string AssemblyQualifiedName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type BaseType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string FullName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Guid GUID { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsConstructedGenericType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Namespace { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeTypeHandle TypeHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public FieldBuilder UnderlyingField { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type UnderlyingSystemType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal EnumBuilder() { } public TypeInfo CreateTypeInfo() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineLiteral(string literalName, object literalValue) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override TypeAttributes GetAttributeFlagsImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetElementType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetEnumUnderlyingType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetInterface(string name, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetInterfaces() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool HasElementTypeImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsArrayImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsByRefImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsCOMObjectImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPointerImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPrimitiveImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsValueTypeImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType(int rank) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeByRefType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakePointerType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class EventBuilder { internal EventBuilder() { } public void AddOtherMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetAddOnMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetRaiseMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetRemoveOnMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class FieldBuilder : FieldInfo { public override FieldAttributes Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeFieldHandle FieldHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type FieldType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal FieldBuilder() { } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object GetValue(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetConstant(object defaultValue) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetOffset(int iOffset) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class GenericTypeParameterBuilder : Type { public override Assembly Assembly { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string AssemblyQualifiedName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type BaseType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool ContainsGenericParameters { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override MethodBase DeclaringMethod { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string FullName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override GenericParameterAttributes GenericParameterAttributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override int GenericParameterPosition { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Guid GUID { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsConstructedGenericType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericParameter { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericTypeDefinition { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Namespace { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeTypeHandle TypeHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type UnderlyingSystemType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal GenericTypeParameterBuilder() { } public override bool Equals(object o) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override TypeAttributes GetAttributeFlagsImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetElementType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetGenericArguments() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetGenericTypeDefinition() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetInterface(string name, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetInterfaces() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool HasElementTypeImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsArrayImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsAssignableFrom(Type c) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsByRefImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsCOMObjectImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPointerImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPrimitiveImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsSubclassOf(Type c) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsValueTypeImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType(int rank) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeByRefType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeGenericType(params Type[] typeArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakePointerType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetBaseTypeConstraint(Type baseTypeConstraint) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetGenericParameterAttributes(GenericParameterAttributes genericParameterAttributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetInterfaceConstraints(params Type[] interfaceConstraints) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class MethodBuilder : MethodInfo { public override MethodAttributes Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override CallingConventions CallingConvention { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool ContainsGenericParameters { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public bool InitLocals { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } set { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericMethod { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericMethodDefinition { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecurityCritical { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecuritySafeCritical { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecurityTransparent { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeMethodHandle MethodHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override ParameterInfo ReturnParameter { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReturnType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal MethodBuilder() { } public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool Equals(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo GetBaseDefinition() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetGenericArguments() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo GetGenericMethodDefinition() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ILGenerator GetILGenerator() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ILGenerator GetILGenerator(int size) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodImplAttributes GetMethodImplementationFlags() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ParameterInfo[] GetParameters() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo MakeGenericMethod(params Type[] typeArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetImplementationFlags(MethodImplAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetParameters(params Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetReturnType(Type returnType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public class ModuleBuilder : Module { public override Assembly Assembly { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string FullyQualifiedName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override int MDStreamVersion { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override int MetadataToken { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Guid ModuleVersionId { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string ScopeName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal ModuleBuilder() { } public void CreateGlobalFunctions() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type underlyingType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, int typesize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packsize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool Equals(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodInfo GetArrayMethod(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override IList<CustomAttributeData> GetCustomAttributesData() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo[] GetFields(BindingFlags bindingFlags) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo[] GetMethods(BindingFlags bindingFlags) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetType(string className) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetType(string className, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetType(string className, bool throwOnError, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetTypes() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsResource() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override byte[] ResolveSignature(int metadataToken) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string ResolveString(int metadataToken) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class PropertyBuilder : PropertyInfo { public override PropertyAttributes Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool CanRead { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool CanWrite { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type PropertyType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal PropertyBuilder() { } public void AddOtherMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo[] GetAccessors(bool nonPublic) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo GetGetMethod(bool nonPublic) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ParameterInfo[] GetIndexParameters() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo GetSetMethod(bool nonPublic) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object GetValue(object obj, object[] index) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetConstant(object defaultValue) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetGetMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetSetMethod(MethodBuilder mdBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override void SetValue(object obj, object value, object[] index) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public sealed class TypeBuilder : Type { public const int UnspecifiedTypeSize = 0; public override Assembly Assembly { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string AssemblyQualifiedName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type BaseType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override MethodBase DeclaringMethod { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type DeclaringType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string FullName { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override GenericParameterAttributes GenericParameterAttributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override int GenericParameterPosition { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Guid GUID { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsConstructedGenericType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericParameter { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsGenericTypeDefinition { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecurityCritical { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecuritySafeCritical { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override bool IsSecurityTransparent { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Module Module { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override string Namespace { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public PackingSize PackingSize { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type ReflectedType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public int Size { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override RuntimeTypeHandle TypeHandle { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } public override Type UnderlyingSystemType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } internal TypeBuilder() { } public void AddInterfaceImplementation(Type interfaceType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeInfo CreateTypeInfo() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ConstructorBuilder DefineDefaultConstructor(MethodAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineField(string fieldName, Type type, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public GenericTypeParameterBuilder[] DefineGenericParameters(params string[] names) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineMethod(string name, MethodAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public MethodBuilder DefineMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, int typeSize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, PackingSize packSize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, PackingSize packSize, int typeSize) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, Type[] interfaces) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public ConstructorBuilder DefineTypeInitializer() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override TypeAttributes GetAttributeFlagsImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetElementType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public static FieldInfo GetField(Type type, FieldInfo field) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetGenericArguments() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetGenericTypeDefinition() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetInterface(string name, bool ignoreCase) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetInterfaces() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public static MethodInfo GetMethod(Type type, MethodInfo method) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool HasElementTypeImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsArrayImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsAssignableFrom(Type c) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsByRefImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsCOMObjectImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public bool IsCreated() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsDefined(Type attributeType, bool inherit) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPointerImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } protected override bool IsPrimitiveImpl() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override bool IsSubclassOf(Type c) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeArrayType(int rank) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeByRefType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakeGenericType(params Type[] typeArguments) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override Type MakePointerType() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public void SetParent(Type parent) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmit); } } }
BepInEx/plugins/DearImGuiInjection/System.ComponentModel.TypeConverter.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Design; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; using FxResources.System.ComponentModel.TypeConverter; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.ComponentModel.TypeConverter")] [assembly: AssemblyDescription("System.ComponentModel.TypeConverter")] [assembly: AssemblyDefaultAlias("System.ComponentModel.TypeConverter")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.1.1.0")] namespace FxResources.System.ComponentModel.TypeConverter { internal static class SR { } } namespace System { public class UriTypeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (sourceType == null) { throw new ArgumentNullException("sourceType"); } if (sourceType != typeof(string)) { return sourceType == typeof(Uri); } return true; } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { if (destinationType != typeof(string)) { return destinationType == typeof(Uri); } return true; } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (value is string text) { if (string.IsNullOrEmpty(text)) { return null; } return (object)new Uri(text, (UriKind)0); } Uri val = (Uri)((value is Uri) ? value : null); if (val != (Uri)null) { return (object)new Uri(val.OriginalString); } throw GetConvertFromException(value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown if (destinationType == null) { throw new ArgumentNullException("destinationType"); } Uri val = (Uri)((value is Uri) ? value : null); if (val != (Uri)null) { if (destinationType == typeof(string)) { return val.OriginalString; } if (destinationType == typeof(Uri)) { return (object)new Uri(val.OriginalString, (UriKind)0); } } throw GetConvertToException(value, destinationType); } } internal class InvariantComparer : IComparer { private readonly CompareInfo _compareInfo; internal static readonly InvariantComparer Default = new InvariantComparer(); internal InvariantComparer() { _compareInfo = CultureInfo.InvariantCulture.CompareInfo; } public int Compare(object a, object b) { string text = a as string; string text2 = b as string; if (text != null && text2 != null) { return _compareInfo.Compare(text, text2); } return Comparer.Default.Compare(a, b); } } internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.ComponentModel.TypeConverter.SR"; private static ResourceManager ResourceManager { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string Array => GetResourceString("Array", null); internal static string Collection => GetResourceString("Collection", null); internal static string ConvertFromException => GetResourceString("ConvertFromException", null); internal static string ConvertInvalidPrimitive => GetResourceString("ConvertInvalidPrimitive", null); internal static string ConvertToException => GetResourceString("ConvertToException", null); internal static string EnumConverterInvalidValue => GetResourceString("EnumConverterInvalidValue", null); internal static string ErrorInvalidEventHandler => GetResourceString("ErrorInvalidEventHandler", null); internal static string ErrorInvalidEventType => GetResourceString("ErrorInvalidEventType", null); internal static string ErrorInvalidPropertyType => GetResourceString("ErrorInvalidPropertyType", null); internal static string ErrorMissingEventAccessors => GetResourceString("ErrorMissingEventAccessors", null); internal static string ErrorMissingPropertyAccessors => GetResourceString("ErrorMissingPropertyAccessors", null); internal static string ErrorPropertyAccessorException => GetResourceString("ErrorPropertyAccessorException", null); internal static string InvalidMemberName => GetResourceString("InvalidMemberName", null); internal static string InvalidNullArgument => GetResourceString("InvalidNullArgument", null); internal static string MetaExtenderName => GetResourceString("MetaExtenderName", null); internal static string none => GetResourceString("none", null); internal static string Null => GetResourceString("Null", null); internal static string NullableConverterBadCtorArg => GetResourceString("NullableConverterBadCtorArg", null); internal static string Text => GetResourceString("Text", null); internal static string TypeDescriptorAlreadyAssociated => GetResourceString("TypeDescriptorAlreadyAssociated", null); internal static string TypeDescriptorArgsCountMismatch => GetResourceString("TypeDescriptorArgsCountMismatch", null); internal static string TypeDescriptorProviderError => GetResourceString("TypeDescriptorProviderError", null); internal static string TypeDescriptorUnsupportedRemoteObject => GetResourceString("TypeDescriptorUnsupportedRemoteObject", null); internal static string TypeDescriptorExpectedElementType => GetResourceString("TypeDescriptorExpectedElementType", null); internal static string TypeDescriptorSameAssociation => GetResourceString("TypeDescriptorSameAssociation", null); internal static System.Type ResourceType => typeof(SR); [MethodImpl(8)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, (StringComparison)4)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", new object[2] { resourceFormat, p1 }); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", new object[3] { resourceFormat, p1, p2 }); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", new object[4] { resourceFormat, p1, p2, p3 }); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.ComponentModel { public class ArrayConverter : CollectionConverter { private class ArrayPropertyDescriptor : SimplePropertyDescriptor { private readonly int _index; public ArrayPropertyDescriptor(System.Type arrayType, System.Type elementType, int index) : base(arrayType, string.Concat((object)"[", (object)index, (object)"]"), elementType, null) { _index = index; } public override object GetValue(object instance) { if (instance is System.Array array && array.GetLength(0) > _index) { return array.GetValue(_index); } return null; } public override void SetValue(object instance, object value) { if (instance is System.Array) { System.Array array = (System.Array)instance; if (array.GetLength(0) > _index) { array.SetValue(value, _index); } OnValueChanged(instance, EventArgs.Empty); } } } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value is System.Array) { return System.SR.Format(System.SR.Array, value.GetType().Name); } return base.ConvertTo(context, culture, value, destinationType); } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) { if (value == null) { return null; } PropertyDescriptor[] array = null; if (value.GetType().IsArray) { System.Array array2 = (System.Array)value; int length = array2.GetLength(0); array = new PropertyDescriptor[length]; System.Type type = value.GetType(); System.Type elementType = type.GetElementType(); for (int i = 0; i < length; i++) { array[i] = new ArrayPropertyDescriptor(type, elementType, i); } } return new PropertyDescriptorCollection(array); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; } } public abstract class BaseNumberConverter : TypeConverter { internal virtual bool AllowHex => true; internal abstract System.Type TargetType { get; } internal abstract object FromString(string value, int radix); internal abstract object FromString(string value, NumberFormatInfo formatInfo); internal abstract object FromString(string value, CultureInfo culture); internal virtual System.Exception FromStringError(string failedText, System.Exception innerException) { return new System.Exception(System.SR.Format(System.SR.ConvertInvalidPrimitive, failedText, TargetType.Name), innerException); } internal abstract string ToString(object value, NumberFormatInfo formatInfo); public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown if (value is string text) { string text2 = text.Trim(); try { if (AllowHex && text2[0] == '#') { return FromString(text2.Substring(1), 16); } if ((AllowHex && text2.StartsWith("0x", (StringComparison)5)) || text2.StartsWith("&h", (StringComparison)5)) { return FromString(text2.Substring(2), 16); } if (culture == null) { culture = CultureInfo.CurrentCulture; } NumberFormatInfo formatInfo = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo)); return FromString(text2, formatInfo); } catch (System.Exception innerException) { throw FromStringError(text2, innerException); } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value != null && IntrospectionExtensions.GetTypeInfo(TargetType).IsAssignableFrom(IntrospectionExtensions.GetTypeInfo(value.GetType()))) { if (culture == null) { culture = CultureInfo.CurrentCulture; } NumberFormatInfo val = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo)); return ToString(value, val); } if (IntrospectionExtensions.GetTypeInfo(destinationType).IsPrimitive) { return Convert.ChangeType(value, destinationType, (IFormatProvider)(object)culture); } return base.ConvertTo(context, culture, value, destinationType); } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { if (!base.CanConvertTo(context, destinationType)) { return IntrospectionExtensions.GetTypeInfo(destinationType).IsPrimitive; } return true; } } public class BooleanConverter : TypeConverter { private static volatile StandardValuesCollection s_values; public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0020: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (value is string text) { string text2 = text.Trim(); try { return bool.Parse(text2); } catch (FormatException val) { FormatException val2 = val; throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, "Boolean"), (System.Exception)(object)val2); } } return base.ConvertFrom(context, culture, value); } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (s_values == null) { s_values = new StandardValuesCollection((System.Collections.ICollection)(object)new object[2] { true, false }); } return s_values; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } public class ByteConverter : BaseNumberConverter { internal override System.Type TargetType => typeof(byte); internal override object FromString(string value, int radix) { return Convert.ToByte(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return byte.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return byte.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((byte)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class CharConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { if (destinationType == typeof(string) && value is char && (char)value == '\0') { return ""; } return base.ConvertTo(context, culture, value, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) string text = value as string; if (text != null) { if (text.Length > 1) { text = text.Trim(); } if (text.Length > 0) { if (text.Length != 1) { throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, text, "Char")); } return text[0]; } return '\0'; } return base.ConvertFrom(context, culture, value); } } public class CollectionConverter : TypeConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value is System.Collections.ICollection) { return System.SR.Collection; } return base.ConvertTo(context, culture, value, destinationType); } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return new PropertyDescriptorCollection(null); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return false; } } public class DateTimeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0062: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (value is string text) { string text2 = text.Trim(); if (text2.Length == 0) { return System.DateTime.MinValue; } try { DateTimeFormatInfo val = null; if (culture != null) { val = (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo)); } if (val != null) { return System.DateTime.Parse(text2, (IFormatProvider)(object)val); } return System.DateTime.Parse(text2, (IFormatProvider)(object)culture); } catch (FormatException val2) { FormatException val3 = val2; throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, "DateTime"), (System.Exception)(object)val3); } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (destinationType == typeof(string) && value is System.DateTime dateTime) { if (dateTime == System.DateTime.MinValue) { return string.Empty; } if (culture == null) { culture = CultureInfo.CurrentCulture; } DateTimeFormatInfo val = null; val = (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo)); TimeSpan timeOfDay; if (culture == CultureInfo.InvariantCulture) { timeOfDay = dateTime.TimeOfDay; if (((TimeSpan)(ref timeOfDay)).TotalSeconds == 0.0) { return dateTime.ToString("yyyy-MM-dd", (IFormatProvider)(object)culture); } return dateTime.ToString((IFormatProvider)(object)culture); } timeOfDay = dateTime.TimeOfDay; string text = ((((TimeSpan)(ref timeOfDay)).TotalSeconds != 0.0) ? (val.ShortDatePattern + " " + val.ShortTimePattern) : val.ShortDatePattern); return dateTime.ToString(text, (IFormatProvider)(object)CultureInfo.CurrentCulture); } return base.ConvertTo(context, culture, value, destinationType); } } public class DateTimeOffsetConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0062: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (value is string text) { string text2 = text.Trim(); if (text2.Length == 0) { return DateTimeOffset.MinValue; } try { DateTimeFormatInfo val = null; if (culture != null) { val = (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo)); } if (val != null) { return DateTimeOffset.Parse(text2, (IFormatProvider)(object)val); } return DateTimeOffset.Parse(text2, (IFormatProvider)(object)culture); } catch (FormatException val2) { FormatException val3 = val2; throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, "DateTimeOffset"), (System.Exception)(object)val3); } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (destinationType == typeof(string) && value is DateTimeOffset val) { if (val == DateTimeOffset.MinValue) { return string.Empty; } if (culture == null) { culture = CultureInfo.CurrentCulture; } DateTimeFormatInfo val2 = null; val2 = (DateTimeFormatInfo)culture.GetFormat(typeof(DateTimeFormatInfo)); TimeSpan timeOfDay; if (culture == CultureInfo.InvariantCulture) { timeOfDay = ((DateTimeOffset)(ref val)).TimeOfDay; if (((TimeSpan)(ref timeOfDay)).TotalSeconds == 0.0) { return ((DateTimeOffset)(ref val)).ToString("yyyy-MM-dd zzz", (IFormatProvider)(object)culture); } return ((DateTimeOffset)(ref val)).ToString((IFormatProvider)(object)culture); } timeOfDay = ((DateTimeOffset)(ref val)).TimeOfDay; string text = ((((TimeSpan)(ref timeOfDay)).TotalSeconds != 0.0) ? (val2.ShortDatePattern + " " + val2.ShortTimePattern + " zzz") : (val2.ShortDatePattern + " zzz")); return ((DateTimeOffset)(ref val)).ToString(text, (IFormatProvider)(object)CultureInfo.CurrentCulture); } return base.ConvertTo(context, culture, value, destinationType); } } public class DecimalConverter : BaseNumberConverter { internal override bool AllowHex => false; internal override System.Type TargetType => typeof(decimal); public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } return base.ConvertTo(context, culture, value, destinationType); } internal override object FromString(string value, int radix) { return Convert.ToDecimal(value, (IFormatProvider)(object)CultureInfo.CurrentCulture); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return decimal.Parse(value, (NumberStyles)167, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return decimal.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((decimal)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class DoubleConverter : BaseNumberConverter { internal override bool AllowHex => false; internal override System.Type TargetType => typeof(double); internal override object FromString(string value, int radix) { return Convert.ToDouble(value, (IFormatProvider)(object)CultureInfo.CurrentCulture); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return double.Parse(value, (NumberStyles)167, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return double.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((double)value).ToString("R", (IFormatProvider)(object)formatInfo); } } public class EnumConverter : TypeConverter { private StandardValuesCollection _values; private readonly System.Type _type; protected System.Type EnumType => _type; protected StandardValuesCollection Values { get { return _values; } set { _values = value; } } protected virtual IComparer Comparer => (IComparer)(object)InvariantComparer.Default; public EnumConverter(System.Type type) { _type = type; } public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType == typeof(string) || sourceType == typeof(System.Enum[])) { return true; } return base.CanConvertFrom(context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { if (destinationType == typeof(System.Enum[])) { return true; } return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (value is string text) { try { if (text.IndexOf(',') != -1) { long num = 0L; string[] array = text.Split(new char[1] { ',' }); string[] array2 = array; foreach (string text2 in array2) { num |= Convert.ToInt64((object)(System.Enum)System.Enum.Parse(_type, text2, true), (IFormatProvider)(object)culture); } return System.Enum.ToObject(_type, (object)num); } return System.Enum.Parse(_type, text, true); } catch (System.Exception ex) { throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, _type.Name), ex); } } if (value is System.Enum[]) { long num2 = 0L; System.Enum[] array3 = (System.Enum[])value; foreach (System.Enum @enum in array3) { num2 |= Convert.ToInt64((object)@enum, (IFormatProvider)(object)culture); } return System.Enum.ToObject(_type, (object)num2); } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value != null) { if (!CustomAttributeExtensions.IsDefined((MemberInfo)(object)IntrospectionExtensions.GetTypeInfo(_type), typeof(FlagsAttribute), false) && !System.Enum.IsDefined(_type, value)) { throw new ArgumentException(System.SR.Format(System.SR.EnumConverterInvalidValue, value.ToString(), _type.Name)); } return System.Enum.Format(_type, value, "G"); } if (destinationType == typeof(System.Enum[]) && value != null) { if (CustomAttributeExtensions.IsDefined((MemberInfo)(object)IntrospectionExtensions.GetTypeInfo(_type), typeof(FlagsAttribute), false)) { List<System.Enum> val = new List<System.Enum>(); System.Array values = System.Enum.GetValues(_type); long[] array = new long[values.Length]; for (int i = 0; i < values.Length; i++) { array[i] = Convert.ToInt64((object)(System.Enum)values.GetValue(i), (IFormatProvider)(object)culture); } long num = Convert.ToInt64((object)(System.Enum)value, (IFormatProvider)(object)culture); bool flag = true; while (flag) { flag = false; long[] array2 = array; foreach (long num2 in array2) { if ((num2 != 0L && (num2 & num) == num2) || num2 == num) { val.Add((System.Enum)System.Enum.ToObject(_type, (object)num2)); flag = true; num &= ~num2; break; } } if (num == 0L) { break; } } if (!flag && num != 0L) { val.Add((System.Enum)System.Enum.ToObject(_type, (object)num)); } return val.ToArray(); } return new System.Enum[1] { (System.Enum)System.Enum.ToObject(_type, value) }; } return base.ConvertTo(context, culture, value, destinationType); } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown if (_values == null) { System.Type type = TypeDescriptor.GetReflectionType(_type); if (type == null) { type = _type; } FieldInfo[] fields = TypeExtensions.GetFields(type, (BindingFlags)24); ArrayList val = null; if (fields != null && fields.Length != 0) { val = new ArrayList(fields.Length); } if (val != null) { FieldInfo[] array = fields; foreach (FieldInfo val2 in array) { BrowsableAttribute val3 = null; System.Collections.Generic.IEnumerator<System.Attribute> enumerator = CustomAttributeExtensions.GetCustomAttributes((MemberInfo)(object)val2, typeof(BrowsableAttribute), false).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { System.Attribute current = enumerator.Current; val3 = (BrowsableAttribute)(object)((current is BrowsableAttribute) ? current : null); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } if (val3 != null && !val3.Browsable) { continue; } object obj = null; try { if (((MemberInfo)val2).Name != null) { obj = System.Enum.Parse(_type, ((MemberInfo)val2).Name); } } catch (ArgumentException) { } if (obj != null) { val.Add(obj); } } IComparer comparer = Comparer; if (comparer != null) { val.Sort(comparer); } } System.Array values = ((val != null) ? val.ToArray() : null); _values = new StandardValuesCollection((System.Collections.ICollection)values); } return _values; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return !CustomAttributeExtensions.IsDefined((MemberInfo)(object)IntrospectionExtensions.GetTypeInfo(_type), typeof(FlagsAttribute), false); } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } public override bool IsValid(ITypeDescriptorContext context, object value) { return System.Enum.IsDefined(_type, value); } } public class GuidConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (value is string text) { string text2 = text.Trim(); return (object)new Guid(text2); } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } return base.ConvertTo(context, culture, value, destinationType); } } public class Int16Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(short); internal override object FromString(string value, int radix) { return Convert.ToInt16(value, radix); } internal override object FromString(string value, CultureInfo culture) { return short.Parse(value, (IFormatProvider)(object)culture); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return short.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((short)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class Int32Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(int); internal override object FromString(string value, int radix) { return Convert.ToInt32(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return int.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return int.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((int)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class Int64Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(long); internal override object FromString(string value, int radix) { return Convert.ToInt64(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return long.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return long.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((long)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public interface ITypeDescriptorContext : IServiceProvider { IContainer Container { get; } object Instance { get; } PropertyDescriptor PropertyDescriptor { get; } bool OnComponentChanging(); void OnComponentChanged(); } public class MultilineStringConverter : TypeConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string) && value is string) { return System.SR.Text; } return base.ConvertTo(context, culture, value, destinationType); } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return null; } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return false; } } public class NullableConverter : TypeConverter { private readonly System.Type _nullableType; private readonly System.Type _simpleType; private readonly TypeConverter _simpleTypeConverter; public System.Type NullableType => _nullableType; public System.Type UnderlyingType => _simpleType; public TypeConverter UnderlyingTypeConverter => _simpleTypeConverter; public NullableConverter(System.Type type) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) _nullableType = type; _simpleType = Nullable.GetUnderlyingType(type); if (_simpleType == null) { throw new ArgumentException(System.SR.NullableConverterBadCtorArg, "type"); } _simpleTypeConverter = TypeDescriptor.GetConverter(_simpleType); } public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType == _simpleType) { return true; } if (_simpleTypeConverter != null) { return _simpleTypeConverter.CanConvertFrom(context, sourceType); } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value == null || value.GetType() == _simpleType) { return value; } if (value is string && string.IsNullOrEmpty(value as string)) { return null; } if (_simpleTypeConverter != null) { return _simpleTypeConverter.ConvertFrom(context, culture, value); } return base.ConvertFrom(context, culture, value); } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { if (destinationType == _simpleType) { return true; } if (_simpleTypeConverter != null) { return _simpleTypeConverter.CanConvertTo(context, destinationType); } return base.CanConvertTo(context, destinationType); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == _simpleType && value != null && IntrospectionExtensions.GetTypeInfo(_nullableType).IsAssignableFrom(IntrospectionExtensions.GetTypeInfo(value.GetType()))) { return value; } if (value == null) { if (destinationType == typeof(string)) { return string.Empty; } } else if (_simpleTypeConverter != null) { return _simpleTypeConverter.ConvertTo(context, culture, value, destinationType); } return base.ConvertTo(context, culture, value, destinationType); } public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.CreateInstance(context, propertyValues); } return base.CreateInstance(context, propertyValues); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.GetCreateInstanceSupported(context); } return base.GetCreateInstanceSupported(context); } public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.GetProperties(context, value, attributes); } return base.GetProperties(context, value, attributes); } public override bool GetPropertiesSupported(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.GetPropertiesSupported(context); } return base.GetPropertiesSupported(context); } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { StandardValuesCollection standardValues = _simpleTypeConverter.GetStandardValues(context); if (GetStandardValuesSupported(context) && standardValues != null) { object[] array = new object[standardValues.Count + 1]; int num = 0; array[num++] = null; foreach (object item in standardValues) { array[num++] = item; } return new StandardValuesCollection((System.Collections.ICollection)(object)array); } } return base.GetStandardValues(context); } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.GetStandardValuesExclusive(context); } return base.GetStandardValuesExclusive(context); } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { if (_simpleTypeConverter != null) { return _simpleTypeConverter.GetStandardValuesSupported(context); } return base.GetStandardValuesSupported(context); } public override bool IsValid(ITypeDescriptorContext context, object value) { if (_simpleTypeConverter != null) { if (value == null) { return true; } return _simpleTypeConverter.IsValid(context, value); } return base.IsValid(context, value); } } public abstract class PropertyDescriptor : MemberDescriptor { private TypeConverter _converter; private Hashtable _valueChangedHandlers; private object[] _editors; private System.Type[] _editorTypes; private int _editorCount; public abstract System.Type ComponentType { get; } public virtual TypeConverter Converter { get { AttributeCollection attributes = Attributes; if (_converter == null) { TypeConverterAttribute typeConverterAttribute = (TypeConverterAttribute)attributes[typeof(TypeConverterAttribute)]; if (typeConverterAttribute.ConverterTypeName != null && typeConverterAttribute.ConverterTypeName.Length > 0) { System.Type typeFromName = GetTypeFromName(typeConverterAttribute.ConverterTypeName); if (typeFromName != null && IntrospectionExtensions.GetTypeInfo(typeof(TypeConverter)).IsAssignableFrom(typeFromName)) { _converter = (TypeConverter)CreateInstance(typeFromName); } } if (_converter == null) { _converter = TypeDescriptor.GetConverter(PropertyType); } } return _converter; } } public virtual bool IsLocalizable => ((object)LocalizableAttribute.Yes).Equals((object)Attributes[typeof(LocalizableAttribute)]); public abstract bool IsReadOnly { get; } public DesignerSerializationVisibility SerializationVisibility { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) DesignerSerializationVisibilityAttribute val = (DesignerSerializationVisibilityAttribute)Attributes[typeof(DesignerSerializationVisibilityAttribute)]; return val.Visibility; } } public abstract System.Type PropertyType { get; } public virtual bool SupportsChangeEvents => false; protected PropertyDescriptor(string name, System.Attribute[] attrs) : base(name, attrs) { } protected PropertyDescriptor(MemberDescriptor descr) : base(descr) { } protected PropertyDescriptor(MemberDescriptor descr, System.Attribute[] attrs) : base(descr, attrs) { } public virtual void AddValueChanged(object component, EventHandler handler) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown if (component == null) { throw new ArgumentNullException("component"); } if (handler == null) { throw new ArgumentNullException("handler"); } if (_valueChangedHandlers == null) { _valueChangedHandlers = new Hashtable(); } EventHandler val = (EventHandler)_valueChangedHandlers[component]; _valueChangedHandlers[component] = System.Delegate.Combine((System.Delegate)(object)val, (System.Delegate)(object)handler); } public abstract bool CanResetValue(object component); public override bool Equals(object obj) { try { if (obj == this) { return true; } if (obj == null) { return false; } if (obj is PropertyDescriptor propertyDescriptor && propertyDescriptor.NameHashCode == NameHashCode && propertyDescriptor.PropertyType == PropertyType && propertyDescriptor.Name.Equals(Name)) { return true; } } catch { } return false; } protected object CreateInstance(System.Type type) { System.Type[] array = new System.Type[1] { typeof(System.Type) }; ConstructorInfo constructor = IntrospectionExtensions.GetTypeInfo(type).GetConstructor(array); if (constructor != null) { return TypeDescriptor.CreateInstance(null, type, array, new object[1] { PropertyType }); } return TypeDescriptor.CreateInstance(null, type, null, null); } protected override void FillAttributes(System.Collections.IList attributeList) { _converter = null; _editors = null; _editorTypes = null; _editorCount = 0; base.FillAttributes(attributeList); } public PropertyDescriptorCollection GetChildProperties() { return GetChildProperties(null, null); } public PropertyDescriptorCollection GetChildProperties(System.Attribute[] filter) { return GetChildProperties(null, filter); } public PropertyDescriptorCollection GetChildProperties(object instance) { return GetChildProperties(instance, null); } public virtual PropertyDescriptorCollection GetChildProperties(object instance, System.Attribute[] filter) { if (instance == null) { return TypeDescriptor.GetProperties(PropertyType, filter); } return TypeDescriptor.GetProperties(instance, filter); } public virtual object GetEditor(System.Type editorBaseType) { object obj = null; AttributeCollection attributes = Attributes; if (_editorTypes != null) { for (int i = 0; i < _editorCount; i++) { if (_editorTypes[i] == editorBaseType) { return _editors[i]; } } } if (obj == null) { if (obj == null) { obj = TypeDescriptor.GetEditor(PropertyType, editorBaseType); } if (_editorTypes == null) { _editorTypes = new System.Type[5]; _editors = new object[5]; } if (_editorCount >= _editorTypes.Length) { System.Type[] array = new System.Type[_editorTypes.Length * 2]; object[] array2 = new object[_editors.Length * 2]; System.Array.Copy((System.Array)_editorTypes, (System.Array)array, _editorTypes.Length); System.Array.Copy((System.Array)_editors, (System.Array)array2, _editors.Length); _editorTypes = array; _editors = array2; } _editorTypes[_editorCount] = editorBaseType; _editors[_editorCount++] = obj; } return obj; } public override int GetHashCode() { return NameHashCode ^ ((object)PropertyType).GetHashCode(); } protected override object GetInvocationTarget(System.Type type, object instance) { object obj = base.GetInvocationTarget(type, instance); if (obj is ICustomTypeDescriptor customTypeDescriptor) { obj = customTypeDescriptor.GetPropertyOwner(this); } return obj; } protected System.Type GetTypeFromName(string typeName) { if (typeName == null || typeName.Length == 0) { return null; } System.Type type = System.Type.GetType(typeName); System.Type type2 = null; if (ComponentType != null && (type == null || IntrospectionExtensions.GetTypeInfo(ComponentType).Assembly.FullName.Equals(IntrospectionExtensions.GetTypeInfo(type).Assembly.FullName))) { int num = typeName.IndexOf(','); if (num != -1) { typeName = typeName.Substring(0, num); } type2 = IntrospectionExtensions.GetTypeInfo(ComponentType).Assembly.GetType(typeName); } return type2 ?? type; } public abstract object GetValue(object component); protected virtual void OnValueChanged(object component, EventArgs e) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (component != null && _valueChangedHandlers != null) { EventHandler val = (EventHandler)_valueChangedHandlers[component]; if ((int)val != 0) { val.Invoke(component, e); } } } public virtual void RemoveValueChanged(object component, EventHandler handler) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (component == null) { throw new ArgumentNullException("component"); } if (handler == null) { throw new ArgumentNullException("handler"); } if (_valueChangedHandlers != null) { EventHandler val = (EventHandler)_valueChangedHandlers[component]; val = (EventHandler)System.Delegate.Remove((System.Delegate)(object)val, (System.Delegate)(object)handler); if (val != null) { _valueChangedHandlers[component] = val; } else { _valueChangedHandlers.Remove(component); } } } protected internal EventHandler GetValueChangedHandler(object component) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (component != null && _valueChangedHandlers != null) { return (EventHandler)_valueChangedHandlers[component]; } return null; } public abstract void ResetValue(object component); public abstract void SetValue(object component, object value); public abstract bool ShouldSerializeValue(object component); } public class SByteConverter : BaseNumberConverter { internal override System.Type TargetType => typeof(sbyte); internal override object FromString(string value, int radix) { return Convert.ToSByte(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return sbyte.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return sbyte.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((sbyte)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class SingleConverter : BaseNumberConverter { internal override bool AllowHex => false; internal override System.Type TargetType => typeof(float); internal override object FromString(string value, int radix) { return Convert.ToSingle(value, (IFormatProvider)(object)CultureInfo.CurrentCulture); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return float.Parse(value, (NumberStyles)167, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return float.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((float)value).ToString("R", (IFormatProvider)(object)formatInfo); } } public class StringConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { return (string)value; } if (value == null) { return string.Empty; } return base.ConvertFrom(context, culture, value); } } public class TimeSpanConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType != typeof(string)) { return base.CanConvertFrom(context, sourceType); } return true; } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { //IL_0021: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (value is string text) { string text2 = text.Trim(); try { return TimeSpan.Parse(text2, (IFormatProvider)(object)culture); } catch (FormatException val) { FormatException val2 = val; throw new FormatException(System.SR.Format(System.SR.ConvertInvalidPrimitive, (string)value, "TimeSpan"), (System.Exception)(object)val2); } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } return base.ConvertTo(context, culture, value, destinationType); } } public class TypeConverter { protected abstract class SimplePropertyDescriptor : PropertyDescriptor { private System.Type _componentType; private System.Type _propertyType; public override System.Type ComponentType => _componentType; public override bool IsReadOnly => Attributes.Contains((System.Attribute)(object)ReadOnlyAttribute.Yes); public override System.Type PropertyType => _propertyType; protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType) : this(componentType, name, propertyType, new System.Attribute[0]) { } protected SimplePropertyDescriptor(System.Type componentType, string name, System.Type propertyType, System.Attribute[] attributes) : base(name, attributes) { _componentType = componentType; _propertyType = propertyType; } public override bool CanResetValue(object component) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown DefaultValueAttribute val = (DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]; if (val == null) { return false; } return val.Value.Equals(GetValue(component)); } public override void ResetValue(object component) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown DefaultValueAttribute val = (DefaultValueAttribute)Attributes[typeof(DefaultValueAttribute)]; if (val != null) { SetValue(component, val.Value); } } public override bool ShouldSerializeValue(object component) { return false; } } [DefaultMember("Item")] public class StandardValuesCollection : System.Collections.ICollection, System.Collections.IEnumerable { private System.Collections.ICollection _values; private System.Array _valueArray; public int Count { get { if (_valueArray != null) { return _valueArray.Length; } return _values.Count; } } public object this[int index] { get { if (_valueArray != null) { return _valueArray.GetValue(index); } if (_values is System.Collections.IList list) { return list[index]; } _valueArray = new object[_values.Count]; _values.CopyTo(_valueArray, 0); return _valueArray.GetValue(index); } } bool System.Collections.ICollection.IsSynchronized => false; object System.Collections.ICollection.SyncRoot => null; public StandardValuesCollection(System.Collections.ICollection values) { if (values == null) { values = (System.Collections.ICollection)(object)new object[0]; } if (values is System.Array valueArray) { _valueArray = valueArray; } _values = values; } public void CopyTo(System.Array array, int index) { _values.CopyTo(array, index); } public System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.IEnumerable)_values).GetEnumerator(); } } public bool CanConvertFrom(System.Type sourceType) { return CanConvertFrom(null, sourceType); } public virtual bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { return false; } public bool CanConvertTo(System.Type destinationType) { return CanConvertTo(null, destinationType); } public virtual bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return destinationType == typeof(string); } public object ConvertFrom(object value) { return ConvertFrom(null, CultureInfo.CurrentCulture, value); } public virtual object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { throw GetConvertFromException(value); } public object ConvertFromInvariantString(string text) { return ConvertFromString(null, CultureInfo.InvariantCulture, text); } public object ConvertFromInvariantString(ITypeDescriptorContext context, string text) { return ConvertFromString(context, CultureInfo.InvariantCulture, text); } public object ConvertFromString(string text) { return ConvertFrom(null, null, text); } public object ConvertFromString(ITypeDescriptorContext context, string text) { return ConvertFrom(context, CultureInfo.CurrentCulture, text); } public object ConvertFromString(ITypeDescriptorContext context, CultureInfo culture, string text) { return ConvertFrom(context, culture, text); } public object ConvertTo(object value, System.Type destinationType) { return ConvertTo(null, null, value, destinationType); } public virtual object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string)) { if (value == null) { return string.Empty; } if (culture != null && culture != CultureInfo.CurrentCulture && value is System.IFormattable formattable) { return formattable.ToString((string)null, (IFormatProvider)(object)culture); } return value.ToString(); } throw GetConvertToException(value, destinationType); } public string ConvertToInvariantString(object value) { return ConvertToString(null, CultureInfo.InvariantCulture, value); } public string ConvertToInvariantString(ITypeDescriptorContext context, object value) { return ConvertToString(context, CultureInfo.InvariantCulture, value); } public string ConvertToString(object value) { return (string)ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(string)); } public string ConvertToString(ITypeDescriptorContext context, object value) { return (string)ConvertTo(context, CultureInfo.CurrentCulture, value, typeof(string)); } public string ConvertToString(ITypeDescriptorContext context, CultureInfo culture, object value) { return (string)ConvertTo(context, culture, value, typeof(string)); } public object CreateInstance(IDictionary propertyValues) { return CreateInstance(null, propertyValues); } public virtual object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { return null; } protected System.Exception GetConvertFromException(object value) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(System.SR.Format(p2: (value != null) ? value.GetType().FullName : System.SR.Null, resourceFormat: System.SR.ConvertFromException, p1: base.GetType().Name)); } protected System.Exception GetConvertToException(object value, System.Type destinationType) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(System.SR.Format(p2: (value != null) ? value.GetType().FullName : System.SR.Null, resourceFormat: System.SR.ConvertToException, p1: base.GetType().Name, p3: destinationType.FullName)); } public bool GetCreateInstanceSupported() { return GetCreateInstanceSupported(null); } public virtual bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return false; } public PropertyDescriptorCollection GetProperties(object value) { return GetProperties(null, value); } public PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value) { return GetProperties(context, value, new System.Attribute[1] { (System.Attribute)(object)BrowsableAttribute.Yes }); } public virtual PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, System.Attribute[] attributes) { return null; } public bool GetPropertiesSupported() { return GetPropertiesSupported(null); } public virtual bool GetPropertiesSupported(ITypeDescriptorContext context) { return false; } public System.Collections.ICollection GetStandardValues() { return GetStandardValues(null); } public virtual StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { return null; } public bool GetStandardValuesExclusive() { return GetStandardValuesExclusive(null); } public virtual bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return false; } public bool GetStandardValuesSupported() { return GetStandardValuesSupported(null); } public virtual bool GetStandardValuesSupported(ITypeDescriptorContext context) { return false; } public bool IsValid(object value) { return IsValid(null, value); } public virtual bool IsValid(ITypeDescriptorContext context, object value) { bool result = true; try { if (value == null || CanConvertFrom(context, value.GetType())) { ConvertFrom(context, CultureInfo.InvariantCulture, value); } else { result = false; } } catch { result = false; } return result; } protected PropertyDescriptorCollection SortProperties(PropertyDescriptorCollection props, string[] names) { props.Sort(names); return props; } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class TypeConverterAttribute : System.Attribute { private readonly string _typeName; public static readonly TypeConverterAttribute Default = new TypeConverterAttribute(); public string ConverterTypeName => _typeName; public TypeConverterAttribute() { _typeName = string.Empty; } public TypeConverterAttribute(System.Type type) { _typeName = type.AssemblyQualifiedName; } public TypeConverterAttribute(string typeName) { _typeName = typeName; } public bool Equals(object obj) { if (obj is TypeConverterAttribute typeConverterAttribute) { return typeConverterAttribute.ConverterTypeName == _typeName; } return false; } public int GetHashCode() { return ((object)_typeName).GetHashCode(); } } public abstract class TypeListConverter : TypeConverter { private readonly System.Type[] _types; private StandardValuesCollection _values; protected TypeListConverter(System.Type[] types) { _types = types; } public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) { return base.CanConvertTo(context, destinationType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { System.Type[] types = _types; foreach (System.Type type in types) { if (value.Equals((object)type.FullName)) { return type; } } } return base.ConvertFrom(context, culture, value); } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if (destinationType == typeof(string)) { if (value == null) { return System.SR.none; } return ((System.Type)value).FullName; } return base.ConvertTo(context, culture, value, destinationType); } public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (_values == null) { object[] array; if (_types != null) { array = new object[_types.Length]; System.Array.Copy((System.Array)_types, (System.Array)array, _types.Length); } else { array = null; } _values = new StandardValuesCollection((System.Collections.ICollection)(object)array); } return _values; } public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } } public class UInt16Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(ushort); internal override object FromString(string value, int radix) { return Convert.ToUInt16(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return ushort.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return ushort.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((ushort)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class UInt32Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(uint); internal override object FromString(string value, int radix) { return Convert.ToUInt32(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return uint.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return uint.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((uint)value).ToString("G", (IFormatProvider)(object)formatInfo); } } public class UInt64Converter : BaseNumberConverter { internal override System.Type TargetType => typeof(ulong); internal override object FromString(string value, int radix) { return Convert.ToUInt64(value, radix); } internal override object FromString(string value, NumberFormatInfo formatInfo) { return ulong.Parse(value, (NumberStyles)7, (IFormatProvider)(object)formatInfo); } internal override object FromString(string value, CultureInfo culture) { return ulong.Parse(value, (IFormatProvider)(object)culture); } internal override string ToString(object value, NumberFormatInfo formatInfo) { return ((ulong)value).ToString("G", (IFormatProvider)(object)formatInfo); } } [DefaultMember("Item")] public class AttributeCollection : System.Collections.ICollection, System.Collections.IEnumerable { private struct AttributeEntry { public System.Type type; public int index; } public static readonly AttributeCollection Empty = new AttributeCollection((System.Attribute[])null); private static Hashtable s_defaultAttributes; private readonly System.Attribute[] _attributes; private static readonly object s_internalSyncObject = new object(); private const int FOUND_TYPES_LIMIT = 5; private AttributeEntry[] _foundAttributeTypes; private int _index; protected virtual System.Attribute[] Attributes => _attributes; public int Count => Attributes.Length; public virtual System.Attribute this[int index] => Attributes[index]; public virtual System.Attribute this[System.Type attributeType] { get { lock (s_internalSyncObject) { if (_foundAttributeTypes == null) { _foundAttributeTypes = new AttributeEntry[5]; } int i; for (i = 0; i < 5; i++) { if (_foundAttributeTypes[i].type == attributeType) { int index = _foundAttributeTypes[i].index; if (index != -1) { return Attributes[index]; } return GetDefaultAttribute(attributeType); } if (_foundAttributeTypes[i].type == null) { break; } } i = _index++; if (_index >= 5) { _index = 0; } _foundAttributeTypes[i].type = attributeType; int num = Attributes.Length; for (int j = 0; j < num; j++) { System.Attribute attribute = Attributes[j]; System.Type type = ((object)attribute).GetType(); if (type == attributeType) { _foundAttributeTypes[i].index = j; return attribute; } } for (int k = 0; k < num; k++) { System.Attribute attribute2 = Attributes[k]; System.Type type2 = ((object)attribute2).GetType(); if (IntrospectionExtensions.GetTypeInfo(attributeType).IsAssignableFrom(IntrospectionExtensions.GetTypeInfo(type2))) { _foundAttributeTypes[i].index = k; return attribute2; } } _foundAttributeTypes[i].index = -1; return GetDefaultAttribute(attributeType); } } } bool System.Collections.ICollection.IsSynchronized => false; object System.Collections.ICollection.SyncRoot => null; public AttributeCollection(params System.Attribute[] attributes) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) _attributes = attributes ?? new System.Attribute[0]; for (int i = 0; i < _attributes.Length; i++) { if (_attributes[i] == null) { throw new ArgumentNullException("attributes"); } } } protected AttributeCollection() { } public static AttributeCollection FromExisting(AttributeCollection existing, params System.Attribute[] newAttributes) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (existing == null) { throw new ArgumentNullException("existing"); } if (newAttributes == null) { newAttributes = new System.Attribute[0]; } System.Attribute[] array = new System.Attribute[existing.Count + newAttributes.Length]; int count = existing.Count; existing.CopyTo(array, 0); for (int i = 0; i < newAttributes.Length; i++) { if (newAttributes[i] == null) { throw new ArgumentNullException("newAttributes"); } bool flag = false; for (int j = 0; j < existing.Count; j++) { if (array[j].GetTypeId().Equals(newAttributes[i].GetTypeId())) { flag = true; array[j] = newAttributes[i]; break; } } if (!flag) { array[count++] = newAttributes[i]; } } System.Attribute[] array2 = null; if (count < array.Length) { array2 = new System.Attribute[count]; System.Array.Copy((System.Array)array, 0, (System.Array)array2, 0, count); } else { array2 = array; } return new AttributeCollection(array2); } public bool Contains(System.Attribute attribute) { return ((object)this[((object)attribute).GetType()])?.Equals((object)attribute) ?? false; } public bool Contains(System.Attribute[] attributes) { if (attributes == null) { return true; } for (int i = 0; i < attributes.Length; i++) { if (!Contains(attributes[i])) { return false; } } return true; } protected System.Attribute GetDefaultAttribute(System.Type attributeType) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown lock (s_internalSyncObject) { if (s_defaultAttributes == null) { s_defaultAttributes = new Hashtable(); } if (s_defaultAttributes.ContainsKey((object)attributeType)) { return (System.Attribute)s_defaultAttributes[(object)attributeType]; } System.Attribute attribute = null; System.Type reflectionType = TypeDescriptor.GetReflectionType(attributeType); FieldInfo field = IntrospectionExtensions.GetTypeInfo(reflectionType).GetField("Default", (BindingFlags)1048); if (field != null && field.IsStatic) { attribute = (System.Attribute)field.GetValue((object)null); } else { ConstructorInfo constructor = IntrospectionExtensions.GetTypeInfo(IntrospectionExtensions.GetTypeInfo(reflectionType).UnderlyingSystemType).GetConstructor(new System.Type[0]); if (constructor != null) { attribute = (System.Attribute)constructor.Invoke(new object[0]); if (!attribute.IsDefaultAttribute()) { attribute = null; } } } s_defaultAttributes[(object)attributeType] = attribute; return attribute; } } public System.Collections.IEnumerator GetEnumerator() { return ((System.Array)Attributes).GetEnumerator(); } public bool Matches(System.Attribute attribute) { for (int i = 0; i < Attributes.Length; i++) { if (Attributes[i].Match(attribute)) { return true; } } return false; } public bool Matches(System.Attribute[] attributes) { for (int i = 0; i < attributes.Length; i++) { if (!Matches(attributes[i])) { return false; } } return true; } public void CopyTo(System.Array array, int index) { System.Array.Copy((System.Array)Attributes, 0, array, index, Attributes.Length); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public class AttributeProviderAttribute : System.Attribute { private readonly string _typeName; private readonly string _propertyName; public string TypeName => _typeName; public string PropertyName => _propertyName; public AttributeProviderAttribute(string typeName) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (typeName == null) { throw new ArgumentNullException("typeName"); } _typeName = typeName; } public AttributeProviderAttribute(string typeName, string propertyName) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (typeName == null) { throw new ArgumentNullException("typeName"); } if (propertyName == null) { throw new ArgumentNullException("propertyName"); } _typeName = typeName; _propertyName = propertyName; } public AttributeProviderAttribute(System.Type type) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (type == null) { throw new ArgumentNullException("type"); } _typeName = type.AssemblyQualifiedName; } } public delegate void CancelEventHandler(object sender, CancelEventArgs e); public enum CollectionChangeAction { Add = 1, Remove, Refresh } public class CollectionChangeEventArgs : EventArgs { private readonly CollectionChangeAction _action; private readonly object _element; public virtual CollectionChangeAction Action => _action; public virtual object Element => _element; public CollectionChangeEventArgs(CollectionChangeAction action, object element) { _action = action; _element = element; } } public delegate void CollectionChangeEventHandler(object sender, CollectionChangeEventArgs e); internal static class ComponentModelExtensions { private static readonly Dictionary<System.Type, Func<System.Attribute, object>> s_typeId; private static readonly Dictionary<System.Type, Func<System.Attribute, bool>> s_defaultAttributes; public static bool IsDefaultAttribute(this System.Attribute attribute) { Func<System.Attribute, bool> val = default(Func<System.Attribute, bool>); if (s_defaultAttributes.TryGetValue(((object)attribute).GetType(), ref val)) { return val.Invoke(attribute); } return false; } public static object GetTypeId(this System.Attribute attribute) { Func<System.Attribute, object> val = default(Func<System.Attribute, object>); if (!s_typeId.TryGetValue(((object)attribute).GetType(), ref val)) { return ((object)attribute).GetType(); } return val.Invoke(attribute); } public static bool Match(this System.Attribute attribute, object obj) { return ((object)attribute).Equals(obj); } static ComponentModelExtensions() { Dictionary<System.Type, Func<System.Attribute, object>> val = new Dictionary<System.Type, Func<System.Attribute, object>>(); val.Add(typeof(DesignerCategoryAttribute), (Func<System.Attribute, object>)((System.Attribute attr) => ((object)attr).GetType().FullName + ((DesignerCategoryAttribute)attr).Category)); val.Add(typeof(ProvidePropertyAttribute), (Func<System.Attribute, object>)((System.Attribute attr) => ((object)attr).GetType().FullName + ((ProvidePropertyAttribute)attr).PropertyName)); s_typeId = val; Dictionary<System.Type, Func<System.Attribute, bool>> val2 = new Dictionary<System.Type, Func<System.Attribute, bool>>(); val2.Add(typeof(BrowsableAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)BrowsableAttribute.Default))); val2.Add(typeof(CategoryAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((CategoryAttribute)attr).Category.Equals(CategoryAttribute.Default.Category))); val2.Add(typeof(DescriptionAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)DescriptionAttribute.Default))); val2.Add(typeof(DesignOnlyAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((DesignOnlyAttribute)attr).IsDesignOnly == DesignOnlyAttribute.Default.IsDesignOnly)); val2.Add(typeof(DisplayNameAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)DisplayNameAttribute.Default))); val2.Add(typeof(ImmutableObjectAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)ImmutableObjectAttribute.Default))); val2.Add(typeof(LocalizableAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((LocalizableAttribute)attr).IsLocalizable == LocalizableAttribute.Default.IsLocalizable)); val2.Add(typeof(MergablePropertyAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)MergablePropertyAttribute.Default))); val2.Add(typeof(NotifyParentPropertyAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)NotifyParentPropertyAttribute.Default))); val2.Add(typeof(ParenthesizePropertyNameAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)ParenthesizePropertyNameAttribute.Default))); val2.Add(typeof(ReadOnlyAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((ReadOnlyAttribute)attr).IsReadOnly == ReadOnlyAttribute.Default.IsReadOnly)); val2.Add(typeof(RefreshPropertiesAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)RefreshPropertiesAttribute.Default))); val2.Add(typeof(DesignerSerializationVisibilityAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)DesignerSerializationVisibilityAttribute.Default))); val2.Add(typeof(ExtenderProvidedPropertyAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((ExtenderProvidedPropertyAttribute)attr).ReceiverType == null)); val2.Add(typeof(DesignerCategoryAttribute), (Func<System.Attribute, bool>)((System.Attribute attr) => ((object)attr).Equals((object)DesignerCategoryAttribute.Default.Category))); s_defaultAttributes = val2; } } public abstract class CustomTypeDescriptor : ICustomTypeDescriptor { private readonly ICustomTypeDescriptor _parent; protected CustomTypeDescriptor() { } protected CustomTypeDescriptor(ICustomTypeDescriptor parent) { _parent = parent; } public virtual AttributeCollection GetAttributes() { if (_parent != null) { return _parent.GetAttributes(); } return AttributeCollection.Empty; } public virtual string GetClassName() { if (_parent != null) { return _parent.GetClassName(); } return null; } public virtual string GetComponentName() { if (_parent != null) { return _parent.GetComponentName(); } return null; } public virtual TypeConverter GetConverter() { if (_parent != null) { return _parent.GetConverter(); } return new TypeConverter(); } public virtual EventDescriptor GetDefaultEvent() { if (_parent != null) { return _parent.GetDefaultEvent(); } return null; } public virtual PropertyDescriptor GetDefaultProperty() { if (_parent != null) { return _parent.GetDefaultProperty(); } return null; } public virtual object GetEditor(System.Type editorBaseType) { if (_parent != null) { return _parent.GetEditor(editorBaseType); } return null; } public virtual EventDescriptorCollection GetEvents() { if (_parent != null) { return _parent.GetEvents(); } return EventDescriptorCollection.Empty; } public virtual EventDescriptorCollection GetEvents(System.Attribute[] attributes) { if (_parent != null) { return _parent.GetEvents(attributes); } return EventDescriptorCollection.Empty; } public virtual PropertyDescriptorCollection GetProperties() { if (_parent != null) { return _parent.GetProperties(); } return PropertyDescriptorCollection.Empty; } public virtual PropertyDescriptorCollection GetProperties(System.Attribute[] attributes) { if (_parent != null) { return _parent.GetProperties(attributes); } return PropertyDescriptorCollection.Empty; } public virtual object GetPropertyOwner(PropertyDescriptor pd) { if (_parent != null) { return _parent.GetPropertyOwner(pd); } return null; } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class DefaultEventAttribute : System.Attribute { private readonly string _name; public static readonly DefaultEventAttribute Default = new DefaultEventAttribute(null); public string Name => _name; public DefaultEventAttribute(string name) { _name = name; } public bool Equals(object obj) { if (obj is DefaultEventAttribute defaultEventAttribute) { return defaultEventAttribute.Name == _name; } return false; } public int GetHashCode() { return base.GetHashCode(); } } [AttributeUsage(/*Could not decode attribute arguments.*/)] public sealed class DefaultPropertyAttribute : System.Attribute { private readonly string _name; public static readonly DefaultPropertyAttribute Default = new DefaultPropertyAttribute(null); public string Name => _name; public DefaultPropertyAttribute(string name) { _name = name; } public bool Equals(object obj) { if (obj is DefaultPropertyAttribute defaultPropertyAttribute) { return defaultPropertyAttribute.Name == _name; } return false; } public int GetHashCode() { return base.GetHashCode(); } } internal sealed class DelegatingTypeDescriptionProvider : TypeDescriptionProvider { private readonly System.Type _type; internal TypeDescriptionProvider Provider => TypeDescriptor.GetProviderRecursive(_type); internal DelegatingTypeDescriptionProvider(System.Type type) { _type = type; } public override object CreateInstance(IServiceProvider provider, System.Type objectType, System.Type[] argTypes, object[] args) { return Provider.CreateInstance(provider, objectType, argTypes, args); } public override IDictionary GetCache(object instance) { return Provider.GetCache(instance); } public override string GetFullComponentName(object component) { return Provider.GetFullComponentName(component); } public override ICustomTypeDescriptor GetExtendedTypeDescriptor(object instance) { return Provider.GetExtendedTypeDescriptor(instance); } protected internal override IExtenderProvider[] GetExtenderProviders(object instance) { return Provider.GetExtenderProviders(instance); } public override System.Type GetReflectionType(System.Type objectType, object instance) { return Provider.GetReflectionType(objectType, instance); } public override System.Type GetRuntimeType(System.Type objectType) { return Provider.GetRuntimeType(objectType); } public override ICustomTypeDescriptor GetTypeDescriptor(System.Type objectType, object instance) { return Provider.GetTypeDescriptor(objectType, instance); } public override bool IsSupportedType(System.Type type) { return Provider.IsSupportedType(type); } } public abstract class EventDescriptor : MemberDescriptor { public abstract System.Type ComponentType { get; } public abstract System.Type EventType { get; } public abstract bool IsMulticast { get; } protected EventDescriptor(string name, System.Attribute[] attrs) : base(name, attrs) { } protected EventDescriptor(MemberDescriptor descr) : base(descr) { } protected EventDescriptor(MemberDescriptor descr, System.Attribute[] attrs) : base(descr, attrs) { } public abstract void AddEventHandler(object component, System.Delegate value); public abstract void RemoveEventHandler(object component, System.Delegate value); } [DefaultMember("Item")] public class EventDescriptorCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList { private class ArraySubsetEnumerator : System.Collections.IEnumerator { private readonly System.Array _array; private readonly int _total; private int _current; public object Current { get { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (_current == -1) { throw new InvalidOperationException(); } return _array.GetValue(_current); } } public ArraySubsetEnumerator(System.Array array, int count) { _array = array; _total = count; _current = -1; } public bool MoveNext() { if (_current < _total - 1) { _current++; return true; } return false; } public void Reset() { _current = -1; } } private EventDescriptor[] _events; private string[] _namedSort; private readonly IComparer _comparer; private bool _eventsOwned; private bool _needSort; private int _eventCount; private readonly bool _readOnly; public static readonly EventDescriptorCollection Empty = new EventDescriptorCollection(null, readOnly: true); public int Count => _eventCount; public virtual EventDescriptor this[int index] { get { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (index >= _eventCount) { throw new IndexOutOfRangeException(); } EnsureEventsOwned(); return _events[index]; } } public virtual EventDescriptor this[string name] => Find(name, ignoreCase: false); bool System.Collections.ICollection.IsSynchronized => false; object System.Collections.ICollection.SyncRoot => null; object System.Collections.IList.this[int index] { get { return this[index]; } set { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } if (index >= _eventCount) { throw new IndexOutOfRangeException(); } EnsureEventsOwned(); _events[index] = (EventDescriptor)value; } } bool System.Collections.IList.IsReadOnly => _readOnly; bool System.Collections.IList.IsFixedSize => _readOnly; public EventDescriptorCollection(EventDescriptor[] events) { _events = events; if (events == null) { _events = new EventDescriptor[0]; _eventCount = 0; } else { _eventCount = _events.Length; } _eventsOwned = true; } public EventDescriptorCollection(EventDescriptor[] events, bool readOnly) : this(events) { _readOnly = readOnly; } private EventDescriptorCollection(EventDescriptor[] events, int eventCount, string[] namedSort, IComparer comparer) { _eventsOwned = false; if (namedSort != null) { _namedSort = (string[])((System.Array)namedSort).Clone(); } _comparer = comparer; _events = events; _eventCount = eventCount; _needSort = true; } public int Add(EventDescriptor value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } EnsureSize(_eventCount + 1); _events[_eventCount++] = value; return _eventCount - 1; } public void Clear() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } _eventCount = 0; } public bool Contains(EventDescriptor value) { return IndexOf(value) >= 0; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { EnsureEventsOwned(); System.Array.Copy((System.Array)_events, 0, array, index, Count); } private void EnsureEventsOwned() { if (!_eventsOwned) { _eventsOwned = true; if (_events != null) { EventDescriptor[] array = new EventDescriptor[Count]; System.Array.Copy((System.Array)_events, 0, (System.Array)array, 0, Count); _events = array; } } if (_needSort) { _needSort = false; InternalSort(_namedSort); } } private void EnsureSize(int sizeNeeded) { if (sizeNeeded > _events.Length) { if (_events == null || _events.Length == 0) { _eventCount = 0; _events = new EventDescriptor[sizeNeeded]; return; } EnsureEventsOwned(); int num = Math.Max(sizeNeeded, _events.Length * 2); EventDescriptor[] array = new EventDescriptor[num]; System.Array.Copy((System.Array)_events, 0, (System.Array)array, 0, _eventCount); _events = array; } } public virtual EventDescriptor Find(string name, bool ignoreCase) { EventDescriptor result = null; if (ignoreCase) { for (int i = 0; i < Count; i++) { if (string.Equals(_events[i].Name, name, (StringComparison)5)) { result = _events[i]; break; } } } else { for (int j = 0; j < Count; j++) { if (string.Equals(_events[j].Name, name, (StringComparison)4)) { result = _events[j]; break; } } } return result; } public int IndexOf(EventDescriptor value) { return System.Array.IndexOf<EventDescriptor>(_events, value, 0, _eventCount); } public void Insert(int index, EventDescriptor value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } EnsureSize(_eventCount + 1); if (index < _eventCount) { System.Array.Copy((System.Array)_events, index, (System.Array)_events, index + 1, _eventCount - index); } _events[index] = value; _eventCount++; } public void Remove(EventDescriptor value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } int num = IndexOf(value); if (num != -1) { RemoveAt(num); } } public void RemoveAt(int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(); } if (index < _eventCount - 1) { System.Array.Copy((System.Array)_events, index + 1, (System.Array)_events, index, _eventCount - index - 1); } _events[_eventCount - 1] = null; _eventCount--; } public System.Collections.IEnumerator GetEnumerator() { if (_events.Length == _eventCount) { return ((System.Array)_events).GetEnumerator(); } return new ArraySubsetEnumerator(_events, _eventCount); } public virtual EventDescriptorCollection Sort() { return new EventDescriptorCollection(_events, _eventCount, _namedSort, _comparer); } public virtual EventDescriptorCollection Sort(string[] names) { return new EventDescriptorCollection(_events, _eventCount, names, _comparer); } public virtual EventDescriptorCollection Sort(string[] names, IComparer comparer) { return new EventDescriptorCollection(_events, _eventCount, names, comparer); } public virtual EventDescriptorCollection Sort(IComparer comparer) { return new EventDescriptorCollection(_events, _eventCount, _namedSort, comparer); } protected void InternalSort(string[] names) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (_events == null || _events.Length == 0) { return; } InternalSort(_comparer); if (names == null || names.Length == 0) { return; } ArrayList val = new ArrayList((System.Collections.ICollection)(object)_events); int num = 0; int num2 = _events.Length; for (int i = 0; i < names.Length; i++) { for (int j = 0; j < num2; j++) { EventDescriptor eventDescriptor = (EventDescriptor)val[j]; if (eventDescriptor != null && eventDescriptor.Name.Equals(names[i])) { _events[num++] = eventDescriptor; val[j] = null; break; } } } for (int k = 0; k < num2; k++) { if (val[k] != null) { _events[num++] = (EventDescriptor)val[k]; } } } protected void InternalSort(IComparer sorter) { if (sorter == null) { TypeDescriptor.SortDescriptorArray(this); } else { System.Array.Sort((System.Array)_events, sorter); } } int System.Collections.IList.Add(object value) { return Add((EventDescriptor)value); } bool System.Collections.IList.Contains(object value) { return Contains((EventDescriptor)value); } int System.Collections.IList.IndexOf(object value) { return IndexOf((EventDescriptor)value); } void System.Collections.IList.Insert(int index, object value) { Insert(index, (EventDescriptor)value); } void System.Collections.IList.Remove(object value) { Remove((EventDescriptor)value); } } internal sealed class ExtendedPropertyDescriptor : PropertyDescriptor { private readonly ReflectPropertyDescriptor _extenderInfo; private readonly IExtenderProvider _provider; public override System.Type ComponentType => _extenderInfo.ComponentType; public override bool IsReadOnly => ((object)Attributes[typeof(ReadOnlyAttribute)]).Equals((object)ReadOnlyAttribute.Yes); public override System.Type PropertyType => _extenderInfo.ExtenderGetType(_provider); public override string DisplayName { get { string text = base.DisplayName; System.Attribute attribute = Attributes[typeof(DisplayNameAttribute)]; DisplayNameAttribute val = (DisplayNameAttribute)(object)((attribute is DisplayNameAttribute) ? attribute : null); if (val == null || ((System.Attribute)(object)val).IsDefaultAttribute()) { ISite site = MemberDescriptor.GetSite(_provider); if (site != null) { string name = site.Name; if (name != null && name.Length > 0) { text = string.Format(System.SR.MetaExtenderName, (object)text, (object)name); } } } return text; } } public ExtendedPropertyDescriptor(ReflectPropertyDescriptor extenderInfo, System.Type receiverType, IExtenderProvider provider, System.Attribute[] attributes) : base(extenderInfo, attributes) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown ArrayList val = new ArrayList((System.Collections.ICollection)(object)AttributeArray); val.Add((object)ExtenderProvidedPropertyAttribute.Create(extenderInfo, receiverType, provider)); if (extenderInfo.IsReadOnly) { val.Add((object)ReadOnlyAttribute.Yes); } System.Attribute[] array = new System.Attribute[val.Count]; val.CopyTo((System.Array)array, 0); AttributeArray = array; _extenderInfo = extenderInfo; _provider = provider; } public ExtendedPropertyDescriptor(PropertyDescriptor extender, System.Attribute[] attributes) : base(extender, attributes) { ExtenderProvidedPropertyAttribute extenderProvidedPropertyAttribute = extender.Attributes[typeof(ExtenderProvidedPropertyAttribute)] as ExtenderProvidedPropertyAttribute; ReflectPropertyDescriptor extenderInfo = extenderProvidedPropertyAttribute.ExtenderProperty as ReflectPropertyDescriptor; _extenderInfo = extenderInfo; _provider = extenderProvidedPropertyAttribute.Provider; } public override bool CanResetValue(object comp) { return _extenderInfo.ExtenderCanResetValue(_provider, comp); } public override object GetValue(object comp) { return _extenderInfo.ExtenderGetValue(_provider, comp); } public override void ResetValue(object comp) { _extenderInfo.ExtenderResetValue(_provider, comp, this); } public override void SetValue(object component, object value)
BepInEx/plugins/DearImGuiInjection/System.Reflection.Emit.ILGeneration.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using FxResources.System.Reflection.Emit.ILGeneration; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyDefaultAlias("System.Reflection.Emit.ILGeneration")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("NotSupported", "True")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Reflection.Emit.ILGeneration")] [assembly: AssemblyFileVersion("4.700.19.56404")] [assembly: AssemblyInformationalVersion("3.1.0+0f7f38c4fd323b26da10cce95f857f77f0f09b48")] [assembly: AssemblyProduct("Microsoft® .NET Core")] [assembly: AssemblyTitle("System.Reflection.Emit.ILGeneration")] [assembly: CLSCompliant(true)] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: AssemblyVersion("4.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } } namespace FxResources.System.Reflection.Emit.ILGeneration { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR))); internal static string PlatformNotSupported_RefEmitILGeneration => GetResourceString("PlatformNotSupported_RefEmitILGeneration"); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString = null) { if (UsingResourceKeys()) { return defaultString ?? resourceKey; } string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text)) { return defaultString; } return text; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(IFormatProvider provider, string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(provider, resourceFormat, p1); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(provider, resourceFormat, p1, p2); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(provider, resourceFormat, p1, p2, p3); } internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(provider, resourceFormat, args); } return resourceFormat; } } } namespace System.Reflection.Emit { public class CustomAttributeBuilder { public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, FieldInfo[] namedFields, object[] fieldValues) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public class ILGenerator { public virtual int ILOffset { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } internal ILGenerator() { } public virtual void BeginCatchBlock(Type exceptionType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void BeginExceptFilterBlock() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual Label BeginExceptionBlock() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void BeginFaultBlock() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void BeginFinallyBlock() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void BeginScope() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual LocalBuilder DeclareLocal(Type localType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual LocalBuilder DeclareLocal(Type localType, bool pinned) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual Label DefineLabel() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, byte arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, double arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, short arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, int arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, long arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, ConstructorInfo con) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, Label label) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, Label[] labels) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, LocalBuilder local) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, SignatureHelper signature) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, FieldInfo field) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, MethodInfo meth) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } [CLSCompliant(false)] public void Emit(OpCode opcode, sbyte arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, float arg) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, string str) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void Emit(OpCode opcode, Type cls) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EmitCalli(OpCode opcode, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EmitWriteLine(LocalBuilder localBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EmitWriteLine(FieldInfo fld) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EmitWriteLine(string value) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EndExceptionBlock() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void EndScope() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void MarkLabel(Label loc) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void ThrowException(Type excType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public virtual void UsingNamespace(string usingNamespace) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public readonly struct Label { private readonly int _dummyPrimitive; public override bool Equals(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public bool Equals(Label obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static bool operator ==(Label a, Label b) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static bool operator !=(Label a, Label b) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public sealed class LocalBuilder : LocalVariableInfo { public override bool IsPinned { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public override int LocalIndex { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public override Type LocalType { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } internal LocalBuilder() { } } public class ParameterBuilder { public virtual int Attributes { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public bool IsIn { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public bool IsOptional { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public bool IsOut { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public virtual string Name { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public virtual int Position { get { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } internal ParameterBuilder() { } public virtual void SetConstant(object defaultValue) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void SetCustomAttribute(CustomAttributeBuilder customBuilder) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } public sealed class SignatureHelper { internal SignatureHelper() { } public void AddArgument(Type clsArgument) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void AddArgument(Type argument, bool pinned) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public void AddSentinel() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public override bool Equals(object obj) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetFieldSigHelper(Module mod) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public override int GetHashCode() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetLocalVarSigHelper() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetLocalVarSigHelper(Module mod) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetMethodSigHelper(CallingConventions callingConvention, Type returnType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetMethodSigHelper(Module mod, CallingConventions callingConvention, Type returnType) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetMethodSigHelper(Module mod, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetPropertySigHelper(Module mod, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] parameterTypes) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public static SignatureHelper GetPropertySigHelper(Module mod, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public byte[] GetSignature() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } public override string ToString() { throw new PlatformNotSupportedException(System.SR.PlatformNotSupported_RefEmitILGeneration); } } }
BepInEx/plugins/DearImGuiInjection/System.Collections.Specialized.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using FxResources.System.Collections.Specialized; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Collections.Specialized")] [assembly: AssemblyDescription("System.Collections.Specialized")] [assembly: AssemblyDefaultAlias("System.Collections.Specialized")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.0.2.0")] namespace FxResources.System.Collections.Specialized { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Collections.Specialized.SR"; private static ResourceManager ResourceManager { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string Argument_AddingDuplicate => GetResourceString("Argument_AddingDuplicate", null); internal static string Argument_InvalidValue => GetResourceString("Argument_InvalidValue", null); internal static string ArgumentOutOfRange_NeedNonNegNum => GetResourceString("ArgumentOutOfRange_NeedNonNegNum", null); internal static string InvalidOperation_EnumFailedVersion => GetResourceString("InvalidOperation_EnumFailedVersion", null); internal static string InvalidOperation_EnumOpCantHappen => GetResourceString("InvalidOperation_EnumOpCantHappen", null); internal static string Arg_MultiRank => GetResourceString("Arg_MultiRank", null); internal static string Arg_NonZeroLowerBound => GetResourceString("Arg_NonZeroLowerBound", null); internal static string Arg_InsufficientSpace => GetResourceString("Arg_InsufficientSpace", null); internal static string CollectionReadOnly => GetResourceString("CollectionReadOnly", null); internal static string BitVectorFull => GetResourceString("BitVectorFull", null); internal static string OrderedDictionary_ReadOnly => GetResourceString("OrderedDictionary_ReadOnly", null); internal static System.Type ResourceType => typeof(SR); [MethodImpl(8)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, (StringComparison)4)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", new object[2] { resourceFormat, p1 }); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", new object[3] { resourceFormat, p1, p2 }); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", new object[4] { resourceFormat, p1, p2, p3 }); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Collections.Specialized { [DefaultMember("Item")] public struct BitVector32 { public struct Section { private readonly short _mask; private readonly short _offset; public short Mask => _mask; public short Offset => _offset; internal Section(short mask, short offset) { _mask = mask; _offset = offset; } public bool Equals(object o) { if (o is Section) { return Equals((Section)o); } return false; } public bool Equals(Section obj) { if (obj._mask == _mask) { return obj._offset == _offset; } return false; } public static bool operator ==(Section a, Section b) { return a.Equals(b); } public static bool operator !=(Section a, Section b) { return !(a == b); } public int GetHashCode() { return base.GetHashCode(); } public static string ToString(Section value) { return string.Concat(new string[5] { "Section{0x", Convert.ToString(value.Mask, 16), ", 0x", Convert.ToString(value.Offset, 16), "}" }); } public string ToString() { return ToString(this); } } private uint _data; public bool this[int bit] { get { return (_data & bit) == (uint)bit; } set { if (value) { _data |= (uint)bit; } else { _data &= (uint)(~bit); } } } public int this[Section section] { get { return (int)((_data & (uint)(section.Mask << (int)section.Offset)) >> (int)section.Offset); } set { value <<= (int)section.Offset; int num = (0xFFFF & section.Mask) << (int)section.Offset; _data = (_data & (uint)(~num)) | (uint)(value & num); } } public int Data => (int)_data; public BitVector32(int data) { _data = (uint)data; } public BitVector32(BitVector32 value) { _data = value._data; } private static short CountBitsSet(short mask) { short num = 0; while (((uint)mask & (true ? 1u : 0u)) != 0) { num++; mask >>= 1; } return num; } public static int CreateMask() { return CreateMask(0); } public static int CreateMask(int previous) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return previous switch { 0 => 1, -2147483648 => throw new InvalidOperationException(System.SR.BitVectorFull), _ => previous << 1, }; } private static short CreateMaskFromHighValue(short highValue) { short num = 16; while ((highValue & 0x8000) == 0) { num--; highValue <<= 1; } ushort num2 = 0; while (num > 0) { num--; num2 <<= 1; num2 = (ushort)(num2 | 1u); } return (short)num2; } public static Section CreateSection(short maxValue) { return CreateSectionHelper(maxValue, 0, 0); } public static Section CreateSection(short maxValue, Section previous) { return CreateSectionHelper(maxValue, previous.Mask, previous.Offset); } private static Section CreateSectionHelper(short maxValue, short priorMask, short priorOffset) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (maxValue < 1) { throw new ArgumentException(System.SR.Format(System.SR.Argument_InvalidValue, "maxValue", 1), "maxValue"); } short num = (short)(priorOffset + CountBitsSet(priorMask)); if (num >= 32) { throw new InvalidOperationException(System.SR.BitVectorFull); } return new Section(CreateMaskFromHighValue(maxValue), num); } public bool Equals(object o) { if (!(o is BitVector32)) { return false; } return _data == ((BitVector32)o)._data; } public int GetHashCode() { return base.GetHashCode(); } public static string ToString(BitVector32 value) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown StringBuilder val = new StringBuilder(45); val.Append("BitVector32{"); int num = (int)value._data; for (int i = 0; i < 32; i++) { if ((num & 0x80000000u) != 0L) { val.Append('1'); } else { val.Append('0'); } num <<= 1; } val.Append('}'); return ((object)val).ToString(); } public string ToString() { return ToString(this); } } [DefaultMember("Item")] public class HybridDictionary : IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { private const int CutoverPoint = 9; private const int InitialHashtableSize = 13; private const int FixedSizeCutoverPoint = 6; private ListDictionary _list; private Hashtable _hashtable; private readonly bool _caseInsensitive; public object this[object key] { get { //IL_002f: Unknown result type (might be due to invalid IL or missing references) ListDictionary list = _list; if (_hashtable != null) { return _hashtable[key]; } if (list != null) { return list[key]; } if (key == null) { throw new ArgumentNullException("key"); } return null; } set { if (_hashtable != null) { _hashtable[key] = value; } else if (_list != null) { if (_list.Count >= 8) { ChangeOver(); _hashtable[key] = value; } else { _list[key] = value; } } else { _list = new ListDictionary((IComparer)(object)(_caseInsensitive ? StringComparer.OrdinalIgnoreCase : null)); _list[key] = value; } } } private ListDictionary List { get { if (_list == null) { _list = new ListDictionary((IComparer)(object)(_caseInsensitive ? StringComparer.OrdinalIgnoreCase : null)); } return _list; } } public int Count { get { ListDictionary list = _list; if (_hashtable != null) { return _hashtable.Count; } return list?.Count ?? 0; } } public System.Collections.ICollection Keys { get { if (_hashtable != null) { return _hashtable.Keys; } return List.Keys; } } public bool IsReadOnly => false; public bool IsFixedSize => false; public bool IsSynchronized => false; public object SyncRoot => this; public System.Collections.ICollection Values { get { if (_hashtable != null) { return _hashtable.Values; } return List.Values; } } public HybridDictionary() { } public HybridDictionary(int initialSize) : this(initialSize, caseInsensitive: false) { } public HybridDictionary(bool caseInsensitive) { _caseInsensitive = caseInsensitive; } public HybridDictionary(int initialSize, bool caseInsensitive) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown _caseInsensitive = caseInsensitive; if (initialSize >= 6) { if (caseInsensitive) { _hashtable = new Hashtable(initialSize, (IEqualityComparer)(object)StringComparer.OrdinalIgnoreCase); } else { _hashtable = new Hashtable(initialSize); } } } private void ChangeOver() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown IDictionaryEnumerator enumerator = _list.GetEnumerator(); Hashtable val = ((!_caseInsensitive) ? new Hashtable(13) : new Hashtable(13, (IEqualityComparer)(object)StringComparer.OrdinalIgnoreCase)); while (((System.Collections.IEnumerator)enumerator).MoveNext()) { val.Add(enumerator.Key, enumerator.Value); } _hashtable = val; _list = null; } public void Add(object key, object value) { if (_hashtable != null) { _hashtable.Add(key, value); } else if (_list == null) { _list = new ListDictionary((IComparer)(object)(_caseInsensitive ? StringComparer.OrdinalIgnoreCase : null)); _list.Add(key, value); } else if (_list.Count + 1 >= 9) { ChangeOver(); _hashtable.Add(key, value); } else { _list.Add(key, value); } } public void Clear() { if (_hashtable != null) { Hashtable hashtable = _hashtable; _hashtable = null; hashtable.Clear(); } if (_list != null) { ListDictionary list = _list; _list = null; list.Clear(); } } public bool Contains(object key) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) ListDictionary list = _list; if (_hashtable != null) { return _hashtable.Contains(key); } if (list != null) { return list.Contains(key); } if (key == null) { throw new ArgumentNullException("key"); } return false; } public void CopyTo(System.Array array, int index) { if (_hashtable != null) { _hashtable.CopyTo(array, index); } else { List.CopyTo(array, index); } } public IDictionaryEnumerator GetEnumerator() { if (_hashtable != null) { return _hashtable.GetEnumerator(); } if (_list == null) { _list = new ListDictionary((IComparer)(object)(_caseInsensitive ? StringComparer.OrdinalIgnoreCase : null)); } return _list.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { if (_hashtable != null) { return (System.Collections.IEnumerator)_hashtable.GetEnumerator(); } if (_list == null) { _list = new ListDictionary((IComparer)(object)(_caseInsensitive ? StringComparer.OrdinalIgnoreCase : null)); } return (System.Collections.IEnumerator)_list.GetEnumerator(); } public void Remove(object key) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (_hashtable != null) { _hashtable.Remove(key); } else if (_list != null) { _list.Remove(key); } else if (key == null) { throw new ArgumentNullException("key"); } } } [DefaultMember("Item")] public interface IOrderedDictionary : IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { object this[int index] { get; set; } IDictionaryEnumerator GetEnumerator(); void Insert(int index, object key, object value); void RemoveAt(int index); } [DefaultMember("Item")] public class ListDictionary : IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { private class NodeEnumerator : IDictionaryEnumerator, System.Collections.IEnumerator { private ListDictionary _list; private DictionaryNode _current; private int _version; private bool _start; public object Current => Entry; public DictionaryEntry Entry { get { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_current == null) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumOpCantHappen); } return new DictionaryEntry(_current.key, _current.value); } } public object Key { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_current == null) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumOpCantHappen); } return _current.key; } } public object Value { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_current == null) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumOpCantHappen); } return _current.value; } } public NodeEnumerator(ListDictionary list) { _list = list; _version = list._version; _start = true; _current = null; } public bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } if (_start) { _current = _list._head; _start = false; } else if (_current != null) { _current = _current.next; } return _current != null; } public void Reset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } _start = true; _current = null; } } private class NodeKeyValueCollection : System.Collections.ICollection, System.Collections.IEnumerable { private class NodeKeyValueEnumerator : System.Collections.IEnumerator { private ListDictionary _list; private DictionaryNode _current; private int _version; private bool _isKeys; private bool _start; public object Current { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_current == null) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumOpCantHappen); } if (!_isKeys) { return _current.value; } return _current.key; } } public NodeKeyValueEnumerator(ListDictionary list, bool isKeys) { _list = list; _isKeys = isKeys; _version = list._version; _start = true; _current = null; } public bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } if (_start) { _current = _list._head; _start = false; } else if (_current != null) { _current = _current.next; } return _current != null; } public void Reset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } _start = true; _current = null; } } private ListDictionary _list; private bool _isKeys; int System.Collections.ICollection.Count { get { int num = 0; for (DictionaryNode dictionaryNode = _list._head; dictionaryNode != null; dictionaryNode = dictionaryNode.next) { num++; } return num; } } bool System.Collections.ICollection.IsSynchronized => false; object System.Collections.ICollection.SyncRoot => _list.SyncRoot; public NodeKeyValueCollection(ListDictionary list, bool isKeys) { _list = list; _isKeys = isKeys; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } for (DictionaryNode dictionaryNode = _list._head; dictionaryNode != null; dictionaryNode = dictionaryNode.next) { array.SetValue(_isKeys ? dictionaryNode.key : dictionaryNode.value, index); index++; } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new NodeKeyValueEnumerator(_list, _isKeys); } } private class DictionaryNode { public object key; public object value; public DictionaryNode next; } private DictionaryNode _head; private int _version; private int _count; private readonly IComparer _comparer; private object _syncRoot; public object this[object key] { get { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } DictionaryNode dictionaryNode = _head; if (_comparer == null) { while (dictionaryNode != null) { object key2 = dictionaryNode.key; if (key2.Equals(key)) { return dictionaryNode.value; } dictionaryNode = dictionaryNode.next; } } else { while (dictionaryNode != null) { object key3 = dictionaryNode.key; if (_comparer.Compare(key3, key) == 0) { return dictionaryNode.value; } dictionaryNode = dictionaryNode.next; } } return null; } set { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _version++; DictionaryNode dictionaryNode = null; DictionaryNode dictionaryNode2; for (dictionaryNode2 = _head; dictionaryNode2 != null; dictionaryNode2 = dictionaryNode2.next) { object key2 = dictionaryNode2.key; if ((_comparer == null) ? key2.Equals(key) : (_comparer.Compare(key2, key) == 0)) { break; } dictionaryNode = dictionaryNode2; } if (dictionaryNode2 != null) { dictionaryNode2.value = value; return; } DictionaryNode dictionaryNode3 = new DictionaryNode(); dictionaryNode3.key = key; dictionaryNode3.value = value; if (dictionaryNode != null) { dictionaryNode.next = dictionaryNode3; } else { _head = dictionaryNode3; } _count++; } } public int Count => _count; public System.Collections.ICollection Keys => new NodeKeyValueCollection(this, isKeys: true); public bool IsReadOnly => false; public bool IsFixedSize => false; public bool IsSynchronized => false; public object SyncRoot { get { if (_syncRoot == null) { Interlocked.CompareExchange(ref _syncRoot, new object(), (object)null); } return _syncRoot; } } public System.Collections.ICollection Values => new NodeKeyValueCollection(this, isKeys: false); public ListDictionary() { } public ListDictionary(IComparer comparer) { _comparer = comparer; } public void Add(object key, object value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _version++; DictionaryNode dictionaryNode = null; for (DictionaryNode dictionaryNode2 = _head; dictionaryNode2 != null; dictionaryNode2 = dictionaryNode2.next) { object key2 = dictionaryNode2.key; if ((_comparer == null) ? key2.Equals(key) : (_comparer.Compare(key2, key) == 0)) { throw new ArgumentException(System.SR.Format(System.SR.Argument_AddingDuplicate, key)); } dictionaryNode = dictionaryNode2; } DictionaryNode dictionaryNode3 = new DictionaryNode(); dictionaryNode3.key = key; dictionaryNode3.value = value; if (dictionaryNode != null) { dictionaryNode.next = dictionaryNode3; } else { _head = dictionaryNode3; } _count++; } public void Clear() { _count = 0; _head = null; _version++; } public bool Contains(object key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } for (DictionaryNode dictionaryNode = _head; dictionaryNode != null; dictionaryNode = dictionaryNode.next) { object key2 = dictionaryNode.key; if ((_comparer == null) ? key2.Equals(key) : (_comparer.Compare(key2, key) == 0)) { return true; } } return false; } public void CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - index < _count) { throw new ArgumentException(System.SR.Arg_InsufficientSpace); } for (DictionaryNode dictionaryNode = _head; dictionaryNode != null; dictionaryNode = dictionaryNode.next) { array.SetValue((object)new DictionaryEntry(dictionaryNode.key, dictionaryNode.value), index); index++; } } public IDictionaryEnumerator GetEnumerator() { return (IDictionaryEnumerator)(object)new NodeEnumerator(this); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new NodeEnumerator(this); } public void Remove(object key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _version++; DictionaryNode dictionaryNode = null; DictionaryNode dictionaryNode2; for (dictionaryNode2 = _head; dictionaryNode2 != null; dictionaryNode2 = dictionaryNode2.next) { object key2 = dictionaryNode2.key; if ((_comparer == null) ? key2.Equals(key) : (_comparer.Compare(key2, key) == 0)) { break; } dictionaryNode = dictionaryNode2; } if (dictionaryNode2 != null) { if (dictionaryNode2 == _head) { _head = dictionaryNode2.next; } else { dictionaryNode.next = dictionaryNode2.next; } _count--; } } } public abstract class NameObjectCollectionBase : System.Collections.ICollection, System.Collections.IEnumerable { internal class NameObjectEntry { internal string Key; internal object Value; internal NameObjectEntry(string name, object value) { Key = name; Value = value; } } internal class NameObjectKeysEnumerator : System.Collections.IEnumerator { private int _pos; private NameObjectCollectionBase _coll; private int _version; public object Current { get { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (_pos >= 0 && _pos < _coll.Count) { return _coll.BaseGetKey(_pos); } throw new InvalidOperationException(System.SR.InvalidOperation_EnumOpCantHappen); } } internal NameObjectKeysEnumerator(NameObjectCollectionBase coll) { _coll = coll; _version = _coll._version; _pos = -1; } public bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _coll._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } if (_pos < _coll.Count - 1) { _pos++; return true; } _pos = _coll.Count; return false; } public void Reset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _coll._version) { throw new InvalidOperationException(System.SR.InvalidOperation_EnumFailedVersion); } _pos = -1; } } [DefaultMember("Item")] public class KeysCollection : System.Collections.ICollection, System.Collections.IEnumerable { private NameObjectCollectionBase _coll; public string this[int index] => Get(index); public int Count => _coll.Count; object System.Collections.ICollection.SyncRoot => ((System.Collections.ICollection)_coll).SyncRoot; bool System.Collections.ICollection.IsSynchronized => false; internal KeysCollection(NameObjectCollectionBase coll) { _coll = coll; } public virtual string Get(int index) { return _coll.BaseGetKey(index); } public System.Collections.IEnumerator GetEnumerator() { return new NameObjectKeysEnumerator(_coll); } void System.Collections.ICollection.CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(System.SR.Arg_MultiRank, "array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - index < _coll.Count) { throw new ArgumentException(System.SR.Arg_InsufficientSpace); } System.Collections.IEnumerator enumerator = GetEnumerator(); while (enumerator.MoveNext()) { array.SetValue(enumerator.Current, index++); } } } private bool _readOnly; private ArrayList _entriesArray; private IEqualityComparer _keyComparer; private volatile Hashtable _entriesTable; private volatile NameObjectEntry _nullKeyEntry; private KeysCollection _keys; private int _version; private object _syncRoot; private static readonly StringComparer s_defaultComparer = GlobalizationExtensions.GetStringComparer(CultureInfo.InvariantCulture.CompareInfo, (CompareOptions)1); internal IEqualityComparer Comparer { get { return _keyComparer; } set { _keyComparer = value; } } protected bool IsReadOnly { get { return _readOnly; } set { _readOnly = value; } } public virtual int Count => _entriesArray.Count; object System.Collections.ICollection.SyncRoot { get { if (_syncRoot == null) { Interlocked.CompareExchange(ref _syncRoot, new object(), (object)null); } return _syncRoot; } } bool System.Collections.ICollection.IsSynchronized => false; public virtual KeysCollection Keys { get { if (_keys == null) { _keys = new KeysCollection(this); } return _keys; } } protected NameObjectCollectionBase() : this((IEqualityComparer)(object)s_defaultComparer) { } protected NameObjectCollectionBase(IEqualityComparer equalityComparer) { IEqualityComparer keyComparer; if (equalityComparer != null) { keyComparer = equalityComparer; } else { IEqualityComparer val = (IEqualityComparer)(object)s_defaultComparer; keyComparer = val; } _keyComparer = keyComparer; Reset(); } protected NameObjectCollectionBase(int capacity, IEqualityComparer equalityComparer) : this(equalityComparer) { Reset(capacity); } protected NameObjectCollectionBase(int capacity) { _keyComparer = (IEqualityComparer)(object)s_defaultComparer; Reset(capacity); } private void Reset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown _entriesArray = new ArrayList(); _entriesTable = new Hashtable(_keyComparer); _nullKeyEntry = null; _version++; } private void Reset(int capacity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown _entriesArray = new ArrayList(capacity); _entriesTable = new Hashtable(capacity, _keyComparer); _nullKeyEntry = null; _version++; } private NameObjectEntry FindEntry(string key) { if (key != null) { return (NameObjectEntry)_entriesTable[(object)key]; } return _nullKeyEntry; } protected bool BaseHasKeys() { return _entriesTable.Count > 0; } protected void BaseAdd(string name, object value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } NameObjectEntry nameObjectEntry = new NameObjectEntry(name, value); if (name != null) { if (_entriesTable[(object)name] == null) { _entriesTable.Add((object)name, (object)nameObjectEntry); } } else if (_nullKeyEntry == null) { _nullKeyEntry = nameObjectEntry; } _entriesArray.Add((object)nameObjectEntry); _version++; } protected void BaseRemove(string name) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } if (name != null) { _entriesTable.Remove((object)name); for (int num = _entriesArray.Count - 1; num >= 0; num--) { if (_keyComparer.Equals((object)name, (object)BaseGetKey(num))) { _entriesArray.RemoveAt(num); } } } else { _nullKeyEntry = null; for (int num2 = _entriesArray.Count - 1; num2 >= 0; num2--) { if (BaseGetKey(num2) == null) { _entriesArray.RemoveAt(num2); } } } _version++; } protected void BaseRemoveAt(int index) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } string text = BaseGetKey(index); if (text != null) { _entriesTable.Remove((object)text); } else { _nullKeyEntry = null; } _entriesArray.RemoveAt(index); _version++; } protected void BaseClear() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } Reset(); } protected object BaseGet(string name) { return FindEntry(name)?.Value; } protected void BaseSet(string name, object value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } NameObjectEntry nameObjectEntry = FindEntry(name); if (nameObjectEntry != null) { nameObjectEntry.Value = value; _version++; } else { BaseAdd(name, value); } } protected object BaseGet(int index) { NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index]; return nameObjectEntry.Value; } protected string BaseGetKey(int index) { NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index]; return nameObjectEntry.Key; } protected void BaseSet(int index, object value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } NameObjectEntry nameObjectEntry = (NameObjectEntry)_entriesArray[index]; nameObjectEntry.Value = value; _version++; } public virtual System.Collections.IEnumerator GetEnumerator() { return new NameObjectKeysEnumerator(this); } void System.Collections.ICollection.CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(System.SR.Arg_MultiRank, "array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - index < _entriesArray.Count) { throw new ArgumentException(System.SR.Arg_InsufficientSpace); } System.Collections.IEnumerator enumerator = GetEnumerator(); while (enumerator.MoveNext()) { array.SetValue(enumerator.Current, index++); } } protected string[] BaseGetAllKeys() { int count = _entriesArray.Count; string[] array = new string[count]; for (int i = 0; i < count; i++) { array[i] = BaseGetKey(i); } return array; } protected object[] BaseGetAllValues() { int count = _entriesArray.Count; object[] array = new object[count]; for (int i = 0; i < count; i++) { array[i] = BaseGet(i); } return array; } protected object[] BaseGetAllValues(System.Type type) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) int count = _entriesArray.Count; if (type == null) { throw new ArgumentNullException("type"); } object[] array = (object[])System.Array.CreateInstance(type, count); for (int i = 0; i < count; i++) { array[i] = BaseGet(i); } return array; } } [DefaultMember("Item")] public class NameValueCollection : NameObjectCollectionBase { private string[] _all; private string[] _allKeys; public string this[string name] { get { return Get(name); } set { Set(name, value); } } public string this[int index] => Get(index); public virtual string[] AllKeys { get { if (_allKeys == null) { _allKeys = BaseGetAllKeys(); } return _allKeys; } } public NameValueCollection() { } public NameValueCollection(NameValueCollection col) : base(col?.Comparer) { Add(col); } public NameValueCollection(int capacity) : base(capacity) { } public NameValueCollection(IEqualityComparer equalityComparer) : base(equalityComparer) { } public NameValueCollection(int capacity, IEqualityComparer equalityComparer) : base(capacity, equalityComparer) { } public NameValueCollection(int capacity, NameValueCollection col) : base(capacity, col?.Comparer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (col == null) { throw new ArgumentNullException("col"); } base.Comparer = col.Comparer; Add(col); } protected void InvalidateCachedArrays() { _all = null; _allKeys = null; } private static string GetAsOneString(ArrayList list) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown int num = ((list != null) ? list.Count : 0); if (num == 1) { return (string)list[0]; } if (num > 1) { StringBuilder val = new StringBuilder((string)list[0]); for (int i = 1; i < num; i++) { val.Append(','); val.Append((string)list[i]); } return ((object)val).ToString(); } return null; } private static string[] GetAsStringArray(ArrayList list) { int num = ((list != null) ? list.Count : 0); if (num == 0) { return null; } string[] array = new string[num]; list.CopyTo(0, (System.Array)array, 0, num); return array; } public void Add(NameValueCollection c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c"); } InvalidateCachedArrays(); int count = c.Count; for (int i = 0; i < count; i++) { string key = c.GetKey(i); string[] values = c.GetValues(i); if (values != null) { for (int j = 0; j < values.Length; j++) { Add(key, values[j]); } } else { Add(key, null); } } } public virtual void Clear() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (base.IsReadOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } InvalidateCachedArrays(); BaseClear(); } public void CopyTo(System.Array dest, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (dest == null) { throw new ArgumentNullException("dest"); } if (dest.Rank != 1) { throw new ArgumentException(System.SR.Arg_MultiRank, "dest"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } if (dest.Length - index < Count) { throw new ArgumentException(System.SR.Arg_InsufficientSpace); } int count = Count; if (_all == null) { string[] array = new string[count]; for (int i = 0; i < count; i++) { array[i] = Get(i); dest.SetValue((object)array[i], i + index); } _all = array; } else { for (int j = 0; j < count; j++) { dest.SetValue((object)_all[j], j + index); } } } public bool HasKeys() { return InternalHasKeys(); } internal virtual bool InternalHasKeys() { return BaseHasKeys(); } public virtual void Add(string name, string value) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (base.IsReadOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } InvalidateCachedArrays(); ArrayList val = (ArrayList)BaseGet(name); if (val == null) { val = new ArrayList(1); if (value != null) { val.Add((object)value); } BaseAdd(name, val); } else if (value != null) { val.Add((object)value); } } public virtual string Get(string name) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ArrayList list = (ArrayList)BaseGet(name); return GetAsOneString(list); } public virtual string[] GetValues(string name) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ArrayList list = (ArrayList)BaseGet(name); return GetAsStringArray(list); } public virtual void Set(string name, string value) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (base.IsReadOnly) { throw new NotSupportedException(System.SR.CollectionReadOnly); } InvalidateCachedArrays(); ArrayList val = new ArrayList(1); val.Add((object)value); BaseSet(name, val); } public virtual void Remove(string name) { InvalidateCachedArrays(); BaseRemove(name); } public virtual string Get(int index) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ArrayList list = (ArrayList)BaseGet(index); return GetAsOneString(list); } public virtual string[] GetValues(int index) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown ArrayList list = (ArrayList)BaseGet(index); return GetAsStringArray(list); } public virtual string GetKey(int index) { return BaseGetKey(index); } } [DefaultMember("Item")] public class OrderedDictionary : IOrderedDictionary, IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { private class OrderedDictionaryEnumerator : IDictionaryEnumerator, System.Collections.IEnumerator { private int _objectReturnType; internal const int Keys = 1; internal const int Values = 2; internal const int DictionaryEntry = 3; private System.Collections.IEnumerator _arrayEnumerator; public object Current { get { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) DictionaryEntry val; if (_objectReturnType == 1) { val = (DictionaryEntry)_arrayEnumerator.Current; return ((DictionaryEntry)(ref val)).Key; } if (_objectReturnType == 2) { val = (DictionaryEntry)_arrayEnumerator.Current; return ((DictionaryEntry)(ref val)).Value; } return Entry; } } public DictionaryEntry Entry { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) DictionaryEntry val = (DictionaryEntry)_arrayEnumerator.Current; object key = ((DictionaryEntry)(ref val)).Key; val = (DictionaryEntry)_arrayEnumerator.Current; return new DictionaryEntry(key, ((DictionaryEntry)(ref val)).Value); } } public object Key { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) DictionaryEntry val = (DictionaryEntry)_arrayEnumerator.Current; return ((DictionaryEntry)(ref val)).Key; } } public object Value { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) DictionaryEntry val = (DictionaryEntry)_arrayEnumerator.Current; return ((DictionaryEntry)(ref val)).Value; } } internal OrderedDictionaryEnumerator(ArrayList array, int objectReturnType) { _arrayEnumerator = array.GetEnumerator(); _objectReturnType = objectReturnType; } public bool MoveNext() { return _arrayEnumerator.MoveNext(); } public void Reset() { _arrayEnumerator.Reset(); } } private class OrderedDictionaryKeyValueCollection : System.Collections.ICollection, System.Collections.IEnumerable { private ArrayList _objects; private bool _isKeys; int System.Collections.ICollection.Count => _objects.Count; bool System.Collections.ICollection.IsSynchronized => false; object System.Collections.ICollection.SyncRoot => _objects.SyncRoot; public OrderedDictionaryKeyValueCollection(ArrayList array, bool isKeys) { _objects = array; _isKeys = isKeys; } void System.Collections.ICollection.CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", (object)index, System.SR.ArgumentOutOfRange_NeedNonNegNum); } foreach (object @object in _objects) { DictionaryEntry val; object obj; if (!_isKeys) { val = (DictionaryEntry)@object; obj = ((DictionaryEntry)(ref val)).Value; } else { val = (DictionaryEntry)@object; obj = ((DictionaryEntry)(ref val)).Key; } array.SetValue(obj, index); index++; } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new OrderedDictionaryEnumerator(_objects, _isKeys ? 1 : 2); } } private ArrayList _objectsArray; private Hashtable _objectsTable; private readonly int _initialCapacity; private readonly IEqualityComparer _comparer; private readonly bool _readOnly; private object _syncRoot; public int Count => objectsArray.Count; bool IDictionary.IsFixedSize => _readOnly; public bool IsReadOnly => _readOnly; bool System.Collections.ICollection.IsSynchronized => false; public System.Collections.ICollection Keys => new OrderedDictionaryKeyValueCollection(objectsArray, isKeys: true); private ArrayList objectsArray { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown if (_objectsArray == null) { _objectsArray = new ArrayList(_initialCapacity); } return _objectsArray; } } private Hashtable objectsTable { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (_objectsTable == null) { _objectsTable = new Hashtable(_initialCapacity, _comparer); } return _objectsTable; } } object System.Collections.ICollection.SyncRoot { get { if (_syncRoot == null) { Interlocked.CompareExchange(ref _syncRoot, new object(), (object)null); } return _syncRoot; } } public object this[int index] { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) DictionaryEntry val = (DictionaryEntry)objectsArray[index]; return ((DictionaryEntry)(ref val)).Value; } set { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } if (index < 0 || index >= objectsArray.Count) { throw new ArgumentOutOfRangeException("index"); } DictionaryEntry val = (DictionaryEntry)objectsArray[index]; object key = ((DictionaryEntry)(ref val)).Key; objectsArray[index] = (object)new DictionaryEntry(key, value); objectsTable[key] = value; } } public object this[object key] { get { return objectsTable[key]; } set { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } if (objectsTable.Contains(key)) { objectsTable[key] = value; objectsArray[IndexOfKey(key)] = (object)new DictionaryEntry(key, value); } else { Add(key, value); } } } public System.Collections.ICollection Values => new OrderedDictionaryKeyValueCollection(objectsArray, isKeys: false); public OrderedDictionary() : this(0) { } public OrderedDictionary(int capacity) : this(capacity, null) { } public OrderedDictionary(IEqualityComparer comparer) : this(0, comparer) { } public OrderedDictionary(int capacity, IEqualityComparer comparer) { _initialCapacity = capacity; _comparer = comparer; } private OrderedDictionary(OrderedDictionary dictionary) { _readOnly = true; _objectsArray = dictionary._objectsArray; _objectsTable = dictionary._objectsTable; _comparer = dictionary._comparer; _initialCapacity = dictionary._initialCapacity; } public void Add(object key, object value) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } objectsTable.Add(key, value); objectsArray.Add((object)new DictionaryEntry(key, value)); } public void Clear() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } objectsTable.Clear(); objectsArray.Clear(); } public OrderedDictionary AsReadOnly() { return new OrderedDictionary(this); } public bool Contains(object key) { return objectsTable.Contains(key); } public void CopyTo(System.Array array, int index) { objectsTable.CopyTo(array, index); } private int IndexOfKey(object key) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < objectsArray.Count; i++) { DictionaryEntry val = (DictionaryEntry)objectsArray[i]; object key2 = ((DictionaryEntry)(ref val)).Key; if (_comparer != null) { if (_comparer.Equals(key2, key)) { return i; } } else if (key2.Equals(key)) { return i; } } return -1; } public void Insert(int index, object key, object value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } if (index > Count || index < 0) { throw new ArgumentOutOfRangeException("index"); } objectsTable.Add(key, value); objectsArray.Insert(index, (object)new DictionaryEntry(key, value)); } public void RemoveAt(int index) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } if (index >= Count || index < 0) { throw new ArgumentOutOfRangeException("index"); } DictionaryEntry val = (DictionaryEntry)objectsArray[index]; object key = ((DictionaryEntry)(ref val)).Key; objectsArray.RemoveAt(index); objectsTable.Remove(key); } public void Remove(object key) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (_readOnly) { throw new NotSupportedException(System.SR.OrderedDictionary_ReadOnly); } if (key == null) { throw new ArgumentNullException("key"); } int num = IndexOfKey(key); if (num >= 0) { objectsTable.Remove(key); objectsArray.RemoveAt(num); } } public virtual IDictionaryEnumerator GetEnumerator() { return (IDictionaryEnumerator)(object)new OrderedDictionaryEnumerator(objectsArray, 3); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new OrderedDictionaryEnumerator(objectsArray, 3); } } [DefaultMember("Item")] public class StringCollection : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { private readonly ArrayList _data = new ArrayList(); public string this[int index] { get { return (string)_data[index]; } set { _data[index] = value; } } public int Count => _data.Count; bool System.Collections.IList.IsReadOnly => false; bool System.Collections.IList.IsFixedSize => false; public bool IsReadOnly => false; public bool IsSynchronized => false; public object SyncRoot => _data.SyncRoot; object System.Collections.IList.this[int index] { get { return this[index]; } set { this[index] = (string)value; } } public int Add(string value) { return _data.Add((object)value); } public void AddRange(string[] value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (value == null) { throw new ArgumentNullException("value"); } _data.AddRange((System.Collections.ICollection)(object)value); } public void Clear() { _data.Clear(); } public bool Contains(string value) { return _data.Contains((object)value); } public void CopyTo(string[] array, int index) { _data.CopyTo((System.Array)array, index); } public StringEnumerator GetEnumerator() { return new StringEnumerator(this); } public int IndexOf(string value) { return _data.IndexOf((object)value); } public void Insert(int index, string value) { _data.Insert(index, (object)value); } public void Remove(string value) { _data.Remove((object)value); } public void RemoveAt(int index) { _data.RemoveAt(index); } int System.Collections.IList.Add(object value) { return Add((string)value); } bool System.Collections.IList.Contains(object value) { return Contains((string)value); } int System.Collections.IList.IndexOf(object value) { return IndexOf((string)value); } void System.Collections.IList.Insert(int index, object value) { Insert(index, (string)value); } void System.Collections.IList.Remove(object value) { Remove((string)value); } void System.Collections.ICollection.CopyTo(System.Array array, int index) { _data.CopyTo(array, index); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return _data.GetEnumerator(); } } public class StringEnumerator { private System.Collections.IEnumerator _baseEnumerator; private System.Collections.IEnumerable _temp; public string Current => (string)_baseEnumerator.Current; internal StringEnumerator(StringCollection mappings) { _temp = mappings; _baseEnumerator = _temp.GetEnumerator(); } public bool MoveNext() { return _baseEnumerator.MoveNext(); } public void Reset() { _baseEnumerator.Reset(); } } [DefaultMember("Item")] public class StringDictionary : System.Collections.IEnumerable { private readonly Hashtable _contents = new Hashtable(); public virtual int Count => _contents.Count; public virtual bool IsSynchronized => _contents.IsSynchronized; public virtual string this[string key] { get { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } return (string)_contents[(object)key.ToLowerInvariant()]; } set { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _contents[(object)key.ToLowerInvariant()] = value; } } public virtual System.Collections.ICollection Keys => _contents.Keys; public virtual object SyncRoot => _contents.SyncRoot; public virtual System.Collections.ICollection Values => _contents.Values; public virtual void Add(string key, string value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _contents.Add((object)key.ToLowerInvariant(), (object)value); } public virtual void Clear() { _contents.Clear(); } public virtual bool ContainsKey(string key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } return _contents.ContainsKey((object)key.ToLowerInvariant()); } public virtual bool ContainsValue(string value) { return _contents.ContainsValue((object)value); } public virtual void CopyTo(System.Array array, int index) { _contents.CopyTo(array, index); } public virtual System.Collections.IEnumerator GetEnumerator() { return (System.Collections.IEnumerator)_contents.GetEnumerator(); } public virtual void Remove(string key) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key"); } _contents.Remove((object)key.ToLowerInvariant()); } } }
BepInEx/plugins/DearImGuiInjection/SharpDX.DXGI.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Mathematics.Interop; using SharpDX.Win32; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("SharpDX.Direct3D10")] [assembly: InternalsVisibleTo("SharpDX.Direct3D11")] [assembly: InternalsVisibleTo("SharpDX.Direct2D1")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("4.2.1.34")] [assembly: AssemblyInformationalVersion("4.2.1-beta0+7abb72df54")] [assembly: AssemblyCompany("Alexandre Mutel")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2010-2016 Alexandre Mutel")] [assembly: AssemblyDescription("Assembly providing DirectX - DXGI managed API.")] [assembly: AssemblyProduct("SharpDX.DXGI")] [assembly: AssemblyTitle("SharpDX.DXGI")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xiaoxiao921/SharpDX")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.2.0.0")] [module: UnverifiableCode] internal class <Module> { static <Module>() { ModuleInit.Setup(); } } internal sealed class ThisAssembly { internal const string AssemblyVersion = "4.2.0.0"; internal const string AssemblyFileVersion = "4.2.1.34"; internal const string AssemblyInformationalVersion = "4.2.1-beta0+7abb72df54"; internal const string AssemblyName = "SharpDX.DXGI"; internal const string AssemblyTitle = "SharpDX.DXGI"; internal const string AssemblyConfiguration = "Release"; internal const string GitCommitId = "7abb72df544eaede656c546ee71a8ad1be9dd19b"; internal const string RootNamespace = "SharpDX.DXGI"; private ThisAssembly() { } } namespace SharpDX.DXGI; [Guid("2411e7e1-12ac-4ccf-bd14-9798e8534dc0")] public class Adapter : DXGIObject { public Output[] Outputs { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) List<Output> list = new List<Output>(); Output outputOut; while (!(GetOutput(list.Count, out outputOut) == ResultDescriptor.op_Implicit(ResultCode.NotFound)) && outputOut != null) { list.Add(outputOut); } return list.ToArray(); } } public AdapterDescription Description { get { GetDescription(out var descRef); return descRef; } } public bool IsInterfaceSupported(Type type) { long userModeVersion; return IsInterfaceSupported(type, out userModeVersion); } public bool IsInterfaceSupported<T>() where T : ComObject { long userModeVersion; return IsInterfaceSupported(typeof(T), out userModeVersion); } public bool IsInterfaceSupported<T>(out long userModeVersion) where T : ComObject { return IsInterfaceSupported(typeof(T), out userModeVersion); } public bool IsInterfaceSupported(Type type, out long userModeVersion) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Result val = CheckInterfaceSupport(Utilities.GetGuidFromType(type), out userModeVersion); return ((Result)(ref val)).Success; } public Output GetOutput(int outputIndex) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Output outputOut; Result output = GetOutput(outputIndex, out outputOut); ((Result)(ref output)).CheckError(); return outputOut; } public int GetOutputCount() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) int i; Output outputOut; for (i = 0; !(GetOutput(i, out outputOut) == ResultDescriptor.op_Implicit(ResultCode.NotFound)); i++) { if (outputOut == null) { break; } ((DisposeBase)outputOut).Dispose(); } return i; } public Adapter(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Adapter(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Adapter(nativePtr); } return null; } internal unsafe Result GetOutput(int output, out Output outputOut) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, output, &zero)); if (zero != IntPtr.Zero) { outputOut = new Output(zero); return result; } outputOut = null; return result; } internal unsafe void GetDescription(out AdapterDescription descRef) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) AdapterDescription.__Native @ref = default(AdapterDescription.__Native); descRef = default(AdapterDescription); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref)); descRef.__MarshalFrom(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe Result CheckInterfaceSupport(Guid interfaceName, out long uMDVersionRef) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) Result result; fixed (long* ptr = &uMDVersionRef) { void* ptr2 = ptr; result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &interfaceName, ptr2)); } return result; } } [CompilerGenerated] internal class AssemblyDoc { } public static class DebugId { public static readonly Guid All = new Guid("e48ae283-da80-490b-87e6-43e9a9cfda08"); public static readonly Guid App = new Guid("06cd6e01-4219-4ebd-8709-27ed23360c62"); public static readonly Guid Dx = new Guid("35cdd7fc-13b2-421d-a5d7-7e4451287d64"); public static readonly Guid Dxgi = new Guid("25cddaa4-b1c6-47e1-ac3e-98875b5a2e2a"); } internal static class DebugInterface { [UnmanagedFunctionPointer(CallingConvention.Winapi)] private delegate Result GetDebugInterface(ref Guid guid, out IntPtr result); private static readonly GetDebugInterface getDebugInterface; static DebugInterface() { getDebugInterface = null; } public static bool TryCreateComPtr<T>(out IntPtr comPtr) where T : class { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) comPtr = IntPtr.Zero; if (getDebugInterface == null) { return false; } Guid guid = typeof(T).GetTypeInfo().GUID; Result val = getDebugInterface(ref guid, out comPtr); if (((Result)(ref val)).Failure) { return false; } return comPtr != IntPtr.Zero; } } [Guid("54ec77fa-1377-44e6-8c32-88fd5f44c84c")] public class Device : DXGIObject { public Adapter Adapter { get { GetAdapter(out var adapterRef); return adapterRef; } } public int GPUThreadPriority { get { GetGPUThreadPriority(out var priorityRef); return priorityRef; } set { SetGPUThreadPriority(value); } } public Residency[] QueryResourceResidency(params ComObject[] comObjects) { int num = comObjects.Length; Residency[] array = new Residency[num]; QueryResourceResidency((IUnknown[])(object)comObjects, array, num); return array; } public Device(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device(nativePtr); } return null; } internal unsafe void GetAdapter(out Adapter adapterRef) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero)); if (zero != IntPtr.Zero) { adapterRef = new Adapter(zero); } else { adapterRef = null; } ((Result)(ref val)).CheckError(); } internal unsafe void CreateSurface(ref SurfaceDescription descRef, int numSurfaces, int usage, SharedResource? sharedResourceRef, out Surface surfaceOut) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; SharedResource value = default(SharedResource); if (sharedResourceRef.HasValue) { value = sharedResourceRef.Value; } Result val; fixed (SurfaceDescription* ptr = &descRef) { void* ptr2 = ptr; void* nativePointer = ((CppObject)this)._nativePointer; SharedResource* intPtr = ((!sharedResourceRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(nativePointer, ptr2, numSurfaces, usage, intPtr, &zero)); } if (zero != IntPtr.Zero) { surfaceOut = new Surface(zero); } else { surfaceOut = null; } ((Result)(ref val)).CheckError(); } internal unsafe void QueryResourceResidency(IUnknown[] resourcesOut, Residency[] residencyStatusRef, int numResources) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) IntPtr* ptr = null; if (resourcesOut != null) { ptr = stackalloc IntPtr[resourcesOut.Length]; } if (resourcesOut != null) { for (int i = 0; i < resourcesOut.Length; i++) { ptr[i] = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)resourcesOut[i]); } } Result val; fixed (Residency* ptr2 = residencyStatusRef) { void* ptr3 = ptr2; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr, ptr3, numResources)); } ((Result)(ref val)).CheckError(); } internal unsafe void SetGPUThreadPriority(int priority) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, priority)); ((Result)(ref val)).CheckError(); } internal unsafe void GetGPUThreadPriority(out int priorityRef) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &priorityRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } } [Guid("3d3e0379-f9de-4d58-bb6c-18d62992f1a6")] public class DeviceChild : DXGIObject { public unsafe string DebugName { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) byte* ptr = stackalloc byte[1024]; int dataSizeRef = 1023; Result privateData = GetPrivateData(CommonGuid.DebugObjectName, ref dataSizeRef, new IntPtr(ptr)); if (((Result)(ref privateData)).Failure) { return string.Empty; } ptr[dataSizeRef] = 0; return Marshal.PtrToStringAnsi(new IntPtr(ptr)); } set { if (string.IsNullOrEmpty(value)) { SetPrivateData(CommonGuid.DebugObjectName, 0, IntPtr.Zero); return; } IntPtr dataRef = Utilities.StringToHGlobalAnsi(value); SetPrivateData(CommonGuid.DebugObjectName, value.Length, dataRef); } } public T GetDevice<T>() where T : ComObject { GetDevice(Utilities.GetGuidFromType(typeof(T)), out var deviceOut); return CppObject.FromPointer<T>(deviceOut); } public DeviceChild(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DeviceChild(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DeviceChild(nativePtr); } return null; } public unsafe void GetDevice(Guid riid, out IntPtr deviceOut) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &deviceOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } } [Guid("119E7452-DE9E-40fe-8806-88F90C12B441")] public class DXGIDebug : ComObject { public static DXGIDebug TryCreate() { if (!DebugInterface.TryCreateComPtr<DXGIDebug>(out var comPtr)) { return null; } return new DXGIDebug(comPtr); } public DXGIDebug(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DXGIDebug(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DXGIDebug(nativePtr); } return null; } public unsafe void ReportLiveObjects(Guid apiid, DebugRloFlags flags) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, apiid, (int)flags)); ((Result)(ref val)).CheckError(); } } [Guid("c5a05f0c-16f2-4adf-9f4d-a8c4d58ac550")] public class DXGIDebug1 : DXGIDebug { public RawBool IsLeakTrackingEnabledForThread => IsLeakTrackingEnabledForThread_(); public new static DXGIDebug1 TryCreate() { if (!DebugInterface.TryCreateComPtr<DXGIDebug1>(out var comPtr)) { return null; } return new DXGIDebug1(comPtr); } public DXGIDebug1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DXGIDebug1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DXGIDebug1(nativePtr); } return null; } public unsafe void EnableLeakTrackingForThread() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)4 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } public unsafe void DisableLeakTrackingForThread() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)5 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } internal unsafe RawBool IsLeakTrackingEnabledForThread_() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)6 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } } [Guid("aec22fb8-76f3-4639-9be0-28eb43a67a2e")] public class DXGIObject : ComObject { public T GetParent<T>() where T : ComObject { GetParent(Utilities.GetGuidFromType(typeof(T)), out var parentOut); return CppObject.FromPointer<T>(parentOut); } public DXGIObject(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DXGIObject(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DXGIObject(nativePtr); } return null; } public unsafe void SetPrivateData(Guid name, int dataSize, IntPtr dataRef) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &name, dataSize, (void*)dataRef)); ((Result)(ref val)).CheckError(); } public unsafe void SetPrivateDataInterface(Guid name, IUnknown unknownRef) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)unknownRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)4 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &name, (void*)zero)); ((Result)(ref val)).CheckError(); } public unsafe Result GetPrivateData(Guid name, ref int dataSizeRef, IntPtr dataRef) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) Result result; fixed (int* ptr = &dataSizeRef) { void* ptr2 = ptr; result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)5 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &name, ptr2, (void*)dataRef)); } return result; } public unsafe void GetParent(Guid riid, out IntPtr parentOut) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &parentOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)6 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } } [Guid("7b7166ec-21c7-44ae-b21a-c9ae321ae369")] public class Factory : DXGIObject { public Adapter[] Adapters { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) List<Adapter> list = new List<Adapter>(); Adapter adapterOut; while (!(GetAdapter(list.Count, out adapterOut) == ResultDescriptor.op_Implicit(ResultCode.NotFound))) { list.Add(adapterOut); } return list.ToArray(); } } public Adapter GetAdapter(int index) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Adapter adapterOut; Result adapter = GetAdapter(index, out adapterOut); ((Result)(ref adapter)).CheckError(); return adapterOut; } public int GetAdapterCount() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) int num = 0; while (true) { Adapter adapterOut; Result adapter = GetAdapter(num, out adapterOut); if (adapterOut != null) { ((DisposeBase)adapterOut).Dispose(); } if (adapter == ResultDescriptor.op_Implicit(ResultCode.NotFound)) { break; } num++; } return num; } public Factory(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Factory(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Factory(nativePtr); } return null; } internal unsafe Result GetAdapter(int adapter, out Adapter adapterOut) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, adapter, &zero)); if (zero != IntPtr.Zero) { adapterOut = new Adapter(zero); return result; } adapterOut = null; return result; } public unsafe void MakeWindowAssociation(IntPtr windowHandle, WindowAssociationFlags flags) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)windowHandle, (int)flags)); ((Result)(ref val)).CheckError(); } public unsafe IntPtr GetWindowAssociation() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) IntPtr result = default(IntPtr); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result)); ((Result)(ref val)).CheckError(); return result; } internal unsafe void CreateSwapChain(IUnknown deviceRef, ref SwapChainDescription descRef, SwapChain swapChainOut) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); Result val; fixed (SwapChainDescription* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, ptr2, &zero2)); } ((CppObject)swapChainOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } public unsafe Adapter CreateSoftwareAdapter(IntPtr module) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)module, &zero)); Adapter result = ((!(zero != IntPtr.Zero)) ? null : new Adapter(zero)); ((Result)(ref val)).CheckError(); return result; } } [Guid("770aae78-f26f-4dba-a829-253c83d1b387")] public class Factory1 : Factory { public Adapter1[] Adapters1 { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) List<Adapter1> list = new List<Adapter1>(); Adapter1 adapterOut; while (!(GetAdapter1(list.Count, out adapterOut) == ResultDescriptor.op_Implicit(ResultCode.NotFound))) { list.Add(adapterOut); } return list.ToArray(); } } public RawBool IsCurrent => IsCurrent_(); public Factory1() : base(IntPtr.Zero) { DXGI.CreateDXGIFactory1(Utilities.GetGuidFromType(((object)this).GetType()), out var factoryOut); ((CppObject)this).NativePointer = factoryOut; } public Adapter1 GetAdapter1(int index) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Adapter1 adapterOut; Result adapter = GetAdapter1(index, out adapterOut); ((Result)(ref adapter)).CheckError(); return adapterOut; } public int GetAdapterCount1() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) int num = 0; while (true) { Adapter1 adapterOut; Result adapter = GetAdapter1(num, out adapterOut); if (adapterOut != null) { ((DisposeBase)adapterOut).Dispose(); } if (adapter == ResultDescriptor.op_Implicit(ResultCode.NotFound)) { break; } num++; } return num; } public Factory1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Factory1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Factory1(nativePtr); } return null; } internal unsafe Result GetAdapter1(int adapter, out Adapter1 adapterOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, adapter, &zero)); if (zero != IntPtr.Zero) { adapterOut = new Adapter1(zero); return result; } adapterOut = null; return result; } internal unsafe RawBool IsCurrent_() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } } [Guid("50c83a1c-e072-4c48-87b0-3630fa36a6d0")] public class Factory2 : Factory1 { public RawBool IsWindowedStereoEnabled => IsWindowedStereoEnabled_(); public Factory2(bool debug = false) : this(IntPtr.Zero) { DXGI.CreateDXGIFactory2(debug ? 1 : 0, Utilities.GetGuidFromType(((object)this).GetType()), out var factoryOut); ((CppObject)this).NativePointer = factoryOut; } public Factory2(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Factory2(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Factory2(nativePtr); } return null; } internal unsafe RawBool IsWindowedStereoEnabled_() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } internal unsafe void CreateSwapChainForHwnd(IUnknown deviceRef, IntPtr hWnd, ref SwapChainDescription1 descRef, SwapChainFullScreenDescription? fullscreenDescRef, Output restrictToOutputRef, SwapChain1 swapChainOut) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; IntPtr zero3 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); SwapChainFullScreenDescription value = default(SwapChainFullScreenDescription); if (fullscreenDescRef.HasValue) { value = fullscreenDescRef.Value; } zero2 = CppObject.ToCallbackPtr<Output>((ICallbackable)(object)restrictToOutputRef); Result val; fixed (SwapChainDescription1* ptr = &descRef) { void* ptr2 = ptr; void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; void* intPtr2 = (void*)hWnd; SwapChainFullScreenDescription* intPtr3 = ((!fullscreenDescRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, ptr2, intPtr3, (void*)zero2, &zero3)); } ((CppObject)swapChainOut).NativePointer = zero3; ((Result)(ref val)).CheckError(); } internal unsafe void CreateSwapChainForCoreWindow(IUnknown deviceRef, IUnknown windowRef, ref SwapChainDescription1 descRef, Output restrictToOutputRef, SwapChain1 swapChainOut) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; IntPtr zero3 = IntPtr.Zero; IntPtr zero4 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); zero2 = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)windowRef); zero3 = CppObject.ToCallbackPtr<Output>((ICallbackable)(object)restrictToOutputRef); Result val; fixed (SwapChainDescription1* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, (void*)zero2, ptr2, (void*)zero3, &zero4)); } ((CppObject)swapChainOut).NativePointer = zero4; ((Result)(ref val)).CheckError(); } public unsafe void GetSharedResourceAdapterLuid(IntPtr hResource, out long luidRef) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (long* ptr = &luidRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)hResource, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void RegisterStereoStatusWindow(IntPtr windowHandle, int wMsg, out int dwCookieRef) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &dwCookieRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)windowHandle, wMsg, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void RegisterStereoStatusEvent(IntPtr hEvent, out int dwCookieRef) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &dwCookieRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)hEvent, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void UnregisterStereoStatus(int dwCookie) { ((delegate* unmanaged[Stdcall]<void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, dwCookie); } public unsafe void RegisterOcclusionStatusWindow(IntPtr windowHandle, int wMsg, out int dwCookieRef) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &dwCookieRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)windowHandle, wMsg, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void RegisterOcclusionStatusEvent(IntPtr hEvent, out int dwCookieRef) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &dwCookieRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)hEvent, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void UnregisterOcclusionStatus(int dwCookie) { ((delegate* unmanaged[Stdcall]<void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, dwCookie); } internal unsafe void CreateSwapChainForComposition(IUnknown deviceRef, ref SwapChainDescription1 descRef, Output restrictToOutputRef, SwapChain1 swapChainOut) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; IntPtr zero3 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); zero2 = CppObject.ToCallbackPtr<Output>((ICallbackable)(object)restrictToOutputRef); Result val; fixed (SwapChainDescription1* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)24 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, ptr2, (void*)zero2, &zero3)); } ((CppObject)swapChainOut).NativePointer = zero3; ((Result)(ref val)).CheckError(); } } [Guid("1bc6ea02-ef36-464f-bf0c-21ca39e5168a")] public class Factory4 : Factory3 { public Factory4() : this(IntPtr.Zero) { DXGI.CreateDXGIFactory1(Utilities.GetGuidFromType(((object)this).GetType()), out var factoryOut); ((CppObject)this).NativePointer = factoryOut; } public Factory4(bool debug = false) : this(IntPtr.Zero) { DXGI.CreateDXGIFactory2(debug ? 1 : 0, Utilities.GetGuidFromType(typeof(Factory4)), out var factoryOut); ((CppObject)this).NativePointer = factoryOut; } public Adapter GetWarpAdapter() { EnumWarpAdapter(Utilities.GetGuidFromType(typeof(Adapter)), out var vAdapterOut); return new Adapter(vAdapterOut); } public Adapter GetAdapterByLuid(long adapterLuid) { EnumAdapterByLuid(adapterLuid, Utilities.GetGuidFromType(typeof(Adapter)), out var vAdapterOut); return new Adapter(vAdapterOut); } public Factory4(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Factory4(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Factory4(nativePtr); } return null; } private unsafe void EnumAdapterByLuid(long adapterLuid, Guid riid, out IntPtr vAdapterOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &vAdapterOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, long, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)26 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, adapterLuid, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } private unsafe void EnumWarpAdapter(Guid riid, out IntPtr vAdapterOut) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &vAdapterOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)27 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } } [Guid("7632e1f5-ee65-4dca-87fd-84cd75f8838d")] public class Factory5 : Factory4 { public unsafe bool PresentAllowTearing { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) RawBool val = default(RawBool); CheckFeatureSupport(Feature.PresentAllowTearing, new IntPtr(&val), Unsafe.SizeOf<RawBool>()); return RawBool.op_Implicit(val); } } public Factory5(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Factory5(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Factory5(nativePtr); } return null; } public unsafe void CheckFeatureSupport(Feature feature, IntPtr featureSupportDataRef, int featureSupportDataSize) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)28 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)feature, (void*)featureSupportDataRef, featureSupportDataSize)); ((Result)(ref val)).CheckError(); } } public static class FormatHelper { private static readonly int[] sizeOfInBits; private static readonly bool[] compressedFormats; private static readonly bool[] srgbFormats; private static readonly bool[] typelessFormats; public static int SizeOfInBytes(this Format format) { return format.SizeOfInBits() >> 3; } public static int SizeOfInBits(this Format format) { return sizeOfInBits[(int)format]; } public static bool IsValid(this Format format) { if (format >= Format.R32G32B32A32_Typeless) { return format <= Format.B4G4R4A4_UNorm; } return false; } public static bool IsCompressed(this Format format) { return compressedFormats[(int)format]; } public static bool IsPacked(this Format format) { if (format != Format.R8G8_B8G8_UNorm) { return format == Format.G8R8_G8B8_UNorm; } return true; } public static bool IsVideo(this Format format) { switch (format) { case Format.AYUV: case Format.Y410: case Format.Y416: case Format.NV12: case Format.P010: case Format.P016: case Format.YUY2: case Format.Y210: case Format.Y216: case Format.NV11: return true; case Format.Opaque420: case Format.AI44: case Format.IA44: case Format.P8: case Format.A8P8: return true; default: return false; } } public static bool IsSRgb(this Format format) { return srgbFormats[(int)format]; } public static bool IsTypeless(this Format format) { return typelessFormats[(int)format]; } public static int ComputeScanlineCount(this Format format, int height) { if ((uint)(format - 70) <= 14u || (uint)(format - 94) <= 5u) { return Math.Max(1, (height + 3) / 4); } return height; } static FormatHelper() { sizeOfInBits = new int[256]; compressedFormats = new bool[256]; srgbFormats = new bool[256]; typelessFormats = new bool[256]; InitFormat(new Format[1] { Format.R1_UNorm }, 1); InitFormat(new Format[6] { Format.A8_UNorm, Format.R8_SInt, Format.R8_SNorm, Format.R8_Typeless, Format.R8_UInt, Format.R8_UNorm }, 8); InitFormat(new Format[15] { Format.B5G5R5A1_UNorm, Format.B5G6R5_UNorm, Format.D16_UNorm, Format.R16_Float, Format.R16_SInt, Format.R16_SNorm, Format.R16_Typeless, Format.R16_UInt, Format.R16_UNorm, Format.R8G8_SInt, Format.R8G8_SNorm, Format.R8G8_Typeless, Format.R8G8_UInt, Format.R8G8_UNorm, Format.B4G4R4A4_UNorm }, 16); InitFormat(new Format[38] { Format.B8G8R8X8_Typeless, Format.B8G8R8X8_UNorm, Format.B8G8R8X8_UNorm_SRgb, Format.D24_UNorm_S8_UInt, Format.D32_Float, Format.D32_Float_S8X24_UInt, Format.G8R8_G8B8_UNorm, Format.R10G10B10_Xr_Bias_A2_UNorm, Format.R10G10B10A2_Typeless, Format.R10G10B10A2_UInt, Format.R10G10B10A2_UNorm, Format.R11G11B10_Float, Format.R16G16_Float, Format.R16G16_SInt, Format.R16G16_SNorm, Format.R16G16_Typeless, Format.R16G16_UInt, Format.R16G16_UNorm, Format.R24_UNorm_X8_Typeless, Format.R24G8_Typeless, Format.R32_Float, Format.R32_Float_X8X24_Typeless, Format.R32_SInt, Format.R32_Typeless, Format.R32_UInt, Format.R8G8_B8G8_UNorm, Format.R8G8B8A8_SInt, Format.R8G8B8A8_SNorm, Format.R8G8B8A8_Typeless, Format.R8G8B8A8_UInt, Format.R8G8B8A8_UNorm, Format.R8G8B8A8_UNorm_SRgb, Format.B8G8R8A8_Typeless, Format.B8G8R8A8_UNorm, Format.B8G8R8A8_UNorm_SRgb, Format.R9G9B9E5_Sharedexp, Format.X24_Typeless_G8_UInt, Format.X32_Typeless_G8X24_UInt }, 32); InitFormat(new Format[11] { Format.R16G16B16A16_Float, Format.R16G16B16A16_SInt, Format.R16G16B16A16_SNorm, Format.R16G16B16A16_Typeless, Format.R16G16B16A16_UInt, Format.R16G16B16A16_UNorm, Format.R32G32_Float, Format.R32G32_SInt, Format.R32G32_Typeless, Format.R32G32_UInt, Format.R32G8X24_Typeless }, 64); InitFormat(new Format[4] { Format.R32G32B32_Float, Format.R32G32B32_SInt, Format.R32G32B32_Typeless, Format.R32G32B32_UInt }, 96); InitFormat(new Format[4] { Format.R32G32B32A32_Float, Format.R32G32B32A32_SInt, Format.R32G32B32A32_Typeless, Format.R32G32B32A32_UInt }, 128); InitFormat(new Format[6] { Format.BC1_Typeless, Format.BC1_UNorm, Format.BC1_UNorm_SRgb, Format.BC4_SNorm, Format.BC4_Typeless, Format.BC4_UNorm }, 4); InitFormat(new Format[15] { Format.BC2_Typeless, Format.BC2_UNorm, Format.BC2_UNorm_SRgb, Format.BC3_Typeless, Format.BC3_UNorm, Format.BC3_UNorm_SRgb, Format.BC5_SNorm, Format.BC5_Typeless, Format.BC5_UNorm, Format.BC6H_Sf16, Format.BC6H_Typeless, Format.BC6H_Uf16, Format.BC7_Typeless, Format.BC7_UNorm, Format.BC7_UNorm_SRgb }, 8); InitDefaults(new Format[21] { Format.BC1_Typeless, Format.BC1_UNorm, Format.BC1_UNorm_SRgb, Format.BC2_Typeless, Format.BC2_UNorm, Format.BC2_UNorm_SRgb, Format.BC3_Typeless, Format.BC3_UNorm, Format.BC3_UNorm_SRgb, Format.BC4_Typeless, Format.BC4_UNorm, Format.BC4_SNorm, Format.BC5_Typeless, Format.BC5_UNorm, Format.BC5_SNorm, Format.BC6H_Typeless, Format.BC6H_Uf16, Format.BC6H_Sf16, Format.BC7_Typeless, Format.BC7_UNorm, Format.BC7_UNorm_SRgb }, compressedFormats); InitDefaults(new Format[7] { Format.R8G8B8A8_UNorm_SRgb, Format.BC1_UNorm_SRgb, Format.BC2_UNorm_SRgb, Format.BC3_UNorm_SRgb, Format.B8G8R8A8_UNorm_SRgb, Format.B8G8R8X8_UNorm_SRgb, Format.BC7_UNorm_SRgb }, srgbFormats); InitDefaults(new Format[22] { Format.R32G32B32A32_Typeless, Format.R32G32B32_Typeless, Format.R16G16B16A16_Typeless, Format.R32G32_Typeless, Format.R32G8X24_Typeless, Format.R10G10B10A2_Typeless, Format.R8G8B8A8_Typeless, Format.R16G16_Typeless, Format.R32_Typeless, Format.R24G8_Typeless, Format.R8G8_Typeless, Format.R16_Typeless, Format.R8_Typeless, Format.BC1_Typeless, Format.BC2_Typeless, Format.BC3_Typeless, Format.BC4_Typeless, Format.BC5_Typeless, Format.B8G8R8A8_Typeless, Format.B8G8R8X8_Typeless, Format.BC6H_Typeless, Format.BC7_Typeless }, typelessFormats); } private static void InitFormat(IEnumerable<Format> formats, int bitCount) { foreach (Format format in formats) { sizeOfInBits[(int)format] = bitCount; } } private static void InitDefaults(IEnumerable<Format> formats, bool[] outputArray) { foreach (Format format in formats) { outputArray[(int)format] = true; } } } [Guid("D67441C7-672A-476f-9E82-CD55B44949CE")] public class InfoQueue : ComObject { public static InfoQueue TryCreate() { if (!DebugInterface.TryCreateComPtr<InfoQueue>(out var comPtr)) { return null; } return new InfoQueue(comPtr); } public InfoQueue(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator InfoQueue(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new InfoQueue(nativePtr); } return null; } public unsafe void SetMessageCountLimit(Guid producer, long messageCountLimit) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, long, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, messageCountLimit)); ((Result)(ref val)).CheckError(); } public unsafe void ClearStoredMessages(Guid producer) { ((delegate* unmanaged[Stdcall]<void*, Guid, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)4 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void GetMessage(Guid producer, long messageIndex, InformationQueueMessage[] messageRef, ref PointerSize messageByteLengthRef) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) InformationQueueMessage.__Native[] array = ((messageRef == null) ? null : new InformationQueueMessage.__Native[messageRef.Length]); Result val; fixed (PointerSize* ptr = &messageByteLengthRef) { void* ptr2 = ptr; fixed (InformationQueueMessage.__Native* ptr3 = array) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, long, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)5 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, messageIndex, ptr4, ptr2)); } } if (messageRef != null) { for (int i = 0; i < messageRef.Length; i++) { messageRef?[i].__MarshalFrom(ref array[i]); } } ((Result)(ref val)).CheckError(); } public unsafe long GetNumStoredMessagesAllowedByRetrievalFilters(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)6 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe long GetNumStoredMessages(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe long GetNumMessagesDiscardedByMessageCountLimit(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe long GetMessageCountLimit(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe long GetNumMessagesAllowedByStorageFilter(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe long GetNumMessagesDeniedByStorageFilter(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void AddStorageFilterEntries(Guid producer, ref InfoQueueFilter filterRef) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (InfoQueueFilter* ptr = &filterRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void GetStorageFilter(Guid producer, InfoQueueFilter[] filterRef, ref PointerSize filterByteLengthRef) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (PointerSize* ptr = &filterByteLengthRef) { void* ptr2 = ptr; fixed (InfoQueueFilter* ptr3 = filterRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void ClearStorageFilter(Guid producer) { ((delegate* unmanaged[Stdcall]<void*, Guid, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void PushEmptyStorageFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushDenyAllStorageFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushCopyOfStorageFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushStorageFilter(Guid producer, ref InfoQueueFilter filterRef) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (InfoQueueFilter* ptr = &filterRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void PopStorageFilter(Guid producer) { ((delegate* unmanaged[Stdcall]<void*, Guid, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe int GetStorageFilterStackSize(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void AddRetrievalFilterEntries(Guid producer, ref InfoQueueFilter filterRef) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (InfoQueueFilter* ptr = &filterRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void GetRetrievalFilter(Guid producer, InfoQueueFilter[] filterRef, ref PointerSize filterByteLengthRef) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (PointerSize* ptr = &filterByteLengthRef) { void* ptr2 = ptr; fixed (InfoQueueFilter* ptr3 = filterRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void ClearRetrievalFilter(Guid producer) { ((delegate* unmanaged[Stdcall]<void*, Guid, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void PushEmptyRetrievalFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)24 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushDenyAllRetrievalFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)25 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushCopyOfRetrievalFilter(Guid producer) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)26 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer)); ((Result)(ref val)).CheckError(); } public unsafe void PushRetrievalFilter(Guid producer, ref InfoQueueFilter filterRef) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (InfoQueueFilter* ptr = &filterRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)27 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void PopRetrievalFilter(Guid producer) { ((delegate* unmanaged[Stdcall]<void*, Guid, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)28 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe int GetRetrievalFilterStackSize(Guid producer) { return ((delegate* unmanaged[Stdcall]<void*, Guid, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)29 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } public unsafe void AddMessage(Guid producer, InformationQueueMessageCategory category, InformationQueueMessageSeverity severity, int id, string descriptionRef) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) IntPtr intPtr = Marshal.StringToHGlobalAnsi(descriptionRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int, int, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)30 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, (int)category, (int)severity, id, (void*)intPtr)); Marshal.FreeHGlobal(intPtr); ((Result)(ref val)).CheckError(); } public unsafe void AddApplicationMessage(InformationQueueMessageSeverity severity, string descriptionRef) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) IntPtr intPtr = Marshal.StringToHGlobalAnsi(descriptionRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)31 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)severity, (void*)intPtr)); Marshal.FreeHGlobal(intPtr); ((Result)(ref val)).CheckError(); } public unsafe void SetBreakOnCategory(Guid producer, InformationQueueMessageCategory category, RawBool bEnable) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)32 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, (int)category, bEnable)); ((Result)(ref val)).CheckError(); } public unsafe void SetBreakOnSeverity(Guid producer, InformationQueueMessageSeverity severity, RawBool bEnable) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)33 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, (int)severity, bEnable)); ((Result)(ref val)).CheckError(); } public unsafe void SetBreakOnID(Guid producer, int id, RawBool bEnable) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)34 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, id, bEnable)); ((Result)(ref val)).CheckError(); } public unsafe RawBool GetBreakOnCategory(Guid producer, InformationQueueMessageCategory category) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)35 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, (int)category); } public unsafe RawBool GetBreakOnSeverity(Guid producer, InformationQueueMessageSeverity severity) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)36 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, (int)severity); } public unsafe RawBool GetBreakOnID(Guid producer, int id) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, Guid, int, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)37 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, id); } public unsafe void SetMuteDebugOutput(Guid producer, RawBool bMute) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((delegate* unmanaged[Stdcall]<void*, Guid, RawBool, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)38 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer, bMute); } public unsafe RawBool GetMuteDebugOutput(Guid producer) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, Guid, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)39 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, producer); } } [Guid("e9550983-360b-4f53-b391-afd695078691")] public class IVirtualSurfaceImageSourceNative : ISurfaceImageSourceNative { private class VirtualSurfaceUpdatesCallbackNativeCallback : CallbackBase, IVirtualSurfaceUpdatesCallbackNative, IUnknown, ICallbackable, IDisposable { private IVirtualSurfaceImageSourceNative eventCallback; public VirtualSurfaceUpdatesCallbackNativeCallback(IVirtualSurfaceImageSourceNative eventCallbackArg) { eventCallback = eventCallbackArg; } public void UpdatesNeeded() { eventCallback.OnUpdatesNeeded(); } } private IVirtualSurfaceUpdatesCallbackNative callback; private EventHandler<EventArgs> updatesNeeded; public RawRectangle[] UpdateRectangles { get { int updateRectCount = GetUpdateRectCount(); RawRectangle[] array = (RawRectangle[])(object)new RawRectangle[updateRectCount]; GetUpdateRects(array, updateRectCount); return array; } } public RawRectangle VisibleBounds { get { //IL_0008: Unknown result type (might be due to invalid IL or missing references) GetVisibleBounds(out var bounds); return bounds; } } public event EventHandler<EventArgs> UpdatesNeeded { add { if (callback == null) { callback = new VirtualSurfaceUpdatesCallbackNativeCallback(this); RegisterForUpdatesNeeded(callback); } updatesNeeded = (EventHandler<EventArgs>)Delegate.Combine(updatesNeeded, value); } remove { updatesNeeded = (EventHandler<EventArgs>)Delegate.Remove(updatesNeeded, value); } } private void OnUpdatesNeeded() { if (updatesNeeded != null) { updatesNeeded(this, EventArgs.Empty); } } public IVirtualSurfaceImageSourceNative(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator IVirtualSurfaceImageSourceNative(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new IVirtualSurfaceImageSourceNative(nativePtr); } return null; } public unsafe void Invalidate(RawRectangle updateRect) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, RawRectangle, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)6 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, updateRect)); ((Result)(ref val)).CheckError(); } internal unsafe int GetUpdateRectCount() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) int result = default(int); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result)); ((Result)(ref val)).CheckError(); return result; } internal unsafe void GetUpdateRects(RawRectangle[] updates, int count) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (RawRectangle* ptr = updates) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, count)); } ((Result)(ref val)).CheckError(); } internal unsafe void GetVisibleBounds(out RawRectangle bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) bounds = default(RawRectangle); Result val; fixed (RawRectangle* ptr = &bounds) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } internal unsafe void RegisterForUpdatesNeeded(IVirtualSurfaceUpdatesCallbackNative callback) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IVirtualSurfaceUpdatesCallbackNative>((ICallbackable)callback); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero)); ((Result)(ref val)).CheckError(); } public unsafe void Resize(int newWidth, int newHeight) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, newWidth, newHeight)); ((Result)(ref val)).CheckError(); } } [Shadow(typeof(VirtualSurfaceUpdatesCallbackNativeShadow))] [Guid("dbf2e947-8e6c-4254-9eee-7738f71386c9")] internal interface IVirtualSurfaceUpdatesCallbackNative : IUnknown, ICallbackable, IDisposable { void UpdatesNeeded(); } [Guid("dbf2e947-8e6c-4254-9eee-7738f71386c9")] internal class IVirtualSurfaceUpdatesCallbackNativeNative : ComObject, IVirtualSurfaceUpdatesCallbackNative, IUnknown, ICallbackable, IDisposable { public void UpdatesNeeded() { UpdatesNeeded_(); } public IVirtualSurfaceUpdatesCallbackNativeNative(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator IVirtualSurfaceUpdatesCallbackNativeNative(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new IVirtualSurfaceUpdatesCallbackNativeNative(nativePtr); } return null; } internal unsafe void UpdatesNeeded_() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct ModeDescription { public int Width; public int Height; public Rational RefreshRate; public Format Format; public DisplayModeScanlineOrder ScanlineOrdering; public DisplayModeScaling Scaling; public ModeDescription(int width, int height, Rational refreshRate, Format format) { Width = width; Height = height; RefreshRate = refreshRate; Format = format; ScanlineOrdering = DisplayModeScanlineOrder.Unspecified; Scaling = DisplayModeScaling.Unspecified; } public ModeDescription(Format format) { this = default(ModeDescription); Format = format; } } internal class ModuleInit { [Tag("SharpDX.ModuleInit")] internal static void Setup() { ResultDescriptor.RegisterProvider(typeof(ResultCode)); } } [CompilerGenerated] internal class NamespaceDoc { } [Guid("ae02eedb-c735-4690-8d52-5a8dc20213aa")] public class Output : DXGIObject { public OutputDescription Description { get { GetDescription(out var descRef); return descRef; } } public GammaControlCapabilities GammaControlCapabilities { get { GetGammaControlCapabilities(out var gammaCapsRef); return gammaCapsRef; } } public GammaControl GammaControl { get { GetGammaControl(out var arrayRef); return arrayRef; } set { SetGammaControl(ref value); } } public FrameStatistics FrameStatistics { get { GetFrameStatistics(out var statsRef); return statsRef; } } public void GetClosestMatchingMode(ComObject device, ModeDescription modeToMatch, out ModeDescription closestMatch) { FindClosestMatchingMode(ref modeToMatch, out closestMatch, (IUnknown)(object)device); } public ModeDescription[] GetDisplayModeList(Format format, DisplayModeEnumerationFlags flags) { int numModesRef = 0; GetDisplayModeList(format, (int)flags, ref numModesRef, null); ModeDescription[] array = new ModeDescription[numModesRef]; if (numModesRef > 0) { GetDisplayModeList(format, (int)flags, ref numModesRef, array); } return array; } public Output(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Output(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Output(nativePtr); } return null; } internal unsafe void GetDescription(out OutputDescription descRef) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) OutputDescription.__Native @ref = default(OutputDescription.__Native); descRef = default(OutputDescription); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref)); descRef.__MarshalFrom(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe void GetDisplayModeList(Format enumFormat, int flags, ref int numModesRef, ModeDescription[] descRef) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (ModeDescription* ptr = descRef) { void* ptr2 = ptr; fixed (int* ptr3 = &numModesRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)enumFormat, flags, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } internal unsafe void FindClosestMatchingMode(ref ModeDescription modeToMatchRef, out ModeDescription closestMatchRef, IUnknown concernedDeviceRef) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) closestMatchRef = default(ModeDescription); IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)concernedDeviceRef); Result val; fixed (ModeDescription* ptr = &closestMatchRef) { void* ptr2 = ptr; fixed (ModeDescription* ptr3 = &modeToMatchRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, (void*)zero)); } } ((Result)(ref val)).CheckError(); } public unsafe void WaitForVerticalBlank() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } public unsafe void TakeOwnership(IUnknown deviceRef, RawBool exclusive) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, RawBool, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, exclusive)); ((Result)(ref val)).CheckError(); } public unsafe void ReleaseOwnership() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } internal unsafe void GetGammaControlCapabilities(out GammaControlCapabilities gammaCapsRef) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) GammaControlCapabilities.__Native @ref = default(GammaControlCapabilities.__Native); gammaCapsRef = default(GammaControlCapabilities); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref)); gammaCapsRef.__MarshalFrom(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe void SetGammaControl(ref GammaControl arrayRef) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) GammaControl.__Native @ref = default(GammaControl.__Native); arrayRef.__MarshalTo(ref @ref); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref)); arrayRef.__MarshalFree(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe void GetGammaControl(out GammaControl arrayRef) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) GammaControl.__Native @ref = default(GammaControl.__Native); arrayRef = default(GammaControl); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref)); arrayRef.__MarshalFrom(ref @ref); ((Result)(ref val)).CheckError(); } public unsafe void SetDisplaySurface(Surface scanoutSurfaceRef) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Surface>((ICallbackable)(object)scanoutSurfaceRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero)); ((Result)(ref val)).CheckError(); } public unsafe void CopyDisplaySurfaceTo(Surface destinationRef) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Surface>((ICallbackable)(object)destinationRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero)); ((Result)(ref val)).CheckError(); } internal unsafe void GetFrameStatistics(out FrameStatistics statsRef) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) statsRef = default(FrameStatistics); Result val; fixed (FrameStatistics* ptr = &statsRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } } [Guid("00cddea8-939b-4b83-a340-a685226666cc")] public class Output1 : Output { public ModeDescription1[] GetDisplayModeList1(Format enumFormat, DisplayModeEnumerationFlags flags) { int numModesRef = 0; GetDisplayModeList1(enumFormat, (int)flags, ref numModesRef, null); ModeDescription1[] array = new ModeDescription1[numModesRef]; if (numModesRef > 0) { GetDisplayModeList1(enumFormat, (int)flags, ref numModesRef, array); } return array; } public Output1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Output1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Output1(nativePtr); } return null; } internal unsafe void GetDisplayModeList1(Format enumFormat, int flags, ref int numModesRef, ModeDescription1[] descRef) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (ModeDescription1* ptr = descRef) { void* ptr2 = ptr; fixed (int* ptr3 = &numModesRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)enumFormat, flags, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void FindClosestMatchingMode1(ref ModeDescription1 modeToMatchRef, out ModeDescription1 closestMatchRef, IUnknown concernedDeviceRef) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) closestMatchRef = default(ModeDescription1); IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)concernedDeviceRef); Result val; fixed (ModeDescription1* ptr = &closestMatchRef) { void* ptr2 = ptr; fixed (ModeDescription1* ptr3 = &modeToMatchRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, (void*)zero)); } } ((Result)(ref val)).CheckError(); } public unsafe void GetDisplaySurfaceData1(Resource destinationRef) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)destinationRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero)); ((Result)(ref val)).CheckError(); } public unsafe OutputDuplication DuplicateOutput(IUnknown deviceRef) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)deviceRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, &zero2)); OutputDuplication result = ((!(zero2 != IntPtr.Zero)) ? null : new OutputDuplication(zero2)); ((Result)(ref val)).CheckError(); return result; } } [Guid("595e39d1-2724-4663-99b1-da969de28364")] public class Output2 : Output1 { public bool SupportsOverlays => RawBool.op_Implicit(SupportsOverlays_()); public Output2(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Output2(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Output2(nativePtr); } return null; } internal unsafe RawBool SupportsOverlays_() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, RawBool>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } } [Guid("191cfac3-a341-470d-b26e-a864f428319c")] public class OutputDuplication : DXGIObject { public OutputDuplicateDescription Description { get { GetDescription(out var descRef); return descRef; } } public OutputDuplication(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator OutputDuplication(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new OutputDuplication(nativePtr); } return null; } internal unsafe void GetDescription(out OutputDuplicateDescription descRef) { descRef = default(OutputDuplicateDescription); fixed (OutputDuplicateDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } public unsafe Result TryAcquireNextFrame(int timeoutInMilliseconds, out OutputDuplicateFrameInformation frameInfoRef, out Resource desktopResourceOut) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) frameInfoRef = default(OutputDuplicateFrameInformation); IntPtr zero = IntPtr.Zero; Result result; fixed (OutputDuplicateFrameInformation* ptr = &frameInfoRef) { void* ptr2 = ptr; result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, timeoutInMilliseconds, ptr2, &zero)); } if (zero != IntPtr.Zero) { desktopResourceOut = new Resource(zero); return result; } desktopResourceOut = null; return result; } public unsafe void GetFrameDirtyRects(int dirtyRectsBufferSize, RawRectangle[] dirtyRectsBufferRef, out int dirtyRectsBufferSizeRequiredRef) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &dirtyRectsBufferSizeRequiredRef) { void* ptr2 = ptr; fixed (RawRectangle* ptr3 = dirtyRectsBufferRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, dirtyRectsBufferSize, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void GetFrameMoveRects(int moveRectsBufferSize, OutputDuplicateMoveRectangle[] moveRectBufferRef, out int moveRectsBufferSizeRequiredRef) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &moveRectsBufferSizeRequiredRef) { void* ptr2 = ptr; fixed (OutputDuplicateMoveRectangle* ptr3 = moveRectBufferRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, moveRectsBufferSize, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void GetFramePointerShape(int pointerShapeBufferSize, IntPtr pointerShapeBufferRef, out int pointerShapeBufferSizeRequiredRef, out OutputDuplicatePointerShapeInformation pointerShapeInfoRef) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) pointerShapeInfoRef = default(OutputDuplicatePointerShapeInformation); Result val; fixed (OutputDuplicatePointerShapeInformation* ptr = &pointerShapeInfoRef) { void* ptr2 = ptr; fixed (int* ptr3 = &pointerShapeBufferSizeRequiredRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, pointerShapeBufferSize, (void*)pointerShapeBufferRef, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } internal unsafe void MapDesktopSurface(out MappedRectangle lockedRectRef) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) lockedRectRef = default(MappedRectangle); Result val; fixed (MappedRectangle* ptr = &lockedRectRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void UnMapDesktopSurface() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } public unsafe void ReleaseFrame() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } } public struct PresentParameters { internal struct __Native { public int DirtyRectsCount; public IntPtr PDirtyRects; public IntPtr PScrollRect; public IntPtr PScrollOffset; } public RawRectangle[] DirtyRectangles; public RawRectangle? ScrollRectangle; public RawPoint? ScrollOffset; internal int DirtyRectsCount; internal IntPtr PDirtyRects; internal IntPtr PScrollRect; internal IntPtr PScrollOffset; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct Rational : IEquatable<Rational> { public static readonly Rational Empty; public int Numerator; public int Denominator; public Rational(int numerator, int denominator) { Numerator = numerator; Denominator = denominator; } public bool Equals(Rational other) { if (Numerator == other.Numerator) { return Denominator == other.Denominator; } return false; } public override bool Equals(object obj) { if (obj == null) { return false; } if (obj is Rational) { return Equals((Rational)obj); } return false; } public override int GetHashCode() { return (Numerator * 397) ^ Denominator; } public static bool operator ==(Rational left, Rational right) { return left.Equals(right); } public static bool operator !=(Rational left, Rational right) { return !left.Equals(right); } public override string ToString() { return $"{Numerator}/{Denominator}"; } } [Guid("30961379-4609-4a41-998e-54fe567ee0c1")] public class Resource1 : Resource { public IntPtr CreateSharedHandle(string name, SharedResourceFlags dwAccess, SecurityAttributes? attributesRef = null) { return CreateSharedHandle(attributesRef, dwAccess, name); } public Resource1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Resource1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Resource1(nativePtr); } return null; } internal unsafe void CreateSubresourceSurface(int index, Surface2 surfaceOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, index, &zero)); ((CppObject)surfaceOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe IntPtr CreateSharedHandle(SecurityAttributes? attributesRef, SharedResourceFlags dwAccess, string lpName) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) SecurityAttributes value = default(SecurityAttributes); if (attributesRef.HasValue) { value = attributesRef.Value; } Result val; IntPtr result = default(IntPtr); fixed (char* ptr = lpName) { void* nativePointer = ((CppObject)this)._nativePointer; SecurityAttributes* intPtr = ((!attributesRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(nativePointer, intPtr, (int)dwAccess, ptr, &result)); } ((Result)(ref val)).CheckError(); return result; } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct SampleDescription { public int Count; public int Quality; public SampleDescription(int count, int quality) { Count = count; Quality = quality; } public override string ToString() { return $"{{{Count}, {Quality}}}"; } } [Guid("cafcb56c-6ac3-4889-bf47-9e23bbd260ec")] public class Surface : DeviceChild { public SurfaceDescription Description { get { GetDescription(out var descRef); return descRef; } } public DataRectangle Map(MapFlags flags) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) Map(out var lockedRectRef, (int)flags); return new DataRectangle(lockedRectRef.PBits, lockedRectRef.Pitch); } public DataRectangle Map(MapFlags flags, out DataStream dataStream) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) DataRectangle val = Map(flags); dataStream = new DataStream(val.DataPointer, (long)(Description.Height * val.Pitch), true, true); return val; } public static Surface FromSwapChain(SwapChain swapChain, int index) { swapChain.GetBuffer(index, Utilities.GetGuidFromType(typeof(Surface)), out var surfaceOut); return new Surface(surfaceOut); } public Surface(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Surface(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Surface(nativePtr); } return null; } internal unsafe void GetDescription(out SurfaceDescription descRef) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) descRef = default(SurfaceDescription); Result val; fixed (SurfaceDescription* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } internal unsafe void Map(out MappedRectangle lockedRectRef, int mapFlags) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) lockedRectRef = default(MappedRectangle); Result val; fixed (MappedRectangle* ptr = &lockedRectRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, mapFlags)); } ((Result)(ref val)).CheckError(); } public unsafe void Unmap() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } } [Guid("4AE63092-6327-4c1b-80AE-BFE12EA32B86")] public class Surface1 : Surface { public void ReleaseDC() { ReleaseDC_(null); } public void ReleaseDC(RawRectangle dirtyRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ReleaseDC_(dirtyRect); } public Surface1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Surface1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Surface1(nativePtr); } return null; } public unsafe IntPtr GetDC(RawBool discard) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) IntPtr result = default(IntPtr); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, RawBool, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, discard, &result)); ((Result)(ref val)).CheckError(); return result; } internal unsafe void ReleaseDC_(RawRectangle? dirtyRectRef) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) RawRectangle value = default(RawRectangle); if (dirtyRectRef.HasValue) { value = dirtyRectRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; RawRectangle* intPtr = ((!dirtyRectRef.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(nativePointer, intPtr)); ((Result)(ref val)).CheckError(); } } [Guid("aba496dd-b617-4cb8-a866-bc44d7eb1fa2")] public class Surface2 : Surface1 { public Surface2(Resource1 resource, int index) : base(IntPtr.Zero) { resource.CreateSubresourceSurface(index, this); } public Surface2(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Surface2(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Surface2(nativePtr); } return null; } public unsafe void GetResource(Guid riid, out IntPtr parentResourceOut, out int subresourceIndexRef) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &subresourceIndexRef) { void* ptr2 = ptr; fixed (IntPtr* ptr3 = &parentResourceOut) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &riid, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } } [Guid("310d36a0-d2e7-4c0a-aa04-6a9d23b8886a")] public class SwapChain : DeviceChild { public FrameStatistics FrameStatistics { get { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) FrameStatistics statsRef; Result val = TryGetFrameStatistics(out statsRef); ((Result)(ref val)).CheckError(); return statsRef; } } public bool IsFullScreen { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) GetFullscreenState(out var fullscreenRef, out var targetOut); if (targetOut != null) { ((DisposeBase)targetOut).Dispose(); } return RawBool.op_Implicit(fullscreenRef); } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) SetFullscreenState(RawBool.op_Implicit(value), null); } } public SwapChainDescription Description { get { GetDescription(out var descRef); return descRef; } } public Output ContainingOutput { get { GetContainingOutput(out var outputOut); return outputOut; } } public int LastPresentCount { get { GetLastPresentCount(out var lastPresentCountRef); return lastPresentCountRef; } } public SwapChain(Factory factory, ComObject device, SwapChainDescription description) : base(IntPtr.Zero) { factory.CreateSwapChain((IUnknown)(object)device, ref description, this); } public T GetBackBuffer<T>(int index) where T : ComObject { GetBuffer(index, Utilities.GetGuidFromType(typeof(T)), out var surfaceOut); return CppObject.Fro
BepInEx/plugins/DearImGuiInjection/System.Collections.NonGeneric.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Security; using System.Threading; using FxResources.System.Collections.NonGeneric; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Collections.NonGeneric")] [assembly: AssemblyDescription("System.Collections.NonGeneric")] [assembly: AssemblyDefaultAlias("System.Collections.NonGeneric")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.0.2.0")] namespace FxResources.System.Collections.NonGeneric { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Collections.NonGeneric.SR"; private static ResourceManager ResourceManager { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string Argument_AddingDuplicate__ => GetResourceString("Argument_AddingDuplicate__", null); internal static string Argument_ImplementIComparable => GetResourceString("Argument_ImplementIComparable", null); internal static string Arg_ArrayPlusOffTooSmall => GetResourceString("Arg_ArrayPlusOffTooSmall", null); internal static string Arg_RankMultiDimNotSupported => GetResourceString("Arg_RankMultiDimNotSupported", null); internal static string Arg_HTCapacityOverflow => GetResourceString("Arg_HTCapacityOverflow", null); internal static string Arg_RemoveArgNotFound => GetResourceString("Arg_RemoveArgNotFound", null); internal static string Argument_InvalidOffLen => GetResourceString("Argument_InvalidOffLen", null); internal static string ArgumentNull_Array => GetResourceString("ArgumentNull_Array", null); internal static string ArgumentNull_Collection => GetResourceString("ArgumentNull_Collection", null); internal static string ArgumentNull_Dictionary => GetResourceString("ArgumentNull_Dictionary", null); internal static string ArgumentNull_Key => GetResourceString("ArgumentNull_Key", null); internal static string ArgumentOutOfRange_ArrayListInsert => GetResourceString("ArgumentOutOfRange_ArrayListInsert", null); internal static string ArgumentOutOfRange_BiggerThanCollection => GetResourceString("ArgumentOutOfRange_BiggerThanCollection", null); internal static string ArgumentOutOfRange_Count => GetResourceString("ArgumentOutOfRange_Count", null); internal static string ArgumentOutOfRange_HashtableLoadFactor => GetResourceString("ArgumentOutOfRange_HashtableLoadFactor", null); internal static string ArgumentOutOfRange_Index => GetResourceString("ArgumentOutOfRange_Index", null); internal static string ArgumentOutOfRange_NeedNonNegNum => GetResourceString("ArgumentOutOfRange_NeedNonNegNum", null); internal static string ArgumentOutOfRange_SmallCapacity => GetResourceString("ArgumentOutOfRange_SmallCapacity", null); internal static string ArgumentOutOfRange_QueueGrowFactor => GetResourceString("ArgumentOutOfRange_QueueGrowFactor", null); internal static string ArgumentOutOfRange_MustBeNonNegNum => GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", null); internal static string InvalidOperation_EmptyQueue => GetResourceString("InvalidOperation_EmptyQueue", null); internal static string InvalidOperation_EmptyStack => GetResourceString("InvalidOperation_EmptyStack", null); internal static string InvalidOperation_EnumEnded => GetResourceString("InvalidOperation_EnumEnded", null); internal static string InvalidOperation_EnumFailedVersion => GetResourceString("InvalidOperation_EnumFailedVersion", null); internal static string InvalidOperation_EnumNotStarted => GetResourceString("InvalidOperation_EnumNotStarted", null); internal static string InvalidOperation_EnumOpCantHappen => GetResourceString("InvalidOperation_EnumOpCantHappen", null); internal static string InvalidOperation_UnderlyingArrayListChanged => GetResourceString("InvalidOperation_UnderlyingArrayListChanged", null); internal static string InvalidOperation_HashInsertFailed => GetResourceString("InvalidOperation_HashInsertFailed", null); internal static string NotSupported_FixedSizeCollection => GetResourceString("NotSupported_FixedSizeCollection", null); internal static string NotSupported_KeyCollectionSet => GetResourceString("NotSupported_KeyCollectionSet", null); internal static string NotSupported_ReadOnlyCollection => GetResourceString("NotSupported_ReadOnlyCollection", null); internal static string NotSupported_RangeCollection => GetResourceString("NotSupported_RangeCollection", null); internal static string NotSupported_SortedListNestedWrite => GetResourceString("NotSupported_SortedListNestedWrite", null); internal static System.Type ResourceType => typeof(FxResources.System.Collections.NonGeneric.SR); [MethodImpl(8)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, (StringComparison)4)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", new object[2] { resourceFormat, p1 }); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", new object[3] { resourceFormat, p1, p2 }); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", new object[4] { resourceFormat, p1, p2, p3 }); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Collections { [DefaultMember("Item")] [DebuggerTypeProxy(typeof(ArrayListDebugView))] [DebuggerDisplay("Count = {Count}")] public class ArrayList : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { [DefaultMember("Item")] private class IListWrapper : ArrayList { private sealed class IListWrapperEnumWrapper : System.Collections.IEnumerator { private System.Collections.IEnumerator _en; private int _remaining; private int _initialStartIndex; private int _initialCount; private bool _firstCall; public object Current { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (_firstCall) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } if (_remaining < 0) { throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); } return _en.Current; } } internal IListWrapperEnumWrapper(IListWrapper listWrapper, int startIndex, int count) { _en = listWrapper.GetEnumerator(); _initialStartIndex = startIndex; _initialCount = count; while (startIndex-- > 0 && _en.MoveNext()) { } _remaining = count; _firstCall = true; } public bool MoveNext() { if (_firstCall) { _firstCall = false; if (_remaining-- > 0) { return _en.MoveNext(); } return false; } if (_remaining < 0) { return false; } if (_en.MoveNext()) { return _remaining-- > 0; } return false; } public void Reset() { _en.Reset(); int initialStartIndex = _initialStartIndex; while (initialStartIndex-- > 0 && _en.MoveNext()) { } _remaining = _initialCount; _firstCall = true; } } private System.Collections.IList _list; public override int Capacity { get { return ((System.Collections.ICollection)_list).Count; } set { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (value < Count) { throw new ArgumentOutOfRangeException("value", SR.ArgumentOutOfRange_SmallCapacity); } } } public override int Count => ((System.Collections.ICollection)_list).Count; public override bool IsReadOnly => _list.IsReadOnly; public override bool IsFixedSize => _list.IsFixedSize; public override bool IsSynchronized => ((System.Collections.ICollection)_list).IsSynchronized; public override object this[int index] { get { return _list[index]; } set { _list[index] = value; _version++; } } public override object SyncRoot => ((System.Collections.ICollection)_list).SyncRoot; internal IListWrapper(System.Collections.IList list) { _list = list; _version = 0; } public override int Add(object obj) { int result = _list.Add(obj); _version++; return result; } public override void AddRange(System.Collections.ICollection c) { InsertRange(Count, c); } public override int BinarySearch(int index, int count, object value, IComparer comparer) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (comparer == null) { comparer = (IComparer)(object)Comparer.Default; } int num = index; int num2 = index + count - 1; while (num <= num2) { int num3 = (num + num2) / 2; int num4 = comparer.Compare(value, _list[num3]); if (num4 == 0) { return num3; } if (num4 < 0) { num2 = num3 - 1; } else { num = num3 + 1; } } return ~num; } public override void Clear() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (_list.IsFixedSize) { throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } _list.Clear(); _version++; } public override object Clone() { return new IListWrapper(_list); } public override bool Contains(object obj) { return _list.Contains(obj); } public override void CopyTo(System.Array array, int index) { ((System.Collections.ICollection)_list).CopyTo(array, index); } public override void CopyTo(int index, System.Array array, int arrayIndex, int count) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (index < 0 || arrayIndex < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "arrayIndex", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - arrayIndex < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } for (int i = index; i < index + count; i++) { array.SetValue(_list[i], arrayIndex++); } } public override System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.IEnumerable)_list).GetEnumerator(); } public override System.Collections.IEnumerator GetEnumerator(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new IListWrapperEnumWrapper(this, index, count); } public override int IndexOf(object value) { return _list.IndexOf(value); } public override int IndexOf(object value, int startIndex) { return IndexOf(value, startIndex, ((System.Collections.ICollection)_list).Count - startIndex); } public override int IndexOf(object value, int startIndex, int count) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (startIndex < 0 || startIndex > Count) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } if (count < 0 || startIndex > Count - count) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_Count); } int num = startIndex + count; if (value == null) { for (int i = startIndex; i < num; i++) { if (_list[i] == null) { return i; } } return -1; } for (int j = startIndex; j < num; j++) { if (_list[j] != null && _list[j].Equals(value)) { return j; } } return -1; } public override void Insert(int index, object obj) { _list.Insert(index, obj); _version++; } public override void InsertRange(int index, System.Collections.ICollection c) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c", SR.ArgumentNull_Collection); } if (index < 0 || index > Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } if (c.Count <= 0) { return; } if (_list is ArrayList arrayList) { arrayList.InsertRange(index, c); } else { System.Collections.IEnumerator enumerator = ((System.Collections.IEnumerable)c).GetEnumerator(); while (enumerator.MoveNext()) { _list.Insert(index++, enumerator.Current); } } _version++; } public override int LastIndexOf(object value) { return LastIndexOf(value, ((System.Collections.ICollection)_list).Count - 1, ((System.Collections.ICollection)_list).Count); } public override int LastIndexOf(object value, int startIndex) { return LastIndexOf(value, startIndex, startIndex + 1); } public override int LastIndexOf(object value, int startIndex, int count) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (((System.Collections.ICollection)_list).Count == 0) { return -1; } if (startIndex < 0 || startIndex >= ((System.Collections.ICollection)_list).Count) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } if (count < 0 || count > startIndex + 1) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_Count); } int num = startIndex - count + 1; if (value == null) { for (int num2 = startIndex; num2 >= num; num2--) { if (_list[num2] == null) { return num2; } } return -1; } for (int num3 = startIndex; num3 >= num; num3--) { if (_list[num3] != null && _list[num3].Equals(value)) { return num3; } } return -1; } public override void Remove(object value) { int num = IndexOf(value); if (num >= 0) { RemoveAt(num); } } public override void RemoveAt(int index) { _list.RemoveAt(index); _version++; } public override void RemoveRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (count > 0) { _version++; } while (count > 0) { _list.RemoveAt(index); count--; } } public override void Reverse(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } int num = index; int num2 = index + count - 1; while (num < num2) { object obj = _list[num]; _list[num++] = _list[num2]; _list[num2--] = obj; } _version++; } public override void SetRange(int index, System.Collections.ICollection c) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c", SR.ArgumentNull_Collection); } if (index < 0 || index > ((System.Collections.ICollection)_list).Count - c.Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } if (c.Count > 0) { System.Collections.IEnumerator enumerator = ((System.Collections.IEnumerable)c).GetEnumerator(); while (enumerator.MoveNext()) { _list[index++] = enumerator.Current; } _version++; } } public override ArrayList GetRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new Range(this, index, count); } public override void Sort(int index, int count, IComparer comparer) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (((System.Collections.ICollection)_list).Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } object[] array = new object[count]; CopyTo(index, array, 0, count); System.Array.Sort((System.Array)array, 0, count, comparer); for (int i = 0; i < count; i++) { _list[i + index] = array[i]; } _version++; } public override object[] ToArray() { if (Count == 0) { return System.Array.Empty<object>(); } object[] array = new object[Count]; ((System.Collections.ICollection)_list).CopyTo((System.Array)array, 0); return array; } [SecuritySafeCritical] public override System.Array ToArray(System.Type type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (type == null) { throw new ArgumentNullException("type"); } System.Array array = System.Array.CreateInstance(type, ((System.Collections.ICollection)_list).Count); ((System.Collections.ICollection)_list).CopyTo(array, 0); return array; } public override void TrimToSize() { } } [DefaultMember("Item")] private class SyncArrayList : ArrayList { private ArrayList _list; private object _root; public override int Capacity { get { lock (_root) { return _list.Capacity; } } set { lock (_root) { _list.Capacity = value; } } } public override int Count { get { lock (_root) { return _list.Count; } } } public override bool IsReadOnly => _list.IsReadOnly; public override bool IsFixedSize => _list.IsFixedSize; public override bool IsSynchronized => true; public override object this[int index] { get { lock (_root) { return _list[index]; } } set { lock (_root) { _list[index] = value; } } } public override object SyncRoot => _root; internal SyncArrayList(ArrayList list) : base(trash: false) { _list = list; _root = list.SyncRoot; } public override int Add(object value) { lock (_root) { return _list.Add(value); } } public override void AddRange(System.Collections.ICollection c) { lock (_root) { _list.AddRange(c); } } public override int BinarySearch(object value) { lock (_root) { return _list.BinarySearch(value); } } public override int BinarySearch(object value, IComparer comparer) { lock (_root) { return _list.BinarySearch(value, comparer); } } public override int BinarySearch(int index, int count, object value, IComparer comparer) { lock (_root) { return _list.BinarySearch(index, count, value, comparer); } } public override void Clear() { lock (_root) { _list.Clear(); } } public override object Clone() { lock (_root) { return new SyncArrayList((ArrayList)_list.Clone()); } } public override bool Contains(object item) { lock (_root) { return _list.Contains(item); } } public override void CopyTo(System.Array array) { lock (_root) { _list.CopyTo(array); } } public override void CopyTo(System.Array array, int index) { lock (_root) { _list.CopyTo(array, index); } } public override void CopyTo(int index, System.Array array, int arrayIndex, int count) { lock (_root) { _list.CopyTo(index, array, arrayIndex, count); } } public override System.Collections.IEnumerator GetEnumerator() { lock (_root) { return _list.GetEnumerator(); } } public override System.Collections.IEnumerator GetEnumerator(int index, int count) { lock (_root) { return _list.GetEnumerator(index, count); } } public override int IndexOf(object value) { lock (_root) { return _list.IndexOf(value); } } public override int IndexOf(object value, int startIndex) { lock (_root) { return _list.IndexOf(value, startIndex); } } public override int IndexOf(object value, int startIndex, int count) { lock (_root) { return _list.IndexOf(value, startIndex, count); } } public override void Insert(int index, object value) { lock (_root) { _list.Insert(index, value); } } public override void InsertRange(int index, System.Collections.ICollection c) { lock (_root) { _list.InsertRange(index, c); } } public override int LastIndexOf(object value) { lock (_root) { return _list.LastIndexOf(value); } } public override int LastIndexOf(object value, int startIndex) { lock (_root) { return _list.LastIndexOf(value, startIndex); } } public override int LastIndexOf(object value, int startIndex, int count) { lock (_root) { return _list.LastIndexOf(value, startIndex, count); } } public override void Remove(object value) { lock (_root) { _list.Remove(value); } } public override void RemoveAt(int index) { lock (_root) { _list.RemoveAt(index); } } public override void RemoveRange(int index, int count) { lock (_root) { _list.RemoveRange(index, count); } } public override void Reverse(int index, int count) { lock (_root) { _list.Reverse(index, count); } } public override void SetRange(int index, System.Collections.ICollection c) { lock (_root) { _list.SetRange(index, c); } } public override ArrayList GetRange(int index, int count) { lock (_root) { return _list.GetRange(index, count); } } public override void Sort() { lock (_root) { _list.Sort(); } } public override void Sort(IComparer comparer) { lock (_root) { _list.Sort(comparer); } } public override void Sort(int index, int count, IComparer comparer) { lock (_root) { _list.Sort(index, count, comparer); } } public override object[] ToArray() { lock (_root) { return _list.ToArray(); } } public override System.Array ToArray(System.Type type) { lock (_root) { return _list.ToArray(type); } } public override void TrimToSize() { lock (_root) { _list.TrimToSize(); } } } [DefaultMember("Item")] private class SyncIList : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { private System.Collections.IList _list; private object _root; public virtual int Count { get { lock (_root) { return ((System.Collections.ICollection)_list).Count; } } } public virtual bool IsReadOnly => _list.IsReadOnly; public virtual bool IsFixedSize => _list.IsFixedSize; public virtual bool IsSynchronized => true; public virtual object this[int index] { get { lock (_root) { return _list[index]; } } set { lock (_root) { _list[index] = value; } } } public virtual object SyncRoot => _root; internal SyncIList(System.Collections.IList list) { _list = list; _root = ((System.Collections.ICollection)list).SyncRoot; } public virtual int Add(object value) { lock (_root) { return _list.Add(value); } } public virtual void Clear() { lock (_root) { _list.Clear(); } } public virtual bool Contains(object item) { lock (_root) { return _list.Contains(item); } } public virtual void CopyTo(System.Array array, int index) { lock (_root) { ((System.Collections.ICollection)_list).CopyTo(array, index); } } public virtual System.Collections.IEnumerator GetEnumerator() { lock (_root) { return ((System.Collections.IEnumerable)_list).GetEnumerator(); } } public virtual int IndexOf(object value) { lock (_root) { return _list.IndexOf(value); } } public virtual void Insert(int index, object value) { lock (_root) { _list.Insert(index, value); } } public virtual void Remove(object value) { lock (_root) { _list.Remove(value); } } public virtual void RemoveAt(int index) { lock (_root) { _list.RemoveAt(index); } } } [DefaultMember("Item")] private class FixedSizeList : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { private System.Collections.IList _list; public virtual int Count => ((System.Collections.ICollection)_list).Count; public virtual bool IsReadOnly => _list.IsReadOnly; public virtual bool IsFixedSize => true; public virtual bool IsSynchronized => ((System.Collections.ICollection)_list).IsSynchronized; public virtual object this[int index] { get { return _list[index]; } set { _list[index] = value; } } public virtual object SyncRoot => ((System.Collections.ICollection)_list).SyncRoot; internal FixedSizeList(System.Collections.IList l) { _list = l; } public virtual int Add(object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public virtual void Clear() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public virtual bool Contains(object obj) { return _list.Contains(obj); } public virtual void CopyTo(System.Array array, int index) { ((System.Collections.ICollection)_list).CopyTo(array, index); } public virtual System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.IEnumerable)_list).GetEnumerator(); } public virtual int IndexOf(object value) { return _list.IndexOf(value); } public virtual void Insert(int index, object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public virtual void Remove(object value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public virtual void RemoveAt(int index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } } [DefaultMember("Item")] private class FixedSizeArrayList : ArrayList { private ArrayList _list; public override int Count => _list.Count; public override bool IsReadOnly => _list.IsReadOnly; public override bool IsFixedSize => true; public override bool IsSynchronized => _list.IsSynchronized; public override object this[int index] { get { return _list[index]; } set { _list[index] = value; _version = _list._version; } } public override object SyncRoot => _list.SyncRoot; public override int Capacity { get { return _list.Capacity; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } } internal FixedSizeArrayList(ArrayList l) { _list = l; _version = _list._version; } public override int Add(object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override void AddRange(System.Collections.ICollection c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override int BinarySearch(int index, int count, object value, IComparer comparer) { return _list.BinarySearch(index, count, value, comparer); } public override void Clear() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override object Clone() { FixedSizeArrayList fixedSizeArrayList = new FixedSizeArrayList(_list); fixedSizeArrayList._list = (ArrayList)_list.Clone(); return fixedSizeArrayList; } public override bool Contains(object obj) { return _list.Contains(obj); } public override void CopyTo(System.Array array, int index) { _list.CopyTo(array, index); } public override void CopyTo(int index, System.Array array, int arrayIndex, int count) { _list.CopyTo(index, array, arrayIndex, count); } public override System.Collections.IEnumerator GetEnumerator() { return _list.GetEnumerator(); } public override System.Collections.IEnumerator GetEnumerator(int index, int count) { return _list.GetEnumerator(index, count); } public override int IndexOf(object value) { return _list.IndexOf(value); } public override int IndexOf(object value, int startIndex) { return _list.IndexOf(value, startIndex); } public override int IndexOf(object value, int startIndex, int count) { return _list.IndexOf(value, startIndex, count); } public override void Insert(int index, object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override void InsertRange(int index, System.Collections.ICollection c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override int LastIndexOf(object value) { return _list.LastIndexOf(value); } public override int LastIndexOf(object value, int startIndex) { return _list.LastIndexOf(value, startIndex); } public override int LastIndexOf(object value, int startIndex, int count) { return _list.LastIndexOf(value, startIndex, count); } public override void Remove(object value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override void RemoveAt(int index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override void RemoveRange(int index, int count) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } public override void SetRange(int index, System.Collections.ICollection c) { _list.SetRange(index, c); _version = _list._version; } public override ArrayList GetRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new Range(this, index, count); } public override void Reverse(int index, int count) { _list.Reverse(index, count); _version = _list._version; } public override void Sort(int index, int count, IComparer comparer) { _list.Sort(index, count, comparer); _version = _list._version; } public override object[] ToArray() { return _list.ToArray(); } public override System.Array ToArray(System.Type type) { return _list.ToArray(type); } public override void TrimToSize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } } [DefaultMember("Item")] private class ReadOnlyList : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { private System.Collections.IList _list; public virtual int Count => ((System.Collections.ICollection)_list).Count; public virtual bool IsReadOnly => true; public virtual bool IsFixedSize => true; public virtual bool IsSynchronized => ((System.Collections.ICollection)_list).IsSynchronized; public virtual object this[int index] { get { return _list[index]; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } public virtual object SyncRoot => ((System.Collections.ICollection)_list).SyncRoot; internal ReadOnlyList(System.Collections.IList l) { _list = l; } public virtual int Add(object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void Clear() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual bool Contains(object obj) { return _list.Contains(obj); } public virtual void CopyTo(System.Array array, int index) { ((System.Collections.ICollection)_list).CopyTo(array, index); } public virtual System.Collections.IEnumerator GetEnumerator() { return ((System.Collections.IEnumerable)_list).GetEnumerator(); } public virtual int IndexOf(object value) { return _list.IndexOf(value); } public virtual void Insert(int index, object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void Remove(object value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void RemoveAt(int index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } [DefaultMember("Item")] private class ReadOnlyArrayList : ArrayList { private ArrayList _list; public override int Count => _list.Count; public override bool IsReadOnly => true; public override bool IsFixedSize => true; public override bool IsSynchronized => _list.IsSynchronized; public override object this[int index] { get { return _list[index]; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } public override object SyncRoot => _list.SyncRoot; public override int Capacity { get { return _list.Capacity; } set { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } internal ReadOnlyArrayList(ArrayList l) { _list = l; } public override int Add(object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void AddRange(System.Collections.ICollection c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override int BinarySearch(int index, int count, object value, IComparer comparer) { return _list.BinarySearch(index, count, value, comparer); } public override void Clear() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override object Clone() { ReadOnlyArrayList readOnlyArrayList = new ReadOnlyArrayList(_list); readOnlyArrayList._list = (ArrayList)_list.Clone(); return readOnlyArrayList; } public override bool Contains(object obj) { return _list.Contains(obj); } public override void CopyTo(System.Array array, int index) { _list.CopyTo(array, index); } public override void CopyTo(int index, System.Array array, int arrayIndex, int count) { _list.CopyTo(index, array, arrayIndex, count); } public override System.Collections.IEnumerator GetEnumerator() { return _list.GetEnumerator(); } public override System.Collections.IEnumerator GetEnumerator(int index, int count) { return _list.GetEnumerator(index, count); } public override int IndexOf(object value) { return _list.IndexOf(value); } public override int IndexOf(object value, int startIndex) { return _list.IndexOf(value, startIndex); } public override int IndexOf(object value, int startIndex, int count) { return _list.IndexOf(value, startIndex, count); } public override void Insert(int index, object obj) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void InsertRange(int index, System.Collections.ICollection c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override int LastIndexOf(object value) { return _list.LastIndexOf(value); } public override int LastIndexOf(object value, int startIndex) { return _list.LastIndexOf(value, startIndex); } public override int LastIndexOf(object value, int startIndex, int count) { return _list.LastIndexOf(value, startIndex, count); } public override void Remove(object value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void RemoveAt(int index) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void RemoveRange(int index, int count) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void SetRange(int index, System.Collections.ICollection c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override ArrayList GetRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (Count - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new Range(this, index, count); } public override void Reverse(int index, int count) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override void Sort(int index, int count, IComparer comparer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public override object[] ToArray() { return _list.ToArray(); } public override System.Array ToArray(System.Type type) { return _list.ToArray(type); } public override void TrimToSize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } private sealed class ArrayListEnumerator : System.Collections.IEnumerator { private ArrayList _list; private int _index; private int _endIndex; private int _version; private object _currentElement; private int _startIndex; public object Current { get { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (_index < _startIndex) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } if (_index > _endIndex) { throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); } return _currentElement; } } internal ArrayListEnumerator(ArrayList list, int index, int count) { _list = list; _startIndex = index; _index = index - 1; _endIndex = _index + count; _version = list._version; _currentElement = null; } public bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } if (_index < _endIndex) { _currentElement = _list[++_index]; return true; } _index = _endIndex + 1; return false; } public void Reset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } _index = _startIndex - 1; } } [DefaultMember("Item")] private class Range : ArrayList { private ArrayList _baseList; private int _baseIndex; private int _baseSize; private int _baseVersion; public override int Capacity { get { return _baseList.Capacity; } set { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (value < Count) { throw new ArgumentOutOfRangeException("value", SR.ArgumentOutOfRange_SmallCapacity); } } } public override int Count { get { InternalUpdateRange(); return _baseSize; } } public override bool IsReadOnly => _baseList.IsReadOnly; public override bool IsFixedSize => _baseList.IsFixedSize; public override bool IsSynchronized => _baseList.IsSynchronized; public override object SyncRoot => _baseList.SyncRoot; public override object this[int index] { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) InternalUpdateRange(); if (index < 0 || index >= _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } return _baseList[_baseIndex + index]; } set { //IL_001d: Unknown result type (might be due to invalid IL or missing references) InternalUpdateRange(); if (index < 0 || index >= _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } _baseList[_baseIndex + index] = value; InternalUpdateVersion(); } } internal Range(ArrayList list, int index, int count) : base(trash: false) { _baseList = list; _baseIndex = index; _baseSize = count; _baseVersion = list._version; _version = list._version; } private void InternalUpdateRange() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_baseVersion != _baseList._version) { throw new InvalidOperationException(SR.InvalidOperation_UnderlyingArrayListChanged); } } private void InternalUpdateVersion() { _baseVersion++; _version++; } public override int Add(object value) { InternalUpdateRange(); _baseList.Insert(_baseIndex + _baseSize, value); InternalUpdateVersion(); return _baseSize++; } public override void AddRange(System.Collections.ICollection c) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c"); } InternalUpdateRange(); int count = c.Count; if (count > 0) { _baseList.InsertRange(_baseIndex + _baseSize, c); InternalUpdateVersion(); _baseSize += count; } } public override int BinarySearch(int index, int count, object value, IComparer comparer) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); int num = _baseList.BinarySearch(_baseIndex + index, count, value, comparer); if (num >= 0) { return num - _baseIndex; } return num + _baseIndex; } public override void Clear() { InternalUpdateRange(); if (_baseSize != 0) { _baseList.RemoveRange(_baseIndex, _baseSize); InternalUpdateVersion(); _baseSize = 0; } } public override object Clone() { InternalUpdateRange(); Range range = new Range(_baseList, _baseIndex, _baseSize); range._baseList = (ArrayList)_baseList.Clone(); return range; } public override bool Contains(object item) { InternalUpdateRange(); if (item == null) { for (int i = 0; i < _baseSize; i++) { if (_baseList[_baseIndex + i] == null) { return true; } } return false; } for (int j = 0; j < _baseSize; j++) { if (_baseList[_baseIndex + j] != null && _baseList[_baseIndex + j].Equals(item)) { return true; } } return false; } public override void CopyTo(System.Array array, int index) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - index < _baseSize) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); _baseList.CopyTo(_baseIndex, array, index, _baseSize); } public override void CopyTo(int index, System.Array array, int arrayIndex, int count) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - arrayIndex < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); _baseList.CopyTo(_baseIndex + index, array, arrayIndex, count); } public override System.Collections.IEnumerator GetEnumerator() { return GetEnumerator(0, _baseSize); } public override System.Collections.IEnumerator GetEnumerator(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); return _baseList.GetEnumerator(_baseIndex + index, count); } public override ArrayList GetRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); return new Range(this, index, count); } public override int IndexOf(object value) { InternalUpdateRange(); int num = _baseList.IndexOf(value, _baseIndex, _baseSize); if (num >= 0) { return num - _baseIndex; } return -1; } public override int IndexOf(object value, int startIndex) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (startIndex < 0) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_NeedNonNegNum); } if (startIndex > _baseSize) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } InternalUpdateRange(); int num = _baseList.IndexOf(value, _baseIndex + startIndex, _baseSize - startIndex); if (num >= 0) { return num - _baseIndex; } return -1; } public override int IndexOf(object value, int startIndex, int count) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (startIndex < 0 || startIndex > _baseSize) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } if (count < 0 || startIndex > _baseSize - count) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_Count); } InternalUpdateRange(); int num = _baseList.IndexOf(value, _baseIndex + startIndex, count); if (num >= 0) { return num - _baseIndex; } return -1; } public override void Insert(int index, object value) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index > _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } InternalUpdateRange(); _baseList.Insert(_baseIndex + index, value); InternalUpdateVersion(); _baseSize++; } public override void InsertRange(int index, System.Collections.ICollection c) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index > _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } if (c == null) { throw new ArgumentNullException("c"); } InternalUpdateRange(); int count = c.Count; if (count > 0) { _baseList.InsertRange(_baseIndex + index, c); _baseSize += count; InternalUpdateVersion(); } } public override int LastIndexOf(object value) { InternalUpdateRange(); int num = _baseList.LastIndexOf(value, _baseIndex + _baseSize - 1, _baseSize); if (num >= 0) { return num - _baseIndex; } return -1; } public override int LastIndexOf(object value, int startIndex) { return LastIndexOf(value, startIndex, startIndex + 1); } public override int LastIndexOf(object value, int startIndex, int count) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) InternalUpdateRange(); if (_baseSize == 0) { return -1; } if (startIndex >= _baseSize) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } if (startIndex < 0) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_NeedNonNegNum); } int num = _baseList.LastIndexOf(value, _baseIndex + startIndex, count); if (num >= 0) { return num - _baseIndex; } return -1; } public override void RemoveAt(int index) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } InternalUpdateRange(); _baseList.RemoveAt(_baseIndex + index); InternalUpdateVersion(); _baseSize--; } public override void RemoveRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); if (count > 0) { _baseList.RemoveRange(_baseIndex + index, count); InternalUpdateVersion(); _baseSize -= count; } } public override void Reverse(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); _baseList.Reverse(_baseIndex + index, count); InternalUpdateVersion(); } public override void SetRange(int index, System.Collections.ICollection c) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) InternalUpdateRange(); if (index < 0 || index >= _baseSize) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } _baseList.SetRange(_baseIndex + index, c); if (c.Count > 0) { InternalUpdateVersion(); } } public override void Sort(int index, int count, IComparer comparer) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_baseSize - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } InternalUpdateRange(); _baseList.Sort(_baseIndex + index, count, comparer); InternalUpdateVersion(); } public override object[] ToArray() { InternalUpdateRange(); if (_baseSize == 0) { return System.Array.Empty<object>(); } object[] array = new object[_baseSize]; System.Array.Copy((System.Array)_baseList._items, _baseIndex, (System.Array)array, 0, _baseSize); return array; } [SecuritySafeCritical] public override System.Array ToArray(System.Type type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (type == null) { throw new ArgumentNullException("type"); } InternalUpdateRange(); System.Array array = System.Array.CreateInstance(type, _baseSize); _baseList.CopyTo(_baseIndex, array, 0, _baseSize); return array; } public override void TrimToSize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(SR.NotSupported_RangeCollection); } } private sealed class ArrayListEnumeratorSimple : System.Collections.IEnumerator { private ArrayList _list; private int _index; private int _version; private object _currentElement; private bool _isArrayList; private static object s_dummyObject = new object(); public object Current { get { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) object currentElement = _currentElement; if (s_dummyObject == currentElement) { if (_index == -1) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } throw new InvalidOperationException(SR.InvalidOperation_EnumEnded); } return currentElement; } } internal ArrayListEnumeratorSimple(ArrayList list) { _list = list; _index = -1; _version = list._version; _isArrayList = ((object)list).GetType() == typeof(ArrayList); _currentElement = s_dummyObject; } public bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } if (_isArrayList) { if (_index < _list._size - 1) { _currentElement = _list._items[++_index]; return true; } _currentElement = s_dummyObject; _index = _list._size; return false; } if (_index < _list.Count - 1) { _currentElement = _list[++_index]; return true; } _index = _list.Count; _currentElement = s_dummyObject; return false; } public void Reset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_version != _list._version) { throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } _currentElement = s_dummyObject; _index = -1; } } internal class ArrayListDebugView { private ArrayList _arrayList; [DebuggerBrowsable(/*Could not decode attribute arguments.*/)] public object[] Items => _arrayList.ToArray(); public ArrayListDebugView(ArrayList arrayList) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (arrayList == null) { throw new ArgumentNullException("arrayList"); } _arrayList = arrayList; } } private object[] _items; private int _size; private int _version; private object _syncRoot; private const int _defaultCapacity = 4; internal const int MaxArrayLength = 2146435071; public virtual int Capacity { get { return _items.Length; } set { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (value < _size) { throw new ArgumentOutOfRangeException("value", SR.ArgumentOutOfRange_SmallCapacity); } if (value == _items.Length) { return; } if (value > 0) { object[] array = new object[value]; if (_size > 0) { System.Array.Copy((System.Array)_items, 0, (System.Array)array, 0, _size); } _items = array; } else { _items = new object[4]; } } } public virtual int Count => _size; public virtual bool IsFixedSize => false; public virtual bool IsReadOnly => false; public virtual bool IsSynchronized => false; public virtual object SyncRoot { get { if (_syncRoot == null) { Interlocked.CompareExchange<object>(ref _syncRoot, new object(), (object)null); } return _syncRoot; } } public virtual object this[int index] { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _size) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } return _items[index]; } set { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _size) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } _items[index] = value; _version++; } } internal ArrayList(bool trash) { } public ArrayList() { _items = System.Array.Empty<object>(); } public ArrayList(int capacity) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (capacity < 0) { throw new ArgumentOutOfRangeException("capacity", SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, "capacity")); } if (capacity == 0) { _items = System.Array.Empty<object>(); } else { _items = new object[capacity]; } } public ArrayList(System.Collections.ICollection c) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c", SR.ArgumentNull_Collection); } int count = c.Count; if (count == 0) { _items = System.Array.Empty<object>(); return; } _items = new object[count]; AddRange(c); } public static ArrayList Adapter(System.Collections.IList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new IListWrapper(list); } public virtual int Add(object value) { if (_size == _items.Length) { EnsureCapacity(_size + 1); } _items[_size] = value; _version++; return _size++; } public virtual void AddRange(System.Collections.ICollection c) { InsertRange(_size, c); } public virtual int BinarySearch(int index, int count, object value, IComparer comparer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return System.Array.BinarySearch((System.Array)_items, index, count, value, comparer); } public virtual int BinarySearch(object value) { return BinarySearch(0, Count, value, null); } public virtual int BinarySearch(object value, IComparer comparer) { return BinarySearch(0, Count, value, comparer); } public virtual void Clear() { if (_size > 0) { System.Array.Clear((System.Array)_items, 0, _size); _size = 0; } _version++; } public virtual object Clone() { ArrayList arrayList = new ArrayList(_size); arrayList._size = _size; arrayList._version = _version; System.Array.Copy((System.Array)_items, 0, (System.Array)arrayList._items, 0, _size); return arrayList; } public virtual bool Contains(object item) { if (item == null) { for (int i = 0; i < _size; i++) { if (_items[i] == null) { return true; } } return false; } for (int j = 0; j < _size; j++) { if (_items[j] != null && _items[j].Equals(item)) { return true; } } return false; } public virtual void CopyTo(System.Array array) { CopyTo(array, 0); } public virtual void CopyTo(System.Array array, int arrayIndex) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (array != null && array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } System.Array.Copy((System.Array)_items, 0, array, arrayIndex, _size); } public virtual void CopyTo(int index, System.Array array, int arrayIndex, int count) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (array != null && array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } System.Array.Copy((System.Array)_items, index, array, arrayIndex, count); } private void EnsureCapacity(int min) { if (_items.Length < min) { int num = ((_items.Length == 0) ? 4 : (_items.Length * 2)); if ((uint)num > 2146435071u) { num = 2146435071; } if (num < min) { num = min; } Capacity = num; } } public static System.Collections.IList FixedSize(System.Collections.IList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new FixedSizeList(list); } public static ArrayList FixedSize(ArrayList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new FixedSizeArrayList(list); } public virtual System.Collections.IEnumerator GetEnumerator() { return new ArrayListEnumeratorSimple(this); } public virtual System.Collections.IEnumerator GetEnumerator(int index, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new ArrayListEnumerator(this, index, count); } public virtual int IndexOf(object value) { return System.Array.IndexOf((System.Array)_items, value, 0, _size); } public virtual int IndexOf(object value, int startIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (startIndex > _size) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } return System.Array.IndexOf((System.Array)_items, value, startIndex, _size - startIndex); } public virtual int IndexOf(object value, int startIndex, int count) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (startIndex > _size) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } if (count < 0 || startIndex > _size - count) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_Count); } return System.Array.IndexOf((System.Array)_items, value, startIndex, count); } public virtual void Insert(int index, object value) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index > _size) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_ArrayListInsert); } if (_size == _items.Length) { EnsureCapacity(_size + 1); } if (index < _size) { System.Array.Copy((System.Array)_items, index, (System.Array)_items, index + 1, _size - index); } _items[index] = value; _size++; _version++; } public virtual void InsertRange(int index, System.Collections.ICollection c) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c", SR.ArgumentNull_Collection); } if (index < 0 || index > _size) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } int count = c.Count; if (count > 0) { EnsureCapacity(_size + count); if (index < _size) { System.Array.Copy((System.Array)_items, index, (System.Array)_items, index + count, _size - index); } object[] array = new object[count]; c.CopyTo((System.Array)array, 0); ((System.Array)array).CopyTo((System.Array)_items, index); _size += count; _version++; } } public virtual int LastIndexOf(object value) { return LastIndexOf(value, _size - 1, _size); } public virtual int LastIndexOf(object value, int startIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (startIndex >= _size) { throw new ArgumentOutOfRangeException("startIndex", SR.ArgumentOutOfRange_Index); } return LastIndexOf(value, startIndex, startIndex + 1); } public virtual int LastIndexOf(object value, int startIndex, int count) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (Count != 0 && (startIndex < 0 || count < 0)) { throw new ArgumentOutOfRangeException((startIndex < 0) ? "startIndex" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size == 0) { return -1; } if (startIndex >= _size || count > startIndex + 1) { throw new ArgumentOutOfRangeException((startIndex >= _size) ? "startIndex" : "count", SR.ArgumentOutOfRange_BiggerThanCollection); } return System.Array.LastIndexOf((System.Array)_items, value, startIndex, count); } public static System.Collections.IList ReadOnly(System.Collections.IList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new ReadOnlyList(list); } public static ArrayList ReadOnly(ArrayList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new ReadOnlyArrayList(list); } public virtual void Remove(object obj) { int num = IndexOf(obj); if (num >= 0) { RemoveAt(num); } } public virtual void RemoveAt(int index) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= _size) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } _size--; if (index < _size) { System.Array.Copy((System.Array)_items, index + 1, (System.Array)_items, index, _size - index); } _items[_size] = null; _version++; } public virtual void RemoveRange(int index, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } if (count > 0) { int num = _size; _size -= count; if (index < _size) { System.Array.Copy((System.Array)_items, index + count, (System.Array)_items, index, _size - index); } while (num > _size) { _items[--num] = null; } _version++; } } public static ArrayList Repeat(object value, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } ArrayList arrayList = new ArrayList((count > 4) ? count : 4); for (int i = 0; i < count; i++) { arrayList.Add(value); } return arrayList; } public virtual void Reverse() { Reverse(0, Count); } public virtual void Reverse(int index, int count) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } System.Array.Reverse((System.Array)_items, index, count); _version++; } public virtual void SetRange(int index, System.Collections.ICollection c) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (c == null) { throw new ArgumentNullException("c", SR.ArgumentNull_Collection); } int count = c.Count; if (index < 0 || index > _size - count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } if (count > 0) { c.CopyTo((System.Array)_items, index); _version++; } } public virtual ArrayList GetRange(int index, int count) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || count < 0) { throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } return new Range(this, index, count); } public virtual void Sort() { Sort(0, Count, (IComparer)(object)Comparer.Default); } public virtual void Sort(IComparer comparer) { Sort(0, Count, comparer); } public virtual void Sort(int index, int count, IComparer comparer) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (index < 0) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_NeedNonNegNum); } if (count < 0) { throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); } if (_size - index < count) { throw new ArgumentException(SR.Argument_InvalidOffLen); } System.Array.Sort((System.Array)_items, index, count, comparer); _version++; } public static System.Collections.IList Synchronized(System.Collections.IList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new SyncIList(list); } public static ArrayList Synchronized(ArrayList list) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (list == null) { throw new ArgumentNullException("list"); } return new SyncArrayList(list); } public virtual object[] ToArray() { if (_size == 0) { return System.Array.Empty<object>(); } object[] array = new object[_size]; System.Array.Copy((System.Array)_items, 0, (System.Array)array, 0, _size); return array; } [SecuritySafeCritical] public virtual System.Array ToArray(System.Type type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (type == null) { throw new ArgumentNullException("type"); } System.Array array = System.Array.CreateInstance(type, _size); System.Array.Copy((System.Array)_items, 0, array, 0, _size); return array; } public virtual void TrimToSize() { Capacity = _size; } } public class CaseInsensitiveComparer : IComparer { private CompareInfo _compareInfo; private static volatile CaseInsensitiveComparer s_InvariantCaseInsensitiveComparer; public static CaseInsensitiveComparer Default => new CaseInsensitiveComparer(CultureInfo.CurrentCulture); public static CaseInsensitiveComparer DefaultInvariant { get { if (s_InvariantCaseInsensitiveComparer == null) { s_InvariantCaseInsensitiveComparer = new CaseInsensitiveComparer(CultureInfo.InvariantCulture); } return s_InvariantCaseInsensitiveComparer; } } public CaseInsensitiveComparer() { _compareInfo = CultureInfo.CurrentCulture.CompareInfo; } public CaseInsensitiveComparer(CultureInfo culture) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (culture == null) { throw new ArgumentNullException("culture"); } _compareInfo = culture.CompareInfo; } public int Compare(object a, object b) { string text = a as string; string text2 = b as string; if (text != null && text2 != null) { return _compareInfo.Compare(text, text2, (CompareOptions)1); } return Comparer.Default.Compare(a, b); } } public abstract class CollectionBase : System.Collections.IList, System.Collections.ICollection, System.Collections.IEnumerable { private ArrayList _list; protected ArrayList InnerList => _list; protected System.Collections.IList List => this; public int Capacity { get { return InnerList.Capacity; } set { InnerList.Capacity = value; } } public int Count => _list.Count; bool System.Collections.IList.IsReadOnly => InnerList.IsReadOnly; bool System.Collections.IList.IsFixedSize => InnerList.IsFixedSize; bool System.Collections.ICollection.IsSynchronized => InnerList.IsSynchronized; object System.Collections.ICollection.SyncRoot => InnerList.SyncRoot; object System.Collections.IList.this[int index] { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } return InnerList[index]; } set { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } OnValidate(value); object obj = InnerList[index]; OnSet(index, obj, value); InnerList[index] = value; try { OnSetComplete(index, obj, value); } catch { InnerList[index] = obj; throw; } } } protected CollectionBase() { _list = new ArrayList(); } protected CollectionBase(int capacity) { _list = new ArrayList(capacity); } public void Clear() { OnClear(); InnerList.Clear(); OnClearComplete(); } public void RemoveAt(int index) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } object value = InnerList[index]; OnValidate(value); OnRemove(index, value); InnerList.RemoveAt(index); try { OnRemoveComplete(index, value); } catch { InnerList.Insert(index, value); throw; } } void System.Collections.ICollection.CopyTo(System.Array array, int index) { InnerList.CopyTo(array, index); } bool System.Collections.IList.Contains(object value) { return InnerList.Contains(value); } int System.Collections.IList.Add(object value) { OnValidate(value); OnInsert(InnerList.Count, value); int num = InnerList.Add(value); try { OnInsertComplete(num, value); return num; } catch { InnerList.RemoveAt(num); throw; } } void System.Collections.IList.Remove(object value) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) OnValidate(value); int num = InnerList.IndexOf(value); if (num < 0) { throw new ArgumentException(SR.Arg_RemoveArgNotFound); } OnRemove(num, value); InnerList.RemoveAt(num); try { OnRemoveComplete(num, value); } catch { InnerList.Insert(num, value); throw; } } int System.Collections.IList.IndexOf(object value) { return InnerList.IndexOf(value); } void System.Collections.IList.Insert(int index, object value) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (index < 0 || index > Count) { throw new ArgumentOutOfRangeException("index", SR.ArgumentOutOfRange_Index); } OnValidate(value); OnInsert(index, value); InnerList.Insert(index, value); try { OnInsertComplete(index, value); } catch { InnerList.RemoveAt(index); throw; } } public System.Collections.IEnumerator GetEnumerator() { return InnerList.GetEnumerator(); } protected virtual void OnSet(int index, object oldValue, object newValue) { } protected virtual void OnInsert(int index, object value) { } protected virtual void OnClear() { } protected virtual void OnRemove(int index, object value) { } protected virtual void OnValidate(object value) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (value == null) { throw new ArgumentNullException("value"); } } protected virtual void OnSetComplete(int index, object oldValue, object newValue) { } protected virtual void OnInsertComplete(int index, object value) { } protected virtual void OnClearComplete() { } protected virtual void OnRemoveComplete(int index, object value) { } } public sealed class Comparer : IComparer { private CompareInfo _compareInfo; public static readonly Comparer Default = new Comparer(CultureInfo.CurrentCulture); public static readonly Comparer DefaultInvariant = new Comparer(CultureInfo.InvariantCulture); private const string CompareInfoName = "CompareInfo"; public Comparer(CultureInfo culture) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (culture == null) { throw new ArgumentNullException("culture"); } _compareInfo = culture.CompareInfo; } public int Compare(object a, object b) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (a == b) { return 0; } if (a == null) { return -1; } if (b == null) { return 1; } string text = a as string; string text2 = b as string; if (text != null && text2 != null) { return _compareInfo.Compare(text, text2); } IComparable val = (IComparable)((a is IComparable) ? a : null); if (val != null) { return val.CompareTo(b); } IComparable val2 = (IComparable)((b is IComparable) ? b : null); if (val2 != null) { return -val2.CompareTo(a); } throw new ArgumentException(SR.Argument_ImplementIComparable); } } public abstract class DictionaryBase : IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { private Hashtable _hashtable; protected Hashtable InnerHashtable { get { if (_hashtable == null) { _hashtable = new Hashtable(); } return _hashtable; } } protected IDictionary Dictionary => (IDictionary)(object)this; public int Count { get { if (_hashtable != null) { return _hashtable.Count; } return 0; } } bool IDictionary.IsReadOnly => InnerHashtable.IsReadOnly; bool IDictionary.IsFixedSize => InnerHashtable.IsFixedSize; bool System.Collections.ICollection.IsSynchronized => InnerHashtable.IsSynchronized; System.Collections.ICollection IDictionary.Keys => InnerHashtable.Keys; object System.Collections.ICollection.SyncRoot => InnerHashtable.SyncRoot; System.Collections.ICollection IDictionary.Values => InnerHashtable.Values; object IDictionary.this[object key] { get { object obj = InnerHashtable[key]; OnGet(key, obj); return obj; } set { OnValidate(key, value); bool flag = true; object obj = InnerHashtable[key]; if (obj == null) { flag = InnerHashtable.Contains(key); } OnSet(key, obj, value); InnerHashtable[key] = value; try { OnSetComplete(key, obj, value); } catch { if (flag) { InnerHashtable[key] = obj; } else { InnerHashtable.Remove(key); } throw; } } } public void CopyTo(System.Array array, int index) { InnerHashtable.CopyTo(array, index); } bool IDictionary.Contains(object key) { return InnerHashtable.Contains(key); } void IDictionary.Add(object key, object value) { OnValidate(key, value); OnInsert(key, value); InnerHashtable.Add(key, value); try { OnInsertComplete(key, value); } catch { InnerHashtable.Remove(key); throw; } } public void Clear() { OnClear(); InnerHashtable.Clear(); OnClearComplete(); } void IDictionary.Remove(object key) { if (InnerHashtable.Contains(key)) { object value = InnerHashtable[key]; OnValidate(key, value); OnRemove(key, value); InnerHashtable.Remove(key); try { OnRemoveComplete(key, value); } catch { InnerHashtable.Add(key, value); throw; } } } public IDictionaryEnumerator GetEnumerator() { return InnerHashtable.GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)InnerHashtable.GetEnumerator(); } protected virtual object OnGet(object key, object currentValue) { return currentValue; } protected virtual void OnSet(object key, object oldValue, object newValue) { } protected virtual void OnInsert(object key, object value) { } protected virtual void OnClear() { } protected virtual void OnRemove(object key, object value) { } protected virtual void OnValidate(object key, object value) { } protected virtual void OnSetComplete(object key, object oldValue, object newValue) { } protected virtual void OnInsertComplete(object key, object value) { } protected virtual void OnClearComplete() { } protected virtual void OnRemoveComplete(object key, object value) { } } [DefaultMember("Item")] [DebuggerTypeProxy(typeof(HashtableDebugView))] [DebuggerDisplay("Count = {Count}")] public class Hashtable : IDictionary, System.Collections.ICollection, System.Collections.IEnumerable { private struct bucket { public object key; public object val; public int hash_coll; } private class KeyCollection : System.Collections.ICollection, System.Collections.IEnumerable { private Hashtable _hashtable; public virtual bool IsSynchronized => _hashtable.IsSynchronized; public virtual object SyncRoot => _hashtable.SyncRoot; public virtual int Count => _hashtable._count; internal KeyCollection(Hashtable hashtable) { _hashtable = hashtable; } public virtual void CopyTo(System.Array array, int arrayIndex) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex", SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - arrayIndex < _hashtable._count) { throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); } _hashtable.CopyKeys(array, arrayIndex); } public virtual System.Collections.IEnumerator GetEnumerator() { return new HashtableEnumerator(_hashtable, 1); } } private class ValueCollection : System.Collections.ICollection, System.Collections.IEnumerable { private Hashtable _hashtable; public virtual bool IsSynchronized => _hashtable.IsSynchronized; public virtual object SyncRoot => _hashtable.SyncRoot; public virtual int Count => _hashtable._count; internal ValueCollection(Hashtable hashtable) { _hashtable = hashtable; } public virtual void CopyTo(System.Array array, int arrayIndex) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (array == null) { throw new ArgumentNullException("array"); } if (array.Rank != 1) { throw new ArgumentException(SR.Arg_RankMultiDimNotSupported, "array"); } if (arrayIndex < 0) { throw new ArgumentOutOfRangeException("arrayIndex", SR.ArgumentOutOfRange_NeedNonNegNum); } if (array.Length - arrayIndex < _hashtable._count) { throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); } _hashtable.CopyValues(array, arrayIndex); } public virtual System.Collections.IEnumerator GetEnumerator() { return new HashtableEnumerator(_hashtable, 2); } } [DefaultMember("Item")] private class SyncHashtable : Hashtable, System.Collections.IEnumerable { protected Hashtable _table; public override int Count => _table.Count; public override bool IsReadOnly => _table.IsReadOnly; public override bool IsFixedSize => _table.IsFixedSize; public override bool IsSynchronized => true; public override object this[object key] { get { return _table[key]; } set { lock (_table.SyncRoot) { _table[key] = value; } } } public override object SyncRoot => _table.SyncRoot; public override System.Collections.ICollection Keys { get { lock (_table.SyncRoot) { return _table.Keys; } } } public override System.Collections.ICollection Values { get { lock (_table.SyncRoot) { return _table.Values; } } } internal SyncHashtable(Hashtable table) : base(trash: false) { _table = table; } public override void Add(object key, object value) { lock (_table.SyncRoot) { _table.Add(key, value); } } public override void Clear() { lock (_table.SyncRoot) { _table.Clear(); } } public override bool Contains(object key) { return _table.Contains(key); } public override bool ContainsKey(object key) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (key == null) { throw new ArgumentNullException("key", SR.ArgumentNull_Key); } return _table.ContainsKey(key); } public override bool ContainsValue(object key) { lock (_table.SyncRoot) { return _table.ContainsValue(key); } } public override void CopyTo(System.Array array, int arrayIndex) { lock (_table.SyncRoot) { _table.CopyTo(array, arrayIndex); } } public override object Clone() { lock (_table.SyncRoot) { return Synchronized((Hashtable)_table.Clone()); } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)_table.GetEnumerator(); } public override IDictionaryEnumerator GetEnumerator() { return _table.GetEnumerator(); } public override void Remove(object key) { lock (_table.SyncRoot) { _table.Remove(key); } } internal override KeyValuePairs[] ToKeyValuePairsArray() { return _table.ToKeyValuePairsArray(); } } private class HashtableEnumerator : IDictionaryEnumerator, System.Collections.IEnumerator { private Hashtable _hashtable; private int _bucket; private int _version; private bool _current; private int _getObjectRetType; private object _currentKey; private object _currentValue; internal const int Keys = 1; internal const int Values = 2; internal const int DictEntry = 3; public virtual object Key { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!_current) { throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); } return _currentKey; } } public virtual DictionaryEntry Entry { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!_current) { throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return new DictionaryEntry(_currentKey, _currentValue); } } public virtual object Current { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!_current) { throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } if (_getObjectRetType == 1) { return _currentKey; } if (_getObjectRetType == 2) { return _currentValue; } return (object)new DictionaryEntry(_currentKey, _currentValue); } } public virtual object Value { get { //IL_000d: Unknown result type (might be due to invalid IL or missing references) i
BepInEx/plugins/DearImGuiInjection/System.Reflection.TypeExtensions.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using FxResources.System.Reflection.TypeExtensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyDefaultAlias("System.Reflection.TypeExtensions")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Reflection.TypeExtensions")] [assembly: AssemblyFileVersion("4.700.19.56404")] [assembly: AssemblyInformationalVersion("3.1.0+0f7f38c4fd323b26da10cce95f857f77f0f09b48")] [assembly: AssemblyProduct("Microsoft® .NET Core")] [assembly: AssemblyTitle("System.Reflection.TypeExtensions")] [assembly: CLSCompliant(true)] [assembly: AssemblyVersion("4.1.5.0")] [assembly: TypeForwardedTo(typeof(BindingFlags))] namespace FxResources.System.Reflection.TypeExtensions { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR))); internal static string NoMetadataTokenAvailable => GetResourceString("NoMetadataTokenAvailable"); internal static string PlatformNotSupported_ReflectionTypeExtensions => GetResourceString("PlatformNotSupported_ReflectionTypeExtensions"); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString = null) { if (UsingResourceKeys()) { return defaultString ?? resourceKey; } string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text)) { return defaultString; } return text; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(IFormatProvider provider, string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(provider, resourceFormat, p1); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(provider, resourceFormat, p1, p2); } internal static string Format(IFormatProvider provider, string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(provider, resourceFormat, p1, p2, p3); } internal static string Format(IFormatProvider provider, string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + ", " + string.Join(", ", args); } return string.Format(provider, resourceFormat, args); } return resourceFormat; } } } namespace System.Reflection { internal static class Requires { internal static void NotNull(object obj, string name) { if (obj == null) { throw new ArgumentNullException(name); } } } public static class TypeExtensions { public static ConstructorInfo GetConstructor(Type type, Type[] types) { Requires.NotNull(type, "type"); return type.GetConstructor(types); } public static ConstructorInfo[] GetConstructors(Type type) { Requires.NotNull(type, "type"); return type.GetConstructors(); } public static ConstructorInfo[] GetConstructors(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetConstructors(bindingAttr); } public static MemberInfo[] GetDefaultMembers(Type type) { Requires.NotNull(type, "type"); return type.GetDefaultMembers(); } public static EventInfo GetEvent(Type type, string name) { Requires.NotNull(type, "type"); return type.GetEvent(name); } public static EventInfo GetEvent(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetEvent(name, bindingAttr); } public static EventInfo[] GetEvents(Type type) { Requires.NotNull(type, "type"); return type.GetEvents(); } public static EventInfo[] GetEvents(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetEvents(bindingAttr); } public static FieldInfo GetField(Type type, string name) { Requires.NotNull(type, "type"); return type.GetField(name); } public static FieldInfo GetField(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetField(name, bindingAttr); } public static FieldInfo[] GetFields(Type type) { Requires.NotNull(type, "type"); return type.GetFields(); } public static FieldInfo[] GetFields(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetFields(bindingAttr); } public static Type[] GetGenericArguments(Type type) { Requires.NotNull(type, "type"); return type.GetGenericArguments(); } public static Type[] GetInterfaces(Type type) { Requires.NotNull(type, "type"); return type.GetInterfaces(); } public static MemberInfo[] GetMember(Type type, string name) { Requires.NotNull(type, "type"); return type.GetMember(name); } public static MemberInfo[] GetMember(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetMember(name, bindingAttr); } public static MemberInfo[] GetMembers(Type type) { Requires.NotNull(type, "type"); return type.GetMembers(); } public static MemberInfo[] GetMembers(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetMembers(bindingAttr); } public static MethodInfo GetMethod(Type type, string name) { Requires.NotNull(type, "type"); return type.GetMethod(name); } public static MethodInfo GetMethod(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetMethod(name, bindingAttr); } public static MethodInfo GetMethod(Type type, string name, Type[] types) { Requires.NotNull(type, "type"); return type.GetMethod(name, types); } public static MethodInfo[] GetMethods(Type type) { Requires.NotNull(type, "type"); return type.GetMethods(); } public static MethodInfo[] GetMethods(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetMethods(bindingAttr); } public static Type GetNestedType(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetNestedType(name, bindingAttr); } public static Type[] GetNestedTypes(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetNestedTypes(bindingAttr); } public static PropertyInfo[] GetProperties(Type type) { Requires.NotNull(type, "type"); return type.GetProperties(); } public static PropertyInfo[] GetProperties(Type type, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetProperties(bindingAttr); } public static PropertyInfo GetProperty(Type type, string name) { Requires.NotNull(type, "type"); return type.GetProperty(name); } public static PropertyInfo GetProperty(Type type, string name, BindingFlags bindingAttr) { Requires.NotNull(type, "type"); return type.GetProperty(name, bindingAttr); } public static PropertyInfo GetProperty(Type type, string name, Type returnType) { Requires.NotNull(type, "type"); return type.GetProperty(name, returnType); } public static PropertyInfo GetProperty(Type type, string name, Type returnType, Type[] types) { Requires.NotNull(type, "type"); return type.GetProperty(name, returnType, types); } public static bool IsAssignableFrom(Type type, Type c) { Requires.NotNull(type, "type"); return type.IsAssignableFrom(c); } public static bool IsInstanceOfType(Type type, object o) { Requires.NotNull(type, "type"); return type.IsInstanceOfType(o); } } public static class AssemblyExtensions { public static Type[] GetExportedTypes(Assembly assembly) { Requires.NotNull(assembly, "assembly"); return assembly.GetExportedTypes(); } public static Module[] GetModules(Assembly assembly) { Requires.NotNull(assembly, "assembly"); return assembly.GetModules(); } public static Type[] GetTypes(Assembly assembly) { Requires.NotNull(assembly, "assembly"); return assembly.GetTypes(); } } public static class EventInfoExtensions { public static MethodInfo GetAddMethod(EventInfo eventInfo) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetAddMethod(); } public static MethodInfo GetAddMethod(EventInfo eventInfo, bool nonPublic) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetAddMethod(nonPublic); } public static MethodInfo GetRaiseMethod(EventInfo eventInfo) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetRaiseMethod(); } public static MethodInfo GetRaiseMethod(EventInfo eventInfo, bool nonPublic) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetRaiseMethod(nonPublic); } public static MethodInfo GetRemoveMethod(EventInfo eventInfo) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetRemoveMethod(); } public static MethodInfo GetRemoveMethod(EventInfo eventInfo, bool nonPublic) { Requires.NotNull(eventInfo, "eventInfo"); return eventInfo.GetRemoveMethod(nonPublic); } } public static class MemberInfoExtensions { public static bool HasMetadataToken(this MemberInfo member) { Requires.NotNull(member, "member"); try { return GetMetadataTokenOrZeroOrThrow(member) != 0; } catch (InvalidOperationException) { return false; } } public static int GetMetadataToken(this MemberInfo member) { Requires.NotNull(member, "member"); int metadataTokenOrZeroOrThrow = GetMetadataTokenOrZeroOrThrow(member); if (metadataTokenOrZeroOrThrow == 0) { throw new InvalidOperationException(System.SR.NoMetadataTokenAvailable); } return metadataTokenOrZeroOrThrow; } private static int GetMetadataTokenOrZeroOrThrow(MemberInfo member) { int metadataToken = member.MetadataToken; if ((metadataToken & 0xFFFFFF) == 0) { return 0; } return metadataToken; } } public static class MethodInfoExtensions { public static MethodInfo GetBaseDefinition(MethodInfo method) { Requires.NotNull(method, "method"); return method.GetBaseDefinition(); } } public static class ModuleExtensions { public static bool HasModuleVersionId(this Module module) { Requires.NotNull(module, "module"); return true; } public static Guid GetModuleVersionId(this Module module) { Requires.NotNull(module, "module"); return module.ModuleVersionId; } } public static class PropertyInfoExtensions { public static MethodInfo[] GetAccessors(PropertyInfo property) { Requires.NotNull(property, "property"); return property.GetAccessors(); } public static MethodInfo[] GetAccessors(PropertyInfo property, bool nonPublic) { Requires.NotNull(property, "property"); return property.GetAccessors(nonPublic); } public static MethodInfo GetGetMethod(PropertyInfo property) { Requires.NotNull(property, "property"); return property.GetGetMethod(); } public static MethodInfo GetGetMethod(PropertyInfo property, bool nonPublic) { Requires.NotNull(property, "property"); return property.GetGetMethod(nonPublic); } public static MethodInfo GetSetMethod(PropertyInfo property) { Requires.NotNull(property, "property"); return property.GetSetMethod(); } public static MethodInfo GetSetMethod(PropertyInfo property, bool nonPublic) { Requires.NotNull(property, "property"); return property.GetSetMethod(nonPublic); } } }
BepInEx/plugins/DearImGuiInjection/NativeMemory.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("NativeMemory")] [assembly: AssemblyConfiguration("netstandard2.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+af1e9534c67088d11779ad09d1aab2c19226e34a")] [assembly: AssemblyProduct("NativeMemory")] [assembly: AssemblyTitle("NativeMemory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace NativeMemory { public static class Allocator { public static IntPtr AllocAndCopy(byte[] array) { IntPtr intPtr = Marshal.AllocHGlobal(array.Length); Marshal.Copy(array, 0, intPtr, array.Length); return intPtr; } public static IntPtr AllocAndZeroMemory(uint byteCount) { IntPtr intPtr = Marshal.AllocHGlobal((int)byteCount); byte[] array = new byte[byteCount]; Marshal.Copy(array, 0, intPtr, array.Length); return intPtr; } } public static class StringBytePattern { public static byte?[] ParseHexBytes(this string str) { List<byte?> list = new List<byte?>(); StringReader stringReader = new StringReader(str); while (stringReader.Peek() > 0) { char c = char.ToLower((char)stringReader.Read()); if (char.IsWhiteSpace(c)) { continue; } switch (c) { case ';': stringReader.ReadLine(); continue; case '?': list.Add(null); stringReader.Read(); continue; } if (IsHexChar(c) && stringReader.Peek() > 0) { char c2 = char.ToLower((char)stringReader.Peek()); if (IsHexChar(c2)) { stringReader.Read(); list.Add(byte.Parse($"{c}{c2}", NumberStyles.HexNumber)); } } } return list.ToArray(); static bool IsHexChar(char lowerC) { if ('0' > lowerC || lowerC > '9') { if ('a' <= lowerC) { return lowerC <= 'f'; } return false; } return true; } } } public class BytePattern { private readonly byte?[] Pattern; private readonly int[] JumpTable; public int Length => Pattern.Length; public bool IsE8 => ((int?)Pattern[0]).GetValueOrDefault() == 232; public BytePattern(string bytes) { Pattern = bytes.ParseHexBytes(); JumpTable = CreateJumpTable(); } public BytePattern(byte[] bytes) { Pattern = bytes.Cast<byte?>().ToArray(); JumpTable = CreateJumpTable(); } public static implicit operator BytePattern(string pattern) { return new BytePattern(pattern); } public static implicit operator BytePattern(byte[] pattern) { return new BytePattern(pattern); } private int[] CreateJumpTable() { int[] array = new int[Pattern.Length]; int num = 0; array[0] = -1; int num2 = 1; while (num2 < Pattern.Length) { if (Pattern[num2] == Pattern[num]) { array[num2] = array[num]; } else { array[num2] = num; while (num >= 0 && Pattern[num2] != Pattern[num]) { num = array[num]; } } num2++; num++; } return array; } public unsafe IntPtr Match(IntPtr startAddress, long size) { byte* ptr = (byte*)startAddress.ToPointer(); long num = 0L; long num2 = 0L; while (num < size) { if (!Pattern[num2].HasValue || ptr[num] == Pattern[num2]) { num++; num2++; if (num2 == Pattern.Length) { return new IntPtr(num - num2); } } else { num2 = JumpTable[num2]; if (num2 < 0) { num++; num2++; } } } return IntPtr.Zero; } } public static class IntPtrExtensions { public static IntPtr Add(this IntPtr ptr, nint offset) { return new IntPtr((nint)ptr + offset); } public static IntPtr Sub(this IntPtr ptr, nint offset) { return new IntPtr((nint)ptr - offset); } public unsafe static IntPtr Rip(this IntPtr ptr) { return ptr.Add(*(int*)(void*)ptr).Add(4); } } internal static class Log { internal const string Prefix = "[NativeMemory] "; internal static void Debug(object data) { WriteLine(data, ConsoleColor.White); } internal static void Error(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Fatal(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Info(object data) { WriteLine(data, ConsoleColor.White); } internal static void Message(object data) { WriteLine(data, ConsoleColor.White); } internal static void Warning(object data) { WriteLine(data, ConsoleColor.Yellow); } private static void WriteLine(object data, ConsoleColor color) { Console.ForegroundColor = color; Console.WriteLine("[NativeMemory] " + data); Console.ResetColor(); } } public class PatternBatch { internal struct Entry { internal string Name; internal BytePattern BytePattern; internal Action<IntPtr> OnCompletion; internal Entry(string name, BytePattern bytePattern, Action<IntPtr> onCompletion) { Name = name; BytePattern = bytePattern; OnCompletion = onCompletion; } } private readonly List<Entry> Entries = new List<Entry>(); public IntPtr StartAddress { get; } public long Size { get; } internal PatternBatch(IntPtr startAddress, long size) { StartAddress = startAddress; Size = size; } public void Add(string name, BytePattern bytePattern, Action<IntPtr> onCompletion) { Entries.Add(new Entry(name, bytePattern, onCompletion)); } public void Run() { foreach (Entry entry in Entries) { IntPtr intPtr = entry.BytePattern.Match(StartAddress, Size); if (intPtr == IntPtr.Zero) { Log.Error("BytePattern " + entry.Name + " failed."); continue; } try { entry.OnCompletion?.Invoke(intPtr); } catch (Exception arg) { Log.Error($"{arg}"); } } } } }
BepInEx/plugins/DearImGuiInjection/SharpDX.Direct3D12.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Mathematics.Interop; using SharpDX.Win32; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyInformationalVersion("4.2.1-beta0+7abb72df54")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("Alexandre Mutel")] [assembly: AssemblyConfiguration("Release")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyFileVersion("4.2.1.34")] [assembly: ComVisible(false)] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xiaoxiao921/SharpDX")] [assembly: AssemblyTitle("SharpDX.Direct3D12")] [assembly: AssemblyProduct("SharpDX.Direct3D12")] [assembly: AssemblyDescription("Assembly providing DirectX - Direct3D12 managed API.")] [assembly: AssemblyCopyright("Copyright (c) 2010-2016 Alexandre Mutel")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.2.0.0")] [module: UnverifiableCode] internal sealed class ThisAssembly { internal const string AssemblyVersion = "4.2.0.0"; internal const string AssemblyFileVersion = "4.2.1.34"; internal const string AssemblyInformationalVersion = "4.2.1-beta0+7abb72df54"; internal const string AssemblyName = "SharpDX.Direct3D12"; internal const string AssemblyTitle = "SharpDX.Direct3D12"; internal const string AssemblyConfiguration = "Release"; internal const string GitCommitId = "7abb72df544eaede656c546ee71a8ad1be9dd19b"; internal const string RootNamespace = "SharpDX.Direct3D12"; private ThisAssembly() { } } namespace SharpDX.Direct3D12 { public struct BlendStateDescription { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct __Native { public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; public RenderTargetBlendDescription RenderTarget; public RenderTargetBlendDescription __RenderTarget1; public RenderTargetBlendDescription __RenderTarget2; public RenderTargetBlendDescription __RenderTarget3; public RenderTargetBlendDescription __RenderTarget4; public RenderTargetBlendDescription __RenderTarget5; public RenderTargetBlendDescription __RenderTarget6; public RenderTargetBlendDescription __RenderTarget7; } public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; internal RenderTargetBlendDescription[] _RenderTarget; public RenderTargetBlendDescription[] RenderTarget { get { return _RenderTarget ?? (_RenderTarget = new RenderTargetBlendDescription[8]); } private set { _RenderTarget = value; } } public static BlendStateDescription Default() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription blendStateDescription = default(BlendStateDescription); blendStateDescription.AlphaToCoverageEnable = RawBool.op_Implicit(false); blendStateDescription.IndependentBlendEnable = RawBool.op_Implicit(false); BlendStateDescription result = blendStateDescription; RenderTargetBlendDescription[] renderTarget = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget[i].IsBlendEnabled = RawBool.op_Implicit(false); renderTarget[i].SourceBlend = BlendOption.One; renderTarget[i].DestinationBlend = BlendOption.Zero; renderTarget[i].BlendOperation = BlendOperation.Add; renderTarget[i].SourceAlphaBlend = BlendOption.One; renderTarget[i].DestinationAlphaBlend = BlendOption.Zero; renderTarget[i].AlphaBlendOperation = BlendOperation.Add; renderTarget[i].RenderTargetWriteMask = ColorWriteMaskFlags.All; } return result; } public BlendStateDescription Clone() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription blendStateDescription = default(BlendStateDescription); blendStateDescription.AlphaToCoverageEnable = AlphaToCoverageEnable; blendStateDescription.IndependentBlendEnable = IndependentBlendEnable; BlendStateDescription result = blendStateDescription; RenderTargetBlendDescription[] renderTarget = RenderTarget; RenderTargetBlendDescription[] renderTarget2 = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget2[i] = renderTarget[i]; } return result; } internal void __MarshalFree(ref __Native @ref) { } internal unsafe void __MarshalFrom(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AlphaToCoverageEnable = @ref.AlphaToCoverageEnable; IndependentBlendEnable = @ref.IndependentBlendEnable; fixed (RenderTargetBlendDescription* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr2, (IntPtr)ptr4, 8 * Unsafe.SizeOf<RenderTargetBlendDescription>()); } } } internal unsafe void __MarshalTo(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) @ref.AlphaToCoverageEnable = AlphaToCoverageEnable; @ref.IndependentBlendEnable = IndependentBlendEnable; fixed (RenderTargetBlendDescription* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr4, (IntPtr)ptr2, 8 * Unsafe.SizeOf<RenderTargetBlendDescription>()); } } } } public class BuildRaytracingAccelerationStructureInputs { internal struct __Native { public RaytracingAccelerationStructureType Type; public RaytracingAccelerationStructureBuildFlags Flags; public int NumDescs; public ElementsLayout DescsLayout; public IntPtr Ptr; internal void __MarshalFree() { if (Ptr != IntPtr.Zero) { Marshal.FreeHGlobal(Ptr); } } } public RaytracingAccelerationStructureType Type { get; set; } public RaytracingAccelerationStructureBuildFlags Flags { get; set; } public int DescriptorsCount { get; set; } public ElementsLayout Layout { get; set; } public long InstanceDescriptions { get; set; } public RaytracingGeometryDescription[] GeometryDescriptions { get; set; } internal void __MarshalFree(ref __Native @ref) { @ref.__MarshalFree(); } internal void __MarshalFrom(ref __Native @ref) { Type = @ref.Type; Flags = @ref.Flags; DescriptorsCount = @ref.NumDescs; Layout = @ref.DescsLayout; if (@ref.NumDescs > 0) { if (@ref.Type == RaytracingAccelerationStructureType.TopLevel) { InstanceDescriptions = Utilities.Read<long>(@ref.Ptr); return; } GeometryDescriptions = new RaytracingGeometryDescription[@ref.NumDescs]; Utilities.Read<RaytracingGeometryDescription>(@ref.Ptr, GeometryDescriptions, 0, @ref.NumDescs); } } internal void __MarshalTo(ref __Native @ref) { @ref.Type = Type; @ref.Flags = Flags; @ref.NumDescs = DescriptorsCount; @ref.DescsLayout = Layout; if (GeometryDescriptions != null && GeometryDescriptions.Length != 0) { @ref.Ptr = Marshal.AllocHGlobal(Utilities.SizeOf<RaytracingGeometryDescription>() * @ref.NumDescs); Utilities.Write<RaytracingGeometryDescription>(@ref.Ptr, GeometryDescriptions, 0, @ref.NumDescs); } else { @ref.Ptr = Marshal.AllocHGlobal(Utilities.SizeOf<long>()); long instanceDescriptions = InstanceDescriptions; Utilities.Write<long>(@ref.Ptr, ref instanceDescriptions); } } } [Guid("0ec870a6-5d7e-4c22-8cfc-5baae07616ed")] public class CommandQueue : Pageable { public long TimestampFrequency { get { GetTimestampFrequency(out var frequencyRef); return frequencyRef; } } public CommandQueueDescription Description => GetDescription(); public unsafe void ExecuteCommandList(CommandList commandList) { if (commandList == null) { throw new ArgumentNullException("commandList"); } IntPtr nativePointer = ((CppObject)commandList).NativePointer; ExecuteCommandLists(1, new IntPtr(&nativePointer)); } public unsafe void ExecuteCommandLists(params CommandList[] commandLists) { IntPtr* ptr = null; int num = 0; if (commandLists != null) { num = commandLists.Length; ptr = stackalloc IntPtr[num]; for (int i = 0; i < num; i++) { ptr[i] = ((commandLists[i] == null) ? IntPtr.Zero : ((CppObject)commandLists[i]).NativePointer); } } ExecuteCommandLists(num, new IntPtr(ptr)); } public CommandQueue(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator CommandQueue(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new CommandQueue(nativePtr); } return null; } public unsafe void UpdateTileMappings(Resource resourceRef, int numResourceRegions, TiledResourceCoordinate[] resourceRegionStartCoordinatesRef, TileRegionSize[] resourceRegionSizesRef, Heap heapRef, int numRanges, TileRangeFlags[] rangeFlagsRef, int[] heapRangeStartOffsetsRef, int[] rangeTileCountsRef, TileMappingFlags flags) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); zero2 = CppObject.ToCallbackPtr<Heap>((ICallbackable)(object)heapRef); fixed (int* ptr = rangeTileCountsRef) { void* ptr2 = ptr; fixed (int* ptr3 = heapRangeStartOffsetsRef) { void* ptr4 = ptr3; fixed (TileRangeFlags* ptr5 = rangeFlagsRef) { void* ptr6 = ptr5; fixed (TileRegionSize* ptr7 = resourceRegionSizesRef) { void* ptr8 = ptr7; fixed (TiledResourceCoordinate* ptr9 = resourceRegionStartCoordinatesRef) { void* ptr10 = ptr9; ((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, int, void*, void*, void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, numResourceRegions, ptr10, ptr8, (void*)zero2, numRanges, ptr6, ptr4, ptr2, (int)flags); } } } } } } public unsafe void CopyTileMappings(Resource dstResourceRef, TiledResourceCoordinate dstRegionStartCoordinateRef, Resource srcResourceRef, TiledResourceCoordinate srcRegionStartCoordinateRef, TileRegionSize regionSizeRef, TileMappingFlags flags) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)dstResourceRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)srcResourceRef); ((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, &dstRegionStartCoordinateRef, (void*)zero2, &srcRegionStartCoordinateRef, ®ionSizeRef, (int)flags); } public unsafe void ExecuteCommandLists(int numCommandLists, CommandList[] commandListsOut) { IntPtr* ptr = null; if (commandListsOut != null) { ptr = stackalloc IntPtr[commandListsOut.Length]; } if (commandListsOut != null) { for (int i = 0; i < commandListsOut.Length; i++) { ptr[i] = CppObject.ToCallbackPtr<CommandList>((ICallbackable)(object)commandListsOut[i]); } } ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numCommandLists, ptr); } public unsafe void SetMarker(int metadata, IntPtr dataRef, int size) { ((delegate* unmanaged[Stdcall]<void*, int, void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, metadata, (void*)dataRef, size); } public unsafe void BeginEvent(int metadata, IntPtr dataRef, int size) { ((delegate* unmanaged[Stdcall]<void*, int, void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, metadata, (void*)dataRef, size); } public unsafe void EndEvent() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } public unsafe void Signal(Fence fenceRef, long value) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Fence>((ICallbackable)(object)fenceRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, long, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, value)); ((Result)(ref val)).CheckError(); } public unsafe void Wait(Fence fenceRef, long value) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Fence>((ICallbackable)(object)fenceRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, long, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, value)); ((Result)(ref val)).CheckError(); } internal unsafe void GetTimestampFrequency(out long frequencyRef) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (long* ptr = &frequencyRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void GetClockCalibration(out long gpuTimestampRef, out long cpuTimestampRef) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (long* ptr = &cpuTimestampRef) { void* ptr2 = ptr; fixed (long* ptr3 = &gpuTimestampRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2)); } } ((Result)(ref val)).CheckError(); } internal unsafe CommandQueueDescription GetDescription() { CommandQueueDescription result = default(CommandQueueDescription); ((delegate* unmanaged[Stdcall]<void*, void*, void*>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result); return result; } public unsafe void ExecuteCommandLists(int numCommandLists, ComArray<CommandList> commandListsOut) { void* nativePointer = ((CppObject)this)._nativePointer; IntPtr intPtr = ((commandListsOut != null) ? ((ComArray)commandListsOut).NativePointer : IntPtr.Zero); ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(nativePointer, numCommandLists, (void*)intPtr); } private unsafe void ExecuteCommandLists(int numCommandLists, IntPtr commandListsOut) { ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numCommandLists, (void*)commandListsOut); } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct CommandQueueDescription { public CommandListType Type; public int Priority; public CommandQueueFlags Flags; public int NodeMask; public CommandQueueDescription(CommandListType type, CommandQueueFlags flags = CommandQueueFlags.None) { Type = type; Priority = 0; Flags = flags; NodeMask = 0; } public CommandQueueDescription(CommandListType type, int nodeMask) { Type = type; Priority = 0; Flags = CommandQueueFlags.None; NodeMask = nodeMask; } } public class CommandSignatureDescription { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct __Native { public int ByteStride; public int ArgumentDescCount; public IntPtr ArgumentDescsPointer; public int NodeMask; } public int ByteStride; internal int ArgumentDescCount; internal IntPtr ArgumentDescsPointer; public int NodeMask; public IndirectArgumentDescription[] IndirectArguments { get; set; } internal void __MarshalFree(ref __Native @ref) { } internal void __MarshalFrom(ref __Native @ref) { ByteStride = @ref.ByteStride; ArgumentDescCount = @ref.ArgumentDescCount; ArgumentDescsPointer = @ref.ArgumentDescsPointer; NodeMask = @ref.NodeMask; } internal void __MarshalTo(ref __Native @ref) { @ref.ByteStride = ByteStride; @ref.ArgumentDescCount = ArgumentDescCount; @ref.ArgumentDescsPointer = ArgumentDescsPointer; @ref.NodeMask = NodeMask; } } public struct CpuDescriptorHandle { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct __Native { public IntPtr Ptr; } public PointerSize Ptr; public static CpuDescriptorHandle operator +(CpuDescriptorHandle left, int right) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) CpuDescriptorHandle result = default(CpuDescriptorHandle); result.Ptr = left.Ptr + PointerSize.op_Implicit(right); return result; } internal void __MarshalFree(ref __Native @ref) { } internal void __MarshalFrom(ref __Native @ref) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Ptr = PointerSize.op_Implicit(@ref.Ptr); } internal void __MarshalTo(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) @ref.Ptr = PointerSize.op_Implicit(Ptr); } } [Guid("344488b7-6846-474b-b989-f027448245e0")] public class DebugInterface : ComObject { private static DebugInterface debugInterface; public static DebugInterface Get() { if (debugInterface == null) { D3D12.GetDebugInterface(Utilities.GetGuidFromType(typeof(DebugInterface)), out var vDebugOut); debugInterface = new DebugInterface(vDebugOut); } return debugInterface; } public DebugInterface(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DebugInterface(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DebugInterface(nativePtr); } return null; } public unsafe void EnableDebugLayer() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct DepthStencilStateDescription { public RawBool IsDepthEnabled; public DepthWriteMask DepthWriteMask; public Comparison DepthComparison; public RawBool IsStencilEnabled; public byte StencilReadMask; public byte StencilWriteMask; public DepthStencilOperationDescription FrontFace; public DepthStencilOperationDescription BackFace; public static DepthStencilStateDescription Default() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) DepthStencilStateDescription result = default(DepthStencilStateDescription); result.IsDepthEnabled = RawBool.op_Implicit(true); result.DepthWriteMask = DepthWriteMask.All; result.DepthComparison = Comparison.Less; result.IsStencilEnabled = RawBool.op_Implicit(false); result.StencilReadMask = byte.MaxValue; result.StencilWriteMask = byte.MaxValue; result.FrontFace.Comparison = Comparison.Always; result.FrontFace.DepthFailOperation = StencilOperation.Keep; result.FrontFace.FailOperation = StencilOperation.Keep; result.FrontFace.PassOperation = StencilOperation.Keep; result.BackFace.Comparison = Comparison.Always; result.BackFace.DepthFailOperation = StencilOperation.Keep; result.BackFace.FailOperation = StencilOperation.Keep; result.BackFace.PassOperation = StencilOperation.Keep; return result; } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct DescriptorHeapDescription { public DescriptorHeapType Type; public int DescriptorCount; public DescriptorHeapFlags Flags; public int NodeMask; public DescriptorHeapDescription(DescriptorHeapType type, int descriptorCount, DescriptorHeapFlags flags = DescriptorHeapFlags.None, int nodeMask = 0) { Type = type; DescriptorCount = descriptorCount; Flags = flags; NodeMask = nodeMask; } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct DescriptorRange { public DescriptorRangeType RangeType; public int DescriptorCount; public int BaseShaderRegister; public int RegisterSpace; public int OffsetInDescriptorsFromTableStart; public DescriptorRange(DescriptorRangeType rangeType, int descriptorCount, int baseShaderRegister, int registerSpace = 0, int offsetInDescriptorsFromTableStart = 0) { RangeType = rangeType; DescriptorCount = descriptorCount; BaseShaderRegister = baseShaderRegister; RegisterSpace = registerSpace; OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; } } [Guid("189819f1-1db6-4b57-be54-1821339b85f7")] public class Device : Object { public unsafe FeatureDataD3D12Options D3D12Options { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D12Options result = default(FeatureDataD3D12Options); CheckFeatureSupport(Feature.D3D12Options, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D12Options>()); return result; } } public unsafe FeatureDataD3D12Options1 D3D12Options1 { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D12Options1 result = default(FeatureDataD3D12Options1); CheckFeatureSupport(Feature.D3D12Options1, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D12Options1>()); return result; } } public unsafe FeatureDataD3D12Options2 D3D12Options2 { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D12Options2 result = default(FeatureDataD3D12Options2); CheckFeatureSupport(Feature.D3D12Options2, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D12Options2>()); return result; } } public unsafe FeatureDataD3D12Options3 D3D12Options3 { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D12Options3 result = default(FeatureDataD3D12Options3); CheckFeatureSupport(Feature.D3D12Options3, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D12Options3>()); return result; } } public unsafe FeatureDataD3D12Options4 D3D12Options4 { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D12Options4 result = default(FeatureDataD3D12Options4); CheckFeatureSupport(Feature.D3D12Options4, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D12Options4>()); return result; } } public unsafe FeatureDataArchitecture Architecture { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) FeatureDataArchitecture result = default(FeatureDataArchitecture); CheckFeatureSupport(Feature.Architecture, new IntPtr(&result), Utilities.SizeOf<FeatureDataArchitecture>()); return result; } } public unsafe FeatureDataGpuVirtualAddressSupport GpuVirtualAddressSupport { get { //IL_0017: Unknown result type (might be due to invalid IL or missing references) FeatureDataGpuVirtualAddressSupport result = default(FeatureDataGpuVirtualAddressSupport); CheckFeatureSupport(Feature.GpuVirtualAddressSupport, new IntPtr(&result), Utilities.SizeOf<FeatureDataGpuVirtualAddressSupport>()); return result; } } public int NodeCount => GetNodeCount(); public Result DeviceRemovedReason => GetDeviceRemovedReason(); public RawBool StablePowerState { set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SetStablePowerState(value); } } public long AdapterLuid => GetAdapterLuid(); public Device() : this(null, (FeatureLevel)45056) { } public Device(Adapter adapter) : this(adapter, (FeatureLevel)45056) { } public Device(Adapter adapter, FeatureLevel minFeatureLevel) : base(IntPtr.Zero) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) CreateDevice(adapter, minFeatureLevel, this); } public unsafe bool CheckFeatureSupport<T>(Feature feature, ref T featureSupportData) where T : struct { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) fixed (T* value = &featureSupportData) { Result val = CheckFeatureSupport(feature, new IntPtr(value), Utilities.SizeOf<T>()); return ((Result)(ref val)).Success; } } public CommandQueue CreateCommandQueue(CommandQueueDescription description) { return CreateCommandQueue(description, Utilities.GetGuidFromType(typeof(CommandQueue))); } public CommandQueue CreateCommandQueue(CommandListType type) { return CreateCommandQueue(new CommandQueueDescription(type), Utilities.GetGuidFromType(typeof(CommandQueue))); } public CommandQueue CreateCommandQueue(CommandListType type, int nodeMask) { return CreateCommandQueue(new CommandQueueDescription(type, nodeMask), Utilities.GetGuidFromType(typeof(CommandQueue))); } public CommandAllocator CreateCommandAllocator(CommandListType type) { return CreateCommandAllocator(type, Utilities.GetGuidFromType(typeof(CommandAllocator))); } public GraphicsCommandList CreateCommandList(CommandListType type, CommandAllocator commandAllocator, PipelineState initialState) { return CreateCommandList(0, type, commandAllocator, initialState); } public GraphicsCommandList CreateCommandList(int nodeMask, CommandListType type, CommandAllocator commandAllocator, PipelineState initialState) { return new GraphicsCommandList(CreateCommandList(nodeMask, type, commandAllocator, initialState, Utilities.GetGuidFromType(typeof(GraphicsCommandList)))); } public unsafe CommandSignature CreateCommandSignature(CommandSignatureDescription descRef, RootSignature rootSignatureRef) { CommandSignatureDescription.__Native @ref = default(CommandSignatureDescription.__Native); descRef.__MarshalTo(ref @ref); fixed (IndirectArgumentDescription* ptr = descRef.IndirectArguments) { void* value = ptr; if (descRef.IndirectArguments != null) { @ref.ArgumentDescCount = descRef.IndirectArguments.Length; @ref.ArgumentDescsPointer = new IntPtr(value); } return CreateCommandSignature(new IntPtr(&@ref), rootSignatureRef, Utilities.GetGuidFromType(typeof(CommandSignature))); } } public Resource CreateCommittedResource(HeapProperties heapPropertiesRef, HeapFlags heapFlags, ResourceDescription resourceDescRef, ResourceStates initialResourceState, ClearValue? optimizedClearValueRef = null) { return CreateCommittedResource(ref heapPropertiesRef, heapFlags, ref resourceDescRef, initialResourceState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource))); } public unsafe PipelineState CreateComputePipelineState(ComputePipelineStateDescription descRef) { ComputePipelineStateDescription.__Native @ref = default(ComputePipelineStateDescription.__Native); descRef.__MarshalTo(ref @ref); fixed (byte* ptr = descRef.ComputeShader.Buffer) { void* ptr2 = ptr; descRef.ComputeShader.UpdateNative(ref @ref.ComputeShader, (IntPtr)ptr2); return CreateComputePipelineState(new IntPtr(&@ref), Utilities.GetGuidFromType(typeof(PipelineState))); } } public RootSignature CreateRootSignature(DataPointer rootSignaturePointer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return CreateRootSignature(0, rootSignaturePointer); } public RootSignature CreateRootSignature(int nodeMask, DataPointer rootSignaturePointer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) return CreateRootSignature(nodeMask, rootSignaturePointer.Pointer, PointerSize.op_Implicit(rootSignaturePointer.Size), Utilities.GetGuidFromType(typeof(RootSignature))); } public unsafe RootSignature CreateRootSignature(byte[] byteCode) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (byteCode == null) { throw new ArgumentNullException("byteCode"); } fixed (byte* value = &byteCode[0]) { return CreateRootSignature(new DataPointer(new IntPtr(value), byteCode.Length)); } } public DescriptorHeap CreateDescriptorHeap(DescriptorHeapDescription descriptorHeapDesc) { return CreateDescriptorHeap(descriptorHeapDesc, Utilities.GetGuidFromType(typeof(DescriptorHeap))); } public DescriptorHeap CreateDescriptorHeap(DescriptorHeapType type, int descriptorCount, DescriptorHeapFlags flags = DescriptorHeapFlags.None, int nodeMask = 0) { DescriptorHeapDescription descriptorHeapDescription = default(DescriptorHeapDescription); descriptorHeapDescription.Type = type; descriptorHeapDescription.DescriptorCount = descriptorCount; descriptorHeapDescription.Flags = flags; descriptorHeapDescription.NodeMask = nodeMask; DescriptorHeapDescription descriptorHeapDescRef = descriptorHeapDescription; return CreateDescriptorHeap(descriptorHeapDescRef, Utilities.GetGuidFromType(typeof(DescriptorHeap))); } public Fence CreateFence(long initialValue, FenceFlags flags) { return CreateFence(initialValue, flags, Utilities.GetGuidFromType(typeof(Fence))); } public unsafe PipelineState CreateGraphicsPipelineState(GraphicsPipelineStateDescription desc) { GraphicsPipelineStateDescription.__Native @ref = default(GraphicsPipelineStateDescription.__Native); desc.__MarshalTo(ref @ref); fixed (byte* ptr = desc.VertexShader.Buffer) { void* ptr2 = ptr; fixed (byte* ptr3 = desc.GeometryShader.Buffer) { void* ptr4 = ptr3; fixed (byte* ptr5 = desc.DomainShader.Buffer) { void* ptr6 = ptr5; fixed (byte* ptr7 = desc.HullShader.Buffer) { void* ptr8 = ptr7; fixed (byte* ptr9 = desc.PixelShader.Buffer) { void* ptr10 = ptr9; desc.VertexShader.UpdateNative(ref @ref.VertexShader, (IntPtr)ptr2); desc.GeometryShader.UpdateNative(ref @ref.GeometryShader, (IntPtr)ptr4); desc.DomainShader.UpdateNative(ref @ref.DomainShader, (IntPtr)ptr6); desc.HullShader.UpdateNative(ref @ref.HullShader, (IntPtr)ptr8); desc.PixelShader.UpdateNative(ref @ref.PixelShader, (IntPtr)ptr10); InputElement[] array = ((desc.InputLayout != null) ? desc.InputLayout.Elements : null); InputElement.__Native* ptr11 = null; if (array != null && array.Length != 0) { ptr11 = stackalloc InputElement.__Native[array.Length]; for (int i = 0; i < array.Length; i++) { array[i].__MarshalTo(ref ptr11[i]); } @ref.InputLayout.InputElementsPointer = new IntPtr(ptr11); @ref.InputLayout.ElementCount = array.Length; } StreamOutputElement[] array2 = ((desc.StreamOutput != null) ? desc.StreamOutput.Elements : null); StreamOutputElement.__Native* ptr12 = null; if (array2 != null && array2.Length != 0) { ptr12 = stackalloc StreamOutputElement.__Native[array2.Length]; for (int j = 0; j < array2.Length; j++) { array2[j].__MarshalTo(ref ptr12[j]); } @ref.StreamOutput.StreamOutputEntriesPointer = new IntPtr(ptr12); @ref.StreamOutput.EntrieCount = array2.Length; } try { return CreateGraphicsPipelineState(new IntPtr(&@ref), Utilities.GetGuidFromType(typeof(PipelineState))); } finally { if (array != null) { for (int k = 0; k < array.Length; k++) { array[k].__MarshalFree(ref ptr11[k]); } } if (array2 != null) { for (int l = 0; l < array2.Length; l++) { array2[l].__MarshalFree(ref ptr12[l]); } } } } } } } } } public Heap CreateHeap(HeapDescription descRef) { return CreateHeap(ref descRef, Utilities.GetGuidFromType(typeof(Heap))); } public QueryHeap CreateQueryHeap(QueryHeapDescription descRef) { return CreateQueryHeap(descRef, Utilities.GetGuidFromType(typeof(QueryHeap))); } public Resource CreatePlacedResource(Heap heapRef, long heapOffset, ResourceDescription descRef, ResourceStates initialState, ClearValue? optimizedClearValueRef = null) { return CreatePlacedResource(heapRef, heapOffset, ref descRef, initialState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource))); } public Resource CreateReservedResource(ResourceDescription descRef, ResourceStates initialState, ClearValue? optimizedClearValueRef = null) { return CreateReservedResource(ref descRef, initialState, optimizedClearValueRef, Utilities.GetGuidFromType(typeof(Resource))); } public ResourceAllocationInformation GetResourceAllocationInfo(int visibleMask, ResourceDescription resourceDesc) { return GetResourceAllocationInfo(visibleMask, 1, new ResourceDescription[1] { resourceDesc }); } public unsafe FeatureDataShaderModel CheckShaderModel(ShaderModel highestShaderModel) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) FeatureDataShaderModel featureDataShaderModel = default(FeatureDataShaderModel); featureDataShaderModel.HighestShaderModel = highestShaderModel; FeatureDataShaderModel result = featureDataShaderModel; CheckFeatureSupport(Feature.ShaderModel, new IntPtr(&result), Utilities.SizeOf<FeatureDataShaderModel>()); return result; } public unsafe FeatureLevel CheckMaxSupportedFeatureLevel(params FeatureLevel[] levels) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) fixed (FeatureLevel* value = &levels[0]) { FeatureDataFeatureLevels featureDataFeatureLevels = default(FeatureDataFeatureLevels); featureDataFeatureLevels.FeatureLevelCount = levels.Length; featureDataFeatureLevels.FeatureLevelsRequestedPointer = new IntPtr(value); FeatureDataFeatureLevels featureDataFeatureLevels2 = featureDataFeatureLevels; CheckFeatureSupport(Feature.FeatureLevels, new IntPtr(&featureDataFeatureLevels2), Utilities.SizeOf<FeatureDataFeatureLevels>()); return featureDataFeatureLevels2.MaxSupportedFeatureLevel; } } private static void CreateDevice(Adapter adapter, FeatureLevel minFeatureLevel, Device instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) Result val = D3D12.CreateDevice((IUnknown)(object)adapter, minFeatureLevel, Utilities.GetGuidFromType(typeof(Device)), instance); ((Result)(ref val)).CheckError(); } public Device(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device(nativePtr); } return null; } internal unsafe int GetNodeCount() { return ((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } private unsafe CommandQueue CreateCommandQueue(CommandQueueDescription descRef, Guid riid) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, &riid, &zero)); CommandQueue result = ((!(zero != IntPtr.Zero)) ? null : new CommandQueue(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe CommandAllocator CreateCommandAllocator(CommandListType type, Guid riid) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)type, &riid, &zero)); CommandAllocator result = ((!(zero != IntPtr.Zero)) ? null : new CommandAllocator(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe PipelineState CreateGraphicsPipelineState(IntPtr descRef, Guid riid) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)descRef, &riid, &zero)); PipelineState result = ((!(zero != IntPtr.Zero)) ? null : new PipelineState(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe PipelineState CreateComputePipelineState(IntPtr descRef, Guid riid) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)descRef, &riid, &zero)); PipelineState result = ((!(zero != IntPtr.Zero)) ? null : new PipelineState(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe IntPtr CreateCommandList(int nodeMask, CommandListType type, CommandAllocator commandAllocatorRef, PipelineState initialStateRef, Guid riid) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<CommandAllocator>((ICallbackable)(object)commandAllocatorRef); zero2 = CppObject.ToCallbackPtr<PipelineState>((ICallbackable)(object)initialStateRef); IntPtr result = default(IntPtr); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, nodeMask, (int)type, (void*)zero, (void*)zero2, &riid, &result)); ((Result)(ref val)).CheckError(); return result; } private unsafe Result CheckFeatureSupport(Feature feature, IntPtr featureSupportDataRef, int featureSupportDataSize) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) return Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)feature, (void*)featureSupportDataRef, featureSupportDataSize)); } private unsafe DescriptorHeap CreateDescriptorHeap(DescriptorHeapDescription descriptorHeapDescRef, Guid riid) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descriptorHeapDescRef, &riid, &zero)); DescriptorHeap result = ((!(zero != IntPtr.Zero)) ? null : new DescriptorHeap(zero)); ((Result)(ref val)).CheckError(); return result; } public unsafe int GetDescriptorHandleIncrementSize(DescriptorHeapType descriptorHeapType) { return ((delegate* unmanaged[Stdcall]<void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)descriptorHeapType); } private unsafe RootSignature CreateRootSignature(int nodeMask, IntPtr blobWithRootSignatureRef, PointerSize blobLengthInBytes, Guid riid) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, nodeMask, (void*)blobWithRootSignatureRef, PointerSize.op_Implicit(blobLengthInBytes), &riid, &zero)); RootSignature result = ((!(zero != IntPtr.Zero)) ? null : new RootSignature(zero)); ((Result)(ref val)).CheckError(); return result; } public unsafe void CreateConstantBufferView(ConstantBufferViewDescription? descRef, CpuDescriptorHandle destDescriptor) { CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); ConstantBufferViewDescription value = default(ConstantBufferViewDescription); if (descRef.HasValue) { value = descRef.Value; } destDescriptor.__MarshalTo(ref @ref); void* nativePointer = ((CppObject)this)._nativePointer; ConstantBufferViewDescription* intPtr = ((!descRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(nativePointer, intPtr, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CreateShaderResourceView(Resource resourceRef, ShaderResourceViewDescription? descRef, CpuDescriptorHandle destDescriptor) { IntPtr zero = IntPtr.Zero; CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); ShaderResourceViewDescription value = default(ShaderResourceViewDescription); if (descRef.HasValue) { value = descRef.Value; } destDescriptor.__MarshalTo(ref @ref); void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; ShaderResourceViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CreateUnorderedAccessView(Resource resourceRef, Resource counterResourceRef, UnorderedAccessViewDescription? descRef, CpuDescriptorHandle destDescriptor) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)counterResourceRef); UnorderedAccessViewDescription value = default(UnorderedAccessViewDescription); if (descRef.HasValue) { value = descRef.Value; } destDescriptor.__MarshalTo(ref @ref); void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; void* intPtr2 = (void*)zero2; UnorderedAccessViewDescription* intPtr3 = ((!descRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, intPtr3, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CreateRenderTargetView(Resource resourceRef, RenderTargetViewDescription? descRef, CpuDescriptorHandle destDescriptor) { IntPtr zero = IntPtr.Zero; CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); RenderTargetViewDescription value = default(RenderTargetViewDescription); if (descRef.HasValue) { value = descRef.Value; } destDescriptor.__MarshalTo(ref @ref); void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; RenderTargetViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CreateDepthStencilView(Resource resourceRef, DepthStencilViewDescription? descRef, CpuDescriptorHandle destDescriptor) { IntPtr zero = IntPtr.Zero; CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); DepthStencilViewDescription value = default(DepthStencilViewDescription); if (descRef.HasValue) { value = descRef.Value; } destDescriptor.__MarshalTo(ref @ref); void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; DepthStencilViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CreateSampler(SamplerStateDescription descRef, CpuDescriptorHandle destDescriptor) { CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); destDescriptor.__MarshalTo(ref @ref); ((delegate* unmanaged[Stdcall]<void*, void*, CpuDescriptorHandle.__Native, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, @ref); destDescriptor.__MarshalFree(ref @ref); } public unsafe void CopyDescriptors(int numDestDescriptorRanges, CpuDescriptorHandle[] destDescriptorRangeStartsRef, int[] destDescriptorRangeSizesRef, int numSrcDescriptorRanges, CpuDescriptorHandle[] srcDescriptorRangeStartsRef, int[] srcDescriptorRangeSizesRef, DescriptorHeapType descriptorHeapsType) { CpuDescriptorHandle.__Native[] array = new CpuDescriptorHandle.__Native[destDescriptorRangeStartsRef.Length]; CpuDescriptorHandle.__Native[] array2 = new CpuDescriptorHandle.__Native[srcDescriptorRangeStartsRef.Length]; for (int i = 0; i < destDescriptorRangeStartsRef.Length; i++) { destDescriptorRangeStartsRef[i].__MarshalTo(ref array[i]); } for (int j = 0; j < srcDescriptorRangeStartsRef.Length; j++) { srcDescriptorRangeStartsRef[j].__MarshalTo(ref array2[j]); } fixed (int* ptr = srcDescriptorRangeSizesRef) { void* ptr2 = ptr; fixed (CpuDescriptorHandle.__Native* ptr3 = array2) { void* ptr4 = ptr3; fixed (int* ptr5 = destDescriptorRangeSizesRef) { void* ptr6 = ptr5; fixed (CpuDescriptorHandle.__Native* ptr7 = array) { void* ptr8 = ptr7; ((delegate* unmanaged[Stdcall]<void*, int, void*, void*, int, void*, void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numDestDescriptorRanges, ptr8, ptr6, numSrcDescriptorRanges, ptr4, ptr2, (int)descriptorHeapsType); } } } } for (int k = 0; k < destDescriptorRangeStartsRef.Length; k++) { destDescriptorRangeStartsRef[k].__MarshalFree(ref array[k]); } for (int l = 0; l < srcDescriptorRangeStartsRef.Length; l++) { srcDescriptorRangeStartsRef[l].__MarshalFree(ref array2[l]); } } public unsafe void CopyDescriptorsSimple(int numDescriptors, CpuDescriptorHandle destDescriptorRangeStart, CpuDescriptorHandle srcDescriptorRangeStart, DescriptorHeapType descriptorHeapsType) { CpuDescriptorHandle.__Native @ref = default(CpuDescriptorHandle.__Native); CpuDescriptorHandle.__Native ref2 = default(CpuDescriptorHandle.__Native); destDescriptorRangeStart.__MarshalTo(ref @ref); srcDescriptorRangeStart.__MarshalTo(ref ref2); ((delegate* unmanaged[Stdcall]<void*, int, CpuDescriptorHandle.__Native, CpuDescriptorHandle.__Native, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)24 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numDescriptors, @ref, ref2, (int)descriptorHeapsType); destDescriptorRangeStart.__MarshalFree(ref @ref); srcDescriptorRangeStart.__MarshalFree(ref ref2); } public unsafe ResourceAllocationInformation GetResourceAllocationInfo(int visibleMask, int numResourceDescs, ResourceDescription[] resourceDescsRef) { ResourceAllocationInformation result = default(ResourceAllocationInformation); fixed (ResourceDescription* ptr = resourceDescsRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, int, int, void*, void*>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)25 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result, visibleMask, numResourceDescs, ptr2); } return result; } public unsafe HeapProperties GetCustomHeapProperties(int nodeMask, HeapType heapType) { HeapProperties result = default(HeapProperties); ((delegate* unmanaged[Stdcall]<void*, void*, int, int, void*>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)26 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result, nodeMask, (int)heapType); return result; } private unsafe Resource CreateCommittedResource(ref HeapProperties heapPropertiesRef, HeapFlags heapFlags, ref ResourceDescription descRef, ResourceStates initialResourceState, ClearValue? optimizedClearValueRef, Guid riidResource) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; ClearValue value = default(ClearValue); if (optimizedClearValueRef.HasValue) { value = optimizedClearValueRef.Value; } Result val; fixed (ResourceDescription* ptr = &descRef) { void* ptr2 = ptr; fixed (HeapProperties* ptr3 = &heapPropertiesRef) { void* ptr4 = ptr3; void* nativePointer = ((CppObject)this)._nativePointer; ClearValue* intPtr = ((!optimizedClearValueRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)27 * (nint)sizeof(void*))))(nativePointer, ptr4, (int)heapFlags, ptr2, (int)initialResourceState, intPtr, &riidResource, &zero)); } } Resource result = ((!(zero != IntPtr.Zero)) ? null : new Resource(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe Heap CreateHeap(ref HeapDescription descRef, Guid riid) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (HeapDescription* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)28 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &riid, &zero)); } Heap result = ((!(zero != IntPtr.Zero)) ? null : new Heap(zero)); ((Result)(ref val)).CheckError(); return result; } private unsafe Resource CreatePlacedResource(Heap heapRef, long heapOffset, ref ResourceDescription descRef, ResourceStates initialState, ClearValue? optimizedClearValueRef, Guid riid) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Heap>((ICallbackable)(object)heapRef); ClearValue value = default(ClearValue); if (optimizedClearValueRef.HasValue) { value = optimizedClearValueRef.Value; } Result val; fixed (ResourceDescription* ptr = &descRef) { void* ptr2 = ptr; void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; ClearValue* intPtr2 = ((!optimizedClearValueRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, long, void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)29 * (nint)sizeof(void*))))(nativePointer, intPtr, heapOffset, ptr2, (int)initialState, intPtr2, &riid, &zero2)); } Resource result = ((!(zero2 != IntPtr.Zero)) ? null : new Resource(zero2)); ((Result)(ref val)).CheckError(); return result; } private unsafe Resource CreateReservedResource(ref ResourceDescription descRef, ResourceStates initialState, ClearValue? optimizedClearValueRef, Guid riid) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; ClearValue value = default(ClearValue); if (optimizedClearValueRef.HasValue) { value = optimizedClearValueRef.Value; } Result val; fixed (ResourceDescription* ptr = &descRef) { void* ptr2 = ptr; void* nativePointer = ((CppObject)this)._nativePointer; ClearValue* intPtr = ((!optimizedClearValueRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)30 * (nint)sizeof(void*))))(nativePointer, ptr2, (int)initialState, intPtr, &riid, &zero)); } Resource result = ((!(zero != IntPtr.Zero)) ? null : new Resource(zero)); ((Result)(ref val)).CheckError(); return result; } internal unsafe void CreateSharedHandle(DeviceChild objectRef, SecurityAttributes? attributesRef, int access, string name, out IntPtr handleRef) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<DeviceChild>((ICallbackable)(object)objectRef); SecurityAttributes value = default(SecurityAttributes); if (attributesRef.HasValue) { value = attributesRef.Value; } Result val; fixed (IntPtr* ptr = &handleRef) { void* ptr2 = ptr; fixed (char* ptr3 = name) { void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; SecurityAttributes* intPtr2 = ((!attributesRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)31 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, access, ptr3, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void OpenSharedHandle(IntPtr nTHandle, Guid riid, out IntPtr vObjOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &vObjOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)32 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)nTHandle, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void OpenSharedHandleByName(string name, int access, out IntPtr nTHandleRef) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &nTHandleRef) { void* ptr2 = ptr; fixed (char* ptr3 = name) { val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)33 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr3, access, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe void MakeResident(int numObjects, Pageable[] objectsOut) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) IntPtr* ptr = null; if (objectsOut != null) { ptr = stackalloc IntPtr[objectsOut.Length]; } if (objectsOut != null) { for (int i = 0; i < objectsOut.Length; i++) { ptr[i] = CppObject.ToCallbackPtr<Pageable>((ICallbackable)(object)objectsOut[i]); } } Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)34 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numObjects, ptr)); ((Result)(ref val)).CheckError(); } public unsafe void Evict(int numObjects, Pageable[] objectsOut) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) IntPtr* ptr = null; if (objectsOut != null) { ptr = stackalloc IntPtr[objectsOut.Length]; } if (objectsOut != null) { for (int i = 0; i < objectsOut.Length; i++) { ptr[i] = CppObject.ToCallbackPtr<Pageable>((ICallbackable)(object)objectsOut[i]); } } Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)35 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numObjects, ptr)); ((Result)(ref val)).CheckError(); } private unsafe Fence CreateFence(long initialValue, FenceFlags flags, Guid riid) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, long, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)36 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, initialValue, (int)flags, &riid, &zero)); Fence result = ((!(zero != IntPtr.Zero)) ? null : new Fence(zero)); ((Result)(ref val)).CheckError(); return result; } internal unsafe Result GetDeviceRemovedReason() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)37 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); } public unsafe void GetCopyableFootprints(ref ResourceDescription resourceDescRef, int firstSubresource, int numSubresources, long baseOffset, PlacedSubResourceFootprint[] layoutsRef, int[] numRowsRef, long[] rowSizeInBytesRef, out long totalBytesRef) { fixed (long* ptr = &totalBytesRef) { void* ptr2 = ptr; fixed (long* ptr3 = rowSizeInBytesRef) { void* ptr4 = ptr3; fixed (int* ptr5 = numRowsRef) { void* ptr6 = ptr5; fixed (PlacedSubResourceFootprint* ptr7 = layoutsRef) { void* ptr8 = ptr7; fixed (ResourceDescription* ptr9 = &resourceDescRef) { void* ptr10 = ptr9; ((delegate* unmanaged[Stdcall]<void*, void*, int, int, long, void*, void*, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)38 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr10, firstSubresource, numSubresources, baseOffset, ptr8, ptr6, ptr4, ptr2); } } } } } } private unsafe QueryHeap CreateQueryHeap(QueryHeapDescription descRef, Guid riid) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)39 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, &riid, &zero)); QueryHeap result = ((!(zero != IntPtr.Zero)) ? null : new QueryHeap(zero)); ((Result)(ref val)).CheckError(); return result; } internal unsafe void SetStablePowerState(RawBool enable) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, RawBool, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)40 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, enable)); ((Result)(ref val)).CheckError(); } private unsafe CommandSignature CreateCommandSignature(IntPtr descRef, RootSignature rootSignatureRef, Guid riid) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<RootSignature>((ICallbackable)(object)rootSignatureRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)41 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)descRef, (void*)zero, &riid, &zero2)); CommandSignature result = ((!(zero2 != IntPtr.Zero)) ? null : new CommandSignature(zero2)); ((Result)(ref val)).CheckError(); return result; } public unsafe void GetResourceTiling(Resource tiledResourceRef, out int numTilesForEntireResourceRef, out PackedMipInformation packedMipDescRef, out TileShape standardTileShapeForNonPackedMipsRef, IntPtr numSubresourceTilingsRef, int firstSubresourceTilingToGet, SubResourceTiling[] subresourceTilingsForNonPackedMipsRef) { IntPtr zero = IntPtr.Zero; packedMipDescRef = default(PackedMipInformation); standardTileShapeForNonPackedMipsRef = default(TileShape); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)tiledResourceRef); fixed (SubResourceTiling* ptr = subresourceTilingsForNonPackedMipsRef) { void* ptr2 = ptr; fixed (TileShape* ptr3 = &standardTileShapeForNonPackedMipsRef) { void* ptr4 = ptr3; fixed (PackedMipInformation* ptr5 = &packedMipDescRef) { void* ptr6 = ptr5; fixed (int* ptr7 = &numTilesForEntireResourceRef) { void* ptr8 = ptr7; ((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)42 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, ptr8, ptr6, ptr4, (void*)numSubresourceTilingsRef, firstSubresourceTilingToGet, ptr2); } } } } } internal unsafe long GetAdapterLuid() { return ((delegate* unmanaged[Stdcall]<void*, long>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)43 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } public unsafe void MakeResident(int numObjects, ComArray<Pageable> objectsOut) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) void* nativePointer = ((CppObject)this)._nativePointer; IntPtr intPtr = ((objectsOut != null) ? ((ComArray)objectsOut).NativePointer : IntPtr.Zero); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)34 * (nint)sizeof(void*))))(nativePointer, numObjects, (void*)intPtr)); ((Result)(ref val)).CheckError(); } private unsafe void MakeResident(int numObjects, IntPtr objectsOut) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)34 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numObjects, (void*)objectsOut)); ((Result)(ref val)).CheckError(); } public unsafe void Evict(int numObjects, ComArray<Pageable> objectsOut) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) void* nativePointer = ((CppObject)this)._nativePointer; IntPtr intPtr = ((objectsOut != null) ? ((ComArray)objectsOut).NativePointer : IntPtr.Zero); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)35 * (nint)sizeof(void*))))(nativePointer, numObjects, (void*)intPtr)); ((Result)(ref val)).CheckError(); } private unsafe void Evict(int numObjects, IntPtr objectsOut) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)35 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numObjects, (void*)objectsOut)); ((Result)(ref val)).CheckError(); } } [Guid("e865df17-a9ee-46f9-a463-3098315aa2e5")] public class Device4 : Device3 { public GraphicsCommandList1 CreateCommandList1(CommandListType type, CommandListFlags flags) { return CreateCommandList1(0, type, flags); } public GraphicsCommandList1 CreateCommandList1(int nodeMask, CommandListType type, CommandListFlags flags) { return new GraphicsCommandList1(CreateCommandList1(nodeMask, type, flags, Utilities.GetGuidFromType(typeof(GraphicsCommandList1)))); } public ProtectedResourceSession CreateProtectedResourceSession(ProtectedResourceSessionDescription desc) { return CreateProtectedResourceSession(desc, Utilities.GetGuidFromType(typeof(ProtectedResourceSession))); } public Heap1 CreateHeap1(HeapDescription desc, ProtectedResourceSession protectedSession) { return CreateHeap1(ref desc, protectedSession, Utilities.GetGuidFromType(typeof(Heap1))); } public Device4(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device4(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device4(nativePtr); } return null; } private unsafe IntPtr CreateCommandList1(int nodeMask, CommandListType type, CommandListFlags flags, Guid riid) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) IntPtr result = default(IntPtr); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)51 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, nodeMask, (int)type, (int)flags, &riid, &result)); ((Result)(ref val)).CheckError(); return result; } private unsafe ProtectedResourceSession CreateProtectedResourceSession(ProtectedResourceSessionDescription descRef, Guid riid) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)52 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, &riid, &zero)); ProtectedResourceSession result = ((!(zero != IntPtr.Zero)) ? null : new ProtectedResourceSession(zero)); ((Result)(ref val)).CheckError(); return result; } public unsafe void CreateCommittedResource1(ref HeapProperties heapPropertiesRef, HeapFlags heapFlags, ref ResourceDescription descRef, ResourceStates initialResourceState, ClearValue? optimizedClearValueRef, ProtectedResourceSession protectedSessionRef, Guid riidResource, out IntPtr vResourceOut) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; ClearValue value = default(ClearValue); if (optimizedClearValueRef.HasValue) { value = optimizedClearValueRef.Value; } zero = CppObject.ToCallbackPtr<ProtectedResourceSession>((ICallbackable)(object)protectedSessionRef); Result val; fixed (IntPtr* ptr = &vResourceOut) { void* ptr2 = ptr; fixed (ResourceDescription* ptr3 = &descRef) { void* ptr4 = ptr3; fixed (HeapProperties* ptr5 = &heapPropertiesRef) { void* ptr6 = ptr5; void* nativePointer = ((CppObject)this)._nativePointer; ClearValue* intPtr = ((!optimizedClearValueRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)53 * (nint)sizeof(void*))))(nativePointer, ptr6, (int)heapFlags, ptr4, (int)initialResourceState, intPtr, (void*)zero, &riidResource, ptr2)); } } } ((Result)(ref val)).CheckError(); } private unsafe Heap1 CreateHeap1(ref HeapDescription descRef, ProtectedResourceSession protectedSessionRef, Guid riid) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ProtectedResourceSession>((ICallbackable)(object)protectedSessionRef); Result val; fixed (HeapDescription* ptr = &descRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)54 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, (void*)zero, &riid, &zero2)); } Heap1 result = ((!(zero2 != IntPtr.Zero)) ? null : new Heap1(zero2)); ((Result)(ref val)).CheckError(); return result; } public unsafe void CreateReservedResource1(ref ResourceDescription descRef, ResourceStates initialState, ClearValue? optimizedClearValueRef, ProtectedResourceSession protectedSessionRef, Guid riid, out IntPtr vResourceOut) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; ClearValue value = default(ClearValue); if (optimizedClearValueRef.HasValue) { value = optimizedClearValueRef.Value; } zero = CppObject.ToCallbackPtr<ProtectedResourceSession>((ICallbackable)(object)protectedSessionRef); Result val; fixed (IntPtr* ptr = &vResourceOut) { void* ptr2 = ptr; fixed (ResourceDescription* ptr3 = &descRef) { void* ptr4 = ptr3; void* nativePointer = ((CppObject)this)._nativePointer; ClearValue* intPtr = ((!optimizedClearValueRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)55 * (nint)sizeof(void*))))(nativePointer, ptr4, (int)initialState, intPtr, (void*)zero, &riid, ptr2)); } } ((Result)(ref val)).CheckError(); } public unsafe ResourceAllocationInformation GetResourceAllocationInfo1(int visibleMask, int numResourceDescs, ResourceDescription[] resourceDescsRef, ResourceAllocationInformation1[] resourceAllocationInfo1Ref) { ResourceAllocationInformation result = default(ResourceAllocationInformation); fixed (ResourceAllocationInformation1* ptr = resourceAllocationInfo1Ref) { void* ptr2 = ptr; fixed (ResourceDescription* ptr3 = resourceDescsRef) { void* ptr4 = ptr3; ((delegate* unmanaged[Stdcall]<void*, void*, int, int, void*, void*, void*>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)56 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result, visibleMask, numResourceDescs, ptr4, ptr2); } } return result; } } [Guid("8b4f173b-2fea-4b80-8f58-4307191ab95d")] public class Device5 : Device4 { public StateObject CreateStateObject(StateObjectDescription description) { return CreateStateObject(description, Utilities.GetGuidFromType(typeof(StateObject))); } public Device5(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device5(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device5(nativePtr); } return null; } public unsafe void CreateLifetimeTracker(LifetimeOwner ownerRef, Guid riid, out IntPtr vTrackerOut) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<LifetimeOwner>((ICallbackable)(object)ownerRef); Result val; fixed (IntPtr* ptr = &vTrackerOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)57 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, &riid, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe void RemoveDevice() { ((delegate* unmanaged[Stdcall]<void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)58 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } public unsafe void EnumerateMetaCommands(ref int numMetaCommandsRef, MetaCommandDescription[] descsRef) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) MetaCommandDescription.__Native[] array = ((descsRef == null) ? null : new MetaCommandDescription.__Native[descsRef.Length]); Result val; fixed (MetaCommandDescription.__Native* ptr = array) { void* ptr2 = ptr; fixed (int* ptr3 = &numMetaCommandsRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)59 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2)); } } if (descsRef != null) { for (int i = 0; i < descsRef.Length; i++) { descsRef?[i].__MarshalFrom(ref array[i]); } } ((Result)(ref val)).CheckError(); } public unsafe void EnumerateMetaCommandParameters(Guid commandId, MetaCommandParameterStage stage, out int totalStructureSizeInBytesRef, ref int parameterCountRef, MetaCommandParameterDescription[] parameterDescsRef) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) MetaCommandParameterDescription.__Native[] array = ((parameterDescsRef == null) ? null : new MetaCommandParameterDescription.__Native[parameterDescsRef.Length]); Result val; fixed (MetaCommandParameterDescription.__Native* ptr = array) { void* ptr2 = ptr; fixed (int* ptr3 = ¶meterCountRef) { void* ptr4 = ptr3; fixed (int* ptr5 = &totalStructureSizeInBytesRef) { void* ptr6 = ptr5; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)60 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &commandId, (int)stage, ptr6, ptr4, ptr2)); } } } if (parameterDescsRef != null) { for (int i = 0; i < parameterDescsRef.Length; i++) { parameterDescsRef?[i].__MarshalFrom(ref array[i]); } } ((Result)(ref val)).CheckError(); } public unsafe void CreateMetaCommand(Guid commandId, int nodeMask, IntPtr creationParametersDataRef, PointerSize creationParametersDataSizeInBytes, Guid riid, out IntPtr metaCommandOut) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &metaCommandOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)61 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &commandId, nodeMask, (void*)creationParametersDataRef, PointerSize.op_Implicit(creationParametersDataSizeInBytes), &riid, ptr2)); } ((Result)(ref val)).CheckError(); } private unsafe StateObject CreateStateObject(StateObjectDescription descRef, Guid riid) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)62 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, &riid, &zero)); StateObject result = ((!(zero != IntPtr.Zero)) ? null : new StateObject(zero)); ((Result)(ref val)).CheckError(); return result; } public unsafe RaytracingAccelerationStructurePrebuildInformation GetRaytracingAccelerationStructurePrebuildInfo(BuildRaytracingAccelerationStructureInputs descRef) { BuildRaytracingAccelerationStructureInputs.__Native @ref = default(BuildRaytracingAccelerationStructureInputs.__Native); descRef.__MarshalTo(ref @ref); RaytracingAccelerationStructurePrebuildInformation result = default(RaytracingAccelerationStructurePrebuildInformation); ((delegate* unmanaged[Stdcall]<void*, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)63 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref, &result); descRef.__MarshalFree(ref @ref); return result; } public unsafe DriverMatchingIdentifierStatus CheckDriverMatchingIdentifier(SerializedDataType serializedDataType, ref SerializedDataDriverMatchingIdentifier identifierToCheckRef) { SerializedDataDriverMatchingIdentifier.__Native @ref = default(SerializedDataDriverMatchingIdentifier.__Native); identifierToCheckRef.__MarshalTo(ref @ref); DriverMatchingIdentifierStatus result = ((delegate* unmanaged[Stdcall]<void*, int, void*, DriverMatchingIdentifierStatus>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)64 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)serializedDataType, &@ref); identifierToCheckRef.__MarshalFree(ref @ref); return result; } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct GpuDescriptorHandle { public long Ptr; public static GpuDescriptorHandle operator +(GpuDescriptorHandle left, int right) { GpuDescriptorHandle result = default(GpuDescriptorHandle); result.Ptr = left.Ptr + right; return result; } } [Guid("5b160d0f-ac1b-4185-8ba8-b3ae42a5a455")] public class GraphicsCommandList : CommandList { public PrimitiveTopology PrimitiveTopology { set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SetPrimitiveTopology(value); } } public RawVector4 BlendFactor { set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) SetBlendFactor(value); } } public int StencilReference { set { SetStencilReference(value); } } public PipelineState PipelineState { set { SetPipelineState(value); } } public void ClearDepthStencilView(CpuDescriptorHandle depthStencilView, ClearFlags clearFlags, float depth, byte stencil) { ClearDepthStencilView(depthStencilView, clearFlags, depth, stencil, 0, null); } public void ClearRenderTargetView(CpuDescriptorHandle renderTargetView, RawColor4 colorRGBA) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ClearRenderTargetView(renderTargetView, colorRGBA, 0, null); } public void ResourceBarrierTransition(Resource resource, ResourceStates stateBefore, ResourceStates stateAfter) { ResourceBarrierTransition(resource, -1, stateBefore, stateAfter); } public unsafe void ResourceBarrierTransition(Resource resource, int subresource, ResourceStates stateBefore, ResourceStates stateAfter) { ResourceBarrier resourceBarrier = new ResourceBarrier(new ResourceTransitionBarrier(resource, subresource, stateBefore, stateAfter)); ResourceBarrier(1, new IntPtr(&resourceBarrier)); } public unsafe void ResourceBarrierAliasing(Resource resourceBefore, Resource resourceAfter) { ResourceBarrier resourceBarrier = new ResourceBarrier(new ResourceAliasingBarrier(resourceBefore, resourceAfter)); ResourceBarrier(1, new IntPtr(&resourceBarrier)); } public unsafe void ResourceBarrier(ResourceBarrier barrier) { ResourceBarrier(1, new IntPtr(&barrier)); } public unsafe void ResourceBarrier(params ResourceBarrier[] barriers) { if (barriers == null) { throw new ArgumentNullException("barriers"); } fixed (ResourceBarrier* ptr = barriers) { void* value = ptr; ResourceBarrier(barriers.Length, new IntPtr(value)); } } public void SetDescriptorHeaps(params DescriptorHeap[] descriptorHeaps) { SetDescriptorHeaps(descriptorHeaps.Length, descriptorHeaps); } public unsafe void SetRenderTargets(int numRenderTargetDescriptors, CpuDescriptorHandle renderTargetDescriptors, CpuDescriptorHandle? depthStencilDescriptorRef) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) SetRenderTargets(numRenderTargetDescriptors, new IntPtr(&renderTargetDescriptors), RawBool.op_Implicit(true), depthStencilDescriptorRef); } public unsafe void SetRenderTargets(CpuDescriptorHandle[] renderTargetDescriptors, CpuDescriptorHandle? depthStencilDescriptorRef) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) fixed (CpuDescriptorHandle* value = renderTargetDescriptors) { SetRenderTargets(renderTargetDescriptorsRef: new IntPtr(value), numRenderTargetDescriptors: (renderTargetDescriptors != null) ? renderTargetDescriptors.Length : 0, rTsSingleHandleToDescriptorRange: RawBool.op_Implicit(false), depthStencilDescriptorRef: depthStencilDescriptorRef); } } public unsafe void SetRenderTargets(CpuDescriptorHandle? renderTargetDescriptor, CpuDescriptorHandle? depthStencilDescriptorRef) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) CpuDescriptorHandle cpuDescriptorHandle = default(CpuDescriptorHandle); if (renderTargetDescriptor.HasValue) { cpuDescriptorHandle = renderTargetDescriptor.Value; } SetRenderTargets((cpuDescriptorHandle.Ptr != PointerSize.Zero) ? 1 : 0, renderTargetDescriptor.HasValue ? new IntPtr(&cpuDescriptorHandle) : IntPtr.Zero, RawBool.op_Implicit(false), depthStencilDescriptorRef); } public unsafe void SetVertexBuffers(int startSlot, VertexBufferView[] vertexBufferViews, int numBuffers) { fixed (VertexBufferView* ptr = vertexBufferViews) { void* value = ptr; SetVertexBuffers(startSlot, numBuffers, new IntPtr(value)); } } public void SetVertexBuffers(int startSlot, params VertexBufferView[] vertexBufferViews) { SetVertexBuffers(startSlot, vertexBufferViews, vertexBufferViews.Length); } public unsafe void SetVertexBuffer(int startSlot, VertexBufferView vertexBufferView) { SetVertexBuffers(startSlot, 1, (IntPtr)(&vertexBufferView)); } public unsafe void SetViewports(params RawViewportF[] viewports) { if (viewports == null) { throw new ArgumentNullException("viewports"); } fixed (RawViewportF* ptr = viewports) { void* ptr2 = ptr; SetViewports(viewports.Length, (IntPtr)ptr2); } } public unsafe void SetViewport(RawViewportF viewport) { SetViewports(1, new IntPtr(&viewport)); } public void SetScissorRectangles(params RawRectangle[] rectangles) { if (rectangles == null) { throw new ArgumentNullException("rectangles"); } SetScissorRectangles(rectangles.Length, rectangles); } public unsafe void SetScissorRectangles(RawRectangle rectangle) { SetScissorRectangles(1, new IntPtr(&rectangle)); } public void BeginEvent(string name) { if (name == null) { throw new ArgumentNullException("name"); } IntPtr intPtr = IntPtr.Zero; try { intPtr = Marshal.StringToHGlobalUni(name); BeginEvent(1, intPtr, name.Length); } finally { if (intPtr != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr); intPtr = IntPtr.Zero; } } } public void SetMarker(string name) { if (name == null) { throw new ArgumentNullException("name"); } IntPtr intPtr = IntPtr.Zero; try { intPtr = Marshal.StringToHGlobalUni(name); SetMarker(1, intPtr, name.Length); } finally { if (intPtr != IntPtr.Zero) { Marshal.FreeHGlobal(intPtr); intPtr = IntPtr.Zero; } } } public void ExecuteIndirect(CommandSignature commandSignature, int maxCommandCount, Resource argumentBuffer, long argumentBufferOffset) { ExecuteIndirect(commandSignature, maxCommandCount, argumentBuffer, argumentBufferOffset, null, 0L); } public GraphicsCommandList(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator GraphicsCommandList(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new GraphicsCommandList(nativePtr); } return null; } public unsafe void Close() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); ((Result)(ref val)).CheckError(); } public unsafe void Reset(CommandAllocator allocatorRef, PipelineState initialStateRef) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<CommandAllocator>((ICallbackable)(object)allocatorRef); zero2 = CppObject.ToCallbackPtr<PipelineState>((ICallbackable)(object)initialStateRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, (void*)zero2)); ((Result)(ref val)).CheckError(); } public unsafe void ClearState(PipelineState pipelineStateRef) { IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<PipelineState>((ICallbackable)(object)pipelineStateRef); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero); } public unsafe void DrawInstanced(int vertexCountPerInstance, int instanceCount, int startVertexLocation, int startInstanceLocation) { ((delegate* unmanaged[Stdcall]<void*, int, int, int, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, vertexCountPerInstance, instanceCount, startVertexLocation, startInstanceLocation); } public unsafe void DrawIndexedInstanced(int indexCountPerInstance, int instanceCount, int startIndexLocation, int baseVertexLocation, int startInstanceLocation) { ((delegate* unmanaged[Stdcall]<void*, int, int, int, int, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, indexCountPerInstance, instanceCount, startIndexLocation, baseVertexLocation, startInstanceLocation); } public unsafe void Dispatch(int threadGroupCountX, int threadGroupCountY, int threadGroupCountZ) { ((delegate* unmanaged[Stdcall]<void*, int, int, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, threadGroupCountX, threadGroupCountY, threadGroupCountZ); } public unsafe void CopyBufferRegion(Resource dstBufferRef, long dstOffset, Resource srcBufferRef, long srcOffset, long numBytes) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)dstBufferRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)srcBufferRef); ((delegate* unmanaged[Stdcall]<void*, void*, long, void*, long, long, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, dstOffset, (void*)zero2, srcOffset, numBytes); } public unsafe void CopyTextureRegion(TextureCopyLocation dstRef, int dstX, int dstY, int dstZ, TextureCopyLocation srcRef, ResourceRegion? srcBoxRef) { ResourceRegion value = default(ResourceRegion); if (srcBoxRef.HasValue) { value = srcBoxRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; TextureCopyLocation* num = &dstRef; TextureCopyLocation* num2 = &srcRef; ResourceRegion* intPtr = ((!srcBoxRef.HasValue) ? null : (&value)); ((delegate* unmanaged[Stdcall]<void*, void*, int, int, int, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(nativePointer, num, dstX, dstY, dstZ, num2, intPtr); } public unsafe void CopyResource(Resource dstResourceRef, Resource srcResourceRef) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)dstResourceRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)srcResourceRef); ((delegate* unmanaged[Stdcall]<void*, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, (void*)zero2); } public unsafe void CopyTiles(Resource tiledResourceRef, TiledResourceCoordinate tileRegionStartCoordinateRef, TileRegionSize tileRegionSizeRef, Resource bufferRef, long bufferStartOffsetInBytes, TileCopyFlags flags) { IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)tiledResourceRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)bufferRef); ((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, long, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, &tileRegionStartCoordinateRef, &tileRegionSizeRef, (void*)zero2, bufferStartOffsetInBytes, (int)flags); } public unsafe void ResolveSubresource(Resource dstResourceRef, int dstSubresource, Resource srcResourceRef, int srcSubresource, Format format) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected I4, but got Unknown IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)dstResourceRef); zero2 = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)srcResourceRef); ((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, dstSubresource, (void*)zero2, srcSubresource, (int)format); } internal unsafe void SetPrimitiveTopology(PrimitiveTopology primitiveTopology) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected I4, but got Unknown ((delegate* unmanaged[Stdcall]<void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)primitiveTopology); } public unsafe void SetViewports(int numViewports, Viewport[] viewportsRef) { fixed (Viewport* ptr = viewportsRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numViewports, ptr2); } } public unsafe void SetScissorRectangles(int numRects, RawRectangle[] rectsRef) { fixed (RawRectangle* ptr = rectsRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numRects, ptr2); } } internal unsafe void SetBlendFactor(RawVector4 blendFactor) { ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &blendFactor); } internal unsafe void SetStencilReference(int stencilRef) { ((delegate* unmanaged[Stdcall]<void*, int, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)24 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, stencilRef); } internal unsafe void SetPipelineState(PipelineState pipelineStateRef) { IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<PipelineState>((ICallbackable)(object)pipelineStateRef); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)25 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero); } private unsafe void ResourceBarrier(int numBarriers, IntPtr barriersRef) { ((delegate* unmanaged[Stdcall]<void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)26 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, numBarriers, (void*)barriersRef); } public unsafe void ExecuteBundle(GraphicsCommandList commandListRef) { IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<GraphicsCommandList>((ICallbackable)(object)commandListRef); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)27 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*
BepInEx/plugins/DearImGuiInjection/SharpDX.Direct3D11.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.Mathematics.Interop; using SharpDX.Win32; [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xiaoxiao921/SharpDX")] [assembly: AssemblyTitle("SharpDX.Direct3D11")] [assembly: AssemblyProduct("SharpDX.Direct3D11")] [assembly: AssemblyDescription("Assembly providing DirectX - Direct3D11, Direct3D11.1 and Effects11 managed API.")] [assembly: AssemblyCopyright("Copyright (c) 2010-2016 Alexandre Mutel")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCompany("Alexandre Mutel")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyInformationalVersion("4.2.1-beta0+7abb72df54")] [assembly: AssemblyFileVersion("4.2.1.34")] [assembly: ComVisible(false)] [assembly: InternalsVisibleTo("SharpDX.Direct3D11.Effects")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.2.0.0")] [module: UnverifiableCode] internal class <Module> { static <Module>() { ModuleInit.Setup(); } } internal sealed class ThisAssembly { internal const string AssemblyVersion = "4.2.0.0"; internal const string AssemblyFileVersion = "4.2.1.34"; internal const string AssemblyInformationalVersion = "4.2.1-beta0+7abb72df54"; internal const string AssemblyName = "SharpDX.Direct3D11"; internal const string AssemblyTitle = "SharpDX.Direct3D11"; internal const string AssemblyConfiguration = "Release"; internal const string GitCommitId = "7abb72df544eaede656c546ee71a8ad1be9dd19b"; internal const string RootNamespace = "SharpDX.Direct3D11"; private ThisAssembly() { } } namespace SharpDX.Direct3D11; [CompilerGenerated] internal class AssemblyDoc { } [Guid("75b68faa-347d-4159-8f45-a0640f01cd9a")] public class BlendState : DeviceChild { public BlendStateDescription Description { get { GetDescription(out var descRef); return descRef; } } public BlendState(Device device, BlendStateDescription description) : base(IntPtr.Zero) { device.CreateBlendState(ref description, this); } public BlendState(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator BlendState(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new BlendState(nativePtr); } return null; } internal unsafe void GetDescription(out BlendStateDescription descRef) { BlendStateDescription.__Native @ref = default(BlendStateDescription.__Native); descRef = default(BlendStateDescription); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref); descRef.__MarshalFrom(ref @ref); } } [Guid("cc86fabe-da55-401d-85e7-e3c9de2877e9")] public class BlendState1 : BlendState { public BlendStateDescription1 Description1 { get { GetDescription1(out var descRef); return descRef; } } public BlendState1(Device1 device, BlendStateDescription1 description) : base(IntPtr.Zero) { device.CreateBlendState1(ref description, this); } public BlendState1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator BlendState1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new BlendState1(nativePtr); } return null; } internal unsafe void GetDescription1(out BlendStateDescription1 descRef) { BlendStateDescription1.__Native @ref = default(BlendStateDescription1.__Native); descRef = default(BlendStateDescription1); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref); descRef.__MarshalFrom(ref @ref); } } public struct BlendStateDescription { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct __Native { public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; public RenderTargetBlendDescription RenderTarget; public RenderTargetBlendDescription __RenderTarget1; public RenderTargetBlendDescription __RenderTarget2; public RenderTargetBlendDescription __RenderTarget3; public RenderTargetBlendDescription __RenderTarget4; public RenderTargetBlendDescription __RenderTarget5; public RenderTargetBlendDescription __RenderTarget6; public RenderTargetBlendDescription __RenderTarget7; } public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; internal RenderTargetBlendDescription[] _RenderTarget; public RenderTargetBlendDescription[] RenderTarget { get { return _RenderTarget ?? (_RenderTarget = new RenderTargetBlendDescription[8]); } private set { _RenderTarget = value; } } public static BlendStateDescription Default() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription blendStateDescription = default(BlendStateDescription); blendStateDescription.AlphaToCoverageEnable = RawBool.op_Implicit(false); blendStateDescription.IndependentBlendEnable = RawBool.op_Implicit(false); BlendStateDescription result = blendStateDescription; RenderTargetBlendDescription[] renderTarget = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget[i].IsBlendEnabled = RawBool.op_Implicit(false); renderTarget[i].SourceBlend = BlendOption.One; renderTarget[i].DestinationBlend = BlendOption.Zero; renderTarget[i].BlendOperation = BlendOperation.Add; renderTarget[i].SourceAlphaBlend = BlendOption.One; renderTarget[i].DestinationAlphaBlend = BlendOption.Zero; renderTarget[i].AlphaBlendOperation = BlendOperation.Add; renderTarget[i].RenderTargetWriteMask = ColorWriteMaskFlags.All; } return result; } public BlendStateDescription Clone() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription blendStateDescription = default(BlendStateDescription); blendStateDescription.AlphaToCoverageEnable = AlphaToCoverageEnable; blendStateDescription.IndependentBlendEnable = IndependentBlendEnable; BlendStateDescription result = blendStateDescription; RenderTargetBlendDescription[] renderTarget = RenderTarget; RenderTargetBlendDescription[] renderTarget2 = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget2[i] = renderTarget[i]; } return result; } internal void __MarshalFree(ref __Native @ref) { } internal unsafe void __MarshalFrom(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AlphaToCoverageEnable = @ref.AlphaToCoverageEnable; IndependentBlendEnable = @ref.IndependentBlendEnable; fixed (RenderTargetBlendDescription* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr2, (IntPtr)ptr4, 8 * Unsafe.SizeOf<RenderTargetBlendDescription>()); } } } internal unsafe void __MarshalTo(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) @ref.AlphaToCoverageEnable = AlphaToCoverageEnable; @ref.IndependentBlendEnable = IndependentBlendEnable; fixed (RenderTargetBlendDescription* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr4, (IntPtr)ptr2, 8 * Unsafe.SizeOf<RenderTargetBlendDescription>()); } } } } public struct BlendStateDescription1 { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] internal struct __Native { public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; public RenderTargetBlendDescription1 RenderTarget; public RenderTargetBlendDescription1 __RenderTarget1; public RenderTargetBlendDescription1 __RenderTarget2; public RenderTargetBlendDescription1 __RenderTarget3; public RenderTargetBlendDescription1 __RenderTarget4; public RenderTargetBlendDescription1 __RenderTarget5; public RenderTargetBlendDescription1 __RenderTarget6; public RenderTargetBlendDescription1 __RenderTarget7; } public RawBool AlphaToCoverageEnable; public RawBool IndependentBlendEnable; internal RenderTargetBlendDescription1[] _RenderTarget; public RenderTargetBlendDescription1[] RenderTarget { get { return _RenderTarget ?? (_RenderTarget = new RenderTargetBlendDescription1[8]); } private set { _RenderTarget = value; } } public static BlendStateDescription1 Default() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription1 blendStateDescription = default(BlendStateDescription1); blendStateDescription.AlphaToCoverageEnable = RawBool.op_Implicit(false); blendStateDescription.IndependentBlendEnable = RawBool.op_Implicit(false); BlendStateDescription1 result = blendStateDescription; RenderTargetBlendDescription1[] renderTarget = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget[i].IsBlendEnabled = RawBool.op_Implicit(false); renderTarget[i].IsLogicOperationEnabled = RawBool.op_Implicit(false); renderTarget[i].SourceBlend = BlendOption.One; renderTarget[i].DestinationBlend = BlendOption.Zero; renderTarget[i].BlendOperation = BlendOperation.Add; renderTarget[i].SourceAlphaBlend = BlendOption.One; renderTarget[i].DestinationAlphaBlend = BlendOption.Zero; renderTarget[i].AlphaBlendOperation = BlendOperation.Add; renderTarget[i].RenderTargetWriteMask = ColorWriteMaskFlags.All; renderTarget[i].LogicOperation = LogicOperation.Noop; } return result; } public BlendStateDescription1 Clone() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription1 blendStateDescription = default(BlendStateDescription1); blendStateDescription.AlphaToCoverageEnable = AlphaToCoverageEnable; blendStateDescription.IndependentBlendEnable = IndependentBlendEnable; BlendStateDescription1 result = blendStateDescription; RenderTargetBlendDescription1[] renderTarget = RenderTarget; RenderTargetBlendDescription1[] renderTarget2 = result.RenderTarget; for (int i = 0; i < renderTarget.Length; i++) { renderTarget2[i] = renderTarget[i]; } return result; } internal void __MarshalFree(ref __Native @ref) { } internal unsafe void __MarshalFrom(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AlphaToCoverageEnable = @ref.AlphaToCoverageEnable; IndependentBlendEnable = @ref.IndependentBlendEnable; fixed (RenderTargetBlendDescription1* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription1* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr2, (IntPtr)ptr4, 8 * Unsafe.SizeOf<RenderTargetBlendDescription1>()); } } } internal unsafe void __MarshalTo(ref __Native @ref) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) @ref.AlphaToCoverageEnable = AlphaToCoverageEnable; @ref.IndependentBlendEnable = IndependentBlendEnable; fixed (RenderTargetBlendDescription1* ptr = &RenderTarget[0]) { void* ptr2 = ptr; fixed (RenderTargetBlendDescription1* ptr3 = &@ref.RenderTarget) { void* ptr4 = ptr3; Utilities.CopyMemory((IntPtr)ptr4, (IntPtr)ptr2, 8 * Unsafe.SizeOf<RenderTargetBlendDescription1>()); } } } } [Guid("48570b85-d1ee-4fcd-a250-eb350722b037")] public class Buffer : Resource { public BufferDescription Description { get { GetDescription(out var descRef); return descRef; } } public Buffer(Device device, BufferDescription description) : base(IntPtr.Zero) { device.CreateBuffer(ref description, null, this); } public Buffer(Device device, DataStream data, BufferDescription description) : base(IntPtr.Zero) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) device.CreateBuffer(ref description, (DataBox?)new DataBox(data.PositionPointer, 0, 0), this); } public Buffer(Device device, IntPtr dataPointer, BufferDescription description) : base(IntPtr.Zero) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) device.CreateBuffer(ref description, (dataPointer != IntPtr.Zero) ? new DataBox?(new DataBox(dataPointer, 0, 0)) : null, this); } public Buffer(Device device, int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags accessFlags, ResourceOptionFlags optionFlags, int structureByteStride) : base(IntPtr.Zero) { BufferDescription descRef = new BufferDescription { BindFlags = bindFlags, CpuAccessFlags = accessFlags, OptionFlags = optionFlags, SizeInBytes = sizeInBytes, Usage = usage, StructureByteStride = structureByteStride }; device.CreateBuffer(ref descRef, null, this); } public Buffer(Device device, DataStream data, int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags accessFlags, ResourceOptionFlags optionFlags, int structureByteStride) : base(IntPtr.Zero) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) BufferDescription descRef = new BufferDescription { BindFlags = bindFlags, CpuAccessFlags = accessFlags, OptionFlags = optionFlags, SizeInBytes = sizeInBytes, Usage = usage, StructureByteStride = structureByteStride }; device.CreateBuffer(ref descRef, (DataBox?)new DataBox(data.PositionPointer, 0, 0), this); } public unsafe static Buffer Create<T>(Device device, BindFlags bindFlags, ref T data, int sizeInBytes = 0, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags accessFlags = CpuAccessFlags.None, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, int structureByteStride = 0) where T : struct { //IL_005e: Unknown result type (might be due to invalid IL or missing references) Buffer buffer = new Buffer(IntPtr.Zero); BufferDescription bufferDescription = default(BufferDescription); bufferDescription.BindFlags = bindFlags; bufferDescription.CpuAccessFlags = accessFlags; bufferDescription.OptionFlags = optionFlags; bufferDescription.SizeInBytes = ((sizeInBytes == 0) ? Utilities.SizeOf<T>() : sizeInBytes); bufferDescription.Usage = usage; bufferDescription.StructureByteStride = structureByteStride; BufferDescription descRef = bufferDescription; fixed (T* ptr = &data) { device.CreateBuffer(ref descRef, (DataBox?)new DataBox((IntPtr)ptr), buffer); return buffer; } } public unsafe static Buffer Create<T>(Device device, BindFlags bindFlags, T[] data, int sizeInBytes = 0, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags accessFlags = CpuAccessFlags.None, ResourceOptionFlags optionFlags = ResourceOptionFlags.None, int structureByteStride = 0) where T : struct { //IL_0068: Unknown result type (might be due to invalid IL or missing references) Buffer buffer = new Buffer(IntPtr.Zero); BufferDescription bufferDescription = default(BufferDescription); bufferDescription.BindFlags = bindFlags; bufferDescription.CpuAccessFlags = accessFlags; bufferDescription.OptionFlags = optionFlags; bufferDescription.SizeInBytes = ((sizeInBytes == 0) ? (Utilities.SizeOf<T>() * data.Length) : sizeInBytes); bufferDescription.Usage = usage; bufferDescription.StructureByteStride = structureByteStride; BufferDescription descRef = bufferDescription; fixed (T* ptr = &data[0]) { device.CreateBuffer(ref descRef, (DataBox?)new DataBox((IntPtr)ptr), buffer); return buffer; } } public unsafe static Buffer Create<T>(Device device, ref T data, BufferDescription description) where T : struct { //IL_002a: Unknown result type (might be due to invalid IL or missing references) Buffer buffer = new Buffer(IntPtr.Zero); if (description.SizeInBytes == 0) { description.SizeInBytes = Utilities.SizeOf<T>(); } fixed (T* ptr = &data) { device.CreateBuffer(ref description, (DataBox?)new DataBox((IntPtr)ptr), buffer); return buffer; } } public unsafe static Buffer Create<T>(Device device, T[] data, BufferDescription description) where T : struct { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Buffer buffer = new Buffer(IntPtr.Zero); if (description.SizeInBytes == 0) { description.SizeInBytes = Utilities.SizeOf<T>() * data.Length; } fixed (T* ptr = &data[0]) { device.CreateBuffer(ref description, (DataBox?)new DataBox((IntPtr)ptr), buffer); return buffer; } } public Buffer(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Buffer(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Buffer(nativePtr); } return null; } internal unsafe void GetDescription(out BufferDescription descRef) { descRef = default(BufferDescription); fixed (BufferDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct BufferDescription { public int SizeInBytes; public ResourceUsage Usage; public BindFlags BindFlags; public CpuAccessFlags CpuAccessFlags; public ResourceOptionFlags OptionFlags; public int StructureByteStride; public BufferDescription(int sizeInBytes, ResourceUsage usage, BindFlags bindFlags, CpuAccessFlags cpuAccessFlags, ResourceOptionFlags optionFlags, int structureByteStride) { SizeInBytes = sizeInBytes; Usage = usage; BindFlags = bindFlags; CpuAccessFlags = cpuAccessFlags; OptionFlags = optionFlags; StructureByteStride = structureByteStride; } public BufferDescription(int sizeInBytes, BindFlags bindFlags, ResourceUsage usage) { this = default(BufferDescription); SizeInBytes = sizeInBytes; BindFlags = bindFlags; Usage = usage; } } [Guid("a6cd7faa-b0b7-4a2f-9436-8662a65797cb")] public class ClassInstance : DeviceChild { public unsafe string InstanceName { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) PointerSize bufferLengthRef = default(PointerSize); GetInstanceName(IntPtr.Zero, ref bufferLengthRef); sbyte* ptr = stackalloc sbyte[(int)(uint)PointerSize.op_Implicit(bufferLengthRef)]; GetInstanceName((IntPtr)ptr, ref bufferLengthRef); return Marshal.PtrToStringAnsi((IntPtr)ptr); } } public unsafe string TypeName { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) PointerSize bufferLengthRef = default(PointerSize); GetInstanceName(IntPtr.Zero, ref bufferLengthRef); sbyte* ptr = stackalloc sbyte[(int)(uint)PointerSize.op_Implicit(bufferLengthRef)]; GetTypeName((IntPtr)ptr, ref bufferLengthRef); return Marshal.PtrToStringAnsi((IntPtr)ptr); } } public ClassLinkage ClassLinkage { get { GetClassLinkage(out var linkageOut); return linkageOut; } } public ClassInstanceDescription Description { get { GetDescription(out var descRef); return descRef; } } public ClassInstance(ClassLinkage linkage, string classTypeName, int constantBufferOffset, int constantVectorOffset, int textureOffset, int samplerOffset) : base(IntPtr.Zero) { linkage.CreateClassInstance(classTypeName, constantBufferOffset, constantVectorOffset, textureOffset, samplerOffset, this); } public ClassInstance(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator ClassInstance(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new ClassInstance(nativePtr); } return null; } internal unsafe void GetClassLinkage(out ClassLinkage linkageOut) { IntPtr zero = IntPtr.Zero; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero); if (zero != IntPtr.Zero) { linkageOut = new ClassLinkage(zero); } else { linkageOut = null; } } internal unsafe void GetDescription(out ClassInstanceDescription descRef) { descRef = default(ClassInstanceDescription); fixed (ClassInstanceDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } internal unsafe void GetInstanceName(IntPtr instanceNameRef, ref PointerSize bufferLengthRef) { fixed (PointerSize* ptr = &bufferLengthRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)instanceNameRef, ptr2); } } internal unsafe void GetTypeName(IntPtr typeNameRef, ref PointerSize bufferLengthRef) { fixed (PointerSize* ptr = &bufferLengthRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)typeNameRef, ptr2); } } } [Guid("ddf57cba-9543-46e4-a12b-f207a0fe7fed")] public class ClassLinkage : DeviceChild { public ClassLinkage(Device device) : base(IntPtr.Zero) { device.CreateClassLinkage(this); } public ClassLinkage(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator ClassLinkage(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new ClassLinkage(nativePtr); } return null; } public unsafe ClassInstance GetClassInstance(string classInstanceNameRef, int instanceIndex) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr intPtr = Marshal.StringToHGlobalAnsi(classInstanceNameRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)intPtr, instanceIndex, &zero)); ClassInstance result = ((!(zero != IntPtr.Zero)) ? null : new ClassInstance(zero)); Marshal.FreeHGlobal(intPtr); ((Result)(ref val)).CheckError(); return result; } internal unsafe void CreateClassInstance(string classTypeNameRef, int constantBufferOffset, int constantVectorOffset, int textureOffset, int samplerOffset, ClassInstance instanceOut) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr intPtr = Marshal.StringToHGlobalAnsi(classTypeNameRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, int, int, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)intPtr, constantBufferOffset, constantVectorOffset, textureOffset, samplerOffset, &zero)); ((CppObject)instanceOut).NativePointer = zero; Marshal.FreeHGlobal(intPtr); ((Result)(ref val)).CheckError(); } } [Guid("4f5b196e-c2bd-495e-bd01-1fded38e4969")] public class ComputeShader : DeviceChild { public unsafe ComputeShader(Device device, byte[] shaderBytecode, ClassLinkage linkage = null) : base(IntPtr.Zero) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (shaderBytecode == null) { throw new ArgumentNullException("shaderBytecode", "ShaderBytecode cannot be null"); } fixed (byte* ptr = shaderBytecode) { void* ptr2 = ptr; device.CreateComputeShader((IntPtr)ptr2, PointerSize.op_Implicit(shaderBytecode.Length), linkage, this); } } public ComputeShader(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator ComputeShader(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new ComputeShader(nativePtr); } return null; } } [Guid("6e8c49fb-a371-4770-b440-29086022b741")] public class Counter : Asynchronous { public CounterDescription Description { get { GetDescription(out var descRef); return descRef; } } public Counter(Device device, CounterDescription description) : base(IntPtr.Zero) { device.CreateCounter(description, this); } public Counter(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Counter(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Counter(nativePtr); } return null; } internal unsafe void GetDescription(out CounterDescription descRef) { descRef = default(CounterDescription); fixed (CounterDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } } public class CounterMetadata { public CounterType Type { get; internal set; } public int HardwareCounterCount { get; internal set; } public string Name { get; internal set; } public string Units { get; internal set; } public string Description { get; internal set; } } [Guid("03823efb-8d8f-4e1c-9aa2-f64bb2cbfdf1")] public class DepthStencilState : DeviceChild { public DepthStencilStateDescription Description { get { GetDescription(out var descRef); return descRef; } } public DepthStencilState(Device device, DepthStencilStateDescription description) : base(IntPtr.Zero) { device.CreateDepthStencilState(ref description, this); } public DepthStencilState(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DepthStencilState(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DepthStencilState(nativePtr); } return null; } internal unsafe void GetDescription(out DepthStencilStateDescription descRef) { descRef = default(DepthStencilStateDescription); fixed (DepthStencilStateDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct DepthStencilStateDescription { public RawBool IsDepthEnabled; public DepthWriteMask DepthWriteMask; public Comparison DepthComparison; public RawBool IsStencilEnabled; public byte StencilReadMask; public byte StencilWriteMask; public DepthStencilOperationDescription FrontFace; public DepthStencilOperationDescription BackFace; public static DepthStencilStateDescription Default() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) DepthStencilStateDescription result = default(DepthStencilStateDescription); result.IsDepthEnabled = RawBool.op_Implicit(true); result.DepthWriteMask = DepthWriteMask.All; result.DepthComparison = Comparison.Less; result.IsStencilEnabled = RawBool.op_Implicit(false); result.StencilReadMask = byte.MaxValue; result.StencilWriteMask = byte.MaxValue; result.FrontFace.Comparison = Comparison.Always; result.FrontFace.DepthFailOperation = StencilOperation.Keep; result.FrontFace.FailOperation = StencilOperation.Keep; result.FrontFace.PassOperation = StencilOperation.Keep; result.BackFace.Comparison = Comparison.Always; result.BackFace.DepthFailOperation = StencilOperation.Keep; result.BackFace.FailOperation = StencilOperation.Keep; result.BackFace.PassOperation = StencilOperation.Keep; return result; } } [Guid("9fdac92a-1876-48c3-afad-25b94f84a9b6")] public class DepthStencilView : ResourceView { public DepthStencilViewDescription Description { get { GetDescription(out var descRef); return descRef; } } public DepthStencilView(Device device, Resource resource) : base(IntPtr.Zero) { device.CreateDepthStencilView(resource, null, this); } public DepthStencilView(Device device, Resource resource, DepthStencilViewDescription description) : base(IntPtr.Zero) { device.CreateDepthStencilView(resource, description, this); } public DepthStencilView(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator DepthStencilView(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new DepthStencilView(nativePtr); } return null; } internal unsafe void GetDescription(out DepthStencilViewDescription descRef) { descRef = default(DepthStencilViewDescription); fixed (DepthStencilViewDescription* ptr = &descRef) { void* ptr2 = ptr; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2); } } } [Guid("db6f6ddb-ac77-4e88-8253-819df9bbf140")] public class Device : ComObject { public const int MultisampleCountMaximum = 32; protected internal DeviceContext ImmediateContext__; public unsafe string DebugName { get { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) byte* ptr = stackalloc byte[1024]; int dataSizeRef = 1023; Result privateData = GetPrivateData(CommonGuid.DebugObjectName, ref dataSizeRef, new IntPtr(ptr)); if (((Result)(ref privateData)).Failure) { return string.Empty; } ptr[dataSizeRef] = 0; return Marshal.PtrToStringAnsi(new IntPtr(ptr)); } set { if (string.IsNullOrEmpty(value)) { SetPrivateData(CommonGuid.DebugObjectName, 0, IntPtr.Zero); return; } IntPtr dataRef = Utilities.StringToHGlobalAnsi(value); SetPrivateData(CommonGuid.DebugObjectName, value.Length, dataRef); } } public FeatureLevel FeatureLevel => GetFeatureLevel(); public DeviceCreationFlags CreationFlags => GetCreationFlags(); public Result DeviceRemovedReason => GetDeviceRemovedReason(); public DeviceContext ImmediateContext { get { if (ImmediateContext__ == null) { GetImmediateContext(out ImmediateContext__); } return ImmediateContext__; } } public int ExceptionMode { get { return GetExceptionMode(); } set { SetExceptionMode(value); } } public Device(DriverType driverType) : this(driverType, DeviceCreationFlags.None) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) public Device(Adapter adapter) : this(adapter, DeviceCreationFlags.None) { } public Device(DriverType driverType, DeviceCreationFlags flags) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) CreateDevice(null, driverType, flags, null); } public Device(Adapter adapter, DeviceCreationFlags flags) { CreateDevice(adapter, (DriverType)0, flags, null); } public Device(DriverType driverType, DeviceCreationFlags flags, params FeatureLevel[] featureLevels) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) CreateDevice(null, driverType, flags, featureLevels); } public Device(Adapter adapter, DeviceCreationFlags flags, params FeatureLevel[] featureLevels) { CreateDevice(adapter, (DriverType)0, flags, featureLevels); } public static void CreateWithSwapChain(DriverType driverType, DeviceCreationFlags flags, SwapChainDescription swapChainDescription, out Device device, out SwapChain swapChain) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) CreateWithSwapChain(null, driverType, flags, null, swapChainDescription, out device, out swapChain); } public static void CreateWithSwapChain(Adapter adapter, DeviceCreationFlags flags, SwapChainDescription swapChainDescription, out Device device, out SwapChain swapChain) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) CreateWithSwapChain(adapter, (DriverType)0, flags, null, swapChainDescription, out device, out swapChain); } public static void CreateWithSwapChain(DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, out Device device, out SwapChain swapChain) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) CreateWithSwapChain(null, driverType, flags, featureLevels, swapChainDescription, out device, out swapChain); } public static void CreateWithSwapChain(Adapter adapter, DeviceCreationFlags flags, FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, out Device device, out SwapChain swapChain) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) CreateWithSwapChain(adapter, (DriverType)0, flags, featureLevels, swapChainDescription, out device, out swapChain); } private static void CreateWithSwapChain(Adapter adapter, DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels, SwapChainDescription swapChainDescription, out Device device, out SwapChain swapChain) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown device = ((adapter == null) ? new Device(driverType, flags, featureLevels) : new Device(adapter, flags, featureLevels)); Factory1 val = new Factory1(); try { swapChain = new SwapChain((Factory)(object)val, (ComObject)(object)device, swapChainDescription); } finally { ((IDisposable)val)?.Dispose(); } } public unsafe CounterMetadata GetCounterMetadata(CounterDescription counterDescription) { CounterMetadata counterMetadata = new CounterMetadata(); int num = 0; int num2 = 0; int num3 = 0; CheckCounter(counterDescription, out var typeRef, out var activeCountersRef, IntPtr.Zero, new IntPtr(&num), IntPtr.Zero, new IntPtr(&num2), IntPtr.Zero, new IntPtr(&num3)); sbyte* ptr = stackalloc sbyte[(int)(uint)num]; sbyte* ptr2 = stackalloc sbyte[(int)(uint)num2]; sbyte* ptr3 = stackalloc sbyte[(int)(uint)num3]; CheckCounter(counterDescription, out typeRef, out activeCountersRef, new IntPtr(ptr), new IntPtr(&num), new IntPtr(ptr2), new IntPtr(&num2), new IntPtr(ptr3), new IntPtr(&num3)); counterMetadata.Type = typeRef; counterMetadata.HardwareCounterCount = activeCountersRef; counterMetadata.Name = Marshal.PtrToStringAnsi((IntPtr)ptr, num); counterMetadata.Units = Marshal.PtrToStringAnsi((IntPtr)ptr2, num2); counterMetadata.Description = Marshal.PtrToStringAnsi((IntPtr)ptr3, num3); return counterMetadata; } public T OpenSharedResource<T>(IntPtr resourceHandle) where T : ComObject { OpenSharedResource(resourceHandle, Utilities.GetGuidFromType(typeof(T)), out var resourceOut); return CppObject.FromPointer<T>(resourceOut); } public unsafe ComputeShaderFormatSupport CheckComputeShaderFormatSupport(Format format) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) FeatureDataFormatSupport2 featureDataFormatSupport = default(FeatureDataFormatSupport2); featureDataFormatSupport.InFormat = format; Result val = CheckFeatureSupport(Feature.ComputeShaders, new IntPtr(&featureDataFormatSupport), Utilities.SizeOf<FeatureDataFormatSupport2>()); if (((Result)(ref val)).Failure) { return ComputeShaderFormatSupport.None; } return featureDataFormatSupport.OutFormatSupport2; } public unsafe FeatureDataD3D11Options CheckD3D11Feature() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options result = default(FeatureDataD3D11Options); Result val = CheckFeatureSupport(Feature.D3D11Options, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options); } return result; } public unsafe FeatureDataShaderMinimumPrecisionSupport CheckShaderMinimumPrecisionSupport() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) FeatureDataShaderMinimumPrecisionSupport result = default(FeatureDataShaderMinimumPrecisionSupport); Result val = CheckFeatureSupport(Feature.ShaderMinimumPrecisionSupport, new IntPtr(&result), Utilities.SizeOf<FeatureDataShaderMinimumPrecisionSupport>()); if (((Result)(ref val)).Failure) { return default(FeatureDataShaderMinimumPrecisionSupport); } return result; } public unsafe bool CheckFullNonPow2TextureSupport() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D9Options featureDataD3D9Options = default(FeatureDataD3D9Options); Result val = CheckFeatureSupport(Feature.D3D9Options, new IntPtr(&featureDataD3D9Options), Utilities.SizeOf<FeatureDataD3D9Options>()); if ((int)FeatureLevel <= 37632) { return ((Result)(ref val)).Failure; } if (((Result)(ref val)).Failure) { return false; } return RawBool.op_Implicit(featureDataD3D9Options.FullNonPow2TextureSupport); } public unsafe bool CheckTileBasedDeferredRendererSupport() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) FeatureDataArchitectureInformation featureDataArchitectureInformation = default(FeatureDataArchitectureInformation); Result val = CheckFeatureSupport(Feature.ArchitectureInformation, new IntPtr(&featureDataArchitectureInformation), Utilities.SizeOf<FeatureDataArchitectureInformation>()); if (((Result)(ref val)).Failure) { return false; } return RawBool.op_Implicit(featureDataArchitectureInformation.TileBasedDeferredRenderer); } public unsafe FeatureDataD3D11Options1 CheckD3D112Feature() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options1 result = default(FeatureDataD3D11Options1); Result val = CheckFeatureSupport(Feature.D3D11Options1, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options1>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options1); } return result; } public unsafe FeatureDataD3D11Options2 CheckD3D113Features2() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options2 result = default(FeatureDataD3D11Options2); Result val = CheckFeatureSupport(Feature.D3D11Options2, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options2>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options2); } return result; } public unsafe FeatureDataD3D11Options3 CheckD3D113Features3() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options3 result = default(FeatureDataD3D11Options3); Result val = CheckFeatureSupport(Feature.D3D11Options3, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options3>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options3); } return result; } public unsafe FeatureDataD3D11Options4 CheckD3D113Features4() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options4 result = default(FeatureDataD3D11Options4); Result val = CheckFeatureSupport(Feature.D3D11Options4, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options4>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options4); } return result; } public unsafe FeatureDataD3D11Options5 CheckD3D113Feature5() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) FeatureDataD3D11Options5 result = default(FeatureDataD3D11Options5); Result val = CheckFeatureSupport(Feature.D3D11Options5, new IntPtr(&result), Utilities.SizeOf<FeatureDataD3D11Options5>()); if (((Result)(ref val)).Failure) { return default(FeatureDataD3D11Options5); } return result; } public unsafe bool CheckFeatureSupport(Feature feature) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Result val; switch (feature) { case Feature.ShaderDoubles: { FeatureDataDoubles featureDataDoubles = default(FeatureDataDoubles); val = CheckFeatureSupport(Feature.ShaderDoubles, new IntPtr(&featureDataDoubles), Utilities.SizeOf<FeatureDataDoubles>()); if (((Result)(ref val)).Failure) { return false; } return RawBool.op_Implicit(featureDataDoubles.DoublePrecisionFloatShaderOps); } case Feature.ComputeShaders: case Feature.D3D10XHardwareOptions: { FeatureDataD3D10XHardwareOptions featureDataD3D10XHardwareOptions = default(FeatureDataD3D10XHardwareOptions); val = CheckFeatureSupport(Feature.D3D10XHardwareOptions, new IntPtr(&featureDataD3D10XHardwareOptions), Utilities.SizeOf<FeatureDataD3D10XHardwareOptions>()); if (((Result)(ref val)).Failure) { return false; } return RawBool.op_Implicit(featureDataD3D10XHardwareOptions.ComputeShadersPlusRawAndStructuredBuffersViaShader4X); } default: throw new SharpDXException("Unsupported Feature. Use specialized CheckXXX methods", Array.Empty<object>()); } } public unsafe Result CheckThreadingSupport(out bool supportsConcurrentResources, out bool supportsCommandLists) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) FeatureDataThreading featureDataThreading = default(FeatureDataThreading); Result result = CheckFeatureSupport(Feature.Threading, new IntPtr(&featureDataThreading), Utilities.SizeOf<FeatureDataThreading>()); if (((Result)(ref result)).Failure) { supportsConcurrentResources = false; supportsCommandLists = false; } else { supportsConcurrentResources = RawBool.op_Implicit(featureDataThreading.DriverConcurrentCreates); supportsCommandLists = RawBool.op_Implicit(featureDataThreading.DriverCommandLists); } return result; } public static bool IsSupportedFeatureLevel(FeatureLevel featureLevel) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected I4, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Device device = new Device(IntPtr.Zero); DeviceContext immediateContextOut = null; try { FeatureLevel featureLevelRef; Result val = D3D11.CreateDevice(null, (DriverType)1, IntPtr.Zero, DeviceCreationFlags.None, (FeatureLevel[])(object)new FeatureLevel[1] { (FeatureLevel)(int)featureLevel }, 1, 7, device, out featureLevelRef, out immediateContextOut); return ((Result)(ref val)).Success && featureLevelRef == featureLevel; } finally { if (immediateContextOut != null) { ((DisposeBase)immediateContextOut).Dispose(); } if (((CppObject)device).NativePointer != IntPtr.Zero) { ((DisposeBase)device).Dispose(); } } } public static bool IsSupportedFeatureLevel(Adapter adapter, FeatureLevel featureLevel) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected I4, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Device device = new Device(IntPtr.Zero); DeviceContext immediateContextOut = null; try { FeatureLevel featureLevelRef; Result val = D3D11.CreateDevice(adapter, (DriverType)0, IntPtr.Zero, DeviceCreationFlags.None, (FeatureLevel[])(object)new FeatureLevel[1] { (FeatureLevel)(int)featureLevel }, 1, 7, device, out featureLevelRef, out immediateContextOut); return ((Result)(ref val)).Success && featureLevelRef == featureLevel; } finally { if (immediateContextOut != null) { ((DisposeBase)immediateContextOut).Dispose(); } if (((CppObject)device).NativePointer != IntPtr.Zero) { ((DisposeBase)device).Dispose(); } } } public static FeatureLevel GetSupportedFeatureLevel() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Device device = new Device(IntPtr.Zero); FeatureLevel featureLevelRef; DeviceContext immediateContextOut; Result val = D3D11.CreateDevice(null, (DriverType)1, IntPtr.Zero, DeviceCreationFlags.None, null, 0, 7, device, out featureLevelRef, out immediateContextOut); ((Result)(ref val)).CheckError(); ((DisposeBase)immediateContextOut).Dispose(); ((DisposeBase)device).Dispose(); return featureLevelRef; } public static FeatureLevel GetSupportedFeatureLevel(Adapter adapter) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Device device = new Device(IntPtr.Zero); FeatureLevel featureLevelRef; DeviceContext immediateContextOut; Result val = D3D11.CreateDevice(adapter, (DriverType)0, IntPtr.Zero, DeviceCreationFlags.None, null, 0, 7, device, out featureLevelRef, out immediateContextOut); ((Result)(ref val)).CheckError(); ((DisposeBase)immediateContextOut).Dispose(); ((DisposeBase)device).Dispose(); return featureLevelRef; } protected override void Dispose(bool disposing) { if (disposing && ImmediateContext__ != null) { ((DisposeBase)ImmediateContext__).Dispose(); ImmediateContext__ = null; } ((ComObject)this).Dispose(disposing); } private void CreateDevice(Adapter adapter, DriverType driverType, DeviceCreationFlags flags, FeatureLevel[] featureLevels) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) FeatureLevel featureLevelRef; Result val = D3D11.CreateDevice(adapter, driverType, IntPtr.Zero, flags, featureLevels, (featureLevels != null) ? featureLevels.Length : 0, 7, this, out featureLevelRef, out ImmediateContext__); ((Result)(ref val)).CheckError(); if (ImmediateContext__ != null) { ((IUnknown)this).AddReference(); ImmediateContext__.Device__ = this; } } public static Device CreateFromDirect3D12(ComObject d3D12Device, DeviceCreationFlags flags, FeatureLevel[] featureLevels, Adapter adapter, params ComObject[] commandQueues) { if (d3D12Device == null) { throw new ArgumentNullException("d3D12Device"); } D3D11.On12CreateDevice((IUnknown)(object)d3D12Device, flags, featureLevels, (featureLevels != null) ? featureLevels.Length : 0, (IUnknown[])(object)commandQueues, commandQueues.Length, 0, out var deviceOut, out var immediateContextOut, out var _); ((DisposeBase)immediateContextOut).Dispose(); return deviceOut; } public Device(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device(nativePtr); } return null; } internal unsafe void CreateBuffer(ref BufferDescription descRef, DataBox? initialDataRef, Buffer bufferOut) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; DataBox value = default(DataBox); if (initialDataRef.HasValue) { value = initialDataRef.Value; } Result val; fixed (BufferDescription* ptr = &descRef) { void* ptr2 = ptr; void* nativePointer = ((CppObject)this)._nativePointer; DataBox* intPtr = ((!initialDataRef.HasValue) ? null : (&value)); val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)3 * (nint)sizeof(void*))))(nativePointer, ptr2, intPtr, &zero)); } ((CppObject)bufferOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateTexture1D(ref Texture1DDescription descRef, DataBox[] initialDataRef, Texture1D texture1DOut) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DataBox* ptr = initialDataRef) { void* ptr2 = ptr; fixed (Texture1DDescription* ptr3 = &descRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)4 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, &zero)); } } ((CppObject)texture1DOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateTexture2D(ref Texture2DDescription descRef, DataBox[] initialDataRef, Texture2D texture2DOut) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DataBox* ptr = initialDataRef) { void* ptr2 = ptr; fixed (Texture2DDescription* ptr3 = &descRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)5 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, &zero)); } } ((CppObject)texture2DOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateTexture3D(ref Texture3DDescription descRef, DataBox[] initialDataRef, Texture3D texture3DOut) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DataBox* ptr = initialDataRef) { void* ptr2 = ptr; fixed (Texture3DDescription* ptr3 = &descRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)6 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, &zero)); } } ((CppObject)texture3DOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateShaderResourceView(Resource resourceRef, ShaderResourceViewDescription? descRef, ShaderResourceView sRViewOut) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); ShaderResourceViewDescription value = default(ShaderResourceViewDescription); if (descRef.HasValue) { value = descRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; ShaderResourceViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)7 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)sRViewOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateUnorderedAccessView(Resource resourceRef, UnorderedAccessViewDescription? descRef, UnorderedAccessView uAViewOut) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); UnorderedAccessViewDescription value = default(UnorderedAccessViewDescription); if (descRef.HasValue) { value = descRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; UnorderedAccessViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)8 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)uAViewOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateRenderTargetView(Resource resourceRef, RenderTargetViewDescription? descRef, RenderTargetView rTViewOut) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); RenderTargetViewDescription value = default(RenderTargetViewDescription); if (descRef.HasValue) { value = descRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; RenderTargetViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)9 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)rTViewOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateDepthStencilView(Resource resourceRef, DepthStencilViewDescription? descRef, DepthStencilView depthStencilViewOut) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); DepthStencilViewDescription value = default(DepthStencilViewDescription); if (descRef.HasValue) { value = descRef.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; DepthStencilViewDescription* intPtr2 = ((!descRef.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)10 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)depthStencilViewOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateInputLayout(InputElement[] inputElementDescsRef, int numElements, IntPtr shaderBytecodeWithInputSignatureRef, PointerSize bytecodeLength, InputLayout inputLayoutOut) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) InputElement.__Native[] array = new InputElement.__Native[inputElementDescsRef.Length]; IntPtr zero = IntPtr.Zero; for (int i = 0; i < inputElementDescsRef.Length; i++) { inputElementDescsRef[i].__MarshalTo(ref array[i]); } Result val; fixed (InputElement.__Native* ptr = array) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)11 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, numElements, (void*)shaderBytecodeWithInputSignatureRef, PointerSize.op_Implicit(bytecodeLength), &zero)); } ((CppObject)inputLayoutOut).NativePointer = zero; for (int j = 0; j < inputElementDescsRef.Length; j++) { inputElementDescsRef[j].__MarshalFree(ref array[j]); } ((Result)(ref val)).CheckError(); } internal unsafe void CreateVertexShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, VertexShader vertexShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)12 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)vertexShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateGeometryShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, GeometryShader geometryShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)13 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)geometryShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateGeometryShaderWithStreamOutput(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, StreamOutputElement[] sODeclarationRef, int numEntries, int[] bufferStridesRef, int numStrides, int rasterizedStream, ClassLinkage classLinkageRef, GeometryShader geometryShaderOut) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) StreamOutputElement.__Native[] array = ((sODeclarationRef == null) ? null : new StreamOutputElement.__Native[sODeclarationRef.Length]); IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; if (sODeclarationRef != null) { for (int i = 0; i < sODeclarationRef.Length; i++) { sODeclarationRef?[i].__MarshalTo(ref array[i]); } } zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val; fixed (int* ptr = bufferStridesRef) { void* ptr2 = ptr; fixed (StreamOutputElement.__Native* ptr3 = array) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int, void*, int, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)14 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), ptr4, numEntries, ptr2, numStrides, rasterizedStream, (void*)zero, &zero2)); } } ((CppObject)geometryShaderOut).NativePointer = zero2; if (sODeclarationRef != null) { for (int j = 0; j < sODeclarationRef.Length; j++) { sODeclarationRef?[j].__MarshalFree(ref array[j]); } } ((Result)(ref val)).CheckError(); } internal unsafe void CreatePixelShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, PixelShader pixelShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)15 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)pixelShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateHullShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, HullShader hullShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)16 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)hullShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateDomainShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, DomainShader domainShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)17 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)domainShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateComputeShader(IntPtr shaderBytecodeRef, PointerSize bytecodeLength, ClassLinkage classLinkageRef, ComputeShader computeShaderOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<ClassLinkage>((ICallbackable)(object)classLinkageRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)18 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)shaderBytecodeRef, PointerSize.op_Implicit(bytecodeLength), (void*)zero, &zero2)); ((CppObject)computeShaderOut).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateClassLinkage(ClassLinkage linkageOut) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)19 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero)); ((CppObject)linkageOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateBlendState(ref BlendStateDescription blendStateDescRef, BlendState blendStateOut) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription.__Native @ref = default(BlendStateDescription.__Native); IntPtr zero = IntPtr.Zero; blendStateDescRef.__MarshalTo(ref @ref); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)20 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref, &zero)); ((CppObject)blendStateOut).NativePointer = zero; blendStateDescRef.__MarshalFree(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe void CreateDepthStencilState(ref DepthStencilStateDescription depthStencilDescRef, DepthStencilState depthStencilStateOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DepthStencilStateDescription* ptr = &depthStencilDescRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)21 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &zero)); } ((CppObject)depthStencilStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateRasterizerState(ref RasterizerStateDescription rasterizerDescRef, RasterizerState rasterizerStateOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (RasterizerStateDescription* ptr = &rasterizerDescRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)22 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &zero)); } ((CppObject)rasterizerStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateSamplerState(ref SamplerStateDescription samplerDescRef, SamplerState samplerStateOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (SamplerStateDescription* ptr = &samplerDescRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)23 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &zero)); } ((CppObject)samplerStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateQuery(QueryDescription queryDescRef, Query queryOut) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)24 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &queryDescRef, &zero)); ((CppObject)queryOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreatePredicate(QueryDescription predicateDescRef, Predicate predicateOut) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)25 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &predicateDescRef, &zero)); ((CppObject)predicateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateCounter(CounterDescription counterDescRef, Counter counterOut) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)26 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &counterDescRef, &zero)); ((CppObject)counterOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateDeferredContext(int contextFlags, DeviceContext deferredContextOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)27 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, contextFlags, &zero)); ((CppObject)deferredContextOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void OpenSharedResource(IntPtr hResource, Guid returnedInterface, out IntPtr resourceOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &resourceOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)28 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)hResource, &returnedInterface, ptr2)); } ((Result)(ref val)).CheckError(); } public unsafe FormatSupport CheckFormatSupport(Format format) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) FormatSupport result = default(FormatSupport); Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)29 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)format, &result)); return result; } public unsafe int CheckMultisampleQualityLevels(Format format, int sampleCount) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected I4, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) int result = default(int); Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)30 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)format, sampleCount, &result)); return result; } public unsafe CounterCapabilities GetCounterCapabilities() { CounterCapabilities result = default(CounterCapabilities); ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)31 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &result); return result; } internal unsafe void CheckCounter(CounterDescription descRef, out CounterType typeRef, out int activeCountersRef, IntPtr szName, IntPtr nameLengthRef, IntPtr szUnits, IntPtr unitsLengthRef, IntPtr szDescription, IntPtr descriptionLengthRef) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (int* ptr = &activeCountersRef) { void* ptr2 = ptr; fixed (CounterType* ptr3 = &typeRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)32 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &descRef, ptr4, ptr2, (void*)szName, (void*)nameLengthRef, (void*)szUnits, (void*)unitsLengthRef, (void*)szDescription, (void*)descriptionLengthRef)); } } ((Result)(ref val)).CheckError(); } internal unsafe Result CheckFeatureSupport(Feature feature, IntPtr featureSupportDataRef, int featureSupportDataSize) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) return Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)33 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)feature, (void*)featureSupportDataRef, featureSupportDataSize)); } public unsafe Result GetPrivateData(Guid guid, ref int dataSizeRef, IntPtr dataRef) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) Result result; fixed (int* ptr = &dataSizeRef) { void* ptr2 = ptr; result = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)34 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &guid, ptr2, (void*)dataRef)); } return result; } public unsafe void SetPrivateData(Guid guid, int dataSize, IntPtr dataRef) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)35 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &guid, dataSize, (void*)dataRef)); ((Result)(ref val)).CheckError(); } public unsafe void SetPrivateDataInterface(Guid guid, IUnknown dataRef) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; zero = CppObject.ToCallbackPtr<IUnknown>((ICallbackable)(object)dataRef); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)36 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &guid, (void*)zero)); ((Result)(ref val)).CheckError(); } internal unsafe FeatureLevel GetFeatureLevel() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) return ((delegate* unmanaged[Stdcall]<void*, FeatureLevel>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)37 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } internal unsafe DeviceCreationFlags GetCreationFlags() { return ((delegate* unmanaged[Stdcall]<void*, DeviceCreationFlags>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)38 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } internal unsafe Result GetDeviceRemovedReason() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) return Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)39 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer)); } internal unsafe void GetImmediateContext(out DeviceContext immediateContextOut) { IntPtr zero = IntPtr.Zero; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)40 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero); if (zero != IntPtr.Zero) { immediateContextOut = new DeviceContext(zero); } else { immediateContextOut = null; } } internal unsafe void SetExceptionMode(int raiseFlags) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)41 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, raiseFlags)); ((Result)(ref val)).CheckError(); } internal unsafe int GetExceptionMode() { return ((delegate* unmanaged[Stdcall]<void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)42 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer); } } [Guid("a04bfb29-08ef-43d6-a49c-a9bdbdcbe686")] public class Device1 : Device { protected internal DeviceContext1 ImmediateContext1__; public DeviceContext1 ImmediateContext1 { get { if (ImmediateContext1__ == null) { GetImmediateContext1(out ImmediateContext1__); } return ImmediateContext1__; } } public DeviceContextState CreateDeviceContextState<T>(CreateDeviceContextStateFlags flags, FeatureLevel[] featureLevelsRef, out FeatureLevel chosenFeatureLevelRef) where T : ComObject { DeviceContextState deviceContextState = new DeviceContextState(IntPtr.Zero); CreateDeviceContextState(flags, featureLevelsRef, featureLevelsRef.Length, 7, Utilities.GetGuidFromType(typeof(T)), out chosenFeatureLevelRef, deviceContextState); return deviceContextState; } public T OpenSharedResource1<T>(IntPtr resourceHandle) where T : ComObject { OpenSharedResource1(resourceHandle, Utilities.GetGuidFromType(typeof(T)), out var resourceOut); return CppObject.FromPointer<T>(resourceOut); } public T OpenSharedResource1<T>(string name, SharedResourceFlags desiredAccess) where T : ComObject { //IL_0002: Unknown result type (might be due to invalid IL or missing references) OpenSharedResourceByName(name, desiredAccess, Utilities.GetGuidFromType(typeof(T)), out var resourceOut); return CppObject.FromPointer<T>(resourceOut); } protected override void Dispose(bool disposing) { if (disposing && ImmediateContext1__ != null) { ((DisposeBase)ImmediateContext1__).Dispose(); ImmediateContext1__ = null; } base.Dispose(disposing); } public Device1(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device1(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device1(nativePtr); } return null; } internal unsafe void GetImmediateContext1(out DeviceContext1 immediateContextOut) { IntPtr zero = IntPtr.Zero; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)43 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero); if (zero != IntPtr.Zero) { immediateContextOut = new DeviceContext1(zero); } else { immediateContextOut = null; } } internal unsafe void CreateDeferredContext1(int contextFlags, DeviceContext1 deferredContextOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)44 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, contextFlags, &zero)); ((CppObject)deferredContextOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateBlendState1(ref BlendStateDescription1 blendStateDescRef, BlendState1 blendStateOut) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) BlendStateDescription1.__Native @ref = default(BlendStateDescription1.__Native); IntPtr zero = IntPtr.Zero; blendStateDescRef.__MarshalTo(ref @ref); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)45 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &@ref, &zero)); ((CppObject)blendStateOut).NativePointer = zero; blendStateDescRef.__MarshalFree(ref @ref); ((Result)(ref val)).CheckError(); } internal unsafe void CreateRasterizerState1(ref RasterizerStateDescription1 rasterizerDescRef, RasterizerState1 rasterizerStateOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (RasterizerStateDescription1* ptr = &rasterizerDescRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)46 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &zero)); } ((CppObject)rasterizerStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateDeviceContextState(CreateDeviceContextStateFlags flags, FeatureLevel[] featureLevelsRef, int featureLevels, int sDKVersion, Guid emulatedInterface, out FeatureLevel chosenFeatureLevelRef, DeviceContextState contextStateOut) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (FeatureLevel* ptr = &chosenFeatureLevelRef) { void* ptr2 = ptr; fixed (FeatureLevel* ptr3 = featureLevelsRef) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int, int, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)47 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)flags, ptr4, featureLevels, sDKVersion, &emulatedInterface, ptr2, &zero)); } } ((CppObject)contextStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void OpenSharedResource1(IntPtr hResource, Guid returnedInterface, out IntPtr resourceOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &resourceOut) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)48 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)hResource, &returnedInterface, ptr2)); } ((Result)(ref val)).CheckError(); } internal unsafe void OpenSharedResourceByName(string lpName, SharedResourceFlags dwDesiredAccess, Guid returnedInterface, out IntPtr resourceOut) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected I4, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Result val; fixed (IntPtr* ptr = &resourceOut) { void* ptr2 = ptr; fixed (char* ptr3 = lpName) { val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, int, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)49 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr3, (int)dwDesiredAccess, &returnedInterface, ptr2)); } } ((Result)(ref val)).CheckError(); } } [Guid("9d06dffa-d1e5-4d07-83a8-1bb123f2f841")] public class Device2 : Device1 { protected internal DeviceContext2 ImmediateContext2__; public DeviceContext2 ImmediateContext2 { get { if (ImmediateContext2__ == null) { GetImmediateContext2(out ImmediateContext2__); } return ImmediateContext2__; } } protected override void Dispose(bool disposing) { if (disposing && ImmediateContext2__ != null) { ((DisposeBase)ImmediateContext2__).Dispose(); ImmediateContext2__ = null; } base.Dispose(disposing); } public Device2(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device2(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device2(nativePtr); } return null; } internal unsafe void GetImmediateContext2(out DeviceContext2 immediateContextOut) { IntPtr zero = IntPtr.Zero; ((delegate* unmanaged[Stdcall]<void*, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)50 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, &zero); if (zero != IntPtr.Zero) { immediateContextOut = new DeviceContext2(zero); } else { immediateContextOut = null; } } internal unsafe void CreateDeferredContext2(int contextFlags, DeviceContext2 deferredContextOut) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)51 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, contextFlags, &zero)); ((CppObject)deferredContextOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } public unsafe void GetResourceTiling(Resource tiledResourceRef, out int numTilesForEntireResourceRef, out PackedMipDescription packedMipDescRef, out TileShape standardTileShapeForNonPackedMipsRef, ref int numSubresourceTilingsRef, int firstSubresourceTilingToGet, SubResourceTiling[] subresourceTilingsForNonPackedMipsRef) { IntPtr zero = IntPtr.Zero; packedMipDescRef = default(PackedMipDescription); standardTileShapeForNonPackedMipsRef = default(TileShape); zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)tiledResourceRef); fixed (SubResourceTiling* ptr = subresourceTilingsForNonPackedMipsRef) { void* ptr2 = ptr; fixed (int* ptr3 = &numSubresourceTilingsRef) { void* ptr4 = ptr3; fixed (TileShape* ptr5 = &standardTileShapeForNonPackedMipsRef) { void* ptr6 = ptr5; fixed (PackedMipDescription* ptr7 = &packedMipDescRef) { void* ptr8 = ptr7; fixed (int* ptr9 = &numTilesForEntireResourceRef) { void* ptr10 = ptr9; ((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, void*, void*, int, void*, void>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)52 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (void*)zero, ptr10, ptr8, ptr6, ptr4, firstSubresourceTilingToGet, ptr2); } } } } } } public unsafe int CheckMultisampleQualityLevels1(Format format, int sampleCount, CheckMultisampleQualityLevelsFlags flags) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected I4, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) int result = default(int); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, int, int, int, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)53 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, (int)format, sampleCount, (int)flags, &result)); ((Result)(ref val)).CheckError(); return result; } } [Guid("A05C8C37-D2C6-4732-B3A0-9CE0B0DC9AE6")] public class Device3 : Device2 { protected internal DeviceContext3 ImmediateContext3__; public DeviceContext3 ImmediateContext3 { get { if (ImmediateContext3__ == null) { GetImmediateContext3(out ImmediateContext3__); } return ImmediateContext3__; } } protected override void Dispose(bool disposing) { if (disposing && ImmediateContext3__ != null) { ((DisposeBase)ImmediateContext3__).Dispose(); ImmediateContext3__ = null; } base.Dispose(disposing); } public Device3(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator Device3(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new Device3(nativePtr); } return null; } internal unsafe void CreateTexture2D1(ref Texture2DDescription1 desc1Ref, DataBox[] initialDataRef, Texture2D1 texture2DOut) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DataBox* ptr = initialDataRef) { void* ptr2 = ptr; fixed (Texture2DDescription1* ptr3 = &desc1Ref) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)54 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, &zero)); } } ((CppObject)texture2DOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateTexture3D1(ref Texture3DDescription1 desc1Ref, DataBox[] initialDataRef, Texture3D1 texture3DOut) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (DataBox* ptr = initialDataRef) { void* ptr2 = ptr; fixed (Texture3DDescription1* ptr3 = &desc1Ref) { void* ptr4 = ptr3; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)55 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr4, ptr2, &zero)); } } ((CppObject)texture3DOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateRasterizerState2(ref RasterizerStateDescription2 rasterizerDescRef, RasterizerState2 rasterizerStateOut) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; Result val; fixed (RasterizerStateDescription2* ptr = &rasterizerDescRef) { void* ptr2 = ptr; val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)56 * (nint)sizeof(void*))))(((CppObject)this)._nativePointer, ptr2, &zero)); } ((CppObject)rasterizerStateOut).NativePointer = zero; ((Result)(ref val)).CheckError(); } internal unsafe void CreateShaderResourceView1(Resource resourceRef, ShaderResourceViewDescription1? desc1Ref, ShaderResourceView1 sRView1Out) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); ShaderResourceViewDescription1 value = default(ShaderResourceViewDescription1); if (desc1Ref.HasValue) { value = desc1Ref.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; ShaderResourceViewDescription1* intPtr2 = ((!desc1Ref.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)57 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)sRView1Out).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateUnorderedAccessView1(Resource resourceRef, UnorderedAccessViewDescription1? desc1Ref, UnorderedAccessView1 uAView1Out) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); UnorderedAccessViewDescription1 value = default(UnorderedAccessViewDescription1); if (desc1Ref.HasValue) { value = desc1Ref.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; UnorderedAccessViewDescription1* intPtr2 = ((!desc1Ref.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePointer) + (nint)58 * (nint)sizeof(void*))))(nativePointer, intPtr, intPtr2, &zero2)); ((CppObject)uAView1Out).NativePointer = zero2; ((Result)(ref val)).CheckError(); } internal unsafe void CreateRenderTargetView1(Resource resourceRef, RenderTargetViewDescription1? desc1Ref, RenderTargetView1 rTView1Out) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) IntPtr zero = IntPtr.Zero; IntPtr zero2 = IntPtr.Zero; zero = CppObject.ToCallbackPtr<Resource>((ICallbackable)(object)resourceRef); RenderTargetViewDescription1 value = default(RenderTargetViewDescription1); if (desc1Ref.HasValue) { value = desc1Ref.Value; } void* nativePointer = ((CppObject)this)._nativePointer; void* intPtr = (void*)zero; RenderTargetViewDescription1* intPtr2 = ((!desc1Ref.HasValue) ? null : (&value)); Result val = Result.op_Implicit(((delegate* unmanaged[Stdcall]<void*, void*, void*, void*, int>)(*(IntPtr*)((nint)(*(IntPtr*)((CppObject)this)._nativePoi
BepInEx/plugins/DearImGuiInjection/Reloaded.Memory.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers.Binary; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; using Reloaded.Memory.Exceptions; using Reloaded.Memory.Internal; using Reloaded.Memory.Kernel32; using Reloaded.Memory.Pointers; using Reloaded.Memory.Sources; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Sewer56")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A fully featured C# memory editing library supporting reading/writing primitive or generic struct types in either current or an external process.")] [assembly: AssemblyFileVersion("7.0.0.0")] [assembly: AssemblyInformationalVersion("7.0.0")] [assembly: AssemblyProduct("Project Reloaded")] [assembly: AssemblyTitle("Reloaded.Memory")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("7.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace Reloaded.Memory { public static class Endian { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte Reverse(byte value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static sbyte Reverse(sbyte value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static short Reverse(short value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort Reverse(ushort value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Reverse(int value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Reverse(uint value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Reverse(long value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Reverse(ulong value) { return BinaryPrimitives.ReverseEndianness(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Reverse(float value) { int value2 = Unsafe.As<float, int>(ref value); value2 = BinaryPrimitives.ReverseEndianness(value2); return Unsafe.As<int, float>(ref value2); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Reverse(double value) { long value2 = Unsafe.As<double, long>(ref value); value2 = BinaryPrimitives.ReverseEndianness(value2); return Unsafe.As<long, double>(ref value2); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Reverse<T>(ref T type, out T swapped) where T : unmanaged { swapped = type; Reverse(ref swapped); } public unsafe static void Reverse<T>(ref T type) where T : unmanaged { byte* pointer = (byte*)Unsafe.AsPointer(ref type); new Span<byte>(pointer, sizeof(T)).Reverse(); } } public interface IEndianReversible { void SwapEndian(); } public static class Struct { public static IMemory Source { get; set; } = new Reloaded.Memory.Sources.Memory(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void ToPtr<T>(nuint pointer, T item, bool marshalElement = false) { ToPtr(pointer, ref item, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void ToPtr<T>(nuint pointer, ref T item, bool marshalElement = false) { ToPtr(pointer, ref item, Source.Write, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void FromPtr<T>(nuint pointer, out T value, bool marshalElement = false) { FromPtr(pointer, out value, (Reloaded.Memory.Sources.MemoryExtensions.ReadFunction<T>)Source.Read, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void ToPtr<T>(nuint pointer, ref T item, Reloaded.Memory.Sources.MemoryExtensions.WriteFunction<T> writeFunction, bool marshalElement = false) { writeFunction(pointer, ref item, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void FromPtr<T>(nuint pointer, out T value, Reloaded.Memory.Sources.MemoryExtensions.ReadFunction<T> readFunction, bool marshalElement = false) { readFunction(pointer, out value, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static void FromArray<T>(byte[] data, out T value, bool marshalElement = true, int startIndex = 0) { fixed (byte* ptr = data) { value = Marshal.PtrToStructure<T>((IntPtr)(ptr + startIndex)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void FromArray<T>(byte[] data, out T value, int startIndex = 0) where T : unmanaged { Span<byte> span = new Span<byte>(data, startIndex, data.Length - startIndex); value = MemoryMarshal.Read<T>(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void FromArray<T>(Span<byte> data, out T value) where T : unmanaged { value = MemoryMarshal.Read<T>(data); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetSize<T>(bool marshalElement) { if (!marshalElement) { return Unsafe.SizeOf<T>(); } return Marshal.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetSize<T>() where T : unmanaged { return Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static byte[] GetBytes<T>(T item) where T : unmanaged { return GetBytes(ref item); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static Span<byte> GetBytes<T>(T item, Span<byte> buffer) where T : unmanaged { return GetBytes(ref item, buffer); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static byte[] GetBytes<T>(T item, bool marshalElement) { return GetBytes(ref item, marshalElement); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static Span<byte> GetBytes<T>(T item, bool marshalElement, Span<byte> buffer) { return GetBytes(ref item, marshalElement, buffer); } public unsafe static byte[] GetBytes<T>(ref T item) where T : unmanaged { byte[] array = new byte[sizeof(T)]; MemoryMarshal.Write(new Span<byte>(array), ref item); return array; } public unsafe static Span<byte> GetBytes<T>(ref T item, Span<byte> buffer) where T : unmanaged { MemoryMarshal.Write(buffer, ref item); return buffer.Slice(0, sizeof(T)); } public unsafe static byte[] GetBytes<T>(ref T item, bool marshalElement) { byte[] array = new byte[GetSize<T>(marshalElement)]; fixed (byte* ptr = array) { Marshal.StructureToPtr(item, (IntPtr)ptr, fDeleteOld: false); } return array; } public unsafe static Span<byte> GetBytes<T>(ref T item, bool marshalElement, Span<byte> buffer) { fixed (byte* ptr = buffer) { Marshal.StructureToPtr(item, (IntPtr)ptr, fDeleteOld: false); } return buffer.Slice(0, GetSize<T>(marshalElement)); } } public static class StructArray { private const int MaxStackLimit = 1024; public static void FromPtr<T>(nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) { int size = Struct.GetSize<T>(marshal); value = new T[arrayLength]; for (int i = 0; i < arrayLength; i++) { Struct.FromPtr<T>((UIntPtr)memoryAddress + size * i, out var value2, marshal); value[i] = value2; } } public static void ToPtr<T>(nuint memoryAddress, T[] item, bool marshal = false) { int size = Struct.GetSize<T>(marshal); for (int i = 0; i < item.Length; i++) { Struct.ToPtr((UIntPtr)memoryAddress + size * i, ref item[i], marshal); } } public static void FromArray<T>(byte[] data, out T[] value, bool marshalElement, int length = 0, int startIndex = 0) { int size = Struct.GetSize<T>(marshalElement); int num = ((length == 0) ? ((data.Length - startIndex) / size) : length); value = new T[num]; for (int i = 0; i < value.Length; i++) { int startIndex2 = startIndex + size * i; Struct.FromArray<T>(data, out var value2, marshalElement, startIndex2); value[i] = value2; } } public static void FromArray<T>(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged { int size = Struct.GetSize<T>(); int num = ((length == 0) ? ((data.Length - startIndex) / size) : length); value = new T[num]; for (int i = 0; i < value.Length; i++) { int startIndex2 = startIndex + size * i; Struct.FromArray<T>(data, out var value2, startIndex2); value[i] = value2; } } public static void FromArray<T>(Span<byte> data, out T[] value, int length = 0) where T : unmanaged { int size = Struct.GetSize<T>(); int num = ((length == 0) ? (data.Length / size) : length); value = new T[num]; for (int i = 0; i < value.Length; i++) { Struct.FromArray<T>(data, out value[i]); data = data.Slice(size); } } public static void FromArrayBigEndianPrimitive<T>(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged { FromArray<T>(data, out value, startIndex, length); for (int i = 0; i < value.Length; i++) { Endian.Reverse(ref value[i], out value[i]); } } public static void FromArrayBigEndianPrimitive<T>(Span<byte> data, out T[] value, int length = 0) where T : unmanaged { FromArray<T>(data, out value, length); for (int i = 0; i < value.Length; i++) { Endian.Reverse(ref value[i], out value[i]); } } public static void FromArrayBigEndianStruct<T>(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged, IEndianReversible { FromArray<T>(data, out value, startIndex, length); for (int i = 0; i < value.Length; i++) { value[i].SwapEndian(); } } public static void FromArrayBigEndianStruct<T>(Span<byte> data, out T[] value, int length = 0) where T : unmanaged, IEndianReversible { FromArray<T>(data, out value, length); for (int i = 0; i < value.Length; i++) { value[i].SwapEndian(); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetSize<T>(int elementCount, bool marshalElement) { return Struct.GetSize<T>(marshalElement) * elementCount; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetSize<T>(int elementCount) where T : unmanaged { return Struct.GetSize<T>() * elementCount; } public static byte[] GetBytes<T>(T[] items, bool marshalElements) { byte[] array = new byte[Struct.GetSize<T>(marshalElements) * items.Length]; GetBytes(items, marshalElements, array.AsSpan()); return array; } public static Span<byte> GetBytes<T>(T[] items, bool marshalElements, Span<byte> buffer) { int size = Struct.GetSize<T>(marshalElements); Span<byte> span = buffer[..(size * items.Length)]; if (size < 1024) { Span<byte> currentItem2 = stackalloc byte[size]; GetBytesInternal(items, size, marshalElements, currentItem2, span); } else { Span<byte> currentItem3 = new byte[size]; GetBytesInternal(items, size, marshalElements, currentItem3, span); } return span; [MethodImpl(MethodImplOptions.AggressiveInlining)] static void GetBytesInternal(T[] items, int sizeOfItem, bool marshalElements, Span<byte> currentItem, Span<byte> resultSpan) { for (int i = 0; i < items.Length; i++) { Struct.GetBytes(ref items[i], marshalElements, currentItem); currentItem.CopyTo(resultSpan); resultSpan = resultSpan.Slice(sizeOfItem); } } } public static byte[] GetBytes<T>(T[] items) where T : unmanaged { byte[] array = new byte[GetSize<T>(items.Length)]; GetBytes(items, array.AsSpan()); return array; } public unsafe static Span<byte> GetBytes<T>(T[] items, Span<byte> buffer) where T : unmanaged { Span<byte> span2 = buffer[..GetSize<T>(items.Length)]; if (sizeof(T) < 1024) { Span<byte> currentItem2 = stackalloc byte[sizeof(T)]; GetBytesInternal(items, currentItem2, span2); } else { Span<byte> currentItem3 = new byte[sizeof(T)]; GetBytesInternal(items, currentItem3, span2); } return span2; [MethodImpl(MethodImplOptions.AggressiveInlining)] static unsafe void GetBytesInternal(T[] items, Span<byte> currentItem, Span<byte> span) { for (int i = 0; i < items.Length; i++) { Struct.GetBytes(ref items[i], currentItem); currentItem.CopyTo(span); span = span.Slice(sizeof(T)); } } } } } namespace Reloaded.Memory.Utilities { public static class Blittable { private static class IsBlittableCache<T> { public static readonly bool Value = IsBlittable(typeof(T)); } public static bool IsBlittable<T>() { return IsBlittableCache<T>.Value; } public static bool IsBlittable(Type type) { if (type.IsArray) { Type elementType = type.GetElementType(); if (elementType.IsValueType) { return IsBlittable(elementType); } return false; } try { GCHandle.Alloc(FormatterServices.GetUninitializedObject(type), GCHandleType.Pinned).Free(); return true; } catch { return false; } } } public class CircularBuffer : IDisposable { public enum ItemFit { No, Yes, StartOfBuffer } public IMemory Source { get; } public int Offset { get; set; } public nuint Address { get; set; } public int Size { get; set; } public nuint WritePointer => (UIntPtr)Address + Offset; private int Remaining => Size - Offset; public CircularBuffer(int size, IMemory source) { Offset = 0; Size = size; Source = source; Address = source.Allocate(Size); } [ExcludeFromCodeCoverage] ~CircularBuffer() { Dispose(); } public nuint Add(byte[] bytesToWrite) { switch (CanItemFit(bytesToWrite.Length)) { case ItemFit.No: return 0u; case ItemFit.StartOfBuffer: Offset = 0; break; } nuint writePointer = WritePointer; Source.WriteRaw(writePointer, bytesToWrite); Offset += bytesToWrite.Length; return writePointer; } public nuint Add<TStructure>(ref TStructure item, bool marshalElement = false) { return Add(Struct.GetBytes(ref item, marshalElement)); } public ItemFit CanItemFit(int objectSize) { if (Remaining >= objectSize) { return ItemFit.Yes; } if (Size >= objectSize) { return ItemFit.StartOfBuffer; } return ItemFit.No; } public ItemFit CanItemFit<TStructure>(ref TStructure item, bool marshalElement = false) { return CanItemFit(Struct.GetSize<TStructure>(marshalElement)); } public void Dispose() { Source.Free(Address); GC.SuppressFinalize(this); } } } namespace Reloaded.Memory.Streams { public class BufferedStreamReader : IDisposable { private readonly Stream _stream; private readonly byte[] _buffer; private readonly int _bufferSize; private int _bufferOffset; private int _bufferedBytesRemaining; private GCHandle _gcHandle; private IntPtr _gcHandlePtr; private Reloaded.Memory.Sources.Memory _memory = new Reloaded.Memory.Sources.Memory(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out short value) { int num = 2; ReFillIfNecessary(num); value = *(short*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public short ReadBigEndianPrimitiveInt16() { ReadBigEndianPrimitive(out short value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out short value) { ReFillIfNecessary(2); value = *(short*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public short PeekBigEndianPrimitiveInt16() { PeekBigEndianPrimitive(out short value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out ushort value) { int num = 2; ReFillIfNecessary(num); value = *(ushort*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public ushort ReadBigEndianPrimitiveUInt16() { ReadBigEndianPrimitive(out ushort value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out ushort value) { ReFillIfNecessary(2); value = *(ushort*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public ushort PeekBigEndianPrimitiveUInt16() { PeekBigEndianPrimitive(out ushort value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out int value) { int num = 4; ReFillIfNecessary(num); value = *(int*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public int ReadBigEndianPrimitiveInt32() { ReadBigEndianPrimitive(out int value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out int value) { ReFillIfNecessary(4); value = *(int*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public int PeekBigEndianPrimitiveInt32() { PeekBigEndianPrimitive(out int value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out uint value) { int num = 4; ReFillIfNecessary(num); value = *(uint*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public uint ReadBigEndianPrimitiveUInt32() { ReadBigEndianPrimitive(out uint value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out uint value) { ReFillIfNecessary(4); value = *(uint*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public uint PeekBigEndianPrimitiveUInt32() { PeekBigEndianPrimitive(out uint value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out long value) { int num = 8; ReFillIfNecessary(num); value = *(long*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public long ReadBigEndianPrimitiveInt64() { ReadBigEndianPrimitive(out long value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out long value) { ReFillIfNecessary(8); value = *(long*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public long PeekBigEndianPrimitiveInt64() { PeekBigEndianPrimitive(out long value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out ulong value) { int num = 8; ReFillIfNecessary(num); value = *(ulong*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public ulong ReadBigEndianPrimitiveUInt64() { ReadBigEndianPrimitive(out ulong value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out ulong value) { ReFillIfNecessary(8); value = *(ulong*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public ulong PeekBigEndianPrimitiveUInt64() { PeekBigEndianPrimitive(out ulong value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out float value) { int num = 4; ReFillIfNecessary(num); value = *(float*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public float ReadBigEndianPrimitiveSingle() { ReadBigEndianPrimitive(out float value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out float value) { ReFillIfNecessary(4); value = *(float*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public float PeekBigEndianPrimitiveSingle() { PeekBigEndianPrimitive(out float value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void ReadBigEndianPrimitive(out double value) { int num = 8; ReFillIfNecessary(num); value = *(double*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public double ReadBigEndianPrimitiveDouble() { ReadBigEndianPrimitive(out double value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public unsafe void PeekBigEndianPrimitive(out double value) { ReFillIfNecessary(8); value = *(double*)(void*)(_gcHandlePtr + _bufferOffset); value = Endian.Reverse(value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public double PeekBigEndianPrimitiveDouble() { PeekBigEndianPrimitive(out double value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Stream BaseStream() { return _stream; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int BufferBytesAvailable() { return _bufferedBytesRemaining; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public int CurrentBufferSize() { return _bufferOffset + _bufferedBytesRemaining; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public long Position() { return _stream.Position - _bufferedBytesRemaining; } public BufferedStreamReader(Stream stream, int bufferSize) { _stream = stream; _bufferSize = bufferSize; _buffer = new byte[bufferSize]; _bufferOffset = bufferSize; _gcHandle = GCHandle.Alloc(_buffer, GCHandleType.Pinned); _gcHandlePtr = _gcHandle.AddrOfPinnedObject(); } ~BufferedStreamReader() { Dispose(); } public void Dispose() { if (_gcHandle.IsAllocated) { _gcHandle.Free(); } GC.SuppressFinalize(this); } public void Seek(long offset, SeekOrigin origin) { switch (origin) { case SeekOrigin.Current: RelativeSeek(offset); break; case SeekOrigin.Begin: { long relativeOffset2 = offset - Position(); RelativeSeek(relativeOffset2); break; } case SeekOrigin.End: { long relativeOffset = _stream.Length - offset - Position(); RelativeSeek(relativeOffset); break; } } } public byte[] ReadBytes(long offset, int count) { long position = _stream.Position; _stream.Position = offset; byte[] result = new byte[count]; if (!_stream.TryReadSafe(result)) { BufferedStreamReaderException.Throw("Could not read enough bytes from stream."); } _stream.Position = position; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Read<T>(out T value, bool marshal) { int size = Struct.GetSize<T>(marshal); ReFillIfNecessary(size); _memory.Read<T>((UIntPtr)(void*)_gcHandlePtr + _bufferOffset, out value, marshal); _bufferOffset += size; _bufferedBytesRemaining -= size; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Read<T>(out T value) where T : unmanaged { int num = sizeof(T); ReFillIfNecessary(num); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Read<T>(bool marshal) { Read<T>(out var value, marshal); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Read<T>() where T : unmanaged { Read<T>(out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Peek<T>(out T value, bool marshal) { ReFillIfNecessary(Struct.GetSize<T>(marshal)); _memory.Read<T>((UIntPtr)(void*)_gcHandlePtr + _bufferOffset, out value, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Peek<T>(out T value) where T : unmanaged { ReFillIfNecessary(sizeof(T)); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Peek<T>(bool marshal) { Peek<T>(out var value, marshal); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Peek<T>() where T : unmanaged { Peek<T>(out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void ReadBigEndianPrimitive<T>(out T value) where T : unmanaged { int num = sizeof(T); ReFillIfNecessary(num); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); Endian.Reverse(ref value); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void ReadBigEndianStruct<T>(out T value) where T : unmanaged, IEndianReversible { int num = sizeof(T); ReFillIfNecessary(num); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); value.SwapEndian(); _bufferOffset += num; _bufferedBytesRemaining -= num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T ReadBigEndianPrimitive<T>() where T : unmanaged { ReadBigEndianPrimitive(out T value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T ReadBigEndianStruct<T>() where T : unmanaged, IEndianReversible { ReadBigEndianStruct<T>(out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PeekBigEndianPrimitive<T>(out T value) where T : unmanaged { ReFillIfNecessary(sizeof(T)); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); Endian.Reverse(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void PeekBigEndianStruct<T>(out T value) where T : unmanaged, IEndianReversible { ReFillIfNecessary(sizeof(T)); value = *(T*)(void*)(_gcHandlePtr + _bufferOffset); value.SwapEndian(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PeekBigEndianPrimitive<T>() where T : unmanaged { PeekBigEndianPrimitive(out T value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PeekBigEndianStruct<T>() where T : unmanaged, IEndianReversible { PeekBigEndianStruct<T>(out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool CanRead(int size) { return size <= _bufferedBytesRemaining; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReFillIfNecessary(int size) { if (!CanRead(size)) { ReFillBuffer(); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReFillBuffer() { _stream.Seek(_bufferedBytesRemaining * -1, SeekOrigin.Current); FillBuffer(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void FillBuffer() { _bufferedBytesRemaining = _stream.Read(_buffer, 0, _bufferSize); _bufferOffset = 0; } private void RelativeSeek(long relativeOffset) { if (!FastSeekRelativeToCurrent(relativeOffset)) { long offset = Position() + relativeOffset - _stream.Position; _stream.Seek(offset, SeekOrigin.Current); FillBuffer(); } } private bool FastSeekRelativeToCurrent(long offset) { if (offset >= 0) { if (offset <= _bufferedBytesRemaining) { _bufferOffset += (int)offset; _bufferedBytesRemaining -= (int)offset; return true; } } else if (offset * -1 <= _bufferOffset) { _bufferOffset += (int)offset; _bufferedBytesRemaining -= (int)offset; return true; } return false; } } public class ExtendedMemoryStream : MemoryStream { private const int MaxStackLimit = 1024; [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(byte structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(byte[] structures) { foreach (byte structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(sbyte structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(sbyte[] structures) { foreach (sbyte structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(short structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(short[] structures) { foreach (short structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(ushort structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(ushort[] structures) { foreach (ushort structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(int structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(int[] structures) { foreach (int structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(uint structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(uint[] structures) { foreach (uint structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(long structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(long[] structures) { foreach (long structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(ulong structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(ulong[] structures) { foreach (ulong structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(float structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(float[] structures) { foreach (float structure in structures) { WriteBigEndianPrimitive(structure); } } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(double structure) { structure = Endian.Reverse(structure); Write(ref structure); } [ExcludeFromCodeCoverage] public void WriteBigEndianPrimitive(double[] structures) { foreach (double structure in structures) { WriteBigEndianPrimitive(structure); } } public ExtendedMemoryStream() { } public ExtendedMemoryStream(byte[] buffer) : base(buffer) { } public ExtendedMemoryStream(byte[] buffer, bool writable) : base(buffer, writable) { } public ExtendedMemoryStream(byte[] buffer, int index, int count) : base(buffer, index, count) { } public ExtendedMemoryStream(byte[] buffer, int index, int count, bool writable) : base(buffer, index, count, writable) { } public ExtendedMemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible) : base(buffer, index, count, writable, publiclyVisible) { } public ExtendedMemoryStream(int capacity) : base(capacity) { } public void AddPadding(int alignment = 2048) { StreamExtensions.AddPadding(this, alignment); } public void AddPadding(byte value, int alignment = 2048) { StreamExtensions.AddPadding(this, value, alignment); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T[] structure) where T : unmanaged { StreamExtensions.Write(this, structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T[] structure, bool marshalStructure = true) { StreamExtensions.Write(this, structure, marshalStructure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T structure) where T : unmanaged { StreamExtensions.Write(this, ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(ref T structure) where T : unmanaged { StreamExtensions.Write(this, ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T structure, bool marshalStructure = true) { StreamExtensions.Write(this, ref structure, marshalStructure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(ref T structure, bool marshalStructure = true) { StreamExtensions.Write(this, ref structure, marshalStructure); } public void Write(byte[] data) { Write(data, 0, data.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteBigEndianPrimitive<T>(T[] structures) where T : unmanaged { StreamExtensions.WriteBigEndianPrimitive(this, structures); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteBigEndianStruct<T>(T[] structures) where T : unmanaged, IEndianReversible { StreamExtensions.WriteBigEndianStruct(this, structures); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteBigEndianPrimitive<T>(T structure) where T : unmanaged { StreamExtensions.WriteBigEndianPrimitive(this, structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteBigEndianStruct<T>(T structure) where T : unmanaged, IEndianReversible { StreamExtensions.WriteBigEndianStruct(this, structure); } } public static class StreamExtensions { private const int MaxStackLimit = 1024; public static void AddPadding(this Stream stream, int alignment = 2048) { long num = Reloaded.Memory.Internal.Utilities.RoundUp((int)stream.Position, alignment) - stream.Position; if (num > 0) { stream.Write(new byte[num], 0, (int)num); } } public static void AddPadding(this Stream stream, byte value, int alignment = 2048) { long num = Reloaded.Memory.Internal.Utilities.RoundUp((int)stream.Position, alignment) - stream.Position; if (num > 0) { byte[] array = new byte[num]; for (int i = 0; i < array.Length; i++) { array[i] = value; } stream.Write(array, 0, (int)num); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, T[] structure) where T : unmanaged { for (int i = 0; i < structure.Length; i++) { stream.Write(ref structure[i]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, T[] structure, bool marshalStructure = true) { for (int i = 0; i < structure.Length; i++) { stream.Write(ref structure[i], marshalStructure); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, T structure) where T : unmanaged { stream.Write(ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, ref T structure) where T : unmanaged { Write(stream, Struct.GetBytes(structure)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, T structure, bool marshalStructure = true) { stream.Write(ref structure, marshalStructure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, ref T structure, bool marshalStructure = true) { Write(stream, Struct.GetBytes(structure, marshalStructure)); } public static void Write(this Stream stream, byte[] data) { stream.Write(data, 0, data.Length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBigEndianPrimitive<T>(this Stream stream, T[] structures) where T : unmanaged { for (int i = 0; i < structures.Length; i++) { stream.WriteBigEndianPrimitive(structures[i]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBigEndianStruct<T>(this Stream stream, T[] structures) where T : unmanaged, IEndianReversible { for (int i = 0; i < structures.Length; i++) { stream.WriteBigEndianStruct(structures[i]); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBigEndianPrimitive<T>(this Stream stream, T structure) where T : unmanaged { Endian.Reverse(ref structure); stream.Write(ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void WriteBigEndianStruct<T>(this Stream stream, T structure) where T : unmanaged, IEndianReversible { structure.SwapEndian(); stream.Write(ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryReadSafe(this Stream stream, byte[] result) { int num = 0; int num2 = result.Length; do { int num3 = stream.Read(result, num, num2); if (num3 <= 0) { return false; } num += num3; num2 -= num3; } while (num < num2); return true; } } } namespace Reloaded.Memory.Streams.Writers { public class BigEndianMemoryStream : EndianMemoryStream { public BigEndianMemoryStream(ExtendedMemoryStream stream) : base(stream) { } public BigEndianMemoryStream(ExtendedMemoryStream stream, bool disposeUnderlyingStream = true) : base(stream, disposeUnderlyingStream) { } public override void Write<T>(T[] structure) { base.Stream.WriteBigEndianPrimitive(structure); } public override void Write<T>(T structure) { base.Stream.WriteBigEndianPrimitive(structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteStruct<T>(T[] structures) where T : unmanaged, IEndianReversible { base.Stream.WriteBigEndianStruct(structures); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteStruct<T>(T structure) where T : unmanaged, IEndianReversible { base.Stream.WriteBigEndianStruct(structure); } [ExcludeFromCodeCoverage] public override void WriteInt16(short data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteUInt16(ushort data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteInt32(int data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteUInt32(uint data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteInt64(long data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteUInt64(ulong data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteSingle(float data) { base.Stream.WriteBigEndianPrimitive(data); } [ExcludeFromCodeCoverage] public override void WriteDouble(double data) { base.Stream.WriteBigEndianPrimitive(data); } } public abstract class EndianMemoryStream : IDisposable { public ExtendedMemoryStream Stream { get; private set; } public bool DisposeUnderlyingStream { get; private set; } = true; protected EndianMemoryStream(ExtendedMemoryStream stream) { Stream = stream; } protected EndianMemoryStream(ExtendedMemoryStream stream, bool disposeUnderlyingStream) { Stream = stream; DisposeUnderlyingStream = disposeUnderlyingStream; } ~EndianMemoryStream() { Dispose(); } public void Dispose() { if (DisposeUnderlyingStream) { Stream?.Dispose(); } GC.SuppressFinalize(this); } public void AddPadding(int alignment = 2048) { Stream.AddPadding(alignment); } public void AddPadding(byte value, int alignment = 2048) { Stream.AddPadding(value, alignment); } public void Write(byte[] data) { Stream.Write(data); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract void Write<T>(T[] structure) where T : unmanaged; [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract void Write<T>(T structure) where T : unmanaged; [MethodImpl(MethodImplOptions.AggressiveInlining)] public byte[] ToArray() { return Stream.ToArray(); } [ExcludeFromCodeCoverage] public abstract void WriteInt16(short data); [ExcludeFromCodeCoverage] public abstract void WriteUInt16(ushort data); [ExcludeFromCodeCoverage] public abstract void WriteInt32(int data); [ExcludeFromCodeCoverage] public abstract void WriteUInt32(uint data); [ExcludeFromCodeCoverage] public abstract void WriteInt64(long data); [ExcludeFromCodeCoverage] public abstract void WriteUInt64(ulong data); [ExcludeFromCodeCoverage] public abstract void WriteSingle(float data); [ExcludeFromCodeCoverage] public abstract void WriteDouble(double data); } public class LittleEndianMemoryStream : EndianMemoryStream { public LittleEndianMemoryStream(ExtendedMemoryStream stream) : base(stream) { } public LittleEndianMemoryStream(ExtendedMemoryStream stream, bool disposeUnderlyingStream = true) : base(stream, disposeUnderlyingStream) { } public override void Write<T>(T[] structure) { base.Stream.Write(structure); } public override void Write<T>(T structure) { base.Stream.Write(ref structure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T[] structure, bool marshalStructure = true) { base.Stream.Write(structure, marshalStructure); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write<T>(T structure, bool marshalStructure = true) { base.Stream.Write(ref structure, marshalStructure); } [ExcludeFromCodeCoverage] public override void WriteInt16(short data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteUInt16(ushort data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteInt32(int data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteUInt32(uint data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteInt64(long data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteUInt64(ulong data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteSingle(float data) { base.Stream.Write(data); } [ExcludeFromCodeCoverage] public override void WriteDouble(double data) { base.Stream.Write(data); } } } namespace Reloaded.Memory.Streams.Readers { public class BigEndianStreamReader : EndianStreamReader { public BigEndianStreamReader(BufferedStreamReader streamReader) : base(streamReader) { } public BigEndianStreamReader(BufferedStreamReader streamReader, bool disposeUnderlyingStream = true) : base(streamReader, disposeUnderlyingStream) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override void Read<T>(out T value) { base.Reader.ReadBigEndianPrimitive(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override T Read<T>() { return base.Reader.ReadBigEndianPrimitive<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override void Peek<T>(out T value) { base.Reader.PeekBigEndianPrimitive(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override T Peek<T>() { return base.Reader.PeekBigEndianPrimitive<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ReadStruct<T>(out T value) where T : unmanaged, IEndianReversible { base.Reader.ReadBigEndianStruct<T>(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T ReadStruct<T>() where T : unmanaged, IEndianReversible { return base.Reader.ReadBigEndianStruct<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PeekStruct<T>(out T value) where T : unmanaged, IEndianReversible { base.Reader.PeekBigEndianStruct<T>(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T PeekStruct<T>() where T : unmanaged, IEndianReversible { return base.Reader.PeekBigEndianStruct<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out short value) { value = base.Reader.ReadBigEndianPrimitiveInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override short ReadInt16() { return base.Reader.ReadBigEndianPrimitiveInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out short value) { value = base.Reader.PeekBigEndianPrimitiveInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override short PeekInt16() { return base.Reader.PeekBigEndianPrimitiveInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out ushort value) { value = base.Reader.ReadBigEndianPrimitiveUInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ushort ReadUInt16() { return base.Reader.ReadBigEndianPrimitiveUInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out ushort value) { value = base.Reader.PeekBigEndianPrimitiveUInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ushort PeekUInt16() { return base.Reader.PeekBigEndianPrimitiveUInt16(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out int value) { value = base.Reader.ReadBigEndianPrimitiveInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override int ReadInt32() { return base.Reader.ReadBigEndianPrimitiveInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out int value) { value = base.Reader.PeekBigEndianPrimitiveInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override int PeekInt32() { return base.Reader.PeekBigEndianPrimitiveInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out uint value) { value = base.Reader.ReadBigEndianPrimitiveUInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override uint ReadUInt32() { return base.Reader.ReadBigEndianPrimitiveUInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out uint value) { value = base.Reader.PeekBigEndianPrimitiveUInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override uint PeekUInt32() { return base.Reader.PeekBigEndianPrimitiveUInt32(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out long value) { value = base.Reader.ReadBigEndianPrimitiveInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override long ReadInt64() { return base.Reader.ReadBigEndianPrimitiveInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out long value) { value = base.Reader.PeekBigEndianPrimitiveInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override long PeekInt64() { return base.Reader.PeekBigEndianPrimitiveInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out ulong value) { value = base.Reader.ReadBigEndianPrimitiveUInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ulong ReadUInt64() { return base.Reader.ReadBigEndianPrimitiveUInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out ulong value) { value = base.Reader.PeekBigEndianPrimitiveUInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ulong PeekUInt64() { return base.Reader.PeekBigEndianPrimitiveUInt64(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out float value) { value = base.Reader.ReadBigEndianPrimitiveSingle(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override float ReadSingle() { return base.Reader.ReadBigEndianPrimitiveSingle(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out float value) { value = base.Reader.PeekBigEndianPrimitiveSingle(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override float PeekSingle() { return base.Reader.PeekBigEndianPrimitiveSingle(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out double value) { value = base.Reader.ReadBigEndianPrimitiveDouble(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override double ReadDouble() { return base.Reader.ReadBigEndianPrimitiveDouble(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out double value) { value = base.Reader.PeekBigEndianPrimitiveDouble(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override double PeekDouble() { return base.Reader.PeekBigEndianPrimitiveDouble(); } } public abstract class EndianStreamReader : IDisposable { public BufferedStreamReader Reader { get; private set; } public bool DisposeUnderlyingStream { get; private set; } = true; [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public Stream BaseStream() { return Reader.BaseStream(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public int BufferBytesAvailable() { return Reader.BufferBytesAvailable(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public int CurrentBufferSize() { return Reader.CurrentBufferSize(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public long Position() { return Reader.Position(); } protected EndianStreamReader(BufferedStreamReader streamReader) { Reader = streamReader; } protected EndianStreamReader(BufferedStreamReader streamReader, bool disposeUnderlyingStream) { Reader = streamReader; DisposeUnderlyingStream = disposeUnderlyingStream; } ~EndianStreamReader() { Dispose(); } public void Dispose() { if (DisposeUnderlyingStream) { Reader?.Dispose(); } GC.SuppressFinalize(this); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract void Read<T>(out T value) where T : unmanaged; [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract T Read<T>() where T : unmanaged; [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract void Peek<T>(out T value) where T : unmanaged; [MethodImpl(MethodImplOptions.AggressiveInlining)] public abstract T Peek<T>() where T : unmanaged; public void Seek(long offset, SeekOrigin origin) { Reader.Seek(offset, origin); } public byte[] ReadBytes(long offset, int count) { return Reader.ReadBytes(offset, count); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool CanRead(int size) { return Reader.CanRead(size); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out short value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract short ReadInt16(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out short value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract short PeekInt16(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out ushort value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract ushort ReadUInt16(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out ushort value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract ushort PeekUInt16(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out int value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract int ReadInt32(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out int value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract int PeekInt32(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out uint value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract uint ReadUInt32(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out uint value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract uint PeekUInt32(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out long value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract long ReadInt64(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out long value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract long PeekInt64(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out ulong value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract ulong ReadUInt64(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out ulong value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract ulong PeekUInt64(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out float value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract float ReadSingle(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out float value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract float PeekSingle(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Read(out double value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract double ReadDouble(); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract void Peek(out double value); [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public abstract double PeekDouble(); } public class LittleEndianStreamReader : EndianStreamReader { public LittleEndianStreamReader(BufferedStreamReader streamReader) : base(streamReader) { } public LittleEndianStreamReader(BufferedStreamReader streamReader, bool disposeUnderlyingStream = true) : base(streamReader, disposeUnderlyingStream) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override void Read<T>(out T value) { base.Reader.Read<T>(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override T Read<T>() { return base.Reader.Read<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override void Peek<T>(out T value) { base.Reader.Peek<T>(out value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override T Peek<T>() { return base.Reader.Peek<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Read<T>(out T value, bool marshal) { base.Reader.Read<T>(out value, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Read<T>(bool marshal) { return base.Reader.Read<T>(marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Peek<T>(out T value, bool marshal) { base.Reader.Peek<T>(out value, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public T Peek<T>(bool marshal) { return base.Reader.Peek<T>(marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out short value) { value = base.Reader.Read<short>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override short ReadInt16() { return base.Reader.Read<short>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out short value) { value = base.Reader.Peek<short>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override short PeekInt16() { return base.Reader.Peek<short>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out ushort value) { value = base.Reader.Read<ushort>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ushort ReadUInt16() { return base.Reader.Read<ushort>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out ushort value) { value = base.Reader.Peek<ushort>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ushort PeekUInt16() { return base.Reader.Peek<ushort>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out int value) { value = base.Reader.Read<int>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override int ReadInt32() { return base.Reader.Read<int>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out int value) { value = base.Reader.Peek<int>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override int PeekInt32() { return base.Reader.Peek<int>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out uint value) { value = base.Reader.Read<uint>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override uint ReadUInt32() { return base.Reader.Read<uint>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out uint value) { value = base.Reader.Peek<uint>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override uint PeekUInt32() { return base.Reader.Peek<uint>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out long value) { value = base.Reader.Read<long>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override long ReadInt64() { return base.Reader.Read<long>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out long value) { value = base.Reader.Peek<long>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override long PeekInt64() { return base.Reader.Peek<long>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out ulong value) { value = base.Reader.Read<ulong>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ulong ReadUInt64() { return base.Reader.Read<ulong>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out ulong value) { value = base.Reader.Peek<ulong>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override ulong PeekUInt64() { return base.Reader.Peek<ulong>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out float value) { value = base.Reader.Read<float>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override float ReadSingle() { return base.Reader.Read<float>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out float value) { value = base.Reader.Peek<float>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override float PeekSingle() { return base.Reader.Peek<float>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Read(out double value) { value = base.Reader.Read<double>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override double ReadDouble() { return base.Reader.Read<double>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override void Peek(out double value) { value = base.Reader.Peek<double>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public override double PeekDouble() { return base.Reader.Peek<double>(); } } } namespace Reloaded.Memory.Sources { public class ExternalMemory : IMemory { private static Memory _localMemory = new Memory(); private readonly IntPtr _processHandle; public ExternalMemory(IntPtr processHandle) { _processHandle = processHandle; } public ExternalMemory(Process process) : this(process.Handle) { } public unsafe void Read<T>(nuint memoryAddress, out T value) where T : unmanaged { int size = Struct.GetSize<T>(); fixed (byte* ptr = new byte[size]) { if (!Reloaded.Memory.Kernel32.Kernel32.ReadProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)size, out var _)) { throw new MemoryException($"ReadProcessMemory failed to read {size} bytes of memory from {memoryAddress}"); } _localMemory.Read<T>((nuint)ptr, out value); } } public unsafe void Read<T>(nuint memoryAddress, out T value, bool marshal) { int size = Struct.GetSize<T>(marshal); fixed (byte* ptr = new byte[size]) { if (!Reloaded.Memory.Kernel32.Kernel32.ReadProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)size, out var _)) { throw new MemoryException($"ReadProcessMemory failed to read {size} bytes of memory from {memoryAddress}"); } _localMemory.Read<T>((nuint)ptr, out value, marshal); } } public unsafe void ReadRaw(nuint memoryAddress, out byte[] value, int length) { value = new byte[length]; fixed (byte* ptr = value) { if (!Reloaded.Memory.Kernel32.Kernel32.ReadProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)value.Length, out var _)) { throw new MemoryException($"ReadProcessMemory failed to read {value.Length} bytes of memory from {memoryAddress}"); } } } public unsafe void Write<T>(nuint memoryAddress, ref T item) where T : unmanaged { byte[] bytes = Struct.GetBytes(ref item); fixed (byte* ptr = bytes) { if (!Reloaded.Memory.Kernel32.Kernel32.WriteProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)bytes.Length, out var _)) { throw new MemoryException($"WriteProcessMemory failed to write {bytes.Length} bytes of memory to {memoryAddress}"); } } } public unsafe void Write<T>(nuint memoryAddress, ref T item, bool marshal) { byte[] bytes = Struct.GetBytes(ref item, marshal); fixed (byte* ptr = bytes) { if (!Reloaded.Memory.Kernel32.Kernel32.WriteProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)bytes.Length, out var _)) { throw new MemoryException($"WriteProcessMemory failed to write {bytes.Length} bytes of memory to {memoryAddress}"); } } } public unsafe void WriteRaw(nuint memoryAddress, byte[] data) { fixed (byte* ptr = data) { if (!Reloaded.Memory.Kernel32.Kernel32.WriteProcessMemory(_processHandle, memoryAddress, (UIntPtr)ptr, (UIntPtr)(ulong)data.Length, out var _)) { throw new MemoryException($"WriteProcessMemory failed to write {data.Length} bytes of memory to {memoryAddress}"); } } } public nuint Allocate(int length) { nuint num = Reloaded.Memory.Kernel32.Kernel32.VirtualAllocEx(_processHandle, UIntPtr.Zero, (UIntPtr)(ulong)length, Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_COMMIT | Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_RESERVE, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); if (num == 0) { throw new MemoryAllocationException($"Failed to allocate memory in external process: {length} bytes, {Marshal.GetLastWin32Error()} last error."); } return num; } public bool Free(nuint address) { return Reloaded.Memory.Kernel32.Kernel32.VirtualFreeEx(_processHandle, address, (UIntPtr)0uL, Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_RELEASE); } public Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION ChangePermission(nuint memoryAddress, int size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions) { if (!Reloaded.Memory.Kernel32.Kernel32.VirtualProtectEx(_processHandle, memoryAddress, (UIntPtr)(ulong)size, newPermissions, out var lpflOldProtect)) { throw new MemoryPermissionException($"Unable to change permissions for the following memory address {memoryAddress} of size {size} and permission {newPermissions.ToString()}"); } return lpflOldProtect; } } public interface IMemory { void Read<T>(nuint memoryAddress, out T value) where T : unmanaged; void Read<T>(nuint memoryAddress, out T value, bool marshal); void ReadRaw(nuint memoryAddress, out byte[] value, int length); void Write<T>(nuint memoryAddress, ref T item) where T : unmanaged; void Write<T>(nuint memoryAddress, ref T item, bool marshal); void WriteRaw(nuint memoryAddress, byte[] data); nuint Allocate(int length); bool Free(nuint address); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION ChangePermission(nuint memoryAddress, int size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions); } public class Memory : IMemory { public static Memory CurrentProcess => Instance; public static Memory Instance { get; } = new Memory(); public unsafe void Read<T>(nuint memoryAddress, out T value) where T : unmanaged { value = Unsafe.Read<T>((void*)memoryAddress); } public unsafe void Read<T>(nuint memoryAddress, out T value, bool marshal) { value = (T)(marshal ? ((object)Marshal.PtrToStructure<T>((nint)memoryAddress)) : ((object)Unsafe.Read<T>((void*)memoryAddress))); } public void ReadRaw(nuint memoryAddress, out byte[] value, int length) { value = new byte[length]; Marshal.Copy((nint)memoryAddress, value, 0, value.Length); } public unsafe void Write<T>(nuint memoryAddress, ref T item) where T : unmanaged { Unsafe.Write((void*)memoryAddress, item); } public unsafe void Write<T>(nuint memoryAddress, ref T item, bool marshal) { if (marshal) { Marshal.StructureToPtr(item, (nint)memoryAddress, fDeleteOld: false); } else { Unsafe.Write((void*)memoryAddress, item); } } public void WriteRaw(nuint memoryAddress, byte[] data) { Marshal.Copy(data, 0, (nint)memoryAddress, data.Length); } public nuint Allocate(int length) { nuint num = Reloaded.Memory.Kernel32.Kernel32.VirtualAlloc(UIntPtr.Zero, (UIntPtr)(ulong)length, Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_COMMIT | Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_RESERVE, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); if (num == 0) { throw new MemoryAllocationException($"Failed to allocate memory in current process: {length} bytes, {Marshal.GetLastWin32Error()} last error."); } return num; } public bool Free(nuint address) { Reloaded.Memory.Kernel32.Kernel32.VirtualFree(address, (UIntPtr)0uL, Reloaded.Memory.Kernel32.Kernel32.MEM_ALLOCATION_TYPE.MEM_RELEASE); return true; } public Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION ChangePermission(nuint memoryAddress, int size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions) { if (!Reloaded.Memory.Kernel32.Kernel32.VirtualProtect(memoryAddress, (UIntPtr)(ulong)size, newPermissions, out var lpflOldProtect)) { throw new MemoryPermissionException($"Unable to change permissions for the following memory address {memoryAddress} of size {size} and permission {newPermissions}"); } return lpflOldProtect; } } public static class MemoryExtensions { public delegate void ReadFunction<T>(nuint memoryAddress, out T value, bool marshal); public delegate void WriteFunction<T>(nuint memoryAddress, ref T item, bool marshal); public static void Read<TMemory, T>(this TMemory memory, nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) where TMemory : IMemory { IMemory source = Struct.Source; Struct.Source = memory; value = new T[arrayLength]; StructArray.FromPtr<T>(memoryAddress, out value, arrayLength, marshal); Struct.Source = source; } public static void SafeRead<TMemory, T>(this TMemory memory, nuint memoryAddress, out T value, bool marshal) where TMemory : IMemory { int size = Struct.GetSize<T>(marshal); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Read<T>(memoryAddress, out value, marshal); memory.ChangePermission(memoryAddress, size, newPermissions); } public static void SafeRead<TMemory, T>(this TMemory memory, nuint memoryAddress, out T value) where TMemory : IMemory where T : unmanaged { int size = Struct.GetSize<T>(); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Read<T>(memoryAddress, out value); memory.ChangePermission(memoryAddress, size, newPermissions); } public static void SafeReadRaw<TMemory>(this TMemory memory, nuint memoryAddress, out byte[] value, int length) where TMemory : IMemory { Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, length, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); value = new byte[length]; memory.ReadRaw(memoryAddress, out value, length); memory.ChangePermission(memoryAddress, length, newPermissions); } public static void SafeRead<TMemory, T>(this TMemory memory, nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) where TMemory : IMemory { int size = StructArray.GetSize<T>(arrayLength, marshal); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Read<TMemory, T>(memoryAddress, out value, arrayLength, marshal); memory.ChangePermission(memoryAddress, size, newPermissions); } public static void Write<TMemory, T>(this TMemory memory, nuint memoryAddress, T[] items, bool marshal = false) where TMemory : IMemory { IMemory source = Struct.Source; Struct.Source = memory; StructArray.ToPtr(memoryAddress, items, marshal); Struct.Source = source; } public static void SafeWrite<TMemory, T>(this TMemory memory, nuint memoryAddress, ref T item, bool marshal) where TMemory : IMemory { int size = Struct.GetSize<T>(marshal); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Write(memoryAddress, ref item, marshal); memory.ChangePermission(memoryAddress, size, newPermissions); } public static void SafeWrite<TMemory, T>(this TMemory memory, nuint memoryAddress, ref T item) where TMemory : IMemory where T : unmanaged { int size = Struct.GetSize<T>(); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Write(memoryAddress, ref item); memory.ChangePermission(memoryAddress, size, newPermissions); } public static void SafeWriteRaw<TMemory>(this TMemory memory, nuint memoryAddress, byte[] data) where TMemory : IMemory { Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, data.Length, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.WriteRaw(memoryAddress, data); memory.ChangePermission(memoryAddress, data.Length, newPermissions); } public static void SafeWrite<TMemory, T>(this TMemory memory, nuint memoryAddress, T[] items, bool marshal = false) where TMemory : IMemory { int size = StructArray.GetSize<T>(items.Length, marshal); Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions = memory.ChangePermission(memoryAddress, size, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION.PAGE_EXECUTE_READWRITE); memory.Write(memoryAddress, items, marshal); memory.ChangePermission(memoryAddress, size, newPermissions); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, int memoryAddress) where TMemory : IMemory where T : unmanaged { memory.Read<T>((nuint)memoryAddress, out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, int memoryAddress, bool marshal) where TMemory : IMemory { memory.Read<T>((nuint)memoryAddress, out var value, marshal); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, long memoryAddress) where TMemory : IMemory where T : unmanaged { memory.Read<T>((nuint)memoryAddress, out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, long memoryAddress, bool marshal) where TMemory : IMemory { memory.Read<T>((nuint)memoryAddress, out var value, marshal); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, nuint memoryAddress) where TMemory : IMemory where T : unmanaged { memory.Read<T>(memoryAddress, out var value); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static T Read<TMemory, T>(this TMemory memory, nuint memoryAddress, bool marshal) where TMemory : IMemory { memory.Read<T>(memoryAddress, out var value, marshal); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, int memoryAddress, T item) where TMemory : IMemory where T : unmanaged { memory.Write((nuint)memoryAddress, ref item); } [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, int memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.Write((nuint)memoryAddress, ref item, marshal); } [ExcludeFromCodeCoverage] public static void SafeWrite<TMemory, T>(this TMemory memory, int memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.SafeWrite((nuint)memoryAddress, ref item, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, long memoryAddress, T item) where TMemory : IMemory where T : unmanaged { memory.Write((nuint)memoryAddress, ref item); } [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, long memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.Write((nuint)memoryAddress, ref item, marshal); } [ExcludeFromCodeCoverage] public static void SafeWrite<TMemory, T>(this TMemory memory, long memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.SafeWrite((nuint)memoryAddress, ref item, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, nuint memoryAddress, T item) where TMemory : IMemory where T : unmanaged { memory.Write(memoryAddress, ref item); } [ExcludeFromCodeCoverage] public static void Write<TMemory, T>(this TMemory memory, nuint memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.Write(memoryAddress, ref item, marshal); } [ExcludeFromCodeCoverage] public static void SafeWrite<TMemory, T>(this TMemory memory, nuint memoryAddress, T item, bool marshal = false) where TMemory : IMemory { memory.SafeWrite(memoryAddress, ref item, marshal); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [ExcludeFromCodeCoverage] public static Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION ChangePermission<TMemory, T>(this TMemory memory, nuint memoryAddress, ref T baseElement, Reloaded.Memory.Kernel32.Kernel32.MEM_PROTECTION newPermissions, bool marshalElement = false) where TMemory : IMemory { return memory.ChangePermission(memoryAddress, Struct.GetSize<T>(marshalElement), newPermissions); } } } namespace Reloaded.Memory.Pointers { public struct ArrayPtr<TStruct> : IArrayPtr<TStruct> { public unsafe void* Pointer { get; set; } public bool MarshalElements { get; set; } public IMemory Source { get; set; } public int ElementSize => Struct.GetSize<TStruct>(MarshalElements); public TStruct this[int index] { get { Get(out var value, index); return value; } set { Set(ref value, index); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Get(out TStruct value, int index) { Source.Read<TStruct>((nuint)GetPointerToElement(index), out value, MarshalElements); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Set(ref TStruct value, int index) { Source.Write((nuint)GetPointerToElement(index), ref value, MarshalElements); } public unsafe ArrayPtr(nuint address, bool marshalElements = false, IMemory source = null) { Pointer = (void*)address; MarshalElements = marshalElements; Source = source ?? Reloaded.Memory.Sources.Memory.CurrentProcess; } public unsafe void* GetPointerToElement(int index) { return (void*)((ulong)Pointer + (ulong)(index * ElementSize)); } } public struct BlittablePointer<T> where T : unmanaged { public unsafe T* Pointer { get; set; } public unsafe BlittablePointer(T* pointer) { Pointer = pointer; } public RefPointer<T> AsRefPointer() { return this; } public unsafe ref T AsReference() { return ref Unsafe.AsRef<T>(Pointer); } public unsafe static implicit operator BlittablePointer<T>(T* operand) { return new BlittablePointer<T>(operand); } public unsafe static implicit operator T*(BlittablePointer<T> operand) { return operand.Pointer; } } public struct FixedArrayPtr<TStruct> : IEnumerable<TStruct>, IEnumerable, IArrayPtr<TStruct> { private class FixedArrayPtrEnumerator : IEnumerator<TStruct>, IEnumerator, IDisposable { private readonly FixedArrayPtr<TStruct> _arrayPtr; private int _currentIndex = -1; object IEnumerator.Current => Current; public TStruct Current { get { _arrayPtr.Get(out var value, _currentIndex); return value; } } public FixedArrayPtrEnumerator(FixedArrayPtr<TStruct> parentArrayPtr) { _arrayPtr = parentArrayPtr; } public bool MoveNext() { _currentIndex++; return _currentIndex < _arrayPtr.Count; } [ExcludeFromCodeCoverage] public void Reset() { _currentIndex = -1; } public void Dispose() { } } public unsafe void* Pointer { get; set; } public bool MarshalElements { get; set; } public IMemory Source { get; set; } public int ElementSize => Struct.GetSize<TStruct>(MarshalElements); public int Count { get; set; } public int ArraySize => Struct.GetSize<TStruct>(MarshalElements) * Count; public TStruct this[int index] { get { Get(out var value, index); return value; } set { Set(ref value, index); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Get(out TStruct value, int index) { Source.Read<TStruct>((nuint)GetPointerToElement(index), out value, MarshalElements); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Set(ref TStruct value, int index) { Source.Write((nuint)GetPointerToElement(index), ref value, MarshalElements); } public unsafe FixedArrayPtr(nuint address, int count, bool marshalElements = false, IMemory source = null) { Pointer = (void*)address; Count = count; MarshalElements = marshalElements; Source = source ?? Reloaded.Memory.Sources.Memory.CurrentProcess; } public bool Contains(TStruct item) { return Contains(ref item); } public bool Contains(ref TStruct item) { return IndexOf(ref item) != -1; } public int IndexOf(TStruct item) { return IndexOf(ref item); } public int IndexOf(ref TStruct item) { for (int i = 0; i < Count; i++) { Get(out var value, i); if (value.Equals(item)) { return i; } } return -1; } public void CopyFrom(TStruct[] sourceArray, int length, int sourceIndex = 0, int destinationIndex = 0) { int num = Count - destinationIndex; if (length > num) { throw new ArgumentException(string.Format("There is insufficient space in the {0} to copy {1} elements. (Length: {2}, Available Elements: {3})", "FixedArrayPtr", length, length, num)); } int num2 = sourceArray.Length - sourceIndex; if (length > num2) { throw new ArgumentException(string.Format("There is insufficient space in the {0} to copy {1} elements. (Length: {2}, Available Elements: {3})", "sourceArray", length, length, num2)); } for (int i = 0; i < length; i++) { Set(ref sourceArray[sourceIndex + i], destinationIndex + i); } } public void CopyTo(TStruct[] destinationArray, int length, int sourceIndex = 0, int destinationIndex = 0) { int num = destinationArray.Length - destinationIndex; if (length > num) { throw new ArgumentException(string.Format("There is insufficient space in the {0} to copy {1} elements. (Length: {2}, Available Elements: {3})", "destinationArray", length, length, num)); } int num2 = Count - sourceIndex; if (length > num2) { throw new ArgumentException(string.Format("There are not enough elements in the current {0}. (Length: {1}, Available Elements: {2})", "FixedArrayPtr", length, num2)); } for (int i = 0; i < length; i++) { Get(out var value, sourceIndex + i); destinationArray[i + destinationIndex] = value; } } public unsafe void* GetPointerToElement(int index) { if (index >= Count) { return (void*)(-1); } return (void*)((ulong)Pointer + (ulong)(index * ElementSize)); } public IEnumerator<TStruct> GetEnumerator() { return new FixedArrayPtrEnumerator(this); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public interface IArrayPtr<TStruct> { int ElementSize { get; } bool MarshalElements { get; set; } unsafe void* Pointer { get; set; } IMemory Source { get; set; } TStruct this[int index] { get; set; } unsafe void* GetPointerToElement(int index); void Get(out TStruct value, int index); void Set(ref TStruct value, int index); } public struct Pointer<TStruct> { public unsafe void* Address { get; set; } public bool MarshalElements { get; set; } public IMemory Source { get; set; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe TStruct GetValue() { Source.Read<TStruct>((nuint)Address, out var value, MarshalElements); return value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void GetValue(out TStruct value) { Source.Read<TStruct>((nuint)Address, out value, MarshalElements); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetValue(TStruct value) { Source.Write((nuint)Address, ref value, MarshalElements); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void SetValue(ref TStruct value) { Source.Write((nuint)Address, ref value, MarshalElements); } public unsafe Pointer(nuint address, bool marshalElements = false, IMemory memorySource = null) { Address = (void*)address; MarshalElements = marshalElements; Source = memorySource ?? Reloaded.Memory.Sources.Memory.CurrentProcess; } } public struct RefArrayPtr<TStruct> where TStruct : unmanaged { public unsafe TStruct* Pointer { get; private set; } public unsafe ref TStruct this[int index] => ref RefPointer<TStruct>.Create(Pointer + index); public unsafe RefArrayPtr(nuint address) { Pointer = (TStruct*)address; } public unsafe RefArrayPtr(TStruct* structPtr) { Pointer = structPtr; } } public struct RefFixedArrayPtr<TStruct> where TStruct : unmanaged { public unsafe TStruct* Pointer { get; set; } public int Count { get; set; } public unsafe ref TStruct this[int index] => ref RefPointer<TStruct>.Create(Pointer + index); public unsafe RefFixedArrayPtr(nuint address, int numberOfItems) { Pointer = (TStruct*)address; Count = numberOfItems; } public unsafe RefFixedArrayPtr(TStruct* structPtr, int numberOfItems) { Pointer = structPtr; Count = numberOfItems; } public bool Contains(TStruct item) { return IndexOf(ref item) != -1; } public bool Contains(ref TStruct item) { return IndexOf(ref item) != -1; } public int IndexOf(TStruct item) { return IndexOf(ref item); } public int IndexOf(ref TStruct item) { for (int i = 0; i < Count; i++) { if (this[i].Equals(item)) { return i; } } return -1; } public void CopyFrom(TStruct[] sourceArray, int length, int sourceIndex = 0, int destinationIndex = 0) { int num = Count - destinationIndex; if (length > num) { throw new ArgumentException(string.Format("There is insufficient space in the {0} to copy {1} elements. (Length: {2}, Available Elements: {3})", "RefFixedArrayPtr", length, length, num)); } int num2 = sourceArray.Length - sourceIndex; if (length > num2) { throw new ArgumentException(string.Format("There is insufficient space in the {0} to copy {1} elements. (Length: {2}, Available Elements: {3})", "sourceArray", length, length, num2)); } for (int i = 0; i < length; i++) { this[destinationIndex + i] = sourceArray[sourceIndex + i]; } } public void CopyTo(TStruct[] destinationArray, int length, int sourceIndex = 0, int destinationIndex = 0) { int num = destinationArray.Length - destinationIndex; if (length > num) { throw new ArgumentException($"There is insufficient space in the destination array to copy {length} elements. (Length: {length}, Available Elements: {num})"); } int num2 = Count - sourceIndex; if (length > num2) { throw new ArgumentException(string.Format("There are not enough elements in the current {0}. (Length: {1}, Available Elements: {2})", "FixedArrayPtr", length, num2)); } for (int i = 0; i < length; i++) { destinationArray[i + destinationIndex] = this[sourceIndex + i]; } } } public struct RefPointer<TStruct> where TStruct : unmanaged { public unsafe TStruct* Address { get; set; } public int DepthLevel { get; set; } public unsafe RefPointer(TStruct* address, int depthLevel) { Address = address; DepthLevel = depthLevel; } public unsafe bool TryDereference(ref TStruct value) { TStruct* ptr = Address; if (ptr == null) { return false; } for (int i = 0; i < DepthLevel - 1; i++) { ptr = *(TStruct**)ptr; if (ptr == null) { return false; } } value = Create(ptr); return true; } public unsafe bool TryDereference(out TStruct* value) { TStruct* ptr = Address; value = null; if (ptr == null) { return false; } for (int i = 0; i < DepthLevel - 1; i++) { ptr = *(TStruct**)ptr; if (ptr == null) { return false; } } value = ptr; return true; } public unsafe ref TStruct TryDereference(out bool success) { TStruct* ptr = Address; success = false; if (ptr == null) { return ref Create(ptr); } for (int i = 0; i < DepthLevel - 1; i++) { ptr = *(TStruct**)ptr; if (ptr == null) { return ref Create(ptr); } } success = true; return ref Create(ptr); } public unsafe static ref TStruct Create(TStruct* pointer) { return ref Unsafe.AsRef<TStruct>(pointer); } public unsafe static ref TStruct Create(nuint pointer) { return ref Unsafe.AsRef<TStruct>((void*)pointer); } public unsafe static implicit operator RefPointer<TStruct>(BlittablePointer<TStruct> operand) { return new RefPointer<TStruct>(operand.Pointer, 1); } } } namespace Reloaded.Memory.Kernel32 { public static class Kernel32 { [Flags] public enum MEM_ALLOCATION_TYPE : uint { MEM_COMMIT = 0x1000u, MEM_RESERVE = 0x2000u, MEM_DECOMMIT = 0x4000u, MEM_RELEASE = 0x8000u, MEM_FREE = 0x10000u, MEM_PRIVATE = 0x20000u, MEM_MAPPED = 0x40000u, MEM_RESET = 0x80000u, MEM_TOP_DOWN = 0x100000u, MEM_WRITE_WATCH = 0x200000u, MEM_PHYSICAL = 0x400000u, MEM_ROTATE = 0x800000u, MEM_DIFFERENT_IMAGE_BASE_OK = 0x800000u, MEM_RESET_UNDO = 0x1000000u, MEM_LARGE_PAGES = 0x20000000u, MEM_4MB_PAGES = 0x80000000u, MEM_64K_PAGES = 0x20400000u } [Flags] public enum MEM_PROTECTION : uint { PAGE_NOACCESS = 1u, PAGE_READONLY = 2u, PAGE_READWRITE = 4u, PAGE_WRITECOPY = 8u, PAGE_EXECUTE = 0x10u, PAGE_EXECUTE_READ = 0x20u, PAGE_EXECUTE_READWRITE = 0x40u, PAGE_EXECUTE_WRITECOPY = 0x80u, PAGE_GUARD = 0x100u, PAGE_NOCACHE = 0x200u, PAGE_WRITECOMBINE = 0x400u, PAGE_ENCLAVE_UNVALIDATED = 0x20000000u, PAGE_TARGETS_INVALID = 0x40000000u, PAGE_TARGETS_NO_UPDATE = 0x40000000u, PAGE_ENCLAVE_THREAD_CONTROL = 0x80000000u, PAGE_REVERT_TO_FILE_MAP = 0x80000000u } [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadProcessMemory([In] IntPtr hProcess, [In] UIntPtr lpBaseAddress, UIntPtr lpBuffer, UIntPtr nSize, out UIntPtr lpNumberOfBytesRead); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool WriteProcessMemory([In] IntPtr hProcess, [In] UIntPtr lpBaseAddress, [In] UIntPtr lpBuffer, UIntPtr nSize, out UIntPtr lpNumberOfBytesWritten); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] public static extern nuint VirtualAllocEx([In] IntPtr hProcess, [In] UIntPtr lpAddress, UIntPtr dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool VirtualFreeEx([In] IntPtr hProcess, [In] UIntPtr lpAddress, UIntPtr dwSize, MEM_ALLOCATION_TYPE dwFreeType); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool VirtualProtectEx([In] IntPtr hProcess, [In] UIntPtr lpAddress, UIntPtr dwSize, MEM_PROTECTION flNewProtect, out MEM_PROTECTION lpflOldProtect); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] public static extern nuint VirtualAlloc([In] UIntPtr lpAddress, UIntPtr dwSize, MEM_ALLOCATION_TYPE flAllocationType, MEM_PROTECTION flProtect); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool VirtualFree([In] UIntPtr lpAddress, UIntPtr dwSize, MEM_ALLOCATION_TYPE dwFreeType); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool VirtualProtect([In] UIntPtr lpAddress, UIntPtr dwSize, MEM_PROTECTION flNewProtect, out MEM_PROTECTION lpflOldProtect); } } namespace Reloaded.Memory.Interop { public class Pinnable<T> : IDisposable where T : unmanaged { private GCHandle _handle; public unsafe ref T Value => ref RefPointer<T>.Create(Pointer); public unsafe T* Pointer { get; private set; } public unsafe Pinnable(T[] value) { _handle = GCHandle.Alloc(value, GCHandleType.Pinned); Pointer = (T*)(void*)_handle.AddrOfPinnedObject(); } public Pinnable(T value) { InitFromReference(ref value); } public Pinnable(ref T value) { InitFromReference(ref value); } private unsafe void InitFromReference(ref T value) { _handle = GCHandle.Alloc(value, GCHandleType.Pinned); Pointer = (T*)(void*)_handle.AddrOfPinnedObject(); } ~Pinnable() { Dispose(); } public void Dispose() { if (_handle.IsAllocated) { _handle.Free(); } GC.SuppressFinalize(this); } } public class PinnableDisposable<T> : Pinnable<T> where T : unmanaged, IDisposable { public PinnableDisposable(T value) : base(value) { } public PinnableDisposable(ref T value) : base(ref value) { } ~PinnableDisposable() { Dispose(); } public new void Dispose() { base.Dispose(); base.Value.Dispose(); GC.SuppressFinalize(this); } } } namespace Reloaded.Memory.Internal { internal static class Utilities { internal static int RoundUp(int number, int multiple) { if (multiple == 0
BepInEx/plugins/DearImGuiInjection/Reloaded.Memory.Buffers.dll
Decompiled 7 months agousing System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using Microsoft.CodeAnalysis; using Reloaded.Memory.Buffers.Internal; using Reloaded.Memory.Buffers.Internal.Kernel32; using Reloaded.Memory.Buffers.Internal.Structs; using Reloaded.Memory.Buffers.Internal.Utilities; using Reloaded.Memory.Kernel32; using Reloaded.Memory.Sources; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Sewer56")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("LGPL V3")] [assembly: AssemblyDescription("An implementation of efficient, shared, concurrent and permanent storage of objects in unmanaged memory in static, non-changing locations that last the lifetime of a given process.")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0")] [assembly: AssemblyProduct("Project Reloaded")] [assembly: AssemblyTitle("Reloaded.Memory.Buffers")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Reloaded-Project/Reloaded.Memory.Buffers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace Reloaded.Memory.Buffers { public class MemoryBuffer : IDisposable { private Mutex _bufferAddMutex; private readonly nuint _headerAddress; public IMemory MemorySource { get; private set; } public MemoryBufferProperties Properties { get { MemoryBufferProperties result = default(MemoryBufferProperties); MemorySource.Read<MemoryBufferProperties>((UIntPtr)_headerAddress, ref result); return result; } set { MemorySource.Write<MemoryBufferProperties>((UIntPtr)_headerAddress, ref value); } } internal unsafe nuint AllocationAddress => (UIntPtr)_headerAddress - sizeof(MemoryBufferMagic); internal MemoryBuffer(IMemory memorySource, nuint headerAddress) { _headerAddress = headerAddress; MemorySource = memorySource; } internal MemoryBuffer(IMemory memorySource, nuint headerAddress, MemoryBufferProperties memoryBufferProperties) : this(memorySource, headerAddress) { Properties = memoryBufferProperties; } ~MemoryBuffer() { Dispose(); } public void Dispose() { _bufferAddMutex?.Dispose(); GC.SuppressFinalize(this); } internal void SetupMutex(Process process) { try { _bufferAddMutex = Mutex.OpenExisting(GetMutexName(process)); } catch (WaitHandleCannotBeOpenedException) { _bufferAddMutex = new Mutex(initiallyOwned: false, GetMutexName(process)); } } internal string GetMutexName(Process process) { object arg = process.Id; nuint headerAddress = _headerAddress; return $"Reloaded.Memory.Buffers.MemoryBuffer | PID: {arg} | Memory Address: {((UIntPtr)headerAddress).ToString()}"; } public T ExecuteWithLock<T>(Func<T> func) { try { _bufferAddMutex.WaitOne(); T result = func(); _bufferAddMutex.ReleaseMutex(); return result; } catch (Exception) { _bufferAddMutex.ReleaseMutex(); throw; } } public void SetAlignment(int alignment) { ExecuteWithLock(delegate { MemoryBufferProperties properties = Properties; properties.SetAlignment(alignment); Properties = properties; return true; }); } public nuint Add(int numBytes, int alignment = 4) { return ExecuteWithLock(delegate { MemoryBufferProperties properties = Properties; properties.SetAlignment(alignment); if (Properties.Remaining < numBytes) { return 0u; } nuint writePointer = properties.WritePointer; properties.Offset += numBytes; Properties = properties; return writePointer; }); } public nuint Add(byte[] bytesToWrite, int alignment = 4) { return ExecuteWithLock(delegate { MemoryBufferProperties properties = Properties; properties.SetAlignment(alignment); if (Properties.Remaining < bytesToWrite.Length) { return 0u; } nuint writePointer = properties.WritePointer; MemorySource.WriteRaw((UIntPtr)writePointer, bytesToWrite); properties.Offset += bytesToWrite.Length; Properties = properties; return writePointer; }); } public nuint Add<TStructure>(ref TStructure bytesToWrite, bool marshalElement = false, int alignment = 4) { TStructure bytesToWriteByVal = bytesToWrite; return ExecuteWithLock(delegate { MemoryBufferProperties properties = Properties; int size = Struct.GetSize<TStructure>(marshalElement); properties.SetAlignment(alignment); if (Properties.Remaining < size) { return 0u; } nuint writePointer = properties.WritePointer; MemorySource.Write<TStructure>((UIntPtr)writePointer, ref bytesToWriteByVal, marshalElement); properties.Offset += size; Properties = properties; return writePointer; }); } public bool CanItemFit(int objectSize) { return Properties.Remaining >= objectSize; } public bool CanItemFit<TGeneric>(ref TGeneric item, bool marshalElement = false) { return CanItemFit(Struct.GetSize<TGeneric>(marshalElement)); } public override bool Equals(object obj) { return obj is MemoryBuffer memoryBuffer && _headerAddress == memoryBuffer._headerAddress; } [ExcludeFromCodeCoverage] public override int GetHashCode() { return (int)_headerAddress; } } public class MemoryBufferHelper { internal const int DefaultPageSize = 4096; private Mutex _allocateMemoryMutex; private MemoryBufferSearcher _bufferSearcher; private VirtualQueryUtility.VirtualQueryFunction _virtualQueryFunction; public Process Process { get; private set; } internal string CreateBufferMutexName() { return $"Reloaded.Memory.Buffers.MemoryBufferHelper | Allocate Memory | PID: {Process.Id}"; } public MemoryBufferHelper(Process process) { Process = process; _bufferSearcher = new MemoryBufferSearcher(process); _virtualQueryFunction = VirtualQueryUtility.GetVirtualQueryFunction(process); _allocateMemoryMutex = MutexObtainer.MakeMutex(CreateBufferMutexName()); } public BufferAllocationProperties FindBufferLocation(int size, nuint minimumAddress, nuint maximumAddress, bool isPrivateBuffer = false) { if (minimumAddress == 0) { throw new ArgumentException("Please do not set the minimum address to 0 or negative. It collides with the return values of Windows API functionswhere e.g. 0 is returned on failure but you can also allocate successfully on 0."); } int bufferSize = GetBufferSize(size, isPrivateBuffer); List<Kernel32.MEMORY_BASIC_INFORMATION> pages = MemoryPages.GetPages(Process); for (int i = 0; i < pages.Count; i++) { Kernel32.MEMORY_BASIC_INFORMATION pageInfo = pages[i]; nuint bufferPointerInPageRange = GetBufferPointerInPageRange(in pageInfo, bufferSize, minimumAddress, maximumAddress); if (bufferPointerInPageRange != 0) { return new BufferAllocationProperties(bufferPointerInPageRange, bufferSize); } } throw new Exception($"Unable to find memory location to fit MemoryBuffer of size {size} ({bufferSize}) between {minimumAddress} and {maximumAddress}."); } public MemoryBuffer CreateMemoryBuffer(int size, nuint minimumAddress = 65536u, nuint maximumAddress = 2147483647u, int retryCount = 3) { if (minimumAddress == 0) { throw new ArgumentException("Please do not set the minimum address to 0 or negative. It collides with the return values of Windows API functionswhere e.g. 0 is returned on failure but you can also allocate successfully on 0."); } Exception ex = new Exception(); _allocateMemoryMutex.WaitOne(); while (minimumAddress < maximumAddress) { try { return Run(retryCount, delegate { BufferAllocationProperties bufferAllocationProperties = FindBufferLocation(size, minimumAddress, maximumAddress); MemoryBuffer memoryBuffer = MemoryBufferFactory.CreateBuffer(Process, bufferAllocationProperties.MemoryAddress, bufferAllocationProperties.Size); _bufferSearcher.AddBuffer(memoryBuffer); _allocateMemoryMutex.ReleaseMutex(); return memoryBuffer; }); } catch (Exception ex2) { ex = ex2; minimumAddress += 65536u; } } _allocateMemoryMutex.ReleaseMutex(); throw ex; } public PrivateMemoryBuffer CreatePrivateMemoryBuffer(int size, nuint minimumAddress = 65536u, nuint maximumAddress = 2147483647u, int retryCount = 3) { if (minimumAddress == 0) { throw new ArgumentException("Please do not set the minimum address to 0 or negative. It collides with the return values of Windows API functionswhere e.g. 0 is returned on failure but you can also allocate successfully on 0."); } Exception ex = new Exception(); _allocateMemoryMutex.WaitOne(); while (minimumAddress < maximumAddress) { try { return Run(retryCount, delegate { BufferAllocationProperties bufferAllocationProperties = FindBufferLocation(size, minimumAddress, maximumAddress, isPrivateBuffer: true); PrivateMemoryBuffer result = MemoryBufferFactory.CreatePrivateBuffer(Process, bufferAllocationProperties.MemoryAddress, bufferAllocationProperties.Size); _allocateMemoryMutex.ReleaseMutex(); return result; }); } catch (Exception ex2) { ex = ex2; minimumAddress += 65536u; } } _allocateMemoryMutex.ReleaseMutex(); throw ex; } public MemoryBuffer[] FindBuffers(int size, bool useCache = true) { return _bufferSearcher.GetBuffers(size, useCache); } public MemoryBuffer[] FindBuffers(int size, nuint minimumAddress, nuint maximumAddress, bool useCache = true) { MemoryBuffer[] buffers = _bufferSearcher.GetBuffers(size, useCache); AddressRange addressRange = new AddressRange(minimumAddress, maximumAddress); List<MemoryBuffer> list = new List<MemoryBuffer>(buffers.Length); MemoryBuffer[] array = buffers; foreach (MemoryBuffer memoryBuffer in array) { MemoryBufferProperties properties = memoryBuffer.Properties; AddressRange otherRange = new AddressRange(properties.DataPointer, (UIntPtr)properties.DataPointer + properties.Size); if (addressRange.Contains(ref otherRange)) { list.Add(memoryBuffer); } } return list.ToArray(); } public BufferAllocationProperties Allocate(int size, nuint minimumAddress = 65536u, nuint maximumAddress = 2147483647u, int retryCount = 3) { if (minimumAddress == 0) { throw new ArgumentException("Please do not set the minimum address to 0 or negative. It collides with the return values of Windows API functionswhere e.g. 0 is returned on failure but you can also allocate successfully on 0."); } Exception ex = new Exception(); _allocateMemoryMutex.WaitOne(); while (minimumAddress < maximumAddress) { try { return Run(retryCount, delegate { BufferAllocationProperties result = FindBufferLocation(size, minimumAddress, maximumAddress, isPrivateBuffer: true); VirtualAllocUtility.VirtualAllocFunction virtualAllocFunction = VirtualAllocUtility.GetVirtualAllocFunction(Process); UIntPtr uIntPtr = virtualAllocFunction(Process.Handle, result.MemoryAddress, (ulong)result.Size); if (uIntPtr == UIntPtr.Zero) { throw new Exception("Failed to allocate memory using VirtualAlloc/VirtualAllocEx"); } _allocateMemoryMutex.ReleaseMutex(); return result; }); } catch (Exception ex2) { ex = ex2; minimumAddress += 65536u; } } _allocateMemoryMutex.ReleaseMutex(); throw ex; } public void Free(nuint address) { _allocateMemoryMutex.WaitOne(); try { VirtualFreeUtility.GetVirtualFreeFunction(Process)(Process.Handle, address); _allocateMemoryMutex.ReleaseMutex(); } catch (Exception) { _allocateMemoryMutex.ReleaseMutex(); throw; } } public int GetBufferSize(int size, bool isPrivateBuffer = false) { Kernel32.GetSystemInfo(out var lpSystemInfo); int num = 4096; if (lpSystemInfo.dwPageSize > num || num % lpSystemInfo.dwPageSize != 0) { num = (int)lpSystemInfo.dwPageSize; } if (isPrivateBuffer) { return Mathematics.RoundUp(size + MemoryBufferFactory.PrivateBufferOverhead, num); } return Mathematics.RoundUp(size + MemoryBufferFactory.BufferOverhead, num); } private T Run<T>(int retries, Func<T> function) { Exception ex = new Exception("This should not throw"); for (int i = 0; i < retries; i++) { try { return function(); } catch (Exception ex2) { ex = ex2; } } throw ex; } private nuint GetBufferPointerInPageRange(in Kernel32.MEMORY_BASIC_INFORMATION pageInfo, int bufferSize, nuint minimumPtr, nuint maximumPtr) { if (pageInfo.State != 65536) { return 0u; } nuint multiple = 65536u; nuint baseAddress = pageInfo.BaseAddress; nuint endPointer = pageInfo.BaseAddress + pageInfo.RegionSize; AddressRange otherRange = new AddressRange(minimumPtr, maximumPtr); AddressRange addressRange = new AddressRange(baseAddress, endPointer); if (!addressRange.Overlaps(ref otherRange)) { return 0u; } nuint num = Mathematics.RoundDown((UIntPtr)addressRange.EndPointer - bufferSize, multiple); AddressRange otherRange2 = new AddressRange(num, (UIntPtr)num + bufferSize); if (addressRange.Contains(ref otherRange2) && otherRange.Contains(ref otherRange2)) { return otherRange2.StartPointer; } nuint num2 = Mathematics.RoundUp(addressRange.StartPointer, multiple); AddressRange otherRange3 = new AddressRange(num2, (UIntPtr)num2 + bufferSize); if (addressRange.Contains(ref otherRange3) && otherRange.Contains(ref otherRange3)) { return otherRange3.StartPointer; } nuint num3 = Mathematics.RoundDown((UIntPtr)maximumPtr - bufferSize, multiple); AddressRange otherRange4 = new AddressRange(num3, (UIntPtr)num3 + bufferSize); if (addressRange.Contains(ref otherRange4) && otherRange.Contains(ref otherRange4)) { return otherRange4.StartPointer; } nuint num4 = Mathematics.RoundUp(minimumPtr, multiple); AddressRange otherRange5 = new AddressRange(num4, (UIntPtr)num4 + bufferSize); if (addressRange.Contains(ref otherRange5) && otherRange.Contains(ref otherRange5)) { return otherRange5.StartPointer; } return 0u; } } public struct MemoryBufferProperties { public nuint DataPointer { get; internal set; } public int Alignment { get; private set; } public int Offset { get; internal set; } public int Size { get; internal set; } public int Remaining => Size - Offset; public nuint WritePointer => (UIntPtr)DataPointer + Offset; public MemoryBufferProperties(nuint dataPointer, int size) { Alignment = 4; DataPointer = dataPointer; Offset = 0; Size = size; } internal void SetAlignment(int alignment) { Alignment = alignment; Align(); } internal void Align() { Offset = (int)(Mathematics.RoundUp(WritePointer, (ulong)Alignment) - DataPointer); } } public static class MemoryPages { public static List<Kernel32.MEMORY_BASIC_INFORMATION> GetPages(Process process) { Kernel32.IsWow64Process(process.Handle, out var Wow64Process); Kernel32.GetSystemInfo(out var lpSystemInfo); nuint num = 0u; nuint num2 = 2147483647u; if (lpSystemInfo.wProcessorArchitecture == Kernel32.ProcessorArchitecture.PROCESSOR_ARCHITECTURE_AMD64 && !Wow64Process) { num2 = lpSystemInfo.lpMaximumApplicationAddress; } if (IntPtr.Size == 4 && lpSystemInfo.lpMaximumApplicationAddress > num2) { num2 = lpSystemInfo.lpMaximumApplicationAddress; } VirtualQueryUtility.VirtualQueryFunction virtualQueryFunction = VirtualQueryUtility.GetVirtualQueryFunction(process); List<Kernel32.MEMORY_BASIC_INFORMATION> list = new List<Kernel32.MEMORY_BASIC_INFORMATION>(8192); Kernel32.MEMORY_BASIC_INFORMATION memoryInformation; for (; num <= num2; num += memoryInformation.RegionSize) { memoryInformation = default(Kernel32.MEMORY_BASIC_INFORMATION); UIntPtr uIntPtr = virtualQueryFunction(process.Handle, num, ref memoryInformation); if (uIntPtr == (UIntPtr)0uL) { break; } list.Add(memoryInformation); } return list; } } public class PrivateMemoryBuffer : MemoryBuffer, IDisposable { internal PrivateMemoryBuffer(IMemory memorySource, nuint headerAddress, MemoryBufferProperties memoryBufferProperties) : base(memorySource, headerAddress, memoryBufferProperties) { } ~PrivateMemoryBuffer() { Dispose(); } public new void Dispose() { base.MemorySource.Free((UIntPtr)base.AllocationAddress); base.Dispose(); GC.SuppressFinalize(this); } } } namespace Reloaded.Memory.Buffers.Internal { internal static class MemoryBufferFactory { private static MemoryBufferMagic _bufferMagic = new MemoryBufferMagic(initialize: true); internal unsafe static int BufferOverhead => sizeof(MemoryBufferProperties) + sizeof(MemoryBufferMagic); internal unsafe static int PrivateBufferOverhead => sizeof(MemoryBufferProperties); internal unsafe static MemoryBuffer CreateBuffer(Process process, nuint bufferAddress, int allocationSize, bool allocateMemory = true) { if (allocateMemory) { AllocateBuffer(process, bufferAddress, allocationSize); } IMemory memorySource = GetMemorySource(process); memorySource.Write<MemoryBufferMagic>((UIntPtr)bufferAddress, ref _bufferMagic); nuint headerAddress = (UIntPtr)bufferAddress + sizeof(MemoryBufferMagic); nuint dataPointer = (UIntPtr)bufferAddress + BufferOverhead; int size = allocationSize - BufferOverhead; MemoryBufferProperties memoryBufferProperties = new MemoryBufferProperties(dataPointer, size); MemoryBuffer memoryBuffer = new MemoryBuffer(memorySource, headerAddress, memoryBufferProperties); memoryBuffer.SetupMutex(process); return memoryBuffer; } internal static PrivateMemoryBuffer CreatePrivateBuffer(Process process, nuint bufferAddress, int allocationSize, bool allocateMemory = true) { if (allocateMemory) { AllocateBuffer(process, bufferAddress, allocationSize); } IMemory memorySource = GetMemorySource(process); nuint dataPointer = (UIntPtr)bufferAddress + PrivateBufferOverhead; int size = allocationSize - PrivateBufferOverhead; MemoryBufferProperties memoryBufferProperties = new MemoryBufferProperties(dataPointer, size); PrivateMemoryBuffer privateMemoryBuffer = new PrivateMemoryBuffer(memorySource, bufferAddress, memoryBufferProperties); privateMemoryBuffer.SetupMutex(process); return privateMemoryBuffer; } internal unsafe static MemoryBuffer FromAddress(Process process, nuint bufferMagicAddress) { VirtualQueryUtility.VirtualQueryFunction virtualQueryFunction = VirtualQueryUtility.GetVirtualQueryFunction(process); Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION memoryInformation = default(Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION); UIntPtr uIntPtr = virtualQueryFunction(process.Handle, bufferMagicAddress, ref memoryInformation); if (uIntPtr == (UIntPtr)0uL) { throw new Exception("VirtualQuery failed. Result is 0."); } if (memoryInformation.State != 65536 && IsBuffer(process, bufferMagicAddress)) { MemoryBuffer memoryBuffer = new MemoryBuffer(GetMemorySource(process), (UIntPtr)bufferMagicAddress + sizeof(MemoryBufferMagic)); memoryBuffer.SetupMutex(process); return memoryBuffer; } return null; } internal static void AllocateBuffer(Process process, nuint bufferAddress, int bufferSize) { VirtualAllocUtility.VirtualAllocFunction virtualAllocFunction = VirtualAllocUtility.GetVirtualAllocFunction(process); UIntPtr uIntPtr = virtualAllocFunction(process.Handle, bufferAddress, (uint)bufferSize); if (uIntPtr == UIntPtr.Zero) { throw new Exception($"Failed to allocate MemoryBuffer of size {bufferSize} at address {bufferAddress}. Last Win32 Error: {Marshal.GetLastWin32Error()}"); } } internal static IMemory GetMemorySource(Process process) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (process.Id == Process.GetCurrentProcess().Id) { return (IMemory)new Memory(); } return (IMemory)new ExternalMemory(process); } internal static bool IsBuffer(Process process, nuint bufferMagicAddress) { try { MemoryBufferMagic other = default(MemoryBufferMagic); MemoryExtensions.SafeRead<IMemory, MemoryBufferMagic>(GetMemorySource(process), (UIntPtr)bufferMagicAddress, ref other); if (_bufferMagic.MagicEquals(ref other)) { return true; } } catch { } return false; } } internal class MemoryBufferSearcher { private ConcurrentDictionary<nuint, MemoryBuffer> _bufferCache = new ConcurrentDictionary<UIntPtr, MemoryBuffer>(); private Process _process; internal MemoryBufferSearcher(Process targetProcess) { _process = targetProcess; } internal void AddBuffer(MemoryBuffer buffer) { _bufferCache[buffer.AllocationAddress] = buffer; } internal MemoryBuffer[] FindBuffers() { List<Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION> pages = MemoryPages.GetPages(_process); List<MemoryBuffer> list = new List<MemoryBuffer>(); for (int i = 0; i < pages.Count; i++) { if (pages[i].State == 4096 && pages[i].Type == 131072 && pages[i].Protect == 64 && MemoryBufferFactory.IsBuffer(_process, pages[i].BaseAddress)) { nuint baseAddress = pages[i].BaseAddress; MemoryBuffer memoryBuffer = MemoryBufferFactory.FromAddress(_process, baseAddress); AddBuffer(memoryBuffer); list.Add(memoryBuffer); } } return list.ToArray(); } internal MemoryBuffer[] GetBuffers(int size, bool useCache = true) { if (useCache) { MemoryBuffer[] array = _bufferCache.Values.Where((MemoryBuffer x) => x.CanItemFit(size)).ToArray(); if (array.Length != 0) { return array; } } MemoryBuffer[] source = FindBuffers(); if (useCache) { return _bufferCache.Values.Where((MemoryBuffer x) => x.CanItemFit(size)).ToArray(); } return source.Where((MemoryBuffer x) => x.CanItemFit(size)).ToArray(); } } } namespace Reloaded.Memory.Buffers.Internal.Utilities { internal static class Mathematics { internal static int RoundUp(int number, int multiple) { if (multiple == 0) { return number; } int num = number % multiple; if (num == 0) { return number; } return number + multiple - num; } internal static long RoundUp(long number, long multiple) { if (multiple == 0) { return number; } long num = number % multiple; if (num == 0) { return number; } return number + multiple - num; } internal static ulong RoundUp(ulong number, ulong multiple) { if (multiple == 0) { return number; } ulong num = number % multiple; if (num == 0) { return number; } return number + multiple - num; } internal static nuint RoundUp(nuint number, nuint multiple) { if (multiple == 0) { return number; } nuint num = number % multiple; if (num == 0) { return number; } return number + multiple - num; } internal static long RoundDown(long number, long multiple) { if (multiple == 0) { return number; } long num = number % multiple; if (num == 0) { return number; } return number - num; } internal static nuint RoundDown(nuint number, nuint multiple) { if (multiple == 0) { return number; } nuint num = number % multiple; if (num == 0) { return number; } return number - num; } } internal static class MutexObtainer { internal static Mutex MakeMutex(string mutexName) { try { return Mutex.OpenExisting(mutexName); } catch (WaitHandleCannotBeOpenedException) { return new Mutex(initiallyOwned: false, mutexName); } } } public static class VirtualAllocUtility { public delegate UIntPtr VirtualAllocFunction(IntPtr processHandle, nuint address, ulong size); public static VirtualAllocFunction GetVirtualAllocFunction(Process targetProcess) { VirtualAllocFunction result = VirtualAllocRemote; if (Process.GetCurrentProcess().Id == targetProcess.Id) { result = VirtualAllocLocal; } return result; } private static UIntPtr VirtualAllocLocal(IntPtr processHandle, nuint address, ulong size) { return Kernel32.VirtualAlloc((UIntPtr)address, (UIntPtr)size, (MEM_ALLOCATION_TYPE)12288, (MEM_PROTECTION)64); } private static UIntPtr VirtualAllocRemote(IntPtr processHandle, nuint address, ulong size) { return Kernel32.VirtualAllocEx(processHandle, (UIntPtr)address, (UIntPtr)size, (MEM_ALLOCATION_TYPE)12288, (MEM_PROTECTION)64); } } public static class VirtualFreeUtility { public delegate void VirtualFreeFunction(IntPtr processHandle, nuint address); public static VirtualFreeFunction GetVirtualFreeFunction(Process targetProcess) { VirtualFreeFunction result = VirtualFreeRemote; if (Process.GetCurrentProcess().Id == targetProcess.Id) { result = VirtualFreeLocal; } return result; } private static void VirtualFreeLocal(IntPtr processHandle, nuint address) { Kernel32.VirtualFree((UIntPtr)address, (UIntPtr)0uL, (MEM_ALLOCATION_TYPE)32768); } private static void VirtualFreeRemote(IntPtr processHandle, nuint address) { Kernel32.VirtualFreeEx(processHandle, (UIntPtr)address, (UIntPtr)0uL, (MEM_ALLOCATION_TYPE)32768); } } public static class VirtualQueryUtility { public delegate UIntPtr VirtualQueryFunction(IntPtr processHandle, nuint address, ref Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION memoryInformation); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] private static extern UIntPtr VirtualQueryEx(IntPtr hProcess, nuint lpAddress, ref Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength); [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] private static extern UIntPtr VirtualQuery(nuint lpAddress, ref Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength); public static VirtualQueryFunction GetVirtualQueryFunction(Process targetProcess) { VirtualQueryFunction result = VirtualQueryRemote; if (Process.GetCurrentProcess().Id == targetProcess.Id) { result = VirtualQueryLocal; } return result; } private unsafe static nuint VirtualQueryLocal(IntPtr processHandle, nuint address, ref Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION memoryInformation) { return VirtualQuery(address, ref memoryInformation, (UIntPtr)(ulong)sizeof(Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION)); } private unsafe static nuint VirtualQueryRemote(IntPtr processHandle, nuint address, ref Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION memoryInformation) { return VirtualQueryEx(processHandle, address, ref memoryInformation, (UIntPtr)(ulong)sizeof(Reloaded.Memory.Buffers.Internal.Kernel32.Kernel32.MEMORY_BASIC_INFORMATION)); } } } namespace Reloaded.Memory.Buffers.Internal.Testing { public static class Buffers { public static bool FreeBuffer(MemoryBuffer buffer) { return buffer.MemorySource.Free((UIntPtr)buffer.AllocationAddress); } } } namespace Reloaded.Memory.Buffers.Internal.Structs { internal struct AddressRange { public nuint StartPointer; public nuint EndPointer; public AddressRange(nuint startPointer, nuint endPointer) { StartPointer = startPointer; EndPointer = endPointer; } public bool Contains(ref AddressRange otherRange) { if (otherRange.StartPointer >= StartPointer && otherRange.EndPointer <= EndPointer) { return true; } return false; } public bool Overlaps(ref AddressRange otherRange) { if (PointInRange(ref otherRange, StartPointer)) { return true; } if (PointInRange(ref otherRange, EndPointer)) { return true; } if (PointInRange(ref this, otherRange.StartPointer)) { return true; } if (PointInRange(ref this, otherRange.EndPointer)) { return true; } return false; } private bool PointInRange(ref AddressRange range, nuint point) { if (point >= range.StartPointer && point <= range.EndPointer) { return true; } return false; } } public struct BufferAllocationProperties { public nuint MemoryAddress; public int Size; public BufferAllocationProperties(nuint memoryAddress, int size) { MemoryAddress = memoryAddress; Size = size; } } public struct MemoryBufferMagic { public const int InitialSeed = 1; public const int MagicCount = 16; public unsafe fixed int ReloadedIdentifier[16]; public MemoryBufferMagic(bool initialize) { if (initialize) { PseudoGenerate(); } } public unsafe bool MagicEquals(ref MemoryBufferMagic other) { fixed (int* pointer = ReloadedIdentifier) { fixed (int* pointer2 = other.ReloadedIdentifier) { Span<int> span = new Span<int>(pointer, 16); Span<int> span2 = new Span<int>(pointer2, 16); for (int i = 0; i < 16; i++) { if (span[i] != span2[i]) { return false; } } return true; } } } private unsafe void PseudoGenerate() { int num = 1; for (int i = 0; i < 16; i++) { ReloadedIdentifier[i] = num; num = (num + 13) * 31; } } } } namespace Reloaded.Memory.Buffers.Internal.Kernel32 { public class Kernel32 { [StructLayout(LayoutKind.Sequential, Pack = 2)] public struct SYSTEM_INFO { public ProcessorArchitecture wProcessorArchitecture; public ushort wReserved; public uint dwPageSize; public nuint lpMinimumApplicationAddress; public nuint lpMaximumApplicationAddress; public UIntPtr dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public ushort wProcessorLevel; public ushort wProcessorRevision; } public struct MEMORY_BASIC_INFORMATION { public nuint BaseAddress; public nuint AllocationBase; public uint AllocationProtect; public nuint RegionSize; public uint State; public uint Protect; public uint Type; } public enum ProcessorArchitecture : ushort { PROCESSOR_ARCHITECTURE_INTEL = 0, PROCESSOR_ARCHITECTURE_MIPS = 1, PROCESSOR_ARCHITECTURE_ALPHA = 2, PROCESSOR_ARCHITECTURE_PPC = 3, PROCESSOR_ARCHITECTURE_SHX = 4, PROCESSOR_ARCHITECTURE_ARM = 5, PROCESSOR_ARCHITECTURE_IA64 = 6, PROCESSOR_ARCHITECTURE_ALPHA64 = 7, PROCESSOR_ARCHITECTURE_MSIL = 8, PROCESSOR_ARCHITECTURE_AMD64 = 9, PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 = 10, PROCESSOR_ARCHITECTURE_NEUTRAL = 11, PROCESSOR_ARCHITECTURE_ARM64 = 12, PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64 = 13, PROCESSOR_ARCHITECTURE_UNKNOWN = ushort.MaxValue } [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWow64Process([In] IntPtr hProcess, [MarshalAs(UnmanagedType.Bool)] out bool Wow64Process); [DllImport("kernel32.dll")] [SuppressUnmanagedCodeSecurity] public static extern void GetSystemInfo(out SYSTEM_INFO lpSystemInfo); } }
BepInEx/plugins/DearImGuiInjection/Reloaded.Hooks.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Iced.Intel; using Microsoft.CodeAnalysis; using Reloaded.Assembler; using Reloaded.Hooks.Definitions; using Reloaded.Hooks.Definitions.Enums; using Reloaded.Hooks.Definitions.Helpers; using Reloaded.Hooks.Definitions.Internal; using Reloaded.Hooks.Definitions.Structs; using Reloaded.Hooks.Definitions.X64; using Reloaded.Hooks.Definitions.X86; using Reloaded.Hooks.Internal; using Reloaded.Hooks.Tools; using Reloaded.Hooks.X64; using Reloaded.Hooks.X86; using Reloaded.Memory.Buffers; using Reloaded.Memory.Sources; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Sewer56")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Advanced native function hooks for x86, x64. Welcome to the next level!")] [assembly: AssemblyFileVersion("4.3.0.0")] [assembly: AssemblyInformationalVersion("4.3.0")] [assembly: AssemblyProduct("Reloaded.Hooks")] [assembly: AssemblyTitle("Reloaded.Hooks")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Reloaded-Project/Reloaded.Hooks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public static class VirtualFunctionTableHelpers { public static List<TableEntry> GetAddresses(nuint tablePointer, int numberOfMethods) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) List<TableEntry> list = new List<TableEntry>(); IntPtr functionPointer = default(IntPtr); for (int i = 0; i < numberOfMethods; i++) { nuint num = tablePointer + (nuint)(IntPtr.Size * i); MemoryExtensions.SafeRead<Memory, IntPtr>(Memory.CurrentProcess, (UIntPtr)num, ref functionPointer); list.Add(new TableEntry { EntryAddress = AddressExtensions.ToSigned((UIntPtr)num), FunctionPointer = functionPointer }); } return list; } } namespace Reloaded.Hooks { public class AsmHook : IAsmHook { private static Memory _memory = Memory.CurrentProcess; private Patch _activateHookPatch; private Patch _disableHookPatch; private Patch _enableHookPatch; private bool _activated; private readonly bool _is64Bit; private List<Patch>? _otherHookPatches; public bool IsEnabled { get; private set; } private unsafe AsmHook() { _is64Bit = sizeof(UIntPtr) == 8; } public AsmHook(string[] asmCode, nuint functionAddress, AsmHookBehaviour behaviour = 0, int hookLength = -1) : this(Utilities.Assembler.Assemble((IEnumerable<string>)asmCode, (ushort)100), functionAddress, new AsmHookOptions { Behaviour = behaviour, hookLength = hookLength }) { }//IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown public AsmHook(string asmCode, nuint functionAddress, AsmHookBehaviour behaviour = 0, int hookLength = -1) : this(Utilities.Assembler.Assemble(asmCode, (ushort)100), functionAddress, new AsmHookOptions { Behaviour = behaviour, hookLength = hookLength }) { }//IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown public AsmHook(byte[] asmCode, nuint functionAddress, AsmHookBehaviour behaviour = 0, int hookLength = -1) : this(asmCode, functionAddress, new AsmHookOptions { Behaviour = behaviour, hookLength = hookLength }) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown public AsmHook(string[] asmCode, nuint functionAddress, AsmHookOptions options = null) : this(Utilities.Assembler.Assemble((IEnumerable<string>)asmCode, (ushort)100), functionAddress, options) { } public AsmHook(string asmCode, nuint functionAddress, AsmHookOptions options = null) : this(Utilities.Assembler.Assemble(asmCode, (ushort)100), functionAddress, options) { } public AsmHook(byte[] asmCode, nuint functionAddress, AsmHookOptions options = null) : this() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown AsmHook asmHook = this; if (options == null) { options = new AsmHookOptions(); } if (options.hookLength == -1) { options.hookLength = Utilities.GetHookLength(functionAddress, options.MaxOpcodeSize, _is64Bit); } byte[] originalFunction = default(byte[]); MemoryExtensions.SafeReadRaw<Memory>(Memory.CurrentProcess, (UIntPtr)functionAddress, ref originalFunction, options.hookLength); nuint jumpBackAddress = functionAddress + (nuint)options.hookLength; int num = (originalFunction.Length / 2 + 1) * 4; int codeAlignment = 16; int num2 = 3; int num3 = codeAlignment * num2; int num4 = (_is64Bit ? 8 : 4); int num5 = num4 * 2; int num6 = asmCode.Length + options.hookLength + 8; int num7 = options.hookLength + 8 + num4; int num8 = 8 + num6 + num7 + num3 + num5 + num; (UIntPtr, UIntPtr) relativeJumpMinMax = Utilities.GetRelativeJumpMinMax(functionAddress, int.MaxValue - num8); MemoryBuffer buffer = Utilities.FindOrCreateBufferInRange(num8, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2); buffer.ExecuteWithLock<bool>((Func<bool>)delegate { try { return asmHook.MakeAsmHook(asmCode, functionAddress, options, originalFunction, buffer, codeAlignment, jumpBackAddress); } catch (Exception) { FunctionPatch functionPatch = new FunctionPatcher(asmHook._is64Bit).Patch(originalFunction.ToList(), functionAddress); originalFunction = functionPatch.NewFunction.ToArray(); asmHook._otherHookPatches = functionPatch.Patches; return asmHook.MakeAsmHook(asmCode, functionAddress, options, originalFunction, buffer, codeAlignment, jumpBackAddress); } }); } private bool MakeAsmHook(byte[] asmCode, nuint functionAddress, AsmHookOptions options, byte[] originalFunction, MemoryBuffer buffer, int codeAlignment, nuint jumpBackAddress) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) IcedPatcher patcher = new IcedPatcher(_is64Bit, originalFunction, functionAddress); buffer.SetAlignment(codeAlignment); nuint targetAddress = MakeHookStub(buffer, patcher, asmCode, originalFunction.Length, jumpBackAddress, options.Behaviour); buffer.SetAlignment(codeAlignment); nuint targetAddress2 = MakeOriginalStub(buffer, patcher, originalFunction.Length, jumpBackAddress); buffer.SetAlignment(codeAlignment); MemoryBufferProperties properties = buffer.Properties; UIntPtr writePointer = ((MemoryBufferProperties)(ref properties)).WritePointer; byte[] bytes = Utilities.AssembleRelativeJump(writePointer, targetAddress2, _is64Bit); byte[] array = Utilities.AssembleRelativeJump(writePointer, targetAddress, _is64Bit); nuint num = buffer.Add(array, codeAlignment); _disableHookPatch = new Patch(num, bytes); _enableHookPatch = new Patch(num, array); List<byte> list = (options.PreferRelativeJump ? Utilities.AssembleRelativeJump(functionAddress, num, _is64Bit).ToList() : Utilities.AssembleAbsoluteJump(num, _is64Bit).ToList()); Utilities.FillArrayUntilSize<byte>(list, 144, options.hookLength); _activateHookPatch = new Patch(functionAddress, list.ToArray()); return true; } private nuint MakeHookStub(MemoryBuffer buffer, IcedPatcher patcher, byte[] asmCode, int originalCodeLength, nuint jumpBackAddress, AsmHookBehaviour behaviour) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected I4, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) List<byte> list = new List<byte>(asmCode.Length + originalCodeLength); MemoryBufferProperties properties; switch ((int)behaviour) { case 0: list.AddRange(asmCode); properties = buffer.Properties; list.AddRange(patcher.EncodeForNewAddress((nuint)((nint)(nuint)((MemoryBufferProperties)(ref properties)).WritePointer + list.Count))); break; case 1: properties = buffer.Properties; list.AddRange(patcher.EncodeForNewAddress((nuint)((nint)(nuint)((MemoryBufferProperties)(ref properties)).WritePointer + list.Count))); list.AddRange(asmCode); break; case 2: list.AddRange(asmCode); break; default: throw new ArgumentOutOfRangeException("behaviour", behaviour, null); } properties = buffer.Properties; byte[] collection = Utilities.AssembleRelativeJump((nuint)((nint)(nuint)((MemoryBufferProperties)(ref properties)).WritePointer + list.Count), jumpBackAddress, _is64Bit); list.AddRange(collection); return buffer.Add(list.ToArray(), 1); } private nuint MakeOriginalStub(MemoryBuffer buffer, IcedPatcher patcher, int originalCodeLength, nuint jumpBackAddress) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) List<byte> list = new List<byte>(originalCodeLength); MemoryBufferProperties properties = buffer.Properties; list.AddRange(patcher.EncodeForNewAddress(((MemoryBufferProperties)(ref properties)).WritePointer)); properties = buffer.Properties; byte[] collection = Utilities.AssembleRelativeJump((nuint)((nint)(nuint)((MemoryBufferProperties)(ref properties)).WritePointer + list.Count), jumpBackAddress, _is64Bit); list.AddRange(collection); return buffer.Add(list.ToArray(), 1); } public IAsmHook Activate() { if (_activated) { return (IAsmHook)(object)this; } _activated = true; _activateHookPatch.Apply(); _enableHookPatch.ApplyUnsafe(); if (_otherHookPatches == null) { return (IAsmHook)(object)this; } foreach (Patch otherHookPatch in _otherHookPatches) { otherHookPatch.Apply(); } return (IAsmHook)(object)this; } public void Enable() { _enableHookPatch.ApplyUnsafe(); IsEnabled = true; } public void Disable() { _disableHookPatch.ApplyUnsafe(); IsEnabled = false; } } internal class Constants { internal const int MaxAbsJmpSize = 8; } public class Function<TFunction> : IFunction<TFunction> { private bool _wrapperCreated; private TFunction _wrapper; private nuint _wrapperAddress; private nuint _address; public long Address => (long)AddressExtensions.ToSigned((UIntPtr)_address); public IReloadedHooks Hooks { get; private set; } public Function(nuint address, IReloadedHooks hooks) { _address = address; Hooks = hooks; } public IHook<TFunction> Hook(TFunction function, int minHookLength) { return Hooks.CreateHook<TFunction>(function, Address, minHookLength); } public IHook<TFunction> Hook(TFunction function) { return Hook(function, -1); } public unsafe IHook<TFunction> Hook(void* function, int minHookLength) { return Hooks.CreateHook<TFunction>(function, Address, minHookLength); } public unsafe IHook<TFunction> Hook(void* function) { return Hook(function, -1); } public IHook<TFunction> Hook(Type type, string methodName, int minHookLength) { return Hooks.CreateHook<TFunction>(type, methodName, Address, minHookLength); } public IHook<TFunction> Hook(Type type, string methodName) { return Hook(type, methodName, -1); } public unsafe IHook<TFunctionType> HookAs<TFunctionType>(void* function, int minHookLength) { return Hooks.CreateHook<TFunctionType>(function, Address, minHookLength); } public unsafe IHook<TFunctionType> HookAs<TFunctionType>(void* function) { return HookAs<TFunctionType>(function, -1); } public IHook<TFunctionType> HookAs<TFunctionType>(Type type, string methodName, int minHookLength) { return Hooks.CreateHook<TFunctionType>(type, methodName, Address, minHookLength); } public IHook<TFunctionType> HookAs<TFunctionType>(Type type, string methodName) { return HookAs<TFunctionType>(type, methodName, -1); } public TFunction GetWrapper() { if (!_wrapperCreated) { IntPtr intPtr = default(IntPtr); _wrapper = Hooks.CreateWrapper<TFunction>(Address, ref intPtr); _wrapperAddress = AddressExtensions.ToUnsigned(intPtr); _wrapperCreated = true; } return _wrapper; } public TFunction GetWrapper(out IntPtr wrapperAddress) { if (!_wrapperCreated) { IntPtr intPtr = default(IntPtr); _wrapper = Hooks.CreateWrapper<TFunction>(Address, ref intPtr); _wrapperAddress = AddressExtensions.ToUnsigned(intPtr); _wrapperCreated = true; } wrapperAddress = AddressExtensions.ToSigned((UIntPtr)_wrapperAddress); return _wrapper; } public IAsmHook MakeAsmHook(string[] asmCode, AsmHookBehaviour behaviour = 0, int hookLength = -1) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return Hooks.CreateAsmHook(asmCode, Address, behaviour, hookLength); } public IAsmHook MakeAsmHook(byte[] asmCode, AsmHookBehaviour behaviour = 0, int hookLength = -1) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return Hooks.CreateAsmHook(asmCode, Address, behaviour, hookLength); } } public class Hook<TFunction> : IHook<TFunction>, IHook { private Patch _hookPatch; private List<Patch> _otherHookPatches; private Patch _disableHookPatch; private Patch _enableHookPatch; private bool _is64Bit; public bool IsHookEnabled { get; private set; } public bool IsHookActivated { get; private set; } public TFunction OriginalFunction { get; private set; } public IntPtr OriginalFunctionAddress { get; private set; } public IntPtr OriginalFunctionWrapperAddress { get; private set; } public IReverseWrapper<TFunction> ReverseWrapper { get; private set; } public unsafe Hook(TFunction function, nuint functionAddress, int minHookLength = -1, FunctionHookOptions options = null) { _is64Bit = sizeof(IntPtr) == 8; ReverseWrapper = CreateReverseWrapper(function); CreateHook(functionAddress, minHookLength, options); } public unsafe Hook(void* targetAddress, nuint functionAddress, int minHookLength = -1, FunctionHookOptions options = null) { _is64Bit = sizeof(IntPtr) == 8; ReverseWrapper = CreateReverseWrapper(targetAddress); CreateHook(functionAddress, minHookLength, options); } private void CreateHook(nuint functionAddress, int minHookLength = -1, FunctionHookOptions options = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown if (options == null) { Misc.TryGetAttribute<TFunction, FunctionHookOptions>(ref options); if (options == null) { options = new FunctionHookOptions(); } } bool isRelative; List<byte> list = (options.PreferRelativeJump ? Utilities.TryAssembleRelativeJump(functionAddress, AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer), _is64Bit, out isRelative) : Utilities.AssembleAbsoluteJump(AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer), _is64Bit).ToList()); if (minHookLength == -1) { minHookLength = Utilities.GetHookLength(functionAddress, list.Count, _is64Bit); } Utilities.FillArrayUntilSize<byte>(list, 144, minHookLength); byte[] source = default(byte[]); MemoryExtensions.SafeReadRaw<Memory>(Memory.CurrentProcess, (UIntPtr)functionAddress, ref source, minHookLength); FunctionPatch functionPatch = new FunctionPatcher(_is64Bit, options).Patch(source.ToList(), functionAddress); nuint value = functionAddress + (nuint)minHookLength; IcedPatcher icedPatcher = new IcedPatcher(_is64Bit, functionPatch.NewFunction.ToArray(), functionAddress); OriginalFunctionAddress = AddressExtensions.ToSigned((UIntPtr)icedPatcher.ToMemoryBuffer(new UIntPtr?(value))); OriginalFunction = CreateWrapper(icedPatcher.ToMemoryBuffer(null), out UIntPtr wrapperAddress); OriginalFunctionWrapperAddress = AddressExtensions.ToSigned(wrapperAddress); _otherHookPatches = functionPatch.Patches; _hookPatch = new Patch(functionAddress, list.ToArray()); } public IHook<TFunction> Activate() { byte[] array = Utilities.AssembleAbsoluteJump(AddressExtensions.ToUnsigned(OriginalFunctionAddress), _is64Bit); byte[] bytes = default(byte[]); MemoryExtensions.SafeReadRaw<Memory>(Memory.CurrentProcess, AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer), ref bytes, array.Length); _disableHookPatch = new Patch(AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer), array); _enableHookPatch = new Patch(AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer), bytes); _hookPatch.Apply(); foreach (Patch otherHookPatch in _otherHookPatches) { otherHookPatch.Apply(); } IsHookEnabled = true; IsHookActivated = true; return this; } IHook IHook.Activate() { return (IHook)(object)Activate(); } public void Disable() { if (IsHookActivated) { _disableHookPatch.ApplyUnsafe(); IsHookEnabled = false; } } public void Enable() { if (IsHookActivated) { _enableHookPatch.ApplyUnsafe(); IsHookEnabled = true; } } protected IReverseWrapper<TFunction> CreateReverseWrapper(TFunction function) { if (_is64Bit) { return new Reloaded.Hooks.X64.ReverseWrapper<TFunction>(function); } return new Reloaded.Hooks.X86.ReverseWrapper<TFunction>(function); } protected unsafe IReverseWrapper<TFunction> CreateReverseWrapper(void* function) { if (_is64Bit) { return new Reloaded.Hooks.X64.ReverseWrapper<TFunction>((nuint)function); } return new Reloaded.Hooks.X86.ReverseWrapper<TFunction>((nuint)function); } protected TFunction CreateWrapper(nuint functionAddress, out nuint wrapperAddress) { if (_is64Bit) { return Reloaded.Hooks.X64.Wrapper.Create<TFunction>(functionAddress, out wrapperAddress); } return Reloaded.Hooks.X86.Wrapper.Create<TFunction>(functionAddress, out wrapperAddress); } } [ExcludeFromCodeCoverage] public class HookException : Exception { public HookException() { } public HookException(string message) : base(message) { } public HookException(string message, Exception innerException) : base(message, innerException) { } protected HookException(SerializationInfo info, StreamingContext context) : base(info, context) { } } public class ReloadedHooks : IReloadedHooks { public static ReloadedHooks Instance { get; } = new ReloadedHooks(); public IReloadedHooksUtilities Utilities { get; } = (IReloadedHooksUtilities)(object)ReloadedHooksUtilities.Instance; public IFunction<TFunction> CreateFunction<TFunction>(long address) { return new Function<TFunction>((nuint)AddressExtensions.ToUnsigned(address), (IReloadedHooks)(object)this); } public IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress) { return CreateHook(function, functionAddress, -1); } public unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress) { return CreateHook<TFunction>(targetAddress, functionAddress, -1); } public IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress, int minHookLength) { return new Hook<TFunction>(function, (nuint)AddressExtensions.ToUnsigned(functionAddress), minHookLength); } public unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress, int minHookLength) { return new Hook<TFunction>(targetAddress, (nuint)AddressExtensions.ToUnsigned(functionAddress), minHookLength); } public IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress, int minHookLength, FunctionHookOptions options) { return new Hook<TFunction>(function, (nuint)AddressExtensions.ToUnsigned(functionAddress), minHookLength, options); } public unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress, int minHookLength, FunctionHookOptions options) { return new Hook<TFunction>(targetAddress, (nuint)AddressExtensions.ToUnsigned(functionAddress), minHookLength, options); } public unsafe IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress, int minHookLength) { return CreateHook<TFunction>(Instance.Utilities.GetFunctionPointer(type, methodName), functionAddress, minHookLength); } public IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress) { return CreateHook<TFunction>(type, methodName, functionAddress, -1); } public unsafe IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress, int minHookLength, FunctionHookOptions options) { return CreateHook<TFunction>(Instance.Utilities.GetFunctionPointer(type, methodName), functionAddress, minHookLength, options); } public IntPtr CreateNativeWrapperX86<TFunction>(IntPtr functionAddress, IFunctionAttribute fromConvention) { return AddressExtensions.ToSigned((UIntPtr)Reloaded.Hooks.X86.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(functionAddress), fromConvention, FunctionAttribute.GetAttribute<TFunction>().GetEquivalent(Misc.TryGetAttributeOrDefault<TFunction, UnmanagedFunctionPointerAttribute>()))); } public IntPtr CreateNativeWrapperX86<TFunction>(IntPtr functionAddress, IFunctionAttribute fromConvention, IFunctionAttribute toConvention) { return AddressExtensions.ToSigned((UIntPtr)Reloaded.Hooks.X86.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(functionAddress), fromConvention, toConvention)); } public IntPtr CreateNativeWrapperX64<TFunction>(IntPtr functionAddress, IFunctionAttribute fromConvention, IFunctionAttribute toConvention) { return AddressExtensions.ToSigned((UIntPtr)Reloaded.Hooks.X64.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(functionAddress), fromConvention, toConvention)); } public unsafe IntPtr CreateWrapper<TFunction>(long functionAddress) { UIntPtr wrapperAddress; if (sizeof(IntPtr) == 4) { return AddressExtensions.ToSigned((UIntPtr)Reloaded.Hooks.X86.Wrapper.CreatePointer<TFunction>((nuint)AddressExtensions.ToUnsigned(functionAddress), out wrapperAddress)); } return AddressExtensions.ToSigned((UIntPtr)Reloaded.Hooks.X64.Wrapper.CreatePointer<TFunction>((nuint)AddressExtensions.ToUnsigned(functionAddress), out wrapperAddress)); } public unsafe TFunction CreateWrapper<TFunction>(long functionAddress, out IntPtr wrapperAddress) { UIntPtr wrapperAddress2; if (sizeof(IntPtr) == 4) { TFunction result = Reloaded.Hooks.X86.Wrapper.Create<TFunction>((nuint)AddressExtensions.ToUnsigned(functionAddress), out wrapperAddress2); wrapperAddress = AddressExtensions.ToSigned(wrapperAddress2); return result; } TFunction result2 = Reloaded.Hooks.X64.Wrapper.Create<TFunction>((nuint)AddressExtensions.ToUnsigned(functionAddress), out wrapperAddress2); wrapperAddress = AddressExtensions.ToSigned(wrapperAddress2); return result2; } public unsafe IReverseWrapper<TFunction> CreateReverseWrapper<TFunction>(TFunction function) { if (sizeof(IntPtr) == 4) { return new Reloaded.Hooks.X86.ReverseWrapper<TFunction>(function); } return new Reloaded.Hooks.X64.ReverseWrapper<TFunction>(function); } public unsafe IReverseWrapper<TFunction> CreateReverseWrapper<TFunction>(IntPtr function) { if (sizeof(IntPtr) == 4) { return new Reloaded.Hooks.X86.ReverseWrapper<TFunction>(AddressExtensions.ToUnsigned(function)); } return new Reloaded.Hooks.X64.ReverseWrapper<TFunction>(AddressExtensions.ToUnsigned(function)); } public IVirtualFunctionTable HookedVirtualFunctionTableFromObject(IntPtr objectAddress, int numberOfMethods) { return (IVirtualFunctionTable)(object)HookedObjectVirtualFunctionTable.FromObject(AddressExtensions.ToUnsigned(objectAddress), numberOfMethods); } public IVirtualFunctionTable VirtualFunctionTableFromObject(IntPtr objectAddress, int numberOfMethods) { return (IVirtualFunctionTable)(object)VirtualFunctionTable.FromObject(AddressExtensions.ToUnsigned(objectAddress), numberOfMethods); } public IVirtualFunctionTable VirtualFunctionTableFromAddress(IntPtr tableAddress, int numberOfMethods) { return (IVirtualFunctionTable)(object)VirtualFunctionTable.FromAddress(AddressExtensions.ToUnsigned(tableAddress), numberOfMethods); } public IFunctionPtr<TDelegate> CreateFunctionPtr<TDelegate>(ulong functionPointer) where TDelegate : Delegate { return new FunctionPtr<TDelegate>(functionPointer); } public IAsmHook CreateAsmHook(string[] asmCode, long functionAddress) { return CreateAsmHook(asmCode, functionAddress, (AsmHookBehaviour)0, -1); } public IAsmHook CreateAsmHook(string asmCode, long functionAddress) { return CreateAsmHook(asmCode, functionAddress, (AsmHookBehaviour)0, -1); } public IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress) { return CreateAsmHook(asmCode, functionAddress, (AsmHookBehaviour)0, -1); } public IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookBehaviour behaviour) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return CreateAsmHook(asmCode, functionAddress, behaviour, -1); } public IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookBehaviour behaviour) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return CreateAsmHook(asmCode, functionAddress, behaviour, -1); } public IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookBehaviour behaviour) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return CreateAsmHook(asmCode, functionAddress, behaviour, -1); } public IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), behaviour, hookLength); } public IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), behaviour, hookLength); } public IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), behaviour, hookLength); } public IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookOptions options) { return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), options); } public IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookOptions options) { return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), options); } public IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookOptions options) { return (IAsmHook)(object)new AsmHook(asmCode, (nuint)AddressExtensions.ToUnsigned(functionAddress), options); } } public class ReloadedHooksUtilities : IReloadedHooksUtilities { public static ReloadedHooksUtilities Instance { get; } = new ReloadedHooksUtilities(); public byte[] AssembleAbsoluteJump(IntPtr target, bool is64bit) { return Utilities.AssembleAbsoluteJump(AddressExtensions.ToUnsigned(target), is64bit); } public byte[] AssemblePushReturn(IntPtr target, bool is64bit) { return Utilities.AssemblePushReturn(AddressExtensions.ToUnsigned(target), is64bit); } public byte[] AssembleRelativeJump(IntPtr relativeJumpOffset, bool is64bit) { return Utilities.AssembleRelativeJump(relativeJumpOffset, is64bit); } public byte[] AssembleRelativeJump(IntPtr currentAddress, IntPtr targetAddress, bool is64bit) { return Utilities.AssembleRelativeJump(AddressExtensions.ToUnsigned(currentAddress), AddressExtensions.ToUnsigned(targetAddress), is64bit); } public string GetAbsoluteJumpMnemonics(IntPtr target, bool is64bit) { return Utilities.GetAbsoluteJumpMnemonics(AddressExtensions.ToUnsigned(target), is64bit); } public string GetAbsoluteCallMnemonics(IntPtr target, bool is64bit) { return Utilities.GetAbsoluteCallMnemonics(AddressExtensions.ToUnsigned(target), is64bit); } public string GetAbsoluteJumpMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate { return Utilities.GetAbsoluteJumpMnemonics(function, out reverseWrapper); } public string GetAbsoluteCallMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate { return Utilities.GetAbsoluteCallMnemonics(function, out reverseWrapper); } public string GetPushReturnMnemonics(IntPtr target, bool is64bit) { return Utilities.GetPushReturnMnemonics(AddressExtensions.ToUnsigned(target), is64bit); } public string GetRelativeJumpMnemonics(IntPtr relativeJumpOffset, bool is64bit) { return Utilities.GetRelativeJumpMnemonics(relativeJumpOffset, is64bit); } public IntPtr InsertJump(byte[] opcodes, bool is64bit, long jumpTarget, long targetAddress = 0L, long maxDisplacement = 2147483647L) { return AddressExtensions.ToSigned((UIntPtr)Utilities.InsertJump(opcodes, is64bit, (nuint)AddressExtensions.ToUnsigned(jumpTarget), (nuint)targetAddress, (nint)maxDisplacement)); } public int GetHookLength(IntPtr hookAddress, int hookLength, bool is64Bit) { return Utilities.GetHookLength(AddressExtensions.ToUnsigned(hookAddress), hookLength, is64Bit); } public int GetNumberofParameters(Type delegateType) { return Utilities.GetNumberofParameters(delegateType); } public int GetNumberofParametersWithoutFloats(Type delegateType) { return Utilities.GetNumberofParametersWithoutFloats(delegateType); } public int GetNumberofParameters<TFunction>() { return Utilities.GetNumberofParameters<TFunction>(); } public int GetNumberofParametersWithoutFloats<TFunction>() { return Utilities.GetNumberofParametersWithoutFloats<TFunction>(); } public string PushCdeclCallerSavedRegisters() { return "push eax\npush ecx\npush edx"; } public string PopCdeclCallerSavedRegisters() { return "pop edx\npop ecx\npop eax"; } public IntPtr WritePointer(IntPtr target) { return AddressExtensions.ToSigned((UIntPtr)Utilities.WritePointer(AddressExtensions.ToUnsigned(target))); } public unsafe void* GetFunctionPointer(Type type, string name) { RuntimeMethodHandle methodHandle = type.GetMethod(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).MethodHandle; RuntimeHelpers.PrepareMethod(methodHandle); return (void*)methodHandle.GetFunctionPointer(); } public (long min, long max) GetRelativeJumpMinMax(long targetAddress, long maxDisplacement = 2147483647L) { (UIntPtr, UIntPtr) relativeJumpMinMax = Utilities.GetRelativeJumpMinMax((nuint)AddressExtensions.ToUnsigned(targetAddress), (nint)maxDisplacement); return ((long)AddressExtensions.ToSigned(relativeJumpMinMax.Item1), (long)AddressExtensions.ToSigned(relativeJumpMinMax.Item2)); } } } namespace Reloaded.Hooks.X86 { public class ReverseWrapper<TFunction> : IReverseWrapper<TFunction>, IReverseWrapper { public TFunction CSharpFunction { get; } public IntPtr NativeFunctionPtr { get; } public IntPtr WrapperPointer { get; private set; } public ReverseWrapper(TFunction function) { CSharpFunction = function; if (typeof(TFunction).IsValueType && !typeof(TFunction).IsPrimitive) { NativeFunctionPtr = Unsafe.As<TFunction, IntPtr>(ref function); } else { NativeFunctionPtr = Marshal.GetFunctionPointerForDelegate(function); } WrapperPointer = NativeFunctionPtr; Create(this, AddressExtensions.ToUnsigned(NativeFunctionPtr)); } public ReverseWrapper(nuint function) { NativeFunctionPtr = AddressExtensions.ToSigned((UIntPtr)function); WrapperPointer = NativeFunctionPtr; Create(this, function); } private static void Create(ReverseWrapper<TFunction> reverseFunctionWrapper, nuint functionPtr) { IFunctionAttribute attribute = FunctionAttribute.GetAttribute<TFunction>(); ManagedFunctionAttribute val = Misc.TryGetAttributeOrDefault<TFunction, ManagedFunctionAttribute>(); if (val != null) { if (((object)val).Equals((object?)attribute)) { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Utilities.CreateJump(functionPtr, is64Bit: false, 8)); } else { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Wrapper.Create<TFunction>(functionPtr, (IFunctionAttribute)(object)val, attribute)); } return; } UnmanagedFunctionPointerAttribute unmanagedFunctionPointerAttribute = Misc.TryGetAttributeOrDefault<TFunction, UnmanagedFunctionPointerAttribute>(); if (!attribute.IsEquivalent(unmanagedFunctionPointerAttribute)) { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Wrapper.Create<TFunction>(functionPtr, attribute.GetEquivalent(unmanagedFunctionPointerAttribute), attribute)); } else { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Utilities.CreateJump(functionPtr, is64Bit: false, 8)); } } } public static class Wrapper { public static TFunction Create<TFunction>(nuint functionAddress) { UIntPtr wrapperAddress; return Create<TFunction>(functionAddress, out wrapperAddress); } public static TFunction Create<TFunction>(nuint functionAddress, out nuint wrapperAddress) { CreatePointer<TFunction>(functionAddress, out wrapperAddress); if (typeof(TFunction).IsValueType && !typeof(TFunction).IsPrimitive) { return Unsafe.As<UIntPtr, TFunction>(ref wrapperAddress); } return Marshal.GetDelegateForFunctionPointer<TFunction>(AddressExtensions.ToSigned((UIntPtr)wrapperAddress)); } public static nuint CreatePointer<TFunction>(nuint functionAddress, out nuint wrapperAddress) { IFunctionAttribute attribute = FunctionAttribute.GetAttribute<TFunction>(); wrapperAddress = functionAddress; UnmanagedFunctionPointerAttribute unmanagedFunctionPointerAttribute = Misc.TryGetAttributeOrDefault<TFunction, UnmanagedFunctionPointerAttribute>(); if (!attribute.IsEquivalent(unmanagedFunctionPointerAttribute)) { wrapperAddress = Create<TFunction>(functionAddress, attribute, attribute.GetEquivalent(unmanagedFunctionPointerAttribute)); } return wrapperAddress; } public static nuint Create<TFunction>(nuint functionAddress, IFunctionAttribute fromConvention, IFunctionAttribute toConvention) { (UIntPtr, UIntPtr) relativeJumpMinMax = Utilities.GetRelativeJumpMinMax(functionAddress, 2147483391); MemoryBuffer buffer = Utilities.FindOrCreateBufferInRange(256, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2); int numberOfParameters = Utilities.GetNumberofParameters<TFunction>(); return buffer.ExecuteWithLock<UIntPtr>((Func<UIntPtr>)delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Invalid comparison between Unknown and I4 //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) buffer.SetAlignment(16); MemoryBufferProperties properties = buffer.Properties; UIntPtr writePointer = ((MemoryBufferProperties)(ref properties)).WritePointer; List<string> list = new List<string> { "use32", $"org {writePointer}" }; int num = (((int)fromConvention.Cleanup == 1) ? ((numberOfParameters - fromConvention.SourceRegisters.Length) * 4) : 0); int num2 = (((int)toConvention.Cleanup == 2) ? ((numberOfParameters - toConvention.SourceRegisters.Length) * 4) : 0); int num3 = num + fromConvention.ReservedStackSpace; list.Add("push ebp"); list.Add("mov ebp, esp"); Register[] calleeSavedRegisters = toConvention.CalleeSavedRegisters; foreach (Register val in calleeSavedRegisters) { list.Add($"push {val}"); } if (fromConvention.ReservedStackSpace > 0) { list.Add($"sub esp, {fromConvention.ReservedStackSpace}"); } if (numberOfParameters > 0) { list.AddRange(AssembleFunctionParameters(numberOfParameters, fromConvention.SourceRegisters, toConvention.SourceRegisters)); } list.Add($"call {functionAddress}"); if (num3 > 0) { list.Add($"add esp, {num3}"); } if (fromConvention.ReturnRegister != toConvention.ReturnRegister) { list.Add($"mov {toConvention.ReturnRegister}, {fromConvention.ReturnRegister}"); } foreach (Register item in toConvention.CalleeSavedRegisters.Reverse()) { list.Add($"pop {item}"); } list.Add("pop ebp"); list.Add($"ret {num2}"); return buffer.Add(Utilities.Assembler.Assemble((IEnumerable<string>)list.ToArray(), (ushort)100), 1); }); } private static string[] AssembleFunctionParameters(int parameterCount, Register[] fromRegisters, Register[] toRegisters) { List<string> list = new List<string>(); int num = parameterCount - toRegisters.Length; int num2 = num * 4 + 4; for (int i = 0; i < num; i++) { list.Add($"push dword [ebp + {num2}]"); num2 -= 4; } for (int num3 = Math.Min(toRegisters.Length, parameterCount) - 1; num3 >= 0; num3--) { list.Add($"push {toRegisters[num3]}"); } for (int j = 0; j < fromRegisters.Length && j < parameterCount; j++) { list.Add($"pop {fromRegisters[j]}"); } return list.ToArray(); } } } namespace Reloaded.Hooks.X64 { public class ReverseWrapper<TFunction> : IReverseWrapper<TFunction>, IReverseWrapper { public TFunction CSharpFunction { get; } public IntPtr NativeFunctionPtr { get; } public IntPtr WrapperPointer { get; private set; } public ReverseWrapper(TFunction function) { CSharpFunction = function; if (typeof(TFunction).IsValueType && !typeof(TFunction).IsPrimitive) { NativeFunctionPtr = Unsafe.As<TFunction, IntPtr>(ref function); } else { NativeFunctionPtr = Marshal.GetFunctionPointerForDelegate(function); } WrapperPointer = NativeFunctionPtr; Create(this, AddressExtensions.ToUnsigned(NativeFunctionPtr)); } public ReverseWrapper(nuint function) { NativeFunctionPtr = AddressExtensions.ToSigned((UIntPtr)function); WrapperPointer = NativeFunctionPtr; Create(this, function); } private static void Create(ReverseWrapper<TFunction> reverseFunctionWrapper, nuint functionPtr) { IFunctionAttribute attribute = FunctionAttribute.GetAttribute<TFunction>(); if (!((object)attribute).Equals((object?)FunctionAttribute.Microsoft)) { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Wrapper.Create<TFunction>(functionPtr, (IFunctionAttribute)(object)FunctionAttribute.Microsoft, attribute)); } else { reverseFunctionWrapper.WrapperPointer = AddressExtensions.ToSigned((UIntPtr)Utilities.CreateJump(functionPtr, is64Bit: true, 8)); } } } public static class Wrapper { public static TFunction Create<TFunction>(nuint functionAddress) { UIntPtr wrapperAddress; return Create<TFunction>(functionAddress, out wrapperAddress); } public static TFunction Create<TFunction>(nuint functionAddress, out nuint wrapperAddress) { CreatePointer<TFunction>(functionAddress, out wrapperAddress); if (typeof(TFunction).IsValueType && !typeof(TFunction).IsPrimitive) { return Unsafe.As<UIntPtr, TFunction>(ref wrapperAddress); } return Marshal.GetDelegateForFunctionPointer<TFunction>(AddressExtensions.ToSigned((UIntPtr)wrapperAddress)); } public static nuint CreatePointer<TFunction>(nuint functionAddress, out nuint wrapperAddress) { IFunctionAttribute attribute = FunctionAttribute.GetAttribute<TFunction>(); wrapperAddress = functionAddress; if (!((object)attribute).Equals((object?)FunctionAttribute.Microsoft)) { wrapperAddress = Create<TFunction>(functionAddress, attribute, (IFunctionAttribute)(object)FunctionAttribute.Microsoft); } return wrapperAddress; } public static nuint Create<TFunction>(nuint functionAddress, IFunctionAttribute fromConvention, IFunctionAttribute toConvention) { (UIntPtr, UIntPtr) relativeJumpMinMax = Utilities.GetRelativeJumpMinMax(functionAddress, 2147483263); MemoryBuffer buffer = Utilities.FindOrCreateBufferInRange(384, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2); int numberOfParameters = Utilities.GetNumberofParametersWithoutFloats<TFunction>(); return buffer.ExecuteWithLock<UIntPtr>((Func<UIntPtr>)delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) buffer.SetAlignment(16); MemoryBufferProperties properties = buffer.Properties; UIntPtr writePointer = ((MemoryBufferProperties)(ref properties)).WritePointer; List<string> list = new List<string> { "use64", $"org {writePointer}" }; list.Add("push rbp"); list.Add("mov rbp, rsp"); Register[] calleeSavedRegisters = toConvention.CalleeSavedRegisters; foreach (Register val in calleeSavedRegisters) { list.Add($"push {val}"); } int num = numberOfParameters - fromConvention.SourceRegisters.Length; num = ((num >= 0) ? num : 0); int num2 = num * 8; int num3 = (num2 + 8) % 16; int num4 = (fromConvention.ShadowSpace ? 32 : 0); if (num3 != 0) { list.Add($"sub rsp, {num3}"); } if (numberOfParameters > 0) { list.AddRange(AssembleFunctionParameters(numberOfParameters, ref fromConvention, ref toConvention)); } if (fromConvention.ShadowSpace) { list.Add($"sub rsp, {num4}"); } list.Add($"call {functionAddress}"); if (num2 + num4 + num3 != 0) { list.Add($"add rsp, {num2 + num4 + num3}"); } if (fromConvention.ReturnRegister != toConvention.ReturnRegister) { list.Add($"mov {toConvention.ReturnRegister}, {fromConvention.ReturnRegister}"); } foreach (Register item in toConvention.CalleeSavedRegisters.Reverse()) { list.Add($"pop {item}"); } list.Add("pop rbp"); list.Add("ret"); return buffer.Add(Utilities.Assembler.Assemble((IEnumerable<string>)list.ToArray(), (ushort)100), 1); }); } private static string[] AssembleFunctionParameters(int parameterCount, ref IFunctionAttribute fromConvention, ref IFunctionAttribute toConvention) { List<string> list = new List<string>(); int num = parameterCount - toConvention.SourceRegisters.Length; int num2 = (toConvention.ShadowSpace ? 32 : 0) + 8; num2 += num * 8; for (int i = 0; i < num; i++) { list.Add($"push qword [rbp + {num2}]"); num2 -= 8; } for (int num3 = Math.Min(toConvention.SourceRegisters.Length, parameterCount) - 1; num3 >= 0; num3--) { list.Add($"push {toConvention.SourceRegisters[num3]}"); } for (int j = 0; j < fromConvention.SourceRegisters.Length && j < parameterCount; j++) { list.Add($"pop {fromConvention.SourceRegisters[j]}"); } return list.ToArray(); } } } namespace Reloaded.Hooks.Tools { public class FunctionPtr<TDelegate> : IFunctionPtr<TDelegate> where TDelegate : Delegate { private readonly Dictionary<IntPtr, TDelegate> _methodCache; private TDelegate _delegate; private IntPtr _lastFunctionPointer; public ulong FunctionPointer { get; } public TDelegate this[int index] => GetDelegate(index); public FunctionPtr(ulong functionPointer) { FunctionPointer = functionPointer; _methodCache = new Dictionary<IntPtr, TDelegate>(); } public unsafe IntPtr GetFunctionAddress(int index) { IntPtr* ptr = (IntPtr*)FunctionPointer; return ptr[index]; } public unsafe TDelegate GetDelegate(int index = 0) { IntPtr functionAddress = GetFunctionAddress(index); if (functionAddress == _lastFunctionPointer) { return _delegate; } if (_methodCache.TryGetValue(functionAddress, out var value)) { return value; } if (sizeof(IntPtr) == 4) { _delegate = Reloaded.Hooks.X86.Wrapper.Create<TDelegate>(AddressExtensions.ToUnsigned(functionAddress), out UIntPtr _); } else { _delegate = Reloaded.Hooks.X64.Wrapper.Create<TDelegate>(AddressExtensions.ToUnsigned(functionAddress), out UIntPtr _); } _methodCache[functionAddress] = _delegate; _lastFunctionPointer = functionAddress; return _delegate; } public static implicit operator bool(FunctionPtr<TDelegate> value) { return value.GetFunctionAddress(0) != IntPtr.Zero; } } public class HookedObjectVirtualFunctionTable : IVirtualFunctionTable { internal class VTableEntryHook<TFunction> : IHook<TFunction>, IHook { private readonly HookedObjectVirtualFunctionTable _vTableHook; private readonly int _index; private readonly bool _is64Bit; public TFunction OriginalFunction { get; } public IReverseWrapper<TFunction> ReverseWrapper { get; } public bool IsHookEnabled { get; private set; } public bool IsHookActivated { get; private set; } public IntPtr OriginalFunctionAddress { get; } public IntPtr OriginalFunctionWrapperAddress { get; } internal unsafe VTableEntryHook(HookedObjectVirtualFunctionTable vTableHook, nuint originalVirtualFunctionTableAddress, int index, TFunction function) { nuint num = default(nuint); MemoryExtensions.SafeRead<Memory, UIntPtr>(Memory.CurrentProcess, (UIntPtr)(originalVirtualFunctionTableAddress + (nuint)(index * sizeof(UIntPtr))), ref num); _vTableHook = vTableHook; _index = index; _is64Bit = sizeof(IntPtr) == 8; ReverseWrapper = CreateReverseWrapper(function); OriginalFunction = CreateWrapper(num, out UIntPtr wrapperAddress); OriginalFunctionAddress = AddressExtensions.ToSigned((UIntPtr)num); OriginalFunctionWrapperAddress = AddressExtensions.ToSigned(wrapperAddress); IsHookActivated = false; } protected IReverseWrapper<TFunction> CreateReverseWrapper(TFunction function) { if (_is64Bit) { return new Reloaded.Hooks.X64.ReverseWrapper<TFunction>(function); } return new Reloaded.Hooks.X86.ReverseWrapper<TFunction>(function); } protected TFunction CreateWrapper(nuint functionAddress, out nuint wrapperAddress) { if (_is64Bit) { return Reloaded.Hooks.X64.Wrapper.Create<TFunction>(functionAddress, out wrapperAddress); } return Reloaded.Hooks.X86.Wrapper.Create<TFunction>(functionAddress, out wrapperAddress); } IHook IHook.Activate() { return (IHook)(object)Activate(); } public IHook<TFunction> Activate() { _vTableHook.AddHook((IHook)(object)this); Enable(); IsHookActivated = true; return this; } public void Disable() { _vTableHook.SetHookedVTableEntry(_index, AddressExtensions.ToUnsigned(OriginalFunctionAddress)); IsHookEnabled = false; } public void Enable() { _vTableHook.SetHookedVTableEntry(_index, AddressExtensions.ToUnsigned(ReverseWrapper.WrapperPointer)); IsHookEnabled = true; } } private readonly nuint _originalVirtualFunctionTableAddress; private readonly nuint[] _newVTableForObject; private readonly GCHandle _pinnedNewVTableForObject; private readonly List<IHook> _hooks; public List<TableEntry> TableEntries { get; set; } public IntPtr ObjectAddress { get; private set; } public TableEntry this[int i] { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return TableEntries[i]; } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) TableEntries[i] = value; } } public static HookedObjectVirtualFunctionTable FromObject(nuint objectAddress, int numberOfMethods) { nuint num = default(nuint); MemoryExtensions.SafeRead<Memory, UIntPtr>(Memory.CurrentProcess, (UIntPtr)objectAddress, ref num); List<TableEntry> addresses = VirtualFunctionTableHelpers.GetAddresses(num, numberOfMethods); return new HookedObjectVirtualFunctionTable(objectAddress, num, addresses); } public IHook<TFunction> CreateFunctionHook<TFunction>(int index, TFunction delegateType) { return new VTableEntryHook<TFunction>(this, _originalVirtualFunctionTableAddress, index, delegateType); } public unsafe TFunction CreateWrapperFunction<TFunction>(int index) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) UIntPtr wrapperAddress; if (sizeof(IntPtr) == 4) { return Reloaded.Hooks.X86.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(TableEntries[index].FunctionPointer), out wrapperAddress); } UIntPtr wrapperAddress2; if (sizeof(IntPtr) == 8) { return Reloaded.Hooks.X64.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(TableEntries[index].FunctionPointer), out wrapperAddress2); } throw new Exception("Machine does not appear to be of a 32 or 64bit architecture."); } private HookedObjectVirtualFunctionTable(nuint objectAddress, nuint virtualFunctionTableAddress, List<TableEntry> table) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) ObjectAddress = AddressExtensions.ToSigned((UIntPtr)objectAddress); TableEntries = table; _originalVirtualFunctionTableAddress = virtualFunctionTableAddress; _newVTableForObject = new UIntPtr[table.Count]; _hooks = new List<IHook>(); for (int i = 0; i < table.Count; i++) { _newVTableForObject[i] = AddressExtensions.ToUnsigned(table[i].FunctionPointer); } _pinnedNewVTableForObject = GCHandle.Alloc(_newVTableForObject, GCHandleType.Pinned); MemoryExtensions.SafeWrite<Memory, IntPtr>(Memory.CurrentProcess, (UIntPtr)objectAddress, _pinnedNewVTableForObject.AddrOfPinnedObject(), false); } private void SetHookedVTableEntry(int index, nuint newEntry) { _newVTableForObject[index] = newEntry; } private void AddHook(IHook hook) { _hooks.Add(hook); } } public static class Utilities { private static object _lock; private static MemoryBufferHelper _bufferHelper; public static Assembler Assembler { get; } static Utilities() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown _lock = new object(); Assembler = new Assembler(65536, 32768); _bufferHelper = new MemoryBufferHelper(Process.GetCurrentProcess()); } private static string Architecture(bool is64bit) { if (!is64bit) { return "use32"; } return "use64"; } private static string SetAddress(nuint address) { return $"org {address}"; } public unsafe static nuint WritePointer(nuint target) { return FindOrCreateBufferInRange(sizeof(UIntPtr), 1u, 2147483647u).Add<UIntPtr>(ref target, false, 4); } public static byte[] AssembleAbsoluteJump(nuint target, bool is64bit) { return Assembler.Assemble((IEnumerable<string>)new string[2] { Architecture(is64bit), GetAbsoluteJumpMnemonics(target, is64bit) }, (ushort)100); } public static byte[] AssemblePushReturn(nuint target, bool is64bit) { return Assembler.Assemble((IEnumerable<string>)new string[2] { Architecture(is64bit), GetPushReturnMnemonics(target, is64bit) }, (ushort)100); } public static byte[] AssembleRelativeJump(IntPtr relativeJumpOffset, bool is64bit) { return Assembler.Assemble((IEnumerable<string>)new string[2] { Architecture(is64bit), GetRelativeJumpMnemonics(relativeJumpOffset, is64bit) }, (ushort)100); } public static byte[] AssembleRelativeJump(nuint currentAddress, nuint targetAddress, bool is64bit) { bool isProxied; return AssembleRelativeJump(currentAddress, targetAddress, is64bit, out isProxied); } public static byte[] AssembleRelativeJump(nuint currentAddress, nuint targetAddress, bool is64bit, out bool isProxied) { long value = (long)targetAddress - (long)currentAddress; isProxied = Math.Abs(value) > int.MaxValue; if (!isProxied) { return Assembler.Assemble((IEnumerable<string>)new string[3] { Architecture(is64bit), SetAddress(currentAddress), is64bit ? $"jmp qword {targetAddress}" : $"jmp dword {targetAddress}" }, (ushort)100); } (UIntPtr, UIntPtr) relativeJumpMinMax = GetRelativeJumpMinMax(currentAddress); UIntPtr uIntPtr = FindOrCreateBufferInRange(16, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2).Add(AssembleAbsoluteJump(targetAddress, is64bit), 4); return Assembler.Assemble((IEnumerable<string>)new string[3] { Architecture(is64bit), SetAddress(currentAddress), is64bit ? $"jmp qword {uIntPtr}" : $"jmp dword {uIntPtr}" }, (ushort)100); } public static string GetAbsoluteJumpMnemonics(nuint target, bool is64bit) { UIntPtr uIntPtr = FindOrCreateBufferInRange(IntPtr.Size, 1u, uint.MaxValue).Add<UIntPtr>(ref target, false, 4); if (is64bit) { return "jmp qword [qword " + uIntPtr + "]"; } return "jmp dword [" + uIntPtr + "]"; } public static string GetAbsoluteCallMnemonics(nuint target, bool is64bit) { UIntPtr uIntPtr = FindOrCreateBufferInRange(IntPtr.Size, 1u, uint.MaxValue).Add<UIntPtr>(ref target, false, 4); if (is64bit) { return "call qword [qword " + uIntPtr + "]"; } return "call dword [" + uIntPtr + "]"; } public static string GetAbsoluteJumpMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate { ReloadedHooks instance = ReloadedHooks.Instance; reverseWrapper = instance.CreateReverseWrapper(function); return GetAbsoluteJumpMnemonics(AddressExtensions.ToUnsigned(reverseWrapper.WrapperPointer), IntPtr.Size == 8); } public static string GetAbsoluteCallMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate { ReloadedHooks instance = ReloadedHooks.Instance; reverseWrapper = instance.CreateReverseWrapper(function); return GetAbsoluteCallMnemonics(AddressExtensions.ToUnsigned(reverseWrapper.WrapperPointer), IntPtr.Size == 8); } public static string GetPushReturnMnemonics(nuint target, bool is64bit) { return $"push {target}\nret"; } public static string GetRelativeJumpMnemonics(IntPtr relativeJumpOffset, bool is64bit) { if (is64bit) { return "jmp qword " + relativeJumpOffset; } return "jmp dword " + relativeJumpOffset; } public static nuint InsertJump(byte[] opcodes, bool is64bit, nuint jumpTarget, nuint targetAddress = 0u, nint maxDisplacement = 2147483647) { List<byte> list = opcodes.ToList(); list.AddRange(AssembleAbsoluteJump(jumpTarget, is64bit)); byte[] array = list.ToArray(); (UIntPtr, UIntPtr) relativeJumpMinMax = GetRelativeJumpMinMax(targetAddress, maxDisplacement); return FindOrCreateBufferInRange(array.Length, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2).Add(array, 4); } public static nuint CreateJump(nuint targetPtr, bool is64Bit, int minBytesUsed = 0) { int num = 24 + minBytesUsed; (UIntPtr, UIntPtr) relativeJumpMinMax = GetRelativeJumpMinMax(targetPtr, int.MaxValue - num); MemoryBuffer buffer = FindOrCreateBufferInRange(num, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2); return buffer.ExecuteWithLock<UIntPtr>((Func<UIntPtr>)delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) buffer.SetAlignment(16); MemoryBufferProperties properties = buffer.Properties; nuint writePointer = ((MemoryBufferProperties)(ref properties)).WritePointer; bool isRelative; byte[] array = TryAssembleRelativeJumpArray(writePointer, targetPtr, is64Bit, out isRelative); UIntPtr result = buffer.Add(array, 1); properties = buffer.Properties; nuint num2 = (nuint)(nint)(nuint)((MemoryBufferProperties)(ref properties)).WritePointer - writePointer; int num3 = minBytesUsed - (int)num2; if (num3 > 0) { buffer.Add(num3, 1); } return result; }); } public unsafe static int GetHookLength(nuint hookAddress, int hookLength, bool is64Bit) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown using UnmanagedMemoryStream unmanagedMemoryStream = new UnmanagedMemoryStream((byte*)hookAddress, 128L); Decoder val = Decoder.Create(is64Bit ? 64 : 32, (CodeReader)new StreamCodeReader((Stream)unmanagedMemoryStream), (DecoderOptions)0); int i; Instruction val2 = default(Instruction); for (i = 0; i < hookLength; i += ((Instruction)(ref val2)).Length) { val.Decode(ref val2); } return i; } public static int GetNumberofParameters(Type delegateType) { MethodInfo method = delegateType.GetMethod("Invoke"); if (!(method != null)) { return 0; } return method.GetParameters().Length; } public static int GetNumberofParametersWithoutFloats(Type delegateType) { MethodInfo method = delegateType.GetMethod("Invoke"); if (!(method != null)) { return 0; } return GetNonFloatParameters(method); } public static int GetNumberofParameters<TFunction>() { if (TryGetIFuncPtrFromType<TFunction>(out var value)) { return value.NumberOfParameters; } return GetNumberofParameters(typeof(TFunction)); } public static int GetNumberofParametersWithoutFloats<TFunction>() { if (TryGetIFuncPtrFromType<TFunction>(out var value)) { return value.NumberOfParametersWithoutFloats; } return GetNumberofParametersWithoutFloats(typeof(TFunction)); } private static bool TryGetIFuncPtrFromType<TType>(out IFuncPtr value) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown value = null; if (typeof(IFuncPtr).IsAssignableFrom(typeof(TType))) { value = (IFuncPtr)Activator.CreateInstance(typeof(TType)); return true; } FieldInfo[] fields = typeof(TType).GetFields(); foreach (FieldInfo fieldInfo in fields) { if (typeof(IFuncPtr).IsAssignableFrom(fieldInfo.FieldType)) { value = (IFuncPtr)CreateInstanceSuppressed(fieldInfo); return true; } } return false; static object CreateInstanceSuppressed(FieldInfo field) { return Activator.CreateInstance(field.FieldType); } } private static int GetNonFloatParameters(MethodInfo methodInformation) { return methodInformation.GetParameters().Count((ParameterInfo parameter) => parameter.ParameterType != typeof(float) && parameter.ParameterType != typeof(double)); } internal unsafe static bool IsBadReadPtr(IntPtr address) { Native.MEMORY_BASIC_INFORMATION lpBuffer = default(Native.MEMORY_BASIC_INFORMATION); if (Native.VirtualQuery(address, ref lpBuffer, (UIntPtr)(ulong)sizeof(Native.MEMORY_BASIC_INFORMATION)) != IntPtr.Zero) { bool result = (lpBuffer.Protect & (Native.MEM_PROTECTION.PAGE_READONLY | Native.MEM_PROTECTION.PAGE_READWRITE | Native.MEM_PROTECTION.PAGE_WRITECOPY | Native.MEM_PROTECTION.PAGE_EXECUTE_READ | Native.MEM_PROTECTION.PAGE_EXECUTE_READWRITE | Native.MEM_PROTECTION.PAGE_EXECUTE_WRITECOPY)) == 0; if ((lpBuffer.Protect & (Native.MEM_PROTECTION.PAGE_NOACCESS | Native.MEM_PROTECTION.PAGE_GUARD)) != 0) { result = true; } return result; } return true; } public static void FillArrayUntilSize<T>(List<T> array, T value, int length) { if (length > array.Count) { int num = length - array.Count; for (int i = 0; i < num; i++) { array.Add(value); } } } public static byte[] TryAssembleRelativeJumpArray(nuint source, nuint target, bool is64Bit, out bool isRelative) { (UIntPtr, UIntPtr) relativeJumpMinMax = GetRelativeJumpMinMax(source); isRelative = new AddressRange(relativeJumpMinMax.Item1, relativeJumpMinMax.Item2).Contains(target); if (!isRelative) { return AssembleAbsoluteJump(target, is64Bit); } return AssembleRelativeJump(source, target, is64Bit); } public static List<byte> TryAssembleRelativeJump(nuint source, nuint target, bool is64Bit, out bool isRelative) { return TryAssembleRelativeJumpArray(source, target, is64Bit, out isRelative).ToList(); } public static MemoryBuffer FindOrCreateBufferInRange(int size, nuint minimumAddress = 1u, nuint maximumAddress = 2147483647u, int alignment = 4) { MemoryBuffer[] array = _bufferHelper.FindBuffers(size + alignment, (UIntPtr)minimumAddress, (UIntPtr)maximumAddress, true); if (array.Length == 0) { return _bufferHelper.CreateMemoryBuffer(size, (UIntPtr)minimumAddress, (UIntPtr)maximumAddress, 3); } return array[0]; } public static (nuint min, nuint max) GetRelativeJumpMinMax(nuint targetAddress, nint maxDisplacement = 2147483647) { nuint num = targetAddress - (nuint)maxDisplacement; if (num > targetAddress) { num = 1u; } nuint num2 = targetAddress + (nuint)maxDisplacement; if (num2 < targetAddress) { num2 = unchecked((nuint)(-1)); } if (!Environment.Is64BitProcess && num2 > uint.MaxValue) { num2 = uint.MaxValue; } return (num, num2); } } public class VirtualFunctionTable : IVirtualFunctionTable { public List<TableEntry> TableEntries { get; set; } public TableEntry this[int i] { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) return TableEntries[i]; } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) TableEntries[i] = value; } } private VirtualFunctionTable() { } public static VirtualFunctionTable FromObject(nuint objectAddress, int numberOfMethods) { return new VirtualFunctionTable { TableEntries = GetObjectVTableAddresses(objectAddress, numberOfMethods) }; } public static VirtualFunctionTable FromAddress(nuint tableAddress, int numberOfMethods) { return new VirtualFunctionTable { TableEntries = VirtualFunctionTableHelpers.GetAddresses(tableAddress, numberOfMethods) }; } public unsafe TFunction CreateWrapperFunction<TFunction>(int index) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) UIntPtr wrapperAddress; if (sizeof(IntPtr) == 4) { return Reloaded.Hooks.X86.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(TableEntries[index].FunctionPointer), out wrapperAddress); } UIntPtr wrapperAddress2; if (sizeof(IntPtr) == 8) { return Reloaded.Hooks.X64.Wrapper.Create<TFunction>(AddressExtensions.ToUnsigned(TableEntries[index].FunctionPointer), out wrapperAddress2); } throw new Exception("Machine does not appear to be of a 32 or 64bit architecture."); } public IHook<TFunction> CreateFunctionHook<TFunction>(int index, TFunction delegateType) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return new Hook<TFunction>(delegateType, AddressExtensions.ToUnsigned(TableEntries[index].FunctionPointer)); } private static List<TableEntry> GetObjectVTableAddresses(nuint objectAddress, int numberOfMethods) { nuint tablePointer = default(nuint); MemoryExtensions.SafeRead<Memory, UIntPtr>(Memory.CurrentProcess, (UIntPtr)objectAddress, ref tablePointer); return VirtualFunctionTableHelpers.GetAddresses(tablePointer, numberOfMethods); } } } namespace Reloaded.Hooks.Internal { public struct AddressRange { public nuint StartPointer; public nuint EndPointer; public AddressRange(nuint startPointer, nuint endPointer) { StartPointer = startPointer; EndPointer = endPointer; } public static AddressRange FromStartAndLength(nuint start, nuint length) { return new AddressRange(start, start + length); } public bool Contains(nuint point) { return PointInRange(ref this, point); } private bool PointInRange(ref AddressRange range, nuint point) { if (point >= range.StartPointer && point <= range.EndPointer) { return true; } return false; } } public class FunctionPatch { public List<Patch> Patches; public List<byte> NewFunction { get; private set; } public FunctionPatch() { NewFunction = new List<byte>(); Patches = new List<Patch>(); } } public class FunctionPatcher { private struct JumpDetails { public nuint JumpOpcodeEnd; public nuint JumpOpcodeTarget; public JumpDetails(nuint jumpOpcodeEnd, nuint jumpOpcodeTarget) { JumpOpcodeEnd = jumpOpcodeEnd; JumpOpcodeTarget = jumpOpcodeTarget; } } private bool _is64Bit; private FunctionHookOptions _options; private ProcessModule[] _modules; public FunctionPatcher(bool is64Bit, FunctionHookOptions options = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) _is64Bit = is64Bit; _options = (FunctionHookOptions)(((object)options) ?? ((object)new FunctionHookOptions())); } public FunctionPatch Patch(List<byte> oldFunction, nuint baseAddress) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) FunctionPatch functionPatch = new FunctionPatch(); nuint newAddress = baseAddress + (nuint)oldFunction.Count; byte[] array = oldFunction.ToArray(); Decoder val = Decoder.Create(_is64Bit ? 64 : 32, (CodeReader)new ByteArrayCodeReader(array), (DecoderOptions)0); val.IP = baseAddress; nuint num = (nuint)oldFunction.Count + baseAddress; List<Instruction> list = new List<Instruction>(); while (val.IP < num) { list.Add(val.Decode()); } for (int i = 0; i < list.Count; i++) { Instruction val2 = list[i]; Instruction val3 = (Instruction)((i + 1 < list.Count) ? list[i + 1] : default(Instruction)); JumpDetails jumpDetails; if (IsRelativeJump(val2) && !IsJumpTargetInAModule(PC(val2), GetRelativeJumpTarget(val2))) { jumpDetails = RewriteRelativeJump(val2, functionPatch); } else if (IsRIPRelativeJump(val2) && !IsJumpTargetInAModule(PC(val2), GetRewriteRIPRelativeJumpTarget(val2))) { jumpDetails = RewriteRIPRelativeJump(val2, functionPatch); } else { Instruction val4 = default(Instruction); if (!((ref val3) != (ref val4)) || !IsPushReturn(val2, val3) || IsJumpTargetInAModule(PC(val2), GetPushReturnTarget(val2))) { ulong num2 = ((Instruction)(ref val2)).IP - baseAddress; Span<byte> span = array.AsSpan().Slice((int)num2, ((Instruction)(ref val2)).Length); functionPatch.NewFunction.AddRange(span.ToArray()); continue; } jumpDetails = RewritePushReturn(val2, val3, functionPatch); } PatchReturnAddresses(jumpDetails, functionPatch, newAddress); } return functionPatch; } private List<Patch> PatchJumpTargets_Internal(AddressRange searchRange, AddressRange originalJmpTarget, nuint newJmpTarget) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) List<Patch> list = new List<Patch>(); int size = (int)(searchRange.EndPointer - searchRange.StartPointer); byte[] array = TryReadFromMemory(searchRange.StartPointer, size); Decoder val = Decoder.Create(_is64Bit ? 64 : 32, (CodeReader)new ByteArrayCodeReader(array), (DecoderOptions)0); val.IP = searchRange.StartPointer; nuint num = (nuint)array.Length + searchRange.StartPointer; List<Instruction> list2 = new List<Instruction>(); while (val.IP < num) { list2.Add(val.Decode()); } for (int i = 0; i < list2.Count; i++) { Instruction instruction = list2[i]; Instruction nextInstruction = (Instruction)((i + 1 < list2.Count) ? list2[i + 1] : default(Instruction)); if (IsRelativeJump(instruction)) { PatchRelativeJump(instruction, ref originalJmpTarget, newJmpTarget, list); continue; } if (IsRIPRelativeJump(instruction)) { PatchRIPRelativeJump(instruction, ref originalJmpTarget, newJmpTarget, list); continue; } Instruction val2 = default(Instruction); if ((ref nextInstruction) != (ref val2) && IsPushReturn(instruction, nextInstruction)) { PatchPushReturn(instruction, ref originalJmpTarget, newJmpTarget, list); } } return list; } private nuint GetPushReturnTarget(Instruction pushInstruction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (nuint)GetOperandOffset(pushInstruction); } private nuint GetRelativeJumpTarget(Instruction instruction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (nuint)GetJumpTarget(instruction); } private nuint GetRewriteRIPRelativeJumpTarget(Instruction instruction) { ulong iPRelativeMemoryAddress = ((Instruction)(ref instruction)).IPRelativeMemoryAddress; UIntPtr result = default(UIntPtr); Memory.CurrentProcess.Read<UIntPtr>((UIntPtr)(nuint)iPRelativeMemoryAddress, ref result); return result; } private JumpDetails RewriteRelativeJump(Instruction instruction, FunctionPatch patch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) nuint relativeJumpTarget = GetRelativeJumpTarget(instruction); patch.NewFunction.AddRange(Utilities.AssembleAbsoluteJump(relativeJumpTarget, _is64Bit)); return new JumpDetails(PC(instruction), relativeJumpTarget); } private JumpDetails RewriteRIPRelativeJump(Instruction instruction, FunctionPatch patch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) nuint rewriteRIPRelativeJumpTarget = GetRewriteRIPRelativeJumpTarget(instruction); patch.NewFunction.AddRange(Utilities.AssembleAbsoluteJump(rewriteRIPRelativeJumpTarget, _is64Bit)); return new JumpDetails(PC(instruction), rewriteRIPRelativeJumpTarget); } private JumpDetails RewritePushReturn(Instruction pushInstruction, Instruction retInstruction, FunctionPatch patch) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) nuint pushReturnTarget = GetPushReturnTarget(pushInstruction); patch.NewFunction.AddRange(Utilities.AssembleAbsoluteJump(pushReturnTarget, _is64Bit)); return new JumpDetails(PC(retInstruction), pushReturnTarget); } private void PatchReturnAddresses(JumpDetails jumpDetails, FunctionPatch patch, nuint newAddress) { nuint jumpOpcodeTarget = jumpDetails.JumpOpcodeTarget; nuint searchPointer = jumpOpcodeTarget; GetSearchRange(ref searchPointer, out var searchLength); nuint jumpOpcodeEnd = jumpDetails.JumpOpcodeEnd; int size = (int)(newAddress - jumpOpcodeEnd); nuint newOriginalPrologue = Utilities.InsertJump(TryReadFromMemory(jumpOpcodeEnd, size), maxDisplacement: (nint)(int.MaxValue - searchLength), is64bit: _is64Bit, jumpTarget: newAddress, targetAddress: jumpOpcodeTarget); AddressRange searchRange = new AddressRange(searchPointer, searchPointer + searchLength); AddressRange jumpTargetRange = new AddressRange(jumpOpcodeEnd, newAddress); patch.Patches = PatchJumpTargets(searchRange, jumpOpcodeTarget, jumpTargetRange, newOriginalPrologue); } internal List<Patch> PatchJumpTargets(AddressRange searchRange, nuint originalJmpTarget, AddressRange jumpTargetRange, nuint newOriginalPrologue) { List<Patch> result = new List<Patch>(); if (TryCodeAlignmentRange(AddressRange.FromStartAndLength(originalJmpTarget / 16 * 16, 64u))) { return result; } if (TryCodeAlignmentRange(AddressRange.FromStartAndLength(originalJmpTarget / 16 * 16 - 16, 32u))) { return result; } if (TryCodeAlignmentRange(AddressRange.FromStartAndLength(originalJmpTarget, 32u))) { return result; } List<Patch> collection = PatchJumpTargets_Internal(searchRange, jumpTargetRange, newOriginalPrologue); result.AddRange(collection); return result; bool TryCodeAlignmentRange(AddressRange range) { if (range.StartPointer < searchRange.StartPointer && Utilities.IsBadReadPtr(AddressExtensions.ToSigned((UIntPtr)range.StartPointer))) { range.StartPointer = searchRange.StartPointer; } if (range.EndPointer > searchRange.EndPointer && Utilities.IsBadReadPtr(AddressExtensions.ToSigned((UIntPtr)range.EndPointer))) { range.EndPointer = searchRange.EndPointer; } List<Patch> list = PatchJumpTargets_Internal(range, jumpTargetRange, newOriginalPrologue); result.AddRange(list); return list.Count > 0; } } private void PatchRelativeJump(Instruction instruction, ref AddressRange originalJmpTarget, nuint newJmpTarget, List<Patch> patches) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) nuint point = (nuint)GetJumpTarget(instruction); if (originalJmpTarget.Contains(point)) { byte[] bytes = Utilities.AssembleRelativeJump((nuint)((Instruction)(ref instruction)).IP, newJmpTarget, _is64Bit); patches.Add(new Patch((nuint)((Instruction)(ref instruction)).IP, bytes)); } } private void PatchRIPRelativeJump(Instruction instruction, ref AddressRange originalJmpTarget, nuint newJmpTarget, List<Patch> patches) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) nuint rewriteRIPRelativeJumpTarget = GetRewriteRIPRelativeJumpTarget(instruction); if (originalJmpTarget.Contains(rewriteRIPRelativeJumpTarget)) { byte[] bytes = Utilities.AssembleRelativeJump((nuint)((Instruction)(ref instruction)).IP, newJmpTarget, _is64Bit); patches.Add(new Patch((nuint)((Instruction)(ref instruction)).IP, bytes)); } } private void PatchPushReturn(Instruction instruction, ref AddressRange originalJmpTarget, nuint newJmpTarget, List<Patch> patches) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ulong num = GetPushReturnTarget(instruction); if (originalJmpTarget.Contains((nuint)num)) { byte[] array = Utilities.AssembleAbsoluteJump(newJmpTarget, _is64Bit); byte[] bytes = Utilities.AssemblePushReturn(Utilities.FindOrCreateBufferInRange(array.Length, 1u, 2147483647u).Add(array, 4), _is64Bit); patches.Add(new Patch((nuint)((Instruction)(ref instruction)).IP, bytes)); } } internal void GetSearchRange(ref nuint searchPointer, out nuint searchLength) { searchLength = 0u; if (_options.SearchInModules) { ProcessModule[] cachedModules = GetCachedModules(); foreach (ProcessModule processModule in cachedModules) { UIntPtr uIntPtr = AddressExtensions.ToUnsigned(processModule.BaseAddress); nuint num = (nuint)((nint)(nuint)AddressExtensions.ToUnsigned(processModule.BaseAddress) + processModule.ModuleMemorySize); if (searchPointer >= (nuint)uIntPtr && searchPointer <= num) { searchPointer = uIntPtr; searchLength = (nuint)processModule.ModuleMemorySize; } } } if (searchLength == 0) { searchLength = (nuint)Environment.SystemPageSize; searchPointer -= searchPointer % searchLength; } } private byte[] TryReadFromMemory(nuint address, int size) { byte[] result = default(byte[]); try { Memory.CurrentProcess.ReadRaw((UIntPtr)address, ref result, size); } catch (Exception) { MemoryExtensions.SafeReadRaw<Memory>(Memory.CurrentProcess, (UIntPtr)address, ref result, size); } return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool IsRelativeJump(Instruction instruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 if ((int)((Instruction)(ref instruction)).Mnemonic == 308 && ((Instruction)(ref instruction)).OpCount > 0) { if ((int)((Instruction)(ref instruction)).Op0Kind != 1 && (int)((Instruction)(ref instruction)).Op0Kind != 2) { return (int)((Instruction)(ref instruction)).Op0Kind == 3; } return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool IsPushReturn(Instruction instruction, Instruction nextInstruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 if ((int)((Instruction)(ref instruction)).Mnemonic == 640 && ((Instruction)(ref instruction)).OpCount >= 1) { OpKind op0Kind = ((Instruction)(ref instruction)).Op0Kind; if ((int)op0Kind == 9 || (int)op0Kind == 14) { return (int)((Instruction)(ref nextInstruction)).Mnemonic == 662; } } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool IsRIPRelativeJump(Instruction instruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 if ((int)((Instruction)(ref instruction)).Mnemonic == 308 && _is64Bit && ((Instruction)(ref instruction)).OpCount >= 1) { return ((Instruction)(ref instruction)).IsIPRelativeMemoryOperand; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool IsJumpTargetInAModule(nuint source, nuint target) { if (!_options.VerifyJumpTargetsModule) { return false; } ProcessModule[] cachedModules = GetCachedModules(); foreach (ProcessModule processModule in cachedModules) { AddressRange addressRange = new AddressRange(AddressExtensions.ToUnsigned(processModule.BaseAddress), AddressExtensions.ToUnsigned(processModule.BaseAddress + processModule.ModuleMemorySize)); if (addressRange.Contains(source) && addressRange.Contains(target)) { return true; } } return false; } private ProcessModule[] GetCachedModules() { if (_modules != null) { return _modules; } ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; _modules = new ProcessModule[modules.Count]; modules.CopyTo(_modules, 0); return _modules; } private ulong GetJumpTarget(Instruction instruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected I4, but got Unknown OpKind op0Kind = ((Instruction)(ref instruction)).Op0Kind; return (op0Kind - 1) switch { 0 => ((Instruction)(ref instruction)).NearBranch16, 1 => ((Instruction)(ref instruction)).NearBranch32, 2 => ((Instruction)(ref instruction)).NearBranch64, _ => throw new ArgumentOutOfRangeException(), }; } private ulong GetOperandOffset(Instruction instruction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown OpKind op0Kind = ((Instruction)(ref instruction)).Op0Kind; return (op0Kind - 6) switch { 0 => ((Instruction)(ref instruction)).Immediate8, 2 => ((Instruction)(ref instruction)).Immediate16, 3 => ((Instruction)(ref instruction)).Immediate32, 4 => ((Instruction)(ref instruction)).Immediate64, 8 => (ulong)((Instruction)(ref instruction)).Immediate32to64, _ => throw new ArgumentOutOfRangeException(), }; } private static nuint PC(Instruction instruction) { return (nuint)((nint)((Instruction)(ref instruction)).IP + ((Instruction)(ref instruction)).Length); } } public class IcedPatcher { private sealed class CodeWriterImpl : CodeWriter { private List<byte> _allBytes; public override void WriteByte(byte value) { _allBytes.Add(value); } public byte[] ToArray() { return _allBytes.ToArray(); } public CodeWriterImpl(int capacity) { _allBytes = new List<byte>(capacity); } } private static MemoryBufferHelper _helper = new MemoryBufferHelper(Process.GetCurrentProcess()); private int _bitness; private byte[] _bytes; private nuint _originalFunctionAddress; private nuint _newPrologueAddress; public IcedPatcher(bool is64Bit, byte[] bytes, nuint originalFunctionAddress) { _bitness = (is64Bit ? 64 : 32); _bytes = bytes; _originalFunctionAddress = originalFunctionAddress; } public byte[] EncodeForNewAddress(nuint newAddress) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) CodeWriterImpl codeWriterImpl = new CodeWriterImpl(_bytes.Length * 2); InstructionBlock val = default(InstructionBlock); ((InstructionBlock)(ref val))..ctor((CodeWriter)(object)codeWriterImpl, DecodePrologue(), (ulong)newAddress); string text = default(string); BlockEncoderResult val2 = default(BlockEncoderResult); if (!BlockEncoder.TryEncode(_bitness, val, ref text, ref val2, (BlockEncoderOptions)0)) { throw new Exception("Reloaded Hooks: Internal Error in Internal/IcedPatcher. Failed to re-encode code for new address. Process will probably die.Error: " + text); } return codeWriterImpl.ToArray(); } public nuint ToMemoryBuffer(nuint? jumpTarget) { if (_newPrologueAddress != 0) { return _newPrologueAddress; } int alignment = 16; int num = _bytes.Length * 2 + alignment; (UIntPtr, UIntPtr) relativeJumpMinMax = Utilities.GetRelativeJumpMinMax(jumpTarget.GetValueOrDefault(), int.MaxValue - num); MemoryBuffer buffer = Utilities.FindOrCreateBufferInRange(num, relativeJumpMinMax.Item1, relativeJumpMinMax.Item2, alignment); return buffer.ExecuteWithLock<UIntPtr>((Func<UIntPtr>)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) buffer.SetAlignment(alignment); MemoryBufferProperties properties = buffer.Properties; nuint writePointer = ((MemoryBufferProperties)(ref properties)).WritePointer; byte[] array = EncodeForNewAddress(writePointer); _newPrologueAddress = buffer.Add(array, 1); if (jumpTarget.HasValue) { MemoryBuffer obj = buffer; properties = buffer.Properties; obj.Add(Utilities.AssembleRelativeJump(((MemoryBufferProperties)(ref properties)).WritePointer, jumpTarget.Value, _bitness == 64), 1); } return _newPrologueAddress; }); } private IList<Instruction> DecodePrologue() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown ByteArrayCodeReader val = new ByteArrayCodeReader(_bytes); Decoder val2 = Decoder.Create(_bitness, (CodeReader)(object)val, (DecoderOptions)0); val2.IP = _originalFunctionAddress; ulong num = val2.IP + (uint)_bytes.Length; InstructionList val3 = new InstructionList(); while (val2.IP < num) { val2.Decode(ref val3.AllocUninitializedElement()); } return (IList<Instruction>)val3; } } internal class Native { internal struct MEMORY_BASIC_INFORMATION { public IntPtr BaseAddress; public IntPtr AllocationBase; public uint AllocationProtect; public UIntPtr RegionSize; public uint State; public MEM_PROTECTION Protect; public uint Type; } [Flags] internal enum MEM_PROTECTION : uint { PAGE_NOACCESS = 1u, PAGE_READONLY = 2u, PAGE_READWRITE = 4u, PAGE_WRITECOPY = 8u, PAGE_EXECUTE = 0x10u, PAGE_EXECUTE_READ = 0x20u, PAGE_EXECUTE_READWRITE = 0x40u, PAGE_EXECUTE_WRITECOPY = 0x80u, PAGE_GUARD = 0x100u, PAGE_NOCACHE = 0x200u, PAGE_WRITECOMBINE = 0x400u, PAGE_ENCLAVE_UNVALIDATED = 0x20000000u, PAGE_TARGETS_INVALID = 0x40000000u, PAGE_TARGETS_NO_UPDATE = 0x40000000u, PAGE_ENCLAVE_THREAD_CONTROL = 0x80000000u, PAGE_REVERT_TO_FILE_MAP = 0x80000000u } [DllImport("kernel32.dll", SetLastError = true)] [SuppressUnmanagedCodeSecurity] internal static extern IntPtr VirtualQuery(IntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength); } public struct Patch { private nuint _address; private byte[] _bytes; public Patch(nuint address, byte[] bytes) { _address = address; _bytes = bytes; } public void Apply() { MemoryExtensions.SafeWriteRaw<Memory>(Memory.CurrentProcess, (UIntPtr)_address, _bytes); } public unsafe void ApplyUnsafe() { Span<byte> destination = new Span<byte>((void*)_address, _bytes.Length); _bytes.AsSpan().CopyTo(destination); } } } namespace Reloaded.Hooks.Internal.Testing { public static class FunctionPatcherTesting { public static List<Patch> PatchJumpTargets(FunctionPatcher patcher, AddressRange searchRange, AddressRange jumpTargetRange, nuint newJmpTarget) { return patcher.PatchJumpTargets(searchRange, jumpTargetRange.StartPointer, jumpTargetRange, newJmpTarget); } public static void GetSearchRange(FunctionPatcher patcher, ref nuint searchPointer, out nuint searchLength) { patcher.GetSearchRange(ref searchPointer, out searchLength); } } }
BepInEx/plugins/DearImGuiInjection/ImGui.NET.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: InternalsVisibleTo("ImPlot.NET")] [assembly: InternalsVisibleTo("ImNodes.NET")] [assembly: AssemblyCompany("Eric Mellino")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A .NET wrapper for the Dear ImGui library.")] [assembly: AssemblyFileVersion("1.89.5.1")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ImGui.NET")] [assembly: AssemblyTitle("ImGui.NET")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.89.5.1")] [module: UnverifiableCode] namespace ImGuiNET; public delegate void Platform_CreateWindow(ImGuiViewportPtr vp); public delegate void Platform_DestroyWindow(ImGuiViewportPtr vp); public delegate void Platform_ShowWindow(ImGuiViewportPtr vp); public delegate void Platform_SetWindowPos(ImGuiViewportPtr vp, Vector2 pos); public unsafe delegate void Platform_GetWindowPos(ImGuiViewportPtr vp, Vector2* outPos); public delegate void Platform_SetWindowSize(ImGuiViewportPtr vp, Vector2 size); public unsafe delegate void Platform_GetWindowSize(ImGuiViewportPtr vp, Vector2* outSize); public delegate void Platform_SetWindowFocus(ImGuiViewportPtr vp); public delegate byte Platform_GetWindowFocus(ImGuiViewportPtr vp); public delegate byte Platform_GetWindowMinimized(ImGuiViewportPtr vp); public delegate void Platform_SetWindowTitle(ImGuiViewportPtr vp, IntPtr title); public struct ImColor { public Vector4 Value; } public struct ImColorPtr { public unsafe ImColor* NativePtr { get; } public unsafe ref Vector4 Value => ref Unsafe.AsRef<Vector4>(&NativePtr->Value); public unsafe ImColorPtr(ImColor* nativePtr) { NativePtr = nativePtr; } public unsafe ImColorPtr(IntPtr nativePtr) { NativePtr = (ImColor*)(void*)nativePtr; } public unsafe static implicit operator ImColorPtr(ImColor* nativePtr) { return new ImColorPtr(nativePtr); } public unsafe static implicit operator ImColor*(ImColorPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImColorPtr(IntPtr nativePtr) { return new ImColorPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImColor_destroy(NativePtr); } public unsafe ImColor HSV(float h, float s, float v) { float a = 1f; ImColor result = default(ImColor); ImGuiNative.ImColor_HSV(&result, h, s, v, a); return result; } public unsafe ImColor HSV(float h, float s, float v, float a) { ImColor result = default(ImColor); ImGuiNative.ImColor_HSV(&result, h, s, v, a); return result; } public unsafe void SetHSV(float h, float s, float v) { float a = 1f; ImGuiNative.ImColor_SetHSV(NativePtr, h, s, v, a); } public unsafe void SetHSV(float h, float s, float v, float a) { ImGuiNative.ImColor_SetHSV(NativePtr, h, s, v, a); } } public struct ImDrawChannel { public ImVector _CmdBuffer; public ImVector _IdxBuffer; } public struct ImDrawChannelPtr { public unsafe ImDrawChannel* NativePtr { get; } public unsafe ImPtrVector<ImDrawCmdPtr> _CmdBuffer => new ImPtrVector<ImDrawCmdPtr>(NativePtr->_CmdBuffer, Unsafe.SizeOf<ImDrawCmd>()); public unsafe ImVector<ushort> _IdxBuffer => new ImVector<ushort>(NativePtr->_IdxBuffer); public unsafe ImDrawChannelPtr(ImDrawChannel* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawChannelPtr(IntPtr nativePtr) { NativePtr = (ImDrawChannel*)(void*)nativePtr; } public unsafe static implicit operator ImDrawChannelPtr(ImDrawChannel* nativePtr) { return new ImDrawChannelPtr(nativePtr); } public unsafe static implicit operator ImDrawChannel*(ImDrawChannelPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawChannelPtr(IntPtr nativePtr) { return new ImDrawChannelPtr(nativePtr); } } public struct ImDrawCmd { public Vector4 ClipRect; public IntPtr TextureId; public uint VtxOffset; public uint IdxOffset; public uint ElemCount; public IntPtr UserCallback; public unsafe void* UserCallbackData; } public struct ImDrawCmdPtr { public unsafe ImDrawCmd* NativePtr { get; } public unsafe ref Vector4 ClipRect => ref Unsafe.AsRef<Vector4>(&NativePtr->ClipRect); public unsafe ref IntPtr TextureId => ref Unsafe.AsRef<IntPtr>(&NativePtr->TextureId); public unsafe ref uint VtxOffset => ref Unsafe.AsRef<uint>(&NativePtr->VtxOffset); public unsafe ref uint IdxOffset => ref Unsafe.AsRef<uint>(&NativePtr->IdxOffset); public unsafe ref uint ElemCount => ref Unsafe.AsRef<uint>(&NativePtr->ElemCount); public unsafe ref IntPtr UserCallback => ref Unsafe.AsRef<IntPtr>(&NativePtr->UserCallback); public unsafe IntPtr UserCallbackData { get { return (IntPtr)NativePtr->UserCallbackData; } set { NativePtr->UserCallbackData = (void*)value; } } public unsafe ImDrawCmdPtr(ImDrawCmd* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawCmdPtr(IntPtr nativePtr) { NativePtr = (ImDrawCmd*)(void*)nativePtr; } public unsafe static implicit operator ImDrawCmdPtr(ImDrawCmd* nativePtr) { return new ImDrawCmdPtr(nativePtr); } public unsafe static implicit operator ImDrawCmd*(ImDrawCmdPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawCmdPtr(IntPtr nativePtr) { return new ImDrawCmdPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawCmd_destroy(NativePtr); } public unsafe IntPtr GetTexID() { return ImGuiNative.ImDrawCmd_GetTexID(NativePtr); } } public struct ImDrawCmdHeader { public Vector4 ClipRect; public IntPtr TextureId; public uint VtxOffset; } public struct ImDrawCmdHeaderPtr { public unsafe ImDrawCmdHeader* NativePtr { get; } public unsafe ref Vector4 ClipRect => ref Unsafe.AsRef<Vector4>(&NativePtr->ClipRect); public unsafe ref IntPtr TextureId => ref Unsafe.AsRef<IntPtr>(&NativePtr->TextureId); public unsafe ref uint VtxOffset => ref Unsafe.AsRef<uint>(&NativePtr->VtxOffset); public unsafe ImDrawCmdHeaderPtr(ImDrawCmdHeader* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawCmdHeaderPtr(IntPtr nativePtr) { NativePtr = (ImDrawCmdHeader*)(void*)nativePtr; } public unsafe static implicit operator ImDrawCmdHeaderPtr(ImDrawCmdHeader* nativePtr) { return new ImDrawCmdHeaderPtr(nativePtr); } public unsafe static implicit operator ImDrawCmdHeader*(ImDrawCmdHeaderPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawCmdHeaderPtr(IntPtr nativePtr) { return new ImDrawCmdHeaderPtr(nativePtr); } } public struct ImDrawData { public byte Valid; public int CmdListsCount; public int TotalIdxCount; public int TotalVtxCount; public unsafe ImDrawList** CmdLists; public Vector2 DisplayPos; public Vector2 DisplaySize; public Vector2 FramebufferScale; public unsafe ImGuiViewport* OwnerViewport; } public struct ImDrawDataPtr { public unsafe ImDrawData* NativePtr { get; } public unsafe ref bool Valid => ref Unsafe.AsRef<bool>(&NativePtr->Valid); public unsafe ref int CmdListsCount => ref Unsafe.AsRef<int>(&NativePtr->CmdListsCount); public unsafe ref int TotalIdxCount => ref Unsafe.AsRef<int>(&NativePtr->TotalIdxCount); public unsafe ref int TotalVtxCount => ref Unsafe.AsRef<int>(&NativePtr->TotalVtxCount); public unsafe IntPtr CmdLists { get { return (IntPtr)NativePtr->CmdLists; } set { NativePtr->CmdLists = (ImDrawList**)(void*)value; } } public unsafe ref Vector2 DisplayPos => ref Unsafe.AsRef<Vector2>(&NativePtr->DisplayPos); public unsafe ref Vector2 DisplaySize => ref Unsafe.AsRef<Vector2>(&NativePtr->DisplaySize); public unsafe ref Vector2 FramebufferScale => ref Unsafe.AsRef<Vector2>(&NativePtr->FramebufferScale); public unsafe ImGuiViewportPtr OwnerViewport => new ImGuiViewportPtr(NativePtr->OwnerViewport); public unsafe RangePtrAccessor<ImDrawListPtr> CmdListsRange => new RangePtrAccessor<ImDrawListPtr>(CmdLists.ToPointer(), CmdListsCount); public unsafe ImDrawDataPtr(ImDrawData* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawDataPtr(IntPtr nativePtr) { NativePtr = (ImDrawData*)(void*)nativePtr; } public unsafe static implicit operator ImDrawDataPtr(ImDrawData* nativePtr) { return new ImDrawDataPtr(nativePtr); } public unsafe static implicit operator ImDrawData*(ImDrawDataPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawDataPtr(IntPtr nativePtr) { return new ImDrawDataPtr(nativePtr); } public unsafe void Clear() { ImGuiNative.ImDrawData_Clear(NativePtr); } public unsafe void DeIndexAllBuffers() { ImGuiNative.ImDrawData_DeIndexAllBuffers(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawData_destroy(NativePtr); } public unsafe void ScaleClipRects(Vector2 fb_scale) { ImGuiNative.ImDrawData_ScaleClipRects(NativePtr, fb_scale); } } [Flags] public enum ImDrawFlags { None = 0, Closed = 1, RoundCornersTopLeft = 0x10, RoundCornersTopRight = 0x20, RoundCornersBottomLeft = 0x40, RoundCornersBottomRight = 0x80, RoundCornersNone = 0x100, RoundCornersTop = 0x30, RoundCornersBottom = 0xC0, RoundCornersLeft = 0x50, RoundCornersRight = 0xA0, RoundCornersAll = 0xF0, RoundCornersDefault = 0xF0, RoundCornersMask = 0x1F0 } public struct ImDrawList { public ImVector CmdBuffer; public ImVector IdxBuffer; public ImVector VtxBuffer; public ImDrawListFlags Flags; public uint _VtxCurrentIdx; public IntPtr _Data; public unsafe byte* _OwnerName; public unsafe ImDrawVert* _VtxWritePtr; public unsafe ushort* _IdxWritePtr; public ImVector _ClipRectStack; public ImVector _TextureIdStack; public ImVector _Path; public ImDrawCmdHeader _CmdHeader; public ImDrawListSplitter _Splitter; public float _FringeScale; } public struct ImDrawListPtr { public unsafe ImDrawList* NativePtr { get; } public unsafe ImPtrVector<ImDrawCmdPtr> CmdBuffer => new ImPtrVector<ImDrawCmdPtr>(NativePtr->CmdBuffer, Unsafe.SizeOf<ImDrawCmd>()); public unsafe ImVector<ushort> IdxBuffer => new ImVector<ushort>(NativePtr->IdxBuffer); public unsafe ImPtrVector<ImDrawVertPtr> VtxBuffer => new ImPtrVector<ImDrawVertPtr>(NativePtr->VtxBuffer, Unsafe.SizeOf<ImDrawVert>()); public unsafe ref ImDrawListFlags Flags => ref Unsafe.AsRef<ImDrawListFlags>(&NativePtr->Flags); public unsafe ref uint _VtxCurrentIdx => ref Unsafe.AsRef<uint>(&NativePtr->_VtxCurrentIdx); public unsafe ref IntPtr _Data => ref Unsafe.AsRef<IntPtr>(&NativePtr->_Data); public unsafe NullTerminatedString _OwnerName => new NullTerminatedString(NativePtr->_OwnerName); public unsafe ImDrawVertPtr _VtxWritePtr => new ImDrawVertPtr(NativePtr->_VtxWritePtr); public unsafe IntPtr _IdxWritePtr { get { return (IntPtr)NativePtr->_IdxWritePtr; } set { NativePtr->_IdxWritePtr = (ushort*)(void*)value; } } public unsafe ImVector<Vector4> _ClipRectStack => new ImVector<Vector4>(NativePtr->_ClipRectStack); public unsafe ImVector<IntPtr> _TextureIdStack => new ImVector<IntPtr>(NativePtr->_TextureIdStack); public unsafe ImVector<Vector2> _Path => new ImVector<Vector2>(NativePtr->_Path); public unsafe ref ImDrawCmdHeader _CmdHeader => ref Unsafe.AsRef<ImDrawCmdHeader>(&NativePtr->_CmdHeader); public unsafe ref ImDrawListSplitter _Splitter => ref Unsafe.AsRef<ImDrawListSplitter>(&NativePtr->_Splitter); public unsafe ref float _FringeScale => ref Unsafe.AsRef<float>(&NativePtr->_FringeScale); public unsafe ImDrawListPtr(ImDrawList* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawListPtr(IntPtr nativePtr) { NativePtr = (ImDrawList*)(void*)nativePtr; } public unsafe static implicit operator ImDrawListPtr(ImDrawList* nativePtr) { return new ImDrawListPtr(nativePtr); } public unsafe static implicit operator ImDrawList*(ImDrawListPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawListPtr(IntPtr nativePtr) { return new ImDrawListPtr(nativePtr); } public unsafe int _CalcCircleAutoSegmentCount(float radius) { return ImGuiNative.ImDrawList__CalcCircleAutoSegmentCount(NativePtr, radius); } public unsafe void _ClearFreeMemory() { ImGuiNative.ImDrawList__ClearFreeMemory(NativePtr); } public unsafe void _OnChangedClipRect() { ImGuiNative.ImDrawList__OnChangedClipRect(NativePtr); } public unsafe void _OnChangedTextureID() { ImGuiNative.ImDrawList__OnChangedTextureID(NativePtr); } public unsafe void _OnChangedVtxOffset() { ImGuiNative.ImDrawList__OnChangedVtxOffset(NativePtr); } public unsafe void _PathArcToFastEx(Vector2 center, float radius, int a_min_sample, int a_max_sample, int a_step) { ImGuiNative.ImDrawList__PathArcToFastEx(NativePtr, center, radius, a_min_sample, a_max_sample, a_step); } public unsafe void _PathArcToN(Vector2 center, float radius, float a_min, float a_max, int num_segments) { ImGuiNative.ImDrawList__PathArcToN(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void _PopUnusedDrawCmd() { ImGuiNative.ImDrawList__PopUnusedDrawCmd(NativePtr); } public unsafe void _ResetForNewFrame() { ImGuiNative.ImDrawList__ResetForNewFrame(NativePtr); } public unsafe void _TryMergeDrawCmds() { ImGuiNative.ImDrawList__TryMergeDrawCmds(NativePtr); } public unsafe void AddBezierCubic(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness) { int num_segments = 0; ImGuiNative.ImDrawList_AddBezierCubic(NativePtr, p1, p2, p3, p4, col, thickness, num_segments); } public unsafe void AddBezierCubic(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness, int num_segments) { ImGuiNative.ImDrawList_AddBezierCubic(NativePtr, p1, p2, p3, p4, col, thickness, num_segments); } public unsafe void AddBezierQuadratic(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness) { int num_segments = 0; ImGuiNative.ImDrawList_AddBezierQuadratic(NativePtr, p1, p2, p3, col, thickness, num_segments); } public unsafe void AddBezierQuadratic(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness, int num_segments) { ImGuiNative.ImDrawList_AddBezierQuadratic(NativePtr, p1, p2, p3, col, thickness, num_segments); } public unsafe void AddCallback(IntPtr callback, IntPtr callback_data) { void* callback_data2 = callback_data.ToPointer(); ImGuiNative.ImDrawList_AddCallback(NativePtr, callback, callback_data2); } public unsafe void AddCircle(Vector2 center, float radius, uint col) { int num_segments = 0; float thickness = 1f; ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircle(Vector2 center, float radius, uint col, int num_segments) { float thickness = 1f; ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircle(Vector2 center, float radius, uint col, int num_segments, float thickness) { ImGuiNative.ImDrawList_AddCircle(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddCircleFilled(Vector2 center, float radius, uint col) { int num_segments = 0; ImGuiNative.ImDrawList_AddCircleFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddCircleFilled(Vector2 center, float radius, uint col, int num_segments) { ImGuiNative.ImDrawList_AddCircleFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddConvexPolyFilled(ref Vector2 points, int num_points, uint col) { fixed (Vector2* points2 = &points) { ImGuiNative.ImDrawList_AddConvexPolyFilled(NativePtr, points2, num_points, col); } } public unsafe void AddDrawCmd() { ImGuiNative.ImDrawList_AddDrawCmd(NativePtr); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max) { Vector2 uv_min = default(Vector2); Vector2 uv_max = new Vector2(1f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min) { Vector2 uv_max = new Vector2(1f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max) { uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImage(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col) { ImGuiNative.ImDrawList_AddImage(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4) { Vector2 uv = default(Vector2); Vector2 uv2 = new Vector2(1f, 0f); Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1) { Vector2 uv2 = new Vector2(1f, 0f); Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2) { Vector2 uv3 = new Vector2(1f, 1f); Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3) { Vector2 uv4 = new Vector2(0f, 1f); uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3, Vector2 uv4) { uint col = uint.MaxValue; ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageQuad(IntPtr user_texture_id, Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 uv1, Vector2 uv2, Vector2 uv3, Vector2 uv4, uint col) { ImGuiNative.ImDrawList_AddImageQuad(NativePtr, user_texture_id, p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); } public unsafe void AddImageRounded(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddImageRounded(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col, rounding, flags); } public unsafe void AddImageRounded(IntPtr user_texture_id, Vector2 p_min, Vector2 p_max, Vector2 uv_min, Vector2 uv_max, uint col, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_AddImageRounded(NativePtr, user_texture_id, p_min, p_max, uv_min, uv_max, col, rounding, flags); } public unsafe void AddLine(Vector2 p1, Vector2 p2, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddLine(NativePtr, p1, p2, col, thickness); } public unsafe void AddLine(Vector2 p1, Vector2 p2, uint col, float thickness) { ImGuiNative.ImDrawList_AddLine(NativePtr, p1, p2, col, thickness); } public unsafe void AddNgon(Vector2 center, float radius, uint col, int num_segments) { float thickness = 1f; ImGuiNative.ImDrawList_AddNgon(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddNgon(Vector2 center, float radius, uint col, int num_segments, float thickness) { ImGuiNative.ImDrawList_AddNgon(NativePtr, center, radius, col, num_segments, thickness); } public unsafe void AddNgonFilled(Vector2 center, float radius, uint col, int num_segments) { ImGuiNative.ImDrawList_AddNgonFilled(NativePtr, center, radius, col, num_segments); } public unsafe void AddPolyline(ref Vector2 points, int num_points, uint col, ImDrawFlags flags, float thickness) { fixed (Vector2* points2 = &points) { ImGuiNative.ImDrawList_AddPolyline(NativePtr, points2, num_points, col, flags, thickness); } } public unsafe void AddQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddQuad(NativePtr, p1, p2, p3, p4, col, thickness); } public unsafe void AddQuad(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col, float thickness) { ImGuiNative.ImDrawList_AddQuad(NativePtr, p1, p2, p3, p4, col, thickness); } public unsafe void AddQuadFilled(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, uint col) { ImGuiNative.ImDrawList_AddQuadFilled(NativePtr, p1, p2, p3, p4, col); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags) { float thickness = 1f; ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRect(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags, float thickness) { ImGuiNative.ImDrawList_AddRect(NativePtr, p_min, p_max, col, rounding, flags, thickness); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilled(Vector2 p_min, Vector2 p_max, uint col, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_AddRectFilled(NativePtr, p_min, p_max, col, rounding, flags); } public unsafe void AddRectFilledMultiColor(Vector2 p_min, Vector2 p_max, uint col_upr_left, uint col_upr_right, uint col_bot_right, uint col_bot_left) { ImGuiNative.ImDrawList_AddRectFilledMultiColor(NativePtr, p_min, p_max, col_upr_left, col_upr_right, col_bot_right, col_bot_left); } public unsafe void AddTriangle(Vector2 p1, Vector2 p2, Vector2 p3, uint col) { float thickness = 1f; ImGuiNative.ImDrawList_AddTriangle(NativePtr, p1, p2, p3, col, thickness); } public unsafe void AddTriangle(Vector2 p1, Vector2 p2, Vector2 p3, uint col, float thickness) { ImGuiNative.ImDrawList_AddTriangle(NativePtr, p1, p2, p3, col, thickness); } public unsafe void AddTriangleFilled(Vector2 p1, Vector2 p2, Vector2 p3, uint col) { ImGuiNative.ImDrawList_AddTriangleFilled(NativePtr, p1, p2, p3, col); } public unsafe void ChannelsMerge() { ImGuiNative.ImDrawList_ChannelsMerge(NativePtr); } public unsafe void ChannelsSetCurrent(int n) { ImGuiNative.ImDrawList_ChannelsSetCurrent(NativePtr, n); } public unsafe void ChannelsSplit(int count) { ImGuiNative.ImDrawList_ChannelsSplit(NativePtr, count); } public unsafe ImDrawListPtr CloneOutput() { ImDrawList* nativePtr = ImGuiNative.ImDrawList_CloneOutput(NativePtr); return new ImDrawListPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawList_destroy(NativePtr); } public unsafe Vector2 GetClipRectMax() { Vector2 result = default(Vector2); ImGuiNative.ImDrawList_GetClipRectMax(&result, NativePtr); return result; } public unsafe Vector2 GetClipRectMin() { Vector2 result = default(Vector2); ImGuiNative.ImDrawList_GetClipRectMin(&result, NativePtr); return result; } public unsafe void PathArcTo(Vector2 center, float radius, float a_min, float a_max) { int num_segments = 0; ImGuiNative.ImDrawList_PathArcTo(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void PathArcTo(Vector2 center, float radius, float a_min, float a_max, int num_segments) { ImGuiNative.ImDrawList_PathArcTo(NativePtr, center, radius, a_min, a_max, num_segments); } public unsafe void PathArcToFast(Vector2 center, float radius, int a_min_of_12, int a_max_of_12) { ImGuiNative.ImDrawList_PathArcToFast(NativePtr, center, radius, a_min_of_12, a_max_of_12); } public unsafe void PathBezierCubicCurveTo(Vector2 p2, Vector2 p3, Vector2 p4) { int num_segments = 0; ImGuiNative.ImDrawList_PathBezierCubicCurveTo(NativePtr, p2, p3, p4, num_segments); } public unsafe void PathBezierCubicCurveTo(Vector2 p2, Vector2 p3, Vector2 p4, int num_segments) { ImGuiNative.ImDrawList_PathBezierCubicCurveTo(NativePtr, p2, p3, p4, num_segments); } public unsafe void PathBezierQuadraticCurveTo(Vector2 p2, Vector2 p3) { int num_segments = 0; ImGuiNative.ImDrawList_PathBezierQuadraticCurveTo(NativePtr, p2, p3, num_segments); } public unsafe void PathBezierQuadraticCurveTo(Vector2 p2, Vector2 p3, int num_segments) { ImGuiNative.ImDrawList_PathBezierQuadraticCurveTo(NativePtr, p2, p3, num_segments); } public unsafe void PathClear() { ImGuiNative.ImDrawList_PathClear(NativePtr); } public unsafe void PathFillConvex(uint col) { ImGuiNative.ImDrawList_PathFillConvex(NativePtr, col); } public unsafe void PathLineTo(Vector2 pos) { ImGuiNative.ImDrawList_PathLineTo(NativePtr, pos); } public unsafe void PathLineToMergeDuplicate(Vector2 pos) { ImGuiNative.ImDrawList_PathLineToMergeDuplicate(NativePtr, pos); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max) { float rounding = 0f; ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max, float rounding) { ImDrawFlags flags = ImDrawFlags.None; ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathRect(Vector2 rect_min, Vector2 rect_max, float rounding, ImDrawFlags flags) { ImGuiNative.ImDrawList_PathRect(NativePtr, rect_min, rect_max, rounding, flags); } public unsafe void PathStroke(uint col) { ImDrawFlags flags = ImDrawFlags.None; float thickness = 1f; ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PathStroke(uint col, ImDrawFlags flags) { float thickness = 1f; ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PathStroke(uint col, ImDrawFlags flags, float thickness) { ImGuiNative.ImDrawList_PathStroke(NativePtr, col, flags, thickness); } public unsafe void PopClipRect() { ImGuiNative.ImDrawList_PopClipRect(NativePtr); } public unsafe void PopTextureID() { ImGuiNative.ImDrawList_PopTextureID(NativePtr); } public unsafe void PrimQuadUV(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Vector2 uv_a, Vector2 uv_b, Vector2 uv_c, Vector2 uv_d, uint col) { ImGuiNative.ImDrawList_PrimQuadUV(NativePtr, a, b, c, d, uv_a, uv_b, uv_c, uv_d, col); } public unsafe void PrimRect(Vector2 a, Vector2 b, uint col) { ImGuiNative.ImDrawList_PrimRect(NativePtr, a, b, col); } public unsafe void PrimRectUV(Vector2 a, Vector2 b, Vector2 uv_a, Vector2 uv_b, uint col) { ImGuiNative.ImDrawList_PrimRectUV(NativePtr, a, b, uv_a, uv_b, col); } public unsafe void PrimReserve(int idx_count, int vtx_count) { ImGuiNative.ImDrawList_PrimReserve(NativePtr, idx_count, vtx_count); } public unsafe void PrimUnreserve(int idx_count, int vtx_count) { ImGuiNative.ImDrawList_PrimUnreserve(NativePtr, idx_count, vtx_count); } public unsafe void PrimVtx(Vector2 pos, Vector2 uv, uint col) { ImGuiNative.ImDrawList_PrimVtx(NativePtr, pos, uv, col); } public unsafe void PrimWriteIdx(ushort idx) { ImGuiNative.ImDrawList_PrimWriteIdx(NativePtr, idx); } public unsafe void PrimWriteVtx(Vector2 pos, Vector2 uv, uint col) { ImGuiNative.ImDrawList_PrimWriteVtx(NativePtr, pos, uv, col); } public unsafe void PushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max) { byte intersect_with_current_clip_rect = 0; ImGuiNative.ImDrawList_PushClipRect(NativePtr, clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); } public unsafe void PushClipRect(Vector2 clip_rect_min, Vector2 clip_rect_max, bool intersect_with_current_clip_rect) { byte intersect_with_current_clip_rect2 = (byte)(intersect_with_current_clip_rect ? 1 : 0); ImGuiNative.ImDrawList_PushClipRect(NativePtr, clip_rect_min, clip_rect_max, intersect_with_current_clip_rect2); } public unsafe void PushClipRectFullScreen() { ImGuiNative.ImDrawList_PushClipRectFullScreen(NativePtr); } public unsafe void PushTextureID(IntPtr texture_id) { ImGuiNative.ImDrawList_PushTextureID(NativePtr, texture_id); } public unsafe void AddText(Vector2 pos, uint col, string text_begin) { int byteCount = Encoding.UTF8.GetByteCount(text_begin); byte* ptr = stackalloc byte[(int)(uint)(byteCount + 1)]; fixed (char* chars = text_begin) { int bytes = Encoding.UTF8.GetBytes(chars, text_begin.Length, ptr, byteCount); ptr[bytes] = 0; } byte* text_end = null; ImGuiNative.ImDrawList_AddText_Vec2(NativePtr, pos, col, ptr, text_end); } public unsafe void AddText(ImFontPtr font, float font_size, Vector2 pos, uint col, string text_begin) { ImFont* nativePtr = font.NativePtr; int byteCount = Encoding.UTF8.GetByteCount(text_begin); byte* ptr = stackalloc byte[(int)(uint)(byteCount + 1)]; fixed (char* chars = text_begin) { int bytes = Encoding.UTF8.GetBytes(chars, text_begin.Length, ptr, byteCount); ptr[bytes] = 0; } byte* text_end = null; float wrap_width = 0f; Vector4* cpu_fine_clip_rect = null; ImGuiNative.ImDrawList_AddText_FontPtr(NativePtr, nativePtr, font_size, pos, col, ptr, text_end, wrap_width, cpu_fine_clip_rect); } } [Flags] public enum ImDrawListFlags { None = 0, AntiAliasedLines = 1, AntiAliasedLinesUseTex = 2, AntiAliasedFill = 4, AllowVtxOffset = 8 } public struct ImDrawListSplitter { public int _Current; public int _Count; public ImVector _Channels; } public struct ImDrawListSplitterPtr { public unsafe ImDrawListSplitter* NativePtr { get; } public unsafe ref int _Current => ref Unsafe.AsRef<int>(&NativePtr->_Current); public unsafe ref int _Count => ref Unsafe.AsRef<int>(&NativePtr->_Count); public unsafe ImPtrVector<ImDrawChannelPtr> _Channels => new ImPtrVector<ImDrawChannelPtr>(NativePtr->_Channels, Unsafe.SizeOf<ImDrawChannel>()); public unsafe ImDrawListSplitterPtr(ImDrawListSplitter* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawListSplitterPtr(IntPtr nativePtr) { NativePtr = (ImDrawListSplitter*)(void*)nativePtr; } public unsafe static implicit operator ImDrawListSplitterPtr(ImDrawListSplitter* nativePtr) { return new ImDrawListSplitterPtr(nativePtr); } public unsafe static implicit operator ImDrawListSplitter*(ImDrawListSplitterPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawListSplitterPtr(IntPtr nativePtr) { return new ImDrawListSplitterPtr(nativePtr); } public unsafe void Clear() { ImGuiNative.ImDrawListSplitter_Clear(NativePtr); } public unsafe void ClearFreeMemory() { ImGuiNative.ImDrawListSplitter_ClearFreeMemory(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImDrawListSplitter_destroy(NativePtr); } public unsafe void Merge(ImDrawListPtr draw_list) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_Merge(NativePtr, nativePtr); } public unsafe void SetCurrentChannel(ImDrawListPtr draw_list, int channel_idx) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_SetCurrentChannel(NativePtr, nativePtr, channel_idx); } public unsafe void Split(ImDrawListPtr draw_list, int count) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImDrawListSplitter_Split(NativePtr, nativePtr, count); } } public struct ImDrawVert { public Vector2 pos; public Vector2 uv; public uint col; } public struct ImDrawVertPtr { public unsafe ImDrawVert* NativePtr { get; } public unsafe ref Vector2 pos => ref Unsafe.AsRef<Vector2>(&NativePtr->pos); public unsafe ref Vector2 uv => ref Unsafe.AsRef<Vector2>(&NativePtr->uv); public unsafe ref uint col => ref Unsafe.AsRef<uint>(&NativePtr->col); public unsafe ImDrawVertPtr(ImDrawVert* nativePtr) { NativePtr = nativePtr; } public unsafe ImDrawVertPtr(IntPtr nativePtr) { NativePtr = (ImDrawVert*)(void*)nativePtr; } public unsafe static implicit operator ImDrawVertPtr(ImDrawVert* nativePtr) { return new ImDrawVertPtr(nativePtr); } public unsafe static implicit operator ImDrawVert*(ImDrawVertPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImDrawVertPtr(IntPtr nativePtr) { return new ImDrawVertPtr(nativePtr); } } public struct ImFont { public ImVector IndexAdvanceX; public float FallbackAdvanceX; public float FontSize; public ImVector IndexLookup; public ImVector Glyphs; public unsafe ImFontGlyph* FallbackGlyph; public unsafe ImFontAtlas* ContainerAtlas; public unsafe ImFontConfig* ConfigData; public short ConfigDataCount; public ushort FallbackChar; public ushort EllipsisChar; public short EllipsisCharCount; public float EllipsisWidth; public float EllipsisCharStep; public byte DirtyLookupTables; public float Scale; public float Ascent; public float Descent; public int MetricsTotalSurface; public unsafe fixed byte Used4kPagesMap[2]; } public struct ImFontPtr { public unsafe ImFont* NativePtr { get; } public unsafe ImVector<float> IndexAdvanceX => new ImVector<float>(NativePtr->IndexAdvanceX); public unsafe ref float FallbackAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->FallbackAdvanceX); public unsafe ref float FontSize => ref Unsafe.AsRef<float>(&NativePtr->FontSize); public unsafe ImVector<ushort> IndexLookup => new ImVector<ushort>(NativePtr->IndexLookup); public unsafe ImPtrVector<ImFontGlyphPtr> Glyphs => new ImPtrVector<ImFontGlyphPtr>(NativePtr->Glyphs, Unsafe.SizeOf<ImFontGlyph>()); public unsafe ImFontGlyphPtr FallbackGlyph => new ImFontGlyphPtr(NativePtr->FallbackGlyph); public unsafe ImFontAtlasPtr ContainerAtlas => new ImFontAtlasPtr(NativePtr->ContainerAtlas); public unsafe ImFontConfigPtr ConfigData => new ImFontConfigPtr(NativePtr->ConfigData); public unsafe ref short ConfigDataCount => ref Unsafe.AsRef<short>(&NativePtr->ConfigDataCount); public unsafe ref ushort FallbackChar => ref Unsafe.AsRef<ushort>(&NativePtr->FallbackChar); public unsafe ref ushort EllipsisChar => ref Unsafe.AsRef<ushort>(&NativePtr->EllipsisChar); public unsafe ref short EllipsisCharCount => ref Unsafe.AsRef<short>(&NativePtr->EllipsisCharCount); public unsafe ref float EllipsisWidth => ref Unsafe.AsRef<float>(&NativePtr->EllipsisWidth); public unsafe ref float EllipsisCharStep => ref Unsafe.AsRef<float>(&NativePtr->EllipsisCharStep); public unsafe ref bool DirtyLookupTables => ref Unsafe.AsRef<bool>(&NativePtr->DirtyLookupTables); public unsafe ref float Scale => ref Unsafe.AsRef<float>(&NativePtr->Scale); public unsafe ref float Ascent => ref Unsafe.AsRef<float>(&NativePtr->Ascent); public unsafe ref float Descent => ref Unsafe.AsRef<float>(&NativePtr->Descent); public unsafe ref int MetricsTotalSurface => ref Unsafe.AsRef<int>(&NativePtr->MetricsTotalSurface); public unsafe RangeAccessor<byte> Used4kPagesMap => new RangeAccessor<byte>(NativePtr->Used4kPagesMap, 2); public unsafe ImFontPtr(ImFont* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontPtr(IntPtr nativePtr) { NativePtr = (ImFont*)(void*)nativePtr; } public unsafe static implicit operator ImFontPtr(ImFont* nativePtr) { return new ImFontPtr(nativePtr); } public unsafe static implicit operator ImFont*(ImFontPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontPtr(IntPtr nativePtr) { return new ImFontPtr(nativePtr); } public unsafe void AddGlyph(ImFontConfigPtr src_cfg, ushort c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) { ImFontConfig* nativePtr = src_cfg.NativePtr; ImGuiNative.ImFont_AddGlyph(NativePtr, nativePtr, c, x0, y0, x1, y1, u0, v0, u1, v1, advance_x); } public unsafe void AddRemapChar(ushort dst, ushort src) { byte overwrite_dst = 1; ImGuiNative.ImFont_AddRemapChar(NativePtr, dst, src, overwrite_dst); } public unsafe void AddRemapChar(ushort dst, ushort src, bool overwrite_dst) { byte overwrite_dst2 = (byte)(overwrite_dst ? 1 : 0); ImGuiNative.ImFont_AddRemapChar(NativePtr, dst, src, overwrite_dst2); } public unsafe void BuildLookupTable() { ImGuiNative.ImFont_BuildLookupTable(NativePtr); } public unsafe void ClearOutputData() { ImGuiNative.ImFont_ClearOutputData(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFont_destroy(NativePtr); } public unsafe ImFontGlyphPtr FindGlyph(ushort c) { ImFontGlyph* nativePtr = ImGuiNative.ImFont_FindGlyph(NativePtr, c); return new ImFontGlyphPtr(nativePtr); } public unsafe ImFontGlyphPtr FindGlyphNoFallback(ushort c) { ImFontGlyph* nativePtr = ImGuiNative.ImFont_FindGlyphNoFallback(NativePtr, c); return new ImFontGlyphPtr(nativePtr); } public unsafe float GetCharAdvance(ushort c) { return ImGuiNative.ImFont_GetCharAdvance(NativePtr, c); } public unsafe string GetDebugName() { byte* ptr = ImGuiNative.ImFont_GetDebugName(NativePtr); return Util.StringFromPtr(ptr); } public unsafe void GrowIndex(int new_size) { ImGuiNative.ImFont_GrowIndex(NativePtr, new_size); } public unsafe bool IsLoaded() { byte b = ImGuiNative.ImFont_IsLoaded(NativePtr); return b != 0; } public unsafe void RenderChar(ImDrawListPtr draw_list, float size, Vector2 pos, uint col, ushort c) { ImDrawList* nativePtr = draw_list.NativePtr; ImGuiNative.ImFont_RenderChar(NativePtr, nativePtr, size, pos, col, c); } public unsafe void SetGlyphVisible(ushort c, bool visible) { byte visible2 = (byte)(visible ? 1 : 0); ImGuiNative.ImFont_SetGlyphVisible(NativePtr, c, visible2); } } public struct ImFontAtlas { public ImFontAtlasFlags Flags; public IntPtr TexID; public int TexDesiredWidth; public int TexGlyphPadding; public byte Locked; public unsafe void* UserData; public byte TexReady; public byte TexPixelsUseColors; public unsafe byte* TexPixelsAlpha8; public unsafe uint* TexPixelsRGBA32; public int TexWidth; public int TexHeight; public Vector2 TexUvScale; public Vector2 TexUvWhitePixel; public ImVector Fonts; public ImVector CustomRects; public ImVector ConfigData; public Vector4 TexUvLines_0; public Vector4 TexUvLines_1; public Vector4 TexUvLines_2; public Vector4 TexUvLines_3; public Vector4 TexUvLines_4; public Vector4 TexUvLines_5; public Vector4 TexUvLines_6; public Vector4 TexUvLines_7; public Vector4 TexUvLines_8; public Vector4 TexUvLines_9; public Vector4 TexUvLines_10; public Vector4 TexUvLines_11; public Vector4 TexUvLines_12; public Vector4 TexUvLines_13; public Vector4 TexUvLines_14; public Vector4 TexUvLines_15; public Vector4 TexUvLines_16; public Vector4 TexUvLines_17; public Vector4 TexUvLines_18; public Vector4 TexUvLines_19; public Vector4 TexUvLines_20; public Vector4 TexUvLines_21; public Vector4 TexUvLines_22; public Vector4 TexUvLines_23; public Vector4 TexUvLines_24; public Vector4 TexUvLines_25; public Vector4 TexUvLines_26; public Vector4 TexUvLines_27; public Vector4 TexUvLines_28; public Vector4 TexUvLines_29; public Vector4 TexUvLines_30; public Vector4 TexUvLines_31; public Vector4 TexUvLines_32; public Vector4 TexUvLines_33; public Vector4 TexUvLines_34; public Vector4 TexUvLines_35; public Vector4 TexUvLines_36; public Vector4 TexUvLines_37; public Vector4 TexUvLines_38; public Vector4 TexUvLines_39; public Vector4 TexUvLines_40; public Vector4 TexUvLines_41; public Vector4 TexUvLines_42; public Vector4 TexUvLines_43; public Vector4 TexUvLines_44; public Vector4 TexUvLines_45; public Vector4 TexUvLines_46; public Vector4 TexUvLines_47; public Vector4 TexUvLines_48; public Vector4 TexUvLines_49; public Vector4 TexUvLines_50; public Vector4 TexUvLines_51; public Vector4 TexUvLines_52; public Vector4 TexUvLines_53; public Vector4 TexUvLines_54; public Vector4 TexUvLines_55; public Vector4 TexUvLines_56; public Vector4 TexUvLines_57; public Vector4 TexUvLines_58; public Vector4 TexUvLines_59; public Vector4 TexUvLines_60; public Vector4 TexUvLines_61; public Vector4 TexUvLines_62; public Vector4 TexUvLines_63; public unsafe IntPtr* FontBuilderIO; public uint FontBuilderFlags; public int PackIdMouseCursors; public int PackIdLines; } public struct ImFontAtlasPtr { public unsafe ImFontAtlas* NativePtr { get; } public unsafe ref ImFontAtlasFlags Flags => ref Unsafe.AsRef<ImFontAtlasFlags>(&NativePtr->Flags); public unsafe ref IntPtr TexID => ref Unsafe.AsRef<IntPtr>(&NativePtr->TexID); public unsafe ref int TexDesiredWidth => ref Unsafe.AsRef<int>(&NativePtr->TexDesiredWidth); public unsafe ref int TexGlyphPadding => ref Unsafe.AsRef<int>(&NativePtr->TexGlyphPadding); public unsafe ref bool Locked => ref Unsafe.AsRef<bool>(&NativePtr->Locked); public unsafe IntPtr UserData { get { return (IntPtr)NativePtr->UserData; } set { NativePtr->UserData = (void*)value; } } public unsafe ref bool TexReady => ref Unsafe.AsRef<bool>(&NativePtr->TexReady); public unsafe ref bool TexPixelsUseColors => ref Unsafe.AsRef<bool>(&NativePtr->TexPixelsUseColors); public unsafe IntPtr TexPixelsAlpha8 { get { return (IntPtr)NativePtr->TexPixelsAlpha8; } set { NativePtr->TexPixelsAlpha8 = (byte*)(void*)value; } } public unsafe IntPtr TexPixelsRGBA32 { get { return (IntPtr)NativePtr->TexPixelsRGBA32; } set { NativePtr->TexPixelsRGBA32 = (uint*)(void*)value; } } public unsafe ref int TexWidth => ref Unsafe.AsRef<int>(&NativePtr->TexWidth); public unsafe ref int TexHeight => ref Unsafe.AsRef<int>(&NativePtr->TexHeight); public unsafe ref Vector2 TexUvScale => ref Unsafe.AsRef<Vector2>(&NativePtr->TexUvScale); public unsafe ref Vector2 TexUvWhitePixel => ref Unsafe.AsRef<Vector2>(&NativePtr->TexUvWhitePixel); public unsafe ImVector<ImFontPtr> Fonts => new ImVector<ImFontPtr>(NativePtr->Fonts); public unsafe ImPtrVector<ImFontAtlasCustomRectPtr> CustomRects => new ImPtrVector<ImFontAtlasCustomRectPtr>(NativePtr->CustomRects, Unsafe.SizeOf<ImFontAtlasCustomRect>()); public unsafe ImPtrVector<ImFontConfigPtr> ConfigData => new ImPtrVector<ImFontConfigPtr>(NativePtr->ConfigData, Unsafe.SizeOf<ImFontConfig>()); public unsafe RangeAccessor<Vector4> TexUvLines => new RangeAccessor<Vector4>(&NativePtr->TexUvLines_0, 64); public unsafe IntPtr FontBuilderIO { get { return (IntPtr)NativePtr->FontBuilderIO; } set { NativePtr->FontBuilderIO = (IntPtr*)(void*)value; } } public unsafe ref uint FontBuilderFlags => ref Unsafe.AsRef<uint>(&NativePtr->FontBuilderFlags); public unsafe ref int PackIdMouseCursors => ref Unsafe.AsRef<int>(&NativePtr->PackIdMouseCursors); public unsafe ref int PackIdLines => ref Unsafe.AsRef<int>(&NativePtr->PackIdLines); public unsafe ImFontAtlasPtr(ImFontAtlas* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontAtlasPtr(IntPtr nativePtr) { NativePtr = (ImFontAtlas*)(void*)nativePtr; } public unsafe static implicit operator ImFontAtlasPtr(ImFontAtlas* nativePtr) { return new ImFontAtlasPtr(nativePtr); } public unsafe static implicit operator ImFontAtlas*(ImFontAtlasPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontAtlasPtr(IntPtr nativePtr) { return new ImFontAtlasPtr(nativePtr); } public unsafe int AddCustomRectFontGlyph(ImFontPtr font, ushort id, int width, int height, float advance_x) { ImFont* nativePtr = font.NativePtr; return ImGuiNative.ImFontAtlas_AddCustomRectFontGlyph(NativePtr, nativePtr, id, width, height, advance_x, default(Vector2)); } public unsafe int AddCustomRectFontGlyph(ImFontPtr font, ushort id, int width, int height, float advance_x, Vector2 offset) { ImFont* nativePtr = font.NativePtr; return ImGuiNative.ImFontAtlas_AddCustomRectFontGlyph(NativePtr, nativePtr, id, width, height, advance_x, offset); } public unsafe int AddCustomRectRegular(int width, int height) { return ImGuiNative.ImFontAtlas_AddCustomRectRegular(NativePtr, width, height); } public unsafe ImFontPtr AddFont(ImFontConfigPtr font_cfg) { ImFontConfig* nativePtr = font_cfg.NativePtr; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFont(NativePtr, nativePtr); return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontDefault() { ImFontConfig* font_cfg = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontDefault(NativePtr, font_cfg); return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontDefault(ImFontConfigPtr font_cfg) { ImFontConfig* nativePtr = font_cfg.NativePtr; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontDefault(NativePtr, nativePtr); return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, font_cfg, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromFileTTF(string filename, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { int num = 0; byte* ptr; if (filename != null) { num = Encoding.UTF8.GetByteCount(filename); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(filename, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromFileTTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges2); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, font_cfg, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedBase85TTF(string compressed_font_data_base85, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { int num = 0; byte* ptr; if (compressed_font_data_base85 != null) { num = Encoding.UTF8.GetByteCount(compressed_font_data_base85); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(compressed_font_data_base85, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedBase85TTF(NativePtr, ptr, size_pixels, nativePtr, glyph_ranges2); if (num > 2048) { Util.Free(ptr); } return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, font_cfg, glyph_ranges); return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels, ImFontConfigPtr font_cfg) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, nativePtr, glyph_ranges); return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryCompressedTTF(IntPtr compressed_font_data, int compressed_font_size, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { void* compressed_font_data2 = compressed_font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryCompressedTTF(NativePtr, compressed_font_data2, compressed_font_size, size_pixels, nativePtr, glyph_ranges2); return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels) { void* font_data2 = font_data.ToPointer(); ImFontConfig* font_cfg = null; ushort* glyph_ranges = null; ImFont* nativePtr = ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, font_cfg, glyph_ranges); return new ImFontPtr(nativePtr); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels, ImFontConfigPtr font_cfg) { void* font_data2 = font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges = null; ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, nativePtr, glyph_ranges); return new ImFontPtr(nativePtr2); } public unsafe ImFontPtr AddFontFromMemoryTTF(IntPtr font_data, int font_size, float size_pixels, ImFontConfigPtr font_cfg, IntPtr glyph_ranges) { void* font_data2 = font_data.ToPointer(); ImFontConfig* nativePtr = font_cfg.NativePtr; ushort* glyph_ranges2 = (ushort*)glyph_ranges.ToPointer(); ImFont* nativePtr2 = ImGuiNative.ImFontAtlas_AddFontFromMemoryTTF(NativePtr, font_data2, font_size, size_pixels, nativePtr, glyph_ranges2); return new ImFontPtr(nativePtr2); } public unsafe bool Build() { byte b = ImGuiNative.ImFontAtlas_Build(NativePtr); return b != 0; } public unsafe void CalcCustomRectUV(ImFontAtlasCustomRectPtr rect, out Vector2 out_uv_min, out Vector2 out_uv_max) { ImFontAtlasCustomRect* nativePtr = rect.NativePtr; fixed (Vector2* out_uv_min2 = &out_uv_min) { fixed (Vector2* out_uv_max2 = &out_uv_max) { ImGuiNative.ImFontAtlas_CalcCustomRectUV(NativePtr, nativePtr, out_uv_min2, out_uv_max2); } } } public unsafe void Clear() { ImGuiNative.ImFontAtlas_Clear(NativePtr); } public unsafe void ClearFonts() { ImGuiNative.ImFontAtlas_ClearFonts(NativePtr); } public unsafe void ClearInputData() { ImGuiNative.ImFontAtlas_ClearInputData(NativePtr); } public unsafe void ClearTexData() { ImGuiNative.ImFontAtlas_ClearTexData(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontAtlas_destroy(NativePtr); } public unsafe ImFontAtlasCustomRectPtr GetCustomRectByIndex(int index) { ImFontAtlasCustomRect* nativePtr = ImGuiNative.ImFontAtlas_GetCustomRectByIndex(NativePtr, index); return new ImFontAtlasCustomRectPtr(nativePtr); } public unsafe IntPtr GetGlyphRangesChineseFull() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesChineseFull(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesChineseSimplifiedCommon() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesChineseSimplifiedCommon(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesCyrillic() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesCyrillic(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesDefault() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesDefault(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesGreek() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesGreek(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesJapanese() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesJapanese(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesKorean() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesKorean(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesThai() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesThai(NativePtr); return (IntPtr)ptr; } public unsafe IntPtr GetGlyphRangesVietnamese() { ushort* ptr = ImGuiNative.ImFontAtlas_GetGlyphRangesVietnamese(NativePtr); return (IntPtr)ptr; } public unsafe bool GetMouseCursorTexData(ImGuiMouseCursor cursor, out Vector2 out_offset, out Vector2 out_size, out Vector2 out_uv_border, out Vector2 out_uv_fill) { fixed (Vector2* out_offset2 = &out_offset) { fixed (Vector2* out_size2 = &out_size) { fixed (Vector2* out_uv_border2 = &out_uv_border) { fixed (Vector2* out_uv_fill2 = &out_uv_fill) { byte b = ImGuiNative.ImFontAtlas_GetMouseCursorTexData(NativePtr, cursor, out_offset2, out_size2, out_uv_border2, out_uv_fill2); return b != 0; } } } } } public unsafe void GetTexDataAsAlpha8(out byte* out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsAlpha8(out byte* out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsAlpha8(out IntPtr out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsAlpha8(out IntPtr out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsAlpha8(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsRGBA32(out byte* out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsRGBA32(out byte* out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (byte** out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe void GetTexDataAsRGBA32(out IntPtr out_pixels, out int out_width, out int out_height) { int* out_bytes_per_pixel = null; fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel); } } } } public unsafe void GetTexDataAsRGBA32(out IntPtr out_pixels, out int out_width, out int out_height, out int out_bytes_per_pixel) { fixed (IntPtr* out_pixels2 = &out_pixels) { fixed (int* out_width2 = &out_width) { fixed (int* out_height2 = &out_height) { fixed (int* out_bytes_per_pixel2 = &out_bytes_per_pixel) { ImGuiNative.ImFontAtlas_GetTexDataAsRGBA32(NativePtr, out_pixels2, out_width2, out_height2, out_bytes_per_pixel2); } } } } } public unsafe bool IsBuilt() { byte b = ImGuiNative.ImFontAtlas_IsBuilt(NativePtr); return b != 0; } public unsafe void SetTexID(IntPtr id) { ImGuiNative.ImFontAtlas_SetTexID(NativePtr, id); } } public struct ImFontAtlasCustomRect { public ushort Width; public ushort Height; public ushort X; public ushort Y; public uint GlyphID; public float GlyphAdvanceX; public Vector2 GlyphOffset; public unsafe ImFont* Font; } public struct ImFontAtlasCustomRectPtr { public unsafe ImFontAtlasCustomRect* NativePtr { get; } public unsafe ref ushort Width => ref Unsafe.AsRef<ushort>(&NativePtr->Width); public unsafe ref ushort Height => ref Unsafe.AsRef<ushort>(&NativePtr->Height); public unsafe ref ushort X => ref Unsafe.AsRef<ushort>(&NativePtr->X); public unsafe ref ushort Y => ref Unsafe.AsRef<ushort>(&NativePtr->Y); public unsafe ref uint GlyphID => ref Unsafe.AsRef<uint>(&NativePtr->GlyphID); public unsafe ref float GlyphAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphAdvanceX); public unsafe ref Vector2 GlyphOffset => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphOffset); public unsafe ImFontPtr Font => new ImFontPtr(NativePtr->Font); public unsafe ImFontAtlasCustomRectPtr(ImFontAtlasCustomRect* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontAtlasCustomRectPtr(IntPtr nativePtr) { NativePtr = (ImFontAtlasCustomRect*)(void*)nativePtr; } public unsafe static implicit operator ImFontAtlasCustomRectPtr(ImFontAtlasCustomRect* nativePtr) { return new ImFontAtlasCustomRectPtr(nativePtr); } public unsafe static implicit operator ImFontAtlasCustomRect*(ImFontAtlasCustomRectPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontAtlasCustomRectPtr(IntPtr nativePtr) { return new ImFontAtlasCustomRectPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontAtlasCustomRect_destroy(NativePtr); } public unsafe bool IsPacked() { byte b = ImGuiNative.ImFontAtlasCustomRect_IsPacked(NativePtr); return b != 0; } } [Flags] public enum ImFontAtlasFlags { None = 0, NoPowerOfTwoHeight = 1, NoMouseCursors = 2, NoBakedLines = 4 } public struct ImFontConfig { public unsafe void* FontData; public int FontDataSize; public byte FontDataOwnedByAtlas; public int FontNo; public float SizePixels; public int OversampleH; public int OversampleV; public byte PixelSnapH; public Vector2 GlyphExtraSpacing; public Vector2 GlyphOffset; public unsafe ushort* GlyphRanges; public float GlyphMinAdvanceX; public float GlyphMaxAdvanceX; public byte MergeMode; public uint FontBuilderFlags; public float RasterizerMultiply; public ushort EllipsisChar; public unsafe fixed byte Name[40]; public unsafe ImFont* DstFont; } public struct ImFontConfigPtr { public unsafe ImFontConfig* NativePtr { get; } public unsafe IntPtr FontData { get { return (IntPtr)NativePtr->FontData; } set { NativePtr->FontData = (void*)value; } } public unsafe ref int FontDataSize => ref Unsafe.AsRef<int>(&NativePtr->FontDataSize); public unsafe ref bool FontDataOwnedByAtlas => ref Unsafe.AsRef<bool>(&NativePtr->FontDataOwnedByAtlas); public unsafe ref int FontNo => ref Unsafe.AsRef<int>(&NativePtr->FontNo); public unsafe ref float SizePixels => ref Unsafe.AsRef<float>(&NativePtr->SizePixels); public unsafe ref int OversampleH => ref Unsafe.AsRef<int>(&NativePtr->OversampleH); public unsafe ref int OversampleV => ref Unsafe.AsRef<int>(&NativePtr->OversampleV); public unsafe ref bool PixelSnapH => ref Unsafe.AsRef<bool>(&NativePtr->PixelSnapH); public unsafe ref Vector2 GlyphExtraSpacing => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphExtraSpacing); public unsafe ref Vector2 GlyphOffset => ref Unsafe.AsRef<Vector2>(&NativePtr->GlyphOffset); public unsafe IntPtr GlyphRanges { get { return (IntPtr)NativePtr->GlyphRanges; } set { NativePtr->GlyphRanges = (ushort*)(void*)value; } } public unsafe ref float GlyphMinAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphMinAdvanceX); public unsafe ref float GlyphMaxAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->GlyphMaxAdvanceX); public unsafe ref bool MergeMode => ref Unsafe.AsRef<bool>(&NativePtr->MergeMode); public unsafe ref uint FontBuilderFlags => ref Unsafe.AsRef<uint>(&NativePtr->FontBuilderFlags); public unsafe ref float RasterizerMultiply => ref Unsafe.AsRef<float>(&NativePtr->RasterizerMultiply); public unsafe ref ushort EllipsisChar => ref Unsafe.AsRef<ushort>(&NativePtr->EllipsisChar); public unsafe RangeAccessor<byte> Name => new RangeAccessor<byte>(NativePtr->Name, 40); public unsafe ImFontPtr DstFont => new ImFontPtr(NativePtr->DstFont); public unsafe ImFontConfigPtr(ImFontConfig* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontConfigPtr(IntPtr nativePtr) { NativePtr = (ImFontConfig*)(void*)nativePtr; } public unsafe static implicit operator ImFontConfigPtr(ImFontConfig* nativePtr) { return new ImFontConfigPtr(nativePtr); } public unsafe static implicit operator ImFontConfig*(ImFontConfigPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontConfigPtr(IntPtr nativePtr) { return new ImFontConfigPtr(nativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontConfig_destroy(NativePtr); } } public struct ImFontGlyph { public uint Colored; public uint Visible; public uint Codepoint; public float AdvanceX; public float X0; public float Y0; public float X1; public float Y1; public float U0; public float V0; public float U1; public float V1; } public struct ImFontGlyphPtr { public unsafe ImFontGlyph* NativePtr { get; } public unsafe ref uint Colored => ref Unsafe.AsRef<uint>(&NativePtr->Colored); public unsafe ref uint Visible => ref Unsafe.AsRef<uint>(&NativePtr->Visible); public unsafe ref uint Codepoint => ref Unsafe.AsRef<uint>(&NativePtr->Codepoint); public unsafe ref float AdvanceX => ref Unsafe.AsRef<float>(&NativePtr->AdvanceX); public unsafe ref float X0 => ref Unsafe.AsRef<float>(&NativePtr->X0); public unsafe ref float Y0 => ref Unsafe.AsRef<float>(&NativePtr->Y0); public unsafe ref float X1 => ref Unsafe.AsRef<float>(&NativePtr->X1); public unsafe ref float Y1 => ref Unsafe.AsRef<float>(&NativePtr->Y1); public unsafe ref float U0 => ref Unsafe.AsRef<float>(&NativePtr->U0); public unsafe ref float V0 => ref Unsafe.AsRef<float>(&NativePtr->V0); public unsafe ref float U1 => ref Unsafe.AsRef<float>(&NativePtr->U1); public unsafe ref float V1 => ref Unsafe.AsRef<float>(&NativePtr->V1); public unsafe ImFontGlyphPtr(ImFontGlyph* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontGlyphPtr(IntPtr nativePtr) { NativePtr = (ImFontGlyph*)(void*)nativePtr; } public unsafe static implicit operator ImFontGlyphPtr(ImFontGlyph* nativePtr) { return new ImFontGlyphPtr(nativePtr); } public unsafe static implicit operator ImFontGlyph*(ImFontGlyphPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontGlyphPtr(IntPtr nativePtr) { return new ImFontGlyphPtr(nativePtr); } } public struct ImFontGlyphRangesBuilder { public ImVector UsedChars; } public struct ImFontGlyphRangesBuilderPtr { public unsafe ImFontGlyphRangesBuilder* NativePtr { get; } public unsafe ImVector<uint> UsedChars => new ImVector<uint>(NativePtr->UsedChars); public unsafe ImFontGlyphRangesBuilderPtr(ImFontGlyphRangesBuilder* nativePtr) { NativePtr = nativePtr; } public unsafe ImFontGlyphRangesBuilderPtr(IntPtr nativePtr) { NativePtr = (ImFontGlyphRangesBuilder*)(void*)nativePtr; } public unsafe static implicit operator ImFontGlyphRangesBuilderPtr(ImFontGlyphRangesBuilder* nativePtr) { return new ImFontGlyphRangesBuilderPtr(nativePtr); } public unsafe static implicit operator ImFontGlyphRangesBuilder*(ImFontGlyphRangesBuilderPtr wrappedPtr) { return wrappedPtr.NativePtr; } public static implicit operator ImFontGlyphRangesBuilderPtr(IntPtr nativePtr) { return new ImFontGlyphRangesBuilderPtr(nativePtr); } public unsafe void AddChar(ushort c) { ImGuiNative.ImFontGlyphRangesBuilder_AddChar(NativePtr, c); } public unsafe void AddRanges(IntPtr ranges) { ushort* ranges2 = (ushort*)ranges.ToPointer(); ImGuiNative.ImFontGlyphRangesBuilder_AddRanges(NativePtr, ranges2); } public unsafe void AddText(string text) { int num = 0; byte* ptr; if (text != null) { num = Encoding.UTF8.GetByteCount(text); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(text, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* text_end = null; ImGuiNative.ImFontGlyphRangesBuilder_AddText(NativePtr, ptr, text_end); if (num > 2048) { Util.Free(ptr); } } public unsafe void BuildRanges(out ImVector out_ranges) { fixed (ImVector* out_ranges2 = &out_ranges) { ImGuiNative.ImFontGlyphRangesBuilder_BuildRanges(NativePtr, out_ranges2); } } public unsafe void Clear() { ImGuiNative.ImFontGlyphRangesBuilder_Clear(NativePtr); } public unsafe void Destroy() { ImGuiNative.ImFontGlyphRangesBuilder_destroy(NativePtr); } public unsafe bool GetBit(uint n) { byte b = ImGuiNative.ImFontGlyphRangesBuilder_GetBit(NativePtr, n); return b != 0; } public unsafe void SetBit(uint n) { ImGuiNative.ImFontGlyphRangesBuilder_SetBit(NativePtr, n); } } public static class ImGui { public unsafe static ImGuiPayloadPtr AcceptDragDropPayload(string type) { int num = 0; byte* ptr; if (type != null) { num = Encoding.UTF8.GetByteCount(type); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(type, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiDragDropFlags flags = ImGuiDragDropFlags.None; ImGuiPayload* nativePtr = ImGuiNative.igAcceptDragDropPayload(ptr, flags); if (num > 2048) { Util.Free(ptr); } return new ImGuiPayloadPtr(nativePtr); } public unsafe static ImGuiPayloadPtr AcceptDragDropPayload(string type, ImGuiDragDropFlags flags) { int num = 0; byte* ptr; if (type != null) { num = Encoding.UTF8.GetByteCount(type); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(type, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPayload* nativePtr = ImGuiNative.igAcceptDragDropPayload(ptr, flags); if (num > 2048) { Util.Free(ptr); } return new ImGuiPayloadPtr(nativePtr); } public static void AlignTextToFramePadding() { ImGuiNative.igAlignTextToFramePadding(); } public unsafe static bool ArrowButton(string str_id, ImGuiDir dir) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igArrowButton(ptr, dir); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool Begin(string name) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBegin(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool Begin(string name, ref bool p_open) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b2 = ImGuiNative.igBegin(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool Begin(string name, ref bool p_open, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte b2 = ImGuiNative.igBegin(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool BeginChild(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } Vector2 size = default(Vector2); byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_Str(ptr, size, border, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_Str(ptr, size, border, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size, bool border) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border2 = (byte)(border ? 1 : 0); ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_Str(ptr, size, border2, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginChild(string str_id, Vector2 size, bool border, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte border2 = (byte)(border ? 1 : 0); byte b = ImGuiNative.igBeginChild_Str(ptr, size, border2, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public static bool BeginChild(uint id) { Vector2 size = default(Vector2); byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_ID(id, size, border, flags); return b != 0; } public static bool BeginChild(uint id, Vector2 size) { byte border = 0; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_ID(id, size, border, flags); return b != 0; } public static bool BeginChild(uint id, Vector2 size, bool border) { byte border2 = (byte)(border ? 1 : 0); ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChild_ID(id, size, border2, flags); return b != 0; } public static bool BeginChild(uint id, Vector2 size, bool border, ImGuiWindowFlags flags) { byte border2 = (byte)(border ? 1 : 0); byte b = ImGuiNative.igBeginChild_ID(id, size, border2, flags); return b != 0; } public static bool BeginChildFrame(uint id, Vector2 size) { ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginChildFrame(id, size, flags); return b != 0; } public static bool BeginChildFrame(uint id, Vector2 size, ImGuiWindowFlags flags) { byte b = ImGuiNative.igBeginChildFrame(id, size, flags); return b != 0; } public unsafe static bool BeginCombo(string label, string preview_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } int num2 = 0; byte* ptr3; if (preview_value != null) { num2 = Encoding.UTF8.GetByteCount(preview_value); if (num2 > 2048) { ptr3 = Util.Allocate(num2 + 1); } else { byte* ptr4 = stackalloc byte[(int)(uint)(num2 + 1)]; ptr3 = ptr4; } int utf2 = Util.GetUtf8(preview_value, ptr3, num2); ptr3[utf2] = 0; } else { ptr3 = null; } ImGuiComboFlags flags = ImGuiComboFlags.None; byte b = ImGuiNative.igBeginCombo(ptr, ptr3, flags); if (num > 2048) { Util.Free(ptr); } if (num2 > 2048) { Util.Free(ptr3); } return b != 0; } public unsafe static bool BeginCombo(string label, string preview_value, ImGuiComboFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } int num2 = 0; byte* ptr3; if (preview_value != null) { num2 = Encoding.UTF8.GetByteCount(preview_value); if (num2 > 2048) { ptr3 = Util.Allocate(num2 + 1); } else { byte* ptr4 = stackalloc byte[(int)(uint)(num2 + 1)]; ptr3 = ptr4; } int utf2 = Util.GetUtf8(preview_value, ptr3, num2); ptr3[utf2] = 0; } else { ptr3 = null; } byte b = ImGuiNative.igBeginCombo(ptr, ptr3, flags); if (num > 2048) { Util.Free(ptr); } if (num2 > 2048) { Util.Free(ptr3); } return b != 0; } public static void BeginDisabled() { byte disabled = 1; ImGuiNative.igBeginDisabled(disabled); } public static void BeginDisabled(bool disabled) { byte disabled2 = (byte)(disabled ? 1 : 0); ImGuiNative.igBeginDisabled(disabled2); } public static bool BeginDragDropSource() { ImGuiDragDropFlags flags = ImGuiDragDropFlags.None; byte b = ImGuiNative.igBeginDragDropSource(flags); return b != 0; } public static bool BeginDragDropSource(ImGuiDragDropFlags flags) { byte b = ImGuiNative.igBeginDragDropSource(flags); return b != 0; } public static bool BeginDragDropTarget() { byte b = ImGuiNative.igBeginDragDropTarget(); return b != 0; } public static void BeginGroup() { ImGuiNative.igBeginGroup(); } public unsafe static bool BeginListBox(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginListBox(ptr, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginListBox(string label, Vector2 size) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginListBox(ptr, size); if (num > 2048) { Util.Free(ptr); } return b != 0; } public static bool BeginMainMenuBar() { byte b = ImGuiNative.igBeginMainMenuBar(); return b != 0; } public unsafe static bool BeginMenu(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte enabled = 1; byte b = ImGuiNative.igBeginMenu(ptr, enabled); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginMenu(string label, bool enabled) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte enabled2 = (byte)(enabled ? 1 : 0); byte b = ImGuiNative.igBeginMenu(ptr, enabled2); if (num > 2048) { Util.Free(ptr); } return b != 0; } public static bool BeginMenuBar() { byte b = ImGuiNative.igBeginMenuBar(); return b != 0; } public unsafe static bool BeginPopup(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginPopup(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopup(string str_id, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginPopup(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextItem() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextItem(str_id, popup_flags); return b != 0; } public unsafe static bool BeginPopupContextItem(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextItem(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextItem(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginPopupContextItem(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextVoid() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextVoid(str_id, popup_flags); return b != 0; } public unsafe static bool BeginPopupContextVoid(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextVoid(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextVoid(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginPopupContextVoid(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextWindow() { byte* str_id = null; ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextWindow(str_id, popup_flags); return b != 0; } public unsafe static bool BeginPopupContextWindow(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiPopupFlags popup_flags = ImGuiPopupFlags.MouseButtonRight; byte b = ImGuiNative.igBeginPopupContextWindow(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupContextWindow(string str_id, ImGuiPopupFlags popup_flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginPopupContextWindow(ptr, popup_flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupModal(string name) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b = ImGuiNative.igBeginPopupModal(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginPopupModal(string name, ref bool p_open) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiWindowFlags flags = ImGuiWindowFlags.None; byte b2 = ImGuiNative.igBeginPopupModal(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool BeginPopupModal(string name, ref bool p_open, ImGuiWindowFlags flags) { int num = 0; byte* ptr; if (name != null) { num = Encoding.UTF8.GetByteCount(name); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(name, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte b2 = ImGuiNative.igBeginPopupModal(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool BeginTabBar(string str_id) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTabBarFlags flags = ImGuiTabBarFlags.None; byte b = ImGuiNative.igBeginTabBar(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTabBar(string str_id, ImGuiTabBarFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginTabBar(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTabItem(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte* p_open = null; ImGuiTabItemFlags flags = ImGuiTabItemFlags.None; byte b = ImGuiNative.igBeginTabItem(ptr, p_open, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTabItem(string label, ref bool p_open) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; ImGuiTabItemFlags flags = ImGuiTabItemFlags.None; byte b2 = ImGuiNative.igBeginTabItem(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool BeginTabItem(string label, ref bool p_open, ImGuiTabItemFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_open ? 1 : 0); byte* p_open2 = &b; byte b2 = ImGuiNative.igBeginTabItem(ptr, p_open2, flags); if (num > 2048) { Util.Free(ptr); } p_open = b != 0; return b2 != 0; } public unsafe static bool BeginTable(string str_id, int column) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTableFlags flags = ImGuiTableFlags.None; Vector2 outer_size = default(Vector2); float inner_width = 0f; byte b = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } Vector2 outer_size = default(Vector2); float inner_width = 0f; byte b = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags, Vector2 outer_size) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } float inner_width = 0f; byte b = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool BeginTable(string str_id, int column, ImGuiTableFlags flags, Vector2 outer_size, float inner_width) { int num = 0; byte* ptr; if (str_id != null) { num = Encoding.UTF8.GetByteCount(str_id); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(str_id, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igBeginTable(ptr, column, flags, outer_size, inner_width); if (num > 2048) { Util.Free(ptr); } return b != 0; } public static bool BeginTooltip() { byte b = ImGuiNative.igBeginTooltip(); return b != 0; } public static void Bullet() { ImGuiNative.igBullet(); } public unsafe static void BulletText(string fmt) { int num = 0; byte* ptr; if (fmt != null) { num = Encoding.UTF8.GetByteCount(fmt); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(fmt, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiNative.igBulletText(ptr); if (num > 2048) { Util.Free(ptr); } } public unsafe static bool Button(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igButton(ptr, default(Vector2)); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool Button(string label, Vector2 size) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igButton(ptr, size); if (num > 2048) { Util.Free(ptr); } return b != 0; } public static float CalcItemWidth() { return ImGuiNative.igCalcItemWidth(); } public unsafe static bool Checkbox(string label, ref bool v) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(v ? 1 : 0); byte* v2 = &b; byte b2 = ImGuiNative.igCheckbox(ptr, v2); if (num > 2048) { Util.Free(ptr); } v = b != 0; return b2 != 0; } public unsafe static bool CheckboxFlags(string label, ref int flags, int flags_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (int* flags2 = &flags) { byte b = ImGuiNative.igCheckboxFlags_IntPtr(ptr, flags2, flags_value); if (num > 2048) { Util.Free(ptr); } return b != 0; } } public unsafe static bool CheckboxFlags(string label, ref uint flags, uint flags_value) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } fixed (uint* flags2 = &flags) { byte b = ImGuiNative.igCheckboxFlags_UintPtr(ptr, flags2, flags_value); if (num > 2048) { Util.Free(ptr); } return b != 0; } } public static void CloseCurrentPopup() { ImGuiNative.igCloseCurrentPopup(); } public unsafe static bool CollapsingHeader(string label) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None; byte b = ImGuiNative.igCollapsingHeader_TreeNodeFlags(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool CollapsingHeader(string label, ImGuiTreeNodeFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = ImGuiNative.igCollapsingHeader_TreeNodeFlags(ptr, flags); if (num > 2048) { Util.Free(ptr); } return b != 0; } public unsafe static bool CollapsingHeader(string label, ref bool p_visible) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.Allocate(num + 1); } else { byte* ptr2 = stackalloc byte[(int)(uint)(num + 1)]; ptr = ptr2; } int utf = Util.GetUtf8(label, ptr, num); ptr[utf] = 0; } else { ptr = null; } byte b = (byte)(p_visible ? 1 : 0); byte* p_visible2 = &b; ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.None; byte b2 = ImGuiNative.igCollapsingHeader_BoolPtr(ptr, p_visible2, flags); if (num > 2048) { Util.Free(ptr); } p_visible = b != 0; return b2 != 0; } public unsafe static bool CollapsingHeader(string label, ref bool p_visible, ImGuiTreeNodeFlags flags) { int num = 0; byte* ptr; if (label != null) { num = Encoding.UTF8.GetByteCount(label); if (num > 2048) { ptr = Util.
BepInEx/plugins/DearImGuiInjection/System.Linq.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using FxResources.System.Linq; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Linq")] [assembly: AssemblyDescription("System.Linq")] [assembly: AssemblyDefaultAlias("System.Linq")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.1.1.0")] namespace FxResources.System.Linq { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Linq.SR"; private static ResourceManager ResourceManager { get { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string EmptyEnumerable => GetResourceString("EmptyEnumerable", null); internal static string MoreThanOneElement => GetResourceString("MoreThanOneElement", null); internal static string MoreThanOneMatch => GetResourceString("MoreThanOneMatch", null); internal static string NoElements => GetResourceString("NoElements", null); internal static string NoMatch => GetResourceString("NoMatch", null); internal static System.Type ResourceType => typeof(FxResources.System.Linq.SR); [MethodImpl(8)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, (StringComparison)4)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", new object[2] { resourceFormat, p1 }); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", new object[3] { resourceFormat, p1, p2 }); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", new object[4] { resourceFormat, p1, p2, p3 }); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Linq { public static class Enumerable { private abstract class AppendPrependIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { protected readonly System.Collections.Generic.IEnumerable<TSource> _source; protected System.Collections.Generic.IEnumerator<TSource> _enumerator; protected AppendPrependIterator(System.Collections.Generic.IEnumerable<TSource> source) { _source = source; } protected void GetSourceEnumerator() { _enumerator = _source.GetEnumerator(); } public abstract AppendPrependIterator<TSource> Append(TSource item); public abstract AppendPrependIterator<TSource> Prepend(TSource item); protected bool LoadFromEnumerator() { if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _enumerator.Current; return true; } Dispose(); return false; } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public abstract TSource[] ToArray(); public abstract List<TSource> ToList(); public abstract int GetCount(bool onlyIfCheap); } private class AppendPrepend1Iterator<TSource> : AppendPrependIterator<TSource> { private readonly TSource _item; private readonly bool _appending; public AppendPrepend1Iterator(System.Collections.Generic.IEnumerable<TSource> source, TSource item, bool appending) : base(source) { _item = item; _appending = appending; } public override Iterator<TSource> Clone() { return new AppendPrepend1Iterator<TSource>(_source, _item, _appending); } public override bool MoveNext() { switch (_state) { case 1: _state = 2; if (!_appending) { _current = _item; return true; } goto case 2; case 2: GetSourceEnumerator(); _state = 3; goto case 3; case 3: if (LoadFromEnumerator()) { return true; } if (_appending) { _current = _item; return true; } break; } Dispose(); return false; } public override AppendPrependIterator<TSource> Append(TSource item) { if (_appending) { return new AppendPrependN<TSource>(_source, null, new SingleLinkedNode<TSource>(_item, item)); } return new AppendPrependN<TSource>(_source, new SingleLinkedNode<TSource>(_item), new SingleLinkedNode<TSource>(item)); } public override AppendPrependIterator<TSource> Prepend(TSource item) { if (_appending) { return new AppendPrependN<TSource>(_source, new SingleLinkedNode<TSource>(item), new SingleLinkedNode<TSource>(_item)); } return new AppendPrependN<TSource>(_source, new SingleLinkedNode<TSource>(_item, item), null); } public override TSource[] ToArray() { int count = GetCount(onlyIfCheap: true); if (count == -1) { return EnumerableHelpers.ToArray(this); } TSource[] array = new TSource[count]; int num; if (_appending) { num = 0; } else { array[0] = _item; num = 1; } if (_source is System.Collections.Generic.ICollection<TSource> collection) { collection.CopyTo(array, num); } else { System.Collections.Generic.IEnumerator<TSource> enumerator = _source.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; array[num] = current; num++; } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } if (_appending) { array[array.Length - 1] = _item; } return array; } public override List<TSource> ToList() { int count = GetCount(onlyIfCheap: true); List<TSource> val = ((count == -1) ? new List<TSource>() : new List<TSource>(count)); if (!_appending) { val.Add(_item); } val.AddRange(_source); if (_appending) { val.Add(_item); } return val; } public override int GetCount(bool onlyIfCheap) { if (_source is IIListProvider<TSource> iIListProvider) { int count = iIListProvider.GetCount(onlyIfCheap); if (count != -1) { return count + 1; } return -1; } if (onlyIfCheap && !(_source is System.Collections.Generic.ICollection<TSource>)) { return -1; } return _source.Count() + 1; } } private sealed class SingleLinkedNode<TSource> { public TSource Item { [CompilerGenerated] get; } public SingleLinkedNode<TSource> Linked { [CompilerGenerated] get; } public int Count { [CompilerGenerated] get; } public SingleLinkedNode(TSource first, TSource second) { Linked = new SingleLinkedNode<TSource>(first); Item = second; Count = 2; } public SingleLinkedNode(TSource item) { Item = item; Count = 1; } private SingleLinkedNode(SingleLinkedNode<TSource> linked, TSource item) { Linked = linked; Item = item; Count = linked.Count + 1; } public SingleLinkedNode<TSource> Add(TSource item) { return new SingleLinkedNode<TSource>(this, item); } public System.Collections.Generic.IEnumerator<TSource> GetEnumerator() { TSource[] array = new TSource[Count]; int num = Count; for (SingleLinkedNode<TSource> singleLinkedNode = this; singleLinkedNode != null; singleLinkedNode = singleLinkedNode.Linked) { num--; array[num] = singleLinkedNode.Item; } return ((System.Collections.Generic.IEnumerable<TSource>)array).GetEnumerator(); } } private class AppendPrependN<TSource> : AppendPrependIterator<TSource> { private readonly SingleLinkedNode<TSource> _prepended; private readonly SingleLinkedNode<TSource> _appended; private SingleLinkedNode<TSource> _node; public AppendPrependN(System.Collections.Generic.IEnumerable<TSource> source, SingleLinkedNode<TSource> prepended, SingleLinkedNode<TSource> appended) : base(source) { _prepended = prepended; _appended = appended; } public override Iterator<TSource> Clone() { return new AppendPrependN<TSource>(_source, _prepended, _appended); } public override bool MoveNext() { switch (_state) { case 1: _node = _prepended; _state = 2; goto case 2; case 2: if (_node != null) { _current = _node.Item; _node = _node.Linked; return true; } GetSourceEnumerator(); _state = 3; goto case 3; case 3: if (LoadFromEnumerator()) { return true; } if (_appended == null) { return false; } _enumerator = _appended.GetEnumerator(); _state = 4; goto case 4; case 4: return LoadFromEnumerator(); default: Dispose(); return false; } } public override AppendPrependIterator<TSource> Append(TSource item) { return new AppendPrependN<TSource>(_source, _prepended, (_appended != null) ? _appended.Add(item) : new SingleLinkedNode<TSource>(item)); } public override AppendPrependIterator<TSource> Prepend(TSource item) { return new AppendPrependN<TSource>(_source, (_prepended != null) ? _prepended.Add(item) : new SingleLinkedNode<TSource>(item), _appended); } public override TSource[] ToArray() { int count = GetCount(onlyIfCheap: true); if (count == -1) { return EnumerableHelpers.ToArray(this); } TSource[] array = new TSource[count]; int num = 0; for (SingleLinkedNode<TSource> singleLinkedNode = _prepended; singleLinkedNode != null; singleLinkedNode = singleLinkedNode.Linked) { array[num] = singleLinkedNode.Item; num++; } if (_source is System.Collections.Generic.ICollection<TSource> collection) { collection.CopyTo(array, num); } else { System.Collections.Generic.IEnumerator<TSource> enumerator = _source.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; array[num] = current; num++; } } finally { ((System.IDisposable)enumerator)?.Dispose(); } } num = array.Length; for (SingleLinkedNode<TSource> singleLinkedNode2 = _appended; singleLinkedNode2 != null; singleLinkedNode2 = singleLinkedNode2.Linked) { num--; array[num] = singleLinkedNode2.Item; } return array; } public override List<TSource> ToList() { int count = GetCount(onlyIfCheap: true); List<TSource> val = ((count == -1) ? new List<TSource>() : new List<TSource>(count)); for (SingleLinkedNode<TSource> singleLinkedNode = _prepended; singleLinkedNode != null; singleLinkedNode = singleLinkedNode.Linked) { val.Add(singleLinkedNode.Item); } val.AddRange(_source); if (_appended != null) { System.Collections.Generic.IEnumerator<TSource> enumerator = _appended.GetEnumerator(); while (((System.Collections.IEnumerator)enumerator).MoveNext()) { val.Add(enumerator.Current); } } return val; } public override int GetCount(bool onlyIfCheap) { if (_source is IIListProvider<TSource> iIListProvider) { int count = iIListProvider.GetCount(onlyIfCheap); if (count != -1) { return count + ((_appended != null) ? _appended.Count : 0) + ((_prepended != null) ? _prepended.Count : 0); } return -1; } if (onlyIfCheap && !(_source is System.Collections.Generic.ICollection<TSource>)) { return -1; } return _source.Count() + ((_appended != null) ? _appended.Count : 0) + ((_prepended != null) ? _prepended.Count : 0); } } private sealed class Concat2Iterator<TSource> : ConcatIterator<TSource> { private readonly System.Collections.Generic.IEnumerable<TSource> _first; private readonly System.Collections.Generic.IEnumerable<TSource> _second; internal Concat2Iterator(System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second) { _first = first; _second = second; } public override Iterator<TSource> Clone() { return new Concat2Iterator<TSource>(_first, _second); } internal override ConcatIterator<TSource> Concat(System.Collections.Generic.IEnumerable<TSource> next) { return new ConcatNIterator<TSource>(this, next, 2); } internal override System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index) { return index switch { 0 => _first, 1 => _second, _ => null, }; } } private sealed class ConcatNIterator<TSource> : ConcatIterator<TSource> { private readonly ConcatIterator<TSource> _previousConcat; private readonly System.Collections.Generic.IEnumerable<TSource> _next; private readonly int _nextIndex; internal ConcatNIterator(ConcatIterator<TSource> previousConcat, System.Collections.Generic.IEnumerable<TSource> next, int nextIndex) { _previousConcat = previousConcat; _next = next; _nextIndex = nextIndex; } public override Iterator<TSource> Clone() { return new ConcatNIterator<TSource>(_previousConcat, _next, _nextIndex); } internal override ConcatIterator<TSource> Concat(System.Collections.Generic.IEnumerable<TSource> next) { if (_nextIndex == 2147483645) { return new Concat2Iterator<TSource>(this, next); } return new ConcatNIterator<TSource>(this, next, _nextIndex + 1); } internal override System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index) { if (index > _nextIndex) { return null; } ConcatNIterator<TSource> concatNIterator = this; while (true) { if (index == concatNIterator._nextIndex) { return concatNIterator._next; } if (!(concatNIterator._previousConcat is ConcatNIterator<TSource> concatNIterator2)) { break; } concatNIterator = concatNIterator2; } return concatNIterator._previousConcat.GetEnumerable(index); } } private abstract class ConcatIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { private System.Collections.Generic.IEnumerator<TSource> _enumerator; public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } internal abstract System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index); internal abstract ConcatIterator<TSource> Concat(System.Collections.Generic.IEnumerable<TSource> next); public override bool MoveNext() { if (_state == 1) { _enumerator = GetEnumerable(0).GetEnumerator(); _state = 2; } if (_state > 1) { while (true) { if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _enumerator.Current; return true; } System.Collections.Generic.IEnumerable<TSource> enumerable = GetEnumerable(_state++ - 1); if (enumerable == null) { break; } ((System.IDisposable)_enumerator).Dispose(); _enumerator = enumerable.GetEnumerator(); } Dispose(); } return false; } public TSource[] ToArray() { return EnumerableHelpers.ToArray(this); } public List<TSource> ToList() { List<TSource> val = new List<TSource>(); int num = 0; while (true) { System.Collections.Generic.IEnumerable<TSource> enumerable = GetEnumerable(num); if (enumerable == null) { break; } val.AddRange(enumerable); num++; } return val; } public int GetCount(bool onlyIfCheap) { if (onlyIfCheap) { return -1; } int num = 0; int num2 = 0; while (true) { System.Collections.Generic.IEnumerable<TSource> enumerable = GetEnumerable(num2); if (enumerable == null) { break; } num = checked(num + enumerable.Count()); num2++; } return num; } } private sealed class DefaultIfEmptyIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private readonly TSource _default; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public DefaultIfEmptyIterator(System.Collections.Generic.IEnumerable<TSource> source, TSource defaultValue) { _source = source; _default = defaultValue; } public override Iterator<TSource> Clone() { return new DefaultIfEmptyIterator<TSource>(_source, _default); } public override bool MoveNext() { switch (_state) { case 1: _enumerator = _source.GetEnumerator(); if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _enumerator.Current; _state = 2; } else { _current = _default; _state = -1; } return true; case 2: if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _enumerator.Current; return true; } break; } Dispose(); return false; } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public TSource[] ToArray() { TSource[] array = _source.ToArray(); if (array.Length != 0) { return array; } return new TSource[1] { _default }; } public List<TSource> ToList() { List<TSource> val = _source.ToList(); if (val.Count == 0) { val.Add(_default); } return val; } public int GetCount(bool onlyIfCheap) { int num = ((onlyIfCheap && !(_source is System.Collections.Generic.ICollection<TSource>) && !(_source is System.Collections.ICollection)) ? ((!(_source is IIListProvider<TSource> iIListProvider)) ? (-1) : iIListProvider.GetCount(onlyIfCheap: true)) : _source.Count()); if (num != 0) { return num; } return 1; } } private sealed class DistinctIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private readonly IEqualityComparer<TSource> _comparer; private Set<TSource> _set; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public DistinctIterator(System.Collections.Generic.IEnumerable<TSource> source, IEqualityComparer<TSource> comparer) { _source = source; _comparer = comparer; } public override Iterator<TSource> Clone() { return new DistinctIterator<TSource>(_source, _comparer); } public override bool MoveNext() { int state = _state; TSource current; if (state != 1) { if (state == 2) { while (((System.Collections.IEnumerator)_enumerator).MoveNext()) { current = _enumerator.Current; if (_set.Add(current)) { _current = current; return true; } } } Dispose(); return false; } _enumerator = _source.GetEnumerator(); if (!((System.Collections.IEnumerator)_enumerator).MoveNext()) { Dispose(); return false; } current = _enumerator.Current; _set = new Set<TSource>(_comparer); _set.Add(current); _current = current; _state = 2; return true; } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; _set = null; } base.Dispose(); } private Set<TSource> FillSet() { Set<TSource> set = new Set<TSource>(_comparer); System.Collections.Generic.IEnumerator<TSource> enumerator = _source.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; set.Add(current); } return set; } finally { ((System.IDisposable)enumerator)?.Dispose(); } } public TSource[] ToArray() { return FillSet().ToArray(); } public List<TSource> ToList() { return FillSet().ToList(); } public int GetCount(bool onlyIfCheap) { if (!onlyIfCheap) { return FillSet().Count; } return -1; } } internal abstract class Iterator<TSource> : System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TSource>, System.Collections.IEnumerator, System.IDisposable { private readonly int _threadId; internal int _state; internal TSource _current; public TSource Current => _current; object System.Collections.IEnumerator.Current => Current; protected Iterator() { _threadId = Environment.CurrentManagedThreadId; } public abstract Iterator<TSource> Clone(); public virtual void Dispose() { _current = default(TSource); _state = -1; } public System.Collections.Generic.IEnumerator<TSource> GetEnumerator() { Iterator<TSource> iterator = ((_state == 0 && _threadId == Environment.CurrentManagedThreadId) ? this : Clone()); iterator._state = 1; return iterator; } public abstract bool MoveNext(); public virtual System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) { return new SelectEnumerableIterator<TSource, TResult>(this, selector); } public virtual System.Collections.Generic.IEnumerable<TSource> Where(Func<TSource, bool> predicate) { return new WhereEnumerableIterator<TSource>(this, predicate); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)GetEnumerator(); } void System.Collections.IEnumerator.Reset() { throw Error.NotSupported(); } } private sealed class ListPartition<TSource> : Iterator<TSource>, IPartition<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IList<TSource> _source; private readonly int _minIndexInclusive; private readonly int _maxIndexInclusive; private int _index; private int Count { get { int count = ((System.Collections.Generic.ICollection<TSource>)_source).Count; if (count <= _minIndexInclusive) { return 0; } return Math.Min(count - 1, _maxIndexInclusive) - _minIndexInclusive + 1; } } public ListPartition(System.Collections.Generic.IList<TSource> source, int minIndexInclusive, int maxIndexInclusive) { _source = source; _minIndexInclusive = minIndexInclusive; _maxIndexInclusive = maxIndexInclusive; _index = minIndexInclusive; } public override Iterator<TSource> Clone() { return new ListPartition<TSource>(_source, _minIndexInclusive, _maxIndexInclusive); } public override bool MoveNext() { if (((_state == 1) & (_index <= _maxIndexInclusive)) && _index < ((System.Collections.Generic.ICollection<TSource>)_source).Count) { _current = _source[_index]; _index++; return true; } Dispose(); return false; } public override System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) { return new SelectListPartitionIterator<TSource, TResult>(_source, selector, _minIndexInclusive, _maxIndexInclusive); } public IPartition<TSource> Skip(int count) { int num = _minIndexInclusive + count; if ((uint)num <= (uint)_maxIndexInclusive) { return new ListPartition<TSource>(_source, num, _maxIndexInclusive); } return EmptyPartition<TSource>.Instance; } public IPartition<TSource> Take(int count) { int num = _minIndexInclusive + count - 1; if ((uint)num < (uint)_maxIndexInclusive) { return new ListPartition<TSource>(_source, _minIndexInclusive, num); } return this; } public TSource TryGetElementAt(int index, out bool found) { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < ((System.Collections.Generic.ICollection<TSource>)_source).Count - _minIndexInclusive) { found = true; return _source[_minIndexInclusive + index]; } found = false; return default(TSource); } public TSource TryGetFirst(out bool found) { if (((System.Collections.Generic.ICollection<TSource>)_source).Count > _minIndexInclusive) { found = true; return _source[_minIndexInclusive]; } found = false; return default(TSource); } public TSource TryGetLast(out bool found) { int num = ((System.Collections.Generic.ICollection<TSource>)_source).Count - 1; if (num >= _minIndexInclusive) { found = true; return _source[Math.Min(num, _maxIndexInclusive)]; } found = false; return default(TSource); } public TSource[] ToArray() { int count = Count; if (count == 0) { return System.Array.Empty<TSource>(); } TSource[] array = new TSource[count]; int num = 0; int num2 = _minIndexInclusive; while (num != array.Length) { array[num] = _source[num2]; num++; num2++; } return array; } public List<TSource> ToList() { int count = Count; if (count == 0) { return new List<TSource>(); } List<TSource> val = new List<TSource>(count); int num = _minIndexInclusive + count; for (int i = _minIndexInclusive; i != num; i++) { val.Add(_source[i]); } return val; } public int GetCount(bool onlyIfCheap) { return Count; } } private sealed class RangeIterator : Iterator<int>, IPartition<int>, IIListProvider<int>, System.Collections.Generic.IEnumerable<int>, System.Collections.IEnumerable { private readonly int _start; private readonly int _end; public RangeIterator(int start, int count) { _start = start; _end = start + count; } public override Iterator<int> Clone() { return new RangeIterator(_start, _end - _start); } public override bool MoveNext() { switch (_state) { case 1: _current = _start; _state = 2; return true; case 2: if (++_current != _end) { return true; } break; } _state = -1; return false; } public override void Dispose() { _state = -1; } public override System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<int, TResult> selector) { return new SelectIPartitionIterator<int, TResult>(this, selector); } public int[] ToArray() { int[] array = new int[_end - _start]; int num = _start; for (int i = 0; i != array.Length; i++) { array[i] = num; num++; } return array; } public List<int> ToList() { List<int> val = new List<int>(_end - _start); for (int i = _start; i != _end; i++) { val.Add(i); } return val; } public int GetCount(bool onlyIfCheap) { return _end - _start; } public IPartition<int> Skip(int count) { if (count >= _end - _start) { return EmptyPartition<int>.Instance; } return new RangeIterator(_start + count, _end - _start - count); } public IPartition<int> Take(int count) { int num = _end - _start; if (count >= num) { return this; } return new RangeIterator(_start, count); } public int TryGetElementAt(int index, out bool found) { if ((uint)index < (uint)(_end - _start)) { found = true; return _start + index; } found = false; return 0; } public int TryGetFirst(out bool found) { found = true; return _start; } public int TryGetLast(out bool found) { found = true; return _end - 1; } } private sealed class RepeatIterator<TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly int _count; private int _sent; public RepeatIterator(TResult element, int count) { _current = element; _count = count; } public override Iterator<TResult> Clone() { return new RepeatIterator<TResult>(_current, _count); } public override void Dispose() { _state = -1; } public override bool MoveNext() { if ((_state == 1) & (_sent != _count)) { _sent++; return true; } _state = -1; return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectIPartitionIterator<TResult, TResult2>(this, selector); } public TResult[] ToArray() { TResult[] array = new TResult[_count]; if (_current != null) { for (int i = 0; i != array.Length; i++) { array[i] = _current; } } return array; } public List<TResult> ToList() { List<TResult> val = new List<TResult>(_count); for (int i = 0; i != _count; i++) { val.Add(_current); } return val; } public int GetCount(bool onlyIfCheap) { return _count; } public IPartition<TResult> Skip(int count) { if (count >= _count) { return EmptyPartition<TResult>.Instance; } return new RepeatIterator<TResult>(_current, _count - count); } public IPartition<TResult> Take(int count) { if (count >= _count) { return this; } return new RepeatIterator<TResult>(_current, count); } public TResult TryGetElementAt(int index, out bool found) { if ((uint)index < (uint)_count) { found = true; return _current; } found = false; return default(TResult); } public TResult TryGetFirst(out bool found) { found = true; return _current; } public TResult TryGetLast(out bool found) { found = true; return _current; } } private sealed class ReverseIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private TSource[] _buffer; private int _index; public ReverseIterator(System.Collections.Generic.IEnumerable<TSource> source) { _source = source; } public override Iterator<TSource> Clone() { return new ReverseIterator<TSource>(_source); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_006f; } } else { Buffer<TSource> buffer = new Buffer<TSource>(_source); _buffer = buffer._items; _index = buffer._count - 1; _state = 2; } if (_index != -1) { _current = _buffer[_index]; _index--; return true; } goto IL_006f; IL_006f: Dispose(); return false; } public override void Dispose() { _buffer = null; base.Dispose(); } public TSource[] ToArray() { TSource[] array = _source.ToArray(); int num = 0; int num2 = array.Length - 1; while (num < num2) { TSource val = array[num]; array[num] = array[num2]; array[num2] = val; num++; num2--; } return array; } public List<TSource> ToList() { List<TSource> val = _source.ToList(); val.Reverse(); return val; } public int GetCount(bool onlyIfCheap) { if (onlyIfCheap) { if (_source is IIListProvider<TSource> iIListProvider) { return iIListProvider.GetCount(onlyIfCheap: true); } if (!(_source is System.Collections.Generic.ICollection<TSource>) && !(_source is System.Collections.ICollection)) { return -1; } } return _source.Count(); } } internal sealed class SelectEnumerableIterator<TSource, TResult> : Iterator<TResult> { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private readonly Func<TSource, TResult> _selector; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public SelectEnumerableIterator(System.Collections.Generic.IEnumerable<TSource> source, Func<TSource, TResult> selector) { _source = source; _selector = selector; } public override Iterator<TResult> Clone() { return new SelectEnumerableIterator<TSource, TResult>(_source, _selector); } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_005a; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _selector.Invoke(_enumerator.Current); return true; } Dispose(); goto IL_005a; IL_005a: return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectEnumerableIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } } internal sealed class SelectArrayIterator<TSource, TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly TSource[] _source; private readonly Func<TSource, TResult> _selector; private int _index; public SelectArrayIterator(TSource[] source, Func<TSource, TResult> selector) { _source = source; _selector = selector; } public override Iterator<TResult> Clone() { return new SelectArrayIterator<TSource, TResult>(_source, _selector); } public override bool MoveNext() { if (_state == 1 && _index < _source.Length) { _current = _selector.Invoke(_source[_index++]); return true; } Dispose(); return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectArrayIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } public TResult[] ToArray() { if (_source.Length == 0) { return System.Array.Empty<TResult>(); } TResult[] array = new TResult[_source.Length]; for (int i = 0; i < array.Length; i++) { array[i] = _selector.Invoke(_source[i]); } return array; } public List<TResult> ToList() { TSource[] source = _source; List<TResult> val = (List<TResult>)(object)new List<?>(source.Length); for (int i = 0; i < source.Length; i++) { ((List<?>)(object)val).Add(_selector.Invoke(source[i])); } return val; } public int GetCount(bool onlyIfCheap) { return _source.Length; } public IPartition<TResult> Skip(int count) { if (count >= _source.Length) { return EmptyPartition<TResult>.Instance; } return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, count, 2147483647); } public IPartition<TResult> Take(int count) { if (count < _source.Length) { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, 0, count - 1); } return this; } public TResult TryGetElementAt(int index, out bool found) { if ((uint)index < (uint)_source.Length) { found = true; return _selector.Invoke(_source[index]); } found = false; return default(TResult); } public TResult TryGetFirst(out bool found) { if (_source.Length != 0) { found = true; return _selector.Invoke(_source[0]); } found = false; return default(TResult); } public TResult TryGetLast(out bool found) { int num = _source.Length; if (num != 0) { found = true; return _selector.Invoke(_source[num - 1]); } found = false; return default(TResult); } } internal sealed class SelectListIterator<TSource, TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly List<TSource> _source; private readonly Func<TSource, TResult> _selector; private Enumerator<TSource> _enumerator; public SelectListIterator(List<TSource> source, Func<TSource, TResult> selector) { _source = source; _selector = selector; } public override Iterator<TResult> Clone() { return new SelectListIterator<TSource, TResult>(_source, _selector); } public override bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int state = _state; if (state != 1) { if (state != 2) { goto IL_005a; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } if (_enumerator.MoveNext()) { _current = _selector.Invoke(_enumerator.Current); return true; } Dispose(); goto IL_005a; IL_005a: return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectListIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } public TResult[] ToArray() { int count = _source.Count; if (count == 0) { return System.Array.Empty<TResult>(); } TResult[] array = new TResult[count]; for (int i = 0; i < array.Length; i++) { array[i] = _selector.Invoke(_source[i]); } return array; } public List<TResult> ToList() { int count = _source.Count; List<TResult> val = (List<TResult>)(object)new List<?>(count); for (int i = 0; i < count; i++) { ((List<?>)(object)val).Add(_selector.Invoke(_source[i])); } return val; } public int GetCount(bool onlyIfCheap) { return _source.Count; } public IPartition<TResult> Skip(int count) { return new SelectListPartitionIterator<TSource, TResult>((System.Collections.Generic.IList<TSource>)_source, _selector, count, 2147483647); } public IPartition<TResult> Take(int count) { return new SelectListPartitionIterator<TSource, TResult>((System.Collections.Generic.IList<TSource>)_source, _selector, 0, count - 1); } public TResult TryGetElementAt(int index, out bool found) { if ((uint)index < (uint)_source.Count) { found = true; return _selector.Invoke(_source[index]); } found = false; return default(TResult); } public TResult TryGetFirst(out bool found) { if (_source.Count != 0) { found = true; return _selector.Invoke(_source[0]); } found = false; return default(TResult); } public TResult TryGetLast(out bool found) { int count = _source.Count; if (count != 0) { found = true; return _selector.Invoke(_source[count - 1]); } found = false; return default(TResult); } } internal sealed class SelectIListIterator<TSource, TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IList<TSource> _source; private readonly Func<TSource, TResult> _selector; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public SelectIListIterator(System.Collections.Generic.IList<TSource> source, Func<TSource, TResult> selector) { _source = source; _selector = selector; } public override Iterator<TResult> Clone() { return new SelectIListIterator<TSource, TResult>(_source, _selector); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_005a; } } else { _enumerator = ((System.Collections.Generic.IEnumerable<TSource>)_source).GetEnumerator(); _state = 2; } if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _selector.Invoke(_enumerator.Current); return true; } Dispose(); goto IL_005a; IL_005a: return false; } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectIListIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } public TResult[] ToArray() { int count = ((System.Collections.Generic.ICollection<TSource>)_source).Count; if (count == 0) { return System.Array.Empty<TResult>(); } TResult[] array = new TResult[count]; for (int i = 0; i < array.Length; i++) { array[i] = _selector.Invoke(_source[i]); } return array; } public List<TResult> ToList() { int count = ((System.Collections.Generic.ICollection<TSource>)_source).Count; List<TResult> val = (List<TResult>)(object)new List<?>(count); for (int i = 0; i < count; i++) { ((List<?>)(object)val).Add(_selector.Invoke(_source[i])); } return val; } public int GetCount(bool onlyIfCheap) { return ((System.Collections.Generic.ICollection<TSource>)_source).Count; } public IPartition<TResult> Skip(int count) { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, count, 2147483647); } public IPartition<TResult> Take(int count) { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, 0, count - 1); } public TResult TryGetElementAt(int index, out bool found) { if ((uint)index < (uint)((System.Collections.Generic.ICollection<TSource>)_source).Count) { found = true; return _selector.Invoke(_source[index]); } found = false; return default(TResult); } public TResult TryGetFirst(out bool found) { if (((System.Collections.Generic.ICollection<TSource>)_source).Count != 0) { found = true; return _selector.Invoke(_source[0]); } found = false; return default(TResult); } public TResult TryGetLast(out bool found) { int count = ((System.Collections.Generic.ICollection<TSource>)_source).Count; if (count != 0) { found = true; return _selector.Invoke(_source[count - 1]); } found = false; return default(TResult); } } internal sealed class SelectIPartitionIterator<TSource, TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly IPartition<TSource> _source; private readonly Func<TSource, TResult> _selector; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public SelectIPartitionIterator(IPartition<TSource> source, Func<TSource, TResult> selector) { _source = source; _selector = selector; } public override Iterator<TResult> Clone() { return new SelectIPartitionIterator<TSource, TResult>(_source, _selector); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_005a; } } else { _enumerator = ((System.Collections.Generic.IEnumerable<TSource>)_source).GetEnumerator(); _state = 2; } if (((System.Collections.IEnumerator)_enumerator).MoveNext()) { _current = _selector.Invoke(_enumerator.Current); return true; } Dispose(); goto IL_005a; IL_005a: return false; } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectIPartitionIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } public IPartition<TResult> Skip(int count) { return new SelectIPartitionIterator<TSource, TResult>(_source.Skip(count), _selector); } public IPartition<TResult> Take(int count) { return new SelectIPartitionIterator<TSource, TResult>(_source.Take(count), _selector); } public TResult TryGetElementAt(int index, out bool found) { bool found2; TSource val = _source.TryGetElementAt(index, out found2); found = found2; if (!found2) { return default(TResult); } return _selector.Invoke(val); } public TResult TryGetFirst(out bool found) { bool found2; TSource val = _source.TryGetFirst(out found2); found = found2; if (!found2) { return default(TResult); } return _selector.Invoke(val); } public TResult TryGetLast(out bool found) { bool found2; TSource val = _source.TryGetLast(out found2); found = found2; if (!found2) { return default(TResult); } return _selector.Invoke(val); } public TResult[] ToArray() { int count = _source.GetCount(onlyIfCheap: true); switch (count) { case -1: return EnumerableHelpers.ToArray(this); case 0: return System.Array.Empty<TResult>(); default: { TResult[] array = new TResult[count]; int num = 0; System.Collections.Generic.IEnumerator<TSource> enumerator = ((System.Collections.Generic.IEnumerable<TSource>)_source).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; array[num] = _selector.Invoke(current); num++; } return array; } finally { ((System.IDisposable)enumerator)?.Dispose(); } } } } public List<TResult> ToList() { int count = _source.GetCount(onlyIfCheap: true); List<TResult> val; switch (count) { case -1: val = (List<TResult>)(object)new List<?>(); break; case 0: return (List<TResult>)(object)new List<?>(); default: val = (List<TResult>)(object)new List<?>(count); break; } System.Collections.Generic.IEnumerator<TSource> enumerator = ((System.Collections.Generic.IEnumerable<TSource>)_source).GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; ((List<?>)(object)val).Add(_selector.Invoke(current)); } return val; } finally { ((System.IDisposable)enumerator)?.Dispose(); } } public int GetCount(bool onlyIfCheap) { return _source.GetCount(onlyIfCheap); } } private sealed class SelectListPartitionIterator<TSource, TResult> : Iterator<TResult>, IPartition<TResult>, IIListProvider<TResult>, System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable { private readonly System.Collections.Generic.IList<TSource> _source; private readonly Func<TSource, TResult> _selector; private readonly int _minIndexInclusive; private readonly int _maxIndexInclusive; private int _index; private int Count { get { int count = ((System.Collections.Generic.ICollection<TSource>)_source).Count; if (count <= _minIndexInclusive) { return 0; } return Math.Min(count - 1, _maxIndexInclusive) - _minIndexInclusive + 1; } } public SelectListPartitionIterator(System.Collections.Generic.IList<TSource> source, Func<TSource, TResult> selector, int minIndexInclusive, int maxIndexInclusive) { _source = source; _selector = selector; _minIndexInclusive = minIndexInclusive; _maxIndexInclusive = maxIndexInclusive; _index = minIndexInclusive; } public override Iterator<TResult> Clone() { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, _minIndexInclusive, _maxIndexInclusive); } public override bool MoveNext() { if (((_state == 1) & (_index <= _maxIndexInclusive)) && _index < ((System.Collections.Generic.ICollection<TSource>)_source).Count) { _current = _selector.Invoke(_source[_index]); _index++; return true; } Dispose(); return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new SelectListPartitionIterator<TSource, TResult2>(_source, CombineSelectors<TSource, TResult, TResult2>(_selector, selector), _minIndexInclusive, _maxIndexInclusive); } public IPartition<TResult> Skip(int count) { int num = _minIndexInclusive + count; if ((uint)num <= (uint)_maxIndexInclusive) { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, num, _maxIndexInclusive); } return EmptyPartition<TResult>.Instance; } public IPartition<TResult> Take(int count) { int num = _minIndexInclusive + count - 1; if ((uint)num < (uint)_maxIndexInclusive) { return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, _minIndexInclusive, num); } return this; } public TResult TryGetElementAt(int index, out bool found) { if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < ((System.Collections.Generic.ICollection<TSource>)_source).Count - _minIndexInclusive) { found = true; return _selector.Invoke(_source[_minIndexInclusive + index]); } found = false; return default(TResult); } public TResult TryGetFirst(out bool found) { if (((System.Collections.Generic.ICollection<TSource>)_source).Count > _minIndexInclusive) { found = true; return _selector.Invoke(_source[_minIndexInclusive]); } found = false; return default(TResult); } public TResult TryGetLast(out bool found) { int num = ((System.Collections.Generic.ICollection<TSource>)_source).Count - 1; if (num >= _minIndexInclusive) { found = true; return _selector.Invoke(_source[Math.Min(num, _maxIndexInclusive)]); } found = false; return default(TResult); } public TResult[] ToArray() { int count = Count; if (count == 0) { return System.Array.Empty<TResult>(); } TResult[] array = new TResult[count]; int num = 0; int num2 = _minIndexInclusive; while (num != array.Length) { array[num] = _selector.Invoke(_source[num2]); num++; num2++; } return array; } public List<TResult> ToList() { int count = Count; if (count == 0) { return (List<TResult>)(object)new List<?>(); } List<TResult> val = (List<TResult>)(object)new List<?>(count); int num = _minIndexInclusive + count; for (int i = _minIndexInclusive; i != num; i++) { ((List<?>)(object)val).Add(_selector.Invoke(_source[i])); } return val; } public int GetCount(bool onlyIfCheap) { return Count; } } private abstract class UnionIterator<TSource> : Iterator<TSource>, IIListProvider<TSource>, System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable { internal readonly IEqualityComparer<TSource> _comparer; private System.Collections.Generic.IEnumerator<TSource> _enumerator; private Set<TSource> _set; public UnionIterator(IEqualityComparer<TSource> comparer) { _comparer = comparer; } public sealed override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; _set = null; } base.Dispose(); } internal abstract System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index); internal abstract UnionIterator<TSource> Union(System.Collections.Generic.IEnumerable<TSource> next); protected void SetEnumerator(System.Collections.Generic.IEnumerator<TSource> enumerator) { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); } _enumerator = enumerator; } protected void StoreFirst() { Set<TSource> set = new Set<TSource>(_comparer); TSource current = _enumerator.Current; set.Add(current); _current = current; _set = set; } protected bool GetNext() { Set<TSource> set = _set; while (((System.Collections.IEnumerator)_enumerator).MoveNext()) { TSource current = _enumerator.Current; if (set.Add(current)) { _current = current; return true; } } return false; } public sealed override bool MoveNext() { if (_state == 1) { for (System.Collections.Generic.IEnumerable<TSource> enumerable = GetEnumerable(0); enumerable != null; enumerable = GetEnumerable(_state - 1)) { System.Collections.Generic.IEnumerator<TSource> enumerator = enumerable.GetEnumerator(); _state++; if (((System.Collections.IEnumerator)enumerator).MoveNext()) { SetEnumerator(enumerator); StoreFirst(); return true; } } } else if (_state > 0) { while (true) { if (GetNext()) { return true; } System.Collections.Generic.IEnumerable<TSource> enumerable2 = GetEnumerable(_state - 1); if (enumerable2 == null) { break; } SetEnumerator(enumerable2.GetEnumerator()); _state++; } } Dispose(); return false; } private Set<TSource> FillSet() { Set<TSource> set = new Set<TSource>(_comparer); int num = 0; while (true) { System.Collections.Generic.IEnumerable<TSource> enumerable = GetEnumerable(num); if (enumerable == null) { break; } System.Collections.Generic.IEnumerator<TSource> enumerator = enumerable.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; set.Add(current); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } num++; } return set; } public TSource[] ToArray() { return FillSet().ToArray(); } public List<TSource> ToList() { return FillSet().ToList(); } public int GetCount(bool onlyIfCheap) { if (!onlyIfCheap) { return FillSet().Count; } return -1; } } private sealed class UnionIterator2<TSource> : UnionIterator<TSource> { private readonly System.Collections.Generic.IEnumerable<TSource> _first; private readonly System.Collections.Generic.IEnumerable<TSource> _second; public UnionIterator2(System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, IEqualityComparer<TSource> comparer) : base(comparer) { _first = first; _second = second; } public override Iterator<TSource> Clone() { return new UnionIterator2<TSource>(_first, _second, _comparer); } internal override System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index) { return index switch { 0 => _first, 1 => _second, _ => null, }; } internal override UnionIterator<TSource> Union(System.Collections.Generic.IEnumerable<TSource> next) { return new UnionIteratorN<TSource>(this, next, 2); } } private sealed class UnionIteratorN<TSource> : UnionIterator<TSource> { private readonly UnionIterator<TSource> _previous; private readonly System.Collections.Generic.IEnumerable<TSource> _next; private readonly int _nextIndex; public UnionIteratorN(UnionIterator<TSource> previous, System.Collections.Generic.IEnumerable<TSource> next, int nextIndex) : base(previous._comparer) { _previous = previous; _next = next; _nextIndex = nextIndex; } public override Iterator<TSource> Clone() { return new UnionIteratorN<TSource>(_previous, _next, _nextIndex); } internal override System.Collections.Generic.IEnumerable<TSource> GetEnumerable(int index) { if (index > _nextIndex) { return null; } UnionIteratorN<TSource> unionIteratorN = this; while (index < unionIteratorN._nextIndex) { UnionIterator<TSource> previous = unionIteratorN._previous; unionIteratorN = previous as UnionIteratorN<TSource>; if (unionIteratorN == null) { return previous.GetEnumerable(index); } } return unionIteratorN._next; } internal override UnionIterator<TSource> Union(System.Collections.Generic.IEnumerable<TSource> next) { if (_nextIndex == 2147483645) { return new UnionIterator2<TSource>(this, next, _comparer); } return new UnionIteratorN<TSource>(this, next, _nextIndex + 1); } } internal sealed class WhereEnumerableIterator<TSource> : Iterator<TSource> { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private readonly Func<TSource, bool> _predicate; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public WhereEnumerableIterator(System.Collections.Generic.IEnumerable<TSource> source, Func<TSource, bool> predicate) { _source = source; _predicate = predicate; } public override Iterator<TSource> Clone() { return new WhereEnumerableIterator<TSource>(_source, _predicate); } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_0061; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } while (((System.Collections.IEnumerator)_enumerator).MoveNext()) { TSource current = _enumerator.Current; if (_predicate.Invoke(current)) { _current = current; return true; } } Dispose(); goto IL_0061; IL_0061: return false; } public override System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) { return new WhereSelectEnumerableIterator<TSource, TResult>(_source, _predicate, selector); } public override System.Collections.Generic.IEnumerable<TSource> Where(Func<TSource, bool> predicate) { return new WhereEnumerableIterator<TSource>(_source, CombinePredicates<TSource>(_predicate, predicate)); } } internal sealed class WhereArrayIterator<TSource> : Iterator<TSource> { private readonly TSource[] _source; private readonly Func<TSource, bool> _predicate; private int _index; public WhereArrayIterator(TSource[] source, Func<TSource, bool> predicate) { _source = source; _predicate = predicate; } public override Iterator<TSource> Clone() { return new WhereArrayIterator<TSource>(_source, _predicate); } public override bool MoveNext() { if (_state == 1) { while (_index < _source.Length) { TSource val = _source[_index]; _index++; if (_predicate.Invoke(val)) { _current = val; return true; } } Dispose(); } return false; } public override System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) { return new WhereSelectArrayIterator<TSource, TResult>(_source, _predicate, selector); } public override System.Collections.Generic.IEnumerable<TSource> Where(Func<TSource, bool> predicate) { return new WhereArrayIterator<TSource>(_source, CombinePredicates<TSource>(_predicate, predicate)); } } internal sealed class WhereListIterator<TSource> : Iterator<TSource> { private readonly List<TSource> _source; private readonly Func<TSource, bool> _predicate; private Enumerator<TSource> _enumerator; public WhereListIterator(List<TSource> source, Func<TSource, bool> predicate) { _source = source; _predicate = predicate; } public override Iterator<TSource> Clone() { return new WhereListIterator<TSource>(_source, _predicate); } public override bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int state = _state; if (state != 1) { if (state != 2) { goto IL_0061; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } while (_enumerator.MoveNext()) { TSource current = _enumerator.Current; if (_predicate.Invoke(current)) { _current = current; return true; } } Dispose(); goto IL_0061; IL_0061: return false; } public override System.Collections.Generic.IEnumerable<TResult> Select<TResult>(Func<TSource, TResult> selector) { return new WhereSelectListIterator<TSource, TResult>(_source, _predicate, selector); } public override System.Collections.Generic.IEnumerable<TSource> Where(Func<TSource, bool> predicate) { return new WhereListIterator<TSource>(_source, CombinePredicates<TSource>(_predicate, predicate)); } } internal sealed class WhereSelectArrayIterator<TSource, TResult> : Iterator<TResult> { private readonly TSource[] _source; private readonly Func<TSource, bool> _predicate; private readonly Func<TSource, TResult> _selector; private int _index; public WhereSelectArrayIterator(TSource[] source, Func<TSource, bool> predicate, Func<TSource, TResult> selector) { _source = source; _predicate = predicate; _selector = selector; } public override Iterator<TResult> Clone() { return new WhereSelectArrayIterator<TSource, TResult>(_source, _predicate, _selector); } public override bool MoveNext() { if (_state == 1) { while (_index < _source.Length) { TSource val = _source[_index]; _index++; if (_predicate.Invoke(val)) { _current = _selector.Invoke(val); return true; } } Dispose(); } return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new WhereSelectArrayIterator<TSource, TResult2>(_source, _predicate, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } } internal sealed class WhereSelectListIterator<TSource, TResult> : Iterator<TResult> { private readonly List<TSource> _source; private readonly Func<TSource, bool> _predicate; private readonly Func<TSource, TResult> _selector; private Enumerator<TSource> _enumerator; public WhereSelectListIterator(List<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector) { _source = source; _predicate = predicate; _selector = selector; } public override Iterator<TResult> Clone() { return new WhereSelectListIterator<TSource, TResult>(_source, _predicate, _selector); } public override bool MoveNext() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) int state = _state; if (state != 1) { if (state != 2) { goto IL_006c; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } while (_enumerator.MoveNext()) { TSource current = _enumerator.Current; if (_predicate.Invoke(current)) { _current = _selector.Invoke(current); return true; } } Dispose(); goto IL_006c; IL_006c: return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new WhereSelectListIterator<TSource, TResult2>(_source, _predicate, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } } internal sealed class WhereSelectEnumerableIterator<TSource, TResult> : Iterator<TResult> { private readonly System.Collections.Generic.IEnumerable<TSource> _source; private readonly Func<TSource, bool> _predicate; private readonly Func<TSource, TResult> _selector; private System.Collections.Generic.IEnumerator<TSource> _enumerator; public WhereSelectEnumerableIterator(System.Collections.Generic.IEnumerable<TSource> source, Func<TSource, bool> predicate, Func<TSource, TResult> selector) { _source = source; _predicate = predicate; _selector = selector; } public override Iterator<TResult> Clone() { return new WhereSelectEnumerableIterator<TSource, TResult>(_source, _predicate, _selector); } public override void Dispose() { if (_enumerator != null) { ((System.IDisposable)_enumerator).Dispose(); _enumerator = null; } base.Dispose(); } public override bool MoveNext() { int state = _state; if (state != 1) { if (state != 2) { goto IL_006c; } } else { _enumerator = _source.GetEnumerator(); _state = 2; } while (((System.Collections.IEnumerator)_enumerator).MoveNext()) { TSource current = _enumerator.Current; if (_predicate.Invoke(current)) { _current = _selector.Invoke(current); return true; } } Dispose(); goto IL_006c; IL_006c: return false; } public override System.Collections.Generic.IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) { return new WhereSelectEnumerableIterator<TSource, TResult2>(_source, _predicate, CombineSelectors<TSource, TResult, TResult2>(_selector, selector)); } } [CompilerGenerated] private sealed class <OfTypeIterator>d__33<TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.IEnumerable source; public System.Collections.IEnumerable <>3__source; private System.Collections.IEnumerator <>7__wrap1; TResult System.Collections.Generic.IEnumerator<TResult>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OfTypeIterator>d__33(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = source.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { object current = <>7__wrap1.Current; if (current is TResult) { <>2__current = (TResult)current; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 is System.IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() { <OfTypeIterator>d__33<TResult> <OfTypeIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <OfTypeIterator>d__ = this; } else { <OfTypeIterator>d__ = new <OfTypeIterator>d__33<TResult>(0); } <OfTypeIterator>d__.source = <>3__source; return <OfTypeIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<TResult>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <CastIterator>d__35<TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.IEnumerable source; public System.Collections.IEnumerable <>3__source; private System.Collections.IEnumerator <>7__wrap1; TResult System.Collections.Generic.IEnumerator<TResult>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CastIterator>d__35(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = source.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { object current = <>7__wrap1.Current; <>2__current = (TResult)current; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 is System.IDisposable disposable) { disposable.Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() { <CastIterator>d__35<TResult> <CastIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <CastIterator>d__ = this; } else { <CastIterator>d__ = new <CastIterator>d__35<TResult>(0); } <CastIterator>d__.source = <>3__source; return <CastIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<TResult>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <ExceptIterator>d__58<TSource> : System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TSource>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TSource <>2__current; private int <>l__initialThreadId; private IEqualityComparer<TSource> comparer; public IEqualityComparer<TSource> <>3__comparer; private System.Collections.Generic.IEnumerable<TSource> second; public System.Collections.Generic.IEnumerable<TSource> <>3__second; private System.Collections.Generic.IEnumerable<TSource> first; public System.Collections.Generic.IEnumerable<TSource> <>3__first; private Set<TSource> <set>5__1; private System.Collections.Generic.IEnumerator<TSource> <>7__wrap1; TSource System.Collections.Generic.IEnumerator<TSource>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ExceptIterator>d__58(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <set>5__1 = new Set<TSource>(comparer); System.Collections.Generic.IEnumerator<TSource> enumerator = second.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; <set>5__1.Add(current); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } <>7__wrap1 = first.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (((System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { TSource current2 = <>7__wrap1.Current; if (<set>5__1.Add(current2)) { <>2__current = current2; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((System.IDisposable)<>7__wrap1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TSource> System.Collections.Generic.IEnumerable<TSource>.GetEnumerator() { <ExceptIterator>d__58<TSource> <ExceptIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <ExceptIterator>d__ = this; } else { <ExceptIterator>d__ = new <ExceptIterator>d__58<TSource>(0); } <ExceptIterator>d__.first = <>3__first; <ExceptIterator>d__.second = <>3__second; <ExceptIterator>d__.comparer = <>3__comparer; return <ExceptIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<TSource>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <GroupJoinIterator>d__73<TOuter, TInner, TKey, TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.Generic.IEnumerable<TOuter> outer; public System.Collections.Generic.IEnumerable<TOuter> <>3__outer; private System.Collections.Generic.IEnumerable<TInner> inner; public System.Collections.Generic.IEnumerable<TInner> <>3__inner; private Func<TInner, TKey> innerKeySelector; public Func<TInner, TKey> <>3__innerKeySelector; private IEqualityComparer<TKey> comparer; public IEqualityComparer<TKey> <>3__comparer; private System.Collections.Generic.IEnumerator<TOuter> <e>5__1; private Func<TOuter, System.Collections.Generic.IEnumerable<TInner>, TResult> resultSelector; public Func<TOuter, System.Collections.Generic.IEnumerable<TInner>, TResult> <>3__resultSelector; private Lookup<TKey, TInner> <lookup>5__2; private Func<TOuter, TKey> outerKeySelector; public Func<TOuter, TKey> <>3__outerKeySelector; TResult System.Collections.Generic.IEnumerator<?>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GroupJoinIterator>d__73(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; if (((System.Collections.IEnumerator)<e>5__1).MoveNext()) { goto IL_0062; } <lookup>5__2 = null; } else { <>1__state = -1; <e>5__1 = outer.GetEnumerator(); <>1__state = -3; if (((System.Collections.IEnumerator)<e>5__1).MoveNext()) { <lookup>5__2 = Lookup<TKey, TInner>.CreateForJoin(inner, innerKeySelector, comparer); goto IL_0062; } } <>m__Finally1(); <e>5__1 = null; return false; IL_0062: TOuter current = <e>5__1.Current; <>2__current = ((Func<TOuter, System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TInner>>, ?>)(object)resultSelector).Invoke(current, (System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TInner>>)<lookup>5__2[((Func<TOuter, ?>)(object)outerKeySelector).Invoke(current)]); <>1__state = 1; return true; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<e>5__1 != null) { ((System.IDisposable)<e>5__1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<?>.GetEnumerator() { <GroupJoinIterator>d__73<TOuter, TInner, TKey, TResult> <GroupJoinIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <GroupJoinIterator>d__ = this; } else { <GroupJoinIterator>d__ = new <GroupJoinIterator>d__73<TOuter, TInner, TKey, TResult>(0); } <GroupJoinIterator>d__.outer = <>3__outer; <GroupJoinIterator>d__.inner = <>3__inner; <GroupJoinIterator>d__.outerKeySelector = <>3__outerKeySelector; <GroupJoinIterator>d__.innerKeySelector = <>3__innerKeySelector; <GroupJoinIterator>d__.resultSelector = <>3__resultSelector; <GroupJoinIterator>d__.comparer = <>3__comparer; return <GroupJoinIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<?>)(object)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <IntersectIterator>d__76<TSource> : System.Collections.Generic.IEnumerable<TSource>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TSource>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TSource <>2__current; private int <>l__initialThreadId; private IEqualityComparer<TSource> comparer; public IEqualityComparer<TSource> <>3__comparer; private System.Collections.Generic.IEnumerable<TSource> second; public System.Collections.Generic.IEnumerable<TSource> <>3__second; private System.Collections.Generic.IEnumerable<TSource> first; public System.Collections.Generic.IEnumerable<TSource> <>3__first; private Set<TSource> <set>5__1; private System.Collections.Generic.IEnumerator<TSource> <>7__wrap1; TSource System.Collections.Generic.IEnumerator<TSource>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <IntersectIterator>d__76(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; <set>5__1 = new Set<TSource>(comparer); System.Collections.Generic.IEnumerator<TSource> enumerator = second.GetEnumerator(); try { while (((System.Collections.IEnumerator)enumerator).MoveNext()) { TSource current = enumerator.Current; <set>5__1.Add(current); } } finally { ((System.IDisposable)enumerator)?.Dispose(); } <>7__wrap1 = first.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (((System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { TSource current2 = <>7__wrap1.Current; if (<set>5__1.Remove(current2)) { <>2__current = current2; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((System.IDisposable)<>7__wrap1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TSource> System.Collections.Generic.IEnumerable<TSource>.GetEnumerator() { <IntersectIterator>d__76<TSource> <IntersectIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <IntersectIterator>d__ = this; } else { <IntersectIterator>d__ = new <IntersectIterator>d__76<TSource>(0); } <IntersectIterator>d__.first = <>3__first; <IntersectIterator>d__.second = <>3__second; <IntersectIterator>d__.comparer = <>3__comparer; return <IntersectIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<TSource>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <JoinIterator>d__80<TOuter, TInner, TKey, TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.Generic.IEnumerable<TOuter> outer; public System.Collections.Generic.IEnumerable<TOuter> <>3__outer; private System.Collections.Generic.IEnumerable<TInner> inner; public System.Collections.Generic.IEnumerable<TInner> <>3__inner; private Func<TInner, TKey> innerKeySelector; public Func<TInner, TKey> <>3__innerKeySelector; private IEqualityComparer<TKey> comparer; public IEqualityComparer<TKey> <>3__comparer; private System.Collections.Generic.IEnumerator<TOuter> <e>5__1; private Lookup<TKey, TInner> <lookup>5__2; private Func<TOuter, TKey> outerKeySelector; public Func<TOuter, TKey> <>3__outerKeySelector; private Func<TOuter, TInner, TResult> resultSelector; public Func<TOuter, TInner, TResult> <>3__resultSelector; private TOuter <item>5__3; private TInner[] <elements>5__4; private int <i>5__5; private int <count>5__6; TResult System.Collections.Generic.IEnumerator<?>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <JoinIterator>d__80(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; int num2 = <i>5__5 + 1; <i>5__5 = num2; goto IL_0116; } <>1__state = -1; <e>5__1 = outer.GetEnumerator(); <>1__state = -3; if (((System.Collections.IEnumerator)<e>5__1).MoveNext()) { <lookup>5__2 = Lookup<TKey, TInner>.CreateForJoin(inner, innerKeySelector, comparer); if (<lookup>5__2.Count != 0) { goto IL_0075; } goto IL_0147; } goto IL_014e; IL_0075: <item>5__3 = <e>5__1.Current; Grouping<TKey, TInner> grouping = <lookup>5__2.GetGrouping(((Func<TOuter, ?>)(object)outerKeySelector).Invoke(<item>5__3), create: false); if (grouping != null) { <count>5__6 = grouping._count; <elements>5__4 = grouping._elements; <i>5__5 = 0; goto IL_0116; } goto IL_012b; IL_0116: if (<i>5__5 != <count>5__6) { <>2__current = ((Func<TOuter, TInner, ?>)(object)resultSelector).Invoke(<item>5__3, <elements>5__4[<i>5__5]); <>1__state = 1; return true; } <elements>5__4 = null; goto IL_012b; IL_0147: <lookup>5__2 = null; goto IL_014e; IL_012b: <item>5__3 = default(TOuter); if (((System.Collections.IEnumerator)<e>5__1).MoveNext()) { goto IL_0075; } goto IL_0147; IL_014e: <>m__Finally1(); <e>5__1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<e>5__1 != null) { ((System.IDisposable)<e>5__1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<?>.GetEnumerator() { <JoinIterator>d__80<TOuter, TInner, TKey, TResult> <JoinIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <JoinIterator>d__ = this; } else { <JoinIterator>d__ = new <JoinIterator>d__80<TOuter, TInner, TKey, TResult>(0); } <JoinIterator>d__.outer = <>3__outer; <JoinIterator>d__.inner = <>3__inner; <JoinIterator>d__.outerKeySelector = <>3__outerKeySelector; <JoinIterator>d__.innerKeySelector = <>3__innerKeySelector; <JoinIterator>d__.resultSelector = <>3__resultSelector; <JoinIterator>d__.comparer = <>3__comparer; return <JoinIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<?>)(object)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <SelectIterator>d__150<TSource, TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.Generic.IEnumerable<TSource> source; public System.Collections.Generic.IEnumerable<TSource> <>3__source; private int <index>5__1; private Func<TSource, int, TResult> selector; public Func<TSource, int, TResult> <>3__selector; private System.Collections.Generic.IEnumerator<TSource> <>7__wrap1; TResult System.Collections.Generic.IEnumerator<?>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SelectIterator>d__150(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { checked { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <index>5__1 = -1; <>7__wrap1 = source.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } if (((System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { TSource current = <>7__wrap1.Current; <index>5__1++; <>2__current = ((Func<TSource, int, int>)(object)selector).Invoke(current, <index>5__1); <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((System.IDisposable)<>7__wrap1).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<?>.GetEnumerator() { <SelectIterator>d__150<TSource, TResult> <SelectIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <SelectIterator>d__ = this; } else { <SelectIterator>d__ = new <SelectIterator>d__150<TSource, TResult>(0); } <SelectIterator>d__.source = <>3__source; <SelectIterator>d__.selector = <>3__selector; return <SelectIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<?>)(object)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <SelectManyIterator>d__159<TSource, TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.Generic.IEnumerable<TSource> source; public System.Collections.Generic.IEnumerable<TSource> <>3__source; private Func<TSource, System.Collections.Generic.IEnumerable<TResult>> selector; public Func<TSource, System.Collections.Generic.IEnumerable<TResult>> <>3__selector; private System.Collections.Generic.IEnumerator<TSource> <>7__wrap1; private System.Collections.Generic.IEnumerator<TResult> <>7__wrap2; TResult System.Collections.Generic.IEnumerator<?>.Current { [DebuggerHidden] get { return <>2__current; } } object System.Collections.IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SelectManyIterator>d__159(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void System.IDisposable.Dispose() { int num = <>1__state; if (num != -4 && num != -3 && num != 1) { return; } try { if (num != -4 && num != 1) { return; } try { } finally { <>m__Finally2(); } } finally { <>m__Finally1(); } } private bool MoveNext() { try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -4; goto IL_008a; } <>1__state = -1; <>7__wrap1 = source.GetEnumerator(); <>1__state = -3; goto IL_00a4; IL_008a: if (((System.Collections.IEnumerator)<>7__wrap2).MoveNext()) { TResult current = ((System.Collections.Generic.IEnumerator<?>)<>7__wrap2).Current; <>2__current = current; <>1__state = 1; return true; } <>m__Finally2(); <>7__wrap2 = null; goto IL_00a4; IL_00a4: if (((System.Collections.IEnumerator)<>7__wrap1).MoveNext()) { TSource current2 = <>7__wrap1.Current; <>7__wrap2 = ((System.Collections.Generic.IEnumerable<?>)((Func<TSource, System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<TResult>>>)(object)selector).Invoke(current2)).GetEnumerator(); <>1__state = -4; goto IL_008a; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((System.IDisposable)this).Dispose(); throw; } } bool System.Collections.IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { ((System.IDisposable)<>7__wrap1).Dispose(); } } private void <>m__Finally2() { <>1__state = -3; if (<>7__wrap2 != null) { ((System.IDisposable)<>7__wrap2).Dispose(); } } [DebuggerHidden] void System.Collections.IEnumerator.Reset() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) throw new NotSupportedException(); } [DebuggerHidden] System.Collections.Generic.IEnumerator<TResult> System.Collections.Generic.IEnumerable<?>.GetEnumerator() { <SelectManyIterator>d__159<TSource, TResult> <SelectManyIterator>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <SelectManyIterator>d__ = this; } else { <SelectManyIterator>d__ = new <SelectManyIterator>d__159<TSource, TResult>(0); } <SelectManyIterator>d__.source = <>3__source; <SelectManyIterator>d__.selector = <>3__selector; return <SelectManyIterator>d__; } [DebuggerHidden] System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<?>)(object)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <SelectManyIterator>d__161<TSource, TResult> : System.Collections.Generic.IEnumerable<TResult>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<TResult>, System.Collections.IEnumerator, System.IDisposable { private int <>1__state; private TResult <>2__current; private int <>l__initialThreadId; private System.Collections.Generic.IEnumerable<TSource> source; public System.Collections.Generic.IEnumerable<TSource> <>3__source; private int <index>5__1; private Func<TSource, int, System.Collections.Generic.IEnumerable<TResult>> selector; public Func<TSource, int, System.Collections.Generic.IEnumerable<TResult>> <>3__selector; private System.Collections.Generic.IEnumerator<TSource> <>7__wrap1; private System.Collections.Generic.IEnumerator<TResul
BepInEx/plugins/DearImGuiInjection/PortableExecutable.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using NativeMemory; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("PortableExecutable")] [assembly: AssemblyConfiguration("netstandard2.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+af1e9534c67088d11779ad09d1aab2c19226e34a")] [assembly: AssemblyProduct("PortableExecutable")] [assembly: AssemblyTitle("PortableExecutable")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PortableExecutable { internal static class Log { internal const string Prefix = "[PortableExecutable] "; internal static void Debug(object data) { WriteLine(data, ConsoleColor.White); } internal static void Error(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Fatal(object data) { WriteLine(data, ConsoleColor.Red); } internal static void Info(object data) { WriteLine(data, ConsoleColor.White); } internal static void Message(object data) { WriteLine(data, ConsoleColor.White); } internal static void Warning(object data) { WriteLine(data, ConsoleColor.Yellow); } private static void WriteLine(object data, ConsoleColor color) { Console.ForegroundColor = color; Console.WriteLine("[PortableExecutable] " + data); Console.ResetColor(); } } public class PdbReader { private PEReader _target; private byte[] _pdbFileBytes; public PdbReader(PEReader target) { _target = target; } public bool FindOrDownloadPdb(string cacheDirectoryFullPath) { if (string.IsNullOrWhiteSpace(_target.RsdsPdbFileName)) { Log.Error("string.IsNullOrWhiteSpace(_target.RsdsPdbFileName)"); return false; } DirectoryInfo directoryInfo = Directory.CreateDirectory(cacheDirectoryFullPath); string text = Path.Combine(directoryInfo.FullName, string.Format("{0}-{1:N}.pdb", _target.RsdsPdbFileName.Replace(".pdb", string.Empty), _target.PdbGuid)); FileInfo fileInfo = new FileInfo(text); if (fileInfo.Exists && fileInfo.Length != 0L) { _pdbFileBytes = File.ReadAllBytes(text); return true; } foreach (FileInfo item in from file in directoryInfo.EnumerateFiles() where file.Name.StartsWith(_target.RsdsPdbFileName) select file) { try { item.Delete(); } catch (IOException) { } } using HttpClient httpClient = new HttpClient(); string uriString = $"https://msdl.microsoft.com/download/symbols/{_target.RsdsPdbFileName}/{_target.PdbGuid:N}{_target.PdbAge}/{_target.RsdsPdbFileName}"; using HttpResponseMessage httpResponseMessage = httpClient.GetAsync(new Uri(uriString), HttpCompletionOption.ResponseHeadersRead).GetAwaiter().GetResult(); if (!httpResponseMessage.IsSuccessStatusCode) { Log.Error($"Failed to download required files [{_target.RsdsPdbFileName}] with status code {httpResponseMessage.StatusCode}"); return false; } if (!httpResponseMessage.Content.Headers.ContentLength.HasValue) { Log.Error("Failed to retrieve content headers for required files [" + _target.RsdsPdbFileName + "]"); return false; } using Task<Stream> task = httpResponseMessage.Content.ReadAsStreamAsync(); task.Wait(); using Stream stream = task.Result; using FileStream fileStream = new FileStream(text, FileMode.Create); byte[] buffer = new byte[65536]; int num = 0; while (true) { int num2 = stream.Read(buffer, 0, 65536); if (num2 == 0) { break; } num += num2; double num3 = (double)num / (double)httpResponseMessage.Content.Headers.ContentLength.Value * 100.0; double num4 = num3 / 2.0; Log.Info($"\rDownloading required files [{_target.RsdsPdbFileName}] - [{new string('=', (int)num4)}{new string(' ', 50 - (int)num4)}] - {(int)num3}%"); fileStream.Write(buffer, 0, num2); } _pdbFileBytes = new byte[fileStream.Length]; fileStream.Position = 0L; fileStream.Read(_pdbFileBytes, 0, (int)fileStream.Length); return true; } public unsafe IntPtr FindFunctionOffset(BytePattern[] bytePatterns) { fixed (byte* ptr = &_pdbFileBytes[0]) { IntPtr pdbStartAddress = (IntPtr)ptr; long num = _pdbFileBytes.Length; long pdbEndAddress = (long)(ptr + num); var anon = bytePatterns.Select((BytePattern p) => new { p = p, res = p.Match(pdbStartAddress, pdbEndAddress) }).FirstOrDefault(m => m.res.ToInt64() > 0); if (anon == null) { Log.Error("No function offset found, cannot hook! Please report it to the devs!"); return IntPtr.Zero; } Log.Info($"Found at {anon.res:X} ({anon.res.ToInt64():X})"); uint* ptr2 = (uint*)(ptr + anon.res.ToInt64() - 7); uint num2 = *ptr2; ushort* ptr3 = (ushort*)(ptr + anon.res.ToInt64() - 3); int num3 = *ptr3 - 1; num2 += _target.ImageSectionHeaders[num3].VirtualAddress; Log.Info("Function offset : " + num2.ToString("X") + " | PE section : " + num3); return new IntPtr(num2); } } } public class PEReader { public struct IMAGE_DOS_HEADER { public ushort e_magic; public ushort e_cblp; public ushort e_cp; public ushort e_crlc; public ushort e_cparhdr; public ushort e_minalloc; public ushort e_maxalloc; public ushort e_ss; public ushort e_sp; public ushort e_csum; public ushort e_ip; public ushort e_cs; public ushort e_lfarlc; public ushort e_ovno; public ushort e_res_0; public ushort e_res_1; public ushort e_res_2; public ushort e_res_3; public ushort e_oemid; public ushort e_oeminfo; public ushort e_res2_0; public ushort e_res2_1; public ushort e_res2_2; public ushort e_res2_3; public ushort e_res2_4; public ushort e_res2_5; public ushort e_res2_6; public ushort e_res2_7; public ushort e_res2_8; public ushort e_res2_9; public uint e_lfanew; } public struct IMAGE_DATA_DIRECTORY { public uint VirtualAddress; public uint Size; } [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct IMAGE_OPTIONAL_HEADER32 { public ushort Magic; public byte MajorLinkerVersion; public byte MinorLinkerVersion; public uint SizeOfCode; public uint SizeOfInitializedData; public uint SizeOfUninitializedData; public uint AddressOfEntryPoint; public uint BaseOfCode; public uint BaseOfData; public uint ImageBase; public uint SectionAlignment; public uint FileAlignment; public ushort MajorOperatingSystemVersion; public ushort MinorOperatingSystemVersion; public ushort MajorImageVersion; public ushort MinorImageVersion; public ushort MajorSubsystemVersion; public ushort MinorSubsystemVersion; public uint Win32VersionValue; public uint SizeOfImage; public uint SizeOfHeaders; public uint CheckSum; public ushort Subsystem; public ushort DllCharacteristics; public uint SizeOfStackReserve; public uint SizeOfStackCommit; public uint SizeOfHeapReserve; public uint SizeOfHeapCommit; public uint LoaderFlags; public uint NumberOfRvaAndSizes; public IMAGE_DATA_DIRECTORY ExportTable; public IMAGE_DATA_DIRECTORY ImportTable; public IMAGE_DATA_DIRECTORY ResourceTable; public IMAGE_DATA_DIRECTORY ExceptionTable; public IMAGE_DATA_DIRECTORY CertificateTable; public IMAGE_DATA_DIRECTORY BaseRelocationTable; public IMAGE_DATA_DIRECTORY Debug; public IMAGE_DATA_DIRECTORY Architecture; public IMAGE_DATA_DIRECTORY GlobalPtr; public IMAGE_DATA_DIRECTORY TLSTable; public IMAGE_DATA_DIRECTORY LoadConfigTable; public IMAGE_DATA_DIRECTORY BoundImport; public IMAGE_DATA_DIRECTORY IAT; public IMAGE_DATA_DIRECTORY DelayImportDescriptor; public IMAGE_DATA_DIRECTORY CLRRuntimeHeader; public IMAGE_DATA_DIRECTORY Reserved; } [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct IMAGE_OPTIONAL_HEADER64 { public ushort Magic; public byte MajorLinkerVersion; public byte MinorLinkerVersion; public uint SizeOfCode; public uint SizeOfInitializedData; public uint SizeOfUninitializedData; public uint AddressOfEntryPoint; public uint BaseOfCode; public ulong ImageBase; public uint SectionAlignment; public uint FileAlignment; public ushort MajorOperatingSystemVersion; public ushort MinorOperatingSystemVersion; public ushort MajorImageVersion; public ushort MinorImageVersion; public ushort MajorSubsystemVersion; public ushort MinorSubsystemVersion; public uint Win32VersionValue; public uint SizeOfImage; public uint SizeOfHeaders; public uint CheckSum; public ushort Subsystem; public ushort DllCharacteristics; public ulong SizeOfStackReserve; public ulong SizeOfStackCommit; public ulong SizeOfHeapReserve; public ulong SizeOfHeapCommit; public uint LoaderFlags; public uint NumberOfRvaAndSizes; public IMAGE_DATA_DIRECTORY ExportTable; public IMAGE_DATA_DIRECTORY ImportTable; public IMAGE_DATA_DIRECTORY ResourceTable; public IMAGE_DATA_DIRECTORY ExceptionTable; public IMAGE_DATA_DIRECTORY CertificateTable; public IMAGE_DATA_DIRECTORY BaseRelocationTable; public IMAGE_DATA_DIRECTORY Debug; public IMAGE_DATA_DIRECTORY Architecture; public IMAGE_DATA_DIRECTORY GlobalPtr; public IMAGE_DATA_DIRECTORY TLSTable; public IMAGE_DATA_DIRECTORY LoadConfigTable; public IMAGE_DATA_DIRECTORY BoundImport; public IMAGE_DATA_DIRECTORY IAT; public IMAGE_DATA_DIRECTORY DelayImportDescriptor; public IMAGE_DATA_DIRECTORY CLRRuntimeHeader; public IMAGE_DATA_DIRECTORY Reserved; } [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct IMAGE_FILE_HEADER { public ushort Machine; public ushort NumberOfSections; public uint TimeDateStamp; public uint PointerToSymbolTable; public uint NumberOfSymbols; public ushort SizeOfOptionalHeader; public ushort Characteristics; } [StructLayout(LayoutKind.Explicit)] public struct IMAGE_SECTION_HEADER { [FieldOffset(0)] [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)] public string Name; [FieldOffset(8)] public uint VirtualSize; [FieldOffset(12)] public uint VirtualAddress; [FieldOffset(16)] public uint SizeOfRawData; [FieldOffset(20)] public uint PointerToRawData; [FieldOffset(24)] public uint PointerToRelocations; [FieldOffset(28)] public uint PointerToLinenumbers; [FieldOffset(32)] public ushort NumberOfRelocations; [FieldOffset(34)] public ushort NumberOfLinenumbers; [FieldOffset(36)] public DataSectionFlags Characteristics; } [Flags] public enum DataSectionFlags : uint { TypeReg = 0u, TypeDsect = 1u, TypeNoLoad = 2u, TypeGroup = 4u, TypeNoPadded = 8u, TypeCopy = 0x10u, ContentCode = 0x20u, ContentInitializedData = 0x40u, ContentUninitializedData = 0x80u, LinkOther = 0x100u, LinkInfo = 0x200u, TypeOver = 0x400u, LinkRemove = 0x800u, LinkComDat = 0x1000u, NoDeferSpecExceptions = 0x4000u, RelativeGP = 0x8000u, MemPurgeable = 0x20000u, Memory16Bit = 0x20000u, MemoryLocked = 0x40000u, MemoryPreload = 0x80000u, Align1Bytes = 0x100000u, Align2Bytes = 0x200000u, Align4Bytes = 0x300000u, Align8Bytes = 0x400000u, Align16Bytes = 0x500000u, Align32Bytes = 0x600000u, Align64Bytes = 0x700000u, Align128Bytes = 0x800000u, Align256Bytes = 0x900000u, Align512Bytes = 0xA00000u, Align1024Bytes = 0xB00000u, Align2048Bytes = 0xC00000u, Align4096Bytes = 0xD00000u, Align8192Bytes = 0xE00000u, LinkExtendedRelocationOverflow = 0x1000000u, MemoryDiscardable = 0x2000000u, MemoryNotCached = 0x4000000u, MemoryNotPaged = 0x8000000u, MemoryShared = 0x10000000u, MemoryExecute = 0x20000000u, MemoryRead = 0x40000000u, MemoryWrite = 0x80000000u } public struct IMAGE_DEBUG_DIRECTORY { public enum _Type : uint { IMAGE_DEBUG_TYPE_UNKNOWN, IMAGE_DEBUG_TYPE_COFF, IMAGE_DEBUG_TYPE_CODEVIEW, IMAGE_DEBUG_TYPE_FPO, IMAGE_DEBUG_TYPE_MISC, IMAGE_DEBUG_TYPE_EXCEPTION, IMAGE_DEBUG_TYPE_FIXUP, IMAGE_DEBUG_TYPE_OMAP_TO_SRC, IMAGE_DEBUG_TYPE_OMAP_FROM_SRC, IMAGE_DEBUG_TYPE_BORLAND, IMAGE_DEBUG_TYPE_RESERVED10, IMAGE_DEBUG_TYPE_CLSID, IMAGE_DEBUG_TYPE_VC_FEATURE, IMAGE_DEBUG_TYPE_POGO, IMAGE_DEBUG_TYPE_ILTCG, IMAGE_DEBUG_TYPE_MPX, IMAGE_DEBUG_TYPE_REPRO } public uint Characteristics; public uint TimeDateStamp; public ushort MajorVersion; public ushort MinorVersion; public _Type Type; public uint SizeOfData; public uint AddressOfRawData; public uint PointerToRawData; } public struct RSDS { internal const int Magic = 1396986706; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] internal byte[] Guid; internal uint Age; } private IMAGE_DOS_HEADER dosHeader; private IMAGE_FILE_HEADER fileHeader; private IMAGE_OPTIONAL_HEADER32 optionalHeader32; private IMAGE_OPTIONAL_HEADER64 optionalHeader64; private IMAGE_DEBUG_DIRECTORY? imageDebugDirectory; private string rsdsPdbFileName; private string pdbGuid; private string pdbAge; private IMAGE_SECTION_HEADER[] imageSectionHeaders; public bool Is32BitHeader { get { ushort num = 256; return (num & FileHeader.Characteristics) == num; } } public IMAGE_FILE_HEADER FileHeader => fileHeader; public IMAGE_OPTIONAL_HEADER32 OptionalHeader32 => optionalHeader32; public IMAGE_OPTIONAL_HEADER64 OptionalHeader64 => optionalHeader64; public IMAGE_DEBUG_DIRECTORY? ImageDebugDirectory => imageDebugDirectory; public IMAGE_SECTION_HEADER[] ImageSectionHeaders => imageSectionHeaders; public string RsdsPdbFileName => rsdsPdbFileName; public string PdbGuid => pdbGuid; public string PdbAge => pdbAge; public DateTime TimeStamp { get { DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(fileHeader.TimeDateStamp); return dateTime + TimeZone.CurrentTimeZone.GetUtcOffset(dateTime); } } public static PEReader FromFilePath(string filePath) { using FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read); return SafeNew(stream); } public static PEReader FromBytes(byte[] bytes) { using MemoryStream stream = new MemoryStream(bytes); return SafeNew(stream); } public static PEReader FromStream(Stream stream) { return SafeNew(stream); } private static PEReader SafeNew(Stream stream) { PEReader pEReader = new PEReader(); try { pEReader.Init(stream); return pEReader; } catch (Exception data) { Log.Error(data); return null; } } private void Init(Stream stream) { BinaryReader binaryReader = new BinaryReader(stream); dosHeader = FromBinaryReader<IMAGE_DOS_HEADER>(binaryReader); stream.Seek(dosHeader.e_lfanew, SeekOrigin.Begin); binaryReader.ReadUInt32(); fileHeader = FromBinaryReader<IMAGE_FILE_HEADER>(binaryReader); uint virtualAddress; if (Is32BitHeader) { optionalHeader32 = FromBinaryReader<IMAGE_OPTIONAL_HEADER32>(binaryReader); virtualAddress = optionalHeader32.Debug.VirtualAddress; } else { optionalHeader64 = FromBinaryReader<IMAGE_OPTIONAL_HEADER64>(binaryReader); virtualAddress = optionalHeader64.Debug.VirtualAddress; } imageSectionHeaders = new IMAGE_SECTION_HEADER[fileHeader.NumberOfSections]; for (int i = 0; i < imageSectionHeaders.Length; i++) { IMAGE_SECTION_HEADER imageSectionHeader = FromBinaryReader<IMAGE_SECTION_HEADER>(binaryReader); imageSectionHeaders[i] = imageSectionHeader; if (!imageDebugDirectory.HasValue) { imageDebugDirectory = TryGetDebugDirectory(binaryReader, virtualAddress, ref imageSectionHeader); } } if (imageDebugDirectory.HasValue) { TryGetRSDS(binaryReader); } } private IMAGE_DEBUG_DIRECTORY? TryGetDebugDirectory(BinaryReader reader, uint debugRva, ref IMAGE_SECTION_HEADER imageSectionHeader) { uint num = ((imageSectionHeader.VirtualSize != 0) ? imageSectionHeader.VirtualSize : imageSectionHeader.SizeOfRawData); if (debugRva >= imageSectionHeader.VirtualAddress && debugRva < imageSectionHeader.VirtualAddress + num) { long position = reader.BaseStream.Position; uint num2 = debugRva - imageSectionHeader.VirtualAddress + imageSectionHeader.PointerToRawData; reader.BaseStream.Position = num2; IMAGE_DEBUG_DIRECTORY value = FromBinaryReader<IMAGE_DEBUG_DIRECTORY>(reader); reader.BaseStream.Position = position; return value; } return null; } private void TryGetRSDS(BinaryReader reader) { var anon = new { RSDSFileOffset = ImageDebugDirectory.Value.PointerToRawData, Size = ImageDebugDirectory.Value.SizeOfData }; reader.BaseStream.Position = anon.RSDSFileOffset; long num = anon.RSDSFileOffset + anon.Size; while (reader.BaseStream.Position != num) { if (reader.ReadInt32() != 1396986706) { continue; } GCHandle gCHandle = GCHandle.Alloc(reader.ReadBytes(Marshal.SizeOf<RSDS>()), GCHandleType.Pinned); try { RSDS rSDS = Marshal.PtrToStructure<RSDS>(gCHandle.AddrOfPinnedObject()); pdbGuid = new Guid(rSDS.Guid).ToString("N").ToUpperInvariant(); pdbAge = rSDS.Age.ToString(); List<byte> list = new List<byte>(); bool flag = true; while (flag) { byte b = reader.ReadByte(); if (b != 0) { list.Add(b); } else { flag = false; } } rsdsPdbFileName = Path.GetFileName(Encoding.Default.GetString(list.ToArray())); break; } finally { gCHandle.Free(); } } } public static PEReader GetCallingAssemblyHeader() { return FromFilePath(Assembly.GetCallingAssembly().Location); } public static PEReader GetAssemblyHeader() { return FromFilePath(Assembly.GetAssembly(typeof(PEReader)).Location); } public static T FromBinaryReader<T>(BinaryReader reader) { GCHandle gCHandle = GCHandle.Alloc(reader.ReadBytes(Marshal.SizeOf(typeof(T))), GCHandleType.Pinned); T result = (T)Marshal.PtrToStructure(gCHandle.AddrOfPinnedObject(), typeof(T)); gCHandle.Free(); return result; } } }
BepInEx/plugins/DearImGuiInjection/Reloaded.Hooks.Definitions.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; using Reloaded.Hooks.Definitions.Enums; using Reloaded.Hooks.Definitions.Internal; using Reloaded.Hooks.Definitions.X64; using Reloaded.Hooks.Definitions.X86; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Sewer56")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Contains the definitions and attributes used in the Reloaded.Hooks library and their corresponding interfaces.")] [assembly: AssemblyFileVersion("1.15.0.0")] [assembly: AssemblyInformationalVersion("1.15.0")] [assembly: AssemblyProduct("Reloaded.Hooks")] [assembly: AssemblyTitle("Reloaded.Hooks.Definitions")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Reloaded-Project/Reloaded.Hooks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.15.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Reloaded.Hooks.Definitions { public class AsmHookOptions { public bool PreferRelativeJump { get; set; } public AsmHookBehaviour Behaviour { get; set; } public int hookLength { get; set; } = -1; public int MaxOpcodeSize { get; set; } = 7; } public class FunctionHookOptions : Attribute { public bool PreferRelativeJump { get; set; } public bool SearchInModules { get; set; } public bool VerifyJumpTargetsModule { get; set; } } public interface IAsmHook { bool IsEnabled { get; } IAsmHook Activate(); void Enable(); void Disable(); } public interface IFunction<TFunction> { long Address { get; } IReloadedHooks Hooks { get; } IHook<TFunction> Hook(TFunction function, int minHookLength); IHook<TFunction> Hook(TFunction function); unsafe IHook<TFunction> Hook(void* function, int minHookLength); unsafe IHook<TFunction> Hook(void* function); IHook<TFunction> Hook(Type type, string methodName, int minHookLength); IHook<TFunction> Hook(Type type, string methodName); unsafe IHook<TFunctionType> HookAs<TFunctionType>(void* function, int minHookLength); unsafe IHook<TFunctionType> HookAs<TFunctionType>(void* function); IHook<TFunctionType> HookAs<TFunctionType>(Type type, string methodName, int minHookLength); IHook<TFunctionType> HookAs<TFunctionType>(Type type, string methodName); TFunction GetWrapper(out IntPtr wrapperAddress); TFunction GetWrapper(); IAsmHook MakeAsmHook(string[] asmCode, AsmHookBehaviour behaviour = AsmHookBehaviour.ExecuteFirst, int hookLength = -1); IAsmHook MakeAsmHook(byte[] asmCode, AsmHookBehaviour behaviour = AsmHookBehaviour.ExecuteFirst, int hookLength = -1); } public interface IFunctionPtr<TDelegate> where TDelegate : Delegate { ulong FunctionPointer { get; } TDelegate this[int index] { get; } IntPtr GetFunctionAddress(int index = 0); TDelegate GetDelegate(int index = 0); } public interface IHook { bool IsHookEnabled { get; } bool IsHookActivated { get; } IntPtr OriginalFunctionAddress { get; } IntPtr OriginalFunctionWrapperAddress { get; } IHook Activate(); void Disable(); void Enable(); } public interface IHook<TFunction> : IHook { TFunction OriginalFunction { get; } IReverseWrapper<TFunction> ReverseWrapper { get; } new bool IsHookEnabled { get; } new bool IsHookActivated { get; } new IntPtr OriginalFunctionAddress { get; } new IntPtr OriginalFunctionWrapperAddress { get; } new IHook<TFunction> Activate(); new void Disable(); new void Enable(); } public interface IReloadedHooks { IReloadedHooksUtilities Utilities { get; } IFunction<TFunction> CreateFunction<TFunction>(long address); IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress); unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress); IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress, int minHookLength); unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress, int minHookLength); IHook<TFunction> CreateHook<TFunction>(TFunction function, long functionAddress, int minHookLength, FunctionHookOptions options); unsafe IHook<TFunction> CreateHook<TFunction>(void* targetAddress, long functionAddress, int minHookLength, FunctionHookOptions options); IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress, int minHookLength, FunctionHookOptions options); IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress, int minHookLength); IHook<TFunction> CreateHook<TFunction>(Type type, string methodName, long functionAddress); TFunction CreateWrapper<TFunction>(long functionAddress, out IntPtr wrapperAddress); IntPtr CreateWrapper<TFunction>(long functionAddress); IntPtr CreateNativeWrapperX86<TFunction>(IntPtr functionAddress, Reloaded.Hooks.Definitions.X86.IFunctionAttribute fromConvention); IntPtr CreateNativeWrapperX86<TFunction>(IntPtr functionAddress, Reloaded.Hooks.Definitions.X86.IFunctionAttribute fromConvention, Reloaded.Hooks.Definitions.X86.IFunctionAttribute toConvention); IntPtr CreateNativeWrapperX64<TFunction>(IntPtr functionAddress, Reloaded.Hooks.Definitions.X64.IFunctionAttribute fromConvention, Reloaded.Hooks.Definitions.X64.IFunctionAttribute toConvention); IReverseWrapper<TFunction> CreateReverseWrapper<TFunction>(TFunction function); IReverseWrapper<TFunction> CreateReverseWrapper<TFunction>(IntPtr function); IVirtualFunctionTable VirtualFunctionTableFromObject(IntPtr objectAddress, int numberOfMethods); IVirtualFunctionTable VirtualFunctionTableFromAddress(IntPtr tableAddress, int numberOfMethods); IFunctionPtr<TDelegate> CreateFunctionPtr<TDelegate>(ulong functionPointer) where TDelegate : Delegate; IAsmHook CreateAsmHook(string[] asmCode, long functionAddress); IAsmHook CreateAsmHook(string asmCode, long functionAddress); IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress); IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookBehaviour behaviour); IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookBehaviour behaviour); IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookBehaviour behaviour); IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength); IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength); IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookBehaviour behaviour, int hookLength); IAsmHook CreateAsmHook(string[] asmCode, long functionAddress, AsmHookOptions options); IAsmHook CreateAsmHook(string asmCode, long functionAddress, AsmHookOptions options); IAsmHook CreateAsmHook(byte[] asmCode, long functionAddress, AsmHookOptions options); IVirtualFunctionTable HookedVirtualFunctionTableFromObject(IntPtr objectAddress, int numberOfMethods); } public interface IReloadedHooksUtilities { byte[] AssembleAbsoluteJump(IntPtr target, bool is64bit); byte[] AssemblePushReturn(IntPtr target, bool is64bit); byte[] AssembleRelativeJump(IntPtr relativeJumpOffset, bool is64bit); byte[] AssembleRelativeJump(IntPtr currentAddress, IntPtr targetAddress, bool is64bit); string GetAbsoluteJumpMnemonics(IntPtr target, bool is64bit); string GetAbsoluteCallMnemonics(IntPtr target, bool is64bit); string GetAbsoluteJumpMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate; string GetAbsoluteCallMnemonics<TFunction>(TFunction function, out IReverseWrapper<TFunction> reverseWrapper) where TFunction : Delegate; string GetPushReturnMnemonics(IntPtr target, bool is64bit); string GetRelativeJumpMnemonics(IntPtr relativeJumpOffset, bool is64bit); IntPtr InsertJump(byte[] opcodes, bool is64bit, long jumpTarget, long targetAddress = 0L, long maxDisplacement = 2147483647L); int GetHookLength(IntPtr hookAddress, int hookLength, bool is64Bit); int GetNumberofParameters(Type delegateType); int GetNumberofParametersWithoutFloats(Type delegateType); int GetNumberofParameters<TFunction>(); int GetNumberofParametersWithoutFloats<TFunction>(); string PushCdeclCallerSavedRegisters(); string PopCdeclCallerSavedRegisters(); IntPtr WritePointer(IntPtr target); unsafe void* GetFunctionPointer(Type type, string name); (long min, long max) GetRelativeJumpMinMax(long targetAddress, long maxDisplacement = 2147483647L); } public interface IReverseWrapper { IntPtr NativeFunctionPtr { get; } IntPtr WrapperPointer { get; } } public interface IReverseWrapper<TFunction> : IReverseWrapper { TFunction CSharpFunction { get; } new IntPtr NativeFunctionPtr { get; } new IntPtr WrapperPointer { get; } } public interface IVirtualFunctionTable { List<TableEntry> TableEntries { get; set; } TableEntry this[int i] { get; set; } TFunction CreateWrapperFunction<TFunction>(int index); IHook<TFunction> CreateFunctionHook<TFunction>(int index, TFunction delegateType); } public struct TableEntry { public IntPtr EntryAddress; public IntPtr FunctionPointer; } } namespace Reloaded.Hooks.Definitions.X86 { public enum CallingConventions { Cdecl, Stdcall, Fastcall, MicrosoftThiscall, GCCThiscall, Usercall, Userpurge, ClrCall } public class FunctionAttribute : Attribute, IFunctionAttribute { public enum Register { eax, ebx, ecx, edx, esi, edi, ebp, esp } public enum StackCleanup { None, Caller, Callee } public static FunctionAttribute Cdecl = new FunctionAttribute(CallingConventions.Cdecl); public static FunctionAttribute StdCall = new FunctionAttribute(CallingConventions.Stdcall); public static FunctionAttribute Fastcall = new FunctionAttribute(CallingConventions.Fastcall); public static FunctionAttribute GccThiscall = new FunctionAttribute(CallingConventions.GCCThiscall); public static FunctionAttribute MicrosoftThiscall = new FunctionAttribute(CallingConventions.MicrosoftThiscall); public static Register[] DefaultSavedRegisters { get; } = new Register[3] { Register.ebx, Register.esi, Register.edi }; public Register[] SourceRegisters { get; } public Register ReturnRegister { get; } public StackCleanup Cleanup { get; } public int ReservedStackSpace { get; } public Register[] CalleeSavedRegisters { get; } = DefaultSavedRegisters; public FunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup, int reservedStackSpace = 0) { SourceRegisters = sourceRegisters; ReturnRegister = returnRegister; Cleanup = stackCleanup; ReservedStackSpace = reservedStackSpace; } public FunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters, int reservedStackSpace = 0) { SourceRegisters = sourceRegisters; ReturnRegister = returnRegister; Cleanup = stackCleanup; ReservedStackSpace = reservedStackSpace; CalleeSavedRegisters = calleeSavedRegisters; } public FunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup, int reservedStackSpace = 0) { SourceRegisters = new Register[1] { sourceRegister }; ReturnRegister = returnRegister; Cleanup = stackCleanup; ReservedStackSpace = reservedStackSpace; CalleeSavedRegisters = DefaultSavedRegisters; } public FunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters, int reservedStackSpace = 0) { SourceRegisters = new Register[1] { sourceRegister }; ReturnRegister = returnRegister; Cleanup = stackCleanup; ReservedStackSpace = reservedStackSpace; CalleeSavedRegisters = calleeSavedRegisters; } public FunctionAttribute(CallingConventions callingConvention) { switch (callingConvention) { case CallingConventions.Cdecl: SourceRegisters = new Register[0]; ReturnRegister = Register.eax; Cleanup = StackCleanup.Caller; CalleeSavedRegisters = DefaultSavedRegisters; break; case CallingConventions.Stdcall: SourceRegisters = new Register[0]; ReturnRegister = Register.eax; Cleanup = StackCleanup.Callee; CalleeSavedRegisters = DefaultSavedRegisters; break; case CallingConventions.Fastcall: SourceRegisters = new Register[2] { Register.ecx, Register.edx }; ReturnRegister = Register.eax; Cleanup = StackCleanup.Caller; CalleeSavedRegisters = DefaultSavedRegisters; break; case CallingConventions.MicrosoftThiscall: SourceRegisters = new Register[1] { Register.ecx }; ReturnRegister = Register.eax; Cleanup = StackCleanup.Callee; CalleeSavedRegisters = DefaultSavedRegisters; break; case CallingConventions.GCCThiscall: SourceRegisters = new Register[0]; ReturnRegister = Register.eax; Cleanup = StackCleanup.Caller; CalleeSavedRegisters = DefaultSavedRegisters; break; case CallingConventions.ClrCall: SourceRegisters = new Register[2] { Register.ecx, Register.edx }; ReturnRegister = Register.eax; Cleanup = StackCleanup.Callee; CalleeSavedRegisters = DefaultSavedRegisters; break; default: throw new ArgumentException("There is no preset for the specified calling convention " + callingConvention.GetType().Name); } } public bool IsEquivalent(UnmanagedFunctionPointerAttribute attribute) { if (attribute == null) { return Equals(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StdCall : Cdecl); } return attribute.CallingConvention switch { CallingConvention.Cdecl => Equals(Cdecl), CallingConvention.StdCall => Equals(StdCall), CallingConvention.ThisCall => Equals(MicrosoftThiscall), _ => false, }; } public IFunctionAttribute GetEquivalent(UnmanagedFunctionPointerAttribute attribute) { if (attribute == null) { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return Cdecl; } return StdCall; } return attribute.CallingConvention switch { CallingConvention.Cdecl => Cdecl, CallingConvention.StdCall => StdCall, CallingConvention.ThisCall => MicrosoftThiscall, CallingConvention.FastCall => Fastcall, CallingConvention.Winapi => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StdCall : Cdecl, _ => RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? StdCall : Cdecl, }; } public static IFunctionAttribute GetAttribute<TFunction>() { if (Misc.TryGetAttribute<TFunction, FunctionAttribute>(out var result)) { return result; } throw new Exception("FunctionAttribute is missing in the " + typeof(TFunction).Name + " delegate declaration.Please mark the " + typeof(TFunction).Name + " with an appropriate FunctionAttribute"); } [ExcludeFromCodeCoverage] public override bool Equals(object obj) { if (!(obj is FunctionAttribute functionAttribute)) { return false; } if (functionAttribute.Cleanup == Cleanup && functionAttribute.ReturnRegister == ReturnRegister && functionAttribute.SourceRegisters.SequenceEqual(SourceRegisters)) { return functionAttribute.CalleeSavedRegisters.SequenceEqual(CalleeSavedRegisters); } return false; } [ExcludeFromCodeCoverage] public override int GetHashCode() { int num = 13; Register[] sourceRegisters = SourceRegisters; foreach (Register register in sourceRegisters) { num = (int)(num * 7 + register); } num = (int)(num * 7 + ReturnRegister); num = (int)(num * 7 + Cleanup); sourceRegisters = CalleeSavedRegisters; foreach (Register register2 in sourceRegisters) { num = (int)(num * 7 + register2); } return num; } } public interface IFunctionAttribute { FunctionAttribute.Register[] SourceRegisters { get; } FunctionAttribute.Register ReturnRegister { get; } FunctionAttribute.StackCleanup Cleanup { get; } int ReservedStackSpace { get; } FunctionAttribute.Register[] CalleeSavedRegisters { get; } bool IsEquivalent(UnmanagedFunctionPointerAttribute attribute); IFunctionAttribute GetEquivalent(UnmanagedFunctionPointerAttribute attribute); } public class ManagedFunctionAttribute : FunctionAttribute { public ManagedFunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup) : base(sourceRegisters, returnRegister, stackCleanup) { } public ManagedFunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters) : base(sourceRegisters, returnRegister, stackCleanup, calleeSavedRegisters) { } public ManagedFunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup) : base(sourceRegister, returnRegister, stackCleanup) { } public ManagedFunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters) : base(sourceRegister, returnRegister, stackCleanup, calleeSavedRegisters) { } public ManagedFunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup, int reservedStackSpace) : base(sourceRegisters, returnRegister, stackCleanup, reservedStackSpace) { } public ManagedFunctionAttribute(Register[] sourceRegisters, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters, int reservedStackSpace) : base(sourceRegisters, returnRegister, stackCleanup, calleeSavedRegisters, reservedStackSpace) { } public ManagedFunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup, int reservedStackSpace) : base(sourceRegister, returnRegister, stackCleanup, reservedStackSpace) { } public ManagedFunctionAttribute(Register sourceRegister, Register returnRegister, StackCleanup stackCleanup, Register[] calleeSavedRegisters, int reservedStackSpace) : base(sourceRegister, returnRegister, stackCleanup, calleeSavedRegisters, reservedStackSpace) { } public ManagedFunctionAttribute(CallingConventions callingConvention) : base(callingConvention) { } } } namespace Reloaded.Hooks.Definitions.X64 { public enum CallingConventions { Microsoft, SystemV, Custom } public class FunctionAttribute : Attribute, IFunctionAttribute { public enum Register { rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r8, r9, r10, r11, r12, r13, r14, r15 } public static Register[] DefaultSavedRegisters { get; } = new Register[7] { Register.rbx, Register.rdi, Register.rsi, Register.r12, Register.r13, Register.r14, Register.r15 }; public static FunctionAttribute Microsoft { get; } = new FunctionAttribute(CallingConventions.Microsoft); public static FunctionAttribute SystemV { get; } = new FunctionAttribute(CallingConventions.SystemV); public Register[] SourceRegisters { get; } public Register ReturnRegister { get; } public bool ShadowSpace { get; } = true; public Register[] CalleeSavedRegisters { get; } = DefaultSavedRegisters; public FunctionAttribute(Register[] sourceRegisters, Register returnRegister, bool shadowSpace) { SourceRegisters = sourceRegisters; ReturnRegister = returnRegister; ShadowSpace = shadowSpace; } public FunctionAttribute(Register sourceRegister, Register returnRegister, bool shadowSpace) { SourceRegisters = new Register[1] { sourceRegister }; ReturnRegister = returnRegister; ShadowSpace = shadowSpace; CalleeSavedRegisters = DefaultSavedRegisters; } public FunctionAttribute(Register sourceRegister, Register returnRegister, bool shadowSpace, Register[] calleeSavedRegisters) { SourceRegisters = new Register[1] { sourceRegister }; ReturnRegister = returnRegister; ShadowSpace = shadowSpace; CalleeSavedRegisters = calleeSavedRegisters; } public FunctionAttribute(Register[] sourceRegisters, Register returnRegister, bool shadowSpace, Register[] calleeSavedRegisters) { SourceRegisters = sourceRegisters; ReturnRegister = returnRegister; ShadowSpace = shadowSpace; CalleeSavedRegisters = calleeSavedRegisters; } public FunctionAttribute(CallingConventions callingConvention) { switch (callingConvention) { case CallingConventions.Microsoft: SourceRegisters = new Register[4] { Register.rcx, Register.rdx, Register.r8, Register.r9 }; CalleeSavedRegisters = new Register[7] { Register.rbx, Register.rdi, Register.rsi, Register.r12, Register.r13, Register.r14, Register.r15 }; ReturnRegister = Register.rax; ShadowSpace = true; break; case CallingConventions.SystemV: SourceRegisters = new Register[6] { Register.rdi, Register.rsi, Register.rdx, Register.rcx, Register.r8, Register.r9 }; CalleeSavedRegisters = new Register[5] { Register.rbx, Register.r12, Register.r13, Register.r14, Register.r15 }; ReturnRegister = Register.rax; ShadowSpace = false; break; default: throw new ArgumentException("There is no preset for the specified calling convention " + callingConvention.GetType().Name); } } public static IFunctionAttribute GetAttribute<TFunction>() { object[] customAttributes = typeof(TFunction).GetCustomAttributes(inherit: false); for (int i = 0; i < customAttributes.Length; i++) { if ((Attribute)customAttributes[i] is FunctionAttribute result) { return result; } } return new FunctionAttribute(CallingConventions.Microsoft); } [ExcludeFromCodeCoverage] public override bool Equals(object obj) { if (!(obj is FunctionAttribute functionAttribute)) { return false; } if (functionAttribute.ShadowSpace == ShadowSpace && functionAttribute.ReturnRegister == ReturnRegister && functionAttribute.SourceRegisters.SequenceEqual(SourceRegisters)) { return functionAttribute.CalleeSavedRegisters.SequenceEqual(CalleeSavedRegisters); } return false; } [ExcludeFromCodeCoverage] public override int GetHashCode() { int num = 13; Register[] sourceRegisters = SourceRegisters; foreach (Register register in sourceRegisters) { num = (int)(num * 7 + register); } num = (int)(num * 7 + ReturnRegister); num = num * 7 + ShadowSpace.GetHashCode(); sourceRegisters = CalleeSavedRegisters; foreach (Register register2 in sourceRegisters) { num = (int)(num * 7 + register2); } return num; } } public interface IFunctionAttribute { FunctionAttribute.Register[] SourceRegisters { get; } FunctionAttribute.Register ReturnRegister { get; } bool ShadowSpace { get; } FunctionAttribute.Register[] CalleeSavedRegisters { get; } } } namespace Reloaded.Hooks.Definitions.Structs { [ExcludeFromCodeCoverage] public struct FuncPtr<TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<TReturn> Invoke => (delegate* unmanaged[Stdcall]<TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<TReturn>(void* ptr) { return new FuncPtr<TReturn>(ptr); } public unsafe static implicit operator FuncPtr<TReturn>(IntPtr ptr) { return new FuncPtr<TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<TReturn>(delegate* unmanaged[Cdecl]<TReturn> ptr) { return new FuncPtr<TReturn>(ptr); } public unsafe static implicit operator FuncPtr<TReturn>(delegate* unmanaged[Stdcall]<TReturn> ptr) { return new FuncPtr<TReturn>(ptr); } public unsafe static implicit operator FuncPtr<TReturn>(delegate* unmanaged[Thiscall]<TReturn> ptr) { return new FuncPtr<TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, TReturn>(void* ptr) { return new FuncPtr<T1, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, TReturn>(IntPtr ptr) { return new FuncPtr<T1, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, TReturn>(delegate* unmanaged[Cdecl]<T1, TReturn> ptr) { return new FuncPtr<T1, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, TReturn>(delegate* unmanaged[Stdcall]<T1, TReturn> ptr) { return new FuncPtr<T1, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, TReturn>(delegate* unmanaged[Thiscall]<T1, TReturn> ptr) { return new FuncPtr<T1, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, TReturn>(void* ptr) { return new FuncPtr<T1, T2, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, TReturn> ptr) { return new FuncPtr<T1, T2, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, TReturn> ptr) { return new FuncPtr<T1, T2, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, TReturn> ptr) { return new FuncPtr<T1, T2, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, TReturn> ptr) { return new FuncPtr<T1, T2, T3, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, TReturn> ptr) { return new FuncPtr<T1, T2, T3, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, TReturn> ptr) { return new FuncPtr<T1, T2, T3, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, TReturn>(ptr); } } [ExcludeFromCodeCoverage] public struct FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> : IFuncPtr { public unsafe void* funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> Invoke => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)funcPtr; public unsafe delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> InvokeAsCdecl => (delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)funcPtr; public unsafe delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> InvokeAsStdcall => (delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)funcPtr; public unsafe delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> InvokeAsThiscall => (delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)funcPtr; public int NumberOfParameters => FuncPtr.GetNumberOfParameters(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)); public int NumberOfParametersWithoutFloats => FuncPtr.GetNumberOfParametersWithoutFloats(typeof(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>)); public unsafe FuncPtr(void* ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { funcPtr = ptr; } public unsafe FuncPtr(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { funcPtr = ptr; } public unsafe static explicit operator void*(FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> func) { return func.funcPtr; } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(void* ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(IntPtr ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>((void*)ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(delegate* unmanaged[Cdecl]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(delegate* unmanaged[Stdcall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(ptr); } public unsafe static implicit operator FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(delegate* unmanaged[Thiscall]<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn> ptr) { return new FuncPtr<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, TReturn>(ptr); } } public interface IFuncPtr { int NumberOfParameters { get; } int NumberOfParametersWithoutFloats { get; } } public static class FuncPtr { public static int GetNumberOfParameters(Type type) { return type.GenericTypeArguments.Length - 1; } public static int GetNumberOfParametersWithoutFloats(Type type) { return type.GenericTypeArguments.Take(GetNumberOfParameters(type)).Count((Type x) => x != typeof(float) && x != typeof(double)); } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct Void { } } namespace Reloaded.Hooks.Definitions.Internal { public class Misc { public static bool TryGetAttribute<TType, TAttribute>(out TAttribute result) where TAttribute : class { result = null; object[] customAttributes = typeof(TType).GetCustomAttributes(inherit: false); for (int i = 0; i < customAttributes.Length; i++) { Attribute attribute = (Attribute)customAttributes[i]; if (attribute.GetType() == typeof(TAttribute)) { result = attribute as TAttribute; return true; } } return false; } public static TAttribute TryGetAttributeOrDefault<TType, TAttribute>() where TAttribute : class { if (TryGetAttribute<TType, TAttribute>(out var result)) { return result; } return null; } } } namespace Reloaded.Hooks.Definitions.Helpers { public static class AddressExtensions { public static ulong ToUnsigned(this long value) { return Unsafe.As<long, ulong>(ref value); } public static nuint ToUnsigned(this nint value) { return Unsafe.As<IntPtr, UIntPtr>(ref value); } public static nint ToSigned(this nuint value) { return Unsafe.As<UIntPtr, IntPtr>(ref value); } } } namespace Reloaded.Hooks.Definitions.Enums { public enum AsmHookBehaviour { ExecuteFirst, ExecuteAfter, DoNotExecuteOriginal } }
BepInEx/plugins/DearImGuiInjection/System.Threading.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Diagnostics.Tracing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Threading; using FxResources.System.Threading; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Threading")] [assembly: AssemblyDescription("System.Threading")] [assembly: AssemblyDefaultAlias("System.Threading")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.12.0")] [assembly: TypeForwardedTo(typeof(AbandonedMutexException))] [assembly: TypeForwardedTo(typeof(AsyncLocal<>))] [assembly: TypeForwardedTo(typeof(AsyncLocalValueChangedArgs<>))] [assembly: TypeForwardedTo(typeof(AutoResetEvent))] [assembly: TypeForwardedTo(typeof(ContextCallback))] [assembly: TypeForwardedTo(typeof(EventResetMode))] [assembly: TypeForwardedTo(typeof(EventWaitHandle))] [assembly: TypeForwardedTo(typeof(ExecutionContext))] [assembly: TypeForwardedTo(typeof(Interlocked))] [assembly: TypeForwardedTo(typeof(LazyInitializer))] [assembly: TypeForwardedTo(typeof(LockRecursionException))] [assembly: TypeForwardedTo(typeof(ManualResetEvent))] [assembly: TypeForwardedTo(typeof(ManualResetEventSlim))] [assembly: TypeForwardedTo(typeof(Monitor))] [assembly: TypeForwardedTo(typeof(Mutex))] [assembly: TypeForwardedTo(typeof(Semaphore))] [assembly: TypeForwardedTo(typeof(SemaphoreFullException))] [assembly: TypeForwardedTo(typeof(SemaphoreSlim))] [assembly: TypeForwardedTo(typeof(SendOrPostCallback))] [assembly: TypeForwardedTo(typeof(SpinLock))] [assembly: TypeForwardedTo(typeof(SpinWait))] [assembly: TypeForwardedTo(typeof(SynchronizationContext))] [assembly: TypeForwardedTo(typeof(SynchronizationLockException))] [assembly: TypeForwardedTo(typeof(ThreadLocal<>))] [assembly: TypeForwardedTo(typeof(Volatile))] [assembly: TypeForwardedTo(typeof(WaitHandleCannotBeOpenedException))] [module: UnverifiableCode] namespace FxResources.System.Threading { internal static class SR { } } namespace System { internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Threading.SR"; private static ResourceManager ResourceManager { get { if (s_resourceManager == null) { s_resourceManager = new ResourceManager(ResourceType); } return s_resourceManager; } } internal static string CountdownEvent_Increment_AlreadyZero => GetResourceString("CountdownEvent_Increment_AlreadyZero", null); internal static string CountdownEvent_Increment_AlreadyMax => GetResourceString("CountdownEvent_Increment_AlreadyMax", null); internal static string CountdownEvent_Decrement_BelowZero => GetResourceString("CountdownEvent_Decrement_BelowZero", null); internal static string Common_OperationCanceled => GetResourceString("Common_OperationCanceled", null); internal static string Barrier_Dispose => GetResourceString("Barrier_Dispose", null); internal static string Barrier_SignalAndWait_InvalidOperation_ZeroTotal => GetResourceString("Barrier_SignalAndWait_InvalidOperation_ZeroTotal", null); internal static string Barrier_SignalAndWait_ArgumentOutOfRange => GetResourceString("Barrier_SignalAndWait_ArgumentOutOfRange", null); internal static string Barrier_RemoveParticipants_InvalidOperation => GetResourceString("Barrier_RemoveParticipants_InvalidOperation", null); internal static string Barrier_RemoveParticipants_ArgumentOutOfRange => GetResourceString("Barrier_RemoveParticipants_ArgumentOutOfRange", null); internal static string Barrier_RemoveParticipants_NonPositive_ArgumentOutOfRange => GetResourceString("Barrier_RemoveParticipants_NonPositive_ArgumentOutOfRange", null); internal static string Barrier_InvalidOperation_CalledFromPHA => GetResourceString("Barrier_InvalidOperation_CalledFromPHA", null); internal static string Barrier_AddParticipants_NonPositive_ArgumentOutOfRange => GetResourceString("Barrier_AddParticipants_NonPositive_ArgumentOutOfRange", null); internal static string Barrier_SignalAndWait_InvalidOperation_ThreadsExceeded => GetResourceString("Barrier_SignalAndWait_InvalidOperation_ThreadsExceeded", null); internal static string BarrierPostPhaseException => GetResourceString("BarrierPostPhaseException", null); internal static string Barrier_ctor_ArgumentOutOfRange => GetResourceString("Barrier_ctor_ArgumentOutOfRange", null); internal static string Barrier_AddParticipants_Overflow_ArgumentOutOfRange => GetResourceString("Barrier_AddParticipants_Overflow_ArgumentOutOfRange", null); internal static string SynchronizationLockException_IncorrectDispose => GetResourceString("SynchronizationLockException_IncorrectDispose", null); internal static string SynchronizationLockException_MisMatchedWrite => GetResourceString("SynchronizationLockException_MisMatchedWrite", null); internal static string LockRecursionException_UpgradeAfterReadNotAllowed => GetResourceString("LockRecursionException_UpgradeAfterReadNotAllowed", null); internal static string LockRecursionException_UpgradeAfterWriteNotAllowed => GetResourceString("LockRecursionException_UpgradeAfterWriteNotAllowed", null); internal static string SynchronizationLockException_MisMatchedUpgrade => GetResourceString("SynchronizationLockException_MisMatchedUpgrade", null); internal static string SynchronizationLockException_MisMatchedRead => GetResourceString("SynchronizationLockException_MisMatchedRead", null); internal static string LockRecursionException_WriteAfterReadNotAllowed => GetResourceString("LockRecursionException_WriteAfterReadNotAllowed", null); internal static string LockRecursionException_RecursiveWriteNotAllowed => GetResourceString("LockRecursionException_RecursiveWriteNotAllowed", null); internal static string LockRecursionException_ReadAfterWriteNotAllowed => GetResourceString("LockRecursionException_ReadAfterWriteNotAllowed", null); internal static string LockRecursionException_RecursiveUpgradeNotAllowed => GetResourceString("LockRecursionException_RecursiveUpgradeNotAllowed", null); internal static string LockRecursionException_RecursiveReadNotAllowed => GetResourceString("LockRecursionException_RecursiveReadNotAllowed", null); internal static Type ResourceType => typeof(FxResources.System.Threading.SR); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Threading { internal static class Helpers { internal static void Sleep(int milliseconds) { Thread.Sleep(milliseconds); } internal static void Spin(int iterations) { Thread.SpinWait(iterations); } } public class BarrierPostPhaseException : Exception { public BarrierPostPhaseException() : this((string)null) { } public BarrierPostPhaseException(Exception innerException) : this(null, innerException) { } public BarrierPostPhaseException(string message) : this(message, null) { } public BarrierPostPhaseException(string message, Exception innerException) : base((message == null) ? System.SR.BarrierPostPhaseException : message, innerException) { } } [DebuggerDisplay("Participant Count={ParticipantCount},Participants Remaining={ParticipantsRemaining}")] public class Barrier : IDisposable { private volatile int _currentTotalCount; private const int CURRENT_MASK = 2147418112; private const int TOTAL_MASK = 32767; private const int SENSE_MASK = int.MinValue; private const int MAX_PARTICIPANTS = 32767; private long _currentPhase; private bool _disposed; private ManualResetEventSlim _oddEvent; private ManualResetEventSlim _evenEvent; private ExecutionContext _ownerThreadContext; [SecurityCritical] private static ContextCallback s_invokePostPhaseAction; private Action<Barrier> _postPhaseAction; private Exception _exception; private int _actionCallerID; public int ParticipantsRemaining { get { int currentTotalCount = _currentTotalCount; int num = currentTotalCount & 0x7FFF; int num2 = (currentTotalCount & 0x7FFF0000) >> 16; return num - num2; } } public int ParticipantCount => _currentTotalCount & 0x7FFF; public long CurrentPhaseNumber { get { return Volatile.Read(ref _currentPhase); } internal set { Volatile.Write(ref _currentPhase, value); } } public Barrier(int participantCount) : this(participantCount, null) { } public Barrier(int participantCount, Action<Barrier> postPhaseAction) { if (participantCount < 0 || participantCount > 32767) { throw new ArgumentOutOfRangeException("participantCount", participantCount, System.SR.Barrier_ctor_ArgumentOutOfRange); } _currentTotalCount = participantCount; _postPhaseAction = postPhaseAction; _oddEvent = new ManualResetEventSlim(initialState: true); _evenEvent = new ManualResetEventSlim(initialState: false); if (postPhaseAction != null) { _ownerThreadContext = ExecutionContext.Capture(); } _actionCallerID = 0; } private void GetCurrentTotal(int currentTotal, out int current, out int total, out bool sense) { total = currentTotal & 0x7FFF; current = (currentTotal & 0x7FFF0000) >> 16; sense = (((currentTotal & int.MinValue) == 0) ? true : false); } private bool SetCurrentTotal(int currentTotal, int current, int total, bool sense) { int num = (current << 16) | total; if (!sense) { num |= int.MinValue; } return Interlocked.CompareExchange(ref _currentTotalCount, num, currentTotal) == currentTotal; } public long AddParticipant() { try { return AddParticipants(1); } catch (ArgumentOutOfRangeException) { throw new InvalidOperationException(System.SR.Barrier_AddParticipants_Overflow_ArgumentOutOfRange); } } public long AddParticipants(int participantCount) { ThrowIfDisposed(); if (participantCount < 1) { throw new ArgumentOutOfRangeException("participantCount", participantCount, System.SR.Barrier_AddParticipants_NonPositive_ArgumentOutOfRange); } if (participantCount > 32767) { throw new ArgumentOutOfRangeException("participantCount", System.SR.Barrier_AddParticipants_Overflow_ArgumentOutOfRange); } if (_actionCallerID != 0 && Environment.CurrentManagedThreadId == _actionCallerID) { throw new InvalidOperationException(System.SR.Barrier_InvalidOperation_CalledFromPHA); } SpinWait spinWait = default(SpinWait); long num = 0L; bool sense; while (true) { int currentTotalCount = _currentTotalCount; GetCurrentTotal(currentTotalCount, out var current, out var total, out sense); if (participantCount + total > 32767) { throw new ArgumentOutOfRangeException("participantCount", System.SR.Barrier_AddParticipants_Overflow_ArgumentOutOfRange); } if (SetCurrentTotal(currentTotalCount, current, total + participantCount, sense)) { break; } spinWait.SpinOnce(); } long currentPhaseNumber = CurrentPhaseNumber; num = ((sense != (currentPhaseNumber % 2 == 0)) ? (currentPhaseNumber + 1) : currentPhaseNumber); if (num != currentPhaseNumber) { if (sense) { _oddEvent.Wait(); } else { _evenEvent.Wait(); } } else if (sense && _evenEvent.IsSet) { _evenEvent.Reset(); } else if (!sense && _oddEvent.IsSet) { _oddEvent.Reset(); } return num; } public void RemoveParticipant() { RemoveParticipants(1); } public void RemoveParticipants(int participantCount) { ThrowIfDisposed(); if (participantCount < 1) { throw new ArgumentOutOfRangeException("participantCount", participantCount, System.SR.Barrier_RemoveParticipants_NonPositive_ArgumentOutOfRange); } if (_actionCallerID != 0 && Environment.CurrentManagedThreadId == _actionCallerID) { throw new InvalidOperationException(System.SR.Barrier_InvalidOperation_CalledFromPHA); } SpinWait spinWait = default(SpinWait); while (true) { int currentTotalCount = _currentTotalCount; GetCurrentTotal(currentTotalCount, out var current, out var total, out var sense); if (total < participantCount) { throw new ArgumentOutOfRangeException("participantCount", System.SR.Barrier_RemoveParticipants_ArgumentOutOfRange); } if (total - participantCount < current) { throw new InvalidOperationException(System.SR.Barrier_RemoveParticipants_InvalidOperation); } int num = total - participantCount; if (num > 0 && current == num) { if (SetCurrentTotal(currentTotalCount, 0, total - participantCount, !sense)) { FinishPhase(sense); break; } } else if (SetCurrentTotal(currentTotalCount, current, total - participantCount, sense)) { break; } spinWait.SpinOnce(); } } public void SignalAndWait() { SignalAndWait(default(CancellationToken)); } public void SignalAndWait(CancellationToken cancellationToken) { SignalAndWait(-1, cancellationToken); } public bool SignalAndWait(TimeSpan timeout) { return SignalAndWait(timeout, default(CancellationToken)); } public bool SignalAndWait(TimeSpan timeout, CancellationToken cancellationToken) { long num = (long)timeout.TotalMilliseconds; if (num < -1 || num > int.MaxValue) { throw new ArgumentOutOfRangeException("timeout", timeout, System.SR.Barrier_SignalAndWait_ArgumentOutOfRange); } return SignalAndWait((int)timeout.TotalMilliseconds, cancellationToken); } public bool SignalAndWait(int millisecondsTimeout) { return SignalAndWait(millisecondsTimeout, default(CancellationToken)); } public bool SignalAndWait(int millisecondsTimeout, CancellationToken cancellationToken) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException("millisecondsTimeout", millisecondsTimeout, System.SR.Barrier_SignalAndWait_ArgumentOutOfRange); } if (_actionCallerID != 0 && Environment.CurrentManagedThreadId == _actionCallerID) { throw new InvalidOperationException(System.SR.Barrier_InvalidOperation_CalledFromPHA); } SpinWait spinWait = default(SpinWait); int current; int total; bool sense; long currentPhaseNumber; while (true) { int currentTotalCount = _currentTotalCount; GetCurrentTotal(currentTotalCount, out current, out total, out sense); currentPhaseNumber = CurrentPhaseNumber; if (total == 0) { throw new InvalidOperationException(System.SR.Barrier_SignalAndWait_InvalidOperation_ZeroTotal); } if (current == 0 && sense != (CurrentPhaseNumber % 2 == 0)) { throw new InvalidOperationException(System.SR.Barrier_SignalAndWait_InvalidOperation_ThreadsExceeded); } if (current + 1 == total) { if (SetCurrentTotal(currentTotalCount, 0, total, !sense)) { if (System.Threading.CdsSyncEtwBCLProvider.Log.IsEnabled()) { System.Threading.CdsSyncEtwBCLProvider.Log.Barrier_PhaseFinished(sense, CurrentPhaseNumber); } FinishPhase(sense); return true; } } else if (SetCurrentTotal(currentTotalCount, current + 1, total, sense)) { break; } spinWait.SpinOnce(); } ManualResetEventSlim currentPhaseEvent = (sense ? _evenEvent : _oddEvent); bool flag = false; bool flag2 = false; try { flag2 = DiscontinuousWait(currentPhaseEvent, millisecondsTimeout, cancellationToken, currentPhaseNumber); } catch (OperationCanceledException) { flag = true; } catch (ObjectDisposedException) { if (currentPhaseNumber >= CurrentPhaseNumber) { throw; } flag2 = true; } if (!flag2) { spinWait.Reset(); while (true) { int currentTotalCount = _currentTotalCount; GetCurrentTotal(currentTotalCount, out current, out total, out var sense2); if (currentPhaseNumber < CurrentPhaseNumber || sense != sense2) { break; } if (SetCurrentTotal(currentTotalCount, current - 1, total, sense)) { if (flag) { throw new OperationCanceledException(System.SR.Common_OperationCanceled, cancellationToken); } return false; } spinWait.SpinOnce(); } WaitCurrentPhase(currentPhaseEvent, currentPhaseNumber); } if (_exception != null) { throw new BarrierPostPhaseException(_exception); } return true; } [SecuritySafeCritical] private void FinishPhase(bool observedSense) { if (_postPhaseAction != null) { try { _actionCallerID = Environment.CurrentManagedThreadId; if (_ownerThreadContext != null) { ExecutionContext ownerThreadContext = _ownerThreadContext; ContextCallback callback = InvokePostPhaseAction; ExecutionContext.Run(_ownerThreadContext, callback, this); } else { _postPhaseAction(this); } _exception = null; return; } catch (Exception exception) { _exception = exception; return; } finally { _actionCallerID = 0; SetResetEvents(observedSense); if (_exception != null) { throw new BarrierPostPhaseException(_exception); } } } SetResetEvents(observedSense); } [SecurityCritical] private static void InvokePostPhaseAction(object obj) { Barrier barrier = (Barrier)obj; barrier._postPhaseAction(barrier); } private void SetResetEvents(bool observedSense) { CurrentPhaseNumber++; if (observedSense) { _oddEvent.Reset(); _evenEvent.Set(); } else { _evenEvent.Reset(); _oddEvent.Set(); } } private void WaitCurrentPhase(ManualResetEventSlim currentPhaseEvent, long observedPhase) { SpinWait spinWait = default(SpinWait); while (!currentPhaseEvent.IsSet && CurrentPhaseNumber - observedPhase <= 1) { spinWait.SpinOnce(); } } private bool DiscontinuousWait(ManualResetEventSlim currentPhaseEvent, int totalTimeout, CancellationToken token, long observedPhase) { int num = 100; int num2 = 10000; while (observedPhase == CurrentPhaseNumber) { int num3 = ((totalTimeout == -1) ? num : Math.Min(num, totalTimeout)); if (currentPhaseEvent.Wait(num3, token)) { return true; } if (totalTimeout != -1) { totalTimeout -= num3; if (totalTimeout <= 0) { return false; } } num = ((num >= num2) ? num2 : Math.Min(num << 1, num2)); } WaitCurrentPhase(currentPhaseEvent, observedPhase); return true; } public void Dispose() { if (_actionCallerID != 0 && Environment.CurrentManagedThreadId == _actionCallerID) { throw new InvalidOperationException(System.SR.Barrier_InvalidOperation_CalledFromPHA); } Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _oddEvent.Dispose(); _evenEvent.Dispose(); } _disposed = true; } } private void ThrowIfDisposed() { if (_disposed) { throw new ObjectDisposedException("Barrier", System.SR.Barrier_Dispose); } } } [EventSource(Name = "System.Threading.SynchronizationEventSource", Guid = "EC631D38-466B-4290-9306-834971BA0217")] internal sealed class CdsSyncEtwBCLProvider : EventSource { public static System.Threading.CdsSyncEtwBCLProvider Log = new System.Threading.CdsSyncEtwBCLProvider(); private const EventKeywords ALL_KEYWORDS = EventKeywords.All; private const int SPINLOCK_FASTPATHFAILED_ID = 1; private const int SPINWAIT_NEXTSPINWILLYIELD_ID = 2; private const int BARRIER_PHASEFINISHED_ID = 3; private CdsSyncEtwBCLProvider() { } [Event(1, Level = EventLevel.Warning)] public void SpinLock_FastPathFailed(int ownerID) { if (IsEnabled(EventLevel.Warning, EventKeywords.All)) { WriteEvent(1, ownerID); } } [Event(2, Level = EventLevel.Informational)] public void SpinWait_NextSpinWillYield() { if (IsEnabled(EventLevel.Informational, EventKeywords.All)) { WriteEvent(2); } } [SecuritySafeCritical] [Event(3, Level = EventLevel.Verbose, Version = 1)] public unsafe void Barrier_PhaseFinished(bool currentSense, long phaseNum) { if (IsEnabled(EventLevel.Verbose, EventKeywords.All)) { EventData* ptr = stackalloc EventData[2]; int num = (currentSense ? 1 : 0); ptr->Size = 4; ptr->DataPointer = (IntPtr)(&num); ptr[1].Size = 8; ptr[1].DataPointer = (IntPtr)(&phaseNum); WriteEventCore(3, 2, ptr); } } } [DebuggerDisplay("Initial Count={InitialCount}, Current Count={CurrentCount}")] public class CountdownEvent : IDisposable { private int _initialCount; private volatile int _currentCount; private ManualResetEventSlim _event; private volatile bool _disposed; public int CurrentCount { get { int currentCount = _currentCount; if (currentCount >= 0) { return currentCount; } return 0; } } public int InitialCount => _initialCount; public bool IsSet => _currentCount <= 0; public WaitHandle WaitHandle { get { ThrowIfDisposed(); return _event.WaitHandle; } } public CountdownEvent(int initialCount) { if (initialCount < 0) { throw new ArgumentOutOfRangeException("initialCount"); } _initialCount = initialCount; _currentCount = initialCount; _event = new ManualResetEventSlim(); if (initialCount == 0) { _event.Set(); } } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { _event.Dispose(); _disposed = true; } } public bool Signal() { ThrowIfDisposed(); if (_currentCount <= 0) { throw new InvalidOperationException(System.SR.CountdownEvent_Decrement_BelowZero); } int num = Interlocked.Decrement(ref _currentCount); if (num == 0) { _event.Set(); return true; } if (num < 0) { throw new InvalidOperationException(System.SR.CountdownEvent_Decrement_BelowZero); } return false; } public bool Signal(int signalCount) { if (signalCount <= 0) { throw new ArgumentOutOfRangeException("signalCount"); } ThrowIfDisposed(); SpinWait spinWait = default(SpinWait); int currentCount; while (true) { currentCount = _currentCount; if (currentCount < signalCount) { throw new InvalidOperationException(System.SR.CountdownEvent_Decrement_BelowZero); } if (Interlocked.CompareExchange(ref _currentCount, currentCount - signalCount, currentCount) == currentCount) { break; } spinWait.SpinOnce(); } if (currentCount == signalCount) { _event.Set(); return true; } return false; } public void AddCount() { AddCount(1); } public bool TryAddCount() { return TryAddCount(1); } public void AddCount(int signalCount) { if (!TryAddCount(signalCount)) { throw new InvalidOperationException(System.SR.CountdownEvent_Increment_AlreadyZero); } } public bool TryAddCount(int signalCount) { if (signalCount <= 0) { throw new ArgumentOutOfRangeException("signalCount"); } ThrowIfDisposed(); SpinWait spinWait = default(SpinWait); while (true) { int currentCount = _currentCount; if (currentCount <= 0) { return false; } if (currentCount > int.MaxValue - signalCount) { throw new InvalidOperationException(System.SR.CountdownEvent_Increment_AlreadyMax); } if (Interlocked.CompareExchange(ref _currentCount, currentCount + signalCount, currentCount) == currentCount) { break; } spinWait.SpinOnce(); } return true; } public void Reset() { Reset(_initialCount); } public void Reset(int count) { ThrowIfDisposed(); if (count < 0) { throw new ArgumentOutOfRangeException("count"); } _currentCount = count; _initialCount = count; if (count == 0) { _event.Set(); } else { _event.Reset(); } } public void Wait() { Wait(-1, default(CancellationToken)); } public void Wait(CancellationToken cancellationToken) { Wait(-1, cancellationToken); } public bool Wait(TimeSpan timeout) { long num = (long)timeout.TotalMilliseconds; if (num < -1 || num > int.MaxValue) { throw new ArgumentOutOfRangeException("timeout"); } return Wait((int)num, default(CancellationToken)); } public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { long num = (long)timeout.TotalMilliseconds; if (num < -1 || num > int.MaxValue) { throw new ArgumentOutOfRangeException("timeout"); } return Wait((int)num, cancellationToken); } public bool Wait(int millisecondsTimeout) { return Wait(millisecondsTimeout, default(CancellationToken)); } public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) { if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException("millisecondsTimeout"); } ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); bool flag = IsSet; if (!flag) { flag = _event.Wait(millisecondsTimeout, cancellationToken); } return flag; } private void ThrowIfDisposed() { if (_disposed) { throw new ObjectDisposedException("CountdownEvent"); } } } public enum LockRecursionPolicy { NoRecursion, SupportsRecursion } internal class ReaderWriterCount { public long lockID; public int readercount; public int writercount; public int upgradecount; public System.Threading.ReaderWriterCount next; } public class ReaderWriterLockSlim : IDisposable { private struct TimeoutTracker { private int _total; private int _start; public int RemainingMilliseconds { get { if (_total == -1 || _total == 0) { return _total; } int num = Environment.TickCount - _start; if (num < 0 || num >= _total) { return 0; } return _total - num; } } public bool IsExpired => RemainingMilliseconds == 0; public TimeoutTracker(TimeSpan timeout) { long num = (long)timeout.TotalMilliseconds; if (num < -1 || num > int.MaxValue) { throw new ArgumentOutOfRangeException("timeout"); } _total = (int)num; if (_total != -1 && _total != 0) { _start = Environment.TickCount; } else { _start = 0; } } public TimeoutTracker(int millisecondsTimeout) { if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException("millisecondsTimeout"); } _total = millisecondsTimeout; if (_total != -1 && _total != 0) { _start = Environment.TickCount; } else { _start = 0; } } } private bool _fIsReentrant; private int _myLock; private const int LockSpinCycles = 20; private const int LockSpinCount = 10; private const int LockSleep0Count = 5; private uint _numWriteWaiters; private uint _numReadWaiters; private uint _numWriteUpgradeWaiters; private uint _numUpgradeWaiters; private bool _fNoWaiters; private int _upgradeLockOwnerId; private int _writeLockOwnerId; private EventWaitHandle _writeEvent; private EventWaitHandle _readEvent; private EventWaitHandle _upgradeEvent; private EventWaitHandle _waitUpgradeEvent; private static long s_nextLockID; private long _lockID; [ThreadStatic] private static System.Threading.ReaderWriterCount t_rwc; private bool _fUpgradeThreadHoldingRead; private const int MaxSpinCount = 20; private uint _owners; private const uint WRITER_HELD = 2147483648u; private const uint WAITING_WRITERS = 1073741824u; private const uint WAITING_UPGRADER = 536870912u; private const uint MAX_READER = 268435454u; private const uint READER_MASK = 268435455u; private bool _fDisposed; public bool IsReadLockHeld { get { if (RecursiveReadCount > 0) { return true; } return false; } } public bool IsUpgradeableReadLockHeld { get { if (RecursiveUpgradeCount > 0) { return true; } return false; } } public bool IsWriteLockHeld { get { if (RecursiveWriteCount > 0) { return true; } return false; } } public LockRecursionPolicy RecursionPolicy { get { if (_fIsReentrant) { return LockRecursionPolicy.SupportsRecursion; } return LockRecursionPolicy.NoRecursion; } } public int CurrentReadCount { get { int numReaders = (int)GetNumReaders(); if (_upgradeLockOwnerId != -1) { return numReaders - 1; } return numReaders; } } public int RecursiveReadCount { get { int result = 0; System.Threading.ReaderWriterCount threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount != null) { result = threadRWCount.readercount; } return result; } } public int RecursiveUpgradeCount { get { if (_fIsReentrant) { int result = 0; System.Threading.ReaderWriterCount threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount != null) { result = threadRWCount.upgradecount; } return result; } if (Environment.CurrentManagedThreadId == _upgradeLockOwnerId) { return 1; } return 0; } } public int RecursiveWriteCount { get { if (_fIsReentrant) { int result = 0; System.Threading.ReaderWriterCount threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount != null) { result = threadRWCount.writercount; } return result; } if (Environment.CurrentManagedThreadId == _writeLockOwnerId) { return 1; } return 0; } } public int WaitingReadCount => (int)_numReadWaiters; public int WaitingUpgradeCount => (int)_numUpgradeWaiters; public int WaitingWriteCount => (int)_numWriteWaiters; private void InitializeThreadCounts() { _upgradeLockOwnerId = -1; _writeLockOwnerId = -1; } public ReaderWriterLockSlim() : this(LockRecursionPolicy.NoRecursion) { } public ReaderWriterLockSlim(LockRecursionPolicy recursionPolicy) { if (recursionPolicy == LockRecursionPolicy.SupportsRecursion) { _fIsReentrant = true; } InitializeThreadCounts(); _fNoWaiters = true; _lockID = Interlocked.Increment(ref s_nextLockID); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool IsRWEntryEmpty(System.Threading.ReaderWriterCount rwc) { if (rwc.lockID == 0L) { return true; } if (rwc.readercount == 0 && rwc.writercount == 0 && rwc.upgradecount == 0) { return true; } return false; } private bool IsRwHashEntryChanged(System.Threading.ReaderWriterCount lrwc) { return lrwc.lockID != _lockID; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private System.Threading.ReaderWriterCount GetThreadRWCount(bool dontAllocate) { System.Threading.ReaderWriterCount next = t_rwc; System.Threading.ReaderWriterCount readerWriterCount = null; while (next != null) { if (next.lockID == _lockID) { return next; } if (!dontAllocate && readerWriterCount == null && IsRWEntryEmpty(next)) { readerWriterCount = next; } next = next.next; } if (dontAllocate) { return null; } if (readerWriterCount == null) { readerWriterCount = new System.Threading.ReaderWriterCount(); readerWriterCount.next = t_rwc; t_rwc = readerWriterCount; } readerWriterCount.lockID = _lockID; return readerWriterCount; } public void EnterReadLock() { TryEnterReadLock(-1); } public bool TryEnterReadLock(TimeSpan timeout) { return TryEnterReadLock(new TimeoutTracker(timeout)); } public bool TryEnterReadLock(int millisecondsTimeout) { return TryEnterReadLock(new TimeoutTracker(millisecondsTimeout)); } private bool TryEnterReadLock(TimeoutTracker timeout) { return TryEnterReadLockCore(timeout); } private bool TryEnterReadLockCore(TimeoutTracker timeout) { if (_fDisposed) { throw new ObjectDisposedException(null); } System.Threading.ReaderWriterCount readerWriterCount = null; int currentManagedThreadId = Environment.CurrentManagedThreadId; if (!_fIsReentrant) { if (currentManagedThreadId == _writeLockOwnerId) { throw new LockRecursionException(System.SR.LockRecursionException_ReadAfterWriteNotAllowed); } EnterMyLock(); readerWriterCount = GetThreadRWCount(dontAllocate: false); if (readerWriterCount.readercount > 0) { ExitMyLock(); throw new LockRecursionException(System.SR.LockRecursionException_RecursiveReadNotAllowed); } if (currentManagedThreadId == _upgradeLockOwnerId) { readerWriterCount.readercount++; _owners++; ExitMyLock(); return true; } } else { EnterMyLock(); readerWriterCount = GetThreadRWCount(dontAllocate: false); if (readerWriterCount.readercount > 0) { readerWriterCount.readercount++; ExitMyLock(); return true; } if (currentManagedThreadId == _upgradeLockOwnerId) { readerWriterCount.readercount++; _owners++; ExitMyLock(); _fUpgradeThreadHoldingRead = true; return true; } if (currentManagedThreadId == _writeLockOwnerId) { readerWriterCount.readercount++; _owners++; ExitMyLock(); return true; } } bool flag = true; int num = 0; while (true) { if (_owners < 268435454) { _owners++; readerWriterCount.readercount++; ExitMyLock(); return flag; } if (num < 20) { ExitMyLock(); if (timeout.IsExpired) { return false; } num++; SpinWait(num); EnterMyLock(); if (IsRwHashEntryChanged(readerWriterCount)) { readerWriterCount = GetThreadRWCount(dontAllocate: false); } } else if (_readEvent == null) { LazyCreateEvent(ref _readEvent, makeAutoResetEvent: false); if (IsRwHashEntryChanged(readerWriterCount)) { readerWriterCount = GetThreadRWCount(dontAllocate: false); } } else { flag = WaitOnEvent(_readEvent, ref _numReadWaiters, timeout, isWriteWaiter: false); if (!flag) { break; } if (IsRwHashEntryChanged(readerWriterCount)) { readerWriterCount = GetThreadRWCount(dontAllocate: false); } } } return false; } public void EnterWriteLock() { TryEnterWriteLock(-1); } public bool TryEnterWriteLock(TimeSpan timeout) { return TryEnterWriteLock(new TimeoutTracker(timeout)); } public bool TryEnterWriteLock(int millisecondsTimeout) { return TryEnterWriteLock(new TimeoutTracker(millisecondsTimeout)); } private bool TryEnterWriteLock(TimeoutTracker timeout) { return TryEnterWriteLockCore(timeout); } private bool TryEnterWriteLockCore(TimeoutTracker timeout) { if (_fDisposed) { throw new ObjectDisposedException(null); } int currentManagedThreadId = Environment.CurrentManagedThreadId; bool flag = false; System.Threading.ReaderWriterCount threadRWCount; if (!_fIsReentrant) { if (currentManagedThreadId == _writeLockOwnerId) { throw new LockRecursionException(System.SR.LockRecursionException_RecursiveWriteNotAllowed); } if (currentManagedThreadId == _upgradeLockOwnerId) { flag = true; } EnterMyLock(); threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount != null && threadRWCount.readercount > 0) { ExitMyLock(); throw new LockRecursionException(System.SR.LockRecursionException_WriteAfterReadNotAllowed); } } else { EnterMyLock(); threadRWCount = GetThreadRWCount(dontAllocate: false); if (currentManagedThreadId == _writeLockOwnerId) { threadRWCount.writercount++; ExitMyLock(); return true; } if (currentManagedThreadId == _upgradeLockOwnerId) { flag = true; } else if (threadRWCount.readercount > 0) { ExitMyLock(); throw new LockRecursionException(System.SR.LockRecursionException_WriteAfterReadNotAllowed); } } int num = 0; bool flag2 = true; while (true) { if (IsWriterAcquired()) { SetWriterAcquired(); break; } if (flag) { uint numReaders = GetNumReaders(); if (numReaders == 1) { SetWriterAcquired(); break; } if (numReaders == 2 && threadRWCount != null) { if (IsRwHashEntryChanged(threadRWCount)) { threadRWCount = GetThreadRWCount(dontAllocate: false); } if (threadRWCount.readercount > 0) { SetWriterAcquired(); break; } } } if (num < 20) { ExitMyLock(); if (timeout.IsExpired) { return false; } num++; SpinWait(num); EnterMyLock(); } else if (flag) { if (_waitUpgradeEvent == null) { LazyCreateEvent(ref _waitUpgradeEvent, makeAutoResetEvent: true); } else if (!WaitOnEvent(_waitUpgradeEvent, ref _numWriteUpgradeWaiters, timeout, isWriteWaiter: true)) { return false; } } else if (_writeEvent == null) { LazyCreateEvent(ref _writeEvent, makeAutoResetEvent: true); } else if (!WaitOnEvent(_writeEvent, ref _numWriteWaiters, timeout, isWriteWaiter: true)) { return false; } } if (_fIsReentrant) { if (IsRwHashEntryChanged(threadRWCount)) { threadRWCount = GetThreadRWCount(dontAllocate: false); } threadRWCount.writercount++; } ExitMyLock(); _writeLockOwnerId = currentManagedThreadId; return true; } public void EnterUpgradeableReadLock() { TryEnterUpgradeableReadLock(-1); } public bool TryEnterUpgradeableReadLock(TimeSpan timeout) { return TryEnterUpgradeableReadLock(new TimeoutTracker(timeout)); } public bool TryEnterUpgradeableReadLock(int millisecondsTimeout) { return TryEnterUpgradeableReadLock(new TimeoutTracker(millisecondsTimeout)); } private bool TryEnterUpgradeableReadLock(TimeoutTracker timeout) { return TryEnterUpgradeableReadLockCore(timeout); } private bool TryEnterUpgradeableReadLockCore(TimeoutTracker timeout) { if (_fDisposed) { throw new ObjectDisposedException(null); } int currentManagedThreadId = Environment.CurrentManagedThreadId; System.Threading.ReaderWriterCount threadRWCount; if (!_fIsReentrant) { if (currentManagedThreadId == _upgradeLockOwnerId) { throw new LockRecursionException(System.SR.LockRecursionException_RecursiveUpgradeNotAllowed); } if (currentManagedThreadId == _writeLockOwnerId) { throw new LockRecursionException(System.SR.LockRecursionException_UpgradeAfterWriteNotAllowed); } EnterMyLock(); threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount != null && threadRWCount.readercount > 0) { ExitMyLock(); throw new LockRecursionException(System.SR.LockRecursionException_UpgradeAfterReadNotAllowed); } } else { EnterMyLock(); threadRWCount = GetThreadRWCount(dontAllocate: false); if (currentManagedThreadId == _upgradeLockOwnerId) { threadRWCount.upgradecount++; ExitMyLock(); return true; } if (currentManagedThreadId == _writeLockOwnerId) { _owners++; _upgradeLockOwnerId = currentManagedThreadId; threadRWCount.upgradecount++; if (threadRWCount.readercount > 0) { _fUpgradeThreadHoldingRead = true; } ExitMyLock(); return true; } if (threadRWCount.readercount > 0) { ExitMyLock(); throw new LockRecursionException(System.SR.LockRecursionException_UpgradeAfterReadNotAllowed); } } bool flag = true; int num = 0; while (true) { if (_upgradeLockOwnerId == -1 && _owners < 268435454) { _owners++; _upgradeLockOwnerId = currentManagedThreadId; if (_fIsReentrant) { if (IsRwHashEntryChanged(threadRWCount)) { threadRWCount = GetThreadRWCount(dontAllocate: false); } threadRWCount.upgradecount++; } break; } if (num < 20) { ExitMyLock(); if (timeout.IsExpired) { return false; } num++; SpinWait(num); EnterMyLock(); } else if (_upgradeEvent == null) { LazyCreateEvent(ref _upgradeEvent, makeAutoResetEvent: true); } else if (!WaitOnEvent(_upgradeEvent, ref _numUpgradeWaiters, timeout, isWriteWaiter: false)) { return false; } } ExitMyLock(); return true; } public void ExitReadLock() { System.Threading.ReaderWriterCount readerWriterCount = null; EnterMyLock(); readerWriterCount = GetThreadRWCount(dontAllocate: true); if (readerWriterCount == null || readerWriterCount.readercount < 1) { ExitMyLock(); throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedRead); } if (_fIsReentrant) { if (readerWriterCount.readercount > 1) { readerWriterCount.readercount--; ExitMyLock(); return; } if (Environment.CurrentManagedThreadId == _upgradeLockOwnerId) { _fUpgradeThreadHoldingRead = false; } } _owners--; readerWriterCount.readercount--; ExitAndWakeUpAppropriateWaiters(); } public void ExitWriteLock() { if (!_fIsReentrant) { if (Environment.CurrentManagedThreadId != _writeLockOwnerId) { throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedWrite); } EnterMyLock(); } else { EnterMyLock(); System.Threading.ReaderWriterCount threadRWCount = GetThreadRWCount(dontAllocate: false); if (threadRWCount == null) { ExitMyLock(); throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedWrite); } if (threadRWCount.writercount < 1) { ExitMyLock(); throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedWrite); } threadRWCount.writercount--; if (threadRWCount.writercount > 0) { ExitMyLock(); return; } } ClearWriterAcquired(); _writeLockOwnerId = -1; ExitAndWakeUpAppropriateWaiters(); } public void ExitUpgradeableReadLock() { if (!_fIsReentrant) { if (Environment.CurrentManagedThreadId != _upgradeLockOwnerId) { throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedUpgrade); } EnterMyLock(); } else { EnterMyLock(); System.Threading.ReaderWriterCount threadRWCount = GetThreadRWCount(dontAllocate: true); if (threadRWCount == null) { ExitMyLock(); throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedUpgrade); } if (threadRWCount.upgradecount < 1) { ExitMyLock(); throw new SynchronizationLockException(System.SR.SynchronizationLockException_MisMatchedUpgrade); } threadRWCount.upgradecount--; if (threadRWCount.upgradecount > 0) { ExitMyLock(); return; } _fUpgradeThreadHoldingRead = false; } _owners--; _upgradeLockOwnerId = -1; ExitAndWakeUpAppropriateWaiters(); } private void LazyCreateEvent(ref EventWaitHandle waitEvent, bool makeAutoResetEvent) { ExitMyLock(); EventWaitHandle eventWaitHandle = ((!makeAutoResetEvent) ? ((EventWaitHandle)new ManualResetEvent(initialState: false)) : ((EventWaitHandle)new AutoResetEvent(initialState: false))); EnterMyLock(); if (waitEvent == null) { waitEvent = eventWaitHandle; } else { eventWaitHandle.Dispose(); } } private bool WaitOnEvent(EventWaitHandle waitEvent, ref uint numWaiters, TimeoutTracker timeout, bool isWriteWaiter) { waitEvent.Reset(); numWaiters++; _fNoWaiters = false; if (_numWriteWaiters == 1) { SetWritersWaiting(); } if (_numWriteUpgradeWaiters == 1) { SetUpgraderWaiting(); } bool flag = false; ExitMyLock(); try { flag = waitEvent.WaitOne(timeout.RemainingMilliseconds); } finally { EnterMyLock(); numWaiters--; if (_numWriteWaiters == 0 && _numWriteUpgradeWaiters == 0 && _numUpgradeWaiters == 0 && _numReadWaiters == 0) { _fNoWaiters = true; } if (_numWriteWaiters == 0) { ClearWritersWaiting(); } if (_numWriteUpgradeWaiters == 0) { ClearUpgraderWaiting(); } if (!flag) { if (isWriteWaiter) { ExitAndWakeUpAppropriateReadWaiters(); } else { ExitMyLock(); } } } return flag; } private void ExitAndWakeUpAppropriateWaiters() { if (_fNoWaiters) { ExitMyLock(); } else { ExitAndWakeUpAppropriateWaitersPreferringWriters(); } } private void ExitAndWakeUpAppropriateWaitersPreferringWriters() { uint numReaders = GetNumReaders(); if (_fIsReentrant && _numWriteUpgradeWaiters != 0 && _fUpgradeThreadHoldingRead && numReaders == 2) { ExitMyLock(); _waitUpgradeEvent.Set(); } else if (numReaders == 1 && _numWriteUpgradeWaiters != 0) { ExitMyLock(); _waitUpgradeEvent.Set(); } else if (numReaders == 0 && _numWriteWaiters != 0) { ExitMyLock(); _writeEvent.Set(); } else { ExitAndWakeUpAppropriateReadWaiters(); } } private void ExitAndWakeUpAppropriateReadWaiters() { if (_numWriteWaiters != 0 || _numWriteUpgradeWaiters != 0 || _fNoWaiters) { ExitMyLock(); return; } bool flag = _numReadWaiters != 0; bool flag2 = _numUpgradeWaiters != 0 && _upgradeLockOwnerId == -1; ExitMyLock(); if (flag) { _readEvent.Set(); } if (flag2) { _upgradeEvent.Set(); } } private bool IsWriterAcquired() { return (_owners & 0xBFFFFFFFu) == 0; } private void SetWriterAcquired() { _owners |= 2147483648u; } private void ClearWriterAcquired() { _owners &= 2147483647u; } private void SetWritersWaiting() { _owners |= 1073741824u; } private void ClearWritersWaiting() { _owners &= 3221225471u; } private void SetUpgraderWaiting() { _owners |= 536870912u; } private void ClearUpgraderWaiting() { _owners &= 3758096383u; } private uint GetNumReaders() { return _owners & 0xFFFFFFFu; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void EnterMyLock() { if (Interlocked.CompareExchange(ref _myLock, 1, 0) != 0) { EnterMyLockSpin(); } } private void EnterMyLockSpin() { int processorCount = Environment.ProcessorCount; int num = 0; while (true) { if (num < 10 && processorCount > 1) { Helpers.Spin(20 * (num + 1)); } else if (num < 15) { Helpers.Sleep(0); } else { Helpers.Sleep(1); } if (_myLock == 0 && Interlocked.CompareExchange(ref _myLock, 1, 0) == 0) { break; } num++; } } private void ExitMyLock() { Volatile.Write(ref _myLock, 0); } private static void SpinWait(int SpinCount) { if (SpinCount < 5 && Environment.ProcessorCount > 1) { Helpers.Spin(20 * SpinCount); } else if (SpinCount < 17) { Helpers.Sleep(0); } else { Helpers.Sleep(1); } } public void Dispose() { Dispose(disposing: true); } private void Dispose(bool disposing) { if (disposing && !_fDisposed) { if (WaitingReadCount > 0 || WaitingUpgradeCount > 0 || WaitingWriteCount > 0) { throw new SynchronizationLockException(System.SR.SynchronizationLockException_IncorrectDispose); } if (IsReadLockHeld || IsUpgradeableReadLockHeld || IsWriteLockHeld) { throw new SynchronizationLockException(System.SR.SynchronizationLockException_IncorrectDispose); } if (_writeEvent != null) { _writeEvent.Dispose(); _writeEvent = null; } if (_readEvent != null) { _readEvent.Dispose(); _readEvent = null; } if (_upgradeEvent != null) { _upgradeEvent.Dispose(); _upgradeEvent = null; } if (_waitUpgradeEvent != null) { _waitUpgradeEvent.Dispose(); _waitUpgradeEvent = null; } _fDisposed = true; } } } }
BepInEx/plugins/DearImGuiInjection/SharpDX.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq.Expressions; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using SharpDX; using SharpDX.Collections; using SharpDX.Diagnostics; using SharpDX.Direct3D; using SharpDX.Mathematics.Interop; [assembly: InternalsVisibleTo("SharpDX.DirectSound")] [assembly: InternalsVisibleTo("SharpDX.RawInput")] [assembly: InternalsVisibleTo("SharpDX.DirectInput")] [assembly: InternalsVisibleTo("SharpDX.Direct2D1")] [assembly: InternalsVisibleTo("SharpDX.Direct3D11.Effects")] [assembly: InternalsVisibleTo("SharpDX.Direct3D12")] [assembly: InternalsVisibleTo("SharpDX.XAPO")] [assembly: InternalsVisibleTo("SharpDX.Direct3D11")] [assembly: InternalsVisibleTo("SharpDX.Direct3D9")] [assembly: InternalsVisibleTo("SharpDX.Desktop")] [assembly: InternalsVisibleTo("SharpDX.D3DCompiler")] [assembly: InternalsVisibleTo("SharpDX.DXGI")] [assembly: InternalsVisibleTo("SharpDX.Animation")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("SharpDX.Direct3D10")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: InternalsVisibleTo("SharpDX.XAudio2")] [assembly: InternalsVisibleTo("SharpDX.WIC")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/xiaoxiao921/SharpDX")] [assembly: AssemblyTitle("SharpDX")] [assembly: AssemblyProduct("SharpDX")] [assembly: AssemblyDescription("Core assembly for all SharpDX assemblies.")] [assembly: AssemblyCopyright("Copyright (c) 2010-2016 Alexandre Mutel")] [assembly: AssemblyConfiguration("Release")] [assembly: InternalsVisibleTo("SharpDX.XACT3")] [assembly: AssemblyCompany("Alexandre Mutel")] [assembly: AssemblyInformationalVersion("4.2.1-beta0+7abb72df54")] [assembly: AssemblyFileVersion("4.2.1.34")] [assembly: ComVisible(false)] [assembly: InternalsVisibleTo("SharpDX.DirectManipulation")] [assembly: InternalsVisibleTo("SharpDX.DirectComposition")] [assembly: InternalsVisibleTo("SharpDX.MediaFoundation")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.2.0.0")] [module: UnverifiableCode] internal class <Module> { static <Module>() { Interop.ModuleInit(); ModuleInit.Setup(); } } internal sealed class ThisAssembly { internal const string AssemblyVersion = "4.2.0.0"; internal const string AssemblyFileVersion = "4.2.1.34"; internal const string AssemblyInformationalVersion = "4.2.1-beta0+7abb72df54"; internal const string AssemblyName = "SharpDX"; internal const string AssemblyTitle = "SharpDX"; internal const string AssemblyConfiguration = "Release"; internal const string GitCommitId = "7abb72df544eaede656c546ee71a8ad1be9dd19b"; internal const string RootNamespace = "SharpDX"; private ThisAssembly() { } } namespace SharpDX { [CompilerGenerated] internal class AssemblyDoc { } public abstract class CallbackBase : DisposeBase, ICallbackable, IDisposable { private int refCount = 1; IDisposable ICallbackable.Shadow { get; set; } protected override void Dispose(bool disposing) { if (disposing) { Release(); } } public int AddReference() { int num = refCount; while (true) { if (num == 0) { throw new ObjectDisposedException("Cannot add a reference to a nonreferenced item"); } int num2 = Interlocked.CompareExchange(ref refCount, num + 1, num); if (num2 == num) { break; } num = num2; } return num + 1; } public int Release() { int num = refCount; while (true) { int num2 = Interlocked.CompareExchange(ref refCount, num - 1, num); if (num2 == num) { break; } num = num2; } if (num == 1) { ((ICallbackable)this).Shadow.Dispose(); ((ICallbackable)this).Shadow = null; } return num - 1; } public Result QueryInterface(ref Guid guid, out IntPtr comObject) { ShadowContainer shadowContainer = (ShadowContainer)((ICallbackable)this).Shadow; comObject = shadowContainer.Find(guid); if (comObject == IntPtr.Zero) { return Result.NoInterface; } return Result.Ok; } } public class ComArray : DisposeBase, IEnumerable { protected ComObject[] values; private IntPtr nativeBuffer; public IntPtr NativePointer => nativeBuffer; public int Length { get { if (values != null) { return values.Length; } return 0; } } public ComArray(params ComObject[] array) { values = array; nativeBuffer = IntPtr.Zero; if (values != null) { int num = array.Length; values = new ComObject[num]; nativeBuffer = Utilities.AllocateMemory(num * Utilities.SizeOf<IntPtr>()); for (int i = 0; i < num; i++) { Set(i, array[i]); } } } public ComArray(int size) { values = new ComObject[size]; nativeBuffer = Utilities.AllocateMemory(size * Utilities.SizeOf<IntPtr>()); } public ComObject Get(int index) { return values[index]; } internal unsafe void SetFromNative(int index, ComObject value) { values[index] = value; value.NativePointer = *(IntPtr*)((byte*)(void*)nativeBuffer + (nint)index * (nint)sizeof(IntPtr)); } public unsafe void Set(int index, ComObject value) { values[index] = value; *(IntPtr*)((byte*)(void*)nativeBuffer + (nint)index * (nint)sizeof(IntPtr)) = value.NativePointer; } protected override void Dispose(bool disposing) { if (disposing) { values = null; } Utilities.FreeMemory(nativeBuffer); nativeBuffer = IntPtr.Zero; } public IEnumerator GetEnumerator() { return values.GetEnumerator(); } } public class ComArray<T> : ComArray, IEnumerable<T>, IEnumerable where T : ComObject { private struct ArrayEnumerator<T1> : IEnumerator<T1>, IEnumerator, IDisposable where T1 : ComObject { private readonly IEnumerator enumerator; public T1 Current => (T1)enumerator.Current; object IEnumerator.Current => Current; public ArrayEnumerator(IEnumerator enumerator) { this.enumerator = enumerator; } public void Dispose() { } public bool MoveNext() { return enumerator.MoveNext(); } public void Reset() { enumerator.Reset(); } } public T this[int i] { get { return (T)Get(i); } set { Set(i, value); } } public ComArray(params T[] array) : base(array) { } public ComArray(int size) : base(size) { } public new IEnumerator<T> GetEnumerator() { return new ArrayEnumerator<T>(values.GetEnumerator()); } } [Guid("00000000-0000-0000-C000-000000000046")] public class ComObject : CppObject, IUnknown, ICallbackable, IDisposable { public static Action<string> LogMemoryLeakWarning = delegate { }; public ComObject(object iunknowObject) { base.NativePointer = Marshal.GetIUnknownForObject(iunknowObject); } protected ComObject() { } public virtual void QueryInterface(Guid guid, out IntPtr outPtr) { ((IUnknown)this).QueryInterface(ref guid, out outPtr).CheckError(); } public virtual IntPtr QueryInterfaceOrNull(Guid guid) { IntPtr comObject = IntPtr.Zero; ((IUnknown)this).QueryInterface(ref guid, out comObject); return comObject; } public static bool EqualsComObject<T>(T left, T right) where T : ComObject { if (object.Equals(left, right)) { return true; } if (left == null || right == null) { return false; } return left.NativePointer == right.NativePointer; } public virtual T QueryInterface<T>() where T : ComObject { QueryInterface(Utilities.GetGuidFromType(typeof(T)), out var outPtr); return CppObject.FromPointer<T>(outPtr); } internal virtual T QueryInterfaceUnsafe<T>() { QueryInterface(Utilities.GetGuidFromType(typeof(T)), out var outPtr); return CppObject.FromPointerUnsafe<T>(outPtr); } public static T As<T>(object comObject) where T : ComObject { using ComObject comObject2 = new ComObject(Marshal.GetIUnknownForObject(comObject)); return comObject2.QueryInterface<T>(); } public static T As<T>(IntPtr iunknownPtr) where T : ComObject { using ComObject comObject = new ComObject(iunknownPtr); return comObject.QueryInterface<T>(); } internal static T AsUnsafe<T>(IntPtr iunknownPtr) { using ComObject comObject = new ComObject(iunknownPtr); return comObject.QueryInterfaceUnsafe<T>(); } public static T QueryInterface<T>(object comObject) where T : ComObject { using ComObject comObject2 = new ComObject(Marshal.GetIUnknownForObject(comObject)); return comObject2.QueryInterface<T>(); } public static T QueryInterfaceOrNull<T>(IntPtr comPointer) where T : ComObject { if (comPointer == IntPtr.Zero) { return null; } Guid iid = Utilities.GetGuidFromType(typeof(T)); if (!((Result)Marshal.QueryInterface(comPointer, ref iid, out var ppv)).Failure) { return CppObject.FromPointerUnsafe<T>(ppv); } return null; } public virtual T QueryInterfaceOrNull<T>() where T : ComObject { return CppObject.FromPointer<T>(QueryInterfaceOrNull(Utilities.GetGuidFromType(typeof(T)))); } protected void QueryInterfaceFrom<T>(T fromObject) where T : ComObject { fromObject.QueryInterface(Utilities.GetGuidFromType(GetType()), out var outPtr); base.NativePointer = outPtr; } Result IUnknown.QueryInterface(ref Guid guid, out IntPtr comObject) { return Marshal.QueryInterface(base.NativePointer, ref guid, out comObject); } int IUnknown.AddReference() { if (base.NativePointer == IntPtr.Zero) { throw new InvalidOperationException("COM Object pointer is null"); } return Marshal.AddRef(base.NativePointer); } int IUnknown.Release() { if (base.NativePointer == IntPtr.Zero) { throw new InvalidOperationException("COM Object pointer is null"); } return Marshal.Release(base.NativePointer); } protected unsafe override void Dispose(bool disposing) { if (base.NativePointer != IntPtr.Zero) { if (!disposing && Configuration.EnableTrackingReleaseOnFinalizer && !Configuration.EnableReleaseOnFinalizer) { ObjectReference arg = ObjectTracker.Find(this); LogMemoryLeakWarning?.Invoke($"Warning: Live ComObject [0x{base.NativePointer.ToInt64():X}], potential memory leak: {arg}"); } if (disposing || Configuration.EnableReleaseOnFinalizer) { ((IUnknown)this).Release(); } if (Configuration.EnableObjectTracking) { ObjectTracker.UnTrack(this); } _nativePointer = null; } base.Dispose(disposing); } protected override void NativePointerUpdating() { if (Configuration.EnableObjectTracking) { ObjectTracker.UnTrack(this); } } protected override void NativePointerUpdated(IntPtr oldNativePointer) { if (Configuration.EnableObjectTracking) { ObjectTracker.Track(this); } } public ComObject(IntPtr nativePtr) : base(nativePtr) { } public static explicit operator ComObject(IntPtr nativePtr) { if (!(nativePtr == IntPtr.Zero)) { return new ComObject(nativePtr); } return null; } } internal abstract class ComObjectShadow : CppObjectShadow { internal class ComObjectVtbl : CppObjectVtbl { [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int QueryInterfaceDelegate(IntPtr thisObject, IntPtr guid, out IntPtr output); [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int AddRefDelegate(IntPtr thisObject); [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int ReleaseDelegate(IntPtr thisObject); public ComObjectVtbl(int numberOfCallbackMethods) : base(numberOfCallbackMethods + 3) { AddMethod(new QueryInterfaceDelegate(QueryInterfaceImpl)); AddMethod(new AddRefDelegate(AddRefImpl)); AddMethod(new ReleaseDelegate(ReleaseImpl)); } protected unsafe static int QueryInterfaceImpl(IntPtr thisObject, IntPtr guid, out IntPtr output) { ComObjectShadow comObjectShadow = CppObjectShadow.ToShadow<ComObjectShadow>(thisObject); if (comObjectShadow == null) { output = IntPtr.Zero; return Result.NoInterface.Code; } return comObjectShadow.QueryInterfaceImpl(ref *(Guid*)(void*)guid, out output); } protected static int AddRefImpl(IntPtr thisObject) { return CppObjectShadow.ToShadow<ComObjectShadow>(thisObject)?.AddRefImpl() ?? 0; } protected static int ReleaseImpl(IntPtr thisObject) { return CppObjectShadow.ToShadow<ComObjectShadow>(thisObject)?.ReleaseImpl() ?? 0; } } public static Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046"); protected int QueryInterfaceImpl(ref Guid guid, out IntPtr output) { ComObjectShadow comObjectShadow = (ComObjectShadow)((ShadowContainer)base.Callback.Shadow).FindShadow(guid); if (comObjectShadow != null) { ((IUnknown)base.Callback).AddReference(); output = comObjectShadow.NativePointer; return Result.Ok.Code; } output = IntPtr.Zero; return Result.NoInterface.Code; } protected virtual int AddRefImpl() { return ((IUnknown)base.Callback).AddReference(); } protected virtual int ReleaseImpl() { return ((IUnknown)base.Callback).Release(); } } public static class Configuration { public static bool EnableObjectTracking = false; public static bool EnableReleaseOnFinalizer = false; public static bool EnableTrackingReleaseOnFinalizer = true; public static bool ThrowOnShaderCompileError = true; public static bool UseThreadStaticObjectTracking = false; } public class CppObject : DisposeBase, ICallbackable, IDisposable { protected internal unsafe void* _nativePointer; public object Tag { get; set; } public unsafe IntPtr NativePointer { get { return (IntPtr)_nativePointer; } set { void* ptr = (void*)value; if (_nativePointer != ptr) { NativePointerUpdating(); void* nativePointer = _nativePointer; _nativePointer = ptr; NativePointerUpdated((IntPtr)nativePointer); } } } IDisposable ICallbackable.Shadow { get { throw new InvalidOperationException("Invalid access to Callback. This is used internally."); } set { throw new InvalidOperationException("Invalid access to Callback. This is used internally."); } } public CppObject(IntPtr pointer) { NativePointer = pointer; } protected CppObject() { } public static explicit operator IntPtr(CppObject cppObject) { return cppObject?.NativePointer ?? IntPtr.Zero; } protected void FromTemp(CppObject temp) { NativePointer = temp.NativePointer; temp.NativePointer = IntPtr.Zero; } protected void FromTemp(IntPtr temp) { NativePointer = temp; } protected virtual void NativePointerUpdating() { } protected virtual void NativePointerUpdated(IntPtr oldNativePointer) { } protected override void Dispose(bool disposing) { } public static T FromPointer<T>(IntPtr comObjectPtr) where T : CppObject { if (!(comObjectPtr == IntPtr.Zero)) { return (T)Activator.CreateInstance(typeof(T), comObjectPtr); } return null; } internal static T FromPointerUnsafe<T>(IntPtr comObjectPtr) { if (!(comObjectPtr == IntPtr.Zero)) { return (T)Activator.CreateInstance(typeof(T), comObjectPtr); } return (T)(object)null; } public static IntPtr ToCallbackPtr<TCallback>(ICallbackable callback) where TCallback : ICallbackable { if (callback == null) { return IntPtr.Zero; } if (callback is CppObject) { return ((CppObject)callback).NativePointer; } ShadowContainer shadowContainer = callback.Shadow as ShadowContainer; if (shadowContainer == null) { shadowContainer = new ShadowContainer(); shadowContainer.Initialize(callback); } return shadowContainer.Find(typeof(TCallback)); } } internal abstract class CppObjectShadow : CppObject { public ICallbackable Callback { get; private set; } protected abstract CppObjectVtbl GetVtbl { get; } public unsafe virtual void Initialize(ICallbackable callbackInstance) { Callback = callbackInstance; base.NativePointer = Marshal.AllocHGlobal(IntPtr.Size * 2); GCHandle value = GCHandle.Alloc(this); Marshal.WriteIntPtr(base.NativePointer, GetVtbl.Pointer); *(IntPtr*)((byte*)(void*)base.NativePointer + sizeof(IntPtr)) = GCHandle.ToIntPtr(value); } protected unsafe override void Dispose(bool disposing) { if (base.NativePointer != IntPtr.Zero) { GCHandle.FromIntPtr(*(IntPtr*)((byte*)(void*)base.NativePointer + sizeof(IntPtr))).Free(); Marshal.FreeHGlobal(base.NativePointer); base.NativePointer = IntPtr.Zero; } Callback = null; base.Dispose(disposing); } internal unsafe static T ToShadow<T>(IntPtr thisPtr) where T : CppObjectShadow { return (T)GCHandle.FromIntPtr(*(IntPtr*)((byte*)(void*)thisPtr + sizeof(IntPtr))).Target; } } internal class CppObjectVtbl { private readonly List<Delegate> methods; private readonly IntPtr vtbl; public IntPtr Pointer => vtbl; public CppObjectVtbl(int numberOfCallbackMethods) { vtbl = Marshal.AllocHGlobal(IntPtr.Size * numberOfCallbackMethods); methods = new List<Delegate>(); } public unsafe void AddMethod(Delegate method) { int count = methods.Count; methods.Add(method); *(IntPtr*)((byte*)(void*)vtbl + (nint)count * (nint)sizeof(IntPtr)) = Marshal.GetFunctionPointerForDelegate(method); } } public struct DataBox { public IntPtr DataPointer; public int RowPitch; public int SlicePitch; public bool IsEmpty { get { if (DataPointer == IntPtr.Zero && RowPitch == 0) { return SlicePitch == 0; } return false; } } public DataBox(IntPtr datapointer, int rowPitch, int slicePitch) { DataPointer = datapointer; RowPitch = rowPitch; SlicePitch = slicePitch; } public DataBox(IntPtr dataPointer) { DataPointer = dataPointer; RowPitch = 0; SlicePitch = 0; } } public class DataBuffer : DisposeBase { private unsafe sbyte* _buffer; private GCHandle _gCHandle; private readonly bool _ownsBuffer; private readonly int _size; private Blob _blob; public unsafe IntPtr DataPointer => new IntPtr(_buffer); public int Size => _size; public unsafe static DataBuffer Create<T>(T[] userBuffer, int index = 0, bool pinBuffer = true) where T : struct { if (userBuffer == null) { throw new ArgumentNullException("userBuffer"); } if (index < 0 || index > userBuffer.Length) { throw new ArgumentException("Index is out of range [0, userBuffer.Length-1]", "index"); } int num = Utilities.SizeOf(userBuffer); int num2 = index * Utilities.SizeOf<T>(); if (pinBuffer) { GCHandle handle = GCHandle.Alloc(userBuffer, GCHandleType.Pinned); return new DataBuffer(num2 + (byte*)(void*)handle.AddrOfPinnedObject(), num - num2, handle); } fixed (T* ptr = &userBuffer[0]) { return new DataBuffer(num2 + (byte*)(void*)(IntPtr)ptr, num - num2, makeCopy: true); } } public unsafe DataBuffer(int sizeInBytes) { _buffer = (sbyte*)(void*)Utilities.AllocateMemory(sizeInBytes); _size = sizeInBytes; _ownsBuffer = true; } public DataBuffer(DataPointer dataPointer) : this(dataPointer.Pointer, dataPointer.Size) { } public unsafe DataBuffer(IntPtr userBuffer, int sizeInBytes) : this((void*)userBuffer, sizeInBytes, makeCopy: false) { } internal unsafe DataBuffer(void* buffer, int sizeInBytes, GCHandle handle) { _buffer = (sbyte*)buffer; _size = sizeInBytes; _gCHandle = handle; _ownsBuffer = false; } internal unsafe DataBuffer(void* buffer, int sizeInBytes, bool makeCopy) { if (makeCopy) { _buffer = (sbyte*)(void*)Utilities.AllocateMemory(sizeInBytes); Utilities.CopyMemory((IntPtr)_buffer, (IntPtr)buffer, sizeInBytes); } else { _buffer = (sbyte*)buffer; } _size = sizeInBytes; _ownsBuffer = makeCopy; } internal unsafe DataBuffer(Blob buffer) { _buffer = (sbyte*)(void*)buffer.GetBufferPointer(); _size = buffer.GetBufferSize(); _blob = buffer; } protected unsafe override void Dispose(bool disposing) { if (disposing && _blob != null) { _blob.Dispose(); _blob = null; } if (_gCHandle.IsAllocated) { _gCHandle.Free(); } if (_ownsBuffer && _buffer != null) { Utilities.FreeMemory((IntPtr)_buffer); _buffer = null; } } public unsafe void Clear(byte value = 0) { Utilities.ClearMemory((IntPtr)_buffer, value, Size); } public unsafe T Get<T>(int positionInBytes) where T : struct { T data = default(T); Utilities.Read((IntPtr)(_buffer + positionInBytes), ref data); return data; } public unsafe void Get<T>(int positionInBytes, out T value) where T : struct { Utilities.ReadOut<T>((IntPtr)(_buffer + positionInBytes), out value); } public unsafe T[] GetRange<T>(int positionInBytes, int count) where T : struct { T[] array = new T[count]; Utilities.Read((IntPtr)(_buffer + positionInBytes), array, 0, count); return array; } public unsafe void GetRange<T>(int positionInBytes, T[] buffer, int offset, int count) where T : struct { Utilities.Read((IntPtr)(_buffer + positionInBytes), buffer, offset, count); } public unsafe void Set<T>(int positionInBytes, ref T value) where T : struct { Unsafe.Write(_buffer + positionInBytes, value); } public unsafe void Set<T>(int positionInBytes, T value) where T : struct { Unsafe.Write(_buffer + positionInBytes, value); } public unsafe void Set(int positionInBytes, bool value) { *(int*)(_buffer + positionInBytes) = (value ? 1 : 0); } public void Set<T>(int positionInBytes, T[] data) where T : struct { Set(positionInBytes, data, 0, data.Length); } public unsafe void Set(int positionInBytes, IntPtr source, long count) { Utilities.CopyMemory((IntPtr)(_buffer + positionInBytes), source, (int)count); } public unsafe void Set<T>(int positionInBytes, T[] data, int offset, int count) where T : struct { Utilities.Write((IntPtr)(_buffer + positionInBytes), data, offset, count); } public static implicit operator DataPointer(DataBuffer from) { return new DataPointer(from.DataPointer, from.Size); } } public struct DataPointer : IEquatable<DataPointer> { public static readonly DataPointer Zero = new DataPointer(IntPtr.Zero, 0); public IntPtr Pointer; public int Size; public bool IsEmpty => Equals(Zero); public DataPointer(IntPtr pointer, int size) { Pointer = pointer; Size = size; } public unsafe DataPointer(void* pointer, int size) { Pointer = (IntPtr)pointer; Size = size; } public bool Equals(DataPointer other) { if (Pointer.Equals((object?)(nint)other.Pointer)) { return Size == other.Size; } return false; } public override bool Equals(object obj) { if (obj == null) { return false; } if (obj is DataPointer) { return Equals((DataPointer)obj); } return false; } public override int GetHashCode() { return (Pointer.GetHashCode() * 397) ^ Size; } public DataStream ToDataStream() { if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } return new DataStream(this); } public DataBuffer ToDataBuffer() { if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } return new DataBuffer(this); } public byte[] ToArray() { if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } if (Size < 0) { throw new InvalidOperationException("Size cannot be < 0"); } byte[] array = new byte[Size]; Utilities.Read(Pointer, array, 0, Size); return array; } public T[] ToArray<T>() where T : struct { if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } T[] array = new T[Size / Utilities.SizeOf<T>()]; CopyTo(array, 0, array.Length); return array; } public void CopyTo<T>(T[] buffer, int offset, int count) where T : struct { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", "Must be >= 0"); } if (count <= 0) { throw new ArgumentOutOfRangeException("count", "Must be > 0"); } if (count * Utilities.SizeOf<T>() > Size) { throw new ArgumentOutOfRangeException("buffer", "Total buffer size cannot be larger than size of this data pointer"); } Utilities.Read(Pointer, buffer, offset, count); } public void CopyFrom<T>(T[] buffer) where T : struct { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } CopyFrom(buffer, 0, buffer.Length); } public void CopyFrom<T>(T[] buffer, int offset, int count) where T : struct { if (buffer == null) { throw new ArgumentNullException("buffer"); } if (Pointer == IntPtr.Zero) { throw new InvalidOperationException("DataPointer is Zero"); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", "Must be >= 0"); } if (count <= 0) { throw new ArgumentOutOfRangeException("count", "Must be > 0"); } if (count * Utilities.SizeOf<T>() > Size) { throw new ArgumentOutOfRangeException("buffer", "Total buffer size cannot be larger than size of this data pointer"); } Utilities.Write(Pointer, buffer, offset, count); } public static bool operator ==(DataPointer left, DataPointer right) { return left.Equals(right); } public static bool operator !=(DataPointer left, DataPointer right) { return !left.Equals(right); } } public struct DataRectangle { public IntPtr DataPointer; public int Pitch; public DataRectangle(IntPtr dataPointer, int pitch) { DataPointer = dataPointer; Pitch = pitch; } } public class DataStream : Stream { private unsafe byte* _buffer; private readonly bool _canRead; private readonly bool _canWrite; private GCHandle _gCHandle; private Blob _blob; private readonly bool _ownsBuffer; private long _position; private readonly long _size; public override bool CanRead => _canRead; public override bool CanSeek => true; public override bool CanWrite => _canWrite; public unsafe IntPtr DataPointer => new IntPtr(_buffer); public override long Length => _size; public override long Position { get { return _position; } set { Seek(value, SeekOrigin.Begin); } } public unsafe IntPtr PositionPointer => (IntPtr)(_buffer + _position); public long RemainingLength => _size - _position; public unsafe DataStream(Blob buffer) { _buffer = (byte*)(void*)buffer.GetBufferPointer(); _size = buffer.GetBufferSize(); _canRead = true; _canWrite = true; _blob = buffer; } public unsafe static DataStream Create<T>(T[] userBuffer, bool canRead, bool canWrite, int index = 0, bool pinBuffer = true) where T : struct { if (userBuffer == null) { throw new ArgumentNullException("userBuffer"); } if (index < 0 || index > userBuffer.Length) { throw new ArgumentException("Index is out of range [0, userBuffer.Length-1]", "index"); } int num = Utilities.SizeOf(userBuffer); int num2 = index * Utilities.SizeOf<T>(); if (pinBuffer) { GCHandle handle = GCHandle.Alloc(userBuffer, GCHandleType.Pinned); return new DataStream(num2 + (byte*)(void*)handle.AddrOfPinnedObject(), num - num2, canRead, canWrite, handle); } fixed (T* ptr = &userBuffer[0]) { return new DataStream(num2 + (byte*)(void*)(IntPtr)ptr, num - num2, canRead, canWrite, makeCopy: true); } } public unsafe DataStream(int sizeInBytes, bool canRead, bool canWrite) { _buffer = (byte*)(void*)Utilities.AllocateMemory(sizeInBytes); _size = sizeInBytes; _ownsBuffer = true; _canRead = canRead; _canWrite = canWrite; } public DataStream(DataPointer dataPointer) : this(dataPointer.Pointer, dataPointer.Size, canRead: true, canWrite: true) { } public unsafe DataStream(IntPtr userBuffer, long sizeInBytes, bool canRead, bool canWrite) { _buffer = (byte*)userBuffer.ToPointer(); _size = sizeInBytes; _canRead = canRead; _canWrite = canWrite; } internal unsafe DataStream(void* dataPointer, int sizeInBytes, bool canRead, bool canWrite, GCHandle handle) { _gCHandle = handle; _buffer = (byte*)dataPointer; _size = sizeInBytes; _canRead = canRead; _canWrite = canWrite; _ownsBuffer = false; } internal unsafe DataStream(void* buffer, int sizeInBytes, bool canRead, bool canWrite, bool makeCopy) { if (makeCopy) { _buffer = (byte*)(void*)Utilities.AllocateMemory(sizeInBytes); Utilities.CopyMemory((IntPtr)_buffer, (IntPtr)buffer, sizeInBytes); } else { _buffer = (byte*)buffer; } _size = sizeInBytes; _canRead = canRead; _canWrite = canWrite; _ownsBuffer = makeCopy; } ~DataStream() { Dispose(disposing: false); } protected unsafe override void Dispose(bool disposing) { if (disposing && _blob != null) { _blob.Dispose(); _blob = null; } if (_gCHandle.IsAllocated) { _gCHandle.Free(); } if (_ownsBuffer && _buffer != null) { Utilities.FreeMemory((IntPtr)_buffer); _buffer = null; } } public override void Flush() { throw new NotSupportedException("DataStream objects cannot be flushed."); } public unsafe T Read<T>() where T : struct { if (!_canRead) { throw new NotSupportedException(); } byte* ptr = _buffer + _position; T data = default(T); _position = (byte*)(void*)Utilities.ReadAndPosition((IntPtr)ptr, ref data) - _buffer; return data; } public unsafe override int ReadByte() { if (_position >= Length) { return -1; } return _buffer[_position++]; } public override int Read(byte[] buffer, int offset, int count) { int count2 = (int)Math.Min(RemainingLength, count); return ReadRange(buffer, offset, count2); } public unsafe void Read(IntPtr buffer, int offset, int count) { Utilities.CopyMemory(new IntPtr((byte*)(void*)buffer + offset), (IntPtr)(_buffer + _position), count); _position += count; } public unsafe T[] ReadRange<T>(int count) where T : struct { if (!_canRead) { throw new NotSupportedException(); } byte* ptr = _buffer + _position; T[] array = new T[count]; _position = (byte*)(void*)Utilities.Read((IntPtr)ptr, array, 0, count) - _buffer; return array; } public unsafe int ReadRange<T>(T[] buffer, int offset, int count) where T : struct { if (!_canRead) { throw new NotSupportedException(); } long position = _position; _position = (byte*)(void*)Utilities.Read((IntPtr)(_buffer + _position), buffer, offset, count) - _buffer; return (int)(_position - position); } public override long Seek(long offset, SeekOrigin origin) { long num = 0L; switch (origin) { case SeekOrigin.Begin: num = offset; break; case SeekOrigin.Current: num = _position + offset; break; case SeekOrigin.End: num = _size - offset; break; } if (num < 0) { throw new InvalidOperationException("Cannot seek beyond the beginning of the stream."); } if (num > _size) { throw new InvalidOperationException("Cannot seek beyond the end of the stream."); } _position = num; return _position; } public override void SetLength(long value) { throw new NotSupportedException("DataStream objects cannot be resized."); } public unsafe void Write<T>(T value) where T : struct { if (!_canWrite) { throw new NotSupportedException(); } _position = (byte*)(void*)Utilities.WriteAndPosition((IntPtr)(_buffer + _position), ref value) - _buffer; } public override void Write(byte[] buffer, int offset, int count) { WriteRange(buffer, offset, count); } public unsafe void Write(IntPtr buffer, int offset, int count) { Utilities.CopyMemory((IntPtr)(_buffer + _position), new IntPtr((byte*)(void*)buffer + offset), count); _position += count; } public void WriteRange<T>(T[] data) where T : struct { WriteRange(data, 0, data.Length); } public unsafe void WriteRange(IntPtr source, long count) { if (!_canWrite) { throw new NotSupportedException(); } Utilities.CopyMemory((IntPtr)(_buffer + _position), source, (int)count); _position += count; } public unsafe void WriteRange<T>(T[] data, int offset, int count) where T : struct { if (!_canWrite) { throw new NotSupportedException(); } _position = (byte*)(void*)Utilities.Write((IntPtr)(_buffer + _position), data, offset, count) - _buffer; } public static implicit operator DataPointer(DataStream from) { return new DataPointer(from.PositionPointer, (int)from.RemainingLength); } } public class CompilationException : SharpDXException { public CompilationException(string message) : base(message) { } public CompilationException(Result errorCode, string message) : base(errorCode, message) { } } public abstract class CompilationResultBase<T> : DisposeBase where T : class, IDisposable { public T Bytecode { get; private set; } public Result ResultCode { get; private set; } public bool HasErrors => ResultCode.Failure; public string Message { get; private set; } protected CompilationResultBase(T bytecode, Result resultCode, string message = null) { Bytecode = bytecode; ResultCode = resultCode; Message = message; } protected override void Dispose(bool disposing) { if (disposing && Bytecode != null) { Bytecode.Dispose(); Bytecode = null; } } } public abstract class DisposeBase : IDisposable { public bool IsDisposed { get; private set; } public event EventHandler<EventArgs> Disposing; public event EventHandler<EventArgs> Disposed; ~DisposeBase() { CheckAndDispose(disposing: false); } public void Dispose() { CheckAndDispose(disposing: true); } private void CheckAndDispose(bool disposing) { if (!IsDisposed) { this.Disposing?.Invoke(this, DisposeEventArgs.Get(disposing)); Dispose(disposing); GC.SuppressFinalize(this); IsDisposed = true; this.Disposed?.Invoke(this, DisposeEventArgs.Get(disposing)); } } protected abstract void Dispose(bool disposing); } public class DisposeCollector : DisposeBase { private List<object> disposables; public int Count => disposables.Count; public void DisposeAndClear(bool disposeManagedResources = true) { if (disposables == null) { return; } for (int num = disposables.Count - 1; num >= 0; num--) { object obj = disposables[num]; if (obj is IDisposable disposable) { if (disposeManagedResources) { disposable.Dispose(); } } else { Utilities.FreeMemory((IntPtr)obj); } disposables.RemoveAt(num); } disposables.Clear(); } protected override void Dispose(bool disposeManagedResources) { DisposeAndClear(disposeManagedResources); disposables = null; } public T Collect<T>(T toDispose) { if (!(toDispose is IDisposable) && !(toDispose is IntPtr)) { throw new ArgumentException("Argument must be IDisposable or IntPtr"); } if (toDispose is IntPtr && !Utilities.IsMemoryAligned((IntPtr)(object)toDispose)) { throw new ArgumentException("Memory pointer is invalid. Memory must have been allocated with Utilties.AllocateMemory"); } if (!object.Equals(toDispose, default(T))) { if (disposables == null) { disposables = new List<object>(); } if (!disposables.Contains(toDispose)) { disposables.Add(toDispose); } } return toDispose; } public void RemoveAndDispose<T>(ref T objectToDispose) { if (disposables != null) { Remove(objectToDispose); if ((object)objectToDispose is IDisposable disposable) { disposable.Dispose(); } else { Utilities.FreeMemory((IntPtr)(object)objectToDispose); } objectToDispose = default(T); } } public void Remove<T>(T toDisposeArg) { if (disposables != null && disposables.Contains(toDisposeArg)) { disposables.Remove(toDisposeArg); } } } public class DisposeEventArgs : EventArgs { public static readonly DisposeEventArgs DisposingEventArgs = new DisposeEventArgs(disposing: true); public static readonly DisposeEventArgs NotDisposingEventArgs = new DisposeEventArgs(disposing: false); public readonly bool Disposing; private DisposeEventArgs(bool disposing) { Disposing = disposing; } public static DisposeEventArgs Get(bool disposing) { if (!disposing) { return NotDisposingEventArgs; } return DisposingEventArgs; } } [StructLayout(LayoutKind.Sequential)] internal class FunctionCallback { public IntPtr Pointer; public FunctionCallback(IntPtr pointer) { Pointer = pointer; } public unsafe FunctionCallback(void* pointer) { Pointer = new IntPtr(pointer); } public static explicit operator IntPtr(FunctionCallback value) { return value.Pointer; } public static implicit operator FunctionCallback(IntPtr value) { return new FunctionCallback(value); } public unsafe static implicit operator void*(FunctionCallback value) { return (void*)value.Pointer; } public unsafe static explicit operator FunctionCallback(void* value) { return new FunctionCallback(value); } public override string ToString() { return string.Format(CultureInfo.CurrentCulture, "{0}", Pointer); } public string ToString(string format) { if (format == null) { return ToString(); } return string.Format(CultureInfo.CurrentCulture, "{0}", Pointer.ToString(format)); } public override int GetHashCode() { return Pointer.ToInt32(); } public bool Equals(FunctionCallback other) { return Pointer == other.Pointer; } public override bool Equals(object value) { if (value == null) { return false; } if ((object)value.GetType() != typeof(FunctionCallback)) { return false; } return Equals((FunctionCallback)value); } } public interface ICallbackable : IDisposable { IDisposable Shadow { get; set; } } [Shadow(typeof(InspectableShadow))] [Guid("AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90")] public interface IInspectable : ICallbackable, IDisposable { } internal class InspectableShadow : ComObjectShadow { public class InspectableProviderVtbl : ComObjectVtbl { [UnmanagedFunctionPointer(CallingConvention.StdCall)] private unsafe delegate int GetIidsDelegate(IntPtr thisPtr, int* iidCount, IntPtr* iids); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int GetRuntimeClassNameDelegate(IntPtr thisPtr, IntPtr className); private enum TrustLevel { BaseTrust, PartialTrust, FullTrust } [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int GetTrustLevelDelegate(IntPtr thisPtr, IntPtr trustLevel); public InspectableProviderVtbl() : base(3) { AddMethod(new GetIidsDelegate(GetIids)); AddMethod(new GetRuntimeClassNameDelegate(GetRuntimeClassName)); AddMethod(new GetTrustLevelDelegate(GetTrustLevel)); } private unsafe static int GetIids(IntPtr thisPtr, int* iidCount, IntPtr* iids) { try { ShadowContainer shadowContainer = (ShadowContainer)((IInspectable)CppObjectShadow.ToShadow<InspectableShadow>(thisPtr).Callback).Shadow; int num = shadowContainer.Guids.Length; iids = (IntPtr*)(void*)Marshal.AllocCoTaskMem(IntPtr.Size * num); *iidCount = num; for (int i = 0; i < num; i++) { iids[i] = shadowContainer.Guids[i]; } } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } private static int GetRuntimeClassName(IntPtr thisPtr, IntPtr className) { try { _ = (IInspectable)CppObjectShadow.ToShadow<InspectableShadow>(thisPtr).Callback; } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } private static int GetTrustLevel(IntPtr thisPtr, IntPtr trustLevel) { try { _ = (IInspectable)CppObjectShadow.ToShadow<InspectableShadow>(thisPtr).Callback; Marshal.WriteInt32(trustLevel, 2); } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } } private static readonly InspectableProviderVtbl Vtbl = new InspectableProviderVtbl(); protected override CppObjectVtbl GetVtbl => Vtbl; public static IntPtr ToIntPtr(IInspectable callback) { return CppObject.ToCallbackPtr<IInspectable>(callback); } } internal class Interop { public unsafe static void* Fixed<T>(ref T data) { throw new NotImplementedException(); } public unsafe static void* Fixed<T>(T[] data) { throw new NotImplementedException(); } public unsafe static void* Cast<T>(ref T data) where T : struct { return Unsafe.AsPointer(ref data); } public unsafe static void* CastOut<T>(out T data) where T : struct { return Unsafe.AsPointer(ref data); } public static TCAST[] CastArray<TCAST, T>(T[] arrayData) where TCAST : struct where T : struct { return (TCAST[])(object)arrayData; } public unsafe static void memcpy(void* pDest, void* pSrc, int count) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(pDest, pSrc, count); } public unsafe static void memset(void* pDest, byte value, int count) { // IL initblk instruction Unsafe.InitBlockUnaligned(pDest, value, count); } public unsafe static void* Read<T>(void* pSrc, ref T data) where T : struct { fixed (T* ptr = &data) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>(); // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref reference, pSrc, num); return num + (byte*)pSrc; } } public unsafe static T ReadInline<T>(void* pSrc) where T : struct { throw new NotImplementedException(); } public unsafe static void WriteInline<T>(void* pDest, ref T data) where T : struct { throw new NotImplementedException(); } public unsafe static void CopyInline<T>(ref T data, void* pSrc) where T : struct { throw new NotImplementedException(); } public unsafe static void CopyInline<T>(void* pDest, ref T srcData) where T : struct { throw new NotImplementedException(); } public unsafe static void CopyInlineOut<T>(out T data, void* pSrc) where T : struct { throw new NotImplementedException(); } public unsafe static void* ReadOut<T>(void* pSrc, out T data) where T : struct { fixed (T* ptr = &data) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>(); // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref reference, pSrc, num); return num + (byte*)pSrc; } } public unsafe static void* Read<T>(void* pSrc, T[] data, int offset, int count) where T : struct { fixed (T* ptr = &data[offset]) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>() * count; // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref reference, pSrc, num); return num + (byte*)pSrc; } } public unsafe static void* Read2D<T>(void* pSrc, T[,] data, int offset, int count) where T : struct { fixed (T* ptr = &data[offset]) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>() * count; // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref reference, pSrc, num); return num + (byte*)pSrc; } } public static int SizeOf<T>() { throw new NotImplementedException(); } public unsafe static void* Write<T>(void* pDest, ref T data) where T : struct { fixed (T* ptr = &data) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>(); // IL cpblk instruction Unsafe.CopyBlockUnaligned(pDest, ref reference, num); return num + (byte*)pDest; } } public unsafe static void* Write<T>(void* pDest, T[] data, int offset, int count) where T : struct { fixed (T* ptr = &data[offset]) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>() * count; // IL cpblk instruction Unsafe.CopyBlockUnaligned(pDest, ref reference, num); return num + (byte*)pDest; } } public unsafe static void* Write2D<T>(void* pDest, T[,] data, int offset, int count) where T : struct { fixed (T* ptr = &data[offset]) { ref ? reference = ref *(?*)ptr; int num = Unsafe.SizeOf<T>() * count; // IL cpblk instruction Unsafe.CopyBlockUnaligned(pDest, ref reference, num); return num + (byte*)pDest; } } [Tag("SharpDX.ModuleInit")] public static void ModuleInit() { } } [Guid("00000000-0000-0000-C000-000000000046")] public interface IUnknown : ICallbackable, IDisposable { Result QueryInterface(ref Guid guid, out IntPtr comObject); int AddReference(); int Release(); } internal class ModuleInit { [Tag("SharpDX.ModuleInit")] internal static void Setup() { ResultDescriptor.RegisterProvider(typeof(Result)); } } [CompilerGenerated] internal class NamespaceDoc { } public struct PointerSize : IEquatable<PointerSize> { private IntPtr _size; public static readonly PointerSize Zero = new PointerSize(0); public PointerSize(IntPtr size) { _size = size; } private unsafe PointerSize(void* size) { _size = new IntPtr(size); } public PointerSize(int size) { _size = new IntPtr(size); } public PointerSize(long size) { _size = new IntPtr(size); } public override string ToString() { return string.Format(CultureInfo.CurrentCulture, "{0}", _size); } public string ToString(string format) { if (format == null) { return ToString(); } return string.Format(CultureInfo.CurrentCulture, "{0}", _size.ToString(format)); } public override int GetHashCode() { return _size.GetHashCode(); } public bool Equals(PointerSize other) { return _size.Equals((object?)(nint)other._size); } public override bool Equals(object value) { if (value == null) { return false; } if (value is PointerSize) { return Equals((PointerSize)value); } return false; } public static PointerSize operator +(PointerSize left, PointerSize right) { return new PointerSize(left._size.ToInt64() + right._size.ToInt64()); } public static PointerSize operator +(PointerSize value) { return value; } public static PointerSize operator -(PointerSize left, PointerSize right) { return new PointerSize(left._size.ToInt64() - right._size.ToInt64()); } public static PointerSize operator -(PointerSize value) { return new PointerSize(-value._size.ToInt64()); } public static PointerSize operator *(int scale, PointerSize value) { return new PointerSize(scale * value._size.ToInt64()); } public static PointerSize operator *(PointerSize value, int scale) { return new PointerSize(scale * value._size.ToInt64()); } public static PointerSize operator /(PointerSize value, int scale) { return new PointerSize(value._size.ToInt64() / scale); } public static bool operator ==(PointerSize left, PointerSize right) { return left.Equals(right); } public static bool operator !=(PointerSize left, PointerSize right) { return !left.Equals(right); } public static implicit operator int(PointerSize value) { return value._size.ToInt32(); } public static implicit operator long(PointerSize value) { return value._size.ToInt64(); } public static implicit operator PointerSize(int value) { return new PointerSize(value); } public static implicit operator PointerSize(long value) { return new PointerSize(value); } public static implicit operator PointerSize(IntPtr value) { return new PointerSize(value); } public static implicit operator IntPtr(PointerSize value) { return value._size; } public unsafe static implicit operator PointerSize(void* value) { return new PointerSize(value); } public unsafe static implicit operator void*(PointerSize value) { return (void*)value._size; } } public struct Result : IEquatable<Result> { private int _code; public static readonly Result Ok = new Result(0); public static readonly Result False = new Result(1); public static readonly ResultDescriptor Abort = new ResultDescriptor(-2147467260, "General", "E_ABORT", "Operation aborted"); public static readonly ResultDescriptor AccessDenied = new ResultDescriptor(-2147024891, "General", "E_ACCESSDENIED", "General access denied error"); public static readonly ResultDescriptor Fail = new ResultDescriptor(-2147467259, "General", "E_FAIL", "Unspecified error"); public static readonly ResultDescriptor Handle = new ResultDescriptor(-2147024890, "General", "E_HANDLE", "Invalid handle"); public static readonly ResultDescriptor InvalidArg = new ResultDescriptor(-2147024809, "General", "E_INVALIDARG", "Invalid Arguments"); public static readonly ResultDescriptor NoInterface = new ResultDescriptor(-2147467262, "General", "E_NOINTERFACE", "No such interface supported"); public static readonly ResultDescriptor NotImplemented = new ResultDescriptor(-2147467263, "General", "E_NOTIMPL", "Not implemented"); public static readonly ResultDescriptor OutOfMemory = new ResultDescriptor(-2147024882, "General", "E_OUTOFMEMORY", "Out of memory"); public static readonly ResultDescriptor InvalidPointer = new ResultDescriptor(-2147467261, "General", "E_POINTER", "Invalid pointer"); public static readonly ResultDescriptor UnexpectedFailure = new ResultDescriptor(-2147418113, "General", "E_UNEXPECTED", "Catastrophic failure"); public static readonly ResultDescriptor WaitAbandoned = new ResultDescriptor(128, "General", "WAIT_ABANDONED", "WaitAbandoned"); public static readonly ResultDescriptor WaitTimeout = new ResultDescriptor(258, "General", "WAIT_TIMEOUT", "WaitTimeout"); public static readonly ResultDescriptor Pending = new ResultDescriptor(-2147483638, "General", "E_PENDING", "Pending"); public int Code => _code; public bool Success => Code >= 0; public bool Failure => Code < 0; public Result(int code) { _code = code; } public Result(uint code) { _code = (int)code; } public static explicit operator int(Result result) { return result.Code; } public static explicit operator uint(Result result) { return (uint)result.Code; } public static implicit operator Result(int result) { return new Result(result); } public static implicit operator Result(uint result) { return new Result(result); } public bool Equals(Result other) { return Code == other.Code; } public override bool Equals(object obj) { if (!(obj is Result)) { return false; } return Equals((Result)obj); } public override int GetHashCode() { return Code; } public static bool operator ==(Result left, Result right) { return left.Code == right.Code; } public static bool operator !=(Result left, Result right) { return left.Code != right.Code; } public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "HRESULT = 0x{0:X}", _code); } public void CheckError() { if (_code < 0) { throw new SharpDXException(this); } } public static Result GetResultFromException(Exception ex) { return new Result(Marshal.GetHRForException(ex)); } public static Result GetResultFromWin32Error(int win32Error) { return (int)((win32Error <= 0) ? win32Error : ((win32Error & 0xFFFF) | 0x70000 | 0x80000000u)); } } public sealed class ResultDescriptor { private static readonly object LockDescriptor = new object(); private static readonly List<Type> RegisteredDescriptorProvider = new List<Type>(); private static readonly Dictionary<Result, ResultDescriptor> Descriptors = new Dictionary<Result, ResultDescriptor>(); private const string UnknownText = "Unknown"; public Result Result { get; private set; } public int Code => Result.Code; public string Module { get; private set; } public string NativeApiCode { get; private set; } public string ApiCode { get; private set; } public string Description { get; set; } public ResultDescriptor(Result code, string module, string nativeApiCode, string apiCode, string description = null) { Result = code; Module = module; NativeApiCode = nativeApiCode; ApiCode = apiCode; Description = description; } public bool Equals(ResultDescriptor other) { if (other == null) { return false; } if ((object)this == other) { return true; } return other.Result.Equals(Result); } public override bool Equals(object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (obj.GetType() != typeof(ResultDescriptor)) { return false; } return Equals((ResultDescriptor)obj); } public override int GetHashCode() { return Result.GetHashCode(); } public override string ToString() { return $"HRESULT: [0x{Result.Code:X}], Module: [{Module}], ApiCode: [{NativeApiCode}/{ApiCode}], Message: {Description}"; } public static implicit operator Result(ResultDescriptor result) { return result.Result; } public static explicit operator int(ResultDescriptor result) { return result.Result.Code; } public static explicit operator uint(ResultDescriptor result) { return (uint)result.Result.Code; } public static bool operator ==(ResultDescriptor left, Result right) { if (left == null) { return false; } return left.Result.Code == right.Code; } public static bool operator !=(ResultDescriptor left, Result right) { if (left == null) { return false; } return left.Result.Code != right.Code; } public static void RegisterProvider(Type descriptorsProviderType) { lock (LockDescriptor) { if (!RegisteredDescriptorProvider.Contains(descriptorsProviderType)) { RegisteredDescriptorProvider.Add(descriptorsProviderType); } } } public static ResultDescriptor Find(Result result) { ResultDescriptor value; lock (LockDescriptor) { if (RegisteredDescriptorProvider.Count > 0) { foreach (Type item in RegisteredDescriptorProvider) { AddDescriptorsFromType(item); } RegisteredDescriptorProvider.Clear(); } if (!Descriptors.TryGetValue(result, out value)) { value = new ResultDescriptor(result, "Unknown", "Unknown", "Unknown"); } if (value.Description == null) { string descriptionFromResultCode = GetDescriptionFromResultCode(result.Code); value.Description = descriptionFromResultCode ?? "Unknown"; } } return value; } private static void AddDescriptorsFromType(Type type) { foreach (FieldInfo declaredField in type.GetTypeInfo().DeclaredFields) { if (declaredField.FieldType == typeof(ResultDescriptor) && declaredField.IsPublic && declaredField.IsStatic) { ResultDescriptor resultDescriptor = (ResultDescriptor)declaredField.GetValue(null); if (!Descriptors.ContainsKey(resultDescriptor.Result)) { Descriptors.Add(resultDescriptor.Result, resultDescriptor); } } } } private static string GetDescriptionFromResultCode(int resultCode) { IntPtr lpBuffer = IntPtr.Zero; FormatMessageW(4864, IntPtr.Zero, resultCode, 0, ref lpBuffer, 0, IntPtr.Zero); string? result = Marshal.PtrToStringUni(lpBuffer); Marshal.FreeHGlobal(lpBuffer); return result; } [DllImport("kernel32.dll")] private static extern uint FormatMessageW(int dwFlags, IntPtr lpSource, int dwMessageId, int dwLanguageId, ref IntPtr lpBuffer, int nSize, IntPtr Arguments); } public class ServiceEventArgs : EventArgs { public Type ServiceType { get; private set; } public object Instance { get; private set; } public ServiceEventArgs(Type serviceType, object serviceInstance) { ServiceType = serviceType; Instance = serviceInstance; } } [AttributeUsage(AttributeTargets.Interface)] internal class ShadowAttribute : Attribute { private Type type; public Type Type => type; public ShadowAttribute(Type typeOfTheAssociatedShadow) { type = typeOfTheAssociatedShadow; } public static ShadowAttribute Get(Type type) { return type.GetTypeInfo().GetCustomAttribute<ShadowAttribute>(); } } internal class ShadowContainer : DisposeBase { private readonly Dictionary<Guid, CppObjectShadow> guidToShadow = new Dictionary<Guid, CppObjectShadow>(); private static readonly Dictionary<Type, List<Type>> typeToShadowTypes = new Dictionary<Type, List<Type>>(); private IntPtr guidPtr; public IntPtr[] Guids { get; private set; } public unsafe void Initialize(ICallbackable callbackable) { callbackable.Shadow = this; Type type = callbackable.GetType(); List<Type> value; lock (typeToShadowTypes) { if (!typeToShadowTypes.TryGetValue(type, out value)) { IEnumerable<Type> implementedInterfaces = type.GetTypeInfo().ImplementedInterfaces; value = new List<Type>(); value.AddRange(implementedInterfaces); typeToShadowTypes.Add(type, value); foreach (Type item in implementedInterfaces) { if (ShadowAttribute.Get(item) == null) { value.Remove(item); continue; } foreach (Type implementedInterface in item.GetTypeInfo().ImplementedInterfaces) { value.Remove(implementedInterface); } } } } CppObjectShadow cppObjectShadow = null; foreach (Type item2 in value) { CppObjectShadow cppObjectShadow2 = (CppObjectShadow)Activator.CreateInstance(ShadowAttribute.Get(item2).Type); cppObjectShadow2.Initialize(callbackable); if (cppObjectShadow == null) { cppObjectShadow = cppObjectShadow2; guidToShadow.Add(ComObjectShadow.IID_IUnknown, cppObjectShadow); } guidToShadow.Add(Utilities.GetGuidFromType(item2), cppObjectShadow2); foreach (Type implementedInterface2 in item2.GetTypeInfo().ImplementedInterfaces) { if (ShadowAttribute.Get(implementedInterface2) != null) { guidToShadow.Add(Utilities.GetGuidFromType(implementedInterface2), cppObjectShadow2); } } } int num = 0; foreach (Guid key in guidToShadow.Keys) { if (key != Utilities.GetGuidFromType(typeof(IInspectable)) && key != Utilities.GetGuidFromType(typeof(IUnknown))) { num++; } } guidPtr = Marshal.AllocHGlobal(Utilities.SizeOf<Guid>() * num); Guids = new IntPtr[num]; int num2 = 0; Guid* ptr = (Guid*)(void*)guidPtr; foreach (Guid key2 in guidToShadow.Keys) { if (!(key2 == Utilities.GetGuidFromType(typeof(IInspectable))) && !(key2 == Utilities.GetGuidFromType(typeof(IUnknown)))) { ptr[num2] = key2; Guids[num2] = new IntPtr(ptr + num2); num2++; } } } internal IntPtr Find(Type type) { return Find(Utilities.GetGuidFromType(type)); } internal IntPtr Find(Guid guidType) { return FindShadow(guidType)?.NativePointer ?? IntPtr.Zero; } internal CppObjectShadow FindShadow(Guid guidType) { guidToShadow.TryGetValue(guidType, out var value); return value; } protected override void Dispose(bool disposing) { if (!disposing) { return; } foreach (CppObjectShadow value in guidToShadow.Values) { value.Dispose(); } guidToShadow.Clear(); if (guidPtr != IntPtr.Zero) { Marshal.FreeHGlobal(guidPtr); guidPtr = IntPtr.Zero; } } } public class SharpDXException : Exception { private ResultDescriptor descriptor; public Result ResultCode => descriptor.Result; public ResultDescriptor Descriptor => descriptor; public SharpDXException() : base("A SharpDX exception occurred.") { descriptor = ResultDescriptor.Find(Result.Fail); base.HResult = (int)Result.Fail; } public SharpDXException(Result result) : this(ResultDescriptor.Find(result)) { base.HResult = (int)result; } public SharpDXException(ResultDescriptor descriptor) : base(descriptor.ToString()) { this.descriptor = descriptor; base.HResult = (int)descriptor.Result; } public SharpDXException(Result result, string message) : base(message) { descriptor = ResultDescriptor.Find(result); base.HResult = (int)result; } public SharpDXException(Result result, string message, params object[] args) : base(string.Format(CultureInfo.InvariantCulture, message, args)) { descriptor = ResultDescriptor.Find(result); base.HResult = (int)result; } public SharpDXException(string message, params object[] args) : this(Result.Fail, message, args) { } public SharpDXException(string message, Exception innerException, params object[] args) : base(string.Format(CultureInfo.InvariantCulture, message, args), innerException) { descriptor = ResultDescriptor.Find(Result.Fail); base.HResult = (int)Result.Fail; } } public struct Size2 : IEquatable<Size2> { public static readonly Size2 Zero = new Size2(0, 0); public static readonly Size2 Empty = Zero; public int Width; public int Height; public Size2(int width, int height) { Width = width; Height = height; } public bool Equals(Size2 other) { if (other.Width == Width) { return other.Height == Height; } return false; } public override bool Equals(object obj) { if (!(obj is Size2)) { return false; } return Equals((Size2)obj); } public override int GetHashCode() { return (Width * 397) ^ Height; } public static bool operator ==(Size2 left, Size2 right) { return left.Equals(right); } public static bool operator !=(Size2 left, Size2 right) { return !left.Equals(right); } public override string ToString() { return $"({Width},{Height})"; } } public struct Size2F : IEquatable<Size2F> { public static readonly Size2F Zero = new Size2F(0f, 0f); public static readonly Size2F Empty = Zero; public float Width; public float Height; public Size2F(float width, float height) { Width = width; Height = height; } public bool Equals(Size2F other) { if (other.Width == Width) { return other.Height == Height; } return false; } public override bool Equals(object obj) { if (!(obj is Size2F)) { return false; } return Equals((Size2F)obj); } public override int GetHashCode() { return (Width.GetHashCode() * 397) ^ Height.GetHashCode(); } public static bool operator ==(Size2F left, Size2F right) { return left.Equals(right); } public static bool operator !=(Size2F left, Size2F right) { return !left.Equals(right); } public override string ToString() { return $"({Width},{Height})"; } } [AttributeUsage(AttributeTargets.All)] public class TagAttribute : Attribute { public string Value { get; private set; } public TagAttribute(string value) { Value = value; } } public delegate void GetValueFastDelegate<T>(object obj, out T value); public delegate void SetValueFastDelegate<T>(object obj, ref T value); public static class Utilities { [Flags] public enum CLSCTX : uint { ClsctxInprocServer = 1u, ClsctxInprocHandler = 2u, ClsctxLocalServer = 4u, ClsctxInprocServer16 = 8u, ClsctxRemoteServer = 0x10u, ClsctxInprocHandler16 = 0x20u, ClsctxReserved1 = 0x40u, ClsctxReserved2 = 0x80u, ClsctxReserved3 = 0x100u, ClsctxReserved4 = 0x200u, ClsctxNoCodeDownload = 0x400u, ClsctxReserved5 = 0x800u, ClsctxNoCustomMarshal = 0x1000u, ClsctxEnableCodeDownload = 0x2000u, ClsctxNoFailureLog = 0x4000u, ClsctxDisableAaa = 0x8000u, ClsctxEnableAaa = 0x10000u, ClsctxFromDefaultContext = 0x20000u, ClsctxInproc = 3u, ClsctxServer = 0x15u, ClsctxAll = 0x17u } public enum CoInit { MultiThreaded = 0, ApartmentThreaded = 2, DisableOle1Dde = 4, SpeedOverMemory = 8 } internal struct Buffer<TElement> { internal TElement[] items; internal int count; internal Buffer(IEnumerable<TElement> source) { TElement[] array = null; int num = 0; if (source is ICollection<TElement> collection) { num = collection.Count; if (num > 0) { array = new TElement[num]; collection.CopyTo(array, 0); } } else { foreach (TElement item in source) { if (array == null) { array = new TElement[4]; } else if (array.Length == num) { TElement[] array2 = new TElement[checked(num * 2)]; Array.Copy(array, 0, array2, 0, num); array = array2; } array[num] = item; num++; } } items = array; count = num; } internal TElement[] ToArray() { if (count == 0) { return new TElement[0]; } if (items.Length == count) { return items; } TElement[] array = new TElement[count]; Array.Copy(items, 0, array, 0, count); return array; } } public unsafe static void CopyMemory(IntPtr dest, IntPtr src, int sizeInBytesToCopy) { Interop.memcpy((void*)dest, (void*)src, sizeInBytesToCopy); } public unsafe static bool CompareMemory(IntPtr from, IntPtr against, int sizeToCompare) { byte* ptr = (byte*)(void*)from; byte* ptr2 = (byte*)(void*)against; for (int num = sizeToCompare >> 3; num > 0; num--) { if (*(long*)ptr != *(long*)ptr2) { return false; } ptr += 8; ptr2 += 8; } for (int num = sizeToCompare & 7; num > 0; num--) { if (*ptr != *ptr2) { return false; } ptr++; ptr2++; } return true; } public unsafe static void ClearMemory(IntPtr dest, byte value, int sizeInBytesToClear) { Interop.memset((void*)dest, value, sizeInBytesToClear); } public static int SizeOf<T>() where T : struct { return Unsafe.SizeOf<T>(); } public static int SizeOf<T>(T[] array) where T : struct { if (array != null) { return array.Length * Unsafe.SizeOf<T>(); } return 0; } public unsafe static void Pin<T>(ref T source, Action<IntPtr> pinAction) where T : struct { fixed (T* ptr = &source) { pinAction((IntPtr)ptr); } } public unsafe static void Pin<T>(T[] source, Action<IntPtr> pinAction) where T : struct { //The blocks IL_0019 are reachable both inside and outside the pinned region starting at IL_000b. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement. IntPtr obj; if (source != null) { fixed (T* ptr = &source[0]) { obj = (IntPtr)ptr; pinAction(obj); return; } } obj = IntPtr.Zero; pinAction(obj); } public unsafe static byte[] ToByteArray<T>(T[] source) where T : struct { if (source == null) { return null; } byte[] array = new byte[SizeOf<T>() * source.Length]; if (source.Length == 0) { return array; } fixed (byte* ptr = array) { void* pDest = ptr; Interop.Write(pDest, source, 0, source.Length); } return array; } public static void Swap<T>(ref T left, ref T right) { T val = left; left = right; right = val; } public unsafe static T Read<T>(IntPtr source) where T : struct { return Unsafe.Read<T>((void*)source); } public unsafe static void Read<T>(IntPtr source, ref T data) where T : struct { data = Unsafe.Read<T>((void*)source); } public unsafe static void ReadOut<T>(IntPtr source, out T data) where T : struct { data = Unsafe.Read<T>((void*)source); } public unsafe static IntPtr ReadAndPosition<T>(IntPtr source, ref T data) where T : struct { return (IntPtr)Interop.Read((void*)source, ref data); } public unsafe static IntPtr Read<T>(IntPtr source, T[] data, int offset, int count) where T : struct { return (IntPtr)Interop.Read((void*)source, data, offset, count); } public unsafe static void Write<T>(IntPtr destination, ref T data) where T : struct { Unsafe.Write((void*)destination, data); } public unsafe static IntPtr WriteAndPosition<T>(IntPtr destination, ref T data) where T : struct { return (IntPtr)Interop.Write((void*)destination, ref data); } public unsafe static IntPtr Write<T>(IntPtr destination, T[] data, int offset, int count) where T : struct { return (IntPtr)Interop.Write((void*)destination, data, offset, count); } public unsafe static void ConvertToIntArray(bool[] array, int* dest) { for (int i = 0; i < array.Length; i++) { dest[i] = (array[i] ? 1 : 0); } } public static RawBool[] ConvertToIntArray(bool[] array) { RawBool[] array2 = new RawBool[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i]; } return array2; } public unsafe static bool[] ConvertToBoolArray(int* array, int length) { bool[] array2 = new bool[length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i] != 0; } return array2; } public static bool[] ConvertToBoolArray(RawBool[] array) { bool[] array2 = new bool[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i]; } return array2; } public static Guid GetGuidFromType(Type type) { return type.GetTypeInfo().GUID; } public static bool IsAssignableToGenericType(Type givenType, Type genericType) { foreach (Type implementedInterface in givenType.GetTypeInfo().ImplementedInterfaces) { if (implementedInterface.GetTypeInfo().IsGenericType && implementedInterface.GetGenericTypeDefinition() == genericType) { return true; } } if (givenType.GetTypeInfo().IsGenericType && givenType.GetGenericTypeDefinition() == genericType) { return true; } Type baseType = givenType.GetTypeInfo().BaseType; if (baseType == null) { return false; } return IsAssignableToGenericType(baseType, genericType); } public unsafe static IntPtr AllocateMemory(int sizeInBytes, int align = 16) { int num = align - 1; IntPtr intPtr = Marshal.AllocHGlobal(sizeInBytes + num + IntPtr.Size); long num2 = (long)((byte*)(void*)intPtr + sizeof(void*) + num) & (long)(~num); *(IntPtr*)((nint)num2 + (nint)(-1) * (nint)sizeof(IntPtr)) = intPtr; return new IntPtr((void*)num2); } public static IntPtr AllocateClearedMemory(int sizeInBytes, byte clearValue = 0, int align = 16) { IntPtr intPtr = AllocateMemory(sizeInBytes, align); ClearMemory(intPtr, clearValue, sizeInBytes); return intPtr; } public static bool IsMemoryAligned(IntPtr memoryPtr, int align = 16) { return (memoryPtr.ToInt64() & (align - 1)) == 0; } public unsafe static void FreeMemory(IntPtr alignedBuffer) { if (!(alignedBuffer == IntPtr.Zero)) { Marshal.FreeHGlobal(*(IntPtr*)((byte*)(void*)alignedBuffer + (nint)(-1) * (nint)sizeof(IntPtr))); } } public static string PtrToStringAnsi(IntPtr pointer, int maxLength) { string text = Marshal.PtrToStringAnsi(pointer); if (text != null && text.Length > maxLength) { text = text.Substring(0, maxLength); } return text; } public static string PtrToStringUni(IntPtr pointer, int maxLength) { string text = Marshal.PtrToStringUni(pointer); if (text != null && text.Length > maxLength) { text = text.Substring(0, maxLength); } return text; } public static IntPtr StringToHGlobalAnsi(string s) { return Marshal.StringToHGlobalAnsi(s); } public static IntPtr StringToHGlobalUni(string s) { return Marshal.StringToHGlobalUni(s); } public static IntPtr StringToCoTaskMemUni(string s) { if (s == null) { return IntPtr.Zero; } int num = (s.Length + 1) * 2; if (num < s.Length) { throw new ArgumentOutOfRangeException("s"); } IntPtr intPtr = Marshal.AllocCoTaskMem(num); if (intPtr == IntPtr.Zero) { throw new OutOfMemoryException(); } CopyStringToUnmanaged(intPtr, s); return intPtr; } private unsafe static void CopyStringToUnmanaged(IntPtr ptr, string str) { fixed (char* value = str) { CopyMemory(ptr, new IntPtr(value), (str.Length + 1) * 2); } } public static IntPtr GetIUnknownForObject(object obj) { if (obj != null) { return Marshal.GetIUnknownForObject(obj); } return IntPtr.Zero; } public static object GetObjectForIUnknown(IntPtr iunknownPtr) { if (!(iunknownPtr == IntPtr.Zero)) { return Marshal.GetObjectForIUnknown(iunknownPtr); } return null; } public static string Join<T>(string separator, T[] array) { StringBuilder stringBuilder = new StringBuilder(); if (array != null) { for (int i = 0; i < array.Length; i++) { if (i > 0) { stringBuilder.Append(separator); } stringBuilder.Append(array[i]); } } return stringBuilder.ToString(); } public static string Join(string separator, IEnumerable elements) { List<string> list = new List<string>(); foreach (object element in elements) { list.Add(element.ToString()); } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { string value = list[i]; if (i > 0) { stringBuilder.Append(separator); } stringBuilder.Append(value); } return stringBuilder.ToString(); } public static string Join(string separator, IEnumerator elements) { List<string> list = new List<string>(); while (elements.MoveNext()) { list.Add(elements.Current.ToString()); } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { string value = list[i]; if (i > 0) { stringBuilder.Append(separator); } stringBuilder.Append(value); } return stringBuilder.ToString(); } public static string BlobToString(Blob blob) { if (blob == null) { return null; } string? result = Marshal.PtrToStringAnsi(blob.BufferPointer); blob.Dispose(); return result; } public unsafe static IntPtr IntPtrAdd(IntPtr ptr, int offset) { return new IntPtr((byte*)(void*)ptr + offset); } public static byte[] ReadStream(Stream stream) { int readLength = 0; return ReadStream(stream, ref readLength); } public static byte[] ReadStream(Stream stream, ref int readLength) { if (readLength == 0) { readLength = (int)(stream.Length - stream.Position); } int num = readLength; if (num == 0) { return new byte[0]; } byte[] array = new byte[num]; int num2 = 0; if (num > 0) { do { num2 += stream.Read(array, num2, readLength - num2); } while (num2 < readLength); } return array; } public static bool Compare(IEnumerable left, IEnumerable right) { if (left == right) { return true; } if (left == null || right == null) { return false; } return Compare(left.GetEnumerator(), right.GetEnumerator()); } public static bool Compare(IEnumerator leftIt, IEnumerator rightIt) { if (leftIt == rightIt) { return true; } if (leftIt == null || rightIt == null) { return false; } bool flag; bool flag2; while (true) { flag = leftIt.MoveNext(); flag2 = rightIt.MoveNext(); if (!flag || !flag2) { break; } if (!object.Equals(leftIt.Current, rightIt.Current)) { return false; } } if (flag != flag2) { return false; } return true; } public static bool Compare(ICollection left, ICollection right) { if (left == right) { return true; } if (left == null || right == null) { return false; } if (left.Count != right.Count) { return false; } int num = 0; IEnumerator enumerator = left.GetEnumerator(); IEnumerator enumerator2 = right.GetEnumerator(); while (enumerator.MoveNext() && enumerator2.MoveNext()) { if (!object.Equals(enumerator.Current, enumerator2.Current)) { return false; } num++; } if (num != left.Count) { return false; } return true; } public static T GetCustomAttribute<T>(MemberInfo memberInfo, bool inherited = false) where T : Attribute { return memberInfo.GetCustomAttribute<T>(inherited); } public static IEnumerable<T> GetCustomAttributes<T>(MemberInfo memberInfo, bool inherited = false) where T : Attribute { return memberInfo.GetCustomAttributes<T>(inherited); } public static bool IsAssignableFrom(Type toType, Type fromType) { return toType.GetTypeInfo().IsAssignableFrom(fromType.GetTypeInfo()); } public static bool IsEnum(Type typeToTest) { return typeToTest.GetTypeInfo().IsEnum; } public static bool IsValueType(Type typeToTest) { return typeToTest.GetTypeInfo().IsValueType; } private static MethodInfo GetMethod(Type type, string name, Type[] typeArgs) { foreach (MethodInfo declaredMethod in type.GetTypeInfo().GetDeclaredMethods(name)) { if (declaredMethod.GetParameters().Length != typeArgs.Length) { continue; } ParameterInfo[] parameters = declaredMethod.GetParameters(); bool flag = true; for (int i = 0; i < typeArgs.Length; i++) { if (parameters[i].ParameterType != typeArgs[i]) { flag = false; break; } } if (flag) { return declaredMethod; } } return null; } public static GetValueFastDelegate<T> BuildPropertyGetter<T>(Type customEffectType, PropertyInfo propertyInfo) { ParameterExpression parameterExpression = Expression.Parameter(typeof(T).MakeByRefType()); ParameterExpression parameterExpression2 = Expression.Parameter(typeof(object)); MemberExpression memberExpression = Expression.Property(Expression.Convert(parameterExpression2, customEffectType), propertyInfo); Expression right = ((!(propertyInfo.PropertyType == typeof(bool))) ? ((Expression)Expression.Convert(memberExpression, typeof(T))) : ((Expression)Expression.Condition(memberExpression, Expression.Constant(1), Expression.Constant(0)))); return Expression.Lambda<GetValueFastDelegate<T>>(Expression.Assign(parameterExpression, right), new ParameterExpression[2] { parameterExpression2, parameterExpression }).Compile(); } public static SetValueFastDelegate<T> BuildPropertySetter<T>(Type customEffectType, PropertyInfo propertyInfo) { ParameterExpression parameterExpression = Expression.Parameter(typeof(T).MakeByRefType()); ParameterExpression parameterExpression2 = Expression.Parameter(typeof(object)); MemberExpression left = Expression.Property(Expression.Convert(parameterExpression2, customEffectType), propertyInfo); Expression right = ((!(propertyInfo.PropertyType == typeof(bool))) ? ((Expression)Expression.Convert(parameterExpression, propertyInfo.PropertyType)) : ((Expression)Expression.NotEqual(parameterExpression, Expression.Constant(0)))); return Expression.Lambda<SetValueFastDelegate<T>>(Expression.Assign(left, right), new ParameterExpression[2] { parameterExpression2, parameterExpression }).Compile(); } private static MethodInfo FindExplicitConverstion(Type sourceType, Type targetType) { if (sourceType == targetType) { return null; } List<MethodInfo> list = new List<MethodInfo>(); Type type = sourceType; while (type != null) { list.AddRange(type.GetTypeInfo().DeclaredMethods); type = type.GetTypeInfo().BaseType; } type = targetType; while (type != null) { list.AddRange(type.GetTypeInfo().DeclaredMethods); type = type.GetTypeInfo().BaseType; } foreach (MethodInfo item in list) { if (item.Name == "op_Explicit" && item.ReturnType == targetType && IsAssignableFrom(item.GetParameters()[0].ParameterType, sourceType)) { return item; } } return null; } [DllImport("ole32.dll", ExactSpelling = true)] private static extern Result CoCreateInstance([In][MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr pUnkOuter, CLSCTX dwClsContext, [In][MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IntPtr comObject); internal static void CreateComInstance(Guid clsid, CLSCTX clsctx, Guid riid, ComObject comObject) { CoCreateInstance(clsid, IntPtr.Zero, clsctx, riid, out var comObject2).CheckError(); comObject.NativePointer = comObject2; } internal static bool TryCreateComInstance(Guid clsid, CLSCTX clsctx, Guid riid, ComObject comObject) { IntPtr comObject2; Result result = CoCreateInstance(clsid, IntPtr.Zero, clsctx, riid, out comObject2); comObject.NativePointer = comObject2; return result.Success; } [DllImport("kernel32.dll", SetLastError = true)] internal static extern bool CloseHandle(IntPtr handle); public static IntPtr GetProcAddress(IntPtr handle, string dllFunctionToImport) { IntPtr procAddress_ = GetProcAddress_(handle, dllFunctionToImport); if (procAddress_ == IntPtr.Zero) { throw new SharpDXException(dllFunctionToImport); } return procAddress_; } [DllImport("kernel32", CharSet = CharSet.Ansi, EntryPoint = "GetProcAddress", ExactSpelling = true, SetLastError = true)] private static extern IntPtr GetProcAddress_(IntPtr hModule, string procName); public static int ComputeHashFNVModified(byte[] data) { uint num = 2166136261u; foreach (byte b in data) { num = (num ^ b) * 16777619; } num += num << 13; num ^= num >> 7; num += num << 3; num ^= num >> 17; return (int)(num + (num << 5)); } public static void Dispose<T>(ref T comObject) where T : class, IDisposable { if (comObject != null) { comObject.Dispose(); comObject = null; } } public static T[] ToArray<T>(IEnumerable<T> source) { return new Buffer<T>(source).ToArray(); } public static bool Any<T>(IEnumerable<T> source) { return source.GetEnumerator().MoveNext(); } public static IEnumerable<TResult> SelectMany<TSource, TResult>(IEnumerable<TSource> source, Func<TSource, IEnumerable<TResult>> selector) { foreach (TSource item in source) { foreach (TResult item2 in selector(item)) { yield return item2; } } } public static IEnumerable<TSource> Distinct<TSource>(IEnumerable<TSource> source, IEqualityComparer<TSource> comparer = null) { if (comparer == null) { comparer = EqualityComparer<TSource>.Default; } Dictionary<TSource, object> values = new Dictionary<TSource, object>(comparer); foreach (TSource item in source) { if (!values.ContainsKey(item)) { values.Add(item, null); yield return item; } } } public static bool IsTypeInheritFrom(Type type, string parentType) { while (type != null) { if (type.FullName == parentType) { return true; } type = type.GetTypeInfo().BaseType; } return false; } } } namespace SharpDX.Win32 { public struct BitmapInfoHeader { public int SizeInBytes; public int Width; public int Height; public short PlaneCount; public short BitCount; public int Compression; public int SizeImage; public int XPixelsPerMeter; public int YPixelsPerMeter; public int ColorUsedCount; public int ColorImportantCount; } public class ComBaseStreamNative { public IDisposable Callback { get; set; } } internal class ComStreamBaseShadow : ComObjectShadow { internal class ComStreamBaseVtbl : ComObjectVtbl { [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int ReadDelegate(IntPtr thisPtr, IntPtr buffer, int sizeOfBytes, out int bytesRead); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int WriteDelegate(IntPtr thisPtr, IntPtr buffer, int sizeOfBytes, out int bytesWrite); public ComStreamBaseVtbl(int numberOfMethods) : base(numberOfMethods + 2) { AddMethod(new ReadDelegate(ReadImpl)); AddMethod(new WriteDelegate(WriteImpl)); } private static int ReadImpl(IntPtr thisPtr, IntPtr buffer, int sizeOfBytes, out int bytesRead) { bytesRead = 0; try { IStream stream = (IStream)CppObjectShadow.ToShadow<ComStreamBaseShadow>(thisPtr).Callback; bytesRead = stream.Read(buffer, sizeOfBytes); } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } private static int WriteImpl(IntPtr thisPtr, IntPtr buffer, int sizeOfBytes, out int bytesWrite) { bytesWrite = 0; try { IStream stream = (IStream)CppObjectShadow.ToShadow<ComStreamBaseShadow>(thisPtr).Callback; bytesWrite = stream.Write(buffer, sizeOfBytes); } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } } private static readonly ComStreamBaseVtbl Vtbl = new ComStreamBaseVtbl(0); protected override CppObjectVtbl GetVtbl => Vtbl; } [Guid("0000000c-0000-0000-C000-000000000046")] internal class ComStreamProxy : CallbackBase, IStream, IStreamBase, IUnknown, ICallbackable, IDisposable { private Stream sourceStream; private byte[] tempBuffer = new byte[4096]; public ComStreamProxy(Stream sourceStream) { this.sourceStream = sourceStream; } public unsafe int Read(IntPtr buffer, int numberOfBytesToRead) { int num = 0; while (numberOfBytesToRead > 0) { int count = Math.Min(numberOfBytesToRead, tempBuffer.Length); int num2 = sourceStream.Read(tempBuffer, 0, count); if (num2 == 0) { return num; } Utilities.Write(new IntPtr(num + (byte*)(void*)buffer), tempBuffer, 0, num2); numberOfBytesToRead -= num2; num += num2; } return num; } public unsafe int Write(IntPtr buffer, int numberOfBytesToWrite) { int num = 0; while (numberOfBytesToWrite > 0) { int num2 = Math.Min(numberOfBytesToWrite, tempBuffer.Length); Utilities.Read(new IntPtr(num + (byte*)(void*)buffer), tempBuffer, 0, num2); sourceStream.Write(tempBuffer, 0, num2); numberOfBytesToWrite -= num2; num += num2; } return num; } public long Seek(long offset, SeekOrigin origin) { return sourceStream.Seek(offset, origin); } public void SetSize(long newSize) { } public unsafe long CopyTo(IStream streamDest, long numberOfBytesToCopy, out long bytesWritten) { bytesWritten = 0L; fixed (byte* ptr = tempBuffer) { void* ptr2 = ptr; while (numberOfBytesToCopy > 0) { int count = (int)Math.Min(numberOfBytesToCopy, tempBuffer.Length); int num = sourceStream.Read(tempBuffer, 0, count); if (num == 0) { break; } streamDest.Write((IntPtr)ptr2, num); numberOfBytesToCopy -= num; bytesWritten += num; } } return bytesWritten; } public void Commit(CommitFlags commitFlags) { sourceStream.Flush(); } public void Revert() { throw new NotImplementedException(); } public void LockRegion(long offset, long numberOfBytesToLock, LockType dwLockType) { throw new NotImplementedException(); } public void UnlockRegion(long offset, long numberOfBytesToLock, LockType dwLockType) { throw new NotImplementedException(); } public StorageStatistics GetStatistics(StorageStatisticsFlags storageStatisticsFlags) { long num = sourceStream.Length; if (num == 0L) { num = 2147483647L; } StorageStatistics result = default(StorageStatistics); result.Type = 2; result.CbSize = num; result.GrfLocksSupported = 2; result.GrfMode = 2; return result; } public IStream Clone() { return new ComStreamProxy(sourceStream); } protected override void Dispose(bool disposing) { sourceStream = null; base.Dispose(disposing); } } internal class ComStreamShadow : ComStreamBaseShadow { private class ComStreamVtbl : ComStreamBaseVtbl { [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int SeekDelegate(IntPtr thisPtr, long offset, SeekOrigin origin, IntPtr newPosition); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result SetSizeDelegate(IntPtr thisPtr, long newSize); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate int CopyToDelegate(IntPtr thisPtr, IntPtr streamPointer, long numberOfBytes, out long numberOfBytesRead, out long numberOfBytesWritten); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result CommitDelegate(IntPtr thisPtr, CommitFlags flags); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result RevertDelegate(IntPtr thisPtr); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result LockRegionDelegate(IntPtr thisPtr, long offset, long numberOfBytes, LockType lockType); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result UnlockRegionDelegate(IntPtr thisPtr, long offset, long numberOfBytes, LockType lockType); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result StatDelegate(IntPtr thisPtr, ref StorageStatistics.__Native statisticsPtr, StorageStatisticsFlags flags); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate Result CloneDelegate(IntPtr thisPtr, out IntPtr streamPointer); public ComStreamVtbl() : base(9) { AddMethod(new SeekDelegate(SeekImpl)); AddMethod(new SetSizeDelegate(SetSizeImpl)); AddMethod(new CopyToDelegate(CopyToImpl)); AddMethod(new CommitDelegate(CommitImpl)); AddMethod(new RevertDelegate(RevertImpl)); AddMethod(new LockRegionDelegate(LockRegionImpl)); AddMethod(new UnlockRegionDelegate(UnlockRegionImpl)); AddMethod(new StatDelegate(StatImpl)); AddMethod(new CloneDelegate(CloneImpl)); } private unsafe static int SeekImpl(IntPtr thisPtr, long offset, SeekOrigin origin, IntPtr newPosition) { try { long num = ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).Seek(offset, origin); if (newPosition != IntPtr.Zero) { *(long*)(void*)newPosition = num; } } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } private static Result SetSizeImpl(IntPtr thisPtr, long newSize) { Result result = Result.Ok; try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).SetSize(newSize); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } private static int CopyToImpl(IntPtr thisPtr, IntPtr streamPointer, long numberOfBytes, out long numberOfBytesRead, out long numberOfBytesWritten) { numberOfBytesRead = 0L; numberOfBytesWritten = 0L; try { IStream stream = (IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback; numberOfBytesRead = stream.CopyTo(new ComStream(streamPointer), numberOfBytes, out numberOfBytesWritten); } catch (Exception ex) { return (int)Result.GetResultFromException(ex); } return Result.Ok.Code; } private static Result CommitImpl(IntPtr thisPtr, CommitFlags flags) { Result result = Result.Ok; try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).Commit(flags); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } private static Result RevertImpl(IntPtr thisPtr) { Result result = Result.Ok; try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).Revert(); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } private static Result LockRegionImpl(IntPtr thisPtr, long offset, long numberOfBytes, LockType lockType) { Result result = Result.Ok; try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).LockRegion(offset, numberOfBytes, lockType); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } private static Result UnlockRegionImpl(IntPtr thisPtr, long offset, long numberOfBytes, LockType lockType) { Result result = Result.Ok; try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).UnlockRegion(offset, numberOfBytes, lockType); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } private static Result StatImpl(IntPtr thisPtr, ref StorageStatistics.__Native statisticsPtr, StorageStatisticsFlags flags) { try { ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).GetStatistics(flags).__MarshalTo(ref statisticsPtr); } catch (SharpDXException ex) { return ex.ResultCode; } catch (Exception) { return Result.Fail.Code; } return Result.Ok; } private static Result CloneImpl(IntPtr thisPtr, out IntPtr streamPointer) { streamPointer = IntPtr.Zero; Result result = Result.Ok; try { IStream stream = ((IStream)CppObjectShadow.ToShadow<ComStreamShadow>(thisPtr).Callback).Clone(); streamPointer = ToIntPtr(stream); } catch (SharpDXException ex) { result = ex.ResultCode; } catch (Exception) { result = Result.Fail.Code; } return result; } } private static readonly ComStreamVtbl Vtbl = new ComStreamVtbl(); protected override CppObjectVtbl GetVtbl => Vtbl; public static IntPtr ToIntPtr(IStream stream) { return CppObject.ToCallbackPtr<IStream>(stream); } } internal class ComStringEnumerator : IEnumerator<string>, IEnumerator, IDisposable, IEnumerable<string>, IEnumerable { private readonly IEnumString enumString; private string current; public string Current => current; object IEnumerator.Current => Current; public ComStringEnumerator(IntPtr ptrToIEnumString) { enumString = (IEnumString)Marshal.GetObjectForIUnknown(ptrToIEnumString); } public void Dispose() { } public unsafe bool MoveNext() { string[] array = new string[1]; int num = 0; bool flag = enumString.Next(1, array, new IntPtr(&num)) == Result.Ok.Code; current = (flag ? array[0] : null); return flag; } public void Reset() { enumString.Reset(); } public IEnumerator<string> GetEnumerator() { return this; } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } public class ErrorCodeHelper { public static Result ToResult(ErrorCode errorCode) { return ToResult((int)errorCode); } public static Result ToResult(int errorCode) { return new Result((errorCode <= 0) ? ((uint)errorCode) : (((uint)errorCode & 0xFFFFu) | 0x80070000u)); } } [Shadow(typeof(ComStreamShadow))] [Guid("0000000c-0000-0000-C000-000000000046")] public interface IStream : IStreamBase, IUnknown, ICallbackable, IDisposable { long Seek(long offset, SeekOrigin origin); void SetSize(long newSize); long CopyTo(IStream streamDest, long numberOfBytesToCopy, out long bytesWritten); void Commit(CommitFlags commitFlags); void Revert(); void LockRegion(long offset, long numberOfBytesToLock, LockType dwLockType); void UnlockRegion(long offset, long numberOfBytesToLock, LockType dwLockType); StorageStatistics GetStatistics(StorageStatisticsFlags storageStatisticsFlags); IStream Clone(); } [Shadow(typeof(ComStreamBaseShadow))] [Guid("0c733a30-2a1c-11ce-ade5-00aa0044773d")] public interface IStreamBase : IUnknown, ICallbackable, IDisposable { int Read(IntPtr buffer, int numberOfBytesToRead); int Write(IntPtr buffer, int numberOfBytesToRead); } [CompilerGenerated] internal class NamespaceDoc { } public struct NativeMessage { public IntPtr handle; public uint msg; public IntPtr wParam; public IntPtr lParam; public uint time; public RawPoint p; } public class PropertyBag : ComObject { [StructLayout(LayoutKind.Sequential, Pack = 1)] private struct PROPBAG2 : IDisposable { internal uint type; internal ushort vt; internal ushort cfType; internal IntPtr dwHint; internal IntPtr pstrName; internal Guid clsid; public string Name { get { return Marshal.PtrToStringUni(pstrName); } set { pstrName = Marshal.StringToCoTaskMemUni(value); } } public void Dispose() { if (pstrName != IntPtr.Zero) { Marshal.FreeCoTaskMem(pstrName); pstrName = IntPtr.Zero; } } } [ComImport] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("22F55882-280B-11D0-A8A9-00A0C90C2004")] private interface IPropertyBag2 { [PreserveSig] Result Read([In] int cProperties, [In] ref PROPBAG2 pPropBag, IntPtr pErrLog, out object pvarValue, out Result phrError); [PreserveSig] Result Write([In] int cProperties, [In] ref PROPBAG2 pPropBag, ref object value); [PreserveSig] Result CountProperties(out int pcProperties); [PreserveSig] Result GetPropertyInfo([In] int iProperty, [In] int cProperties, out PROPBAG2 pPropBag, out int pcProperties); [PreserveSig] Result LoadObject([In][MarshalAs(UnmanagedType.LPWStr)] string pstrName, [In] uint dwHint, [In][MarshalAs(UnmanagedType.IUnknown)] object pUnkObject, IntPtr pErrLog); } private IPropertyBag2 nativePropertyBag; public int Count { get { CheckIfInitialized(); nativePropertyBag.CountProperties(out var pcProperties); return pcProperties; } } public string[] Keys { get { CheckIfInitialized(); List<string> list = new List<string>(); for (int i = 0; i < Count; i++) { nativePropertyBag.GetPropertyInfo(i, 1, out var pPropBag, out var _); list.Add(pPropBag.Name); } return list.ToArray(); } } public PropertyBag(IntPtr propertyBagPointer) : base(propertyBagPointer) { } protected override void NativePointerUpdated(IntPtr oldNativePointer) { base.NativePointerUpdated(oldNativePointer); if (base.NativePointer != IntPtr.Zero) { nativePropertyBag = (IPropertyBag2)Marshal.GetObjectForIUnknown(base.NativePointer); } else { nativePropertyBag = null; } } private void CheckIfInitialized() { if (nativePropertyBag == null) { throw new InvalidOperationException("This instance is not bound to an unmanaged IPropertyBag2"); } } public object Get(string name) { CheckIfInitialized(); PROPBAG2 pROPBAG = default(PROPBAG2); pROPBAG.Name = name; PROPBAG2 pPropBag = pROPBAG; if (nativePropertyBag.Read(1, ref pPropBag, IntPtr.Zero, out var pvarValue, out var phrError).Failure || phrError.Failure) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Property with name [{0}] is not valid for this instance", name)); } pPropBag.Dispose(); return pvarValue; } public T1 Get<T1, T2>(PropertyBagKey<T1, T2> propertyKey) { return (T1)Convert.ChangeType(Get(propertyKey.Name), typeof(T1)); } public void Set(string name, object value) { CheckIfInitialized(); object obj = Get(name); value = Convert.ChangeType(value, (obj == null) ? value.GetType() : obj.GetType()); PROPBAG2 pROPBAG = default(PROPBAG2); pROPBAG.Name = name; PROPBAG2 pPropBag = pROPBAG; IPropertyBag2 propertyBag = nativePropertyBag; object value2 = value; propertyBag.Write(1, ref pPropBag, ref value2).CheckError(); pPropBag.Dispose(); } public void Set<T1, T2>(PropertyBagKey<T1, T2> propertyKey, T1 value) { Set(propertyKey.Name, value); } } public class PropertyBagKey<T1, T2> { public string Name { get; private set; } public PropertyBagKey(string name) { Name = name; } } public struct SecurityAttributes { public int Length; public IntPtr Descriptor; private int inheritHandle; public bool InheritHandle { get { return inheritHandle != 0; } set { inheritHandle = (value ? 1 : 0); } } } public struct Variant { [StructLayout(LayoutKind.Explicit)] private struct VariantValue { public struct CurrencyLowHigh { public uint LowValue; public int HighValue; } [StructLayout(LayoutKind.Explicit)] public struct CurrencyValue { [FieldOffset(0)] public CurrencyLowHigh LowHigh; [FieldOffset(0)] public long longValue; } public struct RecordValue
BepInEx/plugins/DearImGuiInjection/System.Numerics.Vectors.dll
Decompiled 7 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Diagnostics; using System.Globalization; using System.Numerics.Hashing; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using FxResources.System.Numerics.Vectors; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyTitle("System.Numerics.Vectors")] [assembly: AssemblyDescription("System.Numerics.Vectors")] [assembly: AssemblyDefaultAlias("System.Numerics.Vectors")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.25519.03")] [assembly: AssemblyInformationalVersion("4.6.25519.03 built by: dlab-DDVSOWINAGE013. Commit Hash: 8321c729934c0f8be754953439b88e6e1c120c24")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.1.3.0")] [module: UnverifiableCode] namespace FxResources.System.Numerics.Vectors { internal static class SR { } } namespace System { internal static class MathF { public const float PI = 3.1415927f; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Abs(float x) { return Math.Abs(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Acos(float x) { return (float)Math.Acos(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Cos(float x) { return (float)Math.Cos(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float IEEERemainder(float x, float y) { return (float)Math.IEEERemainder(x, y); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Sin(float x) { return (float)Math.Sin(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Sqrt(float x) { return (float)Math.Sqrt(x); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Tan(float x) { return (float)Math.Tan(x); } } internal static class SR { private static ResourceManager s_resourceManager; private const string s_resourcesName = "FxResources.System.Numerics.Vectors.SR"; private static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(ResourceType)); internal static string Arg_ArgumentOutOfRangeException => GetResourceString("Arg_ArgumentOutOfRangeException", null); internal static string Arg_ElementsInSourceIsGreaterThanDestination => GetResourceString("Arg_ElementsInSourceIsGreaterThanDestination", null); internal static string Arg_NullArgumentNullRef => GetResourceString("Arg_NullArgumentNullRef", null); internal static string Arg_TypeNotSupported => GetResourceString("Arg_TypeNotSupported", null); internal static Type ResourceType => typeof(SR); [MethodImpl(MethodImplOptions.NoInlining)] private static bool UsingResourceKeys() { return false; } internal static string GetResourceString(string resourceKey, string defaultString) { string text = null; try { text = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } if (defaultString != null && resourceKey.Equals(text, StringComparison.Ordinal)) { return defaultString; } return text; } internal static string Format(string resourceFormat, params object[] args) { if (args != null) { if (UsingResourceKeys()) { return resourceFormat + string.Join(", ", args); } return string.Format(resourceFormat, args); } return resourceFormat; } internal static string Format(string resourceFormat, object p1) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1); } return string.Format(resourceFormat, p1); } internal static string Format(string resourceFormat, object p1, object p2) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2); } return string.Format(resourceFormat, p1, p2); } internal static string Format(string resourceFormat, object p1, object p2, object p3) { if (UsingResourceKeys()) { return string.Join(", ", resourceFormat, p1, p2, p3); } return string.Format(resourceFormat, p1, p2, p3); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.All)] internal class __BlockReflectionAttribute : Attribute { } } namespace System.Numerics { internal class ConstantHelper { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte GetByteWithAllBitsSet() { byte result = 0; result = byte.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static sbyte GetSByteWithAllBitsSet() { sbyte result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ushort GetUInt16WithAllBitsSet() { ushort result = 0; result = ushort.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static short GetInt16WithAllBitsSet() { short result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint GetUInt32WithAllBitsSet() { uint result = 0u; result = uint.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetInt32WithAllBitsSet() { int result = 0; result = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong GetUInt64WithAllBitsSet() { ulong result = 0uL; result = ulong.MaxValue; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long GetInt64WithAllBitsSet() { long result = 0L; result = -1L; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static float GetSingleWithAllBitsSet() { float result = 0f; *(int*)(&result) = -1; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static double GetDoubleWithAllBitsSet() { double result = 0.0; *(long*)(&result) = -1L; return result; } } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property)] internal class JitIntrinsicAttribute : Attribute { } [StructLayout(LayoutKind.Explicit)] internal struct Register { [FieldOffset(0)] internal byte byte_0; [FieldOffset(1)] internal byte byte_1; [FieldOffset(2)] internal byte byte_2; [FieldOffset(3)] internal byte byte_3; [FieldOffset(4)] internal byte byte_4; [FieldOffset(5)] internal byte byte_5; [FieldOffset(6)] internal byte byte_6; [FieldOffset(7)] internal byte byte_7; [FieldOffset(8)] internal byte byte_8; [FieldOffset(9)] internal byte byte_9; [FieldOffset(10)] internal byte byte_10; [FieldOffset(11)] internal byte byte_11; [FieldOffset(12)] internal byte byte_12; [FieldOffset(13)] internal byte byte_13; [FieldOffset(14)] internal byte byte_14; [FieldOffset(15)] internal byte byte_15; [FieldOffset(0)] internal sbyte sbyte_0; [FieldOffset(1)] internal sbyte sbyte_1; [FieldOffset(2)] internal sbyte sbyte_2; [FieldOffset(3)] internal sbyte sbyte_3; [FieldOffset(4)] internal sbyte sbyte_4; [FieldOffset(5)] internal sbyte sbyte_5; [FieldOffset(6)] internal sbyte sbyte_6; [FieldOffset(7)] internal sbyte sbyte_7; [FieldOffset(8)] internal sbyte sbyte_8; [FieldOffset(9)] internal sbyte sbyte_9; [FieldOffset(10)] internal sbyte sbyte_10; [FieldOffset(11)] internal sbyte sbyte_11; [FieldOffset(12)] internal sbyte sbyte_12; [FieldOffset(13)] internal sbyte sbyte_13; [FieldOffset(14)] internal sbyte sbyte_14; [FieldOffset(15)] internal sbyte sbyte_15; [FieldOffset(0)] internal ushort uint16_0; [FieldOffset(2)] internal ushort uint16_1; [FieldOffset(4)] internal ushort uint16_2; [FieldOffset(6)] internal ushort uint16_3; [FieldOffset(8)] internal ushort uint16_4; [FieldOffset(10)] internal ushort uint16_5; [FieldOffset(12)] internal ushort uint16_6; [FieldOffset(14)] internal ushort uint16_7; [FieldOffset(0)] internal short int16_0; [FieldOffset(2)] internal short int16_1; [FieldOffset(4)] internal short int16_2; [FieldOffset(6)] internal short int16_3; [FieldOffset(8)] internal short int16_4; [FieldOffset(10)] internal short int16_5; [FieldOffset(12)] internal short int16_6; [FieldOffset(14)] internal short int16_7; [FieldOffset(0)] internal uint uint32_0; [FieldOffset(4)] internal uint uint32_1; [FieldOffset(8)] internal uint uint32_2; [FieldOffset(12)] internal uint uint32_3; [FieldOffset(0)] internal int int32_0; [FieldOffset(4)] internal int int32_1; [FieldOffset(8)] internal int int32_2; [FieldOffset(12)] internal int int32_3; [FieldOffset(0)] internal ulong uint64_0; [FieldOffset(8)] internal ulong uint64_1; [FieldOffset(0)] internal long int64_0; [FieldOffset(8)] internal long int64_1; [FieldOffset(0)] internal float single_0; [FieldOffset(4)] internal float single_1; [FieldOffset(8)] internal float single_2; [FieldOffset(12)] internal float single_3; [FieldOffset(0)] internal double double_0; [FieldOffset(8)] internal double double_1; } public struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct { private struct VectorSizeHelper { internal Vector<T> _placeholder; internal byte _byte; } private System.Numerics.Register register; private static readonly int s_count = InitializeCount(); private static readonly Vector<T> zero = new Vector<T>(GetZeroValue()); private static readonly Vector<T> one = new Vector<T>(GetOneValue()); private static readonly Vector<T> allOnes = new Vector<T>(GetAllBitsSetValue()); [JitIntrinsic] public static int Count => s_count; [JitIntrinsic] public static Vector<T> Zero => zero; [JitIntrinsic] public static Vector<T> One => one; internal static Vector<T> AllOnes => allOnes; [JitIntrinsic] public unsafe T this[int index] { get { if (index >= Count || index < 0) { throw new IndexOutOfRangeException(System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, index)); } if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { return (T)(object)ptr[index]; } } if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { return (T)(object)ptr2[index]; } } if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { return (T)(object)ptr3[index]; } } if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { return (T)(object)ptr4[index]; } } if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { return (T)(object)ptr5[index]; } } if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { return (T)(object)ptr6[index]; } } if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { return (T)(object)ptr7[index]; } } if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { return (T)(object)ptr8[index]; } } if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { return (T)(object)ptr9[index]; } } if (typeof(T) == typeof(double)) { fixed (double* ptr10 = ®ister.double_0) { return (T)(object)ptr10[index]; } } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } } private unsafe static int InitializeCount() { VectorSizeHelper vectorSizeHelper = default(VectorSizeHelper); byte* ptr = &vectorSizeHelper._placeholder.register.byte_0; byte* ptr2 = &vectorSizeHelper._byte; int num = (int)(ptr2 - ptr); int num2 = -1; if (typeof(T) == typeof(byte)) { num2 = 1; } else if (typeof(T) == typeof(sbyte)) { num2 = 1; } else if (typeof(T) == typeof(ushort)) { num2 = 2; } else if (typeof(T) == typeof(short)) { num2 = 2; } else if (typeof(T) == typeof(uint)) { num2 = 4; } else if (typeof(T) == typeof(int)) { num2 = 4; } else if (typeof(T) == typeof(ulong)) { num2 = 8; } else if (typeof(T) == typeof(long)) { num2 = 8; } else if (typeof(T) == typeof(float)) { num2 = 4; } else { if (!(typeof(T) == typeof(double))) { throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } num2 = 8; } return num / num2; } [JitIntrinsic] public unsafe Vector(T value) { this = default(Vector<T>); if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)value; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)value; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)value; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)value; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)value; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)value; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)value; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)value; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)value; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)value; } } } } else if (typeof(T) == typeof(byte)) { register.byte_0 = (byte)(object)value; register.byte_1 = (byte)(object)value; register.byte_2 = (byte)(object)value; register.byte_3 = (byte)(object)value; register.byte_4 = (byte)(object)value; register.byte_5 = (byte)(object)value; register.byte_6 = (byte)(object)value; register.byte_7 = (byte)(object)value; register.byte_8 = (byte)(object)value; register.byte_9 = (byte)(object)value; register.byte_10 = (byte)(object)value; register.byte_11 = (byte)(object)value; register.byte_12 = (byte)(object)value; register.byte_13 = (byte)(object)value; register.byte_14 = (byte)(object)value; register.byte_15 = (byte)(object)value; } else if (typeof(T) == typeof(sbyte)) { register.sbyte_0 = (sbyte)(object)value; register.sbyte_1 = (sbyte)(object)value; register.sbyte_2 = (sbyte)(object)value; register.sbyte_3 = (sbyte)(object)value; register.sbyte_4 = (sbyte)(object)value; register.sbyte_5 = (sbyte)(object)value; register.sbyte_6 = (sbyte)(object)value; register.sbyte_7 = (sbyte)(object)value; register.sbyte_8 = (sbyte)(object)value; register.sbyte_9 = (sbyte)(object)value; register.sbyte_10 = (sbyte)(object)value; register.sbyte_11 = (sbyte)(object)value; register.sbyte_12 = (sbyte)(object)value; register.sbyte_13 = (sbyte)(object)value; register.sbyte_14 = (sbyte)(object)value; register.sbyte_15 = (sbyte)(object)value; } else if (typeof(T) == typeof(ushort)) { register.uint16_0 = (ushort)(object)value; register.uint16_1 = (ushort)(object)value; register.uint16_2 = (ushort)(object)value; register.uint16_3 = (ushort)(object)value; register.uint16_4 = (ushort)(object)value; register.uint16_5 = (ushort)(object)value; register.uint16_6 = (ushort)(object)value; register.uint16_7 = (ushort)(object)value; } else if (typeof(T) == typeof(short)) { register.int16_0 = (short)(object)value; register.int16_1 = (short)(object)value; register.int16_2 = (short)(object)value; register.int16_3 = (short)(object)value; register.int16_4 = (short)(object)value; register.int16_5 = (short)(object)value; register.int16_6 = (short)(object)value; register.int16_7 = (short)(object)value; } else if (typeof(T) == typeof(uint)) { register.uint32_0 = (uint)(object)value; register.uint32_1 = (uint)(object)value; register.uint32_2 = (uint)(object)value; register.uint32_3 = (uint)(object)value; } else if (typeof(T) == typeof(int)) { register.int32_0 = (int)(object)value; register.int32_1 = (int)(object)value; register.int32_2 = (int)(object)value; register.int32_3 = (int)(object)value; } else if (typeof(T) == typeof(ulong)) { register.uint64_0 = (ulong)(object)value; register.uint64_1 = (ulong)(object)value; } else if (typeof(T) == typeof(long)) { register.int64_0 = (long)(object)value; register.int64_1 = (long)(object)value; } else if (typeof(T) == typeof(float)) { register.single_0 = (float)(object)value; register.single_1 = (float)(object)value; register.single_2 = (float)(object)value; register.single_3 = (float)(object)value; } else if (typeof(T) == typeof(double)) { register.double_0 = (double)(object)value; register.double_1 = (double)(object)value; } } [JitIntrinsic] public Vector(T[] values) : this(values, 0) { } public unsafe Vector(T[] values, int index) { this = default(Vector<T>); if (values == null) { throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef); } if (index < 0 || values.Length - index < Count) { throw new IndexOutOfRangeException(); } if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)values[i + index]; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)values[j + index]; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)values[k + index]; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)values[l + index]; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)values[m + index]; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)values[n + index]; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)values[num + index]; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)values[num2 + index]; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)values[num3 + index]; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)values[num4 + index]; } } } } else if (typeof(T) == typeof(byte)) { fixed (byte* ptr11 = ®ister.byte_0) { *ptr11 = (byte)(object)values[index]; ptr11[1] = (byte)(object)values[1 + index]; ptr11[2] = (byte)(object)values[2 + index]; ptr11[3] = (byte)(object)values[3 + index]; ptr11[4] = (byte)(object)values[4 + index]; ptr11[5] = (byte)(object)values[5 + index]; ptr11[6] = (byte)(object)values[6 + index]; ptr11[7] = (byte)(object)values[7 + index]; ptr11[8] = (byte)(object)values[8 + index]; ptr11[9] = (byte)(object)values[9 + index]; ptr11[10] = (byte)(object)values[10 + index]; ptr11[11] = (byte)(object)values[11 + index]; ptr11[12] = (byte)(object)values[12 + index]; ptr11[13] = (byte)(object)values[13 + index]; ptr11[14] = (byte)(object)values[14 + index]; ptr11[15] = (byte)(object)values[15 + index]; } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr12 = ®ister.sbyte_0) { *ptr12 = (sbyte)(object)values[index]; ptr12[1] = (sbyte)(object)values[1 + index]; ptr12[2] = (sbyte)(object)values[2 + index]; ptr12[3] = (sbyte)(object)values[3 + index]; ptr12[4] = (sbyte)(object)values[4 + index]; ptr12[5] = (sbyte)(object)values[5 + index]; ptr12[6] = (sbyte)(object)values[6 + index]; ptr12[7] = (sbyte)(object)values[7 + index]; ptr12[8] = (sbyte)(object)values[8 + index]; ptr12[9] = (sbyte)(object)values[9 + index]; ptr12[10] = (sbyte)(object)values[10 + index]; ptr12[11] = (sbyte)(object)values[11 + index]; ptr12[12] = (sbyte)(object)values[12 + index]; ptr12[13] = (sbyte)(object)values[13 + index]; ptr12[14] = (sbyte)(object)values[14 + index]; ptr12[15] = (sbyte)(object)values[15 + index]; } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr13 = ®ister.uint16_0) { *ptr13 = (ushort)(object)values[index]; ptr13[1] = (ushort)(object)values[1 + index]; ptr13[2] = (ushort)(object)values[2 + index]; ptr13[3] = (ushort)(object)values[3 + index]; ptr13[4] = (ushort)(object)values[4 + index]; ptr13[5] = (ushort)(object)values[5 + index]; ptr13[6] = (ushort)(object)values[6 + index]; ptr13[7] = (ushort)(object)values[7 + index]; } } else if (typeof(T) == typeof(short)) { fixed (short* ptr14 = ®ister.int16_0) { *ptr14 = (short)(object)values[index]; ptr14[1] = (short)(object)values[1 + index]; ptr14[2] = (short)(object)values[2 + index]; ptr14[3] = (short)(object)values[3 + index]; ptr14[4] = (short)(object)values[4 + index]; ptr14[5] = (short)(object)values[5 + index]; ptr14[6] = (short)(object)values[6 + index]; ptr14[7] = (short)(object)values[7 + index]; } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr15 = ®ister.uint32_0) { *ptr15 = (uint)(object)values[index]; ptr15[1] = (uint)(object)values[1 + index]; ptr15[2] = (uint)(object)values[2 + index]; ptr15[3] = (uint)(object)values[3 + index]; } } else if (typeof(T) == typeof(int)) { fixed (int* ptr16 = ®ister.int32_0) { *ptr16 = (int)(object)values[index]; ptr16[1] = (int)(object)values[1 + index]; ptr16[2] = (int)(object)values[2 + index]; ptr16[3] = (int)(object)values[3 + index]; } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr17 = ®ister.uint64_0) { *ptr17 = (ulong)(object)values[index]; ptr17[1] = (ulong)(object)values[1 + index]; } } else if (typeof(T) == typeof(long)) { fixed (long* ptr18 = ®ister.int64_0) { *ptr18 = (long)(object)values[index]; ptr18[1] = (long)(object)values[1 + index]; } } else if (typeof(T) == typeof(float)) { fixed (float* ptr19 = ®ister.single_0) { *ptr19 = (float)(object)values[index]; ptr19[1] = (float)(object)values[1 + index]; ptr19[2] = (float)(object)values[2 + index]; ptr19[3] = (float)(object)values[3 + index]; } } else if (typeof(T) == typeof(double)) { fixed (double* ptr20 = ®ister.double_0) { *ptr20 = (double)(object)values[index]; ptr20[1] = (double)(object)values[1 + index]; } } } internal unsafe Vector(void* dataPointer) : this(dataPointer, 0) { } internal unsafe Vector(void* dataPointer, int offset) { this = default(Vector<T>); if (typeof(T) == typeof(byte)) { byte* ptr = (byte*)dataPointer; ptr += offset; fixed (byte* ptr2 = ®ister.byte_0) { for (int i = 0; i < Count; i++) { ptr2[i] = ptr[i]; } } return; } if (typeof(T) == typeof(sbyte)) { sbyte* ptr3 = (sbyte*)dataPointer; ptr3 += offset; fixed (sbyte* ptr4 = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { ptr4[j] = ptr3[j]; } } return; } if (typeof(T) == typeof(ushort)) { ushort* ptr5 = (ushort*)dataPointer; ptr5 += offset; fixed (ushort* ptr6 = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { ptr6[k] = ptr5[k]; } } return; } if (typeof(T) == typeof(short)) { short* ptr7 = (short*)dataPointer; ptr7 += offset; fixed (short* ptr8 = ®ister.int16_0) { for (int l = 0; l < Count; l++) { ptr8[l] = ptr7[l]; } } return; } if (typeof(T) == typeof(uint)) { uint* ptr9 = (uint*)dataPointer; ptr9 += offset; fixed (uint* ptr10 = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { ptr10[m] = ptr9[m]; } } return; } if (typeof(T) == typeof(int)) { int* ptr11 = (int*)dataPointer; ptr11 += offset; fixed (int* ptr12 = ®ister.int32_0) { for (int n = 0; n < Count; n++) { ptr12[n] = ptr11[n]; } } return; } if (typeof(T) == typeof(ulong)) { ulong* ptr13 = (ulong*)dataPointer; ptr13 += offset; fixed (ulong* ptr14 = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { ptr14[num] = ptr13[num]; } } return; } if (typeof(T) == typeof(long)) { long* ptr15 = (long*)dataPointer; ptr15 += offset; fixed (long* ptr16 = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { ptr16[num2] = ptr15[num2]; } } return; } if (typeof(T) == typeof(float)) { float* ptr17 = (float*)dataPointer; ptr17 += offset; fixed (float* ptr18 = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { ptr18[num3] = ptr17[num3]; } } return; } if (typeof(T) == typeof(double)) { double* ptr19 = (double*)dataPointer; ptr19 += offset; fixed (double* ptr20 = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { ptr20[num4] = ptr19[num4]; } } return; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } private Vector(ref System.Numerics.Register existingRegister) { register = existingRegister; } [JitIntrinsic] public void CopyTo(T[] destination) { CopyTo(destination, 0); } [JitIntrinsic] public unsafe void CopyTo(T[] destination, int startIndex) { if (destination == null) { throw new NullReferenceException(System.SR.Arg_NullArgumentNullRef); } if (startIndex < 0 || startIndex >= destination.Length) { throw new ArgumentOutOfRangeException("startIndex", System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, startIndex)); } if (destination.Length - startIndex < Count) { throw new ArgumentException(System.SR.Format(System.SR.Arg_ElementsInSourceIsGreaterThanDestination, startIndex)); } if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* ptr = (byte[])(object)destination) { for (int i = 0; i < Count; i++) { ptr[startIndex + i] = (byte)(object)this[i]; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr2 = (sbyte[])(object)destination) { for (int j = 0; j < Count; j++) { ptr2[startIndex + j] = (sbyte)(object)this[j]; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr3 = (ushort[])(object)destination) { for (int k = 0; k < Count; k++) { ptr3[startIndex + k] = (ushort)(object)this[k]; } } } else if (typeof(T) == typeof(short)) { fixed (short* ptr4 = (short[])(object)destination) { for (int l = 0; l < Count; l++) { ptr4[startIndex + l] = (short)(object)this[l]; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr5 = (uint[])(object)destination) { for (int m = 0; m < Count; m++) { ptr5[startIndex + m] = (uint)(object)this[m]; } } } else if (typeof(T) == typeof(int)) { fixed (int* ptr6 = (int[])(object)destination) { for (int n = 0; n < Count; n++) { ptr6[startIndex + n] = (int)(object)this[n]; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr7 = (ulong[])(object)destination) { for (int num = 0; num < Count; num++) { ptr7[startIndex + num] = (ulong)(object)this[num]; } } } else if (typeof(T) == typeof(long)) { fixed (long* ptr8 = (long[])(object)destination) { for (int num2 = 0; num2 < Count; num2++) { ptr8[startIndex + num2] = (long)(object)this[num2]; } } } else if (typeof(T) == typeof(float)) { fixed (float* ptr9 = (float[])(object)destination) { for (int num3 = 0; num3 < Count; num3++) { ptr9[startIndex + num3] = (float)(object)this[num3]; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* ptr10 = (double[])(object)destination) { for (int num4 = 0; num4 < Count; num4++) { ptr10[startIndex + num4] = (double)(object)this[num4]; } } } } else if (typeof(T) == typeof(byte)) { fixed (byte* ptr11 = (byte[])(object)destination) { ptr11[startIndex] = register.byte_0; ptr11[startIndex + 1] = register.byte_1; ptr11[startIndex + 2] = register.byte_2; ptr11[startIndex + 3] = register.byte_3; ptr11[startIndex + 4] = register.byte_4; ptr11[startIndex + 5] = register.byte_5; ptr11[startIndex + 6] = register.byte_6; ptr11[startIndex + 7] = register.byte_7; ptr11[startIndex + 8] = register.byte_8; ptr11[startIndex + 9] = register.byte_9; ptr11[startIndex + 10] = register.byte_10; ptr11[startIndex + 11] = register.byte_11; ptr11[startIndex + 12] = register.byte_12; ptr11[startIndex + 13] = register.byte_13; ptr11[startIndex + 14] = register.byte_14; ptr11[startIndex + 15] = register.byte_15; } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* ptr12 = (sbyte[])(object)destination) { ptr12[startIndex] = register.sbyte_0; ptr12[startIndex + 1] = register.sbyte_1; ptr12[startIndex + 2] = register.sbyte_2; ptr12[startIndex + 3] = register.sbyte_3; ptr12[startIndex + 4] = register.sbyte_4; ptr12[startIndex + 5] = register.sbyte_5; ptr12[startIndex + 6] = register.sbyte_6; ptr12[startIndex + 7] = register.sbyte_7; ptr12[startIndex + 8] = register.sbyte_8; ptr12[startIndex + 9] = register.sbyte_9; ptr12[startIndex + 10] = register.sbyte_10; ptr12[startIndex + 11] = register.sbyte_11; ptr12[startIndex + 12] = register.sbyte_12; ptr12[startIndex + 13] = register.sbyte_13; ptr12[startIndex + 14] = register.sbyte_14; ptr12[startIndex + 15] = register.sbyte_15; } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* ptr13 = (ushort[])(object)destination) { ptr13[startIndex] = register.uint16_0; ptr13[startIndex + 1] = register.uint16_1; ptr13[startIndex + 2] = register.uint16_2; ptr13[startIndex + 3] = register.uint16_3; ptr13[startIndex + 4] = register.uint16_4; ptr13[startIndex + 5] = register.uint16_5; ptr13[startIndex + 6] = register.uint16_6; ptr13[startIndex + 7] = register.uint16_7; } } else if (typeof(T) == typeof(short)) { fixed (short* ptr14 = (short[])(object)destination) { ptr14[startIndex] = register.int16_0; ptr14[startIndex + 1] = register.int16_1; ptr14[startIndex + 2] = register.int16_2; ptr14[startIndex + 3] = register.int16_3; ptr14[startIndex + 4] = register.int16_4; ptr14[startIndex + 5] = register.int16_5; ptr14[startIndex + 6] = register.int16_6; ptr14[startIndex + 7] = register.int16_7; } } else if (typeof(T) == typeof(uint)) { fixed (uint* ptr15 = (uint[])(object)destination) { ptr15[startIndex] = register.uint32_0; ptr15[startIndex + 1] = register.uint32_1; ptr15[startIndex + 2] = register.uint32_2; ptr15[startIndex + 3] = register.uint32_3; } } else if (typeof(T) == typeof(int)) { fixed (int* ptr16 = (int[])(object)destination) { ptr16[startIndex] = register.int32_0; ptr16[startIndex + 1] = register.int32_1; ptr16[startIndex + 2] = register.int32_2; ptr16[startIndex + 3] = register.int32_3; } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* ptr17 = (ulong[])(object)destination) { ptr17[startIndex] = register.uint64_0; ptr17[startIndex + 1] = register.uint64_1; } } else if (typeof(T) == typeof(long)) { fixed (long* ptr18 = (long[])(object)destination) { ptr18[startIndex] = register.int64_0; ptr18[startIndex + 1] = register.int64_1; } } else if (typeof(T) == typeof(float)) { fixed (float* ptr19 = (float[])(object)destination) { ptr19[startIndex] = register.single_0; ptr19[startIndex + 1] = register.single_1; ptr19[startIndex + 2] = register.single_2; ptr19[startIndex + 3] = register.single_3; } } else if (typeof(T) == typeof(double)) { fixed (double* ptr20 = (double[])(object)destination) { ptr20[startIndex] = register.double_0; ptr20[startIndex + 1] = register.double_1; } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override bool Equals(object obj) { if (!(obj is Vector<T>)) { return false; } return Equals((Vector<T>)obj); } [JitIntrinsic] public bool Equals(Vector<T> other) { if (Vector.IsHardwareAccelerated) { for (int i = 0; i < Count; i++) { if (!ScalarEquals(this[i], other[i])) { return false; } } return true; } if (typeof(T) == typeof(byte)) { if (register.byte_0 == other.register.byte_0 && register.byte_1 == other.register.byte_1 && register.byte_2 == other.register.byte_2 && register.byte_3 == other.register.byte_3 && register.byte_4 == other.register.byte_4 && register.byte_5 == other.register.byte_5 && register.byte_6 == other.register.byte_6 && register.byte_7 == other.register.byte_7 && register.byte_8 == other.register.byte_8 && register.byte_9 == other.register.byte_9 && register.byte_10 == other.register.byte_10 && register.byte_11 == other.register.byte_11 && register.byte_12 == other.register.byte_12 && register.byte_13 == other.register.byte_13 && register.byte_14 == other.register.byte_14) { return register.byte_15 == other.register.byte_15; } return false; } if (typeof(T) == typeof(sbyte)) { if (register.sbyte_0 == other.register.sbyte_0 && register.sbyte_1 == other.register.sbyte_1 && register.sbyte_2 == other.register.sbyte_2 && register.sbyte_3 == other.register.sbyte_3 && register.sbyte_4 == other.register.sbyte_4 && register.sbyte_5 == other.register.sbyte_5 && register.sbyte_6 == other.register.sbyte_6 && register.sbyte_7 == other.register.sbyte_7 && register.sbyte_8 == other.register.sbyte_8 && register.sbyte_9 == other.register.sbyte_9 && register.sbyte_10 == other.register.sbyte_10 && register.sbyte_11 == other.register.sbyte_11 && register.sbyte_12 == other.register.sbyte_12 && register.sbyte_13 == other.register.sbyte_13 && register.sbyte_14 == other.register.sbyte_14) { return register.sbyte_15 == other.register.sbyte_15; } return false; } if (typeof(T) == typeof(ushort)) { if (register.uint16_0 == other.register.uint16_0 && register.uint16_1 == other.register.uint16_1 && register.uint16_2 == other.register.uint16_2 && register.uint16_3 == other.register.uint16_3 && register.uint16_4 == other.register.uint16_4 && register.uint16_5 == other.register.uint16_5 && register.uint16_6 == other.register.uint16_6) { return register.uint16_7 == other.register.uint16_7; } return false; } if (typeof(T) == typeof(short)) { if (register.int16_0 == other.register.int16_0 && register.int16_1 == other.register.int16_1 && register.int16_2 == other.register.int16_2 && register.int16_3 == other.register.int16_3 && register.int16_4 == other.register.int16_4 && register.int16_5 == other.register.int16_5 && register.int16_6 == other.register.int16_6) { return register.int16_7 == other.register.int16_7; } return false; } if (typeof(T) == typeof(uint)) { if (register.uint32_0 == other.register.uint32_0 && register.uint32_1 == other.register.uint32_1 && register.uint32_2 == other.register.uint32_2) { return register.uint32_3 == other.register.uint32_3; } return false; } if (typeof(T) == typeof(int)) { if (register.int32_0 == other.register.int32_0 && register.int32_1 == other.register.int32_1 && register.int32_2 == other.register.int32_2) { return register.int32_3 == other.register.int32_3; } return false; } if (typeof(T) == typeof(ulong)) { if (register.uint64_0 == other.register.uint64_0) { return register.uint64_1 == other.register.uint64_1; } return false; } if (typeof(T) == typeof(long)) { if (register.int64_0 == other.register.int64_0) { return register.int64_1 == other.register.int64_1; } return false; } if (typeof(T) == typeof(float)) { if (register.single_0 == other.register.single_0 && register.single_1 == other.register.single_1 && register.single_2 == other.register.single_2) { return register.single_3 == other.register.single_3; } return false; } if (typeof(T) == typeof(double)) { if (register.double_0 == other.register.double_0) { return register.double_1 == other.register.double_1; } return false; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } public override int GetHashCode() { int num = 0; if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { for (int i = 0; i < Count; i++) { num = HashHelpers.Combine(num, ((byte)(object)this[i]).GetHashCode()); } return num; } if (typeof(T) == typeof(sbyte)) { for (int j = 0; j < Count; j++) { num = HashHelpers.Combine(num, ((sbyte)(object)this[j]).GetHashCode()); } return num; } if (typeof(T) == typeof(ushort)) { for (int k = 0; k < Count; k++) { num = HashHelpers.Combine(num, ((ushort)(object)this[k]).GetHashCode()); } return num; } if (typeof(T) == typeof(short)) { for (int l = 0; l < Count; l++) { num = HashHelpers.Combine(num, ((short)(object)this[l]).GetHashCode()); } return num; } if (typeof(T) == typeof(uint)) { for (int m = 0; m < Count; m++) { num = HashHelpers.Combine(num, ((uint)(object)this[m]).GetHashCode()); } return num; } if (typeof(T) == typeof(int)) { for (int n = 0; n < Count; n++) { num = HashHelpers.Combine(num, ((int)(object)this[n]).GetHashCode()); } return num; } if (typeof(T) == typeof(ulong)) { for (int num2 = 0; num2 < Count; num2++) { num = HashHelpers.Combine(num, ((ulong)(object)this[num2]).GetHashCode()); } return num; } if (typeof(T) == typeof(long)) { for (int num3 = 0; num3 < Count; num3++) { num = HashHelpers.Combine(num, ((long)(object)this[num3]).GetHashCode()); } return num; } if (typeof(T) == typeof(float)) { for (int num4 = 0; num4 < Count; num4++) { num = HashHelpers.Combine(num, ((float)(object)this[num4]).GetHashCode()); } return num; } if (typeof(T) == typeof(double)) { for (int num5 = 0; num5 < Count; num5++) { num = HashHelpers.Combine(num, ((double)(object)this[num5]).GetHashCode()); } return num; } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } if (typeof(T) == typeof(byte)) { num = HashHelpers.Combine(num, register.byte_0.GetHashCode()); num = HashHelpers.Combine(num, register.byte_1.GetHashCode()); num = HashHelpers.Combine(num, register.byte_2.GetHashCode()); num = HashHelpers.Combine(num, register.byte_3.GetHashCode()); num = HashHelpers.Combine(num, register.byte_4.GetHashCode()); num = HashHelpers.Combine(num, register.byte_5.GetHashCode()); num = HashHelpers.Combine(num, register.byte_6.GetHashCode()); num = HashHelpers.Combine(num, register.byte_7.GetHashCode()); num = HashHelpers.Combine(num, register.byte_8.GetHashCode()); num = HashHelpers.Combine(num, register.byte_9.GetHashCode()); num = HashHelpers.Combine(num, register.byte_10.GetHashCode()); num = HashHelpers.Combine(num, register.byte_11.GetHashCode()); num = HashHelpers.Combine(num, register.byte_12.GetHashCode()); num = HashHelpers.Combine(num, register.byte_13.GetHashCode()); num = HashHelpers.Combine(num, register.byte_14.GetHashCode()); return HashHelpers.Combine(num, register.byte_15.GetHashCode()); } if (typeof(T) == typeof(sbyte)) { num = HashHelpers.Combine(num, register.sbyte_0.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_1.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_2.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_3.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_4.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_5.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_6.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_7.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_8.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_9.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_10.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_11.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_12.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_13.GetHashCode()); num = HashHelpers.Combine(num, register.sbyte_14.GetHashCode()); return HashHelpers.Combine(num, register.sbyte_15.GetHashCode()); } if (typeof(T) == typeof(ushort)) { num = HashHelpers.Combine(num, register.uint16_0.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_1.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_2.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_3.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_4.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_5.GetHashCode()); num = HashHelpers.Combine(num, register.uint16_6.GetHashCode()); return HashHelpers.Combine(num, register.uint16_7.GetHashCode()); } if (typeof(T) == typeof(short)) { num = HashHelpers.Combine(num, register.int16_0.GetHashCode()); num = HashHelpers.Combine(num, register.int16_1.GetHashCode()); num = HashHelpers.Combine(num, register.int16_2.GetHashCode()); num = HashHelpers.Combine(num, register.int16_3.GetHashCode()); num = HashHelpers.Combine(num, register.int16_4.GetHashCode()); num = HashHelpers.Combine(num, register.int16_5.GetHashCode()); num = HashHelpers.Combine(num, register.int16_6.GetHashCode()); return HashHelpers.Combine(num, register.int16_7.GetHashCode()); } if (typeof(T) == typeof(uint)) { num = HashHelpers.Combine(num, register.uint32_0.GetHashCode()); num = HashHelpers.Combine(num, register.uint32_1.GetHashCode()); num = HashHelpers.Combine(num, register.uint32_2.GetHashCode()); return HashHelpers.Combine(num, register.uint32_3.GetHashCode()); } if (typeof(T) == typeof(int)) { num = HashHelpers.Combine(num, register.int32_0.GetHashCode()); num = HashHelpers.Combine(num, register.int32_1.GetHashCode()); num = HashHelpers.Combine(num, register.int32_2.GetHashCode()); return HashHelpers.Combine(num, register.int32_3.GetHashCode()); } if (typeof(T) == typeof(ulong)) { num = HashHelpers.Combine(num, register.uint64_0.GetHashCode()); return HashHelpers.Combine(num, register.uint64_1.GetHashCode()); } if (typeof(T) == typeof(long)) { num = HashHelpers.Combine(num, register.int64_0.GetHashCode()); return HashHelpers.Combine(num, register.int64_1.GetHashCode()); } if (typeof(T) == typeof(float)) { num = HashHelpers.Combine(num, register.single_0.GetHashCode()); num = HashHelpers.Combine(num, register.single_1.GetHashCode()); num = HashHelpers.Combine(num, register.single_2.GetHashCode()); return HashHelpers.Combine(num, register.single_3.GetHashCode()); } if (typeof(T) == typeof(double)) { num = HashHelpers.Combine(num, register.double_0.GetHashCode()); return HashHelpers.Combine(num, register.double_1.GetHashCode()); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } public override string ToString() { return ToString("G", CultureInfo.CurrentCulture); } public string ToString(string format) { return ToString(format, CultureInfo.CurrentCulture); } public string ToString(string format, IFormatProvider formatProvider) { StringBuilder stringBuilder = new StringBuilder(); string numberGroupSeparator = NumberFormatInfo.GetInstance(formatProvider).NumberGroupSeparator; stringBuilder.Append('<'); for (int i = 0; i < Count - 1; i++) { stringBuilder.Append(((IFormattable)(object)this[i]).ToString(format, formatProvider)); stringBuilder.Append(numberGroupSeparator); stringBuilder.Append(' '); } stringBuilder.Append(((IFormattable)(object)this[Count - 1]).ToString(format, formatProvider)); stringBuilder.Append('>'); return stringBuilder.ToString(); } public unsafe static Vector<T>operator +(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarAdd(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarAdd(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarAdd(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarAdd(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarAdd(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarAdd(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarAdd(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarAdd(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarAdd(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarAdd(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 + right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 + right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 + right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 + right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 + right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 + right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 + right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 + right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 + right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 + right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 + right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 + right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 + right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 + right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 + right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 + right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 + right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 + right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 + right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 + right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 + right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 + right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 + right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 + right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 + right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 + right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 + right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 + right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 + right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 + right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 + right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 + right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 + right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 + right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 + right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 + right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 + right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 + right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 + right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 + right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 + right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 + right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 + right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 + right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 + right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 + right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 + right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 + right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 + right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 + right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 + right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 + right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 + right.register.int32_0; result.register.int32_1 = left.register.int32_1 + right.register.int32_1; result.register.int32_2 = left.register.int32_2 + right.register.int32_2; result.register.int32_3 = left.register.int32_3 + right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 + right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 + right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 + right.register.int64_0; result.register.int64_1 = left.register.int64_1 + right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 + right.register.single_0; result.register.single_1 = left.register.single_1 + right.register.single_1; result.register.single_2 = left.register.single_2 + right.register.single_2; result.register.single_3 = left.register.single_3 + right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 + right.register.double_0; result.register.double_1 = left.register.double_1 + right.register.double_1; } return result; } public unsafe static Vector<T>operator -(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarSubtract(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarSubtract(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarSubtract(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarSubtract(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarSubtract(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarSubtract(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarSubtract(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarSubtract(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarSubtract(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarSubtract(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 - right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 - right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 - right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 - right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 - right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 - right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 - right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 - right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 - right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 - right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 - right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 - right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 - right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 - right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 - right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 - right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 - right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 - right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 - right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 - right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 - right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 - right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 - right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 - right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 - right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 - right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 - right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 - right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 - right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 - right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 - right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 - right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 - right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 - right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 - right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 - right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 - right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 - right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 - right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 - right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 - right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 - right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 - right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 - right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 - right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 - right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 - right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 - right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 - right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 - right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 - right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 - right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 - right.register.int32_0; result.register.int32_1 = left.register.int32_1 - right.register.int32_1; result.register.int32_2 = left.register.int32_2 - right.register.int32_2; result.register.int32_3 = left.register.int32_3 - right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 - right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 - right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 - right.register.int64_0; result.register.int64_1 = left.register.int64_1 - right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 - right.register.single_0; result.register.single_1 = left.register.single_1 - right.register.single_1; result.register.single_2 = left.register.single_2 - right.register.single_2; result.register.single_3 = left.register.single_3 - right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 - right.register.double_0; result.register.double_1 = left.register.double_1 - right.register.double_1; } return result; } public unsafe static Vector<T>operator *(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarMultiply(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarMultiply(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarMultiply(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarMultiply(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarMultiply(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarMultiply(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarMultiply(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarMultiply(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarMultiply(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarMultiply(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 * right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 * right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 * right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 * right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 * right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 * right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 * right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 * right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 * right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 * right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 * right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 * right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 * right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 * right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 * right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 * right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 * right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 * right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 * right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 * right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 * right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 * right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 * right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 * right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 * right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 * right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 * right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 * right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 * right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 * right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 * right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 * right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 * right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 * right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 * right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 * right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 * right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 * right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 * right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 * right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 * right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 * right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 * right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 * right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 * right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 * right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 * right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 * right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 * right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 * right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 * right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 * right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 * right.register.int32_0; result.register.int32_1 = left.register.int32_1 * right.register.int32_1; result.register.int32_2 = left.register.int32_2 * right.register.int32_2; result.register.int32_3 = left.register.int32_3 * right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 * right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 * right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 * right.register.int64_0; result.register.int64_1 = left.register.int64_1 * right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 * right.register.single_0; result.register.single_1 = left.register.single_1 * right.register.single_1; result.register.single_2 = left.register.single_2 * right.register.single_2; result.register.single_3 = left.register.single_3 * right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 * right.register.double_0; result.register.double_1 = left.register.double_1 * right.register.double_1; } return result; } public static Vector<T>operator *(Vector<T> value, T factor) { if (Vector.IsHardwareAccelerated) { return new Vector<T>(factor) * value; } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor; result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor; result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor; result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = value.register.int32_0 * (int)(object)factor; result.register.int32_1 = value.register.int32_1 * (int)(object)factor; result.register.int32_2 = value.register.int32_2 * (int)(object)factor; result.register.int32_3 = value.register.int32_3 * (int)(object)factor; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor; result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = value.register.int64_0 * (long)(object)factor; result.register.int64_1 = value.register.int64_1 * (long)(object)factor; } else if (typeof(T) == typeof(float)) { result.register.single_0 = value.register.single_0 * (float)(object)factor; result.register.single_1 = value.register.single_1 * (float)(object)factor; result.register.single_2 = value.register.single_2 * (float)(object)factor; result.register.single_3 = value.register.single_3 * (float)(object)factor; } else if (typeof(T) == typeof(double)) { result.register.double_0 = value.register.double_0 * (double)(object)factor; result.register.double_1 = value.register.double_1 * (double)(object)factor; } return result; } public static Vector<T>operator *(T factor, Vector<T> value) { if (Vector.IsHardwareAccelerated) { return new Vector<T>(factor) * value; } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); result.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); result.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); result.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); result.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); result.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); result.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); result.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); result.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); result.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); result.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); result.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); result.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); result.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); result.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); result.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); result.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); result.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); result.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); result.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); result.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); result.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); result.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); result.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); result.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); result.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); result.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); result.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); result.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); result.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); result.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); result.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); result.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); result.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); result.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); result.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); result.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); result.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); result.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); result.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); result.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); result.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); result.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); result.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); result.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = value.register.uint32_0 * (uint)(object)factor; result.register.uint32_1 = value.register.uint32_1 * (uint)(object)factor; result.register.uint32_2 = value.register.uint32_2 * (uint)(object)factor; result.register.uint32_3 = value.register.uint32_3 * (uint)(object)factor; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = value.register.int32_0 * (int)(object)factor; result.register.int32_1 = value.register.int32_1 * (int)(object)factor; result.register.int32_2 = value.register.int32_2 * (int)(object)factor; result.register.int32_3 = value.register.int32_3 * (int)(object)factor; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = value.register.uint64_0 * (ulong)(object)factor; result.register.uint64_1 = value.register.uint64_1 * (ulong)(object)factor; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = value.register.int64_0 * (long)(object)factor; result.register.int64_1 = value.register.int64_1 * (long)(object)factor; } else if (typeof(T) == typeof(float)) { result.register.single_0 = value.register.single_0 * (float)(object)factor; result.register.single_1 = value.register.single_1 * (float)(object)factor; result.register.single_2 = value.register.single_2 * (float)(object)factor; result.register.single_3 = value.register.single_3 * (float)(object)factor; } else if (typeof(T) == typeof(double)) { result.register.double_0 = value.register.double_0 * (double)(object)factor; result.register.double_1 = value.register.double_1 * (double)(object)factor; } return result; } public unsafe static Vector<T>operator /(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(object)ScalarDivide(left[i], right[i]); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(object)ScalarDivide(left[j], right[j]); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(object)ScalarDivide(left[k], right[k]); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4 = stackalloc short[Count]; for (int l = 0; l < Count; l++) { ptr4[l] = (short)(object)ScalarDivide(left[l], right[l]); } return new Vector<T>(ptr4); } if (typeof(T) == typeof(uint)) { uint* ptr5 = stackalloc uint[Count]; for (int m = 0; m < Count; m++) { ptr5[m] = (uint)(object)ScalarDivide(left[m], right[m]); } return new Vector<T>(ptr5); } if (typeof(T) == typeof(int)) { int* ptr6 = stackalloc int[Count]; for (int n = 0; n < Count; n++) { ptr6[n] = (int)(object)ScalarDivide(left[n], right[n]); } return new Vector<T>(ptr6); } if (typeof(T) == typeof(ulong)) { ulong* ptr7 = stackalloc ulong[Count]; for (int num = 0; num < Count; num++) { ptr7[num] = (ulong)(object)ScalarDivide(left[num], right[num]); } return new Vector<T>(ptr7); } if (typeof(T) == typeof(long)) { long* ptr8 = stackalloc long[Count]; for (int num2 = 0; num2 < Count; num2++) { ptr8[num2] = (long)(object)ScalarDivide(left[num2], right[num2]); } return new Vector<T>(ptr8); } if (typeof(T) == typeof(float)) { float* ptr9 = stackalloc float[Count]; for (int num3 = 0; num3 < Count; num3++) { ptr9[num3] = (float)(object)ScalarDivide(left[num3], right[num3]); } return new Vector<T>(ptr9); } if (typeof(T) == typeof(double)) { double* ptr10 = stackalloc double[Count]; for (int num4 = 0; num4 < Count; num4++) { ptr10[num4] = (double)(object)ScalarDivide(left[num4], right[num4]); } return new Vector<T>(ptr10); } throw new NotSupportedException(System.SR.Arg_TypeNotSupported); } Vector<T> result = default(Vector<T>); if (typeof(T) == typeof(byte)) { result.register.byte_0 = (byte)(left.register.byte_0 / right.register.byte_0); result.register.byte_1 = (byte)(left.register.byte_1 / right.register.byte_1); result.register.byte_2 = (byte)(left.register.byte_2 / right.register.byte_2); result.register.byte_3 = (byte)(left.register.byte_3 / right.register.byte_3); result.register.byte_4 = (byte)(left.register.byte_4 / right.register.byte_4); result.register.byte_5 = (byte)(left.register.byte_5 / right.register.byte_5); result.register.byte_6 = (byte)(left.register.byte_6 / right.register.byte_6); result.register.byte_7 = (byte)(left.register.byte_7 / right.register.byte_7); result.register.byte_8 = (byte)(left.register.byte_8 / right.register.byte_8); result.register.byte_9 = (byte)(left.register.byte_9 / right.register.byte_9); result.register.byte_10 = (byte)(left.register.byte_10 / right.register.byte_10); result.register.byte_11 = (byte)(left.register.byte_11 / right.register.byte_11); result.register.byte_12 = (byte)(left.register.byte_12 / right.register.byte_12); result.register.byte_13 = (byte)(left.register.byte_13 / right.register.byte_13); result.register.byte_14 = (byte)(left.register.byte_14 / right.register.byte_14); result.register.byte_15 = (byte)(left.register.byte_15 / right.register.byte_15); } else if (typeof(T) == typeof(sbyte)) { result.register.sbyte_0 = (sbyte)(left.register.sbyte_0 / right.register.sbyte_0); result.register.sbyte_1 = (sbyte)(left.register.sbyte_1 / right.register.sbyte_1); result.register.sbyte_2 = (sbyte)(left.register.sbyte_2 / right.register.sbyte_2); result.register.sbyte_3 = (sbyte)(left.register.sbyte_3 / right.register.sbyte_3); result.register.sbyte_4 = (sbyte)(left.register.sbyte_4 / right.register.sbyte_4); result.register.sbyte_5 = (sbyte)(left.register.sbyte_5 / right.register.sbyte_5); result.register.sbyte_6 = (sbyte)(left.register.sbyte_6 / right.register.sbyte_6); result.register.sbyte_7 = (sbyte)(left.register.sbyte_7 / right.register.sbyte_7); result.register.sbyte_8 = (sbyte)(left.register.sbyte_8 / right.register.sbyte_8); result.register.sbyte_9 = (sbyte)(left.register.sbyte_9 / right.register.sbyte_9); result.register.sbyte_10 = (sbyte)(left.register.sbyte_10 / right.register.sbyte_10); result.register.sbyte_11 = (sbyte)(left.register.sbyte_11 / right.register.sbyte_11); result.register.sbyte_12 = (sbyte)(left.register.sbyte_12 / right.register.sbyte_12); result.register.sbyte_13 = (sbyte)(left.register.sbyte_13 / right.register.sbyte_13); result.register.sbyte_14 = (sbyte)(left.register.sbyte_14 / right.register.sbyte_14); result.register.sbyte_15 = (sbyte)(left.register.sbyte_15 / right.register.sbyte_15); } else if (typeof(T) == typeof(ushort)) { result.register.uint16_0 = (ushort)(left.register.uint16_0 / right.register.uint16_0); result.register.uint16_1 = (ushort)(left.register.uint16_1 / right.register.uint16_1); result.register.uint16_2 = (ushort)(left.register.uint16_2 / right.register.uint16_2); result.register.uint16_3 = (ushort)(left.register.uint16_3 / right.register.uint16_3); result.register.uint16_4 = (ushort)(left.register.uint16_4 / right.register.uint16_4); result.register.uint16_5 = (ushort)(left.register.uint16_5 / right.register.uint16_5); result.register.uint16_6 = (ushort)(left.register.uint16_6 / right.register.uint16_6); result.register.uint16_7 = (ushort)(left.register.uint16_7 / right.register.uint16_7); } else if (typeof(T) == typeof(short)) { result.register.int16_0 = (short)(left.register.int16_0 / right.register.int16_0); result.register.int16_1 = (short)(left.register.int16_1 / right.register.int16_1); result.register.int16_2 = (short)(left.register.int16_2 / right.register.int16_2); result.register.int16_3 = (short)(left.register.int16_3 / right.register.int16_3); result.register.int16_4 = (short)(left.register.int16_4 / right.register.int16_4); result.register.int16_5 = (short)(left.register.int16_5 / right.register.int16_5); result.register.int16_6 = (short)(left.register.int16_6 / right.register.int16_6); result.register.int16_7 = (short)(left.register.int16_7 / right.register.int16_7); } else if (typeof(T) == typeof(uint)) { result.register.uint32_0 = left.register.uint32_0 / right.register.uint32_0; result.register.uint32_1 = left.register.uint32_1 / right.register.uint32_1; result.register.uint32_2 = left.register.uint32_2 / right.register.uint32_2; result.register.uint32_3 = left.register.uint32_3 / right.register.uint32_3; } else if (typeof(T) == typeof(int)) { result.register.int32_0 = left.register.int32_0 / right.register.int32_0; result.register.int32_1 = left.register.int32_1 / right.register.int32_1; result.register.int32_2 = left.register.int32_2 / right.register.int32_2; result.register.int32_3 = left.register.int32_3 / right.register.int32_3; } else if (typeof(T) == typeof(ulong)) { result.register.uint64_0 = left.register.uint64_0 / right.register.uint64_0; result.register.uint64_1 = left.register.uint64_1 / right.register.uint64_1; } else if (typeof(T) == typeof(long)) { result.register.int64_0 = left.register.int64_0 / right.register.int64_0; result.register.int64_1 = left.register.int64_1 / right.register.int64_1; } else if (typeof(T) == typeof(float)) { result.register.single_0 = left.register.single_0 / right.register.single_0; result.register.single_1 = left.register.single_1 / right.register.single_1; result.register.single_2 = left.register.single_2 / right.register.single_2; result.register.single_3 = left.register.single_3 / right.register.single_3; } else if (typeof(T) == typeof(double)) { result.register.double_0 = left.register.double_0 / right.register.double_0; result.register.double_1 = left.register.double_1 / right.register.double_1; } return result; } public static Vector<T>operator -(Vector<T> value) { return Zero - value; } [JitIntrinsic] public unsafe static Vector<T>operator &(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] & ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 & right.register.int64_0; result.register.int64_1 = left.register.int64_1 & right.register.int64_1; } return result; } [JitIntrinsic] public unsafe static Vector<T>operator |(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] | ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 | right.register.int64_0; result.register.int64_1 = left.register.int64_1 | right.register.int64_1; } return result; } [JitIntrinsic] public unsafe static Vector<T>operator ^(Vector<T> left, Vector<T> right) { Vector<T> result = default(Vector<T>); if (Vector.IsHardwareAccelerated) { long* ptr = &result.register.int64_0; long* ptr2 = &left.register.int64_0; long* ptr3 = &right.register.int64_0; for (int i = 0; i < Vector<long>.Count; i++) { ptr[i] = ptr2[i] ^ ptr3[i]; } } else { result.register.int64_0 = left.register.int64_0 ^ right.register.int64_0; result.register.int64_1 = left.register.int64_1 ^ right.register.int64_1; } return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector<T>operator ~(Vector<T> value) { return allOnes ^ value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(Vector<T> left, Vector<T> right) { return left.Equals(right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Vector<T> left, Vector<T> right) { return !(left == right); } [JitIntrinsic] public static explicit operator Vector<byte>(Vector<T> value) { return new Vector<byte>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<sbyte>(Vector<T> value) { return new Vector<sbyte>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<ushort>(Vector<T> value) { return new Vector<ushort>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<short>(Vector<T> value) { return new Vector<short>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<uint>(Vector<T> value) { return new Vector<uint>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<int>(Vector<T> value) { return new Vector<int>(ref value.register); } [CLSCompliant(false)] [JitIntrinsic] public static explicit operator Vector<ulong>(Vector<T> value) { return new Vector<ulong>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<long>(Vector<T> value) { return new Vector<long>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<float>(Vector<T> value) { return new Vector<float>(ref value.register); } [JitIntrinsic] public static explicit operator Vector<double>(Vector<T> value) { return new Vector<double>(ref value.register); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [JitIntrinsic] internal unsafe static Vector<T> Equals(Vector<T> left, Vector<T> right) { if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { byte* ptr = stackalloc byte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int i = 0; i < Count; i++) { ptr[i] = (byte)(ScalarEquals(left[i], right[i]) ? ConstantHelper.GetByteWithAllBitsSet() : 0); } return new Vector<T>(ptr); } if (typeof(T) == typeof(sbyte)) { sbyte* ptr2 = stackalloc sbyte[(int)checked(unchecked((nuint)(uint)Count) * (nuint)1u)]; for (int j = 0; j < Count; j++) { ptr2[j] = (sbyte)(ScalarEquals(left[j], right[j]) ? ConstantHelper.GetSByteWithAllBitsSet() : 0); } return new Vector<T>(ptr2); } if (typeof(T) == typeof(ushort)) { ushort* ptr3 = stackalloc ushort[Count]; for (int k = 0; k < Count; k++) { ptr3[k] = (ushort)(ScalarEquals(left[k], right[k]) ? ConstantHelper.GetUInt16WithAllBitsSet() : 0); } return new Vector<T>(ptr3); } if (typeof(T) == typeof(short)) { short* ptr4
BepInEx/plugins/DearImGuiInjection/CppInterop.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("CppInterop")] [assembly: AssemblyConfiguration("netstandard2.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+af1e9534c67088d11779ad09d1aab2c19226e34a")] [assembly: AssemblyProduct("CppInterop")] [assembly: AssemblyTitle("CppInterop")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CppInterop { public struct TableEntry { public nuint EntryAddress; public nuint FunctionPointer; } public class VirtualFunctionTable { public List<TableEntry> TableEntries { get; set; } public TableEntry this[int i] { get { return TableEntries[i]; } set { TableEntries[i] = value; } } private VirtualFunctionTable() { } public static VirtualFunctionTable FromObject(nuint objectAddress, nuint numberOfMethods) { return new VirtualFunctionTable { TableEntries = GetObjectVTableAddresses(objectAddress, numberOfMethods) }; } public static VirtualFunctionTable FromAddress(nuint tableAddress, nuint numberOfMethods) { return new VirtualFunctionTable { TableEntries = GetAddresses(tableAddress, numberOfMethods) }; } private unsafe static List<TableEntry> GetObjectVTableAddresses(nuint objectAddress, nuint numberOfMethods) { return GetAddresses(*(nuint*)objectAddress, numberOfMethods); } private unsafe static List<TableEntry> GetAddresses(nuint tablePointer, nuint numberOfMethods) { nuint num = (nuint)sizeof(UIntPtr); List<TableEntry> list = new List<TableEntry>(); for (nuint num2 = 0u; num2 < numberOfMethods; num2++) { nuint num3 = tablePointer + num * num2; UIntPtr functionPointer = *(UIntPtr*)num3; list.Add(new TableEntry { EntryAddress = num3, FunctionPointer = functionPointer }); } return list; } } }
BepInEx/plugins/DearImGuiInjection/System.ComponentModel.dll
Decompiled 7 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: AssemblyTitle("System.ComponentModel")] [assembly: AssemblyDescription("System.ComponentModel")] [assembly: AssemblyDefaultAlias("System.ComponentModel")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyFileVersion("4.6.24705.01")] [assembly: AssemblyInformationalVersion("4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97")] [assembly: CLSCompliant(true)] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyVersion("4.0.2.0")] namespace System { public interface IServiceProvider { object GetService(System.Type serviceType); } } namespace System.ComponentModel { public class CancelEventArgs : EventArgs { [field: CompilerGenerated] public bool Cancel { [CompilerGenerated] get; [CompilerGenerated] set; } public CancelEventArgs() { } public CancelEventArgs(bool cancel) { Cancel = cancel; } } public interface IChangeTracking { bool IsChanged { get; } void AcceptChanges(); } public interface IEditableObject { void BeginEdit(); void EndEdit(); void CancelEdit(); } public interface IRevertibleChangeTracking : IChangeTracking { void RejectChanges(); } }
BepInEx/plugins/DearImGuiInjection/Reloaded.Assembler.dll
Decompiled 7 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Microsoft.CodeAnalysis; using Reloaded.Assembler.Definitions; using Reloaded.Assembler.Kernel32; using Reloaded.Memory.Buffers; using Reloaded.Memory.Buffers.Internal.Structs; using Reloaded.Memory.Sources; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyMetadata("IsTrimmable", "True")] [assembly: AssemblyCompany("Sewer56")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("LGPL V3")] [assembly: AssemblyDescription("Minimal .NET wrapper around the simple, easy to use Flat Assembler written by Tomasz Grysztar. Supports both x64 and x86 development.")] [assembly: AssemblyFileVersion("1.0.14.0")] [assembly: AssemblyInformationalVersion("1.0.14")] [assembly: AssemblyProduct("Reloaded")] [assembly: AssemblyTitle("Reloaded.Assembler")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Reloaded-Project/Reloaded.Assembler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.14.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace Reloaded.Assembler { public class Assembler : IDisposable { private object _lock = new object(); private nuint _textAddress; private int _textSize; private nuint _resultAddress; private int _resultSize; private static readonly MemoryBufferHelper _bufferHelper; private static readonly Memory _processMemory; private readonly FasmDelegates.fasm_Assemble _assembleFunction; private readonly FasmDelegates.fasm_GetVersion _getVersionFunction; static Assembler() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown _processMemory = new Memory(); _bufferHelper = new MemoryBufferHelper(Process.GetCurrentProcess()); } public Assembler(int textSize = 65536, int resultSize = 32768) { AllocateText(textSize, 3); AllocateResult(resultSize, 3); IntPtr hModule = Reloaded.Assembler.Kernel32.Kernel32.LoadLibraryW(GetFasmDLLPath()); IntPtr procAddress = Reloaded.Assembler.Kernel32.Kernel32.GetProcAddress(hModule, "fasm_Assemble"); IntPtr procAddress2 = Reloaded.Assembler.Kernel32.Kernel32.GetProcAddress(hModule, "fasm_GetVersion"); _assembleFunction = Marshal.GetDelegateForFunctionPointer<FasmDelegates.fasm_Assemble>(procAddress); _getVersionFunction = Marshal.GetDelegateForFunctionPointer<FasmDelegates.fasm_GetVersion>(procAddress2); } ~Assembler() { Dispose(); } public void Dispose() { _bufferHelper.Free((UIntPtr)_textAddress); _bufferHelper.Free((UIntPtr)_resultAddress); GC.SuppressFinalize(this); } public Version GetVersion() { int num = _getVersionFunction(); return new Version(num & 0xFF, (num >> 16) & 0xFF); } public byte[] AssembleFile(string filePath) { return Assemble(File.ReadAllLines(filePath), 100); } public byte[] Assemble(IEnumerable<string> mnemonics, ushort passLimit = 100) { string mnemonics2 = string.Join(Environment.NewLine, mnemonics); return Assemble(mnemonics2, 100); } public unsafe byte[] Assemble(string mnemonics, ushort passLimit = 100) { byte[] bytes = Encoding.ASCII.GetBytes(mnemonics + "\0"); if (bytes.Length > _textSize) { throw new FasmWrapperException($"Your supplied array of mnemonics to be assembled is too large ({bytes.Length} > {_textSize} bytes)." + "Consider simplifying your code or creating a new Assembler with greater textSize."); } lock (_lock) { _processMemory.WriteRaw((UIntPtr)_textAddress, bytes); FasmResult num = _assembleFunction((IntPtr)(void*)_textAddress, (IntPtr)(void*)_resultAddress, (IntPtr)_resultSize, passLimit, IntPtr.Zero); FasmState fasmState = default(FasmState); _processMemory.Read<FasmState>((UIntPtr)_resultAddress, ref fasmState); if (num == FasmResult.Ok) { byte[] array = new byte[fasmState.OutputLength]; Marshal.Copy((IntPtr)fasmState.OutputData, array, 0, array.Length); return array; } string[] mnemonics2 = mnemonics.Split(new string[1] { Environment.NewLine }, StringSplitOptions.None); FasmLineHeader lineHeader = fasmState.GetLineHeader(); throw new FasmException(fasmState.ErrorCode, fasmState.Condition, lineHeader.LineNumber, mnemonics2); } } private string GetFasmDLLPath() { if (IntPtr.Size == 4 && File.Exists("FASM.dll")) { return "FASM.dll"; } if (IntPtr.Size == 8 && File.Exists("FASMX64.dll")) { return "FASMX64.dll"; } string executingDLLDirectory = GetExecutingDLLDirectory(); string text = Path.Combine(executingDLLDirectory, "FASM.dll"); string text2 = Path.Combine(executingDLLDirectory, "FASMX64.dll"); if (IntPtr.Size == 4 && File.Exists(text)) { return text; } if (IntPtr.Size == 8 && File.Exists(text2)) { return text2; } throw new FasmWrapperException("Appropriate FASM DLL for X86/64 has not been found in either current or library directory."); } private string GetExecutingDLLDirectory() { return Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)); } private void AllocateText(int textSize, int retryCount) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) BufferAllocationProperties val = _bufferHelper.Allocate(textSize, (UIntPtr)(nuint)1u, (UIntPtr)(nuint)2147483647u, retryCount); _textAddress = val.MemoryAddress; _textSize = val.Size; if (_textAddress == 0) { throw new FasmWrapperException("Failed to allocate text memory for Assembler."); } } private void AllocateResult(int resultSize, int retryCount) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) BufferAllocationProperties val = _bufferHelper.Allocate(resultSize, (UIntPtr)(nuint)1u, (UIntPtr)(nuint)2147483647u, retryCount); _resultAddress = val.MemoryAddress; _resultSize = val.Size; if (_resultAddress == 0) { throw new FasmWrapperException("Failed to allocate result memory for Assembler."); } } } public class FasmDelegates { [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate int fasm_GetVersion(); [SuppressUnmanagedCodeSecurity] [UnmanagedFunctionPointer(CallingConvention.StdCall)] public delegate FasmResult fasm_Assemble(IntPtr lpSource, IntPtr lpMemory, IntPtr nSize, int nPassesLimit, IntPtr hDisplayPipe); } [ExcludeFromCodeCoverage] public class FasmWrapperException : Exception { public FasmWrapperException() { } public FasmWrapperException(string message) : base(message) { } public FasmWrapperException(string message, Exception innerException) : base(message, innerException) { } protected FasmWrapperException(SerializationInfo info, StreamingContext context) : base(info, context) { } } } namespace Reloaded.Assembler.Kernel32 { public class Kernel32 { [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr LoadLibraryW(string lpFileName); [DllImport("kernel32.dll", CharSet = CharSet.Ansi, SetLastError = true)] public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); } } namespace Reloaded.Assembler.Definitions { public enum FasmErrors { FileNotFound = -101, ErrorReadingFile = -102, InvalidFileFormat = -103, InvalidMacroArguments = -104, IncompleteMacro = -105, UnexpectedCharacters = -106, InvalidArgument = -107, IllegalInstruction = -108, InvalidOperand = -109, InvalidOperandSize = -110, OperandSizeNotSpecified = -111, OperandSizesDoNotMatch = -112, InvalidAddressSize = -113, AddressSizesDoNotAgree = -114, DisallowedCombinationOfRegisters = -115, LongImmediateNotEncodable = -116, RelativeJumpOutOfRange = -117, InvalidExpression = -118, InvalidAddress = -119, InvalidValue = -120, ValueOutOfRange = -121, UndefinedSymbol = -122, InvalidUseOfSymbol = -123, NameTooLong = -124, InvalidName = -125, ReservedWordUsedAsSymbol = -126, SymbolAlreadyDefined = -127, MissingEndQuote = -128, MissingEndDirective = -129, UnexpectedInstruction = -130, ExtraCharactersOnLine = -131, SectionNotAlignedEnough = -132, SettingAlreadySpecified = -133, DataAlreadyDefined = -134, TooManyRepeats = -135, SymbolOutOfScope = -136, UserError = -140, AssertionFailed = -141 } public class FasmException : Exception { public FasmErrors ErrorCode { get; private set; } public FasmResult Result { get; private set; } public int Line { get; private set; } public string[] Mnemonics { get; private set; } public FasmException(FasmErrors errorCode, FasmResult condition, int lineNumber, string[] mnemonics) : base($"Failed to assemble FASM Mnemonics: Error name: {errorCode.ToString()}, Line Number: {lineNumber}, Result: {condition.ToString()}") { Result = condition; ErrorCode = errorCode; Line = lineNumber; Mnemonics = mnemonics; } } [StructLayout(LayoutKind.Explicit)] public struct FasmLineHeader { [FieldOffset(0)] public int FilePathPtr; [FieldOffset(4)] public int LineNumber; [FieldOffset(8)] public int FileOffset; [FieldOffset(8)] public int MacroCallingFilePtr; [FieldOffset(12)] public int MacroLinePtr; } public enum FasmResult { Ok = 0, Working = 1, Error = 2, InvalidParameter = -1, OutOfMemory = -2, StackOverflow = -3, SourceNotFound = -4, UnexpectedEndOfSource = -5, CannotGenerateCode = -6, FormatLimitationsExcedded = -7, WriteFailed = -8 } [StructLayout(LayoutKind.Explicit)] public struct FasmState { [FieldOffset(0)] public FasmResult Condition; [FieldOffset(4)] public int OutputLength; [FieldOffset(4)] public FasmErrors ErrorCode; [FieldOffset(8)] public int OutputData; [FieldOffset(8)] public int ErrorLine; public unsafe FasmLineHeader GetLineHeader() { return *(FasmLineHeader*)ErrorLine; } } }