WINAPI指针不工作/语法错误?(初学者问题)



我试图通过以下代码将调用隐藏在程序的导入地址表中:

BOOL (WINAPI * pVirtualProtect)(  [in]  LPVOID lpAddress, [in]  SIZE_T dwSize, [in]  DWORD  flNewProtect, [out] PDWORD lpflOldProtect);

以及后来的

pVirtualProtect = GetProcAddress(GetModuleHandler("kernel32.dll"), "VirtualProtect");
rv = pVirtualProtect(exec_mem, calc_len, PAGE_EXECUTE_READ, &oldprotect);

错误:

1.cpp(14): error C2143: Syntaxerror: Needed ")" before "["
1.cpp(14): error C2065: "in": undeclared Identifier 
1.cpp(14): error C2057: Constant expression expected
1.cpp(14): error C2466: Assignment of the Arrays not possible with constant size 0.
1.cpp(14): error C2090: Functional result is an array
1.cpp(14): error C2054: After "pVirtualProtect" should follow "(" 
1.cpp(14): error C2085: "lpAddress": Not included in the formal parameter list
1.cpp(14): error C2059: Syntaxerror: "["
1.cpp(14): error C2059: Syntaxerror: ")"

这里有什么问题?我感谢每一个回答。

您不应该像那样在源代码中编写[in][out]。我想你是从某个地方的一些文档中复制的,在那里它被用来指示这些参数的用途,但你在实际C++代码中使用它们是无效的。

最新更新