Page 1 of 1

Programming/protocols/decompiling

Posted: 2007-06-29 03:11pm
by Shrykull
Is it illegal to decompile software, even if you're just doing it to modify the program for your own personal use, to tailor it to your preferences? And how would you even know what programming language to decompile it into?

I'd like just to get a look at how some snippet of code that handles how internet software, like a web browser interacts/makes a request with protocols of the OSI model, TCP/IP mostly.

Posted: 2007-06-29 03:20pm
by Hugh
I don't know about the legal side of the issue, but I don't think it's possible to reliably turn machine code back into C, or whatever. There is too much information loss when compiling. It does work for Java bytecode, though, but don't expect perfect recovery of the original source.

Posted: 2007-06-29 03:44pm
by phongn
If you want to see how all that stuff works, there's plenty of open-source code available.

Re: Programming/protocols/decompiling

Posted: 2007-06-29 06:33pm
by Starglider
Shrykull wrote:Is it illegal to decompile software,
Usually it's not illegal in the general sense; some countries even have specific protection for it, though large software companies are lobbying to have it made illegal. That said, most shrink-wrap licenses try to forbid it (the legality of these clauses is dubious in most jurisdictions)
Shrykull wrote:even if you're just doing it to modify the program for your own personal use, to tailor it to your preferences?
Does it really matter, on a personal level? If you're the only one that's going to use it frankly I wouldn't give a damn whether insanely excessive IP laws make it technically illegal.
And how would you even know what programming language to decompile it into?
You can decompile it into any language you like; any Turing-complete language can theoretically be transformed into any other Turing-complete language, though in practice it's often very hard to do this in a way that actually enhances readability to humans and only limited tools exist. The main problem is that a great deal of metadata (comments, variable names, even precise control structures when decompiling JMP tangles) exists in source code but not in object code, and there's no way to recreate that other than manual guesswork. In particular any program that uses nontrivial pointer arithmetic is going to be effectively impossible to decompile into a language that doesn't support it. Disassembly is much more reliable and straightforward, but of course you have to be able to read and understand uncommented x86 (typically) assembly language, which is frankly a bitch for nontrivial programs.
I'd like just to get a look at how some snippet of code that handles how internet software, like a web browser interacts/makes a request with protocols of the OSI model, TCP/IP mostly.
As others have mentioned looking at open source software (e.g. Firefox and the Linux TCP/IP stack) is a much, much better idea than trying to reverse engineer commercial software. Reverse engineering is a difficult and quite specialised skill that even the vast majority of competent software engineers don't have. But yeah, OSI is an academia-bred abstraction hardly anyone pays attention to.

Posted: 2007-06-30 12:40pm
by Braedley
There's also the problem that assembly typically has several times as many lines of code as C or C++. And the code won't even be chunked, may or may not include defines, and may or may not include labels. Those are the three things that make assembly even remotely human readable. And now you want to convert that heap of a mess into a higher level language? You'll have constants all over the place which will have no meaning by themselves, good luck with extracting functions, and all sorts of other pieces of mayhem. At best, you're looking at proper indentation, and that's about it.

Posted: 2007-06-30 12:54pm
by Singular Intellect
A sufficiently knowledgeable programmer can make his program virtually impossible to decompile if he or she really wants.

Posted: 2007-06-30 01:02pm
by Resinence
You only get (basically) unreadable and therefore useless code from decompiling any non-trivial program anyway and reading the output of a dissassembler...lol, no real need to try and obfuscate your program unless you are making alot of money off it/security is an issue.