1

通过保存函数地址的指针调用函数会生成错误代码:

p=GetProcAddress(h,"installhook");//p is a pointer that holds the address returned from getprocaddress() function
(*p)(); //using this pointer making a call to installhook function

但是当我通过它进行调用时,代码正在生成错误,(*p)();它说术语不会评估为函数。如何克服这个问题?还有其他方法可以使用指针调用函数吗?

4

2 回答 2

2

您需要将返回值GetProcAddress转换为正确的函数类型。例如:

typedef void (*FuncPtr)();    //assuming a function like void f()
FuncPtr p;

p = (FuncPtr) GetProcAddress(h, "funcName");
if (p)
    p();
else
    printf("Function not found\n");
于 2012-06-10T18:21:15.040 回答
2

验证p声明如下:

void (*p)(void);

并且返回值的类型GetProcAddress是相同的。

于 2012-06-10T18:21:30.920 回答