- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试 Hook 一个具有签名的未记录的函数:
(void(__thiscall*)(int arg1, int arg2))0x6142E0;
我看过弯路示例“成员”,它解释了:
By default, C++ member functions use the __thiscall calling convention. In order to Detour a member function, both the trampoline and the detour must have exactly the same calling convention as the target function. Unfortunately, the VC compiler does not support a __thiscall, so the only way to create legal detour and trampoline functions is by making them class members of a "detour" class.
In addition, C++ does not support converting a pointer to a member function to an arbitrary pointer. To get a raw pointer, the address of the member function must be moved into a temporary member-function pointer, then passed by taking it's address, then de-referencing it. Fortunately, the compiler will optimize the code to remove the extra pointer operations.
我已经从示例中复制了一些代码并对其进行了修改,但我似乎无法让它工作(original example code here):
class CDetour {
public:
void Mine_Target(int arg1, int arg2);
static void (CDetour::* Real_Target)(int arg1, int arg2);
};
void CDetour::Mine_Target(int arg1, int arg2) {
printf(" CDetour::Mine_Target! (this:%p)\n", this);
(this->*Real_Target)(arg1, arg2);
}
void (CDetour::* CDetour::Real_Target)(int arg1, int arg2) = (void(CDetour::*)(int arg1, int arg2)) (0x6142E0);
void hoo()
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)CDetour::Real_Target, (PVOID)(&(PVOID&)CDetour::Mine_Target));
DetourTransactionCommit();
}
我不确定如何让它工作。 a bow 代码有两个编译器错误:
void (CDetour::* CDetour::Real_Target)(int arg1, int arg2) = (void(CDetour::*)(int arg1, int arg2)) (0x6142E0);
//Error C2440 'type cast': cannot convert from 'int' to 'void (__thiscall CDetour::* )(int,int)'
和:
DetourAttach(&(PVOID&)CDetour::Real_Target, (PVOID)(&(PVOID&)CDetour::Mine_Target));
//Error C2440 'type cast': cannot convert from 'void (__thiscall CDetour::* )(int,int)' to 'PVOID &'
我希望有人能在正确的方向上帮助我,因为我即将放弃 Hook __thiscall 函数...
我正在考虑使用内联汇编编写一个全局“__declspec( naken ) void MyFunc(int, int)”函数,以便按照建议保留“this 指针”here .
最佳答案
Detours 已经相当老了。明确 compiler support for __thiscall
是相当新的。看起来在 Visual C++ 2005 及更高版本中支持它。似乎 Detours 文档从未更新过。
关于c++ - Microsoft Detours - 无法 Hook __thiscall 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34301293/
我有几个关于 Microsoft Detours Library 的快速问题。我以前用过(成功),但是我只是想到了这个功能: LONG DetourUpdateThread(HANDLE hThrea
我是 Microsoft Detours 的新手。我已经安装它来跟踪进程进行的系统调用。我运行以下从网上获得的命令 syelogd.exe /q C:\Users\xxx\Desktop\log.tx
我正在寻找 Delphi 示例,但我只能找到 C++ 示例代码。 例如,如何在Delphi中定义下面的钩子(Hook)? DETOUR_TRAMPOLINE(int WINAPI SetScrol
我正在尝试拦截系统上每个对象的构造/销毁。为此,我使用 Detours Lib创建运行时补丁。它似乎以某种方式工作 FastCode方法确实如此。我认为它应该有相同的限制(无法修补操作码小于 5 个字
请问tileLayers在detour中是如何工作的。 我能否将任意 2 block 瓷砖分层,导致“切口”合并到更大的洞中?以何种方式,是否有任何限制?我可以拥有多少层以及它们在导航时如何交互。例如
在这里感觉很愚蠢,但为什么这段代码在 Visual 中给我一个语法错误Studio 何时尝试编译它? DetourAttach(&(PVOID&)true_create_file, creat
我尝试在谷歌上搜索编译器错误,但它甚至没有返回搜索结果。所以,我在这里有点迷路了。我刚刚下载了 Microsoft Detours,构建它并从中获取了 detours.h、detours.lib、de
我在使用 Microsoft Detours 时遇到访问冲突问题。我制作了一个加载到第三方应用程序中的 dll。我正在使用 Detours 制作一个蹦床功能到一个未记录的功能,Ida Pro 显示为:
我正在寻找一个 C 库/框架,它允许我替换内存中的函数并将它们重定向到我自己的实现,同时仍然允许我的实现调用原始实现。 这在 Linux-y 系统上似乎是一个相当罕见的需求,大概是因为 LD_PREL
我有一个应用程序,它使用 Winsock 2.0 recv 函数,我可以通过 Redox Packet Editor 捕获输出,例如,它确认版本是 2.0。 我有这段代码来 Hook 函数: #def
我不会在 Minesweeper 中绕过 PlaySoundW 功能。游戏一调用 PlaySoundW 函数就崩溃了。如果我在我的代码中取消对 Beep 的注释,游戏会发出哔哔声然后崩溃。 现在代码正
我正在尝试学习使用弯路修改和扩展程序中的功能。在本例中,我尝试修改 Windows 记事本 32 位中的 InsertDateTime 函数。 我正在使用 Winject 注入(inject)我创建的
很长一段时间我都没有遇到使用 Detours 劫持函数的问题...当我试图劫持类方法时(在我的例子中是 IHTMLDocument2::write from mshtml.dll)我遇到了无穷无尽的问
我通过函数偏移量在外部进程中 Hook 函数。到目前为止,这对于我 Hook 的函数来说效果很好——但是我发现一个“debugLog(char...)”函数仍然存在于二进制文件中但不进行任何打印——它
detours包声称支持 64 位 但我没有看到编译 64 位 二进制文件的方法: Detouring 32-bit and 64-bit Processes 使用nmake all 只编译32 位
很长一段时间我都没有遇到使用 Detours 劫持函数的问题...当我试图劫持类方法时(在我的例子中是 IHTMLDocument2::write from mshtml.dll)我遇到了无穷无尽的问
我是新来的,这是我提出的第一个问题。我希望在这里相处得很好:)对于我的问题!: 我为 x64 处理器(普通英特尔 x64)写了一个 Detouring 基础设施 主要有趣的函数如下所示: typede
我将在Visual Studio 2013或Visual Studio 2019中编译旧项目(Visual Studio 2012 Platform-v110xp)。 它使用了boost和Micros
我无法使用绕行来获得我的第一个钩子(Hook)。我正在使用 Detour 3.0。 我的代码编译得很好,我可以使用 Winject 注入(inject) DLL,但是,我应该 Hook 的函数似乎没有
我正在使用: 微软 VS 10 Detours v3.0 Express 完整的源代码DLL: #include #include ofstream prclist ; #pragma comme
我是一名优秀的程序员,十分优秀!