Exemplo n.º 1
0
 public static bool IsValidVersionMark(NCLicenseDll.EvaluationData evaluationDt, short productId)
 {
     if (evaluationDt.Year < 2005 || evaluationDt.Year > 3500)
     {
         return(false);
     }
     if (evaluationDt.Month > 12 || evaluationDt.Days > 31)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public static NCLicenseDll.EvaluationData GetInstallTime(byte[] data, long version, short prodId)
        {
            NCLicenseDll.EvaluationData time = new NCLicenseDll.EvaluationData();

            int evaluationDataSize = 0;

            unsafe
            {
                evaluationDataSize = sizeof(NCLicenseDll.EvaluationData);
            }
            byte[] temp = new byte[evaluationDataSize];
            Buffer.BlockCopy(data, (int)(g_DataOffset + version * evaluationDataSize), temp, 0, evaluationDataSize);

            return(ByteArrayToStructure <NCLicenseDll.EvaluationData>(temp));
        }
Exemplo n.º 3
0
        public static int ReadEvaluationDataManaged(int version, ref NCLicenseDll.EvaluationData evaluationData, short productId)
        {
            String[] systemFolder = GetStubPath();

            byte[] data = null;

            int fileRetryCount = 0;

            for (int i = 0; i < systemFolder.Length; i++)
            {
                //int dwSize = 0;
                bool fileExists = File.Exists(systemFolder[i]);
                if (fileExists)
                {
                    FileStream fs = File.OpenRead(systemFolder[i]);
                    data = new byte[(int)fs.Length];
                    fs.Read(data, 0, (int)fs.Length);
                    fs.Close();
                    if (data != null)
                    {
                        break;
                    }
                }
                fileRetryCount++;
            }
            if (fileRetryCount == systemFolder.Length || data == null)
            {
                return(-1);
            }
            //byte[] temp = new byte[data.Length - g_DataOffset];
            //Buffer.BlockCopy(data, (int)g_DataOffset, temp, 0, (int)(data.Length - g_DataOffset));
            NCCryptoCode.EncryptDecryptBytes(data, data.Length - (int)g_DataOffset, (int)g_DataOffset);
            evaluationData = GetInstallTime(data, version, productId);
            if (!IsValidVersionMark(evaluationData, productId))
            {
                return(-1);
            }
            //evaluationData.Hour = Misc::GetExtensionsUsed(prodId); //TODO: Licensing
            if (evaluationData.Extensions < 0)    //TODO: Licensing (These values need to be zero by them. This is not correct method)
            {
                evaluationData.Extensions = 0;
            }
            if (evaluationData.Res3 < 0)
            {
                evaluationData.Res3 = 0;
            }
            return(0);
        }
Exemplo n.º 4
0
        public static int ReadEvaluationData(int version, ref NCLicenseDll.EvaluationData evaluationData, short productId)
        {
            try
            {
                if (Environment.OSVersion.Platform == PlatformID.Win32NT || RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    return(UnManagedNCLicense.ReadEvaluationData(version, ref evaluationData, productId));
                }
            }
            catch (DllNotFoundException)
            {
                // Eating this exception on purpose
                // because of Nano Server
            }

            return(ReadEvaluationDataManaged(version, ref evaluationData, productId));
        }
Exemplo n.º 5
0
 public static extern int ReadEvaluationData(
     int version,
     ref NCLicenseDll.EvaluationData time, short prodId);