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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!