1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
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()));
}
} |
Partager