There's lots of ways your specific scheme can be broken - as perror says in his comments, setting hardware breakpoints will be unnoticed. The hardware breakpoints will also allow a reverser to check which part of your code reads the memory, pointing the attacker to the checksum algorithm. So, checksumming the process memory won't delay an experienced reverser by any significant amount.
If you want some modest protection, you should at least do some ptrace
tricks to check if you're being debugged, as perror says in his comment. To get some better protection, set up ptrace
in your main process, fork a child process, have the child throw exceptions in various places, catch these exceptions in the main process, have the main process do some of the work and patch the result back into the child's address space, and resume the child. Also, spawn something that will try to ptrace
the parent process, which will fail if the parent is being run under the control of a debugger.
This will at least prevent attackers who have nothing than gdb in their toolbox to fail. It will not help, for example, against anyone who compiles their own linux kernel and adds a sufficient amount of printk
debugging output to the ptrace
system call.
Really, there are companies who specialize in protecting software, and even they fail if the target is worthy enough / the attacker is determined enough. There are attacks on FlexLM, there are attacks on Themida (just google for Themida cracking tutorial), and not even Microsoft is able to prevent cracked versions of windows from floating around in the internet. As i said in my comment, anything you could invent yourself won't prevent a determined reverser from cracking your software, unless you're a very experienced reverser yourself.
I consider myself moderately experienced, not an expert by far, and i know that i couldn't devise anything that would stop anyone who has my experience for more than a few days at most. There are some members of this forum who could rip anything i'd invent into shreds within a day.
So honestly, if your software is worth protecting at all, get something commercial like flexlm. Any effort you spend on it yourself is wasted time.
PTRACE
detection to make it a bit safer.