|Top Previous Next|
So you have created that great game, you started to sell it, but everyone is just copying it and giving it to his friends? What, even your relatives do that? Shut them down for good by reading and using this month's "Plug and play" article and code.
The CopyProtect mechanism uses an API function named GetVolumeInformation, which can return (among other things) the serial of the hard drive. The code consists of two files:
1) User.c should be published and run on the users' PCs; it writes the serial of the current hard drive (the one that stores or will store your game) inside a file named serial.txt. You tell the user to copy the program to his / her hard drive and run it, and then to email you serial.txt (or simply tell you the serial number by phone, etc). In fact, the easiest method is to bundle the published version of user.c with the demo version of your game. Here's what happens when I run user.c on my computer.
This is the serial number of my hard drive; if I would be the client and you would be the game developer, I'd have to tell you this number. The serial will only be displayed for a few seconds but don't forget that the data is written to the serial.txt file as well.
2) Game.c is the actual game file which includes a copy protection system that's based on the PC hardware, just like Microsoft does it with their Windows activation mechanism. My code is more simple but uses the same idea, so you shouldn't have problems if you want to make it more complex. The only line of code that's very important inside game.c is this:
if (str_cmpi(serial_str, "26630-49107")) // this works only for my hard drive, so put your own serial here
As you can probably guess, the game.c file will not run on your PC without changes - the game is copy protected! You will have to put your own hard disk serial between those quotation marks, and then save the file.
Ok, let's review the process one more time:
a) Put the client to run user.c and get his / her hard drive serial number;
b) Edit game.c, replacing my serial number with the serial you've got from your client. The game will then run only on the client's hardware.
Game.c contains a copy-protected example game that challenges you to guess a random number from 1 to 100 using 7 tries or less. If you come up with the proper method it's piece of cake to do it (well, most of the time). The code is fully commented, as always.