Is I understand mining is what makes it impossible to grant yourself 999 bitcoins even when you have access to the source code of the client. Mining is a process of solving a problem by brute force. The difficulty of the problem is automatically adjusted so that it takes on average 10 min to produce a block. Whoever gets lucky to solve the problem, gets privilege of generating a next block and 50 bitcoins bonus. A block is a list of transactions considered as valid.
So if you try to add yourself 999 bitcoins, it will be a random person who will validate your transaction. And then his/her validation will be followed by 3-6 validations by next randomly selected miners.