General software, Operating Systems, and Programming discussion.
Everything from software questions, OSes, simple HTML to scripting languages, Perl, PHP, Python, MySQL, VB, C++ etc.
hi guys
recentlly we hear alot about source code.
well i am not a programmer but i am a curious guy and a good aprender , so what does exactlly the source code mean?
second ; what language is written?
third ; how can i open a source file without knowing what language it is written?
and last is it legal somehow to open a source file?
if you know any toutorial pages , or any other related serious places , please let me know. THANKS
Source code and object code refer to the "before" and "after" versions of a computer program that is compiled (see compiler) before it is ready to run in a computer. The source code consists of the programming statements that are created by a programmer with a text editor or a visual programming tool and then saved in a file. For example, a programmer using the C language types in a desired sequence of C language statements using a text editor and then saves them as a named file. This file is said to contain the source code. It is now ready to be compiled with a C compiler and the resulting output, the compiled file, is often referred to as object code. The object code file contains a sequence of instructions that the processor can understand but that is difficult for a human to read or modify. For this reason and because even debugged programs often need some later enhancement, the source code is the most permanent form of the program.
When you purchase or receive operating system or application software, it is usually in the form of compiled object code and the source code is not included. Proprietary software vendors usually don't want you to try to improve their code since this may created additional service costs for them. Lately, there is a movement to develop software (Linux is an example) that is open to further improvement and here the source code is provided.
In large program development environments, there are often management systems that help programmers separate and keep track of different states and levels of code files. For script (noncompiled or interpreted) program languages, such as JavaScript, the terms source code and object code do not apply since there is only one form of the code.
So, you can typically open and read it in a text editor.
To tell what language was used in the file, programmers typically use well-known file suffixes. For instance, a C++ file will usually end with any of the following: .c++ .C++ .C .cc .cpp .h++ .H++ .H .hh .hpp
thanks for clearing it up for me.
since i've threaded my Q , i have been doing some researches which i'd like to be enlighted if i understand correctly , most of the software we have , they do not come with resource code (as a raw material) .and the resource code is a patent of the company .
which any usage of it is not legal.(without permision)
therefor there is noway anybody could update it or improve it (beside linux).
if so . how come there are some software they could hack the software? or are those sofware only for cracking usage. like softice , or w32dasm and hexeditor and etc.....?
Well PE (portable executable) files (m$ format) sometimes have a .rsrc section that contains resources. Basically, programmers can include images, sounds, icons, text strings, etc within their programs. The compiler/assembler (depending on what language they're coding in) will take these resources and put them in the .rsrc section.
Along come resource editors (not a cracking tool by any means, but a valid programmers tool). These programs can open up a dll, exe, ocx, etc and allow you to extract icons or replace a bitmap or whatever as well as modifying a dialog. It's very useful to quickly change a version number that you forgot to change and don't want to reassemble/recompile the program just for that.
The .rsrc section begins its life as a resource script which is just a text file with an .rc extension, and looks something like this (from my masm dialog template):
I think you may be using "resource code" and "source code" to mean the same thing in your questions. It is commonly (at least where i live) referred to as just source code.
Yes, most companies consider their source code to be company property and in some cases have patents on it. When you receive a program on your computer it is in a machine readable format. most license agreements tell you you cant take it apart or read it, what you do from there is a point of great debate. since it is now in your posession don't you now own it? the same way you are allowed to modify your car to make it work better/faster/different cant you modify "your" software to do the same?
Using programs like you desribe (hexeditors, softice...) you can see the internals of the program in the same language the machine reads it in (commonly refered to as assembly language). Each type of processor has its own assembly language (which is one reason why programs cannot be transferred from a Mac to a PC for example). However if you have the source code you can (theretically) re-compile the code for any specific assembly language/processor you need to (one reason source code is so powerful).
If you know how the machine reads the assembly code for a particular processor you can then edit a program and change the way the program works. This may sound very easy, trust me its not. Legit reasons for doing this are for debugging and troubleshooting applications. Non legit reasons would be cracking encryption/copyright methods built into the software.
there is no *exact* way to "un-compile" or reverse engineer assembly code and get the original source.
It can be done to an extent, there are several tools which do this (names of which escape me at the moment) but the results you get back will not be the original source code. This lies in that there are many different ways to write source code that will all result in the same assembly code.
If you think of it in a mathematical sense: from source code to assembly is a one-to one relationship (keeping the machine and compiler constant) whereas from assembly to source code is a one-to-many relationship. therefore you can break the assembly code down and get a semi-readable idea of how it was coded, but you will never get the exact source back.
hope this helps
*edit*
i just realized i didnt really answer your question fully, ooops
in response, yes you can break it down and modify the way it works but it is very difficult. being able to guarantee that changes you make will not somehow affect other pieces of the code can be near impossible.
You can in fact decompile (decompile==converting to the original source code) certain types of programs. The types of programs that you can decompile are interpreted hll (higher level languages) programs like vb3/4/5/(and if you know somebody)6 and delphi (to a certain extent), java, and of course assembly-written programs (because assembly written programs convert easily back into disassembled assembly listings). In fact, IDA (interactive disassembler--DataRescue) can disassemble programs to the point where you can add snippets to your own assembly code (in tasm.....yuck) and recompile almost as is.
Btw, Boston_Bob.....there's a difference between assembly language (what we type in notepad) and machine code (what resides on our hard drives regardless of what language we code in). What I think you were trying to say is that assembly code in its purist form translates into machine code at a 1-to-1 ratio, meaning that one line of assembly code equals one line of machine code. ....whereas 1 line of an hll program translates into multiple lines of machine code.
peace,
william
edited to say that there's an oft confused difference between a "disassembler" and a "decompiler". A disassembler disassembles a file (be it an .exe, .ocx, .dll, etc) to an assembly code listing regardless of what language the file was coded in. A decompiler decompiles the file into its native language.
...sorry for using a word in its own definition but I'm pretty sure people will understand.
Thank you for pointing out some of the finer points of what i was saying. I was just trying to keep my answer simple, Hamid doesn't seem like a programmer/hacker I was just trying to get a point across in easy to grasp terms.
Sorry if it looked like I was trying to one-up you or something. I've been accused of being arrogant or whatever from some of my posts, but that's just the way I talk (err....type).
you did get me thinking about some stuff though....the technolgies/languages you mentioned as being able to de-compile are all (with the exception of Java, can't forget the IBM jikes compiler, and several projects to turn Java into native machine code on for a particular system...sorry i digress) proprietary languages/compilers. I believe this is where you "are" able to decompile machine code into its original source. What sort of implications might this have on software copyright in general? (I have to add i was not aware you could do this with VB and such)
When i originally posted a response i was basing my answer on C/C++. Based on the fact that there are many different C/C++ compilers + you dont have easy access to how they optimize their code (with the exception of GCC), you can never get the original source back (at least this is my understanding, im just a student, not a compiler designer) you can however get a semi-readable version of assembly.
Im not basing this on pure speculation, I have taken a class where we did exactly this in C and then in MIPS assembly.
I also think it would be interesting to see how Java code, compiled with different compilers would stand up to this test. It seems to me you would get similar results, but not exactly the same bytecode from the same source. the difference coming from how each compiler optimizes the original source during compilation.
I know this isnt completely pertinent to this thread, but you did get me thinking and i wanted to share
I read the entire conversation. Still not sure if we have a solution. I'm in the same boat as Hamid. Have an exe file written in VB. Desperately need to view the code. Is there any way it can be uncompiled to a version viewable and understandable?
dj_dc wrote:I read the entire conversation. Still not sure if we have a solution. I'm in the same boat as Hamid. Have an exe file written in VB. Desperately need to view the code. Is there any way it can be uncompiled to a version viewable and understandable?
Thanks
dj_dc
No. You can never completely decompile something to source. Why? Because I can easily write something that uses the same assembly code as another person's function, but do two totally different things. Therfore, you can only decompile/disassemble back to the Assembly language, and work from there.
If you find yourself in the situation where you need to convert an executable image back into some kind of readable source code, then you have already admitted defeat. There are a hundred ways a piece of located object, ( from a .exe for example), could have been produced.