Читать книгу Beginning Programming All-in-One For Dummies - Wallace Wang - Страница 109

Dissecting Programs with a Disassembler

Оглавление

A disassembler acts like a reverse compiler. A compiler converts your program (written in any programming language, such as C++ or Swift) into machine language; a disassembler takes an executable file (which contains machine-language code) and converts it into assembly language.

Disassemblers can’t convert machine language back into its original source code language (such as C++) because disassemblers can’t tell which programming language was originally used. An executable file created from a C++ program looks no different from an executable file created from a Kotlin or Swift program. Therefore, disassemblers can only convert machine language into assembly language.

Disassemblers have both honorable and shady uses. On the honorable side, antivirus companies use disassemblers to dissect how the latest viruses, worms, and Trojan horses work. After they know how these nasty programs work, they can figure out how to detect, stop, and remove them.

On the shady side, many companies use disassemblers to tear apart their rivals’ products and see how they work. After you know how a competitor’s program works, you can copy those features and use them in your own program.

Programming languages, such as C#, Java, and Visual Basic .NET, get compiled into bytecode format; therefore, a disassembler can reverse-compile a bytecode file into its original source code. So, if you compile a Java program into bytecode format, a Java disassembler can convert the bytecode file into Java source code. Likewise, if you compile a C# or Visual Basic .NET program, you can disassemble that bytecode file into its original C# or Visual Basic .NET source code.

To protect their bytecode files from disassemblers, programmers use another program called an obfuscator. An obfuscator essentially scrambles a bytecode file. The bytecode file can still run, but if other people try to disassemble an obfuscated bytecode file, they can’t retrieve the original source code.

If you use a programming language that compiles into bytecode (such as C#, Java, or Visual Basic .NET), consider using an obfuscator to protect your source code from prying eyes.

At the bare minimum, all you need is an editor (to write programs) and a compiler (to convert your programs into executable files). However, most programmers use a debugger, version control software, and an installer. Although most programmers are happy when they can get their programs to work, some programmers use a profiler to help them speed up and optimize their program.

Finally, some programmers use disassemblers to peek inside the inner workings of other programs, such as viruses or rival software. Disassemblers are never necessary for creating a program, but they can prove useful for legal and not-so-legal purposes.

The tools of a programmer are highly subjective. Some programmers swear by certain tools, such as their favorite editor or compiler, whereas others are happy with whatever tool is available. Just remember that programmer tools can help you write faster and more reliable programs, but the best tool in the world can never substitute for decent programming skills in the first place.

Beginning Programming All-in-One For Dummies

Подняться наверх