程序中嵌入的 C# 序列号

发布于 2024-10-10 13:39:19 字数 156 浏览 3 评论 0原文

我正在为我编写的软件编写自己的序列号验证/保护。

假设序列号验证器正在使用模式匹配...一旦验证了序列号,我如何更改程序本身,以便它不再要求用户提供序列号?

我真的不想创建单独的许可证文件。有没有办法将其嵌入到程序本身中?或者注册表是唯一的其他选择(除了在线验证等)

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.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

缺⑴份安定 2024-10-17 13:39:19

您不应该真正尝试编辑程序本身 - 它会破坏签名/强命名,exe/dll 文件几乎肯定会被锁定,即使您进行卷影复制:许多用户也不会拥有 允许在程序文件中编辑它(或单击一次)。

诸如许可证文件或注册表设置之类的外部内容似乎是合适的(除非您想在每个客户端的服务器上构建应用程序)。

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).

梅窗月明清似水 2024-10-17 13:39:19

有没有办法将其嵌入到程序本身中?

如果您暗示要修改程序集,那么这是可能的*,您需要有两个程序集 - 一个当前正在执行,另一个正在修改 - 因为正在执行的程序集将被文件系统锁定。并且您需要保留足够的空间来存储您打算注入的任何新值。

*为了向自己证明这一点,我创建了一个小型可执行文件,它只需写入字符串的值,并使用十六进制编辑器来更改字符串的值。

您需要非常聪明但是,关于您所做的更改,否则注册软件然后简单地将修改后的二进制文件复制到其他计算机将绕过您的注册过程。

将注册详细信息存储在注册表中可能是一个更简单的解决方案。

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.

玩世 2024-10-17 13:39:19

就我个人而言,我总是从机器硬件生成一个唯一的密钥并将其存储在注册表中。

以下是唯一密钥的简单示例,但如果您需要针对不同版本的软件使用单独的密钥,则可能需要对其进行扩展。

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

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

这个俗人 2024-10-17 13:39:19

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

You could save the serial key that was entered to a file or registry, and just authenticate it whenever the user starts your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文