Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Serial Number Embedded within Program

I'm writing my own serial number verification/protection for a software I wrote.

Assuming the serial number verifier is using pattern matching...once the serial number is verified, how can I change the program itself so that it doesn't ask the user for a serial number any longer?

I really don't want to have to create a separate license file. Is there a way to embed this within the program itself? Or is the registry the only other option (besides online verification, etc.)

like image 449
Sev Avatar asked Dec 28 '22 03:12

Sev


2 Answers

You shouldn't really attempt to edit the program itself - it'll break signatures/strong-naming, the exe/dll file will almost certainly be locked, and even if you shadow-copy: many users won't have permission to edit it in program-files (or as click-once).

Something external such as a license file or registry setting seems appropriate (unless you want to build the app at your server per-client).

like image 54
Marc Gravell Avatar answered Jan 08 '23 09:01

Marc Gravell


Is there a way to embed this within the program itself?

If you're hinting at modifying the assembly, then it's possible*, You'd need to have two assemblies - one that's currently executing and one that you're modifying - because the executing assembly will be locked by the file system. And you'd need to reserve enough space to store whatever new value you intend to inject.

*To prove this to myself, I created a small executable with that simply writes the value of a string, and used a hex editor to alter the value of the string.

You'd need to be quite smart about what change you made, though, otherwise registering the software and then simply copying the modified binary to other machines would circumvent your registration process.

Storing registration details in the registry is probably a far easier solution.

like image 30
Brett Avatar answered Jan 08 '23 09:01

Brett