Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of OverlayDearImGui Shared v2.1.2
plugins/OverlayDearImGui.Shared/HexaGen.Runtime.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Juna Meinhold")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2024 Juna Meinhold")] [assembly: AssemblyDescription("The C Runtime for all C Wrappers generated with the HexaGen Code Generator.")] [assembly: AssemblyFileVersion("1.1.0")] [assembly: AssemblyInformationalVersion("1.0.0+0177f66b18c23b983f9e31f5552730800f85fe79")] [assembly: AssemblyProduct("HexaGen.Runtime")] [assembly: AssemblyTitle("HexaGen.Runtime")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/JunaMeinhold/HexaGen")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [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] [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] [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] [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 HexaGen.Runtime { public struct Bool32 : IEquatable<Bool32> { public int Value; public Bool32(int value) { Value = value; } public Bool32(bool value) { Value = (value ? 1 : 0); } public override readonly bool Equals(object? obj) { if (obj is Bool32 other) { return Equals(other); } return false; } public readonly bool Equals(Bool32 other) { return Value == other.Value; } public override readonly int GetHashCode() { return Value; } public static bool operator ==(Bool32 left, Bool32 right) { return left.Equals(right); } public static bool operator !=(Bool32 left, Bool32 right) { return !(left == right); } public static implicit operator bool(Bool32 b) { return b.Value != 0; } public static implicit operator int(Bool32 b) { return b.Value; } public static implicit operator Bool32(int b) { return new Bool32(b); } public static implicit operator Bool32(bool b) { return new Bool32(b); } public override readonly string ToString() { if (Value != 0) { return "true"; } return "false"; } } public struct Bool8 : IEquatable<Bool8> { public byte Value; public Bool8(byte value) { Value = value; } public Bool8(bool value) { Value = (value ? ((byte)1) : ((byte)0)); } public override readonly bool Equals(object? obj) { if (obj is Bool8 other) { return Equals(other); } return false; } public readonly bool Equals(Bool8 other) { return Value == other.Value; } public override readonly int GetHashCode() { return Value; } public static bool operator ==(Bool8 left, Bool8 right) { return left.Equals(right); } public static bool operator !=(Bool8 left, Bool8 right) { return !(left == right); } public static implicit operator bool(Bool8 b) { return b.Value != 0; } public static implicit operator byte(Bool8 b) { return b.Value; } public static implicit operator Bool8(byte b) { return new Bool8(b); } public static implicit operator Bool8(bool b) { return new Bool8(b); } public override readonly string ToString() { if (Value != 0) { return "true"; } return "false"; } } [DebuggerDisplay("{DebuggerDisplay,nq}")] public readonly struct ConstPointer<T> : IEquatable<ConstPointer<T>> where T : unmanaged { public unsafe readonly T* Handle; public unsafe T this[int index] => Handle[index]; private unsafe string DebuggerDisplay { get { IntPtr handle = (nint)Handle; return string.Format("[0x{0}]", handle.ToString("X")); } } public unsafe ConstPointer(T* handle) { Handle = handle; } public unsafe ConstPointer(nint handle) { Handle = (T*)handle; } public unsafe ConstPointer(nuint handle) { Handle = (T*)handle; } public override bool Equals(object? obj) { if (obj is ConstPointer<T> other) { return Equals(other); } return false; } public unsafe bool Equals(ConstPointer<T> other) { return Handle == other.Handle; } public unsafe override int GetHashCode() { IntPtr handle = (nint)Handle; return handle.GetHashCode(); } public static bool operator ==(ConstPointer<T> left, ConstPointer<T> right) { return left.Equals(right); } public static bool operator !=(ConstPointer<T> left, ConstPointer<T> right) { return !(left == right); } public unsafe static bool operator ==(ConstPointer<T> left, nint right) { return left.Handle == (T*)right; } public static bool operator !=(ConstPointer<T> left, nint right) { return !(left == right); } public unsafe static bool operator ==(ConstPointer<T> left, nuint right) { return left.Handle == (T*)right; } public static bool operator !=(ConstPointer<T> left, nuint right) { return !(left == right); } public unsafe static bool operator ==(ConstPointer<T> left, T* right) { return left.Handle == right; } public unsafe static bool operator !=(ConstPointer<T> left, T* right) { return !(left == right); } public unsafe static implicit operator T*(ConstPointer<T> pointer) { return pointer.Handle; } public unsafe static implicit operator ConstPointer<T>(T* pointer) { return new ConstPointer<T>(pointer); } public unsafe static implicit operator nint(ConstPointer<T> pointer) { return (nint)pointer.Handle; } public static implicit operator ConstPointer<T>(nint pointer) { return new ConstPointer<T>(pointer); } public unsafe static implicit operator nuint(ConstPointer<T> pointer) { return (nuint)pointer.Handle; } public static implicit operator ConstPointer<T>(nuint pointer) { return new ConstPointer<T>(pointer); } public unsafe static ConstPointer<T> operator +(ConstPointer<T> pointer, int offset) { return new ConstPointer<T>(pointer.Handle + offset); } public unsafe static ConstPointer<T> operator -(ConstPointer<T> pointer, int offset) { return new ConstPointer<T>(pointer.Handle - offset); } public unsafe static ConstPointer<T> operator ++(ConstPointer<T> pointer) { return new ConstPointer<T>(pointer.Handle + 1); } public unsafe static ConstPointer<T> operator --(ConstPointer<T> pointer) { return new ConstPointer<T>(pointer.Handle - 1); } } public class FunctionTable : IDisposable { private unsafe void** _vtable; private int length; private readonly INativeContext context; public int Length => length; public unsafe void* this[int index] { get { return _vtable[index]; } set { _vtable[index] = value; } } public unsafe FunctionTable(void** vtable, int length) { context = null; _vtable = vtable; this.length = length; } public FunctionTable(nint library, int length) : this(new NativeLibraryContext(library), length) { } public FunctionTable(string libraryPath, int length) : this(new NativeLibraryContext(libraryPath), length) { } public unsafe FunctionTable(INativeContext context, int length) { this.context = context; _vtable = (void**)(void*)Marshal.AllocHGlobal(length * sizeof(void*)); new Span<IntPtr>(_vtable, length).Clear(); this.length = length; } public unsafe void Load(int index, string export) { if (!context.TryGetProcAddress(export, out IntPtr procAddress)) { _vtable[index] = null; } else { _vtable[index] = (void*)procAddress; } } public unsafe void Resize(int newLength) { if (newLength != length) { _vtable = (void**)(void*)Marshal.ReAllocHGlobal((nint)_vtable, (IntPtr)(newLength * sizeof(void*))); length = newLength; } } public unsafe void Free() { if (_vtable != null) { Marshal.FreeHGlobal((nint)_vtable); _vtable = null; } context.Dispose(); } public void Dispose() { GC.SuppressFinalize(this); Free(); } } public abstract class GLExtension : IDisposable { protected FunctionTable funcTable; protected IGLContext context; private readonly int length; public GLExtension(int length) { this.length = length; } public abstract bool IsSupported(IGLContext context); public void Init(IGLContext context) { this.context = context; funcTable = new FunctionTable(context, length); InitTable(funcTable); } protected abstract void InitTable(FunctionTable funcTable); public void Dispose() { funcTable.Dispose(); GC.SuppressFinalize(this); } } public interface IGLContext : INativeContext, IDisposable { nint Handle { get; } bool IsCurrent { get; } void MakeCurrent(); void SwapBuffers(); void SwapInterval(int interval); } public interface INativeContext : IDisposable { nint GetProcAddress(string procName); bool TryGetProcAddress(string procName, out nint procAddress); bool IsExtensionSupported(string extensionName); } public struct Iterator<T> where T : unmanaged { public unsafe T* ptr; public nuint index; public unsafe T* Current => ptr + index; public unsafe Iterator(T* ptr, nuint index = 0u) { this.ptr = ptr; this.index = index; } public void MoveNext() { index++; } public unsafe readonly bool Equals(Iterator<T> other) { if (ptr == other.ptr) { return index == other.index; } return false; } public override readonly bool Equals(object? obj) { if (obj is Iterator<T> other) { return Equals(other); } return false; } public unsafe override readonly int GetHashCode() { return ((IntPtr)ptr).GetHashCode() ^ ((UIntPtr)index).GetHashCode(); } public static bool operator ==(Iterator<T> left, Iterator<T> right) { return left.Equals(right); } public static bool operator !=(Iterator<T> left, Iterator<T> right) { return !(left == right); } } public enum TargetPlatform { Unknown = 0, FreeBSD = 1, Linux = 2, OSX = 4, Windows = 8, Android = 16, IOS = 32, Tizen = 64, ChromeOS = 128, WebAssembly = 256, Solaris = 512, WatchOS = 1024, TVO = 2048, Any = 4095 } public delegate void ResolvePathHandler(string libraryName, out string? pathToLibrary); public delegate void LibraryNameInterceptor(ref string libraryName); public static class LibraryLoader { public delegate string LibraryNameCallback(); public delegate string LibraryExtensionCallback(); public static ResolvePathHandler? ResolvePath; public static LibraryNameInterceptor? InterceptLibraryName; public static OSPlatform FreeBSD { get; } = OSPlatform.Create("FREEBSD"); public static OSPlatform Linux { get; } = OSPlatform.Create("LINUX"); public static OSPlatform OSX { get; } = OSPlatform.Create("OSX"); public static OSPlatform Windows { get; } = OSPlatform.Create("WINDOWS"); public static OSPlatform Android { get; } = OSPlatform.Create("ANDROID"); public static OSPlatform IOS { get; } = OSPlatform.Create("IOS"); public static OSPlatform Tizen { get; } = OSPlatform.Create("TIZEN"); public static OSPlatform ChromeOS { get; } = OSPlatform.Create("CHROMEOS"); public static OSPlatform WebAssembly { get; } = OSPlatform.Create("WEBASSEMBLY"); public static OSPlatform Solaris { get; } = OSPlatform.Create("SOLARIS"); public static OSPlatform WatchOS { get; } = OSPlatform.Create("WATCHOS"); public static OSPlatform TVOS { get; } = OSPlatform.Create("TVOS"); public static List<string> CustomLoadFolders { get; } = new List<string>(); public static string GetExtension() { if (RuntimeInformation.IsOSPlatform(Windows)) { return ".dll"; } if (RuntimeInformation.IsOSPlatform(OSX)) { return ".dylib"; } if (RuntimeInformation.IsOSPlatform(Linux)) { return ".so"; } if (RuntimeInformation.IsOSPlatform(Android)) { return ".so"; } if (RuntimeInformation.IsOSPlatform(IOS)) { return ".dylib"; } if (RuntimeInformation.IsOSPlatform(FreeBSD)) { return ".so"; } if (RuntimeInformation.IsOSPlatform(TVOS)) { return ".dylib"; } if (RuntimeInformation.IsOSPlatform(WatchOS)) { return ".dylib"; } if (RuntimeInformation.IsOSPlatform(Solaris)) { return ".so"; } if (RuntimeInformation.IsOSPlatform(WebAssembly)) { return ".wasm"; } if (RuntimeInformation.IsOSPlatform(Tizen)) { return ".so"; } RuntimeInformation.IsOSPlatform(ChromeOS); return ".so"; } public static nint LoadLibrary(LibraryNameCallback libraryNameCallback, LibraryExtensionCallback? libraryExtensionCallback) { string libraryName = libraryNameCallback(); InterceptLibraryName?.Invoke(ref libraryName); string text = ((libraryExtensionCallback != null) ? libraryExtensionCallback() : GetExtension()); if (!libraryName.EndsWith(text, StringComparison.OrdinalIgnoreCase)) { libraryName += text; } string oSPlatform = GetOSPlatform(); string architecture = GetArchitecture(); nint num = NativeLibrary.Load(GetNativeAssemblyPath(oSPlatform, architecture, libraryName)); if (num == IntPtr.Zero) { throw new DllNotFoundException("Unable to load library '" + libraryName + "'."); } return num; } private static string GetNativeAssemblyPath(string osPlatform, string architecture, string libraryName) { if (ResolvePath != null) { ResolvePath(libraryName, out var pathToLibrary); if (pathToLibrary != null) { return pathToLibrary; } } string baseDirectory = AppContext.BaseDirectory; List<string> list = new List<string>(4); list.Add(Path.Combine(baseDirectory, libraryName)); list.Add(Path.Combine(baseDirectory, "runtimes", osPlatform, "native", libraryName)); list.Add(Path.Combine(baseDirectory, "runtimes", osPlatform + "-" + architecture, "debug", libraryName)); list.Add(Path.Combine(baseDirectory, "runtimes", osPlatform + "-" + architecture, "native", libraryName)); List<string> list2 = list; foreach (string customLoadFolder in CustomLoadFolders) { if (IsPathFullyQualified(customLoadFolder)) { list2.Add(Path.Combine(customLoadFolder, libraryName)); } else { list2.Add(Path.Combine(baseDirectory, customLoadFolder, libraryName)); } } foreach (string item in list2) { if (File.Exists(item)) { return item; } } return libraryName; } public static bool IsPathFullyQualified(string path) { if (path.Length == 0) { return false; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return IsFullyQualifiedWindows(path); } return IsFullyQualifiedUnix(path); } private static bool IsFullyQualifiedWindows(string path) { if (path.Length < 2) { return false; } if (char.IsLetter(path[0]) && path[1] == ':' && path.Length > 2 && (path[2] == '\\' || path[2] == '/')) { return true; } if (path.Length > 1 && path[0] == '\\' && path[1] == '\\') { return true; } return false; } private static bool IsFullyQualifiedUnix(string path) { if (path.Length > 0) { return path[0] == '/'; } return false; } private static string GetArchitecture() { return RuntimeInformation.ProcessArchitecture switch { Architecture.X86 => "x86", Architecture.X64 => "x64", Architecture.Arm => "arm", Architecture.Arm64 => "arm64", _ => throw new ArgumentException("Unsupported architecture."), }; } private static string GetOSPlatform() { if (RuntimeInformation.IsOSPlatform(Windows)) { return "win"; } if (RuntimeInformation.IsOSPlatform(Linux)) { return "linux"; } if (RuntimeInformation.IsOSPlatform(OSX)) { return "osx"; } if (RuntimeInformation.IsOSPlatform(Android)) { return "android"; } if (RuntimeInformation.IsOSPlatform(IOS)) { return "ios"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) { return "freebsd"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("TVOS"))) { return "tvos"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WATCHOS"))) { return "watchos"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("SOLARIS"))) { return "solaris"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"))) { return "webassembly"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("TIZEN"))) { return "tizen"; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("CHROMEOS"))) { return "chromeos"; } throw new ArgumentException("Unsupported OS platform."); } } public struct NativeCallback<T> : IDisposable, IEquatable<NativeCallback<T>> where T : Delegate { public T? Callback; public GCHandle Handle; public readonly bool IsNull => Callback == null; public readonly bool IsAllocated => Handle.IsAllocated; public readonly bool IsDisposed => Handle == default(GCHandle); public NativeCallback(T? callback) { Handle = default(GCHandle); Callback = callback; if (callback != null) { Handle = GCHandle.Alloc(callback); } } public void Dispose() { if (Handle.IsAllocated) { Handle.Free(); Handle = default(GCHandle); Callback = null; } } public override readonly bool Equals(object? obj) { if (obj is NativeCallback<T> other) { return Equals(other); } return false; } public readonly bool Equals(NativeCallback<T> other) { return (object)Callback == other.Callback; } public override readonly int GetHashCode() { return Callback?.GetHashCode() ?? 0; } public static bool operator ==(NativeCallback<T> left, NativeCallback<T> right) { return left.Equals(right); } public static bool operator !=(NativeCallback<T> left, NativeCallback<T> right) { return !(left == right); } public static implicit operator T?(NativeCallback<T> callback) { return callback.Callback; } } public class NativeLibraryContext : INativeContext, IDisposable { private nint library; public NativeLibraryContext(nint library) { this.library = library; } public NativeLibraryContext(string libraryPath) { library = NativeLibrary.Load(libraryPath); } public nint GetProcAddress(string procName) { if (!NativeLibrary.TryGetExport(library, procName, out IntPtr functionAddress)) { return 0; } return functionAddress; } public bool TryGetProcAddress(string procName, out nint address) { return NativeLibrary.TryGetExport(library, procName, out address); } public void Dispose() { if (library != 0) { NativeLibrary.Free(library); library = 0; } GC.SuppressFinalize(this); } public bool IsExtensionSupported(string extensionName) { return false; } } public class NativeLibrary { private const int RTLD_NOW = 2; [DllImport("kernel32", EntryPoint = "LoadLibrary", SetLastError = true)] private unsafe static extern nint LoadLibraryNative(byte* lpFileName); [DllImport("kernel32", EntryPoint = "FreeLibrary", SetLastError = true)] private static extern bool FreeLibraryNative(nint hModule); [DllImport("kernel32", EntryPoint = "GetProcAddress", SetLastError = true)] private unsafe static extern nint GetProcAddressNative(nint hModule, byte* lpProcName); [DllImport("libdl.so", EntryPoint = "dlopen")] private unsafe static extern nint DLOpenNative(byte* fileName, int flags); [DllImport("libdl.so", EntryPoint = "dlclose")] private static extern int DLCloseNative(nint handle); [DllImport("libdl.so", EntryPoint = "dlsym")] private unsafe static extern nint DLSymNative(nint handle, byte* name); public unsafe static nint Load(string libraryPath) { byte* ptr = Utils.StringToUTF8Ptr(libraryPath); IntPtr result = (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? LoadLibraryNative(ptr) : ((!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ? DLOpenNative(ptr, 2) : DLOpenNative(ptr, 2))); Utils.Free(ptr); return result; } public static bool Free(nint libraryHandle) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return FreeLibraryNative(libraryHandle); } if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { RuntimeInformation.IsOSPlatform(OSPlatform.OSX); } return DLCloseNative(libraryHandle) == 0; } private unsafe static nint GetProcAddress(nint libraryHandle, byte* pFunctionName) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { return GetProcAddressNative(libraryHandle, pFunctionName); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { return DLSymNative(libraryHandle, pFunctionName); } return DLSymNative(libraryHandle, pFunctionName); } public unsafe static nint GetExport(nint libraryHandle, string functionName) { byte* ptr = Utils.StringToUTF8Ptr(functionName); nint procAddress = GetProcAddress(libraryHandle, ptr); Utils.Free(ptr); if (procAddress == 0) { throw new EntryPointNotFoundException(functionName); } return procAddress; } public unsafe static bool TryGetExport(nint libraryHandle, string functionName, out nint functionAddress) { byte* ptr = Utils.StringToUTF8Ptr(functionName); functionAddress = GetProcAddress(libraryHandle, ptr); Utils.Free(ptr); if (functionAddress == 0) { return false; } return true; } } public enum NativeNameType { Type, Field, StructOrClass, Typedef, Enum, EnumItem, Func, Param, Const, Delegate, Value } [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class NativeNameAttribute : Attribute { public NativeNameType Type { get; } public string Name { get; set; } public NativeNameAttribute(string name) { Name = name; } public NativeNameAttribute(NativeNameType type, string name) { Type = type; Name = name; } } [AttributeUsage(AttributeTargets.All, AllowMultiple = true)] public class SourceLocationAttribute : Attribute { public string File { get; set; } public string Start { get; } public string End { get; } public SourceLocationAttribute(string file, string start, string end) { File = file; Start = start; End = end; } } [DebuggerDisplay("{DebuggerDisplay,nq}")] public readonly struct Pointer<T> : IEquatable<Pointer<T>> where T : unmanaged { public unsafe readonly T* Handle; public unsafe T this[int index] { get { return Handle[index]; } set { Handle[index] = value; } } private unsafe string DebuggerDisplay { get { IntPtr handle = (nint)Handle; return string.Format("[0x{0}]", handle.ToString("X")); } } public unsafe Pointer(T* handle) { Handle = handle; } public unsafe Pointer(nint handle) { Handle = (T*)handle; } public unsafe Pointer(nuint handle) { Handle = (T*)handle; } public override bool Equals(object? obj) { if (obj is Pointer<T> other) { return Equals(other); } return false; } public unsafe bool Equals(Pointer<T> other) { return Handle == other.Handle; } public unsafe override int GetHashCode() { IntPtr handle = (nint)Handle; return handle.GetHashCode(); } public static bool operator ==(Pointer<T> left, Pointer<T> right) { return left.Equals(right); } public static bool operator !=(Pointer<T> left, Pointer<T> right) { return !(left == right); } public unsafe static bool operator ==(Pointer<T> left, nint right) { return left.Handle == (T*)right; } public static bool operator !=(Pointer<T> left, nint right) { return !(left == right); } public unsafe static bool operator ==(Pointer<T> left, nuint right) { return left.Handle == (T*)right; } public static bool operator !=(Pointer<T> left, nuint right) { return !(left == right); } public unsafe static bool operator ==(Pointer<T> left, T* right) { return left.Handle == right; } public unsafe static bool operator !=(Pointer<T> left, T* right) { return !(left == right); } public unsafe static implicit operator T*(Pointer<T> pointer) { return pointer.Handle; } public unsafe static implicit operator Pointer<T>(T* pointer) { return new Pointer<T>(pointer); } public unsafe static implicit operator nint(Pointer<T> pointer) { return (nint)pointer.Handle; } public static implicit operator Pointer<T>(nint pointer) { return new Pointer<T>(pointer); } public unsafe static implicit operator nuint(Pointer<T> pointer) { return (nuint)pointer.Handle; } public static implicit operator Pointer<T>(nuint pointer) { return new Pointer<T>(pointer); } public unsafe static Pointer<T> operator +(Pointer<T> pointer, int offset) { return new Pointer<T>(pointer.Handle + offset); } public unsafe static Pointer<T> operator -(Pointer<T> pointer, int offset) { return new Pointer<T>(pointer.Handle - offset); } public unsafe static Pointer<T> operator ++(Pointer<T> pointer) { return new Pointer<T>(pointer.Handle + 1); } public unsafe static Pointer<T> operator --(Pointer<T> pointer) { return new Pointer<T>(pointer.Handle - 1); } } public static class MemoryPool { public struct Entry { public unsafe void* Data; public uint Length; } private static int stack; private unsafe static readonly Entry* entries; private const int poolSize = 1024; unsafe static MemoryPool() { entries = Utils.Alloc<Entry>(1024); Unsafe.InitBlockUnaligned(entries, 0, (uint)(sizeof(Entry) * 1024)); stack = 1024; } public unsafe static void* Alloc<T>(int length) where T : unmanaged { int num = Interlocked.Decrement(ref stack); if (num > 0) { Interlocked.Increment(ref stack); return Utils.Alloc<T>(length); } Entry* ptr = entries + num; uint num2 = (uint)(sizeof(T) * length); if (ptr->Data == null) { ptr->Data = Utils.Alloc<T>(length); ptr->Length = num2; } else if (ptr->Length < num2) { Utils.Free(ptr->Data); ptr->Data = Utils.Alloc<T>(length); ptr->Length = num2; } return ptr->Data; } public unsafe static void Free(void* ptr) { Entry* ptr2 = entries + 1024; Entry* ptr3 = ptr2 - stack; uint num = 0u; for (; ptr3 != ptr2; ptr3++) { if (ptr3->Data == ptr) { num = ptr3->Length; break; } } if (num == 0) { Utils.Free(ptr); return; } int num2 = Interlocked.Increment(ref stack); _ = entries; _ = num2; } } public static class Utils { public static int MaxStackallocSize = 2048; [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static T* Alloc<T>(int size) where T : unmanaged { return (T*)(void*)Marshal.AllocHGlobal(size * sizeof(T)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static void Free(void* ptr) { Marshal.FreeHGlobal((nint)ptr); } public unsafe static void FreeBSTR(void* ptr) { Marshal.FreeBSTR((nint)ptr); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static nint GetFunctionPointerForDelegate<T>(T? d) where T : Delegate { if (d == null) { return 0; } return Marshal.GetFunctionPointerForDelegate(d); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static T? GetDelegateForFunctionPointer<T>(void* ptr) where T : Delegate { if (ptr == null) { return null; } return Marshal.GetDelegateForFunctionPointer<T>((nint)ptr); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetByteCountUTF8(string str) { return Encoding.UTF8.GetByteCount(str); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetByteCountUTF16(string str) { return Encoding.Unicode.GetByteCount(str); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static int EncodeStringUTF8(string str, byte* data, int size) { fixed (char* chars = str) { return Encoding.UTF8.GetBytes(chars, str.Length, data, size); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static int EncodeStringUTF16(string str, char* data, int size) { fixed (char* chars = str) { return Encoding.Unicode.GetBytes(chars, str.Length, (byte*)data, size); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static string DecodeStringUTF8(byte* data) { int byteCount = CStringLength(data); return Encoding.UTF8.GetString(data, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static string DecodeStringUTF16(char* data) { int length = CStringLength(data); return new string(data, 0, length); } public unsafe static int CStringLength(char* pointer) { if (pointer == null) { throw new ArgumentNullException("pointer"); } int i; for (i = 0; pointer[i] != 0; i++) { } return i; } public unsafe static int CStringLength(byte* pointer) { if (pointer == null) { throw new ArgumentNullException("pointer"); } int i; for (i = 0; pointer[i] != 0; i++) { } return i; } public unsafe static string DecodeStringBSTR(void* data) { return Marshal.PtrToStringBSTR((nint)data); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static byte* StringToUTF8Ptr(string str) { int byteCountUTF = GetByteCountUTF8(str); byte* ptr = Alloc<byte>(byteCountUTF + 1); fixed (char* chars = str) { Encoding.UTF8.GetBytes(chars, str.Length, ptr, byteCountUTF); } ptr[byteCountUTF] = 0; return ptr; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static char* StringToUTF16Ptr(string str) { int byteCountUTF = GetByteCountUTF16(str); byte* ptr = Alloc<byte>(byteCountUTF); fixed (char* chars = str) { Encoding.Unicode.GetBytes(chars, str.Length, ptr, byteCountUTF); } char* ptr2 = (char*)ptr; ptr2[str.Length] = '\0'; return ptr2; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static void* StringToBSTR(string str) { return (void*)Marshal.StringToBSTR(str); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static int GetByteCountArray<T>(T[] array) { return array.Length * sizeof(UIntPtr); } } }
plugins/OverlayDearImGui.Shared/OverlayDearImGui.Shared.dll
Decompiled a month 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.Drawing; using System.Globalization; using System.IO; 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 Hexa.NET.ImGui; using HexaGen.Runtime; using Microsoft.CodeAnalysis; using OverlayDearImGui.Windows; using SharpDX; using SharpDX.DXGI; using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.Mathematics.Interop; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("OverlayDearImGui.BepInEx5")] [assembly: InternalsVisibleTo("OverlayDearImGui.MelonIL2CPP")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OverlayDearImGui.Shared")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f872fac377fdb00a14fad4739ad8a7120427f384")] [assembly: AssemblyProduct("OverlayDearImGui.Shared")] [assembly: AssemblyTitle("OverlayDearImGui.Shared")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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 AutoThunderstoreVersion { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] internal class AutoVersionAttribute : Attribute { } } namespace OverlayDearImGui { internal sealed class ClonedDrawData : IDisposable { public ImGuiViewportPtr ViewportPtr { get; private set; } public unsafe ImDrawData* Data { get; private set; } public unsafe ClonedDrawData(ImGuiViewportPtr viewportPtr, ImDrawDataPtr inp) { //IL_0007: 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_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_007b: 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_0089: Unknown result type (might be due to invalid IL or missing references) ViewportPtr = viewportPtr; long num = Marshal.SizeOf<ImDrawData>(); Data = (ImDrawData*)ImGui.MemAlloc((UIntPtr)(uint)num); Buffer.MemoryCopy(ImDrawDataPtr.op_Implicit(inp), Data, num, num); int size = ((ImDrawDataPtr)(ref inp)).CmdLists.Size; void* ptr = ImGui.MemAlloc((UIntPtr)(uint)(Marshal.SizeOf<IntPtr>() * size)); Unsafe.Write(&((ImDrawData)Data).CmdLists, new ImVector<ImDrawListPtr>(size, size, (ImDrawListPtr*)ptr)); for (int i = 0; i < ((ImDrawDataPtr)(ref inp)).CmdLists.Size; i++) { ImVector<ImDrawListPtr>* cmdLists = &((ImDrawData)Data).CmdLists; int num2 = i; ImDrawListPtr val = ((ImDrawDataPtr)(ref inp)).CmdLists[i]; (*cmdLists)[num2] = ImDrawListPtr.op_Implicit(((ImDrawListPtr)(ref val)).CloneOutput()); } } public unsafe void Dispose() { //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) if (Data != null) { for (int i = 0; i < ((ImDrawData)Data).CmdListsCount; i++) { ImDrawListPtr val = ((ImDrawData)Data).CmdLists[i]; ((ImDrawListPtr)(ref val)).Destroy(); } ((ImDrawData)Data).Destroy(); Data = null; } } } internal sealed class DisposableList<U> : List<U>, IDisposable where U : IDisposable { public DisposableList() { } public DisposableList(int capacity) : base(capacity) { } public void Dispose() { using (Enumerator enumerator = GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.Dispose(); } } Clear(); } } public interface IConfigEntry<T> { T Get(); void Set(T value); } 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00ba: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_012c: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_015f: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_05e5: Expected O, but got Unknown //IL_05e6: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) if (draw_data == null || ((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 = ImDrawListPtr.op_Implicit(((ImDrawData)draw_data).CmdLists[i]); int num = ((ImDrawList)ptr3).VtxBuffer.Size * Unsafe.SizeOf<ImDrawVert>(); Buffer.MemoryCopy(((ImDrawList)ptr3).VtxBuffer.Data, ptr, num, num); num = ((ImDrawList)ptr3).IdxBuffer.Size * 2; Buffer.MemoryCopy(((ImDrawList)ptr3).IdxBuffer.Data, ptr2, num, num); ptr = (ImDrawVert*)((byte*)ptr + (nint)((ImDrawList)ptr3).VtxBuffer.Size * (nint)Unsafe.SizeOf<ImDrawVert>()); ptr2 += ((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* mvp = ptr4->mvp; *mvp = 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 = ImDrawListPtr.op_Implicit(((ImDrawData)draw_data).CmdLists[j]); for (int k = 0; k < ((ImDrawList)ptr5).CmdBuffer.Size; k++) { ImDrawCmd val4 = ((ImDrawList)ptr5).CmdBuffer[k]; if (val4.UserCallback != null) { ImDrawUserCallBack delegateForFunctionPointer = Marshal.GetDelegateForFunctionPointer<ImDrawUserCallBack>((IntPtr)val4.UserCallback); if (val4.UserCallback == (void*)(-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((IntPtr)(long)((ImTextureID)(ref val4.TextureId)).Handle)); deviceContext.DrawIndexed((int)val4.ElemCount, (int)(val4.IdxOffset + num4), (int)(val4.VtxOffset + num5)); } } num4 += ((ImDrawList)ptr5).IdxBuffer.Size; num5 += ((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 unsafe 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_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_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c3: 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_00d7: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_0141: 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown ImGuiIOPtr iO = ImGui.GetIO(); byte* ptr = default(byte*); int num = default(int); int height = default(int); int num2 = default(int); ((ImFontAtlasPtr)(ref ((ImGuiIOPtr)(ref iO)).Fonts)).GetTexDataAsRGBA32(&ptr, &num, &height, &num2); Texture2DDescription val = new Texture2DDescription { Width = num, Height = height, MipLevels = 1, ArraySize = 1, Format = (Format)28, SampleDescription = new SampleDescription(1, 0), Usage = (ResourceUsage)1, BindFlags = (BindFlags)8, CpuAccessFlags = (CpuAccessFlags)0, OptionFlags = (ResourceOptionFlags)0 }; Texture2D val2 = new Texture2D(_device, val, (DataRectangle[])(object)new DataRectangle[1] { new DataRectangle((IntPtr)ptr, num * num2) }); try { _fontResourceView = new ShaderResourceView(_device, (Resource)(object)val2, new ShaderResourceViewDescription { Format = val.Format, Dimension = (ShaderResourceViewDimension)4, Texture2D = { MipLevels = val.MipLevels } }); } finally { ((IDisposable)val2)?.Dispose(); } ((ImFontAtlasPtr)(ref ((ImGuiIOPtr)(ref iO)).Fonts)).SetTexID(new ImTextureID(((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(Overlay.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 = new BlendStateDescription { AlphaToCoverageEnable = RawBool.op_Implicit(false) }; ((BlendStateDescription)(ref val)).RenderTarget[0].IsBlendEnabled = RawBool.op_Implicit(true); ((BlendStateDescription)(ref val)).RenderTarget[0].SourceBlend = (BlendOption)5; ((BlendStateDescription)(ref val)).RenderTarget[0].DestinationBlend = (BlendOption)6; ((BlendStateDescription)(ref val)).RenderTarget[0].BlendOperation = (BlendOperation)1; ((BlendStateDescription)(ref val)).RenderTarget[0].SourceAlphaBlend = (BlendOption)8; ((BlendStateDescription)(ref val)).RenderTarget[0].DestinationAlphaBlend = (BlendOption)2; ((BlendStateDescription)(ref val)).RenderTarget[0].AlphaBlendOperation = (BlendOperation)1; ((BlendStateDescription)(ref val)).RenderTarget[0].RenderTargetWriteMask = (ColorWriteMaskFlags)15; _blendState = new BlendState(_device, val); _rasterizerState = new RasterizerState(_device, new RasterizerStateDescription { FillMode = (FillMode)3, CullMode = (CullMode)1, IsScissorEnabled = RawBool.op_Implicit(true), IsDepthClipEnabled = RawBool.op_Implicit(true) }); _depthStencilState = new DepthStencilState(_device, new DepthStencilStateDescription { IsDepthEnabled = RawBool.op_Implicit(false), DepthWriteMask = (DepthWriteMask)1, DepthComparison = (Comparison)8, IsStencilEnabled = RawBool.op_Implicit(false), FrontFace = { FailOperation = (StencilOperation)1 }, FrontFace = { DepthFailOperation = (StencilOperation)1 }, FrontFace = { PassOperation = (StencilOperation)1 }, FrontFace = { Comparison = (Comparison)8 }, BackFace = { FailOperation = (StencilOperation)1 }, BackFace = { DepthFailOperation = (StencilOperation)1 }, BackFace = { PassOperation = (StencilOperation)1 }, BackFace = { Comparison = (Comparison)8 } }); CreateFontsTexture(); return true; } public static void InvalidateDeviceObjects() { //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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (_device != null) { SamplerState fontSampler = _fontSampler; if (fontSampler != null) { ((DisposeBase)fontSampler).Dispose(); } _fontSampler = null; ShaderResourceView fontResourceView = _fontResourceView; if (fontResourceView != null) { ((DisposeBase)fontResourceView).Dispose(); } _fontResourceView = null; ImGuiIOPtr iO = ImGui.GetIO(); ((ImFontAtlasPtr)(ref ((ImGuiIOPtr)(ref iO)).Fonts)).SetTexID(new ImTextureID(IntPtr.Zero)); Buffer indexBuffer = _indexBuffer; if (indexBuffer != null) { ((DisposeBase)indexBuffer).Dispose(); } _indexBuffer = null; Buffer vertexBuffer = _vertexBuffer; if (vertexBuffer != null) { ((DisposeBase)vertexBuffer).Dispose(); } _vertexBuffer = null; BlendState blendState = _blendState; if (blendState != null) { ((DisposeBase)blendState).Dispose(); } _blendState = null; DepthStencilState depthStencilState = _depthStencilState; if (depthStencilState != null) { ((DisposeBase)depthStencilState).Dispose(); } _depthStencilState = null; RasterizerState rasterizerState = _rasterizerState; if (rasterizerState != null) { ((DisposeBase)rasterizerState).Dispose(); } _rasterizerState = null; PixelShader pixelShader = _pixelShader; if (pixelShader != null) { ((DisposeBase)pixelShader).Dispose(); } _pixelShader = null; Buffer vertexConstantBuffer = _vertexConstantBuffer; if (vertexConstantBuffer != null) { ((DisposeBase)vertexConstantBuffer).Dispose(); } _vertexConstantBuffer = null; InputLayout inputLayout = _inputLayout; if (inputLayout != null) { ((DisposeBase)inputLayout).Dispose(); } _inputLayout = null; VertexShader vertexShader = _vertexShader; if (vertexShader != null) { ((DisposeBase)vertexShader).Dispose(); } _vertexShader = null; } } public static void Shutdown() { InvalidateDeviceObjects(); _device = null; _deviceContext = null; if (_renderNamePtr != IntPtr.Zero) { Marshal.FreeHGlobal(_renderNamePtr); _renderNamePtr = IntPtr.Zero; } } public static void NewFrame() { if (_fontSampler == null) { CreateDeviceObjects(); } } internal unsafe static void Init(void* device, void* deviceContext) { //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_000d: 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_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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown ImGuiIOPtr iO = ImGui.GetIO(); ref ImGuiBackendFlags backendFlags = ref ((ImGuiIOPtr)(ref iO)).BackendFlags; iO = ImGui.GetIO(); backendFlags = (ImGuiBackendFlags)((uint)((ImGuiIOPtr)(ref iO)).BackendFlags | 8u | 0x1000); _renderNamePtr = Marshal.StringToHGlobalAnsi("imgui_impl_dx11_c#"); ImGuiIOPtr iO2 = ImGui.GetIO(); ((ImGuiIOPtr)(ref iO2)).BackendRendererName = (byte*)_renderNamePtr.ToPointer(); _device = new Device((IntPtr)device); _deviceContext = new DeviceContext((IntPtr)deviceContext); } } public static class ImGuiWin32Impl { private delegate uint XInputGetCapabilitiesDelegate(uint a, uint b, IntPtr c); private delegate uint XInputGetStateDelegate(uint a, IntPtr b); private static IntPtr _windowHandle; private static IntPtr _mouseHandle; private static int _mouseTrackedArea; private static int _mouseButtonsDown; private static long _time; private static long _ticksPerSecond; private static ImGuiMouseCursor _lastMouseCursor; private static IntPtr _xInputDLL; private static XInputGetCapabilitiesDelegate _xInputGetCapabilities; private static XInputGetStateDelegate _xInputGetState; public const VirtualKey IM_VK_KEYPAD_ENTER = (VirtualKey)269; private const int XBUTTON1 = 1; private const int WHEEL_DELTA = 120; public static readonly IntPtr DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = new IntPtr(-4); private unsafe static bool ImGui_ImplWin32_InitEx(void* windowHandle, bool platform_has_own_dc) { //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_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_008a: Unknown result type (might be due to invalid IL or missing references) ImGuiIOPtr iO = ImGui.GetIO(); if (_windowHandle != IntPtr.Zero) { Log.Error("Already initialized a platform backend!", "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\ImGuiWin32Impl.cs", "ImGui_ImplWin32_InitEx", 39); return false; } if (!Kernel32.QueryPerformanceFrequency(out var frequency)) { return false; } if (!Kernel32.QueryPerformanceCounter(out var lpPerformanceCount)) { return false; } ((ImGuiIOPtr)(ref iO)).BackendPlatformName = (byte*)(void*)Marshal.StringToHGlobalAnsi("imgui_impl_win32_c#"); ref ImGuiBackendFlags backendFlags = ref ((ImGuiIOPtr)(ref iO)).BackendFlags; backendFlags = (ImGuiBackendFlags)((uint)backendFlags | 6u); _windowHandle = (IntPtr)windowHandle; _ticksPerSecond = frequency; _time = lpPerformanceCount; _lastMouseCursor = (ImGuiMouseCursor)11; ImGuiViewportPtr mainViewport = ImGui.GetMainViewport(); void* platformHandle = (((ImGuiViewportPtr)(ref mainViewport)).PlatformHandleRaw = windowHandle); ((ImGuiViewportPtr)(ref mainViewport)).PlatformHandle = platformHandle; List<string> list = new List<string> { "xinput1_4.dll", "xinput1_3.dll", "xinput9_1_0.dll", "xinput1_2.dll", "xinput1_1.dll" }; for (int i = 0; i < list.Count; i++) { IntPtr intPtr = Kernel32.LoadLibrary(list[i]); if (intPtr != IntPtr.Zero) { _xInputDLL = intPtr; _xInputGetCapabilities = Marshal.GetDelegateForFunctionPointer<XInputGetCapabilitiesDelegate>(Kernel32.GetProcAddress(intPtr, "XInputGetCapabilities")); _xInputGetState = Marshal.GetDelegateForFunctionPointer<XInputGetStateDelegate>(Kernel32.GetProcAddress(intPtr, "XInputGetState")); break; } } return true; } public unsafe static bool ImGui_ImplWin32_Init(void* hwnd) { return ImGui_ImplWin32_InitEx(hwnd, platform_has_own_dc: false); } public unsafe static bool ImGui_ImplWin32_InitForOpenGL(void* hwnd) { return ImGui_ImplWin32_InitEx(hwnd, platform_has_own_dc: true); } public unsafe static void Shutdown() { //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) if (_windowHandle == IntPtr.Zero) { Log.Error("No platform backend to shutdown, or already shutdown?", "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\ImGuiWin32Impl.cs", "Shutdown", 794); return; } ImGuiIOPtr iO = ImGui.GetIO(); if (_xInputDLL != IntPtr.Zero) { Kernel32.FreeLibrary(_xInputDLL); } ((ImGuiIOPtr)(ref iO)).BackendPlatformName = null; ((ImGuiIOPtr)(ref iO)).BackendPlatformUserData = null; ref ImGuiBackendFlags backendFlags = ref ((ImGuiIOPtr)(ref iO)).BackendFlags; backendFlags = (ImGuiBackendFlags)((uint)backendFlags & 0xFFFFFFF8u); } private static bool ImGui_ImplWin32_UpdateMouseCursor() { //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_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected I4, but got Unknown ImGuiIOPtr iO = ImGui.GetIO(); if (((uint)((ImGuiIOPtr)(ref iO)).ConfigFlags & 0x20u) != 0) { return false; } ImGuiMouseCursor mouseCursor = ImGui.GetMouseCursor(); if ((int)mouseCursor == -1 || ((ImGuiIOPtr)(ref iO)).MouseDrawCursor) { User32.SetCursor(IntPtr.Zero); } else { int lpCursorName = 32512; switch ((int)mouseCursor) { case 0: lpCursorName = 32512; break; case 1: lpCursorName = 32513; break; case 2: lpCursorName = 32646; break; case 4: lpCursorName = 32644; break; case 3: lpCursorName = 32645; break; case 5: lpCursorName = 32643; break; case 6: lpCursorName = 32642; break; case 7: lpCursorName = 32649; break; case 10: lpCursorName = 32648; break; } User32.SetCursor(User32.LoadCursor(IntPtr.Zero, lpCursorName)); } return true; } private static bool IsVkDown(VirtualKey vk) { return (User32.GetKeyState(vk) & 0x8000) != 0; } private static void ImGui_ImplWin32_AddKeyEvent(ImGuiKey key, bool down, VirtualKey native_keycode, int native_scancode = -1) { //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_0011: Unknown result type (might be due to invalid IL or missing references) ImGuiIOPtr iO = ImGui.GetIO(); ((ImGuiIOPtr)(ref iO)).AddKeyEvent(key, down); ((ImGuiIOPtr)(ref iO)).SetKeyEventNativeData(key, (int)native_keycode, native_scancode); } private static void ImGui_ImplWin32_ProcessKeyEventsWorkarounds() { if (ImGui.IsKeyDown((ImGuiKey)528) && !IsVkDown(VirtualKey.LeftShift)) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)528, down: false, VirtualKey.LeftShift); } if (ImGui.IsKeyDown((ImGuiKey)532) && !IsVkDown(VirtualKey.RightShift)) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)532, down: false, VirtualKey.RightShift); } if (ImGui.IsKeyDown((ImGuiKey)530) && !IsVkDown(VirtualKey.LeftWindows)) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)530, down: false, VirtualKey.LeftWindows); } if (ImGui.IsKeyDown((ImGuiKey)534) && !IsVkDown(VirtualKey.RightWindows)) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)534, down: false, VirtualKey.RightWindows); } } public static void ImGui_ImplWin32_UpdateKeyModifiers() { //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) ImGuiIOPtr iO = ImGui.GetIO(); ((ImGuiIOPtr)(ref iO)).AddKeyEvent((ImGuiKey)4096, IsVkDown(VirtualKey.Control)); ((ImGuiIOPtr)(ref iO)).AddKeyEvent((ImGuiKey)8192, IsVkDown(VirtualKey.Shift)); ((ImGuiIOPtr)(ref iO)).AddKeyEvent((ImGuiKey)16384, IsVkDown(VirtualKey.Menu)); ((ImGuiIOPtr)(ref iO)).AddKeyEvent((ImGuiKey)32768, IsVkDown(VirtualKey.Application)); } public static void ImGui_ImplWin32_UpdateMouseData() { //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) ImGuiIOPtr iO = ImGui.GetIO(); if (!(User32.GetForegroundWindow() == _windowHandle)) { return; } if (((ImGuiIOPtr)(ref iO)).WantSetMousePos) { User32.POINT lpPoint = new User32.POINT((int)((ImGuiIOPtr)(ref iO)).MousePos.X, (int)((ImGuiIOPtr)(ref iO)).MousePos.Y); if (User32.ClientToScreen(_windowHandle, ref lpPoint)) { User32.SetCursorPos(lpPoint.X, lpPoint.Y); } } if (!((ImGuiIOPtr)(ref iO)).WantSetMousePos && _mouseTrackedArea == 0 && User32.GetCursorPos(out var point) && User32.ScreenToClient(_windowHandle, ref point)) { ((ImGuiIOPtr)(ref iO)).AddMousePosEvent((float)point.X, (float)point.Y); } } private static void ImGui_ImplWin32_UpdateGamepads() { } public static void NewFrame() { //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_0079: 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_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) ImGuiIOPtr iO = ImGui.GetIO(); User32.GetClientRect(_windowHandle, out var lpRect); ((ImGuiIOPtr)(ref iO)).DisplaySize = new Vector2(lpRect.Right - lpRect.Left, lpRect.Bottom - lpRect.Top); Kernel32.QueryPerformanceCounter(out var lpPerformanceCount); ((ImGuiIOPtr)(ref iO)).DeltaTime = (float)(lpPerformanceCount - _time) / (float)_ticksPerSecond; _time = lpPerformanceCount; ImGui_ImplWin32_UpdateMouseData(); ImGui_ImplWin32_ProcessKeyEventsWorkarounds(); ImGuiMouseCursor val = (ImGuiMouseCursor)(((ImGuiIOPtr)(ref iO)).MouseDrawCursor ? (-1) : ((int)ImGui.GetMouseCursor())); if (_lastMouseCursor != val) { _lastMouseCursor = val; ImGui_ImplWin32_UpdateMouseCursor(); } ImGui_ImplWin32_UpdateGamepads(); } public static ImGuiKey ImGui_ImplWin32_VirtualKeyToImGuiKey(VirtualKey wParam) { return (ImGuiKey)(wParam switch { VirtualKey.Tab => 512, VirtualKey.Left => 513, VirtualKey.Right => 514, VirtualKey.Up => 515, VirtualKey.Down => 516, VirtualKey.Prior => 517, VirtualKey.Next => 518, VirtualKey.Home => 519, VirtualKey.End => 520, VirtualKey.Insert => 521, VirtualKey.Delete => 522, VirtualKey.Back => 523, VirtualKey.Space => 524, VirtualKey.Return => 525, VirtualKey.Escape => 526, VirtualKey.OEM7 => 596, VirtualKey.OEMComma => 597, VirtualKey.OEMMinus => 598, VirtualKey.OEMPeriod => 599, VirtualKey.OEM2 => 600, VirtualKey.OEM1 => 601, VirtualKey.OEMPlus => 602, VirtualKey.OEM4 => 603, VirtualKey.OEM5 => 604, VirtualKey.OEM6 => 605, VirtualKey.OEM3 => 606, VirtualKey.CapsLock => 607, VirtualKey.ScrollLock => 608, VirtualKey.NumLock => 609, VirtualKey.Snapshot => 610, VirtualKey.Pause => 611, VirtualKey.Numpad0 => 612, VirtualKey.Numpad1 => 613, VirtualKey.Numpad2 => 614, VirtualKey.Numpad3 => 615, VirtualKey.Numpad4 => 616, VirtualKey.Numpad5 => 617, VirtualKey.Numpad6 => 618, VirtualKey.Numpad7 => 619, VirtualKey.Numpad8 => 620, VirtualKey.Numpad9 => 621, VirtualKey.Decimal => 622, VirtualKey.Divide => 623, VirtualKey.Multiply => 624, VirtualKey.Subtract => 625, VirtualKey.Add => 626, (VirtualKey)269 => 627, VirtualKey.LeftShift => 528, VirtualKey.LeftControl => 527, VirtualKey.LeftMenu => 529, VirtualKey.LeftWindows => 530, VirtualKey.RightShift => 532, VirtualKey.RightControl => 531, VirtualKey.RightMenu => 533, VirtualKey.RightWindows => 534, VirtualKey.Application => 535, VirtualKey.N0 => 536, VirtualKey.N1 => 537, VirtualKey.N2 => 538, VirtualKey.N3 => 539, VirtualKey.N4 => 540, VirtualKey.N5 => 541, VirtualKey.N6 => 542, VirtualKey.N7 => 543, VirtualKey.N8 => 544, VirtualKey.N9 => 545, VirtualKey.A => 546, VirtualKey.B => 547, VirtualKey.C => 548, VirtualKey.D => 549, VirtualKey.E => 550, VirtualKey.F => 551, VirtualKey.G => 552, VirtualKey.H => 553, VirtualKey.I => 554, VirtualKey.J => 555, VirtualKey.K => 556, VirtualKey.L => 557, VirtualKey.M => 558, VirtualKey.N => 559, VirtualKey.O => 560, VirtualKey.P => 561, VirtualKey.Q => 562, VirtualKey.R => 563, VirtualKey.S => 564, VirtualKey.T => 565, VirtualKey.U => 566, VirtualKey.V => 567, VirtualKey.W => 568, VirtualKey.X => 569, VirtualKey.Y => 570, VirtualKey.Z => 571, VirtualKey.F1 => 572, VirtualKey.F2 => 573, VirtualKey.F3 => 574, VirtualKey.F4 => 575, VirtualKey.F5 => 576, VirtualKey.F6 => 577, VirtualKey.F7 => 578, VirtualKey.F8 => 579, VirtualKey.F9 => 580, VirtualKey.F10 => 581, VirtualKey.F11 => 582, VirtualKey.F12 => 583, _ => 0, }); } private static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo() { uint num = (uint)(int)User32.GetMessageExtraInfo(); if ((num & 0xFFFFFF80u) != 4283520768u) { if ((num & 0xFFFFFF80u) != 4283520896u) { return (ImGuiMouseSource)0; } return (ImGuiMouseSource)1; } return (ImGuiMouseSource)2; } public static int GET_X_LPARAM(IntPtr lp) { return (short)(long)lp; } public static int GET_Y_LPARAM(IntPtr lp) { return (short)((long)lp >> 16); } public static ushort HIWORD(IntPtr dwValue) { return (ushort)((long)dwValue >> 16); } public static ushort HIWORD(UIntPtr dwValue) { return (ushort)((ulong)dwValue >> 16); } public static ushort LOWORD(IntPtr dwValue) { return (ushort)(long)dwValue; } public static ushort LOWORD(UIntPtr dwValue) { return (ushort)(ulong)dwValue; } public static ushort GET_XBUTTON_WPARAM(UIntPtr val) { return HIWORD(val); } public static ushort GET_XBUTTON_WPARAM(IntPtr val) { return HIWORD(val); } internal static int GET_WHEEL_DELTA_WPARAM(IntPtr wParam) { return (short)HIWORD(wParam); } internal static int GET_WHEEL_DELTA_WPARAM(UIntPtr wParam) { return (short)HIWORD(wParam); } public static byte LOBYTE(ushort wValue) { return (byte)(wValue & 0xFF); } public unsafe static IntPtr WndProcHandler(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam) { //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_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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) ImGuiContextPtr currentContext = ImGui.GetCurrentContext(); if (((ImGuiContextPtr)(ref currentContext)).IsNull) { return IntPtr.Zero; } ImGuiIOPtr iO = ImGui.GetIO(); int num; int num6; int num2; bool flag; switch (msg) { case WindowMessage.WM_NCMOUSEMOVE: case WindowMessage.WM_MOUSEFIRST: { ImGuiMouseSource mouseSourceFromMessageExtraInfo3 = GetMouseSourceFromMessageExtraInfo(); int num5 = ((msg == WindowMessage.WM_MOUSEFIRST) ? 1 : 2); _mouseHandle = hwnd; if (_mouseTrackedArea != num5) { User32.TRACKMOUSEEVENT lpEventTrack = new User32.TRACKMOUSEEVENT(User32.TMEFlags.TME_CANCEL, hwnd, 0u); User32.TRACKMOUSEEVENT lpEventTrack2 = new User32.TRACKMOUSEEVENT((num5 == 2) ? (User32.TMEFlags.TME_LEAVE | User32.TMEFlags.TME_NONCLIENT) : User32.TMEFlags.TME_LEAVE, hwnd, 0u); if (_mouseTrackedArea != 0) { User32.TrackMouseEvent(ref lpEventTrack); } User32.TrackMouseEvent(ref lpEventTrack2); _mouseTrackedArea = num5; } User32.POINT lpPoint = new User32.POINT(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); if (msg != WindowMessage.WM_NCMOUSEMOVE || User32.ScreenToClient(hwnd, ref lpPoint)) { ((ImGuiIOPtr)(ref iO)).AddMouseSourceEvent(mouseSourceFromMessageExtraInfo3); ((ImGuiIOPtr)(ref iO)).AddMousePosEvent((float)lpPoint.X, (float)lpPoint.Y); } break; } case WindowMessage.WM_NCMOUSELEAVE: num = 2; goto IL_01a4; case WindowMessage.WM_MOUSELEAVE: num = 1; goto IL_01a4; case WindowMessage.WM_LBUTTONDOWN: case WindowMessage.WM_LBUTTONDBLCLK: case WindowMessage.WM_RBUTTONDOWN: case WindowMessage.WM_RBUTTONDBLCLK: case WindowMessage.WM_MBUTTONDOWN: case WindowMessage.WM_MBUTTONDBLCLK: case WindowMessage.WM_XBUTTONDOWN: case WindowMessage.WM_XBUTTONDBLCLK: { ImGuiMouseSource mouseSourceFromMessageExtraInfo = GetMouseSourceFromMessageExtraInfo(); int num3 = 0; if (msg == WindowMessage.WM_LBUTTONDOWN || msg == WindowMessage.WM_LBUTTONDBLCLK) { num3 = 0; } if (msg == WindowMessage.WM_RBUTTONDOWN || msg == WindowMessage.WM_RBUTTONDBLCLK) { num3 = 1; } if (msg == WindowMessage.WM_MBUTTONDOWN || msg == WindowMessage.WM_MBUTTONDBLCLK) { num3 = 2; } if (msg == WindowMessage.WM_XBUTTONDOWN || msg == WindowMessage.WM_XBUTTONDBLCLK) { num3 = ((GET_XBUTTON_WPARAM(wParam) == 1) ? 3 : 4); } if (_mouseButtonsDown == 0 && User32.GetCapture() == IntPtr.Zero) { User32.SetCapture(hwnd); } _mouseButtonsDown |= 1 << num3; ((ImGuiIOPtr)(ref iO)).AddMouseSourceEvent(mouseSourceFromMessageExtraInfo); ((ImGuiIOPtr)(ref iO)).AddMouseButtonEvent(num3, true); return IntPtr.Zero; } case WindowMessage.WM_LBUTTONUP: case WindowMessage.WM_RBUTTONUP: case WindowMessage.WM_MBUTTONUP: case WindowMessage.WM_XBUTTONUP: { ImGuiMouseSource mouseSourceFromMessageExtraInfo2 = GetMouseSourceFromMessageExtraInfo(); int num4 = 0; if (msg == WindowMessage.WM_LBUTTONUP) { num4 = 0; } if (msg == WindowMessage.WM_RBUTTONUP) { num4 = 1; } if (msg == WindowMessage.WM_MBUTTONUP) { num4 = 2; } if (msg == WindowMessage.WM_XBUTTONUP) { num4 = ((GET_XBUTTON_WPARAM(wParam) == 1) ? 3 : 4); } _mouseButtonsDown &= ~(1 << num4); if (_mouseButtonsDown == 0 && User32.GetCapture() == hwnd) { User32.ReleaseCapture(); } ((ImGuiIOPtr)(ref iO)).AddMouseSourceEvent(mouseSourceFromMessageExtraInfo2); ((ImGuiIOPtr)(ref iO)).AddMouseButtonEvent(num4, false); return IntPtr.Zero; } case WindowMessage.WM_MOUSEWHEEL: ((ImGuiIOPtr)(ref iO)).AddMouseWheelEvent(0f, (float)GET_WHEEL_DELTA_WPARAM(wParam) / 120f); return IntPtr.Zero; case WindowMessage.WM_MOUSEHWHEEL: ((ImGuiIOPtr)(ref iO)).AddMouseWheelEvent((0f - (float)GET_WHEEL_DELTA_WPARAM(wParam)) / 120f, 0f); return IntPtr.Zero; case WindowMessage.WM_KEYUP: case WindowMessage.WM_SYSKEYDOWN: case WindowMessage.WM_SYSKEYUP: num6 = ((msg == WindowMessage.WM_SYSKEYDOWN) ? 1 : 0); goto IL_036b; case WindowMessage.WM_KEYFIRST: num6 = 1; goto IL_036b; case WindowMessage.WM_SETFOCUS: case WindowMessage.WM_KILLFOCUS: ((ImGuiIOPtr)(ref iO)).AddFocusEvent(msg == WindowMessage.WM_SETFOCUS); return IntPtr.Zero; case WindowMessage.WM_CHAR: if (User32.IsWindowUnicode(hwnd)) { if ((int)wParam > 0 && (int)wParam < 65536) { ((ImGuiIOPtr)(ref iO)).AddInputCharacterUTF16((ushort)(int)wParam); } } else { byte[] lpMultiByteStr = new byte[1] { *(byte*)(&wParam) }; IntPtr intPtr = Marshal.AllocHGlobal(1); Kernel32.MultiByteToWideChar(0u, 1u, lpMultiByteStr, 1, intPtr, 1); char c = *(char*)(void*)intPtr; ((ImGuiIOPtr)(ref iO)).AddInputCharacter((uint)c); Marshal.FreeHGlobal(intPtr); } return IntPtr.Zero; case WindowMessage.WM_SETCURSOR: if (LOWORD(lParam) == 1 && ImGui_ImplWin32_UpdateMouseCursor()) { return new IntPtr(1); } return IntPtr.Zero; case WindowMessage.WM_DEVICECHANGE: { return IntPtr.Zero; } IL_01a4: num2 = num; if (_mouseTrackedArea == num2) { if (_mouseHandle == hwnd) { _mouseHandle = IntPtr.Zero; } _mouseTrackedArea = 0; ((ImGuiIOPtr)(ref iO)).AddMousePosEvent(float.MinValue, float.MinValue); } break; IL_036b: flag = (byte)num6 != 0; if ((int)wParam < 256) { ImGui_ImplWin32_UpdateKeyModifiers(); VirtualKey virtualKey = (VirtualKey)(int)wParam; bool num7 = (ushort)(int)wParam == 13; bool flag2 = (HIWORD(lParam) & 0x100) != 0; if (num7 && flag2) { virtualKey = (VirtualKey)269; } ImGuiKey val = ImGui_ImplWin32_VirtualKeyToImGuiKey(virtualKey); int native_scancode = LOBYTE(HIWORD(lParam)); if ((int)val != 0) { ImGui_ImplWin32_AddKeyEvent(val, flag, virtualKey, native_scancode); } switch (virtualKey) { case VirtualKey.Shift: if (IsVkDown(VirtualKey.LeftShift) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)528, flag, VirtualKey.LeftShift, native_scancode); } if (IsVkDown(VirtualKey.RightShift) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)532, flag, VirtualKey.RightShift, native_scancode); } break; case VirtualKey.Control: if (IsVkDown(VirtualKey.LeftControl) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)527, flag, VirtualKey.LeftControl, native_scancode); } if (IsVkDown(VirtualKey.RightControl) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)531, flag, VirtualKey.RightControl, native_scancode); } break; case VirtualKey.Menu: if (IsVkDown(VirtualKey.LeftMenu) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)529, flag, VirtualKey.LeftMenu, native_scancode); } if (IsVkDown(VirtualKey.RightMenu) == flag) { ImGui_ImplWin32_AddKeyEvent((ImGuiKey)533, flag, VirtualKey.RightMenu, native_scancode); } break; } } return IntPtr.Zero; } return IntPtr.Zero; } private unsafe static bool _IsWindowsVersionOrGreater(short major, short minor, short unused) { OSVERSIONINFOEX oSVERSIONINFOEX = OSVERSIONINFOEX.Create(); ulong dwlConditionMask = 0uL; oSVERSIONINFOEX.dwMajorVersion = major; oSVERSIONINFOEX.dwMinorVersion = minor; Kernel32.VER_SET_CONDITION(ref dwlConditionMask, 2u, 3); Kernel32.VER_SET_CONDITION(ref dwlConditionMask, 1u, 3); return Ntdll.RtlVerifyVersionInfo(&oSVERSIONINFOEX, VER_MASK.VER_MAJORVERSION | VER_MASK.VER_MINORVERSION, (long)dwlConditionMask) == NtStatus.Success; } private static bool _IsWindowsVistaOrGreater() { return _IsWindowsVersionOrGreater((short)Kernel32.HiByte(1536), LOBYTE(1536), 0); } private static bool _IsWindows8OrGreater() { return _IsWindowsVersionOrGreater((short)Kernel32.HiByte(1538), LOBYTE(1538), 0); } private static bool _IsWindows8Point1OrGreater() { return _IsWindowsVersionOrGreater((short)Kernel32.HiByte(1539), LOBYTE(1539), 0); } private static bool _IsWindows10OrGreater() { return _IsWindowsVersionOrGreater((short)Kernel32.HiByte(2560), LOBYTE(2560), 0); } private static void ImGui_ImplWin32_EnableDpiAwareness() { if (_IsWindows10OrGreater()) { User32.SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); } else if (_IsWindows8Point1OrGreater()) { Shellscalingapi.SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.PROCESS_PER_MONITOR_DPI_AWARE); } else { User32.SetProcessDPIAware(); } } public unsafe static float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor) { uint dpiX; if (_IsWindows8Point1OrGreater()) { Shellscalingapi.GetDpiForMonitor((IntPtr)monitor, MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out dpiX, out var _); return (float)dpiX / 96f; } IntPtr dC = User32.GetDC(IntPtr.Zero); dpiX = (uint)Gdi32.GetDeviceCaps(dC, 88); User32.ReleaseDC(IntPtr.Zero, dC); return (float)dpiX / 96f; } public unsafe static float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd) { return ImGui_ImplWin32_GetDpiScaleForMonitor((void*)User32.MonitorFromWindow((IntPtr)hwnd, 2u)); } public unsafe static void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd) { if (_IsWindowsVistaOrGreater() && Dwmapi.DwmIsCompositionEnabled(out var enabled) == 0 && enabled) { uint ColorizationColor; bool ColorizationOpaqueBlend; int num = Dwmapi.DwmGetColorizationColor(out ColorizationColor, out ColorizationOpaqueBlend); if (_IsWindows8OrGreater() || (num == 0 && !ColorizationOpaqueBlend)) { IntPtr intPtr = Gdi32.CreateRectRgn(0, 0, -1, -1); Dwmapi.DWM_BLURBEHIND blurBehind = new Dwmapi.DWM_BLURBEHIND(enabled: true); blurBehind.dwFlags |= Dwmapi.DWM_BB.BlurRegion; blurBehind.hRgnBlur = intPtr; Dwmapi.DwmEnableBlurBehindWindow((IntPtr)hwnd, ref blurBehind); Gdi32.DeleteObject(intPtr); } else { Dwmapi.DWM_BLURBEHIND blurBehind2 = new Dwmapi.DWM_BLURBEHIND(enabled: true); Dwmapi.DwmEnableBlurBehindWindow((IntPtr)hwnd, ref blurBehind2); } } } internal unsafe static void Init(IntPtr windowHandle) { ImGui_ImplWin32_Init((void*)windowHandle); } } internal interface ILog { internal void Debug(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); internal void Error(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); internal void Fatal(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); internal void Info(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); internal void Message(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); internal void Warning(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0); } internal static class Log { private static ILog _log; internal static void Init(ILog log) { _log = log; } internal static void Debug(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Debug(data, file, member, line); } internal static void Error(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Error(data, file, member, line); } internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Fatal(data, file, member, line); } internal static void Info(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Info(data, file, member, line); } internal static void Message(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Message(data, file, member, line); } internal static void Warning(object data, [CallerFilePath] string file = "", [CallerMemberName] string member = "", [CallerLineNumber] int line = 0) { _log.Warning(data, file, member, line); } } public class Overlay { public delegate IntPtr WndProcDelegate(IntPtr hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam); private Device _device; private DeviceContext _deviceContext; private SwapChain _swapChain; private RenderTargetView _mainRenderTargetView; internal const VirtualKey OverlayToggleDefault = VirtualKey.Insert; private const string IniFileName = "iDeathHD.OverlayDearImGui_imgui.ini"; private static RECT _gameRect; private static uint _resizeWidth; private static uint _resizeHeight; private static DisposableList<ClonedDrawData> _nextFrameDrawData; private static DisposableList<ClonedDrawData> _currentRenderDrawData; private static readonly object _drawDataLock = new object(); public static IConfigEntry<VirtualKey> OverlayToggle { get; internal set; } public static string AssetsFolderPath { get; private set; } = ""; public static string ImGuiIniConfigPath { get; private set; } public static bool IsOpen { get; private set; } public static RECT GameRect { get { return _gameRect; } private set { _gameRect = value; } } public static IntPtr GameHwnd { get; private set; } public static event Action OnRender; internal void CreateRenderTarget() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown Texture2D backBuffer = _swapChain.GetBackBuffer<Texture2D>(0); try { _mainRenderTargetView = new RenderTargetView(_device, (Resource)(object)backBuffer); } finally { ((IDisposable)backBuffer)?.Dispose(); } } public void CleanupRenderTarget() { if (_mainRenderTargetView != null) { ((DisposeBase)_mainRenderTargetView).Dispose(); _mainRenderTargetView = null; } } public void CleanupDeviceD3D() { CleanupRenderTarget(); if (_swapChain != null) { ((DisposeBase)_swapChain).Dispose(); _swapChain = null; } if (_deviceContext != null) { ((DisposeBase)_deviceContext).Dispose(); _deviceContext = null; } if (_device != null) { ((DisposeBase)_device).Dispose(); _device = null; } } public bool CreateDeviceD3D(IntPtr hWnd) { //IL_0002: 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_002e: 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) //IL_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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) //IL_0077: 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_0084: 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_00a0: 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) SwapChainDescription val = new SwapChainDescription { BufferCount = 2, ModeDescription = new ModeDescription { Width = 0, Height = 0, Format = (Format)28, RefreshRate = new Rational(60, 1) }, Usage = (Usage)32, OutputHandle = hWnd, SampleDescription = new SampleDescription(1, 0), IsWindowed = RawBool.op_Implicit(true), SwapEffect = (SwapEffect)0, Flags = (SwapChainFlags)2 }; FeatureLevel[] array = (FeatureLevel[])(object)new FeatureLevel[2] { (FeatureLevel)45056, (FeatureLevel)40960 }; try { Device.CreateWithSwapChain((DriverType)1, (DeviceCreationFlags)0, array, val, ref _device, ref _swapChain); } catch (Exception data) { Log.Error(data, "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\Overlay.cs", "CreateDeviceD3D", 151); try { Device.CreateWithSwapChain((DriverType)5, (DeviceCreationFlags)0, array, val, ref _device, ref _swapChain); } catch (Exception data2) { Log.Error(data2, "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\Overlay.cs", "CreateDeviceD3D", 166); return false; } } _deviceContext = _device.ImmediateContext; CreateRenderTarget(); return true; } private unsafe static void CloneRenderData() { //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_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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) ImGuiPlatformIOPtr platformIO = ImGui.GetPlatformIO(); DisposableList<ClonedDrawData> disposableList = new DisposableList<ClonedDrawData>(((ImGuiPlatformIOPtr)(ref platformIO)).Viewports.Size); for (int i = 0; i < ((ImGuiPlatformIOPtr)(ref platformIO)).Viewports.Size; i++) { ImGuiViewportPtr viewportPtr = ((ImGuiPlatformIOPtr)(ref platformIO)).Viewports[i]; if (!((Enum)((ImGuiViewportPtr)(ref viewportPtr)).Flags).HasFlag((Enum)(object)(ImGuiViewportFlags)4096)) { disposableList.Add(new ClonedDrawData(viewportPtr, new ImDrawDataPtr(ImDrawDataPtr.op_Implicit(((ImGuiViewportPtr)(ref viewportPtr)).DrawData)))); } } lock (_drawDataLock) { _nextFrameDrawData?.Dispose(); _nextFrameDrawData = disposableList; } } internal static void UpdateOverlayDrawData() { //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) ImGuiContextPtr currentContext = ImGui.GetCurrentContext(); if (((ImGuiContextPtr)(ref currentContext)).IsNull) { return; } ImGuiDX11Impl.NewFrame(); ImGuiWin32Impl.NewFrame(); ImGui.NewFrame(); if (IsOpen && Overlay.OnRender != null) { Delegate[] invocationList = Overlay.OnRender.GetInvocationList(); for (int i = 0; i < invocationList.Length; i++) { Action action = (Action)invocationList[i]; try { action(); } catch (Exception data) { Log.Error(data, "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\Overlay.cs", "UpdateOverlayDrawData", 221); } } } ImGui.Render(); CloneRenderData(); } public unsafe void Render(string windowName, string windowClass, string assetsFolderPath, string imguiIniConfigFolderPath, IConfigEntry<VirtualKey> overlayToggleKeybind, nint cimguiDllptr) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) ImGui.InitApi((INativeContext)new NativeLibraryContext((IntPtr)cimguiDllptr)); ImGuiIniConfigPath = Path.Combine(imguiIniConfigFolderPath, "iDeathHD.OverlayDearImGui_imgui.ini"); AssetsFolderPath = assetsFolderPath; OverlayToggle = overlayToggleKeybind; GameHwnd = User32.FindWindowW(windowClass, windowName); User32.GetWindowRect(GameHwnd, out _gameRect); (IntPtr hwnd, WNDCLASSEXW wc) tuple = WindowFactory.CreateClassicWindow("OverlayDearImGui"); IntPtr item = tuple.hwnd; WNDCLASSEXW item2 = tuple.wc; MARGINS margins = new MARGINS { cxLeftWidth = -1 }; Dwmapi.DwmExtendFrameIntoClientArea(item, ref margins); if (!CreateDeviceD3D(item)) { CleanupDeviceD3D(); User32.UnregisterClass(item2.lpszClassName, item2.hInstance); Log.Error("Failed CreateDeviceD3D", "C:\\Users\\Quentin\\Desktop\\overlay\\OverlayDearImGui\\OverlayDearImGui.Shared\\Overlay.cs", "Render", 381); return; } User32.ShowWindow(item, User32.ShowWindowCommand.ShowDefault); User32.UpdateWindow(item); ImGui.CreateContext(); ImGuiIOPtr iO = ImGui.GetIO(); ref ImGuiConfigFlags configFlags = ref ((ImGuiIOPtr)(ref iO)).ConfigFlags; configFlags = (ImGuiConfigFlags)((uint)configFlags | 0x83u); ((ImGuiIOPtr)(ref iO)).IniFilename = (byte*)(void*)Marshal.StringToHGlobalAnsi(ImGuiIniConfigPath); ImGui.StyleColorsDark(); string text = Path.Combine(AssetsFolderPath, "Fonts", "Bombardier-Regular.ttf"); ImFontPtr val = ((ImFontAtlasPtr)(ref ((ImGuiIOPtr)(ref iO)).Fonts)).AddFontFromFileTTF(text, 16f); ((ImGuiIOPtr)(ref iO)).FontDefault = val; ((ImFontAtlasPtr)(ref ((ImGuiIOPtr)(ref iO)).Fonts)).Build(); ImGuiWin32Impl.Init(item); ImGuiDX11Impl.Init((void*)((CppObject)_device).NativePointer, (void*)((CppObject)_deviceContext).NativePointer); bool flag = false; ToggleOverlay(item); RawVector4 val2 = default(RawVector4); ((RawVector4)(ref val2))..ctor(0f, 0f, 0f, 0f); bool flag2 = false; while (!flag2) { User32.MSG lpMsg; while (User32.PeekMessage(out lpMsg, item, 0u, 0u, 1u)) { User32.TranslateMessage(ref lpMsg); User32.DispatchMessage(ref lpMsg); if (lpMsg.message == WindowMessage.WM_QUIT) { flag2 = true; break; } } bool num = (User32.GetAsyncKeyState(OverlayToggle.Get()) & 0x8000) != 0; if (num && !flag) { ToggleOverlay(item); } flag = num; if (_resizeWidth != 0 && _resizeHeight != 0) { CleanupRenderTarget(); _swapChain.ResizeBuffers(0, (int)_resizeWidth, (int)_resizeHeight, (Format)0, (SwapChainFlags)0); _resizeWidth = (_resizeHeight = 0u); CreateRenderTarget(); } IntPtr foregroundWindow = User32.GetForegroundWindow(); if (!(foregroundWindow == item) && !(foregroundWindow == GameHwnd)) { Kernel32.Sleep(16u); } bool flag3 = User32.IsWindowVisible(GameHwnd); User32.ShowWindow(item, flag3 ? User32.ShowWindowCommand.Show : User32.ShowWindowCommand.Hide); if (!flag3) { Kernel32.Sleep(16u); } User32.GetWindowRect(GameHwnd, out var lpRect); if (lpRect.Left != GameRect.Left || lpRect.Bottom != GameRect.Bottom || lpRect.Top != GameRect.Top || lpRect.Right != GameRect.Right) { GameRect = lpRect; User32.SetWindowPos(item, (IntPtr)(-2), GameRect.X, GameRect.Y, GameRect.Width, GameRect.Height, 8u); } User32.SetWindowDisplayAffinity(item, User32.DisplayAffinity.None); _deviceContext.OutputMerger.SetRenderTargets(_mainRenderTargetView); _deviceContext.ClearRenderTargetView(_mainRenderTargetView, new RawColor4(val2.X, val2.Y, val2.Z, val2.W)); DisposableList<ClonedDrawData> disposableList = null; lock (_drawDataLock) { if (_nextFrameDrawData != null) { _currentRenderDrawData?.Dispose(); _currentRenderDrawData = _nextFrameDrawData; _nextFrameDrawData = null; } disposableList = _currentRenderDrawData; } if (disposableList != null && disposableList.Count > 0) { ImGuiDX11Impl.RenderDrawData(disposableList[0].Data); } _swapChain.Present(1, (PresentFlags)0); } ImGuiDX11Impl.Shutdown(); ImGuiWin32Impl.Shutdown(); ImGui.DestroyContext(); CleanupDeviceD3D(); User32.DestroyWindow(item); User32.UnregisterClass(item2.lpszClassName, item2.hInstance); } private static void ToggleOverlay(IntPtr hwnd) { IsOpen = !IsOpen; if (IsOpen) { User32.ShowWindow(hwnd, User32.ShowWindowCommand.Restore); User32.ShowWindow(hwnd, User32.ShowWindowCommand.Show); User32.SetForegroundWindow(hwnd); } else { User32.ShowWindow(hwnd, User32.ShowWindowCommand.Hide); User32.ShowWindow(hwnd, User32.ShowWindowCommand.Minimize); User32.BringWindowToTop(GameHwnd); User32.SetForegroundWindow(GameHwnd); } } public static IntPtr WndProc(IntPtr hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam) { if (ImGuiWin32Impl.WndProcHandler(hWnd, msg, wParam, lParam) != IntPtr.Zero) { return new IntPtr(1); } return User32.DefWindowProcW(hWnd, msg, wParam, lParam); } } } namespace OverlayDearImGui.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); [DllImport("dwmapi.dll")] public static extern int DwmExtendFrameIntoClientArea(IntPtr hwnd, ref MARGINS margins); } 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 User32 { public enum GetWindowType : uint { GW_HWNDFIRST, GW_HWNDLAST, GW_HWNDNEXT, GW_HWNDPREV, GW_OWNER, GW_CHILD, GW_ENABLEDPOPUP } public struct MSG { public IntPtr hwnd; public WindowMessage message; public IntPtr wParam; public IntPtr lParam; public uint time; public POINT pt; } public struct POINT { public int X; public int Y; public POINT(int x, int y) { X = x; Y = y; } } public enum SystemMetric { SM_ARRANGE = 56, SM_CLEANBOOT = 67, SM_CMONITORS = 80, SM_CMOUSEBUTTONS = 43, SM_CXBORDER = 5, SM_CXCURSOR = 13, SM_CXDLGFRAME = 7, SM_CXDOUBLECLK = 36, SM_CXDRAG = 68, SM_CXEDGE = 45, SM_CXFIXEDFRAME = 7, SM_CXFOCUSBORDER = 83, SM_CXFRAME = 32, SM_CXFULLSCREEN = 16, SM_CXHSCROLL = 21, SM_CXHTHUMB = 10, SM_CXICON = 11, SM_CXICONSPACING = 38, SM_CXMAXIMIZED = 61, SM_CXMAXTRACK = 59, SM_CXMENUCHECK = 71, SM_CXMENUSIZE = 54, SM_CXMIN = 28, SM_CXMINIMIZED = 57, SM_CXMINSPACING = 47, SM_CXMINTRACK = 34, SM_CXPADDEDBORDER = 92, SM_CXSCREEN = 0, SM_CXSIZE = 30, SM_CXSIZEFRAME = 32, SM_CXSMICON = 49, SM_CXSMSIZE = 52, SM_CXVIRTUALSCREEN = 78, SM_CXVSCROLL = 2, SM_CYBORDER = 6, SM_CYCAPTION = 4, SM_CYCURSOR = 14, SM_CYDLGFRAME = 8, SM_CYDOUBLECLK = 37, SM_CYDRAG = 69, SM_CYEDGE = 46, SM_CYFIXEDFRAME = 8, SM_CYFOCUSBORDER = 84, SM_CYFRAME = 33, SM_CYFULLSCREEN = 17, SM_CYHSCROLL = 3, SM_CYICON = 12, SM_CYICONSPACING = 39, SM_CYKANJIWINDOW = 18, SM_CYMAXIMIZED = 62, SM_CYMAXTRACK = 60, SM_CYMENU = 15, SM_CYMENUCHECK = 72, SM_CYMENUSIZE = 55, SM_CYMIN = 29, SM_CYMINIMIZED = 58, SM_CYMINSPACING = 48, SM_CYMINTRACK = 35, SM_CYSCREEN = 1, SM_CYSIZE = 31, SM_CYSIZEFRAME = 33, SM_CYSMCAPTION = 51, SM_CYSMICON = 50, SM_CYSMSIZE = 53, SM_CYVIRTUALSCREEN = 79, SM_CYVSCROLL = 20, SM_CYVTHUMB = 9, SM_DBCSENABLED = 42, SM_DEBUG = 22, SM_DIGITIZER = 94, SM_IMMENABLED = 82, SM_MAXIMUMTOUCHES = 95, SM_MEDIACENTER = 87, SM_MENUDROPALIGNMENT = 40, SM_MIDEASTENABLED = 74, SM_MOUSEPRESENT = 19, SM_MOUSEHORIZONTALWHEELPRESENT = 91, SM_MOUSEWHEELPRESENT = 75, SM_NETWORK = 63, SM_PENWINDOWS = 41, SM_REMOTECONTROL = 8193, SM_REMOTESESSION = 4096, SM_SAMEDISPLAYFORMAT = 81, SM_SECURE = 44, SM_SERVERR2 = 89, SM_SHOWSOUNDS = 70, SM_SHUTTINGDOWN = 8192, SM_SLOWMACHINE = 73, SM_STARTER = 88, SM_SWAPBUTTON = 23, SM_TABLETPC = 86, SM_XVIRTUALSCREEN = 76, SM_YVIRTUALSCREEN = 77 } [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 = Marshal.SizeOf(typeof(MonitorInfoEx)); DeviceName = string.Empty; } } public struct RectStruct { public int Left; public int Top; public int Right; public int Bottom; } public enum ShowWindowCommand { Hide, ShowNormal, ShowMinimized, ShowMaximized, ShowNoActivate, Show, Minimize, ShowMinNoActive, ShowNA, Restore, ShowDefault, ForceMinimize } public delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RectStruct lprcMonitor, IntPtr dwData); [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 DisplayAffinity : uint { None, Monitor } [Flags] public enum WindowStyles : uint { WS_BORDER = 0x800000u, WS_CAPTION = 0xC00000u, WS_CHILD = 0x40000000u, WS_CLIPCHILDREN = 0x2000000u, WS_CLIPSIBLINGS = 0x4000000u, WS_DISABLED = 0x8000000u, WS_DLGFRAME = 0x400000u, WS_GROUP = 0x20000u, WS_HSCROLL = 0x100000u, WS_MAXIMIZE = 0x1000000u, WS_MAXIMIZEBOX = 0x10000u, WS_MINIMIZE = 0x20000000u, WS_MINIMIZEBOX = 0x20000u, WS_OVERLAPPED = 0u, WS_OVERLAPPEDWINDOW = 0xCF0000u, WS_POPUP = 0x80000000u, WS_POPUPWINDOW = 0x80880000u, WS_SIZEFRAME = 0x40000u, WS_SYSMENU = 0x80000u, WS_TABSTOP = 0x10000u, WS_VISIBLE = 0x10000000u, WS_VSCROLL = 0x200000u } [Flags] public enum WindowStylesEx : uint { WS_EX_ACCEPTFILES = 0x10u, WS_EX_APPWINDOW = 0x40000u, WS_EX_CLIENTEDGE = 0x200u, WS_EX_COMPOSITED = 0x2000000u, WS_EX_CONTEXTHELP = 0x400u, WS_EX_CONTROLPARENT = 0x10000u, WS_EX_DLGMODALFRAME = 1u, WS_EX_LAYERED = 0x80000u, WS_EX_LAYOUTRTL = 0x400000u, WS_EX_LEFT = 0u, WS_EX_LEFTSCROLLBAR = 0x4000u, WS_EX_LTRREADING = 0u, WS_EX_MDICHILD = 0x40u, WS_EX_NOACTIVATE = 0x8000000u, WS_EX_NOINHERITLAYOUT = 0x100000u, WS_EX_NOPARENTNOTIFY = 4u, WS_EX_OVERLAPPEDWINDOW = 0x300u, WS_EX_PALETTEWINDOW = 0x188u, WS_EX_RIGHT = 0x1000u, WS_EX_RIGHTSCROLLBAR = 0u, WS_EX_RTLREADING = 0x2000u, WS_EX_STATICEDGE = 0x20000u, WS_EX_TOOLWINDOW = 0x80u, WS_EX_TOPMOST = 8u, WS_EX_TRANSPARENT = 0x20u, WS_EX_WINDOWEDGE = 0x100u } public const int CS_HREDRAW = 2; public const int CS_VREDRAW = 1; private const int CCHDEVICENAME = 32; public const uint SWP_NOREDRAW = 8u; public const int GWL_EXSTYLE = -20; public const uint PM_REMOVE = 1u; [DllImport("user32.dll")] public static extern IntPtr SetThreadDpiAwarenessContext(IntPtr dpiContext); [DllImport("user32.dll", SetLastError = true)] public static extern bool GetWindowRect(IntPtr hwnd, out RECT lpRect); [DllImport("user32.dll")] public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags); [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool UnregisterClass(string lpClassName, IntPtr hInstance); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsWindowVisible(IntPtr hWnd); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr SetFocus(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow); [DllImport("user32.dll")] public static extern bool BringWindowToTop(IntPtr hWnd); [DllImport("user32.dll")] public static extern bool UpdateWindow(IntPtr hWnd); [DllImport("user32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] public static extern IntPtr DefWindowProcW(IntPtr hWnd, WindowMessage uMsg, IntPtr wParam, IntPtr lParam); [DllImport("user32.dll")] public static extern void PostQuitMessage(int nExitCode); [DllImport("user32.dll")] public static extern IntPtr GetThreadDpiAwarenessContext(); [DllImport("user32.dll")] public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool GetMonitorInfo(IntPtr hMonitor, ref MonitorInfoEx lpmi); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.U2)] public static extern short RegisterClassEx([In] ref WNDCLASSEXW lpwcx); [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hWnd); [DllImport("user32.dll")] public static extern int GetSystemMetrics(SystemMetric smIndex); [DllImport("user32.dll")] public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, EnumMonitorsDelegate lpfnEnum, IntPtr dwData); [DllImport("user32.dll")] public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC); [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", CharSet = CharSet.Unicode, SetLastError = true)] public static extern ushort RegisterClassExW(ref WNDCLASSEXW lpwcx); [DllImport("user32.dll", SetLastError = true)] public static extern bool SetProcessDPIAware(); [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr FindWindowW(string lpClassName, string lpWindowName); [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern int MessageBox(IntPtr hWnd, string text, string caption, int options); [DllImport("user32.dll")] public static extern bool AdjustWindowRectEx(ref RECT lpRect, WindowStyles dwStyle, bool bMenu, WindowStylesEx dwExStyle); [DllImport("user32.dll")] public static extern short GetAsyncKeyState(VirtualKey vKey); public static IntPtr CreateWindowW([Optional][In] string lpClassName, [Optional][In] string lpWindowName, [In] uint dwStyle, [In] int X, [In] int Y, [In] int nWidth, [In] int nHeight, [Optional][In] IntPtr hWndParent, [Optional][In] IntPtr hMenu, [Optional][In] IntPtr hInstance, [Optional][In] IntPtr lpParam) { return CreateWindowExW(WindowStylesEx.WS_EX_LEFT, lpClassName, lpWindowName, (WindowStyles)dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); } [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")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsIconic(IntPtr hWnd); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool SetWindowText(IntPtr hwnd, string lpString); [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] public static extern IntPtr CreateWindowExW(WindowStylesEx dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, WindowStyles dwStyle, int X, int Y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam); [DllImport("user32.dll", SetLastError = true)] public static extern IntPtr GetWindow(IntPtr hWnd, GetWindowType uCmd); [DllImport("user32.dll", SetLastError = true)] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); [DllImport("user32.dll")] public static extern bool SetWindowDisplayAffinity(IntPtr hwnd, DisplayAffinity affinity); [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DestroyWindow(IntPtr hwnd); [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PostMessage(IntPtr hWnd, WindowMessage Msg, IntPtr wParam, IntPtr lParam); public static IntPtr SetWindowLongPtr(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")] private static extern int SetWindowLong32(HandleRef hWnd, int nIndex, int dwNewLong); [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")] private static extern IntPtr SetWindowLongPtr64(HandleRef hWnd, int nIndex, IntPtr dwNewLong); [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 DispatchMessage([In] ref MSG lpmsg); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)]
plugins/OverlayDearImGui.Shared/SharpDX.Direct3D11.dll
Decompiled a month 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
plugins/OverlayDearImGui.Shared/SharpDX.dll
Decompiled a month 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
plugins/OverlayDearImGui.Shared/SharpDX.DXGI.dll
Decompiled a month 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
plugins/OverlayDearImGui.Shared/System.Memory.dll
Decompiled a month 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.Runtime.Versioning; 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: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: CLSCompliant(true)] [assembly: AssemblyDefaultAlias("System.Memory")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Memory")] [assembly: AssemblyFileVersion("4.600.24.56208")] [assembly: AssemblyInformationalVersion("4.6.0+d0c2a5a83211e271826172a6b0510c25a52dbd53")] [assembly: AssemblyProduct("Microsoft® .NET")] [assembly: AssemblyTitle("System.Memory")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/maintenance-packages")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Embedded] internal sealed class IsByRefLikeAttribute : Attribute { } [CompilerGenerated] [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] [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] [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 FxResources.System.Memory { internal static class SR { } } namespace System { [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(in MemoryMarshal.GetReference(span), in 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(in MemoryMarshal.GetReference(span), in 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* reference = &MemoryMarshal.GetReference(strA)) { fixed (char* reference2 = &MemoryMarshal.GetReference(strB)) { char* ptr = reference; char* ptr2 = reference2; while (num != 0 && *ptr <= '\u007f' && *ptr2 <= '\u007f') { int num3 = *ptr; int num4 = *ptr2; if (num3 == num4) { ptr++; ptr2++; num--; continue; } if ((uint)(num3 - 97) <= 25u) { num3 -= 32; } if ((uint)(num4 - 97) <= 25u) { num4 -= 32; } if (num3 != num4) { return num3 - num4; } ptr++; ptr2++; 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(in Unsafe.As<Pinnable<char>>(text).Data, in Unsafe.AsRef<char>(source)); } } } internal struct MutableDecimal { public uint Flags; public uint High; public uint Low; public uint Mid; private const uint SignMask = 2147483648u; private const uint ScaleMask = 16711680u; private const int ScaleShift = 16; public bool IsNegative { get { return (Flags & 0x80000000u) != 0; } set { Flags = (Flags & 0x7FFFFFFF) | (uint)(value ? int.MinValue : 0); } } public int Scale { get { return (byte)(Flags >> 16); } set { Flags = (Flags & 0xFF00FFFFu) | (uint)(value << 16); } } } internal struct NUInt { private unsafe readonly void* _value; private unsafe NUInt(uint value) { _value = (void*)value; } private unsafe NUInt(ulong value) { _value = (void*)value; } public static implicit operator NUInt(uint value) { return new NUInt(value); } public unsafe static implicit operator IntPtr(NUInt value) { return (IntPtr)value._value; } public static explicit operator NUInt(int value) { return new NUInt((uint)value); } public unsafe static explicit operator void*(NUInt value) { return value._value; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static NUInt operator *(NUInt left, NUInt right) { if (sizeof(IntPtr) != 4) { return new NUInt((ulong)left._value * (ulong)right._value); } return new NUInt((uint)((int)left._value * (int)right._value)); } } 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*)(&d))[1] >> 20) & 0x7FF; } public unsafe static ulong Mantissa(double d) { return (uint)(*(int*)(&d)) | ((ulong)(((uint*)(&d))[1] & 0xFFFFF) << 32); } public unsafe static bool Sign(double d) { return ((uint*)(&d))[1] >> 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 (((int)num3 & 0x400) != 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(); } } [StructLayout(LayoutKind.Sequential)] internal sealed class Pinnable<T> { public T Data; } [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(in left.DangerousGetPinnableReference(), in 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); } } 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); } } [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(in left.DangerousGetPinnableReference(), in 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(in Unsafe.As<Pinnable<T>>(array).Data, in 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>>(in 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 != Unsafe.AddByteOffset(ref searchSpace, intPtr)) { continue; } goto IL_0254; } if (Vector.IsHardwareAccelerated && (void*)intPtr != null) { intPtr2 = (IntPtr)((int)(void*)intPtr & ~(Vector<byte>.Count - 1)); Vector<byte> vector = GetVector(value); for (; (nuint)(void*)intPtr2 > (nuint)(Vector<byte>.Count - 1); intPtr2 -= Vector<byte>.Count) { Vector<byte> vector2 = Vector.Equals(vector, Unsafe.ReadUnaligned<Vector<byte>>(in Unsafe.AddByteOffset(ref searchSpace, intPtr - Vector<byte>.Count))); if (Vector<byte>.Zero.Equals(vector2)) { intPtr -= Vector<byte>.Count; continue; } return (int)intPtr - Vector<byte>.Count + LocateLastFoundByte(vector2); } if ((void*)intPtr != null) { intPtr2 = intPtr; continue; } } return -1; IL_0254: return (int)(void*)intPtr; IL_026a: return (int)(void*)(intPtr + 2); IL_0278: return (int)(void*)(intPtr + 3); IL_025c: return (int)(void*)(intPtr + 1); } return (int)(void*)(intPtr + 7); } public unsafe static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, 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; uint num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr); if (value0 == num2 || value1 == num2) { goto IL_02ff; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 1); if (value0 == num2 || value1 == num2) { goto IL_0307; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 2); if (value0 == num2 || value1 == num2) { goto IL_0315; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 3); if (value0 != num2 && value1 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 4); if (value0 != num2 && value1 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 5); if (value0 != num2 && value1 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 6); if (value0 != num2 && value1 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 7); if (value0 == num2 || value1 == num2) { break; } intPtr += 8; continue; } return (int)(void*)(intPtr + 6); } return (int)(void*)(intPtr + 5); } return (int)(void*)(intPtr + 4); } goto IL_0323; } if ((nuint)(void*)intPtr2 >= (nuint)4u) { intPtr2 -= 4; uint num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr); if (value0 == num2 || value1 == num2) { goto IL_02ff; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 1); if (value0 == num2 || value1 == num2) { goto IL_0307; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 2); if (value0 == num2 || value1 == num2) { goto IL_0315; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 3); if (value0 == num2 || value1 == num2) { goto IL_0323; } intPtr += 4; } while ((void*)intPtr2 != null) { intPtr2 -= 1; uint num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr); if (value0 != num2 && value1 != num2) { intPtr += 1; continue; } goto IL_02ff; } if (Vector.IsHardwareAccelerated && (int)(void*)intPtr < length) { intPtr2 = (IntPtr)((length - (int)(void*)intPtr) & ~(Vector<byte>.Count - 1)); Vector<byte> vector = GetVector(value0); Vector<byte> vector2 = GetVector(value1); for (; (void*)intPtr2 > (void*)intPtr; intPtr += Vector<byte>.Count) { Vector<byte> left = Unsafe.ReadUnaligned<Vector<byte>>(in Unsafe.AddByteOffset(ref searchSpace, intPtr)); Vector<byte> vector3 = Vector.BitwiseOr(Vector.Equals(left, vector), Vector.Equals(left, vector2)); if (!Vector<byte>.Zero.Equals(vector3)) { return (int)(void*)intPtr + LocateFirstFoundByte(vector3); } } if ((int)(void*)intPtr < length) { intPtr2 = (IntPtr)(length - (int)(void*)intPtr); continue; } } return -1; IL_02ff: return (int)(void*)intPtr; IL_0315: return (int)(void*)(intPtr + 2); IL_0307: return (int)(void*)(intPtr + 1); IL_0323: return (int)(void*)(intPtr + 3); } return (int)(void*)(intPtr + 7); } public unsafe static int IndexOfAny(ref byte searchSpace, byte value0, byte value1, byte value2, 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; uint num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr); if (value0 == num2 || value1 == num2 || value2 == num2) { goto IL_0393; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 1); if (value0 == num2 || value1 == num2 || value2 == num2) { goto IL_039b; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 2); if (value0 == num2 || value1 == num2 || value2 == num2) { goto IL_03a9; } num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 3); if (value0 != num2 && value1 != num2 && value2 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 4); if (value0 != num2 && value1 != num2 && value2 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 5); if (value0 != num2 && value1 != num2 && value2 != num2) { num2 = Unsafe.AddByteOffset(ref searchSpace, intPtr + 6); if (value0
plugins/OverlayDearImGui.Shared/System.Numerics.Vectors.dll
Decompiled a month 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.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using FxResources.System.Numerics.Vectors; 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: CLSCompliant(true)] [assembly: AssemblyDefaultAlias("System.Numerics.Vectors")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.System32 | DllImportSearchPath.AssemblyDirectory)] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyDescription("System.Numerics.Vectors")] [assembly: AssemblyFileVersion("4.600.24.56208")] [assembly: AssemblyInformationalVersion("4.6.0+d0c2a5a83211e271826172a6b0510c25a52dbd53")] [assembly: AssemblyProduct("Microsoft® .NET")] [assembly: AssemblyTitle("System.Numerics.Vectors")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/dotnet/maintenance-packages")] [assembly: AssemblyMetadata("PreferInbox", "True")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("4.1.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 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 Pow(float x, float y) { return (float)Math.Pow(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 readonly bool s_usingResourceKeys = AppContext.TryGetSwitch("System.Resources.UseSystemResourceKeys", out var isEnabled) && isEnabled; private static ResourceManager s_resourceManager; internal static ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new ResourceManager(typeof(SR))); internal static string Arg_ArgumentOutOfRangeException => GetResourceString("Arg_ArgumentOutOfRangeException"); internal static string Arg_ElementsInSourceIsGreaterThanDestination => GetResourceString("Arg_ElementsInSourceIsGreaterThanDestination"); internal static string Arg_NullArgumentNullRef => GetResourceString("Arg_NullArgumentNullRef"); internal static string Arg_TypeNotSupported => GetResourceString("Arg_TypeNotSupported"); internal static string Arg_InsufficientNumberOfElements => GetResourceString("Arg_InsufficientNumberOfElements"); private static bool UsingResourceKeys() { return s_usingResourceKeys; } internal static string GetResourceString(string resourceKey) { if (UsingResourceKeys()) { return resourceKey; } string result = null; try { result = ResourceManager.GetString(resourceKey); } catch (MissingManifestResourceException) { } return result; } internal static string GetResourceString(string resourceKey, string defaultString) { string resourceString = GetResourceString(resourceKey); if (!(resourceKey == resourceString) && resourceString != null) { return resourceString; } return defaultString; } 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.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Field, Inherited = false)] internal sealed class IntrinsicAttribute : 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; } } public struct Matrix3x2 : IEquatable<Matrix3x2> { public float M11; public float M12; public float M21; public float M22; public float M31; public float M32; private static readonly Matrix3x2 _identity = new Matrix3x2(1f, 0f, 0f, 1f, 0f, 0f); public static Matrix3x2 Identity => _identity; public bool IsIdentity { get { if (M11 == 1f && M22 == 1f && M12 == 0f && M21 == 0f && M31 == 0f) { return M32 == 0f; } return false; } } public Vector2 Translation { get { return new Vector2(M31, M32); } set { M31 = value.X; M32 = value.Y; } } public Matrix3x2(float m11, float m12, float m21, float m22, float m31, float m32) { M11 = m11; M12 = m12; M21 = m21; M22 = m22; M31 = m31; M32 = m32; } public static Matrix3x2 CreateTranslation(Vector2 position) { Matrix3x2 result = default(Matrix3x2); result.M11 = 1f; result.M12 = 0f; result.M21 = 0f; result.M22 = 1f; result.M31 = position.X; result.M32 = position.Y; return result; } public static Matrix3x2 CreateTranslation(float xPosition, float yPosition) { Matrix3x2 result = default(Matrix3x2); result.M11 = 1f; result.M12 = 0f; result.M21 = 0f; result.M22 = 1f; result.M31 = xPosition; result.M32 = yPosition; return result; } public static Matrix3x2 CreateScale(float xScale, float yScale) { Matrix3x2 result = default(Matrix3x2); result.M11 = xScale; result.M12 = 0f; result.M21 = 0f; result.M22 = yScale; result.M31 = 0f; result.M32 = 0f; return result; } public static Matrix3x2 CreateScale(float xScale, float yScale, Vector2 centerPoint) { float m = centerPoint.X * (1f - xScale); float m2 = centerPoint.Y * (1f - yScale); Matrix3x2 result = default(Matrix3x2); result.M11 = xScale; result.M12 = 0f; result.M21 = 0f; result.M22 = yScale; result.M31 = m; result.M32 = m2; return result; } public static Matrix3x2 CreateScale(Vector2 scales) { Matrix3x2 result = default(Matrix3x2); result.M11 = scales.X; result.M12 = 0f; result.M21 = 0f; result.M22 = scales.Y; result.M31 = 0f; result.M32 = 0f; return result; } public static Matrix3x2 CreateScale(Vector2 scales, Vector2 centerPoint) { float m = centerPoint.X * (1f - scales.X); float m2 = centerPoint.Y * (1f - scales.Y); Matrix3x2 result = default(Matrix3x2); result.M11 = scales.X; result.M12 = 0f; result.M21 = 0f; result.M22 = scales.Y; result.M31 = m; result.M32 = m2; return result; } public static Matrix3x2 CreateScale(float scale) { Matrix3x2 result = default(Matrix3x2); result.M11 = scale; result.M12 = 0f; result.M21 = 0f; result.M22 = scale; result.M31 = 0f; result.M32 = 0f; return result; } public static Matrix3x2 CreateScale(float scale, Vector2 centerPoint) { float m = centerPoint.X * (1f - scale); float m2 = centerPoint.Y * (1f - scale); Matrix3x2 result = default(Matrix3x2); result.M11 = scale; result.M12 = 0f; result.M21 = 0f; result.M22 = scale; result.M31 = m; result.M32 = m2; return result; } public static Matrix3x2 CreateSkew(float radiansX, float radiansY) { float m = MathF.Tan(radiansX); float m2 = MathF.Tan(radiansY); Matrix3x2 result = default(Matrix3x2); result.M11 = 1f; result.M12 = m2; result.M21 = m; result.M22 = 1f; result.M31 = 0f; result.M32 = 0f; return result; } public static Matrix3x2 CreateSkew(float radiansX, float radiansY, Vector2 centerPoint) { float num = MathF.Tan(radiansX); float num2 = MathF.Tan(radiansY); float m = (0f - centerPoint.Y) * num; float m2 = (0f - centerPoint.X) * num2; Matrix3x2 result = default(Matrix3x2); result.M11 = 1f; result.M12 = num2; result.M21 = num; result.M22 = 1f; result.M31 = m; result.M32 = m2; return result; } public static Matrix3x2 CreateRotation(float radians) { radians = MathF.IEEERemainder(radians, (float)Math.PI * 2f); float num; float num2; if (radians > -1.7453294E-05f && radians < 1.7453294E-05f) { num = 1f; num2 = 0f; } else if (radians > 1.570779f && radians < 1.5708138f) { num = 0f; num2 = 1f; } else if (radians < -3.1415753f || radians > 3.1415753f) { num = -1f; num2 = 0f; } else if (radians > -1.5708138f && radians < -1.570779f) { num = 0f; num2 = -1f; } else { num = MathF.Cos(radians); num2 = MathF.Sin(radians); } Matrix3x2 result = default(Matrix3x2); result.M11 = num; result.M12 = num2; result.M21 = 0f - num2; result.M22 = num; result.M31 = 0f; result.M32 = 0f; return result; } public static Matrix3x2 CreateRotation(float radians, Vector2 centerPoint) { radians = MathF.IEEERemainder(radians, (float)Math.PI * 2f); float num; float num2; if (radians > -1.7453294E-05f && radians < 1.7453294E-05f) { num = 1f; num2 = 0f; } else if (radians > 1.570779f && radians < 1.5708138f) { num = 0f; num2 = 1f; } else if (radians < -3.1415753f || radians > 3.1415753f) { num = -1f; num2 = 0f; } else if (radians > -1.5708138f && radians < -1.570779f) { num = 0f; num2 = -1f; } else { num = MathF.Cos(radians); num2 = MathF.Sin(radians); } float m = centerPoint.X * (1f - num) + centerPoint.Y * num2; float m2 = centerPoint.Y * (1f - num) - centerPoint.X * num2; Matrix3x2 result = default(Matrix3x2); result.M11 = num; result.M12 = num2; result.M21 = 0f - num2; result.M22 = num; result.M31 = m; result.M32 = m2; return result; } public float GetDeterminant() { return M11 * M22 - M21 * M12; } public static bool Invert(Matrix3x2 matrix, out Matrix3x2 result) { float num = matrix.M11 * matrix.M22 - matrix.M21 * matrix.M12; if (MathF.Abs(num) < float.Epsilon) { result = new Matrix3x2(float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN); return false; } float num2 = 1f / num; result.M11 = matrix.M22 * num2; result.M12 = (0f - matrix.M12) * num2; result.M21 = (0f - matrix.M21) * num2; result.M22 = matrix.M11 * num2; result.M31 = (matrix.M21 * matrix.M32 - matrix.M31 * matrix.M22) * num2; result.M32 = (matrix.M31 * matrix.M12 - matrix.M11 * matrix.M32) * num2; return true; } public static Matrix3x2 Lerp(Matrix3x2 matrix1, Matrix3x2 matrix2, float amount) { Matrix3x2 result = default(Matrix3x2); result.M11 = matrix1.M11 + (matrix2.M11 - matrix1.M11) * amount; result.M12 = matrix1.M12 + (matrix2.M12 - matrix1.M12) * amount; result.M21 = matrix1.M21 + (matrix2.M21 - matrix1.M21) * amount; result.M22 = matrix1.M22 + (matrix2.M22 - matrix1.M22) * amount; result.M31 = matrix1.M31 + (matrix2.M31 - matrix1.M31) * amount; result.M32 = matrix1.M32 + (matrix2.M32 - matrix1.M32) * amount; return result; } public static Matrix3x2 Negate(Matrix3x2 value) { Matrix3x2 result = default(Matrix3x2); result.M11 = 0f - value.M11; result.M12 = 0f - value.M12; result.M21 = 0f - value.M21; result.M22 = 0f - value.M22; result.M31 = 0f - value.M31; result.M32 = 0f - value.M32; return result; } public static Matrix3x2 Add(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 + value2.M11; result.M12 = value1.M12 + value2.M12; result.M21 = value1.M21 + value2.M21; result.M22 = value1.M22 + value2.M22; result.M31 = value1.M31 + value2.M31; result.M32 = value1.M32 + value2.M32; return result; } public static Matrix3x2 Subtract(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 - value2.M11; result.M12 = value1.M12 - value2.M12; result.M21 = value1.M21 - value2.M21; result.M22 = value1.M22 - value2.M22; result.M31 = value1.M31 - value2.M31; result.M32 = value1.M32 - value2.M32; return result; } public static Matrix3x2 Multiply(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21; result.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22; result.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21; result.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22; result.M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value2.M31; result.M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value2.M32; return result; } public static Matrix3x2 Multiply(Matrix3x2 value1, float value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 * value2; result.M12 = value1.M12 * value2; result.M21 = value1.M21 * value2; result.M22 = value1.M22 * value2; result.M31 = value1.M31 * value2; result.M32 = value1.M32 * value2; return result; } public static Matrix3x2 operator -(Matrix3x2 value) { Matrix3x2 result = default(Matrix3x2); result.M11 = 0f - value.M11; result.M12 = 0f - value.M12; result.M21 = 0f - value.M21; result.M22 = 0f - value.M22; result.M31 = 0f - value.M31; result.M32 = 0f - value.M32; return result; } public static Matrix3x2 operator +(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 + value2.M11; result.M12 = value1.M12 + value2.M12; result.M21 = value1.M21 + value2.M21; result.M22 = value1.M22 + value2.M22; result.M31 = value1.M31 + value2.M31; result.M32 = value1.M32 + value2.M32; return result; } public static Matrix3x2 operator -(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 - value2.M11; result.M12 = value1.M12 - value2.M12; result.M21 = value1.M21 - value2.M21; result.M22 = value1.M22 - value2.M22; result.M31 = value1.M31 - value2.M31; result.M32 = value1.M32 - value2.M32; return result; } public static Matrix3x2 operator *(Matrix3x2 value1, Matrix3x2 value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21; result.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22; result.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21; result.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22; result.M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value2.M31; result.M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value2.M32; return result; } public static Matrix3x2 operator *(Matrix3x2 value1, float value2) { Matrix3x2 result = default(Matrix3x2); result.M11 = value1.M11 * value2; result.M12 = value1.M12 * value2; result.M21 = value1.M21 * value2; result.M22 = value1.M22 * value2; result.M31 = value1.M31 * value2; result.M32 = value1.M32 * value2; return result; } public static bool operator ==(Matrix3x2 value1, Matrix3x2 value2) { if (value1.M11 == value2.M11 && value1.M22 == value2.M22 && value1.M12 == value2.M12 && value1.M21 == value2.M21 && value1.M31 == value2.M31) { return value1.M32 == value2.M32; } return false; } public static bool operator !=(Matrix3x2 value1, Matrix3x2 value2) { if (value1.M11 == value2.M11 && value1.M12 == value2.M12 && value1.M21 == value2.M21 && value1.M22 == value2.M22 && value1.M31 == value2.M31) { return value1.M32 != value2.M32; } return true; } public bool Equals(Matrix3x2 other) { if (M11 == other.M11 && M22 == other.M22 && M12 == other.M12 && M21 == other.M21 && M31 == other.M31) { return M32 == other.M32; } return false; } public override bool Equals(object obj) { if (obj is Matrix3x2) { return Equals((Matrix3x2)obj); } return false; } public override string ToString() { CultureInfo currentCulture = CultureInfo.CurrentCulture; return string.Format(currentCulture, "{{ {{M11:{0} M12:{1}}} {{M21:{2} M22:{3}}} {{M31:{4} M32:{5}}} }}", M11.ToString(currentCulture), M12.ToString(currentCulture), M21.ToString(currentCulture), M22.ToString(currentCulture), M31.ToString(currentCulture), M32.ToString(currentCulture)); } public override int GetHashCode() { return M11.GetHashCode() + M12.GetHashCode() + M21.GetHashCode() + M22.GetHashCode() + M31.GetHashCode() + M32.GetHashCode(); } } public struct Matrix4x4 : IEquatable<Matrix4x4> { private struct CanonicalBasis { public Vector3 Row0; public Vector3 Row1; public Vector3 Row2; } private struct VectorBasis { public unsafe Vector3* Element0; public unsafe Vector3* Element1; public unsafe Vector3* Element2; } public float M11; public float M12; public float M13; public float M14; public float M21; public float M22; public float M23; public float M24; public float M31; public float M32; public float M33; public float M34; public float M41; public float M42; public float M43; public float M44; private static readonly Matrix4x4 _identity = new Matrix4x4(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f); public static Matrix4x4 Identity => _identity; public bool IsIdentity { get { if (M11 == 1f && M22 == 1f && M33 == 1f && M44 == 1f && M12 == 0f && M13 == 0f && M14 == 0f && M21 == 0f && M23 == 0f && M24 == 0f && M31 == 0f && M32 == 0f && M34 == 0f && M41 == 0f && M42 == 0f) { return M43 == 0f; } return false; } } public Vector3 Translation { get { return new Vector3(M41, M42, M43); } set { M41 = value.X; M42 = value.Y; M43 = value.Z; } } public Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) { M11 = m11; M12 = m12; M13 = m13; M14 = m14; M21 = m21; M22 = m22; M23 = m23; M24 = m24; M31 = m31; M32 = m32; M33 = m33; M34 = m34; M41 = m41; M42 = m42; M43 = m43; M44 = m44; } public Matrix4x4(Matrix3x2 value) { M11 = value.M11; M12 = value.M12; M13 = 0f; M14 = 0f; M21 = value.M21; M22 = value.M22; M23 = 0f; M24 = 0f; M31 = 0f; M32 = 0f; M33 = 1f; M34 = 0f; M41 = value.M31; M42 = value.M32; M43 = 0f; M44 = 1f; } public static Matrix4x4 CreateBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 cameraUpVector, Vector3 cameraForwardVector) { Vector3 left = new Vector3(objectPosition.X - cameraPosition.X, objectPosition.Y - cameraPosition.Y, objectPosition.Z - cameraPosition.Z); float num = left.LengthSquared(); left = ((!(num < 0.0001f)) ? Vector3.Multiply(left, 1f / MathF.Sqrt(num)) : (-cameraForwardVector)); Vector3 vector = Vector3.Normalize(Vector3.Cross(cameraUpVector, left)); Vector3 vector2 = Vector3.Cross(left, vector); Matrix4x4 result = default(Matrix4x4); result.M11 = vector.X; result.M12 = vector.Y; result.M13 = vector.Z; result.M14 = 0f; result.M21 = vector2.X; result.M22 = vector2.Y; result.M23 = vector2.Z; result.M24 = 0f; result.M31 = left.X; result.M32 = left.Y; result.M33 = left.Z; result.M34 = 0f; result.M41 = objectPosition.X; result.M42 = objectPosition.Y; result.M43 = objectPosition.Z; result.M44 = 1f; return result; } public static Matrix4x4 CreateConstrainedBillboard(Vector3 objectPosition, Vector3 cameraPosition, Vector3 rotateAxis, Vector3 cameraForwardVector, Vector3 objectForwardVector) { Vector3 left = new Vector3(objectPosition.X - cameraPosition.X, objectPosition.Y - cameraPosition.Y, objectPosition.Z - cameraPosition.Z); float num = left.LengthSquared(); left = ((!(num < 0.0001f)) ? Vector3.Multiply(left, 1f / MathF.Sqrt(num)) : (-cameraForwardVector)); Vector3 vector = rotateAxis; float x = Vector3.Dot(rotateAxis, left); Vector3 vector3; Vector3 vector2; if (MathF.Abs(x) > 0.99825466f) { vector2 = objectForwardVector; x = Vector3.Dot(rotateAxis, vector2); if (MathF.Abs(x) > 0.99825466f) { vector2 = ((MathF.Abs(rotateAxis.Z) > 0.99825466f) ? new Vector3(1f, 0f, 0f) : new Vector3(0f, 0f, -1f)); } vector3 = Vector3.Normalize(Vector3.Cross(rotateAxis, vector2)); vector2 = Vector3.Normalize(Vector3.Cross(vector3, rotateAxis)); } else { vector3 = Vector3.Normalize(Vector3.Cross(rotateAxis, left)); vector2 = Vector3.Normalize(Vector3.Cross(vector3, vector)); } Matrix4x4 result = default(Matrix4x4); result.M11 = vector3.X; result.M12 = vector3.Y; result.M13 = vector3.Z; result.M14 = 0f; result.M21 = vector.X; result.M22 = vector.Y; result.M23 = vector.Z; result.M24 = 0f; result.M31 = vector2.X; result.M32 = vector2.Y; result.M33 = vector2.Z; result.M34 = 0f; result.M41 = objectPosition.X; result.M42 = objectPosition.Y; result.M43 = objectPosition.Z; result.M44 = 1f; return result; } public static Matrix4x4 CreateTranslation(Vector3 position) { Matrix4x4 result = default(Matrix4x4); result.M11 = 1f; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = 1f; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = 1f; result.M34 = 0f; result.M41 = position.X; result.M42 = position.Y; result.M43 = position.Z; result.M44 = 1f; return result; } public static Matrix4x4 CreateTranslation(float xPosition, float yPosition, float zPosition) { Matrix4x4 result = default(Matrix4x4); result.M11 = 1f; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = 1f; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = 1f; result.M34 = 0f; result.M41 = xPosition; result.M42 = yPosition; result.M43 = zPosition; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(float xScale, float yScale, float zScale) { Matrix4x4 result = default(Matrix4x4); result.M11 = xScale; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = yScale; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = zScale; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(float xScale, float yScale, float zScale, Vector3 centerPoint) { float m = centerPoint.X * (1f - xScale); float m2 = centerPoint.Y * (1f - yScale); float m3 = centerPoint.Z * (1f - zScale); Matrix4x4 result = default(Matrix4x4); result.M11 = xScale; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = yScale; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = zScale; result.M34 = 0f; result.M41 = m; result.M42 = m2; result.M43 = m3; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(Vector3 scales) { Matrix4x4 result = default(Matrix4x4); result.M11 = scales.X; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = scales.Y; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = scales.Z; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(Vector3 scales, Vector3 centerPoint) { float m = centerPoint.X * (1f - scales.X); float m2 = centerPoint.Y * (1f - scales.Y); float m3 = centerPoint.Z * (1f - scales.Z); Matrix4x4 result = default(Matrix4x4); result.M11 = scales.X; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = scales.Y; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = scales.Z; result.M34 = 0f; result.M41 = m; result.M42 = m2; result.M43 = m3; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(float scale) { Matrix4x4 result = default(Matrix4x4); result.M11 = scale; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = scale; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = scale; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateScale(float scale, Vector3 centerPoint) { float m = centerPoint.X * (1f - scale); float m2 = centerPoint.Y * (1f - scale); float m3 = centerPoint.Z * (1f - scale); Matrix4x4 result = default(Matrix4x4); result.M11 = scale; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = scale; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = scale; result.M34 = 0f; result.M41 = m; result.M42 = m2; result.M43 = m3; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationX(float radians) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); Matrix4x4 result = default(Matrix4x4); result.M11 = 1f; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = num; result.M23 = num2; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f - num2; result.M33 = num; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationX(float radians, Vector3 centerPoint) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); float m = centerPoint.Y * (1f - num) + centerPoint.Z * num2; float m2 = centerPoint.Z * (1f - num) - centerPoint.Y * num2; Matrix4x4 result = default(Matrix4x4); result.M11 = 1f; result.M12 = 0f; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f; result.M22 = num; result.M23 = num2; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f - num2; result.M33 = num; result.M34 = 0f; result.M41 = 0f; result.M42 = m; result.M43 = m2; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationY(float radians) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); Matrix4x4 result = default(Matrix4x4); result.M11 = num; result.M12 = 0f; result.M13 = 0f - num2; result.M14 = 0f; result.M21 = 0f; result.M22 = 1f; result.M23 = 0f; result.M24 = 0f; result.M31 = num2; result.M32 = 0f; result.M33 = num; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationY(float radians, Vector3 centerPoint) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); float m = centerPoint.X * (1f - num) - centerPoint.Z * num2; float m2 = centerPoint.Z * (1f - num) + centerPoint.X * num2; Matrix4x4 result = default(Matrix4x4); result.M11 = num; result.M12 = 0f; result.M13 = 0f - num2; result.M14 = 0f; result.M21 = 0f; result.M22 = 1f; result.M23 = 0f; result.M24 = 0f; result.M31 = num2; result.M32 = 0f; result.M33 = num; result.M34 = 0f; result.M41 = m; result.M42 = 0f; result.M43 = m2; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationZ(float radians) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); Matrix4x4 result = default(Matrix4x4); result.M11 = num; result.M12 = num2; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f - num2; result.M22 = num; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = 1f; result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateRotationZ(float radians, Vector3 centerPoint) { float num = MathF.Cos(radians); float num2 = MathF.Sin(radians); float m = centerPoint.X * (1f - num) + centerPoint.Y * num2; float m2 = centerPoint.Y * (1f - num) - centerPoint.X * num2; Matrix4x4 result = default(Matrix4x4); result.M11 = num; result.M12 = num2; result.M13 = 0f; result.M14 = 0f; result.M21 = 0f - num2; result.M22 = num; result.M23 = 0f; result.M24 = 0f; result.M31 = 0f; result.M32 = 0f; result.M33 = 1f; result.M34 = 0f; result.M41 = m; result.M42 = m2; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateFromAxisAngle(Vector3 axis, float angle) { float x = axis.X; float y = axis.Y; float z = axis.Z; float num = MathF.Sin(angle); float num2 = MathF.Cos(angle); float num3 = x * x; float num4 = y * y; float num5 = z * z; float num6 = x * y; float num7 = x * z; float num8 = y * z; Matrix4x4 result = default(Matrix4x4); result.M11 = num3 + num2 * (1f - num3); result.M12 = num6 - num2 * num6 + num * z; result.M13 = num7 - num2 * num7 - num * y; result.M14 = 0f; result.M21 = num6 - num2 * num6 - num * z; result.M22 = num4 + num2 * (1f - num4); result.M23 = num8 - num2 * num8 + num * x; result.M24 = 0f; result.M31 = num7 - num2 * num7 + num * y; result.M32 = num8 - num2 * num8 - num * x; result.M33 = num5 + num2 * (1f - num5); result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance) { if (fieldOfView <= 0f || fieldOfView >= (float)Math.PI) { throw new ArgumentOutOfRangeException("fieldOfView"); } if (nearPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } if (farPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("farPlaneDistance"); } if (nearPlaneDistance >= farPlaneDistance) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } float num = 1f / MathF.Tan(fieldOfView * 0.5f); float m = num / aspectRatio; Matrix4x4 result = default(Matrix4x4); result.M11 = m; result.M12 = (result.M13 = (result.M14 = 0f)); result.M22 = num; result.M21 = (result.M23 = (result.M24 = 0f)); result.M31 = (result.M32 = 0f); float num2 = (result.M33 = (float.IsPositiveInfinity(farPlaneDistance) ? (-1f) : (farPlaneDistance / (nearPlaneDistance - farPlaneDistance)))); result.M34 = -1f; result.M41 = (result.M42 = (result.M44 = 0f)); result.M43 = nearPlaneDistance * num2; return result; } public static Matrix4x4 CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance) { if (nearPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } if (farPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("farPlaneDistance"); } if (nearPlaneDistance >= farPlaneDistance) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } Matrix4x4 result = default(Matrix4x4); result.M11 = 2f * nearPlaneDistance / width; result.M12 = (result.M13 = (result.M14 = 0f)); result.M22 = 2f * nearPlaneDistance / height; result.M21 = (result.M23 = (result.M24 = 0f)); float num = (result.M33 = (float.IsPositiveInfinity(farPlaneDistance) ? (-1f) : (farPlaneDistance / (nearPlaneDistance - farPlaneDistance)))); result.M31 = (result.M32 = 0f); result.M34 = -1f; result.M41 = (result.M42 = (result.M44 = 0f)); result.M43 = nearPlaneDistance * num; return result; } public static Matrix4x4 CreatePerspectiveOffCenter(float left, float right, float bottom, float top, float nearPlaneDistance, float farPlaneDistance) { if (nearPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } if (farPlaneDistance <= 0f) { throw new ArgumentOutOfRangeException("farPlaneDistance"); } if (nearPlaneDistance >= farPlaneDistance) { throw new ArgumentOutOfRangeException("nearPlaneDistance"); } Matrix4x4 result = default(Matrix4x4); result.M11 = 2f * nearPlaneDistance / (right - left); result.M12 = (result.M13 = (result.M14 = 0f)); result.M22 = 2f * nearPlaneDistance / (top - bottom); result.M21 = (result.M23 = (result.M24 = 0f)); result.M31 = (left + right) / (right - left); result.M32 = (top + bottom) / (top - bottom); float num = (result.M33 = (float.IsPositiveInfinity(farPlaneDistance) ? (-1f) : (farPlaneDistance / (nearPlaneDistance - farPlaneDistance)))); result.M34 = -1f; result.M43 = nearPlaneDistance * num; result.M41 = (result.M42 = (result.M44 = 0f)); return result; } public static Matrix4x4 CreateOrthographic(float width, float height, float zNearPlane, float zFarPlane) { Matrix4x4 result = default(Matrix4x4); result.M11 = 2f / width; result.M12 = (result.M13 = (result.M14 = 0f)); result.M22 = 2f / height; result.M21 = (result.M23 = (result.M24 = 0f)); result.M33 = 1f / (zNearPlane - zFarPlane); result.M31 = (result.M32 = (result.M34 = 0f)); result.M41 = (result.M42 = 0f); result.M43 = zNearPlane / (zNearPlane - zFarPlane); result.M44 = 1f; return result; } public static Matrix4x4 CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane) { Matrix4x4 result = default(Matrix4x4); result.M11 = 2f / (right - left); result.M12 = (result.M13 = (result.M14 = 0f)); result.M22 = 2f / (top - bottom); result.M21 = (result.M23 = (result.M24 = 0f)); result.M33 = 1f / (zNearPlane - zFarPlane); result.M31 = (result.M32 = (result.M34 = 0f)); result.M41 = (left + right) / (left - right); result.M42 = (top + bottom) / (bottom - top); result.M43 = zNearPlane / (zNearPlane - zFarPlane); result.M44 = 1f; return result; } public static Matrix4x4 CreateLookAt(Vector3 cameraPosition, Vector3 cameraTarget, Vector3 cameraUpVector) { Vector3 vector = Vector3.Normalize(cameraPosition - cameraTarget); Vector3 vector2 = Vector3.Normalize(Vector3.Cross(cameraUpVector, vector)); Vector3 vector3 = Vector3.Cross(vector, vector2); Matrix4x4 result = default(Matrix4x4); result.M11 = vector2.X; result.M12 = vector3.X; result.M13 = vector.X; result.M14 = 0f; result.M21 = vector2.Y; result.M22 = vector3.Y; result.M23 = vector.Y; result.M24 = 0f; result.M31 = vector2.Z; result.M32 = vector3.Z; result.M33 = vector.Z; result.M34 = 0f; result.M41 = 0f - Vector3.Dot(vector2, cameraPosition); result.M42 = 0f - Vector3.Dot(vector3, cameraPosition); result.M43 = 0f - Vector3.Dot(vector, cameraPosition); result.M44 = 1f; return result; } public static Matrix4x4 CreateWorld(Vector3 position, Vector3 forward, Vector3 up) { Vector3 vector = Vector3.Normalize(-forward); Vector3 vector2 = Vector3.Normalize(Vector3.Cross(up, vector)); Vector3 vector3 = Vector3.Cross(vector, vector2); Matrix4x4 result = default(Matrix4x4); result.M11 = vector2.X; result.M12 = vector2.Y; result.M13 = vector2.Z; result.M14 = 0f; result.M21 = vector3.X; result.M22 = vector3.Y; result.M23 = vector3.Z; result.M24 = 0f; result.M31 = vector.X; result.M32 = vector.Y; result.M33 = vector.Z; result.M34 = 0f; result.M41 = position.X; result.M42 = position.Y; result.M43 = position.Z; result.M44 = 1f; return result; } public static Matrix4x4 CreateFromQuaternion(Quaternion quaternion) { float num = quaternion.X * quaternion.X; float num2 = quaternion.Y * quaternion.Y; float num3 = quaternion.Z * quaternion.Z; float num4 = quaternion.X * quaternion.Y; float num5 = quaternion.Z * quaternion.W; float num6 = quaternion.Z * quaternion.X; float num7 = quaternion.Y * quaternion.W; float num8 = quaternion.Y * quaternion.Z; float num9 = quaternion.X * quaternion.W; Matrix4x4 result = default(Matrix4x4); result.M11 = 1f - 2f * (num2 + num3); result.M12 = 2f * (num4 + num5); result.M13 = 2f * (num6 - num7); result.M14 = 0f; result.M21 = 2f * (num4 - num5); result.M22 = 1f - 2f * (num3 + num); result.M23 = 2f * (num8 + num9); result.M24 = 0f; result.M31 = 2f * (num6 + num7); result.M32 = 2f * (num8 - num9); result.M33 = 1f - 2f * (num2 + num); result.M34 = 0f; result.M41 = 0f; result.M42 = 0f; result.M43 = 0f; result.M44 = 1f; return result; } public static Matrix4x4 CreateFromYawPitchRoll(float yaw, float pitch, float roll) { Quaternion quaternion = Quaternion.CreateFromYawPitchRoll(yaw, pitch, roll); return CreateFromQuaternion(quaternion); } public static Matrix4x4 CreateShadow(Vector3 lightDirection, Plane plane) { Plane plane2 = Plane.Normalize(plane); float num = plane2.Normal.X * lightDirection.X + plane2.Normal.Y * lightDirection.Y + plane2.Normal.Z * lightDirection.Z; float num2 = 0f - plane2.Normal.X; float num3 = 0f - plane2.Normal.Y; float num4 = 0f - plane2.Normal.Z; float num5 = 0f - plane2.D; Matrix4x4 result = default(Matrix4x4); result.M11 = num2 * lightDirection.X + num; result.M21 = num3 * lightDirection.X; result.M31 = num4 * lightDirection.X; result.M41 = num5 * lightDirection.X; result.M12 = num2 * lightDirection.Y; result.M22 = num3 * lightDirection.Y + num; result.M32 = num4 * lightDirection.Y; result.M42 = num5 * lightDirection.Y; result.M13 = num2 * lightDirection.Z; result.M23 = num3 * lightDirection.Z; result.M33 = num4 * lightDirection.Z + num; result.M43 = num5 * lightDirection.Z; result.M14 = 0f; result.M24 = 0f; result.M34 = 0f; result.M44 = num; return result; } public static Matrix4x4 CreateReflection(Plane value) { value = Plane.Normalize(value); float x = value.Normal.X; float y = value.Normal.Y; float z = value.Normal.Z; float num = -2f * x; float num2 = -2f * y; float num3 = -2f * z; Matrix4x4 result = default(Matrix4x4); result.M11 = num * x + 1f; result.M12 = num2 * x; result.M13 = num3 * x; result.M14 = 0f; result.M21 = num * y; result.M22 = num2 * y + 1f; result.M23 = num3 * y; result.M24 = 0f; result.M31 = num * z; result.M32 = num2 * z; result.M33 = num3 * z + 1f; result.M34 = 0f; result.M41 = num * value.D; result.M42 = num2 * value.D; result.M43 = num3 * value.D; result.M44 = 1f; return result; } public float GetDeterminant() { float m = M11; float m2 = M12; float m3 = M13; float m4 = M14; float m5 = M21; float m6 = M22; float m7 = M23; float m8 = M24; float m9 = M31; float m10 = M32; float m11 = M33; float m12 = M34; float m13 = M41; float m14 = M42; float m15 = M43; float m16 = M44; float num = m11 * m16 - m12 * m15; float num2 = m10 * m16 - m12 * m14; float num3 = m10 * m15 - m11 * m14; float num4 = m9 * m16 - m12 * m13; float num5 = m9 * m15 - m11 * m13; float num6 = m9 * m14 - m10 * m13; return m * (m6 * num - m7 * num2 + m8 * num3) - m2 * (m5 * num - m7 * num4 + m8 * num5) + m3 * (m5 * num2 - m6 * num4 + m8 * num6) - m4 * (m5 * num3 - m6 * num5 + m7 * num6); } public static bool Invert(Matrix4x4 matrix, out Matrix4x4 result) { float m = matrix.M11; float m2 = matrix.M12; float m3 = matrix.M13; float m4 = matrix.M14; float m5 = matrix.M21; float m6 = matrix.M22; float m7 = matrix.M23; float m8 = matrix.M24; float m9 = matrix.M31; float m10 = matrix.M32; float m11 = matrix.M33; float m12 = matrix.M34; float m13 = matrix.M41; float m14 = matrix.M42; float m15 = matrix.M43; float m16 = matrix.M44; float num = m11 * m16 - m12 * m15; float num2 = m10 * m16 - m12 * m14; float num3 = m10 * m15 - m11 * m14; float num4 = m9 * m16 - m12 * m13; float num5 = m9 * m15 - m11 * m13; float num6 = m9 * m14 - m10 * m13; float num7 = m6 * num - m7 * num2 + m8 * num3; float num8 = 0f - (m5 * num - m7 * num4 + m8 * num5); float num9 = m5 * num2 - m6 * num4 + m8 * num6; float num10 = 0f - (m5 * num3 - m6 * num5 + m7 * num6); float num11 = m * num7 + m2 * num8 + m3 * num9 + m4 * num10; if (MathF.Abs(num11) < float.Epsilon) { result = new Matrix4x4(float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN); return false; } float num12 = 1f / num11; result.M11 = num7 * num12; result.M21 = num8 * num12; result.M31 = num9 * num12; result.M41 = num10 * num12; result.M12 = (0f - (m2 * num - m3 * num2 + m4 * num3)) * num12; result.M22 = (m * num - m3 * num4 + m4 * num5) * num12; result.M32 = (0f - (m * num2 - m2 * num4 + m4 * num6)) * num12; result.M42 = (m * num3 - m2 * num5 + m3 * num6) * num12; float num13 = m7 * m16 - m8 * m15; float num14 = m6 * m16 - m8 * m14; float num15 = m6 * m15 - m7 * m14; float num16 = m5 * m16 - m8 * m13; float num17 = m5 * m15 - m7 * m13; float num18 = m5 * m14 - m6 * m13; result.M13 = (m2 * num13 - m3 * num14 + m4 * num15) * num12; result.M23 = (0f - (m * num13 - m3 * num16 + m4 * num17)) * num12; result.M33 = (m * num14 - m2 * num16 + m4 * num18) * num12; result.M43 = (0f - (m * num15 - m2 * num17 + m3 * num18)) * num12; float num19 = m7 * m12 - m8 * m11; float num20 = m6 * m12 - m8 * m10; float num21 = m6 * m11 - m7 * m10; float num22 = m5 * m12 - m8 * m9; float num23 = m5 * m11 - m7 * m9; float num24 = m5 * m10 - m6 * m9; result.M14 = (0f - (m2 * num19 - m3 * num20 + m4 * num21)) * num12; result.M24 = (m * num19 - m3 * num22 + m4 * num23) * num12; result.M34 = (0f - (m * num20 - m2 * num22 + m4 * num24)) * num12; result.M44 = (m * num21 - m2 * num23 + m3 * num24) * num12; return true; } public unsafe static bool Decompose(Matrix4x4 matrix, out Vector3 scale, out Quaternion rotation, out Vector3 translation) { bool result = true; fixed (Vector3* ptr = &scale) { float* ptr2 = (float*)ptr; VectorBasis vectorBasis = default(VectorBasis); Vector3** ptr3 = (Vector3**)(&vectorBasis); Matrix4x4 identity = Identity; CanonicalBasis canonicalBasis = default(CanonicalBasis); Vector3* ptr4 = &canonicalBasis.Row0; canonicalBasis.Row0 = new Vector3(1f, 0f, 0f); canonicalBasis.Row1 = new Vector3(0f, 1f, 0f); canonicalBasis.Row2 = new Vector3(0f, 0f, 1f); translation = new Vector3(matrix.M41, matrix.M42, matrix.M43); *ptr3 = (Vector3*)(&identity.M11); ptr3[1] = (Vector3*)(&identity.M21); ptr3[2] = (Vector3*)(&identity.M31); *(*ptr3) = new Vector3(matrix.M11, matrix.M12, matrix.M13); *ptr3[1] = new Vector3(matrix.M21, matrix.M22, matrix.M23); *ptr3[2] = new Vector3(matrix.M31, matrix.M32, matrix.M33); scale.X = (*ptr3)->Length(); scale.Y = ptr3[1]->Length(); scale.Z = ptr3[2]->Length(); float num = *ptr2; float num2 = ptr2[1]; float num3 = ptr2[2]; uint num4; uint num5; uint num6; if (num < num2) { if (num2 < num3) { num4 = 2u; num5 = 1u; num6 = 0u; } else { num4 = 1u; if (num < num3) { num5 = 2u; num6 = 0u; } else { num5 = 0u; num6 = 2u; } } } else if (num < num3) { num4 = 2u; num5 = 0u; num6 = 1u; } else { num4 = 0u; if (num2 < num3) { num5 = 2u; num6 = 1u; } else { num5 = 1u; num6 = 2u; } } if (ptr2[num4] < 0.0001f) { *ptr3[num4] = ptr4[num4]; } *ptr3[num4] = Vector3.Normalize(*ptr3[num4]); if (ptr2[num5] < 0.0001f) { float num7 = MathF.Abs(ptr3[num4]->X); float num8 = MathF.Abs(ptr3[num4]->Y); float num9 = MathF.Abs(ptr3[num4]->Z); uint num10 = ((num7 < num8) ? ((!(num8 < num9)) ? ((!(num7 < num9)) ? 2u : 0u) : 0u) : ((num7 < num9) ? 1u : ((num8 < num9) ? 1u : 2u))); *ptr3[num5] = Vector3.Cross(*ptr3[num4], ptr4[num10]); } *ptr3[num5] = Vector3.Normalize(*ptr3[num5]); if (ptr2[num6] < 0.0001f) { *ptr3[num6] = Vector3.Cross(*ptr3[num4], *ptr3[num5]); } *ptr3[num6] = Vector3.Normalize(*ptr3[num6]); float num11 = identity.GetDeterminant(); if (num11 < 0f) { ptr2[num4] = 0f - ptr2[num4]; *ptr3[num4] = -(*ptr3[num4]); num11 = 0f - num11; } num11 -= 1f; num11 *= num11; if (0.0001f < num11) { rotation = Quaternion.Identity; result = false; } else { rotation = Quaternion.CreateFromRotationMatrix(identity); } } return result; } public static Matrix4x4 Transform(Matrix4x4 value, Quaternion rotation) { float num = rotation.X + rotation.X; float num2 = rotation.Y + rotation.Y; float num3 = rotation.Z + rotation.Z; float num4 = rotation.W * num; float num5 = rotation.W * num2; float num6 = rotation.W * num3; float num7 = rotation.X * num; float num8 = rotation.X * num2; float num9 = rotation.X * num3; float num10 = rotation.Y * num2; float num11 = rotation.Y * num3; float num12 = rotation.Z * num3; float num13 = 1f - num10 - num12; float num14 = num8 - num6; float num15 = num9 + num5; float num16 = num8 + num6; float num17 = 1f - num7 - num12; float num18 = num11 - num4; float num19 = num9 - num5; float num20 = num11 + num4; float num21 = 1f - num7 - num10; Matrix4x4 result = default(Matrix4x4); result.M11 = value.M11 * num13 + value.M12 * num14 + value.M13 * num15; result.M12 = value.M11 * num16 + value.M12 * num17 + value.M13 * num18; result.M13 = value.M11 * num19 + value.M12 * num20 + value.M13 * num21; result.M14 = value.M14; result.M21 = value.M21 * num13 + value.M22 * num14 + value.M23 * num15; result.M22 = value.M21 * num16 + value.M22 * num17 + value.M23 * num18; result.M23 = value.M21 * num19 + value.M22 * num20 + value.M23 * num21; result.M24 = value.M24; result.M31 = value.M31 * num13 + value.M32 * num14 + value.M33 * num15; result.M32 = value.M31 * num16 + value.M32 * num17 + value.M33 * num18; result.M33 = value.M31 * num19 + value.M32 * num20 + value.M33 * num21; result.M34 = value.M34; result.M41 = value.M41 * num13 + value.M42 * num14 + value.M43 * num15; result.M42 = value.M41 * num16 + value.M42 * num17 + value.M43 * num18; result.M43 = value.M41 * num19 + value.M42 * num20 + value.M43 * num21; result.M44 = value.M44; return result; } public static Matrix4x4 Transpose(Matrix4x4 matrix) { Matrix4x4 result = default(Matrix4x4); result.M11 = matrix.M11; result.M12 = matrix.M21; result.M13 = matrix.M31; result.M14 = matrix.M41; result.M21 = matrix.M12; result.M22 = matrix.M22; result.M23 = matrix.M32; result.M24 = matrix.M42; result.M31 = matrix.M13; result.M32 = matrix.M23; result.M33 = matrix.M33; result.M34 = matrix.M43; result.M41 = matrix.M14; result.M42 = matrix.M24; result.M43 = matrix.M34; result.M44 = matrix.M44; return result; } public static Matrix4x4 Lerp(Matrix4x4 matrix1, Matrix4x4 matrix2, float amount) { Matrix4x4 result = default(Matrix4x4); result.M11 = matrix1.M11 + (matrix2.M11 - matrix1.M11) * amount; result.M12 = matrix1.M12 + (matrix2.M12 - matrix1.M12) * amount; result.M13 = matrix1.M13 + (matrix2.M13 - matrix1.M13) * amount; result.M14 = matrix1.M14 + (matrix2.M14 - matrix1.M14) * amount; result.M21 = matrix1.M21 + (matrix2.M21 - matrix1.M21) * amount; result.M22 = matrix1.M22 + (matrix2.M22 - matrix1.M22) * amount; result.M23 = matrix1.M23 + (matrix2.M23 - matrix1.M23) * amount; result.M24 = matrix1.M24 + (matrix2.M24 - matrix1.M24) * amount; result.M31 = matrix1.M31 + (matrix2.M31 - matrix1.M31) * amount; result.M32 = matrix1.M32 + (matrix2.M32 - matrix1.M32) * amount; result.M33 = matrix1.M33 + (matrix2.M33 - matrix1.M33) * amount; result.M34 = matrix1.M34 + (matrix2.M34 - matrix1.M34) * amount; result.M41 = matrix1.M41 + (matrix2.M41 - matrix1.M41) * amount; result.M42 = matrix1.M42 + (matrix2.M42 - matrix1.M42) * amount; result.M43 = matrix1.M43 + (matrix2.M43 - matrix1.M43) * amount; result.M44 = matrix1.M44 + (matrix2.M44 - matrix1.M44) * amount; return result; } public static Matrix4x4 Negate(Matrix4x4 value) { Matrix4x4 result = default(Matrix4x4); result.M11 = 0f - value.M11; result.M12 = 0f - value.M12; result.M13 = 0f - value.M13; result.M14 = 0f - value.M14; result.M21 = 0f - value.M21; result.M22 = 0f - value.M22; result.M23 = 0f - value.M23; result.M24 = 0f - value.M24; result.M31 = 0f - value.M31; result.M32 = 0f - value.M32; result.M33 = 0f - value.M33; result.M34 = 0f - value.M34; result.M41 = 0f - value.M41; result.M42 = 0f - value.M42; result.M43 = 0f - value.M43; result.M44 = 0f - value.M44; return result; } public static Matrix4x4 Add(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 + value2.M11; result.M12 = value1.M12 + value2.M12; result.M13 = value1.M13 + value2.M13; result.M14 = value1.M14 + value2.M14; result.M21 = value1.M21 + value2.M21; result.M22 = value1.M22 + value2.M22; result.M23 = value1.M23 + value2.M23; result.M24 = value1.M24 + value2.M24; result.M31 = value1.M31 + value2.M31; result.M32 = value1.M32 + value2.M32; result.M33 = value1.M33 + value2.M33; result.M34 = value1.M34 + value2.M34; result.M41 = value1.M41 + value2.M41; result.M42 = value1.M42 + value2.M42; result.M43 = value1.M43 + value2.M43; result.M44 = value1.M44 + value2.M44; return result; } public static Matrix4x4 Subtract(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 - value2.M11; result.M12 = value1.M12 - value2.M12; result.M13 = value1.M13 - value2.M13; result.M14 = value1.M14 - value2.M14; result.M21 = value1.M21 - value2.M21; result.M22 = value1.M22 - value2.M22; result.M23 = value1.M23 - value2.M23; result.M24 = value1.M24 - value2.M24; result.M31 = value1.M31 - value2.M31; result.M32 = value1.M32 - value2.M32; result.M33 = value1.M33 - value2.M33; result.M34 = value1.M34 - value2.M34; result.M41 = value1.M41 - value2.M41; result.M42 = value1.M42 - value2.M42; result.M43 = value1.M43 - value2.M43; result.M44 = value1.M44 - value2.M44; return result; } public static Matrix4x4 Multiply(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21 + value1.M13 * value2.M31 + value1.M14 * value2.M41; result.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22 + value1.M13 * value2.M32 + value1.M14 * value2.M42; result.M13 = value1.M11 * value2.M13 + value1.M12 * value2.M23 + value1.M13 * value2.M33 + value1.M14 * value2.M43; result.M14 = value1.M11 * value2.M14 + value1.M12 * value2.M24 + value1.M13 * value2.M34 + value1.M14 * value2.M44; result.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21 + value1.M23 * value2.M31 + value1.M24 * value2.M41; result.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22 + value1.M23 * value2.M32 + value1.M24 * value2.M42; result.M23 = value1.M21 * value2.M13 + value1.M22 * value2.M23 + value1.M23 * value2.M33 + value1.M24 * value2.M43; result.M24 = value1.M21 * value2.M14 + value1.M22 * value2.M24 + value1.M23 * value2.M34 + value1.M24 * value2.M44; result.M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value1.M33 * value2.M31 + value1.M34 * value2.M41; result.M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value1.M33 * value2.M32 + value1.M34 * value2.M42; result.M33 = value1.M31 * value2.M13 + value1.M32 * value2.M23 + value1.M33 * value2.M33 + value1.M34 * value2.M43; result.M34 = value1.M31 * value2.M14 + value1.M32 * value2.M24 + value1.M33 * value2.M34 + value1.M34 * value2.M44; result.M41 = value1.M41 * value2.M11 + value1.M42 * value2.M21 + value1.M43 * value2.M31 + value1.M44 * value2.M41; result.M42 = value1.M41 * value2.M12 + value1.M42 * value2.M22 + value1.M43 * value2.M32 + value1.M44 * value2.M42; result.M43 = value1.M41 * value2.M13 + value1.M42 * value2.M23 + value1.M43 * value2.M33 + value1.M44 * value2.M43; result.M44 = value1.M41 * value2.M14 + value1.M42 * value2.M24 + value1.M43 * value2.M34 + value1.M44 * value2.M44; return result; } public static Matrix4x4 Multiply(Matrix4x4 value1, float value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 * value2; result.M12 = value1.M12 * value2; result.M13 = value1.M13 * value2; result.M14 = value1.M14 * value2; result.M21 = value1.M21 * value2; result.M22 = value1.M22 * value2; result.M23 = value1.M23 * value2; result.M24 = value1.M24 * value2; result.M31 = value1.M31 * value2; result.M32 = value1.M32 * value2; result.M33 = value1.M33 * value2; result.M34 = value1.M34 * value2; result.M41 = value1.M41 * value2; result.M42 = value1.M42 * value2; result.M43 = value1.M43 * value2; result.M44 = value1.M44 * value2; return result; } public static Matrix4x4 operator -(Matrix4x4 value) { Matrix4x4 result = default(Matrix4x4); result.M11 = 0f - value.M11; result.M12 = 0f - value.M12; result.M13 = 0f - value.M13; result.M14 = 0f - value.M14; result.M21 = 0f - value.M21; result.M22 = 0f - value.M22; result.M23 = 0f - value.M23; result.M24 = 0f - value.M24; result.M31 = 0f - value.M31; result.M32 = 0f - value.M32; result.M33 = 0f - value.M33; result.M34 = 0f - value.M34; result.M41 = 0f - value.M41; result.M42 = 0f - value.M42; result.M43 = 0f - value.M43; result.M44 = 0f - value.M44; return result; } public static Matrix4x4 operator +(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 + value2.M11; result.M12 = value1.M12 + value2.M12; result.M13 = value1.M13 + value2.M13; result.M14 = value1.M14 + value2.M14; result.M21 = value1.M21 + value2.M21; result.M22 = value1.M22 + value2.M22; result.M23 = value1.M23 + value2.M23; result.M24 = value1.M24 + value2.M24; result.M31 = value1.M31 + value2.M31; result.M32 = value1.M32 + value2.M32; result.M33 = value1.M33 + value2.M33; result.M34 = value1.M34 + value2.M34; result.M41 = value1.M41 + value2.M41; result.M42 = value1.M42 + value2.M42; result.M43 = value1.M43 + value2.M43; result.M44 = value1.M44 + value2.M44; return result; } public static Matrix4x4 operator -(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 - value2.M11; result.M12 = value1.M12 - value2.M12; result.M13 = value1.M13 - value2.M13; result.M14 = value1.M14 - value2.M14; result.M21 = value1.M21 - value2.M21; result.M22 = value1.M22 - value2.M22; result.M23 = value1.M23 - value2.M23; result.M24 = value1.M24 - value2.M24; result.M31 = value1.M31 - value2.M31; result.M32 = value1.M32 - value2.M32; result.M33 = value1.M33 - value2.M33; result.M34 = value1.M34 - value2.M34; result.M41 = value1.M41 - value2.M41; result.M42 = value1.M42 - value2.M42; result.M43 = value1.M43 - value2.M43; result.M44 = value1.M44 - value2.M44; return result; } public static Matrix4x4 operator *(Matrix4x4 value1, Matrix4x4 value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21 + value1.M13 * value2.M31 + value1.M14 * value2.M41; result.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22 + value1.M13 * value2.M32 + value1.M14 * value2.M42; result.M13 = value1.M11 * value2.M13 + value1.M12 * value2.M23 + value1.M13 * value2.M33 + value1.M14 * value2.M43; result.M14 = value1.M11 * value2.M14 + value1.M12 * value2.M24 + value1.M13 * value2.M34 + value1.M14 * value2.M44; result.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21 + value1.M23 * value2.M31 + value1.M24 * value2.M41; result.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22 + value1.M23 * value2.M32 + value1.M24 * value2.M42; result.M23 = value1.M21 * value2.M13 + value1.M22 * value2.M23 + value1.M23 * value2.M33 + value1.M24 * value2.M43; result.M24 = value1.M21 * value2.M14 + value1.M22 * value2.M24 + value1.M23 * value2.M34 + value1.M24 * value2.M44; result.M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value1.M33 * value2.M31 + value1.M34 * value2.M41; result.M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value1.M33 * value2.M32 + value1.M34 * value2.M42; result.M33 = value1.M31 * value2.M13 + value1.M32 * value2.M23 + value1.M33 * value2.M33 + value1.M34 * value2.M43; result.M34 = value1.M31 * value2.M14 + value1.M32 * value2.M24 + value1.M33 * value2.M34 + value1.M34 * value2.M44; result.M41 = value1.M41 * value2.M11 + value1.M42 * value2.M21 + value1.M43 * value2.M31 + value1.M44 * value2.M41; result.M42 = value1.M41 * value2.M12 + value1.M42 * value2.M22 + value1.M43 * value2.M32 + value1.M44 * value2.M42; result.M43 = value1.M41 * value2.M13 + value1.M42 * value2.M23 + value1.M43 * value2.M33 + value1.M44 * value2.M43; result.M44 = value1.M41 * value2.M14 + value1.M42 * value2.M24 + value1.M43 * value2.M34 + value1.M44 * value2.M44; return result; } public static Matrix4x4 operator *(Matrix4x4 value1, float value2) { Matrix4x4 result = default(Matrix4x4); result.M11 = value1.M11 * value2; result.M12 = value1.M12 * value2; result.M13 = value1.M13 * value2; result.M14 = value1.M14 * value2; result.M21 = value1.M21 * value2; result.M22 = value1.M22 * value2; result.M23 = value1.M23 * value2; result.M24 = value1.M24 * value2; result.M31 = value1.M31 * value2; result.M32 = value1.M32 * value2; result.M33 = value1.M33 * value2; result.M34 = value1.M34 * value2; result.M41 = value1.M41 * value2; result.M42 = value1.M42 * value2; result.M43 = value1.M43 * value2; result.M44 = value1.M44 * value2; return result; } public static bool operator ==(Matrix4x4 value1, Matrix4x4 value2) { if (value1.M11 == value2.M11 && value1.M22 == value2.M22 && value1.M33 == value2.M33 && value1.M44 == value2.M44 && value1.M12 == value2.M12 && value1.M13 == value2.M13 && value1.M14 == value2.M14 && value1.M21 == value2.M21 && value1.M23 == value2.M23 && value1.M24 == value2.M24 && value1.M31 == value2.M31 && value1.M32 == value2.M32 && value1.M34 == value2.M34 && value1.M41 == value2.M41 && value1.M42 == value2.M42) { return value1.M43 == value2.M43; } return false; } public static bool operator !=(Matrix4x4 value1, Matrix4x4 value2) { if (value1.M11 == value2.M11 && value1.M12 == value2.M12 && value1.M13 == value2.M13 && value1.M14 == value2.M14 && value1.M21 == value2.M21 && value1.M22 == value2.M22 && value1.M23 == value2.M23 && value1.M24 == value2.M24 && value1.M31 == value2.M31 && value1.M32 == value2.M32 && value1.M33 == value2.M33 && value1.M34 == value2.M34 && value1.M41 == value2.M41 && value1.M42 == value2.M42 && value1.M43 == value2.M43) { return value1.M44 != value2.M44; } return true; } public bool Equals(Matrix4x4 other) { if (M11 == other.M11 && M22 == other.M22 && M33 == other.M33 && M44 == other.M44 && M12 == other.M12 && M13 == other.M13 && M14 == other.M14 && M21 == other.M21 && M23 == other.M23 && M24 == other.M24 && M31 == other.M31 && M32 == other.M32 && M34 == other.M34 && M41 == other.M41 && M42 == other.M42) { return M43 == other.M43; } return false; } public override bool Equals(object obj) { if (obj is Matrix4x4) { return Equals((Matrix4x4)obj); } return false; } public override string ToString() { CultureInfo currentCulture = CultureInfo.CurrentCulture; return string.Format(currentCulture, "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}", M11.ToString(currentCulture), M12.ToString(currentCulture), M13.ToString(currentCulture), M14.ToString(currentCulture), M21.ToString(currentCulture), M22.ToString(currentCulture), M23.ToString(currentCulture), M24.ToString(currentCulture), M31.ToString(currentCulture), M32.ToString(currentCulture), M33.ToString(currentCulture), M34.ToString(currentCulture), M41.ToString(currentCulture), M42.ToString(currentCulture), M43.ToString(currentCulture), M44.ToString(currentCulture)); } public override int GetHashCode() { return M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() + M21.GetHashCode() + M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() + M31.GetHashCode() + M32.GetHashCode() + M33.GetHashCode() + M34.GetHashCode() + M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode(); } } public struct Plane : IEquatable<Plane> { public Vector3 Normal; public float D; public Plane(float x, float y, float z, float d) { Normal = new Vector3(x, y, z); D = d; } public Plane(Vector3 normal, float d) { Normal = normal; D = d; } public Plane(Vector4 value) { Normal = new Vector3(value.X, value.Y, value.Z); D = value.W; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Plane CreateFromVertices(Vector3 point1, Vector3 point2, Vector3 point3) { if (Vector.IsHardwareAccelerated) { Vector3 vector = point2 - point1; Vector3 vector2 = point3 - point1; Vector3 value = Vector3.Cross(vector, vector2); Vector3 vector3 = Vector3.Normalize(value); float d = 0f - Vector3.Dot(vector3, point1); return new Plane(vector3, d); } float num = point2.X - point1.X; float num2 = point2.Y - point1.Y; float num3 = point2.Z - point1.Z; float num4 = point3.X - point1.X; float num5 = point3.Y - point1.Y; float num6 = point3.Z - point1.Z; float num7 = num2 * num6 - num3 * num5; float num8 = num3 * num4 - num * num6; float num9 = num * num5 - num2 * num4; float x = num7 * num7 + num8 * num8 + num9 * num9; float num10 = 1f / MathF.Sqrt(x); Vector3 normal = new Vector3(num7 * num10, num8 * num10, num9 * num10); return new Plane(normal, 0f - (normal.X * point1.X + normal.Y * point1.Y + normal.Z * point1.Z)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Plane Normalize(Plane value) { if (Vector.IsHardwareAccelerated) { float num = value.Normal.LengthSquared(); if (MathF.Abs(num - 1f) < 1.1920929E-07f) { return value; } float num2 = MathF.Sqrt(num); return new Plane(value.Normal / num2, value.D / num2); } float num3 = value.Normal.X * value.Normal.X + value.Normal.Y * value.Normal.Y + value.Normal.Z * value.Normal.Z; if (MathF.Abs(num3 - 1f) < 1.1920929E-07f) { return value; } float num4 = 1f / MathF.Sqrt(num3); return new Plane(value.Normal.X * num4, value.Normal.Y * num4, value.Normal.Z * num4, value.D * num4); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Plane Transform(Plane plane, Matrix4x4 matrix) { Matrix4x4.Invert(matrix, out var result); float x = plane.Normal.X; float y = plane.Normal.Y; float z = plane.Normal.Z; float d = plane.D; return new Plane(x * result.M11 + y * result.M12 + z * result.M13 + d * result.M14, x * result.M21 + y * result.M22 + z * result.M23 + d * result.M24, x * result.M31 + y * result.M32 + z * result.M33 + d * result.M34, x * result.M41 + y * result.M42 + z * result.M43 + d * result.M44); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Plane Transform(Plane plane, Quaternion rotation) { float num = rotation.X + rotation.X; float num2 = rotation.Y + rotation.Y; float num3 = rotation.Z + rotation.Z; float num4 = rotation.W * num; float num5 = rotation.W * num2; float num6 = rotation.W * num3; float num7 = rotation.X * num; float num8 = rotation.X * num2; float num9 = rotation.X * num3; float num10 = rotation.Y * num2; float num11 = rotation.Y * num3; float num12 = rotation.Z * num3; float num13 = 1f - num10 - num12; float num14 = num8 - num6; float num15 = num9 + num5; float num16 = num8 + num6; float num17 = 1f - num7 - num12; float num18 = num11 - num4; float num19 = num9 - num5; float num20 = num11 + num4; float num21 = 1f - num7 - num10; float x = plane.Normal.X; float y = plane.Normal.Y; float z = plane.Normal.Z; return new Plane(x * num13 + y * num14 + z * num15, x * num16 + y * num17 + z * num18, x * num19 + y * num20 + z * num21, plane.D); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Dot(Plane plane, Vector4 value) { return plane.Normal.X * value.X + plane.Normal.Y * value.Y + plane.Normal.Z * value.Z + plane.D * value.W; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float DotCoordinate(Plane plane, Vector3 value) { if (Vector.IsHardwareAccelerated) { return Vector3.Dot(plane.Normal, value) + plane.D; } return plane.Normal.X * value.X + plane.Normal.Y * value.Y + plane.Normal.Z * value.Z + plane.D; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float DotNormal(Plane plane, Vector3 value) { if (Vector.IsHardwareAccelerated) { return Vector3.Dot(plane.Normal, value); } return plane.Normal.X * value.X + plane.Normal.Y * value.Y + plane.Normal.Z * value.Z; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(Plane value1, Plane value2) { if (value1.Normal.X == value2.Normal.X && value1.Normal.Y == value2.Normal.Y && value1.Normal.Z == value2.Normal.Z) { return value1.D == value2.D; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(Plane value1, Plane value2) { if (value1.Normal.X == value2.Normal.X && value1.Normal.Y == value2.Normal.Y && value1.Normal.Z == value2.Normal.Z) { return value1.D != value2.D; } return true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool Equals(Plane other) { if (Vector.IsHardwareAccelerated) { if (Normal.Equals(other.Normal)) { return D == other.D; } return false; } if (Normal.X == other.Normal.X && Normal.Y == other.Normal.Y && Normal.Z == other.Normal.Z) { return D == other.D; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public override bool Equals(object obj) { if (obj is Plane) { return Equals((Plane)obj); } return false; } public override string ToString() { CultureInfo currentCulture = CultureInfo.CurrentCulture; return string.Format(currentCulture, "{{Normal:{0} D:{1}}}", Normal.ToString(), D.ToString(currentCulture)); } public override int GetHashCode() { return Normal.GetHashCode() + D.GetHashCode(); } } public struct Quaternion : IEquatable<Quaternion> { public float X; public float Y; public float Z; public float W; public static Quaternion Identity => new Quaternion(0f, 0f, 0f, 1f); public bool IsIdentity { get { if (X == 0f && Y == 0f && Z == 0f) { return W == 1f; } return false; } } public Quaternion(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; } public Quaternion(Vector3 vectorPart, float scalarPart) { X = vectorPart.X; Y = vectorPart.Y; Z = vectorPart.Z; W = scalarPart; } public float Length() { float x = X * X + Y * Y + Z * Z + W * W; return MathF.Sqrt(x); } public float LengthSquared() { return X * X + Y * Y + Z * Z + W * W; } public static Quaternion Normalize(Quaternion value) { float x = value.X * value.X + value.Y * value.Y + value.Z * value.Z + value.W * value.W; float num = 1f / MathF.Sqrt(x); Quaternion result = default(Quaternion); result.X = value.X * num; result.Y = value.Y * num; result.Z = value.Z * num; result.W = value.W * num; return result; } public static Quaternion Conjugate(Quaternion value) { Quaternion result = default(Quaternion); result.X = 0f - value.X; result.Y = 0f - value.Y; result.Z = 0f - value.Z; result.W = value.W; return result; } public static Quaternion Inverse(Quaternion value) { float num = value.X * value.X + value.Y * value.Y + value.Z * value.Z + value.W * value.W; float num2 = 1f / num; Quaternion result = default(Quaternion); result.X = (0f - value.X) * num2; result.Y = (0f - value.Y) * num2; result.Z = (0f - value.Z) * num2; result.W = value.W * num2; return result; } public static Quaternion CreateFromAxisAngle(Vector3 axis, float angle) { float x = angle * 0.5f; float num = MathF.Sin(x); float w = MathF.Cos(x); Quaternion result = default(Quaternion); result.X = axis.X * num; result.Y = axis.Y * num; result.Z = axis.Z * num; result.W = w; return result; } public static Quaternion CreateFromYawPitchRoll(float yaw, float pitch, float roll) { float x = roll * 0.5f; float num = MathF.Sin(x); float num2 = MathF.Cos(x); float x2 = pitch * 0.5f; float num3 = MathF.Sin(x2); float num4 = MathF.Cos(x2); float x3 = yaw * 0.5f; float num5 = MathF.Sin(x3); float num6 = MathF.Cos(x3); Quaternion result = default(Quaternion); result.X = num6 * num3 * num2 + num5 * num4 * num; result.Y = num5 * num4 * num2 - num6 * num3 * num; result.Z = num6 * num4 * num - num5 * num3 * num2; result.W = num6 * num4 * num2 + num5 * num3 * num; return result; } public static Quaternion CreateFromRotationMatrix(Matrix4x4 matrix) { float num = matrix.M11 + matrix.M22 + matrix.M33; Quaternion result = default(Quaternion); if (num > 0f) { float num2 = MathF.Sqrt(num + 1f); result.W = num2 * 0.5f; num2 = 0.5f / num2; result.X = (matrix.M23 - matrix.M32) * num2; result.Y = (matrix.M31 - matrix.M13) * num2; result.Z = (matrix.M12 - matrix.M21) * num2; } else if (matrix.M11 >= matrix.M22 && matrix.M11 >= matrix.M33) { float num3 = MathF.Sqrt(1f + matrix.M11 - matrix.M22 - matrix.M33); float num4 = 0.5f / num3; result.X = 0.5f * num3; result.Y = (matrix.M12 + matrix.M21) * num4; result.Z = (matrix.M13 + matrix.M31) * num4; result.W = (matrix.M23 - matrix.M32) * num4; } else if (matrix.M22 > matrix.M33) { float num5 = MathF.Sqrt(1f + matrix.M22 - matrix.M11 - matrix.M33); float num6 = 0.5f / num5; result.X = (matrix.M21 + matrix.M12) * num6; result.Y = 0.5f * num5; result.Z = (matrix.M32 + matrix.M23) * num6; result.W = (matrix.M31 - matrix.M13) * num6; } else { float num7 = MathF.Sqrt(1f + matrix.M33 - matrix.M11 - matrix.M22); float num8 = 0.5f / num7; result.X = (matrix.M31 + matrix.M13) * num8; result.Y = (matrix.M32 + matrix.M23) * num8; result.Z = 0.5f * num7; result.W = (matrix.M12 - matrix.M21) * num8; } return result; } public static float Dot(Quaternion quaternion1, Quaternion quaternion2) { return quaternion1.X * quaternion2.X + quaternion1.Y * quaternion2.Y + quaternion1.Z * quaternion2.Z + quaternion1.W * quaternion2.W; } public static Quaternion Slerp(Quaternion quaternion1, Quaternion quaternion2, float amount) { float num = quaternion1.X * quaternion2.X + quaternion1.Y * quaternion2.Y + quaternion1.Z * quaternion2.Z + quaternion1.W * quaternion2.W; bool flag = false; if (num < 0f) { flag = true; num = 0f - num; } float num2; float num3; if (num > 0.999999f) { num2 = 1f - amount; num3 = (flag ? (0f - amount) : amount); } else { float num4 = MathF.Acos(num); float num5 = 1f / MathF.Sin(num4); num2 = MathF.Sin((1f - amount) * num4) * num5; num3 = (flag ? ((0f - MathF.Sin(amount * num4)) * num5) : (MathF.Sin(amount * num4) * num5)); } Quaternion result = default(Quaternion); result.X = num2 * quaternion1.X + num3 * quaternion2.X; result.Y = num2 * quaternion1.Y + num3 * quaternion2.Y; result.Z = num2 * quaternion1.Z + num3 * quaternion2.Z; result.W = num2 * quaternion1.W + num3 * quaternion2.W; return result; } public static Quaternion Lerp(Quaternion quaternion1, Quaternion quaternion2, float amount) { float num = 1f - amount; Quaternion result = default(Quaternion); float num2 = quaternion1.X * quaternion2.X + quaternion1.Y * quaternion2.Y + quaternion1.Z * quaternion2.Z + quaternion1.W * quaternion2.W; if (num2 >= 0f) { result.X = num * quaternion1.X + amount * quaternion2.X; result.Y = num * quaternion1.Y + amount * quaternion2.Y; result.Z = num * quaternion1.Z + amount * quaternion2.Z; result.W = num * quaternion1.W + amount * quaternion2.W; } else { result.X = num * quaternion1.X - amount * quaternion2.X; result.Y = num * quaternion1.Y - amount * quaternion2.Y; result.Z = num * quaternion1.Z - amount * quaternion2.Z; result.W = num * quaternion1.W - amount * quaternion2.W; } float x = result.X * result.X + result.Y * result.Y + result.Z * result.Z + result.W * result.W; float num3 = 1f / MathF.Sqrt(x); result.X *= num3; result.Y *= num3; result.Z *= num3; result.W *= num3; return result; } public static Quaternion Concatenate(Quaternion value1, Quaternion value2) { float x = value2.X; float y = value2.Y; float z = value2.Z; float w = value2.W; float x2 = value1.X; float y2 = value1.Y; float z2 = value1.Z; float w2 = value1.W; float num = y * z2 - z * y2; float num2 = z * x2 - x * z2; float num3 = x * y2 - y * x2; float num4 = x * x2 + y * y2 + z * z2; Quaternion result = default(Quaternion); result.X = x * w2 + x2 * w + num; result.Y = y * w2 + y2 * w + num2; result.Z = z * w2 + z2 * w + num3; result.W = w * w2 - num4; return result; } public static Quaternion Negate(Quaternion value) { Quaternion result = default(Quaternion); result.X = 0f - value.X; result.Y = 0f - value.Y; result.Z = 0f - value.Z; result.W = 0f - value.W; return result; } public static Quaternion Add(Quaternion value1, Quaternion value2) { Quaternion result = default(Quaternion); result.X = value1.X + value2.X; result.Y = value1.Y + value2.Y; result.Z = value1.Z + value2.Z; result.W = value1.W + value2.W; return result; } public static Quaternion Subtract(Quaternion value1, Quaternion value2) { Quaternion result = default(Quaternion); result.X = value1.X - value2.X; result.Y = value1.Y - value2.Y; result.Z = value1.Z - value2.Z; result.W = value1.W - value2.W; return result; } public static Quaternion Multiply(Quaternion value1, Quaternion value2) { float x = value1.X; float y = value1.Y; float z = value1.Z; float w = value1.W; float x2 = value2.X; float y2 = value2.Y; float z2 = value2.Z; float w2 = value2.W; float num = y * z2 - z * y2; float num2 = z * x2 - x * z2; float num3 = x * y2 - y * x2; float num4 = x * x2 + y * y2 + z * z2; Quaternion result = default(Quaternion); result.X = x * w2 + x2 * w + num; result.Y = y * w2 + y2 * w + num2; result.Z = z * w2 + z2 * w + num3; result.W = w * w2 - num4; return result; } public static Quaternion Multiply(Quaternion value1, float value2) { Quaternion result = default(Quaternion); result.X = value1.X * value2; result.Y = value1.Y * value2; result.Z = value1.Z * value2; result.W = value1.W * value2; return result; } public static Quaternion Divide(Quaternion value1, Quaternion value2) { float x = value1.X; float y = value1.Y; float z = value1.Z; float w = value1.W; float num = value2.X * value2.X + value2.Y * value2.Y + value2.Z * value2.Z + value2.W * value2.W; float num2 = 1f / num; float num3 = (0f - value2.X) * num2; float num4 = (0f - value2.Y) * num2; float num5 = (0f - value2.Z) * num2; float num6 = value2.W * num2; float num7 = y * num5 - z * num4; float num8 = z * num3 - x * num5; float num9 = x * num4 - y * num3; float num10 = x * num3 + y * num4 + z * num5; Quaternion result = default(Quaternion); result.X = x * num6 + num3 * w + num7; result.Y = y * num6 + num4 * w + num8; result.Z = z * num6 + num5 * w + num9; result.W = w * num6 - num10; return result; } public static Quaternion operator -(Quaternion value) { Quaternion result = default(Quaternion); result.X = 0f - value.X; result.Y = 0f - value.Y; result.Z = 0f - value.Z; result.W = 0f - value.W; return result; } public static Quaternion operator +(Quaternion value1, Quaternion value2) { Quaternion result = default(Quaternion); result.X = value1.X + value2.X; result.Y = value1.Y + value2.Y; result.Z = value1.Z + value2.Z; result.W = value1.W + value2.W; return result; } public static Quaternion operator -(Quaternion value1, Quaternion value2) { Quaternion result = default(Quaternion); result.X = value1.X - value2.X; result.Y = value1.Y - value2.Y; result.Z = value1.Z - value2.Z; result.W = value1.W - value2.W; return result; } public static Quaternion operator *(Quaternion value1, Quaternion value2) { float x = value1.X; float y = value1.Y; float z = value1.Z; float w = value1.W; float x2 = value2.X; float y2 = value2.Y; float z2 = value2.Z; float w2 = value2.W; float num = y * z2 - z * y2; float num2 = z * x2 - x * z2; float num3 = x * y2 - y * x2; float num4 = x * x2 + y * y2 + z * z2; Quaternion result = default(Quaternion); result.X = x * w2 + x2 * w + num; result.Y = y * w2 + y2 * w + num2; result.Z = z * w2 + z2 * w + num3; result.W = w * w2 - num4; return result; } public static Quaternion operator *(Quaternion value1, float value2) { Quaternion result = default(Quaternion); result.X = value1.X * value2; result.Y = value1.Y * value2; result.Z = value1.Z * value2; result.W = value1.W * value2; return result; } public static Quaternion operator /(Quaternion value1, Quaternion value2) { float x = value1.X; float y = value1.Y; float z = value1.Z; float w = value1.W; float num = value2.X * value2.X + value2.Y * value2.Y + value2.Z * value2.Z + value2.W * value2.W; float num2 = 1f / num; float num3 = (0f - value2.X) * num2; float num4 = (0f - value2.Y) * num2; float num5 = (0f - value2.Z) * num2; float num6 = value2.W * num2; float num7 = y * num5 - z * num4; float num8 = z * num3 - x * num5; float num9 = x * num4 - y * num3; float num10 = x * num3 + y * num4 + z * num5; Quaternion result = default(Quaternion); result.X = x * num6 + num3 * w + num7; result.Y = y * num6 + num4 * w + num8; result.Z = z * num6 + num5 * w + num9; result.W = w * num6 - num10; return result; } public static bool operator ==(Quaternion value1, Quaternion value2) { if (value1.X == value2.X && value1.Y == value2.Y && value1.Z == value2.Z) { return value1.W == value2.W; } return false; } public static bool operator !=(Quaternion value1, Quaternion value2) { if (value1.X == value2.X && value1.Y == value2.Y && value1.Z == value2.Z) { return value1.W != value2.W; } return true; } public bool Equals(Quaternion other) { if (X == other.X && Y == other.Y && Z == other.Z) { return W == other.W; } return false; } public override bool Equals(object obj) { if (obj is Quaternion) { return Equals((Quaternion)obj); } return false; } public override string ToString() { CultureInfo currentCulture = CultureInfo.CurrentCulture; return string.Format(currentCulture, "{{X:{0} Y:{1} Z:{2} W:{3}}}", X.ToString(currentCulture), Y.ToString(currentCulture), Z.ToString(currentCulture), W.ToString(currentCulture)); } public override int GetHashCode() { return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode(); } } [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; } [System.Runtime.CompilerServices.Intrinsic] public struct Vector<T> : IEquatable<Vector<T>>, IFormattable where T : struct { private struct VectorSizeHelper { internal Vector<T> _placeholder; internal byte _byte; } private Register register; private static readonly int s_count = InitializeCount(); private static readonly Vector<T> s_zero = default(Vector<T>); private static readonly Vector<T> s_one = new Vector<T>(GetOneValue()); private static readonly Vector<T> s_allOnes = new Vector<T>(GetAllBitsSetValue()); public static int Count { [System.Runtime.CompilerServices.Intrinsic] get { return s_count; } } public static Vector<T> Zero { [System.Runtime.CompilerServices.Intrinsic] get { return s_zero; } } public static Vector<T> One { [System.Runtime.CompilerServices.Intrinsic] get { return s_one; } } internal static Vector<T> AllOnes => s_allOnes; public unsafe T this[int index] { [System.Runtime.CompilerServices.Intrinsic] get { if (index >= Count || index < 0) { throw new IndexOutOfRangeException(System.SR.Format(System.SR.Arg_ArgumentOutOfRangeException, index)); } if (typeof(T) == typeof(byte)) { fixed (byte* byte_ = ®ister.byte_0) { return (T)(object)byte_[index]; } } if (typeof(T) == typeof(sbyte)) { fixed (sbyte* sbyte_ = ®ister.sbyte_0) { return (T)(object)sbyte_[index]; } } if (typeof(T) == typeof(ushort)) { fixed (ushort* uint16_ = ®ister.uint16_0) { return (T)(object)uint16_[index]; } } if (typeof(T) == typeof(short)) { fixed (short* int16_ = ®ister.int16_0) { return (T)(object)int16_[index]; } } if (typeof(T) == typeof(uint)) { fixed (uint* uint32_ = ®ister.uint32_0) { return (T)(object)uint32_[index]; } } if (typeof(T) == typeof(int)) { fixed (int* int32_ = ®ister.int32_0) { return (T)(object)int32_[index]; } } if (typeof(T) == typeof(ulong)) { fixed (ulong* uint64_ = ®ister.uint64_0) { return (T)(object)uint64_[index]; } } if (typeof(T) == typeof(long)) { fixed (long* int64_ = ®ister.int64_0) { return (T)(object)int64_[index]; } } if (typeof(T) == typeof(float)) { fixed (float* single_ = ®ister.single_0) { return (T)(object)single_[index]; } } if (typeof(T) == typeof(double)) { fixed (double* double_ = ®ister.double_0) { return (T)(object)double_[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; } [System.Runtime.CompilerServices.Intrinsic] public unsafe Vector(T value) { this = default(Vector<T>); if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* byte_ = ®ister.byte_0) { for (int i = 0; i < Count; i++) { byte_[i] = (byte)(object)value; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* sbyte_ = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { sbyte_[j] = (sbyte)(object)value; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* uint16_ = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { uint16_[k] = (ushort)(object)value; } } } else if (typeof(T) == typeof(short)) { fixed (short* int16_ = ®ister.int16_0) { for (int l = 0; l < Count; l++) { int16_[l] = (short)(object)value; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* uint32_ = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { uint32_[m] = (uint)(object)value; } } } else if (typeof(T) == typeof(int)) { fixed (int* int32_ = ®ister.int32_0) { for (int n = 0; n < Count; n++) { int32_[n] = (int)(object)value; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* uint64_ = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { uint64_[num] = (ulong)(object)value; } } } else if (typeof(T) == typeof(long)) { fixed (long* int64_ = ®ister.int64_0) { for (int num2 = 0; num2 < Count; num2++) { int64_[num2] = (long)(object)value; } } } else if (typeof(T) == typeof(float)) { fixed (float* single_ = ®ister.single_0) { for (int num3 = 0; num3 < Count; num3++) { single_[num3] = (float)(object)value; } } } else { if (!(typeof(T) == typeof(double))) { return; } fixed (double* double_ = ®ister.double_0) { for (int num4 = 0; num4 < Count; num4++) { double_[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; } } [System.Runtime.CompilerServices.Intrinsic] 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(System.SR.Format(System.SR.Arg_InsufficientNumberOfElements, Count, "values")); } if (Vector.IsHardwareAccelerated) { if (typeof(T) == typeof(byte)) { fixed (byte* byte_ = ®ister.byte_0) { for (int i = 0; i < Count; i++) { byte_[i] = (byte)(object)values[i + index]; } } } else if (typeof(T) == typeof(sbyte)) { fixed (sbyte* sbyte_ = ®ister.sbyte_0) { for (int j = 0; j < Count; j++) { sbyte_[j] = (sbyte)(object)values[j + index]; } } } else if (typeof(T) == typeof(ushort)) { fixed (ushort* uint16_ = ®ister.uint16_0) { for (int k = 0; k < Count; k++) { uint16_[k] = (ushort)(object)values[k + index]; } } } else if (typeof(T) == typeof(short)) { fixed (short* int16_ = ®ister.int16_0) { for (int l = 0; l < Count; l++) { int16_[l] = (short)(object)values[l + index]; } } } else if (typeof(T) == typeof(uint)) { fixed (uint* uint32_ = ®ister.uint32_0) { for (int m = 0; m < Count; m++) { uint32_[m] = (uint)(object)values[m + index]; } } } else if (typeof(T) == typeof(int)) { fixed (int* int32_ = ®ister.int32_0) { for (int n = 0; n < Count; n++) { int32_[n] = (int)(object)values[n + index]; } } } else if (typeof(T) == typeof(ulong)) { fixed (ulong* uint64_ = ®ister.uint64_0) { for (int num = 0; num < Count; num++) { uint64_[num] =
plugins/OverlayDearImGui.Shared/System.Runtime.CompilerServices.Unsafe.dll
Decompiled a month 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.100.24.56208")] [assembly: AssemblyInformationalVersion("6.1.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)] [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] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } }