CTypes中函数中的空指针

2024-07-05 11:34:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要在我的项目中使用minHook.dll。 提供的示例看起来很简单,但我无法使其发挥作用。 我不明白这一部分:

MESSAGEBOXW fpMessageBoxW = NULL;

// Create a hook for MessageBoxW, in disabled state.
if (MH_CreateHook(&MessageBoxW, &DetourMessageBoxW, 
    reinterpret_cast<LPVOID*>(&fpMessageBoxW)) != MH_OK)
{
    return 1;
}

下面是我的Python代码(根据需要钩住的函数进行了调整):

^{pr2}$

最后会出现一个错误:

TypeError: byref() argument must be a ctypes instance, not 'NoneType'

我该怎么做才能至少使MH_CreateHook返回1?在

更新:这里是MH_CreateHook签名:

MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal)

Tags: 项目示例forcreatehooknulldllmh