summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorannaaniol <aa.annaaniol@gmail.com>2018-08-23 08:52:34 -0700
committerSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>2018-10-05 18:43:51 -0700
commit683663b8401432a938822a13de0538300aa3e158 (patch)
tree05a82be5002c1d188fdf730b85a73885baeee5d5 /Documentation
parentcfd39bdb4ddfa9ced1297c21d8be68951398d1f2 (diff)
downloadcoreclr-683663b8401432a938822a13de0538300aa3e158.tar.gz
coreclr-683663b8401432a938822a13de0538300aa3e158.tar.bz2
coreclr-683663b8401432a938822a13de0538300aa3e158.zip
Update the dllmap design doc (4)
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/design-docs/dllmap.md28
1 files changed, 15 insertions, 13 deletions
diff --git a/Documentation/design-docs/dllmap.md b/Documentation/design-docs/dllmap.md
index 3af0e1bd9b..477f9265e2 100644
--- a/Documentation/design-docs/dllmap.md
+++ b/Documentation/design-docs/dllmap.md
@@ -161,7 +161,7 @@ As explained above, runtime will rise two dll specific events on each load attem
* 1st callback - when loading a non-system library
* 2nd callback - when finding an entrypoint
-Events will be defined in `AssemblyLoadContext` in `System.Private.CoreLib`. Default handlers that subscribe dll load events will implement the mono-based dllmap logic.
+Events will be defined in `AssemblyLoadContext` in `System.Private.CoreLib`. Default handlers that subscribe to dll load events will implement the mono-based dllmap logic.
They will take string as argument and return IntPtr of target libraries and entrypoints based on the parsed XML configuration file.
Handlers implementation will stay in `corefx.labs`. Load library resolver will cache all the dll mapping results that got resolved (as key-value: IntPtr-hmod pairs).
@@ -169,18 +169,20 @@ Thanks to that, the same library won't get loaded multiple times. User’s code
That will give a user full flexibility when using dllmap and won’t limit defining the mapping to only xml-based style.
Callbacks can be executed for all assemblies except `System.Private.CoreLib`.
+We do not plan to support unsubscribing from events at this point.
+
### Resolution flow
**User’s code [managed code]**
- Includes `using System.Runtime.Dllmap`
-- Subscribes to `ResolveNativeDllName` and `ResolveNativeEntrypointName` events with their default or custom handler
+- Subscribes to `LoadNativeLibrary` and `LoadNativeEntrypoint` events with their default or custom handler
- Uses DllImport directive and does the p/invoke
```c#
using System.Runtime.Dllmap;
- System.Runtime.Loader.AssemblyLoadContext.Default.ResolveNativeDllName += LoadNativeDllViaDllMap;
- System.Runtime.Loader.AssemblyLoadContext.Default.ResolveNativeEntrypointName += GetEntrypointViaDllMap;
+ System.Runtime.Loader.AssemblyLoadContext.Default.LoadNativeLibrary += LoadLibraryCustomHandler;
+ System.Runtime.Loader.AssemblyLoadContext.Default.LoadNativeEntrypoint += LoadEntrypointCustomHandler;
[DllImport("MyLibrary.dll", EntryPoint="MyFunction")]
static extern int MyFunction();
@@ -189,21 +191,21 @@ Callbacks can be executed for all assemblies except `System.Private.CoreLib`.
```
**Runtime [unmanaged code]**
-- Calls `LoadLibraryModuleViaCallback` that raises `ResolveNativeDllName` event
-- Calls `GetEntrypointViaCallback` that raises `ResolveNativeEntrypointName` event
+- Calls `LoadLibraryModuleViaCallback` that raises `LoadNativeLibrary` event
+- Calls `GetEntrypointViaCallback` that raises `LoadNativeEntrypoint` event
**AssemblyLoadContext [unmanaged code]**
-- Defines `ResolveNativeDllName` and `ResolveNativeEntrypointName` and exposes an API:
+- Defines `LoadNativeLibrary` and `LoadNativeEntrypoint` and exposes an API:
```c#
- IntPtr ResolveNativeDllName(string libraryName)
- IntPtr ResolveNativeEntrypointName(string entrypointName, HMOD hmod)
+ IntPtr LoadNativeLibrary(string libraryName)
+ IntPtr LoadNativeEntrypoint(string entrypointName, HMOD hmod)
```
**corefx.labs [managed code]**
-- Implements default handlers - `LoadNativeDllViaDllMap` and `GetEntrypointViaDllMap`
-- To avoid infinite looping, `LoadNativeDllViaDllMap` takes a lock and releases it after the default library loading process is completed
+- Implements default handlers - `LoadLibraryCustomHandler` and `LoadEntrypointCustomHandler`
+- To avoid infinite looping, `LoadLibraryCustomHandler` takes a lock and releases it after the default library loading process is completed
```c#
- IntPtr LoadNativeDllViaDllMap(string libraryName)
+ IntPtr LoadLibraryCustomHandler(string libraryName)
{
private Object dllLock = new Object();
@@ -222,7 +224,7 @@ Callbacks can be executed for all assemblies except `System.Private.CoreLib`.
}
```
```c#
- IntPtr GetEntrypointViaDllMap(string entrypointName, HMOD hmod)
+ IntPtr LoadEntrypointCustomHandler(string entrypointName, HMOD hmod)
{
targetEntrypointName = mapStructure.GetEntrypoint(entrypointName);
pvTarget = GetProcAddress(targetEntrypointName, hmod);