gpt4 book ai didi

c++ - 与 PVOID 的参数类型不兼容

转载 作者:行者123 更新时间:2023-11-30 03:43:33 27 4
gpt4 key购买 nike

使用绕行 v3,我收到此错误:

argument of type "signed int (Std::*)(int a1, int a2, int a3)" is incompatible with parameter of type "PVOID"   Std.cpp 39  

当我尝试从我的类的函数中使用 DetourAttach 时。

Std* _std = new Std();

case DLL_PROCESS_ATTACH:
DetourAttach(&(PVOID&)_std->m_pKey, &Std::m_Key);

// or if I do this
DetourAttach(&(PVOID&)_std->m_pKey, _std->m_Key);
// the error becomes Std::m_Key non-stardard syntax; use & to create a pointer to member

我知道我可以在不使用类的情况下做到这一点,但我希望这样做。有什么建议吗?


更新

DetourAttach 签名(也可以找到 here ):

LONG WINAPI DetourAttach(PVOID *ppPointer,
PVOID pDetour)

至于Std::m_Key

int Std::m_Key(int a1, int a2, int a3)
{
return m_pKey(a1, a2, a3);
}

最佳答案

这个函数签名是:

LONG DetourAttach(
PVOID * ppPointer,
PVOID pDetour
);

第一个参数是指向要迂回 的函数的指针。第二个是您自己的函数,将被调用。由于只能提供单个指针,因此您无法在类实例上调用方法。要调用类实例方法,您需要一个指向类对象的指针和一个指向方法的指针。

所以你需要一个免费的功能(非成员(member))来让它工作。

[编辑]

你的自由函数可以调用你的 Std 类实例方法:

Std* _std = new Std();
int m_Global_Key(int a1, int a2, int a3)
{
return _std->m_Key(a1, a2, a3);
}

或者你可以让 Std::m_Key 成为一个静态函数,但它与全局函数没有太大区别。

关于c++ - 与 PVOID 的参数类型不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36007262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com