How . exe files work

:confused:Hi

I work on a production server. We have some .exe files in our system, the source of these files are C++ programs that are stored in the development server. How these .exe work. Could somebody please tell that in detail.

Thanks a lot!!
Kanu

Great Question.

the exe files have segments like .text, .bss , heap and stack se
text segment will store the code and functions
data will store the global vars
heap will store dynamic allocated mem.
stack will store local variables.

when you compile these programs the code is transfered to machine instructions in the .text segment and data is stored in data segment. stack and heap grow dynamically
according to their usage.

if you need more help ask specific Questions.

Thx,
Siva

Thanks Swami! :b:
Well this means that the .exe are the already compiled files which we can run without having C++ source codes.
Am I right .... ?

Unlike windows, unix file extensions ( the part after the dot) do not necessarily mean anything.

To find out what a file is/does use the file command:

file /usr/bin/ls
file /usr
file /path/to/your/exefiles/somefile.exe

:confused:how do we pass the parameters in the .exe programs???

exe file would have c/c++ programme containing main programme. while coding parameter like argv[1],argv[2].....soon might have been considered with appropriate logic...

You can pass parameters as,

exename param1 param2 param3.....

Hope this answers your question !!:slight_smile:

Shafi

Is this a windows box or a Unix machine :confused:

is it possible to extract a c program from its exe.file (executable file)??
if yes how?
if no why?

Not exactly. As it was already mentioned when you compile the program it is "converted" to machine instructions. From this point you can' restore the original source code - it's just not possible.
However you can see the machine code and realize what the program does at low level. If you are skilled enough this can help you to figure out how something works. This is called reverse engineering. I'm not going into details, because I'm not an expert in this area.
The whole process can be compared to a cake baking. You have the products, you mix them, bake them and finally you have a cake. You can't restore the products and determine what they were. However if you are skilled enough you can guess them from the taste:)