August 21st, 2003, 02:36 AM
Rip a .obj file
I am in a fix.... recently my hdd crashed and i lost all the code in it. fortuately i was able to retrieve most of the files except a few important files. i have the compiled (.obj) files for these files. can anyone tell me if i can rip the source code out of this .obj file. if yes how. please help me. i am deperately in need of help.
August 21st, 2003, 04:58 AM
The answer is almost certainly no.
The object code does not contain the original source. If the object file contains debug symbols there is a chance that you may be better off.
There are three possible solutions:
1) Use a dissassembler. This will produce assembler code, which you could use as source code in other projects. But it is unlikely that this code will make much sense to yor or be particularly maintainable. Again if debug symbols are used, the code will be more understandable (if the disassembler is any good). If you use the optimizer, then it will be much more confuing.
2) Use a decompiler. This will only work if one is available for the specific compiler you used. It works by recognizing the patterns of assembler code and regenerating the source. The source may not exactly match yours, some or all symbol names may be 'generated' and therfore meaningless. Again debug code is likely to help, and optimization will be less likley to work. Unfortunately, decompilation is feasable with simple compilers but is less likly to be successful with more sophisticated modern compilers. Subsequently most of the tools available are unfinished or experimental or only work with old DOS 16bit code.
3) If you have the original .h files, or can re-create them from memory, then you can simply link the object file to new projects as a 'black-box', just as you would with a library. Unfortunately you will not be able to modify this code.
Here is a list of disassemblers and decompilers: