首页 新闻 会员 周边

会EasyHook的来给帮个忙?

1
悬赏园豆:10 [已关闭问题] 关闭于 2013-11-23 10:43

EasyHook太不Easy了,想实现一个很Easy的功能,一直没弄出来。

需求很简单,只需要LocalHook,不需要全局Hook,能在C#WinForm中Hook住本进程的MessageBoxW就可以了。初学不太懂,高人们给点提示吧?

我的代码如下,运行后没有任何反应:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using EasyHook;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form,IEntryPoint
    {
        delegate IntPtr MessageBoxWCallback(int hwnd, IntPtr lpText, IntPtr lpCaption, int wType);

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            var MyHook = LocalHook.Create(LocalHook.GetProcAddress("user32.dll", "MessageBoxW"),
                new MessageBoxWCallback(MessageBoxWProc), this);

            MyHook.ThreadACL.SetExclusiveACL(new Int32[] { 0 });
        }

        static IntPtr MessageBoxWProc(int hwnd, IntPtr lpText, IntPtr lpCaption, int wType)
        {
            return new IntPtr(0);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("ok");
        }
    }
}
空明流光的主页 空明流光 | 初学一级 | 园豆:106
提问于:2013-11-23 10:28
< >
分享
所有回答(1)
0

MyHook.ThreadACL.SetInclusiveACL(new Int32[] { 0 });

空明流光 | 园豆:106 (初学一级) | 2013-11-23 10:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册