一个没有实现的想法。。。
本文的主题其实是关于Codesmith的授权技术讨论;
有一个类:
[Serializable, LicenseProvider(typeof(cn))]
public sealed class CodeSmithLicense
{
// Fields
private static CodeSmithLicense _codeSmithLicense;
private static string _enginePublicKeyToken;
private static DateTime _expirationDate;
private static bool _isBeta;
private static bool _isFullTrial;
private static bool _isProfessional;
private static bool _isSDK;
private static bool _isServer;
private static bool _isStandard;
private static bool? _isStandardInstall;
private static bool _isTrial;
private SecureLicense _license;
private static DateTime _licenseCacheExpirationDate;
private static CodeSmithEditions _licensedEdition;
private static object _lockHandle;
位于CodeSmith.Engine.dll中。。。
其实想办法改变这些变量估计就可以通过验证与授权之类的了。
所以要写一些代码,但怎么然这些代码运行起来呢?我们写的代码好像与CodeSmithStudio.exe没有关系啊!
其实就是把我们写的一些代码注入到CodeSmithStudio.exe,如果要注入,当然要改原版的程序啦,大家知道改程序用什么啦把(IL语言啊)
.method private hidebysig static void a(string[] A_0) cil managed
{
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor()
.entrypoint
// token: 06000527
.maxstack 4
.locals init (
[0] class [CodeSmith.Engine]CodeSmith.Engine.FeatureNotAllowedException exception)
L_0000: call void [System.Windows.Forms]System.Windows.Forms.Application::EnableVisualStyles() // 282B05000A
L_0005: ldc.i4.0 // 16
L_0006: call void [System.Windows.Forms]System.Windows.Forms.Application::SetCompatibleTextRenderingDefault(bool) // 282C05000A
L_000b: ldstr "CodeSmith Generator Studio" // 7289150070
L_0010: ldc.i4.1 // 17
在入口点加入我们写的代码行不?
代码加完了,再编译回来(大家注意强命名啦,否则编译回来无法运行,要去掉强命名的)
只是一些思路,我也没有去实现,呵呵,仅供技术交流。。。

浙公网安备 33010602011771号