首页
社区
课程
招聘
C#获取win32api的问题
发表于: 2008-8-23 16:35 5024

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期)

收藏
免费 0
支持
分享
最新回复 (1)
雪    币: 225
活跃值: (10)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
2
汗,原来
   [DllImport("kernel32.dll", EntryPoint = "LoadLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);

GetProcAddress写成了LoadLibrary,都是复制惹得祸
2008-8-23 16:46
0
游客
登录 | 注册 方可回帖
返回
//