Thread: CreateProcess with Resource of executable, not the Filename

  1. #1
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    107

    CreateProcess with Resource of executable, not the Filename

    When I want my program to run an executable file located in his resource, I will do the following:

    Find the resource -> FindResource.
    Load the resource -> LoadResource.
    Lock the resource -> LockResource.
    Create the executable file -> CreateFile.
    Write the executable file -> WriteFile.
    Run the executable -> CreateProcess.

    Works like a charm.

    But with the PlaySound function you can play a sound with the resource of the sound, using find, load, lock resource and using the returned value of LockResource as pszSound for the PlaySound function (and setting hmod to the handle of the executable with the resource and fdwSound to SND_RESOURCE).

    My question: Is there a way to run the executable using CreateProcess without writing the resource of the executable to the hard disk and running it by the written file name but running the executable with only the resource of the executable and not the filename?

    Thanks in advance, Ktulu.

  2. #2
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    It's just a multiple process program in one executable, there's nothing too strange about it.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  3. #3
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    107
    Quote Originally Posted by Ken Fitlike
    And why exactly would you want to do this?
    When I don't need to create and write the file to the hard disk but just use the resource in the memory, that will work faster.

  4. #4
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    107
    If you have a windows app for the looks and a command line app to work cross platform, the windows app as parent process and the command line as child process.

  5. #5
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Command line programs can still create windows, you know.

    What you want to do is going to be challenging to implement because it would require mimicing most of the Win32 PE loader built into Windows. You could possibly load the child's PE image stored in a resource into the parent's process space, providing that you ensure that the DLLs that it requires are loaded and patch the functions in the import table yourself, etc. That's waaaaaaaay beyond anything I've ever done though.

    Executable packers like UPX work this way, I believe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 04-11-2009, 01:49 AM
  2. Sorting out a resource manager
    By psychopath in forum Game Programming
    Replies: 1
    Last Post: 11-10-2008, 07:12 PM
  3. Generic Resource_Manager WIP with lots TODO
    By Shamino in forum C++ Programming
    Replies: 19
    Last Post: 02-01-2006, 01:55 AM
  4. Replies: 3
    Last Post: 01-25-2006, 10:30 PM
  5. Serial Communications in C
    By ExDigit in forum Windows Programming
    Replies: 7
    Last Post: 01-09-2002, 10:52 AM