Dev-C++和Detours编译错误

发布于 2024-09-04 18:47:27 字数 1516 浏览 2 评论 0原文

正如标题所说,我正在尝试使用 Detours 用 Dev-C++ 编译一个简单的 DLL,但我收到此错误:

syntax error before token '&'

在这一行上:

DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)

完整的代码是

#include <windows.h>
#include <detours.h>

#pragma comment( lib, "Ws2_32.lib" )
#pragma comment( lib, "detours.lib" )
#pragma comment( lib, "detoured.lib" )


int (WINAPI * trueMessageBox)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) = MessageBox;
int WINAPI hookedMessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
    LPCSTR lpNewCaption = "You've been hijacked";
    int iReturn = trueMessageBox(hWnd, lpText, lpNewCaption, uType);
    return  iReturn;
}

BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) {
    switch ( dwReason ) {
        case DLL_PROCESS_ATTACH:           
                DetourTransactionBegin();
                DetourUpdateThread( GetCurrentThread() );
                DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
                DetourTransactionCommit();
                break;

        case DLL_PROCESS_DETACH:
                DetourTransactionBegin();
                DetourUpdateThread( GetCurrentThread() );
                DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)
                DetourTransactionCommit(); 
                break;
    }

    return TRUE;
}

As title says I'm trying to compile with Dev-C++ a simple DLL using Detours, but I get this error:

syntax error before token '&'

on this lines:

DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)

The complete code is

#include <windows.h>
#include <detours.h>

#pragma comment( lib, "Ws2_32.lib" )
#pragma comment( lib, "detours.lib" )
#pragma comment( lib, "detoured.lib" )


int (WINAPI * trueMessageBox)(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType) = MessageBox;
int WINAPI hookedMessageBox(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
    LPCSTR lpNewCaption = "You've been hijacked";
    int iReturn = trueMessageBox(hWnd, lpText, lpNewCaption, uType);
    return  iReturn;
}

BOOL WINAPI DllMain( HINSTANCE, DWORD dwReason, LPVOID ) {
    switch ( dwReason ) {
        case DLL_PROCESS_ATTACH:           
                DetourTransactionBegin();
                DetourUpdateThread( GetCurrentThread() );
                DetourAttach(&(PVOID &)trueMessageBox, hookedMessageBox)
                DetourTransactionCommit();
                break;

        case DLL_PROCESS_DETACH:
                DetourTransactionBegin();
                DetourUpdateThread( GetCurrentThread() );
                DetourDetach(&(PVOID &)trueMessageBox, hookedMessageBox)
                DetourTransactionCommit(); 
                break;
    }

    return TRUE;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一指流沙 2024-09-11 18:47:27

这些行上没有分号。

由于不知道绕路,我打算查询 PVOID & 的类型转换,这看起来很奇怪 - 但网上有几个这样的例子,所以它看起来似乎是合理的。

You don't have semicolons on those lines.

Not knowing about detours, I was going to query the typecast to PVOID &, which looks odd - but there are several examples of it around the net, so it seems plausible.

你是我的挚爱i 2024-09-11 18:47:27

难道不应该是 LPVOID 而不是 PVOID 吗?

Shouldn't it be LPVOID instead of PVOID?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文