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 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试