[英]C++ Missing type specifier: syntax error
I hook a function with windows detours in C++.我在 C++ 中将 function 与 windows 绕道挂钩。
I get an error in following code:我在以下代码中收到错误:
void (*asmFunction)(const char *text);
void hookFunction(const char *text) {
__asm nop;
asmFunction(text);
}
asmFunction = (void (__cdecl *)(const char *))DetourFunction((PBYTE)0x433A90, (PBYTE)&hookFunction);
The compiler (MSVC++ 2008) says:编译器(MSVC++ 2008)说:
error C4430: Missing type specifier - int assumed.错误 C4430:缺少类型说明符 - 假定为 int。 Hint: "default-int" is not supported in C++.提示:C++ 不支持“default-int”。 Yadda yadda …亚达亚达…
error C2373: 'asmFunction': redefinition with different specifiers错误 C2373:“asmFunction”:使用不同的说明符重新定义
error C2440: 'in initialization': 'void (__cdecl *)(const char *)' cannot be converted to 'int'.错误 C2440:“初始化中”:“void (__cdecl *)(const char *)”无法转换为“int”。 There is no context in which this conversion is valid.没有此转换有效的上下文。
The code worked yesterday.该代码昨天工作。 What's wrong with it?它出什么问题了? How can I fix it without destructing the hook?如何在不破坏钩子的情况下修复它?
This expression needs to be within a function, eg此表达式需要在 function 内,例如
int main() {
asmFunction = (void (__cdecl *)(const char *))DetourFunction(
(PBYTE)0x433A90, (PBYTE)&hookFunction
);
// ...
}
Go read a book on C++ . Go 阅读有关 C++ 的书。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.