【问题标题】:need help implementing argv to some source需要帮助将 argv 实施到某些来源
【发布时间】:2013-11-06 05:26:15
【问题描述】:

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

所以这个程序用于将 .dll 注入到 .exe

这个程序是有人制作的,用于网络游戏作弊

但是我需要在我的私人服务器游戏中使用这个程序来告诉游戏客户端.exe服务器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

【问题讨论】:

  • 代码的“其余部分”是什么?
  • 您应该在索引到 argv 之前检查是否有足够的参数传递。
  • 很容易获得有关您的秘密参数的信息(例如,通过 ProcessExplorer 工具)。所以这不是解决方案。
  • @Aniket 我已经上传了源文件,剩下的代码就是除了 main(int argc, char* argv[]) 之外的所有代码,所以它只是验证参数然后关闭程序。 .不执行游戏exe

标签: c++


【解决方案1】:

我想,我发现了问题所在。你有一个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; 
}

【讨论】:

  • 我遇到了一些错误,先生 "1>StealthInjector.cpp(204): error C3861: 'CommandLineToArgvA': identifier not found"
  • @FredyRommy 让我来处理多字节字符串
  • @FredyRommy,完成,重新检查(我没有win32编译器,所以目前无法测试证明)
  • @FredyRommy,别忘了在开头加上:#include &lt;shellapi.h&gt;
  • 我在 CommandLineToArgvW "1>StealthInjector.cpp(205) 中仍然出现错误:错误 C2664:'CommandLineToArgvW':无法将参数 1 从 'LPSTR' 转换为 'LPCWSTR'" 我已包含 #在 StealthInjector.cpp 之上包含
猜你喜欢
  • 2016-02-24
  • 1970-01-01
  • 1970-01-01
  • 2017-06-07
  • 2021-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多