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

C#获取win32api的问题

2008-8-23 16:35
4961
[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,为什么呢?

[课程]Android-CTF解题方法汇总!

收藏
免费 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
游客
登录 | 注册 方可回帖
返回
//