Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Executable

Status
Not open for further replies.

bsuribabu

Programmer
Apr 4, 2002
25
IN
Hi,

1. Is there any way around how to merge two EXEs.(DOS or Windows)

I want to execute first exe and then next one . Suppose they are separately build , i want to merge them in a way so that executes one after one .


If there are any URLs please provide me

2. After the EXE header ( 512 bytes) , all the byte code is fully executable ? . If one EXE byte code ( except header) is merged into another EXE , is it work ? or
pls Provide me what are the best ways to do this.


Suri

 
Basically the simple answer is "No" for the following reasons, but see the 2 comments at the end:

(1) on loading an exe file, the operating system has to resolve all the far pointers and far calls so that they point to real addresses. That means that an exe file is not executeable code if you just read it into memory and call the start of it. It has to be loaded properly, with the operating system having access to the header and the table of things it needs to rewrite. There's a name for the table that I've forgotten. Sorry.

(2) Although the start point in an exe file is defined, the end isn't (it's simply a call back to the operating system, from which there is no return). There may even be several ends. So it would be hard to patch another piece of code onto the end...

But it can be done:

(1) as a virus would do it (that's what a virus is: a piece of executable code that patches itself onto an exe and gets run first). Find somewhere irrelevant in the second(!!) exe file. Viruses like the stack segment because it is saved to disk, never used, and you can overwrite it without making the file suspiciously longer. In your case there is no call for stealth and you can simply add to the end of the exe file.
(2) Modify the second exe file header so its start point is now your irrelevant point. Put code at the irrelevant point to load and run the first exe file as a subprocess. End with a jump back to the original start point in the second exe file.
Now when you run the second exe file, it will first run the first, before doing its own stuff. Of course you still have two completely separate files.

Simpler way to achieve the effect (I hope) you want: use a batch file! Dead easy, always works.



 
Symbol table? ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
I have not understood properly . Can u give more details on this or provide me is there any links that can give me full details



Suri
 
well that won't work in the protected mode systems like linux, unix etc.

and also i think merging of two exes of differnt origins like dos and windows (because the exe formats are different) in dos far pointer resolution is different from the way it is done in windows.

It will make an interesting experiment....

Rahul



 
No, I assumed two dos exe's. I haven't a clue about mixing 2 windows exe's, and there is no hope whatsoever for mixing a dos exe with a windows, because the dos exe is bound to start in 16bit, and the windows in protected mode. I mean, yes, no doubt a highly cunning programmer fully versant in both operating systems and inclined to write code to change mode might manage to do it if his/her life depended on it, but I'd run a mile.
Oh, and incidentally, you could merge at least an older windows program as though it were a dos one, because it is: there's the dos stub, a mini-dos program that just prints out "this program was written to be used only in the windows operating system..." (or some such message) embedded in at least the older windows programs. It wouldn't be a very useful activity though!

The batch file option in dos is very, very easy. At risk of teaching egg-sucking: Just make a normal ascii/text file with the lines

program1
program2

(substitute your exe-file names for 'program1' etc. You don't need to include .exe but you can if you want)
Save the file as 'thingy.bat' or any other name ending .bat.
Then type 'thingy' at the dos prompt and the 2 dos-style programs will run one after the other.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top