Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Including .exes in C

Name: Anonymous 2009-09-04 11:19

So I'm writing a program on Windows where I'd like to include an exe to run. Source for the exe isn't available. Is there a good way of doing this?

What I have currently is this: convert the exe to a character array and write it to a temporary file for calling with system or spawn. But this seems like the wrong way to go about it. At the very least, the Google has suggested named pipes might be the way to go, but I've got no idea how to work with them.

Halp?

Name: Anonymous 2009-09-04 11:29

There's literally hundreds of ways to do this. Your way isn't wrong, but since we're talking Windows here, why don't you use what the OS provides: store the executable in an unformated resource, that way the resource compiler will include it when you compile your program, and it will be easy to build, and then create the process directly with CreateProcess, which would avoid pitfalls that can happen when using system(). The code won't be portable if written this way, but since you said clearly that it will run on Windows, I don't see why this would be a problem (if it is, just use what you're doing now). Is there an issue with dumping and running the executable?
It's possible to do it without writing the executable to a file, but that's an advanced low-level subject(knowledge of the PE file format, code transformation/loading may be required, good knowledge of kernel32 and windows internals preferred), and I'd rather not go into it without knowing more details about exactly what you want to do.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List