-
Notifications
You must be signed in to change notification settings - Fork 8
/
MappedModuleDatabase.cs
39 lines (32 loc) · 1.09 KB
/
MappedModuleDatabase.cs
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
39
using BlackOps2SoundStudio.Properties;
using System;
using System.Runtime.InteropServices;
namespace BlackOps2SoundStudio
{
static class MappedModuleDatabase
{
public static MemoryModule libFLAC { get; private set; }
static MappedModuleDatabase()
{
libFLAC = new MemoryModule("libFLAC.dll");
}
}
class MemoryModule
{
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
public IntPtr ModuleHandle { get; set; }
public MemoryModule(string path)
{
ModuleHandle = LoadLibrary(path);
if (ModuleHandle == IntPtr.Zero)
throw new DllNotFoundException(path);
}
public IntPtr GetProcAddress(string procName)
{
return GetProcAddress(ModuleHandle, procName);
}
}
}