使用Detours挂钩Python代码 [英] Hooking Python code using Detours

查看:78
本文介绍了使用Detours挂钩Python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我构建了一个简单的Python gui应用程序("App.py"),该应用程序试图使用弯路进行弯钩.我的理解是Python应该在某个时候使用Windows dll,我正在尝试挂钩这些函数调用.

I built a simple Python gui application("App.py") that I am trying to hook using detours. My understanding is that Python should use Windows dll's at some point and I am trying to hook these function calls.

为此,我正在绕道绕过dll.exe:

For that purpose I am using detours withdll.exe :

withdll.exe /d:"myDLL.dll" "myprogram.exe"

因为withdll.exe不接受运行带有参数的程序("python.exe App.py"),所以我尝试如下创建bat文件starter.bat:

Because withdll.exe doesn't accept running a program with arguments ("python.exe App.py"), I tried creating a bat file starter.bat as follows:

cd appdir
python App.py

然后运行:

withdll.exe /d:"myDLL.dll" "starter.bat"

但是,此方法仅挂接后台cmd进程.

However this approach only hooks the background cmd process.

是否有一种变通方法来绕过我的脚本的Python.exe进程?

Is there a workaround to make detours hook the Python.exe process of my script ?

推荐答案

我仔细检查了withdll.exe源代码,发现它可以接受命令行参数,使用以下方法解决了该问题:

I looked through detours withdll.exe source code and found out that it can take command line arguments, the issue was solved using:

withdll.exe /d:"myDLL.dll" "pathtopython/Python.exe" "pathtoscript/myscript.py"

这篇关于使用Detours挂钩Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆