Home c++ How can I view the source code of the program?

How can I view the source code of the program?

Author

Date

Category

I want to tweak the source code, nothing serious, just a few lines of output.
The program is most likely written in C++. Should I use a debugger? Or open it somehow in the IDE? I just don’t want to run the program, I just want to dig deeper into the code. And can you advise some?
P.S. The file itself is .exe


Answer 1, authority 100%

The source code cannot be disclosed if security was tried for this (especially if it is a proprietary item).

But there are ways to fully or partially expose the code.

  • IDA Pro is the best free cracker ever, some macros may allow you to reverse the code. But not always. Borland products open up especially well.
  • Hiew.Exe is a very small free utility that allows you to edit your code in assembly language. You can edit text and integer constants. You can even use it to “translate” the program into another language, erase the name of the company, etc.
  • If there is a PDB file, or debug-info is attached to the file, then the code can be obtained in the development environment (if debug-info is complete) it can rarely be used. The source code cannot be obtained, but you can get “line numbers and source names”, as well as the names / values ​​of all constants, local variables, avoid “fragmentation of functions” and also get classes with class stuffing (almost all structures except the program text) that will greatly simplify the understanding of the program. For some libraries (dll), pdb files can be downloaded separately. It is unlikely that a self-respecting company will leak the pdb of its worthy product.
  • Debug info, there is DebugInfo information embedded in the exe. If there is such information, and the corresponding utility (for example, Borland Delphi is compiled, and it is available), then you can do something similar to the previous point. But a self-respecting company is unlikely to make such a “stupid” mistake (similar to pdb).
  • If the file is written in C # it can be almost completely viewed in codes using disSharp (such programs “include” only mscorlib in the import table and that’s it). DisSharp is not good at disassembling some parts of the program, but perhaps its paid version or the paid version of similar utilities reveals the code better.
  • If the file is written in FoxPro, clipper and other similar byte-code languages, it is expanded by special utilities (Refox for example).
  • The exescope.exe ResourceHacker.exe utility and its-like utilities allow you to view the header, connected libraries (you can understand what it says program) and edit program resources (resource-forms including delphi, icons, pictures, tables of resource-lines).
  • If you know how the code was created, I think there are special utilities that can open it (they are paid and inaccessible).

Again, this is on condition that there is no code packer (then you must first apply a depacker), an encryptor / self-modifying code. If not broken by obfuscator so don’t unravel. The larger the code, the harder it is to figure it out.

P.S. Personally, my opinion is that everything is revealed and hacked, but it takes a lot, a lot of time. Perhaps a year or more (depends on experience and tools, there are no good tools freely available).


Answer 2, authority 42%

I will be glad to be mistaken that there is simply no such way for a “beginner”.
You need to disassemble the exe file in IDA or Hiew32, and there you can already consider the code in the asm (low level) language.


Answer 3, authority 8%

In a nutshell, it’s impossible. A program to run is the result of compiling source code into a set of machine instructions. The reverse process is impossible, unless you analyze the machine code and recreate the source from it yourself.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions