예제 #1
0
    private void Recovery()
    {
        RecoveryData data = mRePlayer.InsertRecovery();

        transform.position  = data.Position;
        transform.rotation  = data.Rotation;
        mRigidbody.velocity = Vector3.zero;
    }
예제 #2
0
파일: Form1.cs 프로젝트: kagada/Arianrhod
        private void RegisterForRecovery()
        {
            // Don't pass any state. We'll use our static variable "CurrentFile" to determine
            // the current state of the application.
            // Since this registration is being done on application startup, we don't have a state currently.
            // In some cases it might make sense to pass this initial state.
            // Another approach: When doing "auto-save", register for recovery everytime, and pass
            // the current state at that time.
            RecoveryData     data     = new RecoveryData(new RecoveryCallback(RecoveryProcedure), null);
            RecoverySettings settings = new RecoverySettings(data, 0);

            ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(settings);

            Debug.WriteLine("ARR: Registered for recovery");
        }
예제 #3
0
    private RecoveryData DrawRecoveryData(RecoveryData entry)
    {
        entry.type = EditorHelper.EnumPopup("Recovery Type", entry.type);

        switch (entry.type)
        {
        case Constants.AbilityRecoveryType.Cooldown:
            entry.cooldown = EditorHelper.FloatField("Cooldown", entry.cooldown);
            break;

        case Constants.AbilityRecoveryType.Kills:
            entry.kills = EditorGUILayout.IntField("Kills", entry.kills);
            break;
        }

        return(entry);
    }
예제 #4
0
    public static AbilityRecovery CreateRecovery(Ability parent, RecoveryData data)
    {
        AbilityRecovery result = null;

        switch (data.type)
        {
        case Constants.AbilityRecoveryType.Cooldown:
            result = new RecoveryCooldown(data.cooldown, parent, parent.RecoveryManager);
            break;

        default:

            break;
        }


        return(result);
    }
예제 #5
0
        // This method is invoked by WER.
        private static int RecoveryProcedure(RecoveryData parameter)
        {
            Console.WriteLine("Recovery in progress for {0}",
                              parameter.CurrentUser);

            // Do recovery work here.
            for (int i = 0; i < 4; i++)
            {
                // Signal to WER that the recovery
                // is still in progress.
                PingSystem();
                // Simulate long running recovery.
                System.Threading.Thread.Sleep(3000);
            }
            // Indicate that recovery work is done.
            Console.WriteLine("Application shutting down...");
            ArrManager.ApplicationRecoveryFinished(true);
            return(0);
        }
예제 #6
0
        public Form1()
        {
            InitializeComponent();

            recoveryFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RecoveryData.xml");
            ApplicationRestartRecoveryManager.RegisterForApplicationRestart(
                new RestartSettings("/restart", RestartRestrictions.NotOnReboot | RestartRestrictions.NotOnPatch));

            var data     = new RecoveryData(RecoveryProcedure, null);
            var settings = new RecoverySettings(data, 0);

            ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(settings);


            if (Environment.GetCommandLineArgs().Length > 1 && Environment.GetCommandLineArgs()[1] == "/restart")
            {
                RecoverLastSession(Environment.GetCommandLineArgs()[1]);
            }
        }
예제 #7
0
        public MainWindow()
        {
            InitializeComponent();

            //Register next Restart Recovery key (It ensures that application if application closes other than OnPatch/ OnReboot / NormalEnd
            // it pass the /recovery argument.
            ApplicationRestartRecoveryManager.RegisterForApplicationRestart(
                new RestartSettings("/recover", RestartRestrictions.NotOnPatch | RestartRestrictions.NotOnReboot));

            //Register Recovery data.
            var data   = new RecoveryData(RecoverDataCallback, null);
            var seting = new RecoverySettings(data, 0);

            ApplicationRestartRecoveryManager.RegisterForApplicationRecovery(seting);

            // Lets Check wheher recovery needed
            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1 && args[1].Equals("/recovery", StringComparison.InvariantCultureIgnoreCase))
            {
                StartRecovery("/recovery");
            }
            SaveButton.IsEnabled = false;
        }
예제 #8
0
 internal static extern uint RegisterApplicationRecoveryCallback(
     RecoveryCallback recoveryCallback,
     RecoveryData parameter,
     uint pingInterval,
     uint flags); // Unused.
예제 #9
0
 internal static extern uint GetApplicationRecoveryCallback(
     IntPtr processHandle,
     out RecoveryCallback recoveryCallback,
     out RecoveryData parameter,
     out uint pingInterval,
     out uint flags);
예제 #10
0
        public RESTStatus ComputerLogin(SQLLib sql, RecoveryLogon logon, NetworkConnectionInfo ni, string IPAddress)
        {
            RD = new RecoveryData();

            if (Fox_LicenseGenerator.SDCLicensing.ValidLicense == false)
            {
                RD.Worked = false;
                return(RESTStatus.Fail);
            }

            if (Fox_LicenseGenerator.SDCLicensing.TestExpiry() == false)
            {
                RD.Worked = false;
                return(RESTStatus.Fail);
            }

            if (string.IsNullOrWhiteSpace(logon.UCID) == true)
            {
                RD.Worked = false;
                return(RESTStatus.Fail);
            }

            if (Settings.Default.UseContract == true)
            {
                if (string.IsNullOrWhiteSpace(logon.ContractID) == true || string.IsNullOrWhiteSpace(logon.ContractPassword) == true)
                {
                    RD.Worked = false;
                    return(RESTStatus.Fail);
                }
            }

            string newID = NetworkConnection.NewSession();

            ni = NetworkConnection.GetSession(newID);
            if (NetworkConnectionProcessor.InitNi(ni) == false)
            {
                NetworkConnection.DeleteSession(newID);
                RD.Worked = false;
                return(RESTStatus.ServerError);
            }

            sql = ni.sql;

            if (Settings.Default.UseContract == true)
            {
                if (Convert.ToInt32(sql.ExecSQLScalar("SELECT Count(*) FROM Contracts WHERE ContractID=@id AND ContractPassword=@pw AND Disabled=0",
                                                      new SQLParam("@id", logon.ContractID),
                                                      new SQLParam("@pw", logon.ContractPassword))) == 0)
                {
                    NetworkConnection.DeleteSession(newID);
                    RD.Worked = false;
                    return(RESTStatus.Fail);
                }

                if (Convert.ToInt32(sql.ExecSQLScalar("SELECT COUNT(*) FROM ComputerAccounts WHERE ContractID=@id AND UCID=@u",
                                                      new SQLParam("@id", logon.ContractID),
                                                      new SQLParam("@u", logon.UCID))) == 0)
                {
                    NetworkConnection.DeleteSession(newID);
                    RD.Worked = false;
                    return(RESTStatus.Fail);
                }
            }

            if (Convert.ToInt32(sql.ExecSQLScalar("SELECT COUNT(*) FROM ComputerAccounts WHERE UCID=@u",
                                                  new SQLParam("@u", logon.UCID))) == 0)
            {
                NetworkConnection.DeleteSession(newID);
                RD.Worked = false;
                return(RESTStatus.Fail);
            }

            SqlDataReader dr = sql.ExecSQLReader("SELECT * FROM ComputerAccounts WHERE UCID=@u",
                                                 new SQLParam("@u", logon.UCID));

            dr.Read();

            string Check = Convert.ToString(dr["CPUName"]).Trim();

            Check += Convert.ToString(dr["ComputerModel"]).Trim();
            Check += Convert.ToString(dr["BIOS"]).Trim();

            string MD5 = MD5Utilities.CalcMD5(Check);

            if (MD5.ToLower() != logon.MoreMachineHash.ToLower())
            {
                dr.Close();
                NetworkConnection.DeleteSession(newID);
                RD.Worked = false;
                return(RESTStatus.Fail);
            }

            RD.MachineID       = Convert.ToString(dr["MachineID"]);
            RD.MachinePassword = Convert.ToString(dr["Password"]);
            RD.Worked          = true;

            dr.Close();

            NetworkConnection.DeleteSession(newID);
            return(RESTStatus.Success);
        }
예제 #11
0
		/// <summary>
		/// Initializes a new instance of the <b>RecoverySettings</b> class.
		/// </summary>
		/// <param name="data">A recovery data object that contains the callback method (invoked by the system
		/// before Windows Error Reporting terminates the application) and an optional state object.</param>
		/// <param name="interval">The time interval within which the 
		/// callback method must invoke <see cref="ApplicationRestartRecoveryManager.ApplicationRecoveryInProgress"/> to 
		/// prevent WER from terminating the application.</param>
		/// <seealso cref="ApplicationRestartRecoveryManager"/>
		public RecoverySettings(RecoveryData data, uint interval) {
			this.recoveryData = data;
			this.pingInterval = interval;
		}
예제 #12
0
        public static void SMain()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#endif
            FoxEventLog.RegisterEventLog();

            if (UsePipeAction == false && UseScreenAction == false && UseDNSAutoConfig == false && UseLoginRecovery == false) //Pipe Actions can also be run in user-space ...
            {
                if (IsSystemUser() != true)
                {
#if !DEBUG || DEBUGSERVICE
                    service.Stop();
#endif
                    return;
                }
            }

            if (LoadDLL() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

#if !DEBUG
            if (TestIntegrity(null) == false)
            {
                FoxEventLog.WriteEventLog("Integrity check failed!", EventLogEntryType.Error);
                service.Stop();
                return;
            }
#endif
            if (UseDNSAutoConfig == true)
            {
                try
                {
                    List <List <string> > Query = CPP.DNSQueryTXT("sdc-contract.my-vulpes-config.lu");

                    if (Query == null)
                    {
                        return;
                    }

                    string ContractID       = null;
                    string ContractPassword = null;
                    string UseOnPrem        = null;
                    string OnPremURL        = null;

                    foreach (List <string> Q in Query)
                    {
                        if (Q == null)
                        {
                            continue;
                        }

                        foreach (string QR in Q)
                        {
                            if (string.IsNullOrWhiteSpace(QR) == true)
                            {
                                continue;
                            }
                            if (QR.ToLower().StartsWith("contractid=") == true)
                            {
                                ContractID = QR.Substring(11).Trim();
                            }
                            if (QR.ToLower().StartsWith("contractpassword="******"useonprem=") == true)
                            {
                                UseOnPrem = QR.Substring(10).Trim();
                            }
                            if (QR.ToLower().StartsWith("onpremurl=") == true)
                            {
                                OnPremURL = QR.Substring(10).Trim();
                            }
                        }
                    }

                    using (RegistryKey k = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Fox\\SDC"))
                    {
                        if (string.IsNullOrWhiteSpace(ContractID) == false && string.IsNullOrWhiteSpace(ContractPassword) == false)
                        {
                            k.SetValue("ContractID", ContractID, RegistryValueKind.String);
                            k.SetValue("ContractPassword", ContractPassword, RegistryValueKind.String);
                        }

                        int UseOnPremInt;
                        if (int.TryParse(UseOnPrem, out UseOnPremInt) == true)
                        {
                            if (UseOnPremInt == 1 && string.IsNullOrWhiteSpace(OnPremURL) == false)
                            {
                                k.SetValue("UseOnPremServer", 1, RegistryValueKind.DWord);
                                k.SetValue("Server", OnPremURL, RegistryValueKind.String);
                            }
                            else
                            {
                                k.SetValue("UseOnPremServer", 0, RegistryValueKind.DWord);
                            }
                        }
                        else
                        {
                            k.SetValue("UseOnPremServer", 0, RegistryValueKind.DWord);
                        }
                    }
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                }
                return;
            }

            if (UseLoginRecovery == true)
            {
                if (SystemInfos.CollectSystemInfo() != 0)
                {
                    return;
                }

#if !DEBUG
                if (SystemInfos.SysInfo.RunningInWindowsPE == false || SystemInfos.SysInfo.RunningInWindowsPE == null)
                {
                    return;
                }
#endif

                RecoveryLogon reclogon = new RecoveryLogon();
                reclogon.UCID             = SystemInfos.SysInfo.UCID;
                reclogon.ContractID       = SystemInfos.ContractID;
                reclogon.ContractPassword = SystemInfos.ContractPassword;

                string Check = SystemInfos.SysInfo.CPUName.Trim();
                Check += SystemInfos.SysInfo.ComputerModel == "" ? "N/A" : SystemInfos.SysInfo.ComputerModel.Trim();
                Check += SystemInfos.SysInfo.BIOS == "" ? "N/A" : SystemInfos.SysInfo.BIOS.Trim();

                reclogon.MoreMachineHash = MD5Utilities.CalcMD5(Check);
                Network net = Utilities.NoConnectNetwork();

                RecoveryData rd = net.GetRecoveryLogon(reclogon);
                if (rd == null)
                {
                    return;
                }
                if (rd.Worked == false)
                {
                    return;
                }

                string Registry = "Windows Registry Editor Version 5.00\r\n\r\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Fox\\SDC]\r\n\"ID\"=\"" + rd.MachineID + "\"\r\n\"PassID\"=\"" + rd.MachinePassword + "\"";
                try
                {
                    File.WriteAllText(Environment.ExpandEnvironmentVariables("%SYSTEMROOT%\\Fox SDC MachinePW.reg"), Registry, Encoding.Unicode);
                }
                catch
                {
                }
                return;
            }

            if (UsePipeAction == false && UseScreenAction == false)
            {
                using (RegistryKey installer = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + VulpesBranding.MSIGUID, false))
                {
                    if (installer == null)
                    {
                        FoxEventLog.WriteEventLog("Missing installer key in HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + VulpesBranding.MSIGUID + ". This can lead to erratic behavoir of the program!", EventLogEntryType.Warning);
                    }
                }

                if (CPP.SetToken() == false)
                {
                    FoxEventLog.WriteEventLog("Cannot setup token - 0x" + Marshal.GetLastWin32Error().ToString("X") + " - " + new Win32Exception(Marshal.GetLastWin32Error()).Message, System.Diagnostics.EventLogEntryType.Error);
                    return;
                }
            }

            if (UsePipeAction == true)
            {
                try
                {
                    Process2ProcessCommClient.RunPipeClient();
                }
                catch (Exception ee)
                {
                    FoxEventLog.WriteEventLog("Pipe SEH " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                }
                return;
            }

            if (UseScreenAction == true)
            {
                try
                {
                    if (SystemInfos.CollectSystemInfo() != 0)
                    {
                        return;
                    }
                    MainScreenSystemClient.RunPipeClient();
                }
                catch (Exception ee)
                {
                    FoxEventLog.WriteEventLog("Screen Pipe SEH " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                }
                return;
            }

            if (SystemInfos.CollectSystemInfo() != 0)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

            RegistryData.InstallPath = AppPath;

            if (ApplicationCertificate.LoadCertificate() == false)
            {
                FoxEventLog.WriteEventLog("Cannot load certificate", System.Diagnostics.EventLogEntryType.Error);
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

            if (FilesystemData.LoadCertificates() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }
            if (FilesystemData.LoadPolicies() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }
            FilesystemData.LoadLocalPackageData();
            FilesystemData.LoadLocalPackages();
            FilesystemData.LoadUserPackageData();
            FilesystemData.LoadEventLogList();

            SyncPolicy.ApplyPolicy(SyncPolicy.ApplyPolicyFunction.ApplySystem);

            PipeCommunicationSRV.StartPipeSrv();

            try
            {
                string p = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (p.EndsWith("\\") == false)
                {
                    p += "\\";
                }

                using (RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
                {
                    reg.SetValue("FoxSDCAgent", p + "FoxSDC_Agent_UI.exe", RegistryValueKind.String);
                    reg.SetValue("FoxSDCAgentApply", p + "FoxSDC_ApplyUserSettings.exe", RegistryValueKind.String);
                    reg.Close();
                }
            }
            catch
            {
            }

            try
            {
                using (RegistryKey reg = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true))
                {
                    object o      = reg.GetValue("SoftwareSASGeneration", null);
                    int    rvalue = 0;
                    if (o != null)
                    {
                        rvalue = Convert.ToInt32(o);
                    }

                    if (rvalue != 1 && rvalue != 3)
                    {
                        reg.SetValue("SoftwareSASGeneration", 1);
                    }
                    reg.Close();
                }
            }
            catch
            {
            }

            Threads.StartAllThreads();
        }