Exemple #1
0
        /// <summary>
        /// Show registering dialog to user
        /// </summary>
        /// <returns>Type of running</returns>
        public RunTypes ShowDialog()
        {
            // check if registered before
            if (CheckRegister() == true)
            {
                return(RunTypes.Full);
            }

            frmDialog PassDialog = new frmDialog(_BaseString, _Password, DaysToEnd(), _Text);

            //MakeHideFile();
            string[] HideInfo;
            HideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');
            if (Convert.ToInt64(HideInfo[3]) < DateTime.Now.Ticks)
            {
                UpdateHideFile();
            }

            DialogResult DR = PassDialog.ShowDialog();

            if (DR == System.Windows.Forms.DialogResult.OK)
            {
                MakeRegFile();
                return(RunTypes.Full);
            }
            else if (DR == DialogResult.Retry)
            {
                return(RunTypes.Trial);
            }
            else
            {
                return(RunTypes.Expired);
            }
        }
Exemple #2
0
        // Get Data from hidden file if exists
        private int CheckHideFile()
        {
            string[] hideInfo;
            hideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');
            long DiffDays;
            int  DaysToEnd;

            if (_BaseString == hideInfo[3])
            {
                DaysToEnd = Convert.ToInt32(hideInfo[1]);
                if (DaysToEnd <= 0)
                {
                    _Runed   = 0;
                    _DefDays = 0;
                    return(0);
                }
                var dt = new DateTime(Convert.ToInt64(hideInfo[0]));
                DiffDays = DateAndTime.DateDiff(DateInterval.Day,
                                                dt.Date, DateTime.Now.Date,
                                                FirstDayOfWeek.Saturday,
                                                FirstWeekOfYear.FirstFullWeek);

                DaysToEnd = Convert.ToInt32(hideInfo[1]);
                _Runed    = Convert.ToInt32(hideInfo[2]);
                _Runed   -= 1;

                DiffDays = Math.Abs(DiffDays);

                _DefDays = DaysToEnd - Convert.ToInt32(DiffDays);
            }
            return(_DefDays);
        }
Exemple #3
0
        // store hidden information to hidden file
        // Date,DaysToEnd,HowManyTimesRuned,BaseString(ComputerID)
        private void MakeHideFile()
        {
            string HideInfo;

            HideInfo  = DateTime.Now.Ticks + ";";
            HideInfo += _DefDays + ";" + _Runed + ";" + _BaseString;
            FileReadWrite.WriteFile(_HideFilePath, HideInfo);
        }
Exemple #4
0
        // store hidden information to hidden file
        // Date,DaysToEnd,HowManyTimesRuned,BaseString(ComputerID)
        private void MakeHideFile()
        {
            string HideInfo;

            _LastRun  = DateTime.Now.Ticks.ToString();
            HideInfo  = DateTime.Now.Ticks + ";";
            HideInfo += _DefDays + ";" + _BaseString + ";" + _LastRun;
            FileReadWrite.WriteFile(_HideFilePath, HideInfo);
        }
        public static bool DetectClockManipulation(string TSFileName)
        {
            string FileContents = FileReadWrite.ReadFile(TSFileName);

            FileContents = FileContents.Trim(new char[] { ',' });
            IEnumerable <long> timeStamps = string.IsNullOrEmpty(FileContents) ? Enumerable.Empty <long>() : FileContents.Split(',').Select(s => long.Parse(s));

            timeStamps = timeStamps.Concat(new[] { DateTime.Now.Ticks });
            return(!timeStamps.Zip(timeStamps.Skip(1), (a, b) => a.CompareTo(b) <= 0).All(b => b));
        }
Exemple #6
0
        // Get Data from hidden file if exists
        private int CheckHideFile()
        {
            string[] HideInfo;
            string   clockManipulationDetectedFile = Path.GetDirectoryName(_HideFilePath) + "\\ClockManipulationDetected";
            string   fileContents = FileReadWrite.ReadFile(_HideFilePath);

            if (File.Exists(clockManipulationDetectedFile))
            {
                _Runed   = 0;
                _DefDays = 0;
                return(0);
            }

            HideInfo = fileContents.Split(';');
            long DiffDays;
            int  DaysToEnd;

            string TSFileName = Path.GetDirectoryName(_HideFilePath) + "\\TS" + _SoftName + ".tsmp";

            if (ClockManipulationDetector.DetectClockManipulation(TSFileName))
            {
                File.Create(clockManipulationDetectedFile);
                _Runed   = 0;
                _DefDays = 0;
                return(0);
            }

            if (_BaseString == HideInfo[3])
            {
                DaysToEnd = Convert.ToInt32(HideInfo[1]);
                if (DaysToEnd <= 0)
                {
                    _Runed   = 0;
                    _DefDays = 0;
                    return(0);
                }

                DateTime dt = new DateTime(Convert.ToInt64(HideInfo[0]));
                DiffDays = DateAndTime.DateDiff(DateInterval.Day,
                                                dt.Date, DateTime.Now.Date,
                                                FirstDayOfWeek.Saturday,
                                                FirstWeekOfYear.FirstFullWeek);

                DaysToEnd = Convert.ToInt32(HideInfo[1]);
                _Runed    = Convert.ToInt32(HideInfo[2]);
                _Runed   -= 1;

                DiffDays = Math.Abs(DiffDays);

                _DefDays = DaysToEnd - Convert.ToInt32(DiffDays);
            }
            return(_DefDays);
        }
Exemple #7
0
        private void UpdateHideFile()
        {
            string[] HideInfo;
            string   UpdatedInfo;

            HideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');

            _LastRun     = DateTime.Now.Ticks.ToString();
            UpdatedInfo  = HideInfo[0] + ";";
            UpdatedInfo += HideInfo[1] + ";" + _BaseString + ";" + _LastRun;
            FileReadWrite.WriteFile(_HideFilePath, UpdatedInfo);
        }
Exemple #8
0
        // Get Data from hidden file if exists
        private int CheckHideFile()
        {
            string[] HideInfo;
            HideInfo = FileReadWrite.ReadFile(_HideFilePath).Split(';');
            long DiffDays;
            int  DaysToEnd;

            _LastRun = HideInfo[3];
            if (_BaseString == HideInfo[2])
            {
                DaysToEnd = Convert.ToInt32(HideInfo[1]);
                if (DaysToEnd <= 0)
                {
                    //_Runed = 0;
                    _DefDays = 0;
                    return(0);
                }
                if (Convert.ToInt64(HideInfo[0]) > DateTime.Now.Ticks)
                {
                    _DefDays = 0;
                    return(0);
                }
                if (Convert.ToInt64(HideInfo[3]) > DateTime.Now.Ticks)
                {
                    _DefDays = 0;
                    return(0);
                }

                DateTime dt = new DateTime(Convert.ToInt64(HideInfo[0]));
                DiffDays = DateAndTime.DateDiff(DateInterval.Day,
                                                dt.Date, DateTime.Now.Date,
                                                FirstDayOfWeek.Saturday,
                                                FirstWeekOfYear.FirstFullWeek);

                DaysToEnd = Convert.ToInt32(HideInfo[1]);
                //_Runed = Convert.ToInt32(HideInfo[2]);
                //_Runed -= 1;

                DiffDays = Math.Abs(DiffDays);

                _DefDays = DaysToEnd - Convert.ToInt32(DiffDays);

                //DateTime dt1 = dt.AddDays(Convert.ToDouble(30 - _DefDays));

                //if (Convert.ToInt64(dt1) < DateTime.Now.Ticks)
                //{
                //    _DefDays = 0;
                //    return 0;
                //}
            }
            return(_DefDays);
        }
Exemple #9
0
        // Control Registeration file for password
        // if password saved correctly return true else false
        private bool CheckRegister()
        {
            string password = FileReadWrite.ReadFile(_RegFilePath);

            if (_Password == password)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #10
0
        private void ModifyTimeStampFile()
        {
            string TSFileName   = Path.GetDirectoryName(_HideFilePath) + "\\TS" + _SoftName + ".tsmp";
            string FileContents = string.Empty;

            if (File.Exists(TSFileName))
            {
                FileContents = FileReadWrite.ReadFile(TSFileName);
            }

            FileContents += DateTime.Now.Ticks + ",";
            FileReadWrite.WriteFile(TSFileName, FileContents);
        }
Exemple #11
0
        /// <summary>
        /// Show registering dialog to user
        /// </summary>
        /// <returns>Type of running</returns>
        public RunTypes ShowDialog()
        {
            // check if registered before

            if (_IsSubscrip == true)
            {
                _Runed = 50;
                if (DaysToEnd() > 0 && CheckRegister() == true)
                {
                    return(RunTypes.Full);
                }
                else if (CheckRegister() == true)
                {
                    _Identifier = "";
                    FileReadWrite.WriteFile(_RegFilePath, "");
                    MessageBox.Show("Your subscription is expired, Please enter new Subcription ID ", "Password", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            else
            {
                if (CheckRegister() == true)
                {
                    return(RunTypes.Full);
                }
            }
            frmDialog PassDialog = new frmDialog(_BaseString, _Password, DaysToEnd(), _Runed, _Text, _UID, _IsSubscrip);

            MakeHideFile();

            DialogResult DR = PassDialog.ShowDialog();

            if (DR == System.Windows.Forms.DialogResult.OK)
            {
                MakeRegFile();
                return(RunTypes.Full);
            }
            else if (DR == DialogResult.Retry)
            {
                return(RunTypes.Trial);
            }
            else
            {
                return(RunTypes.Expired);
            }
        }
Exemple #12
0
        // store hidden information to hidden file
        // Date,DaysToEnd,HowManyTimesRuned,BaseString(ComputerID)
        private void MakeHideFile(bool isFirstTimeCreation = false)
        {
            string HideInfo = string.Empty;

            if (isFirstTimeCreation)
            {
                HideInfo  = DateTime.Now.Ticks + ";";
                HideInfo += _DefDays + ";" + _Runed + ";" + _BaseString;
                HideInfo += ";" + DateTime.Now.Add(TimeSpan.FromDays(_DefDays)).Ticks;
                FileReadWrite.WriteFile(_HideFilePath, HideInfo);
            }
            else
            {
                //first read the contents of the file
                string fileContents = FileReadWrite.ReadFile(_HideFilePath);
                // then keep the installation ticks and license expiration ticks constant
                string[] HideInfoParts = fileContents.Split(';');
                HideInfo  = HideInfoParts[0] + ";";
                HideInfo += _DefDays + ";" + _Runed + ";" + _BaseString;
                HideInfo += ";" + HideInfoParts[4];
                FileReadWrite.WriteFile(_HideFilePath, HideInfo);
            }
        }
Exemple #13
0
 // save password to Registration file for next time usage
 private void MakeRegFile()
 {
     FileReadWrite.WriteFile(_RegFilePath, _Password);
 }