Class DynDll
Inheritance
Namespace: MonoMod.Utils
Assembly: MonoMod.Utils.dll
Syntax
public static class DynDll : Object
Fields
Mappings
Allows you to remap library paths / names and specify loading flags. Useful for cross-platform compatibility. Applies only to DynDll.
Declaration
public static Dictionary<string, DynDllMapping> Mappings
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, DynDllMapping> |
Methods
_OpenLibrary(String, Boolean, Nullable<Int32>)
Declaration
public static IntPtr _OpenLibrary(string name, bool skipMapping, Nullable<int> flags)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | |
System.Boolean | skipMapping | |
System.Nullable<System.Int32> | flags |
Returns
Type | Description |
---|---|
System.IntPtr |
AsDelegate<T>(IntPtr)
Extension method wrapping Marshal.GetDelegateForFunctionPointer
Declaration
public static T AsDelegate<T>(this IntPtr s)
where T : class
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | s |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
CloseLibrary(IntPtr)
Release a library handle obtained via OpenLibrary. Don't release the result of OpenLibrary(null)!
Declaration
public static bool CloseLibrary(IntPtr lib)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | lib | The library handle. |
Returns
Type | Description |
---|---|
System.Boolean |
GetFunction(IntPtr, String)
Get a function pointer for a function in the given library.
Declaration
public static IntPtr GetFunction(this IntPtr lib, string name)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | lib | The library handle. |
System.String | name | The function name. |
Returns
Type | Description |
---|---|
System.IntPtr | The function pointer. |
OpenLibrary(String, Boolean, Nullable<Int32>)
Open a given library and get its handle.
Declaration
public static IntPtr OpenLibrary(string name, bool skipMapping = false, Nullable<int> flags = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The library name. |
System.Boolean | skipMapping | Whether to skip using the mapping or not. |
System.Nullable<System.Int32> | flags | Any optional platform-specific flags. |
Returns
Type | Description |
---|---|
System.IntPtr | The library handle. |
ResolveDynDllImports(Object, Dictionary<String, DynDllMapping>)
Fill all instance delegate fields with the DynDllImport attribute. Call this early on in the constructor.
Declaration
public static void ResolveDynDllImports(object instance, Dictionary<string, DynDllMapping> mappings = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | instance | An instance of a type containing the DynDllImport delegate fields. |
System.Collections.Generic.Dictionary<System.String, DynDllMapping> | mappings | Any optional mappings similar to the static mappings. |
ResolveDynDllImports(Type, Dictionary<String, DynDllMapping>)
Fill all static delegate fields with the DynDllImport attribute. Call this early on in the static constructor.
Declaration
public static void ResolveDynDllImports(this Type type, Dictionary<string, DynDllMapping> mappings = null)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type containing the DynDllImport delegate fields. |
System.Collections.Generic.Dictionary<System.String, DynDllMapping> | mappings | Any optional mappings similar to the static mappings. |
TryGetFunction(IntPtr, String, out IntPtr)
Get a function pointer for a function in the given library.
Declaration
public static bool TryGetFunction(this IntPtr lib, string name, out IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | lib | The library handle. |
System.String | name | The function name. |
System.IntPtr | ptr | The function pointer, or null if it wasn't found. |
Returns
Type | Description |
---|---|
System.Boolean | True if the function pointer was obtained, false otherwise. |
TryOpenLibrary(String, out IntPtr, Boolean, Nullable<Int32>)
Try to open a given library and get its handle.
Declaration
public static bool TryOpenLibrary(string name, out IntPtr lib, bool skipMapping = false, Nullable<int> flags = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The library name. |
System.IntPtr | lib | The library handle, or null if it failed loading. |
System.Boolean | skipMapping | Whether to skip using the mapping or not. |
System.Nullable<System.Int32> | flags | Any optional platform-specific flags. |
Returns
Type | Description |
---|---|
System.Boolean | True if the handle was obtained, false otherwise. |