找回密码
 注册 (不支持IE浏览器)
搜索
查看: 107|回复: 1

[求助] C#怎么把代码中,不加载LIC文件,固定用户名和邮箱.....

[复制链接]

0

精华

9

贡献

244

赞扬

回帖
2
软币
604
在线时间
43 小时
注册时间
2023-8-28
发表于 2025-7-29 14:47:00 | 显示全部楼层 |阅读模式
using System;
using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;

namespace TerminalStudio.Main.ViewModels.Home.Verification
{
        // Token: 0x020002B0 RID: 688
        internal class AuthorizeViewModel : BindableBase
        {
                // Token: 0x170002BB RID: 699
                // (get) Token: 0x060014D2 RID: 5330 RVA: 0x0008BC04 File Offset: 0x00089E04
                // (set) Token: 0x060014D3 RID: 5331 RVA: 0x0008BC1C File Offset: 0x00089E1C
                public int iUserLevel
                {
                        get
                        {
                                return this._iUserLevel;
                        }
                        set
                        {
                                base.SetProperty<int>(ref this._iUserLevel, value, "iUserLevel");
                        }
                }

                // Token: 0x170002BC RID: 700
                // (get) Token: 0x060014D4 RID: 5332 RVA: 0x0008BC34 File Offset: 0x00089E34
                // (set) Token: 0x060014D5 RID: 5333 RVA: 0x0008BC4C File Offset: 0x00089E4C
                public string CompanyName
                {
                        get
                        {
                                return this._companyName;
                        }
                        set
                        {
                                base.SetProperty<string>(ref this._companyName, value, "CompanyName");
                        }
                }

                // Token: 0x170002BD RID: 701
                // (get) Token: 0x060014D6 RID: 5334 RVA: 0x0008BC64 File Offset: 0x00089E64
                // (set) Token: 0x060014D7 RID: 5335 RVA: 0x0008BC7C File Offset: 0x00089E7C
                public string RegisterMessage
                {
                        get
                        {
                                return this._RegisterMessage;
                        }
                        set
                        {
                                base.SetProperty<string>(ref this._RegisterMessage, value, "RegisterMessage");
                        }
                }

                // Token: 0x170002BE RID: 702
                // (get) Token: 0x060014D8 RID: 5336 RVA: 0x0008BC94 File Offset: 0x00089E94
                // (set) Token: 0x060014D9 RID: 5337 RVA: 0x0008BCAC File Offset: 0x00089EAC
                public bool bErrorMessage
                {
                        get
                        {
                                return this._bErrorMessage;
                        }
                        set
                        {
                                base.SetProperty<bool>(ref this._bErrorMessage, value, "bErrorMessage");
                        }
                }

                // Token: 0x060014DA RID: 5338 RVA: 0x0008BCC2 File Offset: 0x00089EC2
                private AuthorizeViewModel()
                {
                }

                // Token: 0x060014DB RID: 5339 RVA: 0x0008BCFC File Offset: 0x00089EFC
                public static AuthorizeViewModel CreateInstance()
                {
                        bool flag = AuthorizeViewModel.vm == null;
                        if (flag)
                        {
                                AuthorizeViewModel.vm = new AuthorizeViewModel();
                        }
                        return AuthorizeViewModel.vm;
                }

                // Token: 0x060014DC RID: 5340 RVA: 0x0008BD2C File Offset: 0x00089F2C
                public bool VerifyUser_Auto(ref string strMsg)
                {
                        bool flag = !this.Init_Verify("keyfile.lic", ref strMsg);
                        bool result;
                        if (flag)
                        {
                                string text = this.isFileExist("keyfile2.lic");
                                bool flag2 = text.Length > 0;
                                result = (flag2 && this.Init_Verify("keyfile2.lic", ref strMsg));
                        }
                        else
                        {
                                result = true;
                        }
                        return result;
                }

                // Token: 0x060014DD RID: 5341 RVA: 0x0008BD80 File Offset: 0x00089F80
                public bool VerifyUser_Manual(string strFilePath, ref string strMsg, bool bOtherFile = false)
                {
                        strMsg = "";
                        bool flag = !this.IsDllExist("verification.dll") || !this.IsDllExist("RequestfileGen.dll");
                        bool result;
                        if (flag)
                        {
                                strMsg = "找不到DLL(verification.dll,RequestfileGen.dll)";
                                this.iUserLevel = 0;
                                result = false;
                        }
                        else
                        {
                                bool flag2 = this.VerifyAuthorizationfile(strFilePath) > 0;
                                if (flag2)
                                {
                                        this.iUserLevel = 0;
                                        strMsg = "Verify failure.(授权验证失败,原因:授权码与本机信息不一致!) ";
                                        result = false;
                                }
                                else
                                {
                                        bool flag3 = !AuthorizeViewModel.CheckServiceLife();
                                        if (flag3)
                                        {
                                                this.iUserLevel = 0;
                                                strMsg = "Verify failure.(授权验证失败,原因:授权文件已失效,请重新申请!) ";
                                                this.SetRegisterMessage(false, strMsg);
                                                result = false;
                                        }
                                        else
                                        {
                                                bool flag4 = !this.CheckCustomerLevel();
                                                if (flag4)
                                                {
                                                        strMsg = "Verify failure.(授权验证失败,原因:授权等级低,请重新申请!) ";
                                                        this.SetRegisterMessage(false, strMsg);
                                                        result = false;
                                                }
                                                else
                                                {
                                                        bool flag5 = !this.CopyKeyfile(strFilePath, ref strMsg, bOtherFile);
                                                        if (flag5)
                                                        {
                                                                this.iUserLevel = 0;
                                                                result = false;
                                                        }
                                                        else
                                                        {
                                                                result = true;
                                                        }
                                                }
                                        }
                                }
                        }
                        return result;
                }

                // Token: 0x060014DE RID: 5342 RVA: 0x0008BE68 File Offset: 0x0008A068
                private bool Init_Verify(string fileName, ref string strMsg)
                {
                        strMsg = "";
                        string text = this.isFileExist(fileName);
                        bool flag = text.Length > 0;
                        bool result;
                        if (flag)
                        {
                                bool flag2 = !this.IsDllExist("verification.dll") || !this.IsDllExist("RequestfileGen.dll");
                                if (flag2)
                                {
                                        strMsg = "找不到DLL(verification.dll,RequestfileGen.dll)";
                                        this.iUserLevel = 0;
                                        result = false;
                                }
                                else
                                {
                                        bool flag3 = this.VerifyAuthorizationfile(text) > 0;
                                        if (flag3)
                                        {
                                                this.iUserLevel = 0;
                                                strMsg = "Verify failure.(授权验证失败,原因:授权码与本机信息不一致!) ";
                                                result = false;
                                        }
                                        else
                                        {
                                                bool flag4 = !AuthorizeViewModel.CheckServiceLife();
                                                if (flag4)
                                                {
                                                        this.iUserLevel = 0;
                                                        strMsg = "Verify failure.(授权验证失败,原因:授权文件已失效,请重新申请!) ";
                                                        this.SetRegisterMessage(false, strMsg);
                                                        result = false;
                                                }
                                                else
                                                {
                                                        bool flag5 = !this.CheckCustomerLevel();
                                                        if (flag5)
                                                        {
                                                                strMsg = "Verify failure.(授权验证失败,原因:授权等级低,请重新申请!) ";
                                                                this.SetRegisterMessage(false, strMsg);
                                                                result = false;
                                                        }
                                                        else
                                                        {
                                                                result = true;
                                                        }
                                                }
                                        }
                                }
                        }
                        else
                        {
                                strMsg = "License file not found.(未注册,原因:无授权文件!) ";
                                this.SetRegisterMessage(false, strMsg);
                                result = false;
                        }
                        return result;
                }

                // Token: 0x060014DF RID: 5343 RVA: 0x0008BF60 File Offset: 0x0008A160
                public byte VerifyAuthorizationfile(string strFullPathName)
                {
                        byte[] array = new byte[256];
                        byte[] array2 = RegisterFunc.Str2Ascii(strFullPathName);
                        byte[] array3 = new byte[256];
                        int iArrLen = 0;
                        Array.Copy(array2, array, array2.Length);
                        array[array2.Length] = 0;
                        byte b = 0;
                        try
                        {
                                b = RegisterFunc.FT_Verify(array);
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine(ex.ToString());
                        }
                        bool flag = b == 0;
                        if (flag)
                        {
                                Array.Clear(array3, 0, array3.Length);
                                RegisterFunc.FT_GetUserName(array3, ref iArrLen);
                                string text2 = RegisterFunc.Ascii2Str(array3);
                                int num = text2.IndexOf("\0");
                                bool flag2 = num > 0 && num < iArrLen;
                                string text3;
                                if (flag2)
                                {
                                        text3 = text2.Substring(0, num);
                                }
                                else
                                {
                                        text3 = text2.Substring(0, iArrLen);
                                }
                                Array.Clear(array3, 0, array3.Length);
                                RegisterFunc.FT_GetUserCompanyName(array3, ref iArrLen);
                                text2 = RegisterFunc.Ascii2Str(array3);
                                num = text2.IndexOf("\0");
                                bool flag3 = num > 0 && num < iArrLen;
                                if (flag3)
                                {
                                        this.CompanyName = text2.Substring(0, num);
                                }
                                else
                                {
                                        this.CompanyName = text2.Substring(0, iArrLen);
                                }
                                Array.Clear(array3, 0, array3.Length);
                                RegisterFunc.FT_GetUserEmail(array3, ref iArrLen);
                                text2 = RegisterFunc.Ascii2Str(array3);
                                num = text2.IndexOf("\0");
                                bool flag4 = num > 0 && num < iArrLen;
                                string text4;
                                if (flag4)
                                {
                                        text4 = text2.Substring(0, num);
                                }
                                else
                                {
                                        text4 = text2.Substring(0, iArrLen);
                                }
                                Array.Clear(array3, 0, array3.Length);
                                bool flag5 = RegisterFunc.FT_GetUserLevel(array3, ref iArrLen) == 0;
                                if (flag5)
                                {
                                        this.iUserLevel = (int)array3[0];
                                }
                                else
                                {
                                        this.iUserLevel = 0;
                                }
                                bool flag6 = this.iUserLevel >= 96;
                                string text5;
                                if (flag6)
                                {
                                        text5 = string.Concat(new string[]
                                        {
                                                "User: ",
                                                text3,
                                                ", Department: ",
                                                this.CompanyName,
                                                ", Mail: ",
                                                text4
                                        });
                                }
                                else
                                {
                                        text5 = string.Concat(new string[]
                                        {
                                                "User: ",
                                                text3,
                                                ", Company: ",
                                                this.CompanyName,
                                                ", Mail: ",
                                                text4
                                        });
                                }
                                this.SetRegisterMessage(true, text5);
                        }
                        else
                        {
                                string text5 = "Verify failure.(未注册,原因:授权文件无效,认证失败!) ";
                                this.SetRegisterMessage(false, text5);
                                AuthorizeViewModel.NavigateByVerifyResult("Keyfile_Error");
                        }
                        return b;
                }

                // Token: 0x060014E0 RID: 5344 RVA: 0x0008C1F8 File Offset: 0x0008A3F8
                private string isFileExist(string strFileName)
                {
                        string text = Directory.GetCurrentDirectory();
                        text = text + "\\" + strFileName;
                        bool flag = File.Exists(text);
                        string result;
                        if (flag)
                        {
                                result = text;
                        }
                        else
                        {
                                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                folderPath = folderPath + "/IdcStudio/" + strFileName;
                                bool flag2 = File.Exists(folderPath);
                                if (flag2)
                                {
                                        File.Copy(folderPath, text, true);
                                        result = folderPath;
                                }
                                else
                                {
                                        result = "";
                                }
                        }
                        return result;
                }

                // Token: 0x060014E1 RID: 5345 RVA: 0x0008C268 File Offset: 0x0008A468
                private bool IsDllSameBitWithProcess(string strFileName, ref string strErrMsg)
                {
                        bool flag = true;
                        bool is64BitProcess = Environment.Is64BitProcess;
                        string currentDirectory = Directory.GetCurrentDirectory();
                        string text = currentDirectory + "\\" + strFileName;
                        bool flag2 = File.Exists(text);
                        if (flag2)
                        {
                                flag = RegisterFunc.Is64BitDll(text);
                        }
                        strErrMsg = "";
                        bool flag3 = flag ^ is64BitProcess;
                        bool result;
                        if (flag3)
                        {
                                int num = 32;
                                bool flag4 = flag;
                                if (flag4)
                                {
                                        num = 64;
                                }
                                int num2 = 32;
                                bool flag5 = is64BitProcess;
                                if (flag5)
                                {
                                        num2 = 64;
                                }
                                strErrMsg = string.Format("Target platforms are different! \r\nDLL: {0}, BIT: {1};\r\nBIT of Current Process: {2}", strFileName, num, num2);
                                result = false;
                        }
                        else
                        {
                                result = true;
                        }
                        return result;
                }

                // Token: 0x060014E2 RID: 5346 RVA: 0x0008C304 File Offset: 0x0008A504
                private bool IsDllExist(string strFileName)
                {
                        bool is64BitProcess = Environment.Is64BitProcess;
                        string currentDirectory = Directory.GetCurrentDirectory();
                        string text = currentDirectory + "\\" + strFileName;
                        bool flag2 = File.Exists(text);
                        bool result;
                        if (flag2)
                        {
                                bool flag = RegisterFunc.Is64BitDll(text);
                                bool flag3 = flag ^ is64BitProcess;
                                if (flag3)
                                {
                                        bool flag4 = is64BitProcess;
                                        if (flag4)
                                        {
                                                string text2 = currentDirectory + "\\Models\\Libs\\Verification\\Bit64\\" + strFileName;
                                                bool flag5 = File.Exists(text2);
                                                if (flag5)
                                                {
                                                        File.Copy(text2, text, true);
                                                        result = true;
                                                }
                                                else
                                                {
                                                        result = false;
                                                }
                                        }
                                        else
                                        {
                                                string text3 = currentDirectory + "\\Models\\Libs\\Verification\\Bit32\\" + strFileName;
                                                bool flag6 = File.Exists(text3);
                                                if (flag6)
                                                {
                                                        File.Copy(text3, text, true);
                                                        result = true;
                                                }
                                                else
                                                {
                                                        result = false;
                                                }
                                        }
                                }
                                else
                                {
                                        result = true;
                                }
                        }
                        else
                        {
                                bool flag7 = is64BitProcess;
                                if (flag7)
                                {
                                        string text4 = currentDirectory + "\\Models\\Libs\\Verification\\Bit64\\" + strFileName;
                                        bool flag8 = File.Exists(text4);
                                        if (flag8)
                                        {
                                                File.Copy(text4, text, true);
                                                result = true;
                                        }
                                        else
                                        {
                                                result = false;
                                        }
                                }
                                else
                                {
                                        string text5 = currentDirectory + "\\Models\\Libs\\Verification\\Bit32\\" + strFileName;
                                        bool flag9 = File.Exists(text5);
                                        if (flag9)
                                        {
                                                File.Copy(text5, text, true);
                                                result = true;
                                        }
                                        else
                                        {
                                                result = false;
                                        }
                                }
                        }
                        return result;
                }

                // Token: 0x060014E3 RID: 5347 RVA: 0x0008C435 File Offset: 0x0008A635
                public static void NavigateByVerifyResult(string strVerifyResult)
                {
                }

                // Token: 0x060014E4 RID: 5348 RVA: 0x0008C438 File Offset: 0x0008A638
                public void NavigateByVerifyResultEx(string strVerifyResult)
                {
                }

                // Token: 0x060014E5 RID: 5349 RVA: 0x0008C43B File Offset: 0x0008A63B
                public void SetRegisterMessage(bool bRegisted, string strMsg)
                {
                        this.bErrorMessage = bRegisted;
                        this.RegisterMessage = strMsg;
                }

                // Token: 0x060014E6 RID: 5350 RVA: 0x0008C450 File Offset: 0x0008A650
                public static bool CheckServiceLife()
                {
                        byte[] array = new byte[256];
                        byte[] bEndDate = new byte[256];
                        int iArrLen = 0;
                        int iServiceDay = 0;
                        int runTimes = AuthorizeViewModel.GetRunTimes();
                        int year = DateTime.Now.Year;
                        int month = DateTime.Now.Month;
                        int day = DateTime.Now.Day;
                        RegisterFunc.FT_GetRegTime(array, ref iArrLen);
                        int num = ((int)array[1] << 8) + (int)array[2];
                        int num2 = (int)array[3];
                        int num3 = (int)array[4];
                        AuthorizeViewModel.GetEndServiceLife(array, ref bEndDate, ref iServiceDay);
                        int num4 = ((int)bEndDate[0] << 8) + (int)bEndDate[1];
                        int num5 = (int)bEndDate[2];
                        int num6 = (int)bEndDate[3];
                        bool flag = num > year || (num == year && num2 > month) || (num == year && num2 == month && num3 > day);
                        bool result;
                        if (flag)
                        {
                                result = false;
                        }
                        else
                        {
                                bool flag2 = num4 > year || (num4 == year && num5 > month) || (num4 == year && num5 == month && num6 >= day);
                                if (flag2)
                                {
                                        bool flag3 = iServiceDay >= runTimes;
                                        if (flag3)
                                        {
                                                return true;
                                        }
                                }
                                result = false;
                        }
                        return result;
                }

                // Token: 0x060014E7 RID: 5351 RVA: 0x0008C570 File Offset: 0x0008A770
                public bool CheckCustomerLevel()
                {
                        bool result = true;
                        bool flag = !MainWindowViewModel.CreateInstance().bIsUsedVersion_Home;
                        if (flag)
                        {
                                result = UserLevelClass.CheckInitialCodeTurningPermission((byte)this.iUserLevel);
                        }
                        return result;
                }

                // Token: 0x060014E8 RID: 5352 RVA: 0x0008C5A8 File Offset: 0x0008A7A8
                public bool SetServiceLife()
                {
                        int num = 0;
                        int num2 = 0;
                        int num3 = 0;
                        int num4 = 0;
                        try
                        {
                                RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                bool flag = registryKey != null;
                                if (flag)
                                {
                                        bool flag2 = registryKey.GetValue("RunTimes") != null;
                                        if (flag2)
                                        {
                                                string text = registryKey.GetValue("RunTimes").ToString();
                                                bool flag3 = text != "";
                                                if (flag3)
                                                {
                                                        num = int.Parse(text);
                                                }
                                        }
                                        bool flag4 = registryKey.GetValue("LastYear") != null;
                                        if (flag4)
                                        {
                                                string text = registryKey.GetValue("LastYear").ToString();
                                                bool flag5 = text != "";
                                                if (flag5)
                                                {
                                                        num2 = int.Parse(text);
                                                }
                                        }
                                        bool flag6 = registryKey.GetValue("LastMonth") != null;
                                        if (flag6)
                                        {
                                                string text = registryKey.GetValue("LastMonth").ToString();
                                                bool flag7 = text != "";
                                                if (flag7)
                                                {
                                                        num3 = int.Parse(text);
                                                }
                                        }
                                        bool flag8 = registryKey.GetValue("LastDay") != null;
                                        if (flag8)
                                        {
                                                string text = registryKey.GetValue("LastDay").ToString();
                                                bool flag9 = text != "";
                                                if (flag9)
                                                {
                                                        num4 = int.Parse(text);
                                                }
                                        }
                                }
                                registryKey.Close();
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine(ex.Message);
                        }
                        byte[] array = new byte[256];
                        int iArrLen = 0;
                        RegisterFunc.FT_GetRegTime(array, ref iArrLen);
                        int num5 = ((int)array[1] << 8) + (int)array[2];
                        int num6 = (int)array[3];
                        int num7 = (int)array[4];
                        int num8 = (int)array[0];
                        bool flag10 = num5 < num2;
                        if (flag10)
                        {
                                int num9 = (num2 - num5 - 1) * 12 + (12 - num6) + num3;
                                bool flag11 = num9 > num8;
                                if (flag11)
                                {
                                        goto IL_2F4;
                                }
                        }
                        bool flag12 = num5 == num2 && num6 < num3;
                        if (flag12)
                        {
                                bool flag13 = num8 < num3 - num6;
                                if (flag13)
                                {
                                        goto IL_2F4;
                                }
                        }
                        bool flag14 = num5 == num2 && num6 == num3 && num7 < num4;
                        if (flag14)
                        {
                                bool flag15 = num8 < num3 - num6;
                                if (flag15)
                                {
                                        goto IL_2F4;
                                }
                        }
                        bool flag16 = num5 == num2 && num6 == num3 && num7 == num4;
                        if (!flag16)
                        {
                                num = 0;
                        }
                        try
                        {
                                RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio");
                                bool flag17 = registryKey2 == null;
                                if (flag17)
                                {
                                        Registry.CurrentUser.CreateSubKey("SOFTWARE\\IdcStudio");
                                }
                                registryKey2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                registryKey2.SetValue("RunTimes", num.ToString());
                                registryKey2.SetValue("LastYear", num5.ToString());
                                registryKey2.SetValue("LastMonth", num6.ToString());
                                registryKey2.SetValue("LastDay", num7.ToString());
                                registryKey2.Close();
                        }
                        catch (Exception ex2)
                        {
                                Console.WriteLine(ex2.Message);
                        }
                        return true;
                        IL_2F4:
                        this.iUserLevel = 0;
                        this.SetRegisterMessage(false, "Verify failure.(注册失败,原因:授权文件无效,认证失败!) ");
                        AuthorizeViewModel.NavigateByVerifyResult("Keyfile_Error");
                        return false;
                }

                // Token: 0x060014E9 RID: 5353 RVA: 0x0008C908 File Offset: 0x0008AB08
                public static void GetEndServiceLife(byte[] bStartData, ref byte[] bEndDate, ref int iServiceDay)
                {
                        int num = (int)bStartData[0];
                        int num2 = ((int)bStartData[1] << 8) + (int)bStartData[2];
                        int num3 = (int)bStartData[3];
                        int num4 = (int)bStartData[4];
                        bool flag = num % 12 == 0;
                        int num5;
                        int num6;
                        int num7;
                        if (flag)
                        {
                                num5 = num2 + num / 12;
                                num6 = num3;
                                num7 = num4;
                                iServiceDay = 365 * (num / 12);
                                for (int i = 0; i < num / 12; i++)
                                {
                                        bool flag2 = (num2 % 4 == 0 && num2 % 100 != 0) || num2 % 400 == 0;
                                        if (flag2)
                                        {
                                                iServiceDay++;
                                        }
                                }
                        }
                        else
                        {
                                bool flag3 = num < 12;
                                if (flag3)
                                {
                                        num6 = num3 + num;
                                        bool flag4 = num6 > 12;
                                        if (flag4)
                                        {
                                                num5 = num2 + 1;
                                                num6 %= 12;
                                                num7 = num4;
                                        }
                                        else
                                        {
                                                num5 = num2;
                                                num7 = num4;
                                        }
                                        iServiceDay = 0;
                                        for (int j = num3; j < num3 + num; j++)
                                        {
                                                switch (j % 12)
                                                {
                                                case 0:
                                                        iServiceDay += 31;
                                                        break;
                                                case 1:
                                                        iServiceDay += 31;
                                                        break;
                                                case 2:
                                                {
                                                        bool flag5 = (num2 % 4 == 0 && num2 % 100 != 0) || num2 % 400 == 0;
                                                        if (flag5)
                                                        {
                                                                iServiceDay += 29;
                                                        }
                                                        else
                                                        {
                                                                iServiceDay += 28;
                                                        }
                                                        break;
                                                }
                                                case 3:
                                                        iServiceDay += 31;
                                                        break;
                                                case 4:
                                                        iServiceDay += 30;
                                                        break;
                                                case 5:
                                                        iServiceDay += 31;
                                                        break;
                                                case 6:
                                                        iServiceDay += 30;
                                                        break;
                                                case 7:
                                                        iServiceDay += 31;
                                                        break;
                                                case 8:
                                                        iServiceDay += 31;
                                                        break;
                                                case 9:
                                                        iServiceDay += 30;
                                                        break;
                                                case 10:
                                                        iServiceDay += 31;
                                                        break;
                                                case 11:
                                                        iServiceDay += 30;
                                                        break;
                                                }
                                        }
                                }
                                else
                                {
                                        num5 = 0;
                                        num6 = 0;
                                        num7 = 0;
                                        iServiceDay = 0;
                                }
                        }
                        bEndDate[0] = (byte)(num5 >> 8);
                        bEndDate[1] = (byte)(num5 & 255);
                        bEndDate[2] = (byte)num6;
                        bEndDate[3] = (byte)num7;
                }

                // Token: 0x060014EA RID: 5354 RVA: 0x0008CB0C File Offset: 0x0008AD0C
                private static int GetRunTimes()
                {
                        int result = 0;
                        try
                        {
                                RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                bool flag = registryKey != null;
                                if (flag)
                                {
                                        bool flag2 = registryKey.GetValue("RunTimes") != null;
                                        if (flag2)
                                        {
                                                string text = registryKey.GetValue("RunTimes").ToString();
                                                bool flag3 = text != "";
                                                if (flag3)
                                                {
                                                        result = int.Parse(text);
                                                }
                                        }
                                }
                                registryKey.Close();
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine(ex.Message);
                                return result;
                        }
                        return result;
                }

                // Token: 0x060014EB RID: 5355 RVA: 0x0008CBB8 File Offset: 0x0008ADB8
                private void SetRunTimes()
                {
                        bool flag = !this.GetAuthorizationState();
                        if (!flag)
                        {
                                int year = DateTime.Now.Year;
                                int month = DateTime.Now.Month;
                                int day = DateTime.Now.Day;
                                string text = string.Format("{0:D04}{1:D02}{2:D02}", year, month, day);
                                string text2 = "";
                                int runTimes = AuthorizeViewModel.GetRunTimes();
                                bool flag2 = this.iStartRunningYear == year && this.iStartRunningMonth == month && this.iStartRunningDay == day;
                                if (flag2)
                                {
                                        runTimes++;
                                }
                                else
                                {
                                        bool flag3 = this.iStartRunningYear == year && this.iStartRunningMonth == month && this.iStartRunningDay < day;
                                        if (flag3)
                                        {
                                                runTimes = day - this.iStartRunningDay + 1;
                                        }
                                        else
                                        {
                                                bool flag4 = this.iStartRunningMonth != month && this.iStartRunningDay != day;
                                                if (flag4)
                                                {
                                                        int num;
                                                        switch (this.iStartRunningMonth)
                                                        {
                                                        case 1:
                                                        case 3:
                                                        case 5:
                                                        case 7:
                                                        case 8:
                                                        case 10:
                                                        case 12:
                                                                num = 31;
                                                                break;
                                                        case 2:
                                                        {
                                                                bool flag5 = (this.iStartRunningYear % 4 == 0 && this.iStartRunningYear % 100 != 0) || this.iStartRunningYear % 400 == 0;
                                                                if (flag5)
                                                                {
                                                                        num = 29;
                                                                }
                                                                else
                                                                {
                                                                        num = 28;
                                                                }
                                                                break;
                                                        }
                                                        case 4:
                                                        case 6:
                                                        case 9:
                                                        case 11:
                                                                num = 30;
                                                                break;
                                                        default:
                                                                num = 30;
                                                                break;
                                                        }
                                                        runTimes = num - this.iStartRunningDay + day + 1;
                                                }
                                                else
                                                {
                                                        runTimes++;
                                                }
                                        }
                                }
                                try
                                {
                                        RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                        bool flag6 = registryKey != null;
                                        if (flag6)
                                        {
                                                bool flag7 = registryKey.GetValue("LastRunDate") != null;
                                                if (flag7)
                                                {
                                                        text2 = registryKey.GetValue("LastRunDate").ToString();
                                                }
                                        }
                                        registryKey.Close();
                                }
                                catch (Exception ex)
                                {
                                        Console.WriteLine(ex.Message);
                                }
                                bool flag8 = text2 != text;
                                if (flag8)
                                {
                                        try
                                        {
                                                RegistryKey registryKey2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio");
                                                bool flag9 = registryKey2 == null;
                                                if (flag9)
                                                {
                                                        Registry.CurrentUser.CreateSubKey("SOFTWARE\\IdcStudio");
                                                }
                                                registryKey2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                                registryKey2.SetValue("RunTimes", runTimes.ToString());
                                                registryKey2.SetValue("LastRunDate", text);
                                                registryKey2.Close();
                                        }
                                        catch (Exception ex2)
                                        {
                                                Console.WriteLine(ex2.Message);
                                        }
                                }
                        }
                }

                // Token: 0x060014EC RID: 5356 RVA: 0x0008CE8C File Offset: 0x0008B08C
                public static bool SetAuthorizationState(bool bRegisted)
                {
                        try
                        {
                                RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio");
                                bool flag = registryKey == null;
                                if (flag)
                                {
                                        Registry.CurrentUser.CreateSubKey("SOFTWARE\\IdcStudio");
                                }
                                registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                if (bRegisted)
                                {
                                        registryKey.SetValue("AuthorizationState", "1");
                                }
                                else
                                {
                                        registryKey.SetValue("AuthorizationState", "0");
                                }
                                registryKey.Close();
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine(ex.Message);
                        }
                        return true;
                }

                // Token: 0x060014ED RID: 5357 RVA: 0x0008CF34 File Offset: 0x0008B134
                private bool GetAuthorizationState()
                {
                        bool result = false;
                        int num = 0;
                        try
                        {
                                RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\IdcStudio", true);
                                bool flag = registryKey != null;
                                if (flag)
                                {
                                        bool flag2 = registryKey.GetValue("AuthorizationState") != null;
                                        if (flag2)
                                        {
                                                string text = registryKey.GetValue("AuthorizationState").ToString();
                                                bool flag3 = text != "";
                                                if (flag3)
                                                {
                                                        num = int.Parse(text);
                                                }
                                                bool flag4 = 1 == num;
                                                if (flag4)
                                                {
                                                        result = true;
                                                }
                                        }
                                }
                                registryKey.Close();
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine(ex.Message);
                        }
                        return result;
                }

                // Token: 0x060014EE RID: 5358 RVA: 0x0008CFEC File Offset: 0x0008B1EC
                public static void SetUserInfo()
                {
                        string text = "";
                        byte[] array = new byte[256];
                        byte[] bEndDate = new byte[256];
                        int iArrLen = 0;
                        int iServiceDay = 0;
                        Array.Clear(array, 0, array.Length);
                        RegisterFunc.FT_GetRegTime(array, ref iArrLen);
                        int num2 = ((int)array[1] << 8) + (int)array[2];
                        int num3 = (int)array[3];
                        int num4 = (int)array[4];
                        AuthorizeViewModel.GetEndServiceLife(array, ref bEndDate, ref iServiceDay);
                        int num5 = ((int)bEndDate[0] << 8) + (int)bEndDate[1];
                        int num6 = (int)bEndDate[2];
                        int num7 = (int)bEndDate[3];
                        Array.Clear(array, 0, array.Length);
                        RegisterFunc.FT_GetUserName(array, ref iArrLen);
                        string text2 = RegisterFunc.Ascii2Str(array);
                        int num8 = text2.IndexOf("\0");
                        bool flag = num8 > 0 && num8 < iArrLen;
                        string text3;
                        if (flag)
                        {
                                text3 = text2.Substring(0, num8);
                        }
                        else
                        {
                                text3 = text2.Substring(0, iArrLen);
                        }
                        string text4 = string.Format("\r\n \r\nUser Name:  {0}", text3);
                        text += text4;
                        text4 = string.Format("\r\n \nValid Date:  {0}-{1:D02}-{2:D02} ----- {3}-{4:D02}-{5:D02}", new object[]
                        {
                                num2,
                                num3,
                                num4,
                                num5,
                                num6,
                                num7
                        });
                        text += text4;
                }

                // Token: 0x060014EF RID: 5359 RVA: 0x0008D144 File Offset: 0x0008B344
                private bool CopyKeyfile(string strFullPathName, ref string strMsg, bool bOtherFile = false)
                {
                        string text = "keyfile.lic";
                        if (bOtherFile)
                        {
                                text = "keyfile2.lic";
                        }
                        string text2 = Directory.GetCurrentDirectory() + "\\" + text;
                        bool flag = AuthorizeViewModel.CheckServiceLife();
                        bool result;
                        if (flag)
                        {
                                bool flag2 = this.SetServiceLife();
                                if (flag2)
                                {
                                        bool flag3 = File.Exists(strFullPathName);
                                        if (!flag3)
                                        {
                                                MessageBox.Show("can't find the source file of license!");
                                                return false;
                                        }
                                        bool flag4 = strFullPathName != text2;
                                        if (flag4)
                                        {
                                                File.Copy(strFullPathName, text2, true);
                                        }
                                        string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                        folderPath += "/IdcStudio";
                                        bool flag5 = !Directory.Exists(folderPath);
                                        if (flag5)
                                        {
                                                Directory.CreateDirectory(folderPath);
                                        }
                                        File.Copy(strFullPathName, folderPath + "/" + text, true);
                                }
                                result = true;
                        }
                        else
                        {
                                this.iUserLevel = 0;
                                strMsg = "Verify failure.(授权验证失败,原因:授权文件已过期,请重新申请!) ";
                                result = false;
                        }
                        return result;
                }

                // Token: 0x060014F0 RID: 5360 RVA: 0x0008D22C File Offset: 0x0008B42C
                private void DeleteLicFiles(string path, string srcFile = "")
                {
                        foreach (string text in Directory.GetFiles(path))
                        {
                                bool flag = text.ToLower().Trim().EndsWith(".lic");
                                if (flag)
                                {
                                        bool flag2 = text != srcFile;
                                        if (flag2)
                                        {
                                                File.Delete(text);
                                        }
                                }
                        }
                }

                // Token: 0x04001074 RID: 4212
                public static AuthorizeViewModel vm;

                // Token: 0x04001075 RID: 4213
                private int iStartRunningYear = 0;

                // Token: 0x04001076 RID: 4214
                private int iStartRunningMonth = 0;

                // Token: 0x04001077 RID: 4215
                private int iStartRunningDay = 0;

                // Token: 0x04001078 RID: 4216
                private int _iUserLevel = 0;

                // Token: 0x04001079 RID: 4217
                private string _companyName;

                // Token: 0x0400107A RID: 4218
                private string _RegisterMessage = "Register Message";

                // Token: 0x0400107B RID: 4219
                private bool _bErrorMessage = true;
        }
}


回复

使用道具 举报

0

精华

89

贡献

468

赞扬

回帖
155
软币
1161
在线时间
85 小时
注册时间
2025-9-17
发表于 2026-1-14 13:47:06 | 显示全部楼层
感谢楼主的分享
回复

使用道具 举报

本版积分规则

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文科技有限公司 苏公网安备32011302322501号

GMT+8, 2026-4-16 02:30

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表