gpt4 book ai didi

C++ 缺少类型说明符 : syntax error

转载 作者:行者123 更新时间:2023-11-27 23:29:21 24 4
gpt4 key购买 nike

我用 C++ 中的 windows 弯路 Hook 了一个函数。

我在以下代码中遇到错误:

void (*asmFunction)(const char *text);
void hookFunction(const char *text) {
__asm nop;
asmFunction(text);
}
asmFunction = (void (__cdecl *)(const char *))DetourFunction((PBYTE)0x433A90, (PBYTE)&hookFunction);

编译器 (MSVC++ 2008) 说:

error C4430: Missing type specifier - int assumed. Hint: "default-int" is not supported in C++. Yadda yadda …
error C2373: 'asmFunction': redefinition with different specifiers
error C2440: 'in initialization': 'void (__cdecl *)(const char *)' cannot be converted to 'int'. There is no context in which this conversion is valid.

代码昨天有效。它出什么问题了?如何在不破坏钩子(Hook)的情况下修复它?

最佳答案

这个表达式需要在一个函数中,例如

int main() {
asmFunction = (void (__cdecl *)(const char *))DetourFunction(
(PBYTE)0x433A90, (PBYTE)&hookFunction
);
// ...
}

去读a book on C++ .

关于C++ 缺少类型说明符 : syntax error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6641685/

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