CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2013
    Posts
    1

    Question need help implementing parameter argument to an exe

    hi,
    i have this Stealth Injector source from internet
    so this program is for injecting .dll to an .exe
    this program was made by someone to used for cheating in online game
    but i need to use this program in my private server game online to tell the game client .exe the server IP, that is stored in a dll file..
    the problem is i don't want the player to directly execute this program, but they need to run the game patcher first to do the patch..
    so i need to put some secret parameter argument that will block player from direct execute..

    i know nothing about c++
    i only know that you need to use main(int argc, char *argv[])
    i've try to put something like this

    Code:
    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;
    }
    the code works fine but the rest of code won't executed..

    i've attached the cpp and header files for you guys to check
    source.rar

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: need help implementing parameter argument to an exe

    The source code you attached doesn't contain the main() code you wrote above. That's probably why it doesn't work as you expect. If that is intended, then you should modify the WinMain() method contained in the StealthInjector.cpp file.

  3. #3
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    Re: need help implementing parameter argument to an exe

    Code:
    if(argc < 1){
    If no params are specified, argc will be 1 as argv[0] is the program name. If you want to check that one command line parameter has been specified, use

    Code:
    if (argc != 2){
    You can also simplify this code

    Code:
    int main(int argc, char* argv[]){
    	if (!(argc == 2 && strcmp(argv[1], "somesecretargument") == 0)) {
    		MessageBox(0, "Do not run this program directly, use the Game Launcher!", "Error", MB_ICONEXCLAMATION);
    		//close;
    	}
    	return 0;
    }
    What is close?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: need help implementing parameter argument to an exe

    And as with so many of these security/cheat/hack type questions...

    This will prevent a novice from not running that program directly. It will have near no effect on any semi serious hacker.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured