简体   繁体   English

程序中嵌入的C#序列号

[英]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.) 或者注册表是唯一的其他选项(除了在线验证等)

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). 你真的不应该试图编辑程序本身-它会打破签名/强命名的exe / dll文件几乎肯定会被锁定,即使你影副本:许多用户没有权限修改它在程序文件中(或单击一次)。

Something external such as a license file or registry setting seems appropriate (unless you want to build the app at your server per-client). 外部设备(例如许可证文件或注册表设置)似乎是合适的(除非您希望在每个客户端的服务器上构建应用程序)。

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. 在注册表中存储注册详细信息可能是一个更容易的解决方案。

Personally I always generate a unique key from the machines hardware and store this in the registry. 我个人总是从机器硬件生成一个唯一的密钥,并将其存储在注册表中。

Here is a simple example of a unique key but you may need to expand it if you want separate keys for different versions of the software. 下面是一个唯一密钥的简单示例,但如果您需要为不同版本的软件使用单独的密钥,则可能需要对其进行扩展。

http://www.vcskicks.com/hardware_id.php http://www.vcskicks.com/hardware_id.php

您可以将输入的序列密钥保存到文件或注册表中,并在用户启动应用程序时对其进行身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM