Exemplo n.º 1
0
        public void Save()
        {
            string bios = RandomFunctions.GetBIOSSerialNumber();

            string _uKey = "UN_" + bios;

            Registry.SetValue(RegSaveBase, "DAT_B", SecurityKeys.ByteArrayToString(Encryption.EncryptStringToBytes(_username, SecurityKeys.GenerateKey(_uKey), SecurityKeys.GenerateIV(_uKey))));

            string _pKey = "PD_" + bios;

            Registry.SetValue(RegSaveBase, "DAT_A", SecurityKeys.ByteArrayToString(Encryption.EncryptStringToBytes(_password, SecurityKeys.GenerateKey(_pKey), SecurityKeys.GenerateIV(_pKey))));
        }
        private void ShowActivateResult(bool value, string msg)
        {
            if (value)
            {
                // If on Vista or newer, we need to elevate to activate.
                if (Environment.OSVersion.Version >= OSVersions.Win_Vista)
                {
                    IsEnabled = false;

                    try
                    {
                        ProcessStartInfo pInfo = new ProcessStartInfo(Process.GetCurrentProcess().MainModule.FileName);
                        pInfo.Verb = "runas";

                        string key = Activation.Key;
                        pInfo.Arguments = "/activate " +
                                          Convert.ToBase64String(Encryption.EncryptStringToBytes(key, SecurityKeys.GenerateKey(key), SecurityKeys.GenerateIV(key)));

                        Process proc = Process.Start(pInfo);
                        proc.EnableRaisingEvents = true;
                        proc.Exited += proc_Exited;
                    }
                    catch (Win32Exception)
                    {
                        Thread deActivate = new Thread(() =>
                        {
                            try
                            {
                                Activation.Free(Activation.Key);
                            }
                            catch { }
                        });
                        deActivate.Start();

                        animation.Stop();
                        message.Text               = "Error: Activation could not be completed due to insufficient privileges.";
                        retryButton.Visibility     = Visibility.Visible;
                        closeButton.Visibility     = Visibility.Visible;
                        changeProductKey.IsEnabled = true;

                        DialogResult = false;
                    }
                }
                else
                {
                    Activation.Activate();
                    DialogResult = true;
                }
            }
            else
            {
                animation.Stop();
                message.Text               = "Error: " + msg;
                retryButton.Visibility     = Visibility.Visible;
                closeButton.Visibility     = Visibility.Visible;
                changeProductKey.IsEnabled = true;
            }
        }
Exemplo n.º 3
0
        public void Load()
        {
            string bios = RandomFunctions.GetBIOSSerialNumber();

            string _uKey = "UN_" + bios;

            _username = Encryption.DecryptStringFromBytes(SecurityKeys.StringToByteArray((string)Registry.GetValue(RegSaveBase, "DAT_B", null)), SecurityKeys.GenerateKey(_uKey), SecurityKeys.GenerateIV(_uKey));

            string _pKey = "PD_" + bios;

            _password = Encryption.DecryptStringFromBytes(SecurityKeys.StringToByteArray((string)Registry.GetValue(RegSaveBase, "DAT_A", null)), SecurityKeys.GenerateKey(_pKey), SecurityKeys.GenerateIV(_pKey));
        }
Exemplo n.º 4
0
        public static void Main()
        {
            try
            {
                string[] args = Environment.GetCommandLineArgs();

                if (args.Length >= 2)
                {
                    switch (args[1].ToLower())
                    {
                    case "/update":
                        string localPath = (new FileInfo(Process.GetCurrentProcess().MainModule.FileName)).DirectoryName;
                        string oldFile   = localPath + "\\UpdateManager.exe";
                        string tempDir   = Data.UpdatesWorkingDirectory;
                        string newFile   = tempDir + "\\~UpdateManager.exe";

                        try
                        {
                            File.Delete(oldFile);
                            File.Move(newFile, oldFile);
                        }
                        catch { }

                        if (Directory.GetFiles(tempDir, "*", SearchOption.AllDirectories).Length == 0)
                        {
                            Directory.Delete(tempDir, true);
                        }

                        return;

                    case "/nosingleinstance":
                        try { DisableProcessWindowsGhosting(); }
                        catch { }

                        if (Settings.FirstRun)
                        {
                            FirstRun();
                        }

                        args = null;

                        new App().Run();

                        return;

                    case "/setkey":
                        Activation.ActivationGracePeriodStart = DateTime.Now;
                        Activation.Key = args[2];
                        return;

                    case "/activate":
                        string keyHash = args[2];
                        string key     = Activation.Key;
                        if (Encryption.DecryptStringFromBytes(Convert.FromBase64String(keyHash),
                                                              SecurityKeys.GenerateKey(key), SecurityKeys.GenerateIV(key))
                            == key)
                        {
                            Activation.Activate();
                        }
                        return;

                    default:
                        break;
                    }
                }

                if (SingleInstance <App> .InitializeAsFirstInstance(AssemblyAttributeAccessors.AssemblyTitle + "_" + AssemblyAttributeAccessors.AssemblyVersion))
                {
                    try { DisableProcessWindowsGhosting(); }
                    catch { }

                    if (Settings.FirstRun)
                    {
                        FirstRun();
                    }

                    args = null;

                    new App().Run();

                    // Allow single instance code to perform cleanup operations
                    SingleInstance <App> .Cleanup();
                }
            }
            catch (Exception exc)
            {
                // Log the exception
                Log(exc);

                // Restart
                Process.Start(Process.GetCurrentProcess().MainModule.FileName, string.Join(" ", Environment.GetCommandLineArgs()));

                // Shutdown
                Environment.Exit(-1);
            }
        }