1./ As I know, Lazarus/Free Pascal makes native code, so regaining the source code from a binary (exe,dll ...) is impossible. In other words: decompiling is impossible. Is it true?No
2./ If it is true, then why do Pascal-obfuscators exist?To make it (slightly) harder for others to reconstruct your source code.
3./ What is the best method to protect my Lazarus-made binaries (exe, dll) from getting decompiled?Keep your exe or dll on a single machine running an unusual operating system that is never connected to the internet.
4./ A concrete example, if I have this:You can apply encryption of various strengths to the string. FPC offers several implementations of encryption algorithms. But you cannot protect it indefinitely from a determined hacker with a big enough array of super computers, given enough time.
MyString: string = 'My special string';
Can I somehow protect the 'My special string' against decompilation?
1./ I read this: "You could do other things to reduce an attacker's ability to disable your software activation system, for example, but in a native-compiled system like Delphi, you can't recreate source code from the binaries." Link: https://stackoverflow.com/questions/6225081/when-and-how-should-i-obfuscate-my-delphi-code (https://stackoverflow.com/questions/6225081/when-and-how-should-i-obfuscate-my-delphi-code)
So, it is not true?
Also, is it possible to get back the original function names and variable names?No, but you don't need it. Take a look at the attached image: http://forum.lazarus.freepascal.org/index.php/topic,37045.msg247844.html#msg247844 You can debug it line by line.
01. Lazarus main menu > Project Options > Compiler Options > Compilation and LinkingIs it the "safest" settings (against any hacking)?
02. Enable "Smaller rather than faster (-Os)"
03. Enable "Smart linkable (-CX)"
04. Enable "Link smart (-XX)"
05. Lazarus main menu > Project Options > Compiler Options > Debugging
06. Disable all items of "Checks and assertion"
07. Disable "Generate debugging info for GDB"
08. Enable "Strip symbols from execuable (-Xs)"
09. Click "Ok" and rebuild the program