thpsthc
April 22nd, 2005, 04:10 PM
Is there a way to have an executable(a) stored as a resource in another executable(b) and have executable(b) load executable(a) into memory and run it without actually writing it to disk first?
|
Click to See Complete Forum and Search --> : loading a program from memory into memory thpsthc April 22nd, 2005, 04:10 PM Is there a way to have an executable(a) stored as a resource in another executable(b) and have executable(b) load executable(a) into memory and run it without actually writing it to disk first? ZeeM April 22nd, 2005, 06:21 PM nope ;) why not write it to disk first? thpsthc April 22nd, 2005, 06:46 PM because I want everything to be in one file, the one executable SuperKoko April 23rd, 2005, 05:55 AM You can include the executable in your resources like that in the .rc file. #define EXERES_Notepad 100 EXERES_Notepad EXECUTABLE "c:\windows\notepad.exe" And get the HRSRC like that #define EXERES_Notepad 100 // ... HRSRC hRes=FindResource(hInstance,MAKEINTRESOURCE(EXERES_Notepad),TEXT("EXECUTABLE")); And now, there are two possibilities: 1) Create a named pipe, with CreateNamedPipe (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/createnamedpipe.asp), and after that, call CreateProcess with a filename like "\\.\pipe\MyPipe". I suggest that you append a LUID (generated with AllocateLocallyUniqueId), to the name of the pipe, to be sure that this name will be unique. The problem with this method, is that it requires Windows NT/2000/XP. I have not tested it, because i have only Windows 98. 2) Create a temporary file (use GetTempFileName to get a temporary file name), write the resource in it, and call CreateProcess on it. thpsthc April 25th, 2005, 12:05 PM cool thanks, I'm going to try that out codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |