Launching program from resources

This is a discussion on Launching program from resources within the Windows Programming forums, part of the Platform Specific Boards category; As far as I know, you should be able to start executing code at any memory address in your executable, ...

  1. #16
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    As far as I know, you should be able to start executing code at any memory address in your executable, but you wouldn't know that address anyway.

    As for actually running an executable that is WITHIN another executable, I'm pretty sure Windows is not capable of doing that. Therefore, the only way to do that would be to find the adress where the executable started, extract it, write it to another file, and execute. Or, you may be able to find an Windows executable emulator or something like that. It's unlikely though.

    What exactly is your aim in all this? Maybe there's another way to go about it.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #17
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    I give u a more detailed idea of what I want to do. I have an exe file that shows a dialog. The user need to type in a product id, a vendor id and need to select a file to do the locking. When the user have have completed these tasks and clicked on the OK button, a dialog box (created by CFileDialog) will appear and ask the user where he/she want to save the second exe file to. After that, the first exe file will create the second exe file which will hold all the information that the user has typed and also the file that the user has selected previously.

    When the user open the second exe, it will need the user to type his/her username and password before he/she can open up the file which is attached to it.

    Can you give mi some ideas on the following:
    1) How can I create an exe file using another exe file?
    2) How can I attach a file to the second exe file?
    3) How to pass in the values from the first exe file to the second exe file?

  3. #18
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    I have merged the threads. This is the same question. If you don't like the answers you are getting, perhaps you have been asking the wrong questions...
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #19
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    ok. sorri that I opened another similiar thread and sorri for any inconvience caused.

  5. #20
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    so can anyone help mi

  6. #21
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    First off where are you from? The use of i over y is distrubing.

    It appears what you really want to do is lock the program until the user registers it. If so I'm sure there are much easier ways.

    Creating an EXE from another is something that not many here are fimilar with or capable of doing. Minor mistakes when writing the program could lead to big problems when you try to run the other exe. Trust me I've edited both win95 and win98's explorer.exe to change my start button to over 5 characters. I ended up having to reload explorer.exe at least 2 dozen times due to mistakes.

  7. #22
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    ok. If that's the case, are there any better ways to do this?

  8. #23
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Dunno, at first guess I'd say a registery entry combined with a check when the program starts.

  9. #24
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    ok. by the way, do you know if there is any way to include exe files as resources in C++?

  10. #25
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    Ya. So how can I solve this problem?

  11. #26
    Registered User
    Join Date
    Aug 2003
    Posts
    17
    This is part of my code:

    HANDLE hExe;
    HRSRC hRes;
    HRSRC hResLoad;
    char *lpResLock;

    hExe = LoadLibrary("Locker.EXE");
    hRes = FindResource(hExe, "IDD_EXE1", RT_RCDATA);
    hResLoad = LoadResource(hExe, hRes);
    lpResLock = LockResource(hResLoad);

    HANDLE hFile = CreateFile(_T("C:\\Testing.EXE"),
    GENERIC_WRITE, FILE_SHARE_READ,
    NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

    CFile myFile(hFile);
    myFile.Write(lpResLock, lstrlen(lpResLock));
    myFile.Close();

    What's wrong with the code?

  12. #27
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    That's pretty damn clever Salem.
    benforbes@optusnet.com.au
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  2. Launching an application from my program
    By tao in forum Windows Programming
    Replies: 6
    Last Post: 07-04-2006, 02:15 PM
  3. Launching a program on startup
    By beanroaster in forum C++ Programming
    Replies: 5
    Last Post: 05-20-2006, 02:21 PM
  4. Launching web documents through a program?
    By carey_sizer in forum C Programming
    Replies: 3
    Last Post: 09-08-2004, 07:51 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21