我有这个来自互联网的隐形注射器来源

因此,该程序用于将.dll注入.exe

该程序是由某人制作的,用于在网络游戏中作弊

但我需要在我的私人服务器游戏中使用此程序在线告诉游戏客户端.exe服务器IP,该IP存储在dll文件中。

问题是我不希望玩家直接执行此程序,但他们需要先运行游戏启动器才能进行补丁。

所以我需要放置一些秘密参数参数,这将阻止播放器直接执行..

我对C ++一无所知

我只知道您需要使用main(int argc,char * argv [])

我试图把这样的东西

int main(int argc, char* argv[]){
    stringstream sparam;
    string param;
    sparam << argv[1];
    sparam >> param;
    if(argc < 1){
        MessageBox(0, "Do not run this program directly, use the Game Launcher!", "Error", MB_ICONEXCLAMATION);
        close;
    }
    if(param != "somesecretargument"){
        MessageBox(0, "Do not run this program directly, use the Game Launcher!", "Error", MB_ICONEXCLAMATION);
        close;
    }
    return 0;
}


上面的代码可以正常工作,但是其余代码将不会执行,只需执行参数验证,然后关闭程序即可。

这是cpp和头文件Source File

最佳答案

我想,我想出了问题。您有一个Win32应用程序,尽管其中的main被隐式调用,但如果未定义,则该控件通常传递给WinMain()函数,该函数将执行Windows应用程序。

这是解决方案,以及修补后的WinMain()函数:

int __stdcall
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow) {
        LPWSTR *szArgList;
        int argc;
        szArgList = CommandLineToArgvW(GetCommandLine(), &argc);
         if(argc < 1){
            MessageBox(0, "Do not run this program directly, use the Game Launcher!", "Error", MB_ICONEXCLAMATION);
            exit(1);
         }
         if(wcscmp(szArgList[1],L"somesecretargument") != 0){
             MessageBox(0, "Do not run this program directly, use the Game Launcher!", "Error", MB_ICONEXCLAMATION);
             exit(1);
         }
    DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DLGPROC(DialogProc), NULL);
    return 0;
}

关于c++ - 需要帮助实现一些来源的argv,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19804747/

10-11 22:51