k345bu 2015-07-24 06:11
浏览 3055

HOOK WebBrowser获取打开的网址 request response header等.

以下代码使用了EsayHook

想先获取到打开的网址. 无奈断点断不到..是否HOOK的函数错了?

 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using EasyHook;


namespace TestHookAPI
{
    public partial class Form1 : Form
    {
        LocalHook hookt = null;
        [DllImport("WININET.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern IntPtr InternetOpenUrlW(
                                IntPtr hInternet,
                                string lpszUrl,
                                string lpszHeaders,
                                Int32 dwHeadersLength,
                                Int32 dwFlags,
                                System.UIntPtr dwContext
                                );

        [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode, SetLastError = true)]
        public delegate IntPtr d_InternetOpenUrl(
                                        IntPtr hInternet,
                                        string lpszUrl,
                                        string lpszHeaders,
                                        Int32 dwHeadersLength,
                                        Int32 dwFlags,
                                        System.UIntPtr dwContext
                                        );
        public static IntPtr h_InternetOpenUrl(
                                        IntPtr hInternet,
                                        string lpszUrl,
                                        string lpszHeaders,
                                        Int32 dwHeadersLength,
                                        Int32 dwFlags,
                                        System.UIntPtr dwContext
                                        )
        {
            IntPtr pret = InternetOpenUrlW(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
            return pret;
        }

        public Form1()
        {
            InitializeComponent();

        }
        private void Form1_Load(object sender, EventArgs e)
        {
            hookt = LocalHook.Create(LocalHook.GetProcAddress("WININET.dll", "InternetOpenUrlW"), new d_InternetOpenUrl(h_InternetOpenUrl), this);
            hookt.ThreadACL.SetExclusiveACL(new Int32[0]);
            webBrowser1.Navigate("http://www.baidu.com/");
        }

        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {

        }
    }
}

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作