need help implementing parameter argument to an exe
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: need help implementing parameter argument to an exe

  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 online now Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,485

    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
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,862

    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. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

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

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center