rufus777 Posted January 31, 2011 Share Posted January 31, 2011 I know that I'm stupid, But "copy /B file1 + file 2 file3" In c + + so I've created a file "system (" echo Mickey was here !!!"); and a file that has "system (" echo ... and here !!!");. ( mikke.exe / mikke2.exe ) Thus, copy /B mikke.exe + mikke2.exe mikke3.exe When I take mikke3.exe to run it, so I get the "Mickey was here!" to nothing more ... hehe, I know it's a bit stupid, but help me? :) Quote Link to comment Share on other sites More sharing options...
Sparda Posted January 31, 2011 Share Posted January 31, 2011 This is because only the first program runs. The second program which happens to be in the same file never executes. I'm not sure you could get it to execute in that state either. Quote Link to comment Share on other sites More sharing options...
digip Posted January 31, 2011 Share Posted January 31, 2011 (edited) I'm not a programmer, but if you wanted to have two programs in one, I think you need to explicitly call the second program from the first one if your condition is met, ie: If program 1 is done doing its routine and was successful, execute program 2, else exit. There are ways to "package" multiple executables together, but I don't know that a straight binary copy of 2 files into a third output will warrant the results you are after. Edited January 31, 2011 by digip Quote Link to comment Share on other sites More sharing options...
Jason Cooper Posted January 31, 2011 Share Posted January 31, 2011 Thus, copy /B mikke.exe + mikke2.exe mikke3.exeWhen I take mikke3.exe to run it, so I get the "Mickey was here!" to nothing more ... The answer here is to learn a bit about the layout of a Window PE file (Portable Executable). A very simple outline of a PE file is DOS Executable code PE Header Section Section Section The DOS executable code is there to tell the user that they can't use the program in DOS if they run it from DOS (Note that with windows XP and beyond not being built on top of DOS in the modern day it doesn't do anything) The PE header tells windows dynamic linker how to map the sections into memory and some other information to do with the program, like where to start. When you append another program onto the end of an existing one the file would look like DOS Executable code PE Header Section Section Section DOS Executable code PE Header Section Section Section Windows takes the program and uses the first PE Header to map it all into memory and starts running the code from where the PE header tells it. Windows doesn't see the second PE header so the sections for the second program don't get mapped into memory, and they don't get run. Quote Link to comment Share on other sites More sharing options...
rufus777 Posted February 1, 2011 Author Share Posted February 1, 2011 The answer here is to learn a bit about the layout of a Window PE file (Portable Executable). A very simple outline of a PE file is DOS Executable code PE Header Section Section Section The DOS executable code is there to tell the user that they can't use the program in DOS if they run it from DOS (Note that with windows XP and beyond not being built on top of DOS in the modern day it doesn't do anything) The PE header tells windows dynamic linker how to map the sections into memory and some other information to do with the program, like where to start. When you append another program onto the end of an existing one the file would look like DOS Executable code PE Header Section Section Section DOS Executable code PE Header Section Section Section Windows takes the program and uses the first PE Header to map it all into memory and starts running the code from where the PE header tells it. Windows doesn't see the second PE header so the sections for the second program don't get mapped into memory, and they don't get run. what about linux? Quote Link to comment Share on other sites More sharing options...
Sparda Posted February 1, 2011 Share Posted February 1, 2011 what about linux? For all intents and purposes it's the same. Quote Link to comment Share on other sites More sharing options...
Jason Cooper Posted February 1, 2011 Share Posted February 1, 2011 If you want to know more about the executable format commonly used by linux then check out My linkhttp://en.wikipedia.org/wiki/Executable_and_Linkable_Format for an overview. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.