以前从没干过破解的勾当,这次确实必须要去破解一个,于是下了个反编译工具。 最终拿到反编译出来的文件,欣赏了一把它的license检测代码。原谅我的无知,以下代码在我看来还是比较新鲜,犬神请不要鄙视:

internal static void CheckLicense()
{
if (!License.licenseChecked)
{
try
{
using (IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly())
{
using (IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream("xxx.lic", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, isolatedStorageFile))
{
long storageLength = isolatedStorageFileStream.Length;
if (storageLength == (long))
{
Encoding uTF8 = Encoding.UTF8;
DateTime dateTime = DateTime.Now.AddDays();
byte[] bytes = uTF8.GetBytes(dateTime.Ticks.ToString());
isolatedStorageFileStream.Write(bytes, , (int)bytes.Length);
}
else
{
byte[] bytes = new byte[checked(storageLength)];
int bytesRead = isolatedStorageFileStream.Read(bytes, , (int)bytes.Length);
DateTime expiryDateTime = new DateTime(long.Parse(Encoding.UTF8.GetString(bytes, , bytesRead)));
if (DateTime.Now > expiryDateTime)
{
License.licenseExpired = true;
}
}
}
}
License.licenseChecked = true;
}
catch (Exception exception)
{
}
}
if (License.licenseExpired)
{
throw new InvalidOperationException("The trial period has expired. Please contact us at xxx.com for further information.");
}
}
CheckLicense()方法可以放在代码中任何地方使用。
基本原理就是在第一次运行时,检测是否生成了license,并把过期日期算好写进去,以后每次检测是否到期。
关键类是IsolatedStorageFile 。它创建的文件在文件系统中,不需要特殊路径,一般权限的托管代码是不能访问其他dll文件的IsolatedStorageFile 文件的,高级权限的托管代码可以访问其他dll的文件,非托管代码可以访问任何IsolatedStorageFile 文件。


最新文章

  1. nodejs开发指南demo
  2. 一起买beta版PHP单元测试
  3. Swift 玩转 3D Touch 之 Peek & Pop
  4. Java中的内存分配机制
  5. 创建ubuntu软件源
  6. XE5 Android 开发数据访问手机端 解决乱码的办法
  7. 【转】Android自定义Adapter的ListView的思路及代码
  8. 在纯C工程的main函数之前跑代码(手工找到程序入口点, 替换为我们自己的函数)
  9. Android Studio Gradle 添加.so 支持文件
  10. J Dp
  11. 零基础入门学习UI设计指南
  12. 学点Groovy来理解build.gradle代码
  13. CentOS安装配置MySql数据库
  14. python作用域与命名空间
  15. Seattle Traffic construction projects punlication
  16. 第一章 Java程序设计概述
  17. 洛谷P1848 书架
  18. [sqoop] sqoop2 使用
  19. java学习之路--多线程实现的方法
  20. 剑指offer-顺时针打印矩阵-二维数组

热门文章

  1. 【airflow实战系列】 基于 python 的调度和监控工作流的平台
  2. 用C#操作IO端口1-用并口控制发光二极管
  3. PHP 数据集循环
  4. 聊聊flutter的UI布局
  5. C++Primer笔记-----day05
  6. Tmux (转)
  7. 收集了一些iOS技术面试题
  8. beego 自定义模板函数
  9. Unity几个有用的游戏运动特效
  10. Codeforces 1154G 枚举