Bonjour,
Je charge une dll (C++) dynamiquement (avec [U]LoadLibrary[/U]) dans mon programme C#.
J'arrive à invoquer des méthodes, etc, etc...
J'aimerais à présent récupérer l'adresse (de début) où ma dll est
chargée en mémoire, j'essaie avec des fonctions de psapi comme suit :
unsafe public struct MODULEINFO
{
public IntPtr lpBaseOfDll;
public UInt64 SizeOfImage;
public IntPtr EntryPoint;
}
[DllImport("psapi.dll")]
unsafe private static extern Boolean GetModuleInformation(
[In]IntPtr hProcess,
[In]IntPtr hModule,
[Out]MODULEINFO* moduleInfo,
[In]UInt64 tailleModuleInfo
);
[DllImport("Kernel32.dll")]
private static extern IntPtr LoadLibrary(
[In] string lpFileName
);
unsafe public void LoadDll(String nomDLL)
{
if (!_isDllLoaded)
{
_DllHModule = LoadLibrary(CheminDll + nomDLL);
_isDllLoaded = (_DllHModule != IntPtr.Zero);
}
MODULEINFO moduleInfo;
Process currentProcess = Process.GetCurrentProcess();
if (_isDllLoaded)
{
retour = GetModuleInformation(currentProcess.Handle, _DllHModule, &moduleInfo, (UInt64)Marshal.SizeOf(moduleInfo.GetType()));
}
}
et cela ne marche pas, GetModuleInformation me retourne un false... :?
Ai-je bien fait de redéfinir MODULEINFO (en m'inspirant de psapi.h) ?
Voyez vous un bug ?
Ou alors connaissez vous un moyen entièrement C#/.NET de récupérer cette information ?
Merci.
Pascal
Pascal