扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:莫艺潜 来源:天极开发 2007年11月21日
关键字:
int m_hTargetWindow;//要挂接的目标窗体句柄 IntPtr m_hTargetProcess;//目标窗体所属的进程 IntPtr m_hModule; //挂接DLL的句柄 private void Form1_Load(object sender, EventArgs e) { IntPtr tpTemp = IntPtr.Zero, tpTempa = IntPtr.Zero; uint tuntApiRet; m_hTargetWindow = (int)clsCECoreAPI.FindWindow("Explore", null );//资源 //挂接指定的进程窗体消息 IntPtr thCurrentProcess = clsCECoreAPI.GetCurrentProcess(); m_hTargetProcess=IntPtr.Zero ;// (IntPtr) (unchecked((int)0xedd84e4a)); tuntApiRet= clsCECoreAPI.GetWindowThreadProcessId(new IntPtr(unchecked((int) m_hTargetWindow)), ref m_hTargetProcess); string tstrArgument; tstrArgument = "\\Program Files\\processinject\\HookWindowsProcMFCDLL.dll";// HookWindowsProcMFCDLL.dll"; IntPtr tpArg0; int tintOriginalKMode = clsCECoreAPI.SetKMode(1); int tintOriginalProcPermission = (int)clsCECoreAPI.SetProcPermissions(0xffffffff); IntPtr tpFuncProc = clsCECoreAPI.GetProcAddress(clsCECoreAPI.GetModuleHandle("coredll.dll"), "LoadLibraryW"); CallBackInfo tudtCALLBACKINFO; tpArg0 = clsCECoreAPI.MapPtrToProcess(tstrArgument, thCurrentProcess); tudtCALLBACKINFO.hProc = m_hTargetProcess;// Proc; tudtCALLBACKINFO.pfn = clsCECoreAPI.MapPtrToProcess(tpFuncProc, m_hTargetProcess); tudtCALLBACKINFO.pvArg0 = tpArg0; m_hModule =new IntPtr(unchecked( (int) clsCECoreAPI.PerformCallBack4(ref tudtCALLBACKINFO,IntPtr.Zero,IntPtr.Zero,IntPtr.Zero ))); //clsCECoreAPI.Sleep(1000); IntPtr thModule = clsCECoreAPI.LoadLibrary("HookWindowsProcMFCDLL.dll"); tpFuncProc = clsCECoreAPI.GetProcAddress(thModule, "fnAttachWinProc"); tpArg0 = (IntPtr) m_hTargetWindow;// clsCECoreAPI.MapPtrToProcess(ref thTargetWindow, thCurrentProcess); tudtCALLBACKINFO.hProc = m_hTargetProcess; tudtCALLBACKINFO.pfn = clsCECoreAPI.MapPtrToProcess(tpFuncProc, m_hTargetProcess); tudtCALLBACKINFO.pvArg0 = tpArg0 ; tuntApiRet = clsCECoreAPI.PerformCallBack4(ref tudtCALLBACKINFO,IntPtr.Zero,IntPtr.Zero,IntPtr.Zero ); //clsCECoreAPI.Sleep(5000); } [DllImport("HookWindowsProcMFCDLL.dll")] public static extern int fnAttachWinProc(IntPtr ni_hAttatchWin); [DllImport("HookWindowsProcMFCDLL.dll")] public static extern int fnDetachWinMsgProc(IntPtr ni_hDetachWin); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者