-
-
C#获取win32api的问题
-
发表于:
2008-8-23 16:35
5024
-
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr LoadLibrary(String lpFileName);
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
[DllImport("kernel32.dll", EntryPoint = "FreeLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern bool FreeLibrary(IntPtr hModule);
private void button1_Click(object sender, EventArgs e)
{
IntPtr farProc = GetProcAddress(LoadLibrary("User32.dll"), "MessageBox");
MessageBox.Show(farProc.ToString());
}
奇怪为什么的不到messagebox的地址呢?
LoadLibrary("User32.dll")是可以正常可以获取的,可GetProcAddress去返回0,为什么呢?
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)