AaronRobinsonMSFT / AaronRobinsonMSFT/DNNE

Using DNNE to generate proxy libraries

Aberta
#100 3 comentários 0 reações 0 responsáveis Ver no GitHub
discussion enhancement
Linguagem predominante
C#
Estrelas
488
Forks
46
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

I am interested in experimenting with using DNNE to generate proxy libraries in C# using source generators, but I believe there is additional functionality necessary in DNNE to do so. I'm intending for this issue to serve as a discussion into how this functionality could be exposed (or if it's even considered to be within scope for the project.)

As a simple example: imagine that we want to log API calls to a COM library, which has the following exports:
```cs
DllGetClassObject
DllCanUnloadNow
```
A proxy library for this can be implemented today with code similar to the example below:
```cs
// The Get* methods will perform NativeLibrary.Load/GetExport to retrieve the exports from the real library.
static readonly delegate* unmanaged DllGetClassObject = GetDllGetClassObject();
static readonly delegate* unmanaged DllCanUnloadNow = GetDllCanUnloadNow();

[UnmanagedCallersOnly(EntryPoint = "DllGetClassObject")]
static uint ProxyDllGetClassObject(Guid* rclsid, Guid* riid, void** ppv)
{
// Perform some logging
return DllGetClassObject(rclsid, riid, ppv);
}

[UnmanagedCallersOnly(EntryPoint = "DllCanUnloadNow")]
static uint ProxyDllCanUnloadNow()
{
// Perform some logging
return DllCanUnloadNow();
}
```
The signatures for these functions are well-known, but for the sake of the example let's imagine we either don't know what they are, or that they aren't relevant for what we want to do (in this example, logging API calls.)

Let's say that we only want to log calls to `DllGetClassObject`, and we don't care about `DllCanUnloadNow` (or the potentially _many_ other exports in the library). We would need to know the signatures of all of these exports in order to produce a proxy library with the above technique.

The solution typically employed for this is for the body of the proxy method to simply `jmp` to the address of the real method, but as far as I'm aware there is currently no way to replicate this technique from DNNE.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.