Hi, I am creating a console application game with pure c++(No libraries, Engines,) and I want to sell it. But How can I prevent my source code to be seen by any disassembly program?
Note: An example game:
Once compiled into a binary, your source code is gone forever. No disassembler can recover your source code. A dissasembler can sometimes generate source code that would produce the same output, but your source code is gone forever.
you cannot prevent disassembly though. Most programs are so large and complex that a hacker needs a great deal of motivation to disassemble it. This is more work than just running your program and writing new code that does the same thing for non trivial programs, so someone stealing a piece of your code via disassembly is unlikely unless you invent something really, really, really cutting edge like a O(1) prime factorization algorithm or something like that. If you do that, get a patent before you distribute the code.
Disassembly is fun for modifying games, but multiplayer games tend to do checks and suicide if they detected changes to prevent cheating. Single player games often allow it for community mods to exist, or offer other ways to mod the software safely. The most common use of disassembly hacks used to be removal of copy protection aggravations way back when those were a nuisance to the gamer instead of hidden and automatic.
Your worries are meaningless because if you have the greatest idea ever, and someone wants to steal it, they can. They may not have the source code, but it is very easy to modify textures and strings and rebrand it as their own.
Plus I think if you have much to learn about production level programming, you will get a better learning experience if you make your code open source. If people care about your game, they can use github directly to submit bug reports, and people who are capable programmers can point out flaws and help you for free (but like I said, only if people like what you are doing).
Also I think for publicity, don't bother yourself with trying to make people download a binary on their machine (if you think you have have a great idea, you could submit what you make to some sort of distributor otherwise). Even though it counts as a library, emscripten is a way for C++ code to be run on websites (it does have the reputation of being used with SDL, but it does have a simple terminal). But I would recommend you do this as a last step.
The most common use of disassembly hacks used to be removal of copy protection aggravations way back when those were a nuisance to the gamer instead of hidden and automatic.
So DRM is no longer a nuisance? Someone should have told me.
Nowadays there are very effective obfuscators that make it extremely difficult to analyze the behavior of a running program. One such technique involves generating at compile time a randomized instruction set for a virtual machine with non-trivial instructions. For example, instead of an assignment operation, it has "copy A to B and multiply C by 57" and so on. Then the obfuscator compiles the program to obfuscate into this instruction set, so that when it's actually running the effects of the instructions are difficult to keep track of. Similar to how money laundering works, the idea is that the interesting operations are obscured and difficult to tell apart from the garbage operations.
Tigress is an obfuscator I'd like to take a look at some point: http://tigress.cs.arizona.edu/
It performs a C to C transformation, applying several different obfuscation techniques. The only caveat is that it's currently closed source.
If you are trying to steal, modify, or the like, it is still a pain. Its also harder to crack, as many games verify a checksum or something against the online version and if they mismatch it 'repairs' it or refuses to work.
But games and software no longer do idiot stuff like 'open your book, turn to page 357, find paragraph #4 and word #18 and type it in'. That old clumsy stuff was so annoying many people hacked it out even when they owned the game legit. Now, there isn't much point for legit owners to mess with it.
stealing the code is a different thing than modifying it though. Again, it seems to me that you would have to have something very cutting edge to bother with stealing it to re-use it in another program. Most code isn't doing anything interesting and unraveling disassembled code is a LOT of trouble, even if not obfuscated.
But games and software no longer do idiot stuff like 'open your book, turn to page 357, find paragraph #4 and word #18 and type it in'.
That's more benign than some of the stunts some developers pull nowadays. See for example Diablo 3.
With old school copy protection, at least painstakingly copying the codes by hand was always a possibility. With online-only, once the company is gone or they decide to shut down the servers, you're SOL.