Tpm2Lib.Tbs.StateSaveAndReload C# (CSharp) Méthode

StateSaveAndReload() private méthode

TPM Debug support. Cycle the TPM through (a) SaveContext all loaded contexts, (b) StateSave(), (c) powerOff, (d) powerOn (e) Startup(SU_State) or Startup(S_CLEAR). Then needed objects and sessions will be paged back in as needed. This command is NOT thread safe. This command has side-effects on the startup counter and will likely result in clock discontinuities.
private StateSaveAndReload ( bool startupState, bool doPowerCycle ) : void
startupState bool
doPowerCycle bool
Résultat void
        private void StateSaveAndReload(bool startupState, bool doPowerCycle)
        {
            CheckConsistency();
            ContextSaveEverything();
            CheckConsistency();
            // Record TPM state so that we can check it's the same through shutdown.
            // The exception is entities that are marked volatileLoad which are destroyed on S4.
            TpmHandle[] startHandles = GetAllLoadedEntities(Tpm);

            Tpm.Shutdown(Su.State);
            // Optionally cycle the power (if the power is not cycled the TPM should be able to carry on as if nothing had happened.
            string stateTransition = "none";

            if (doPowerCycle)
            {
                TpmDevice.PowerCycle();
                // Re-init through simulated S3 and S4 alternately
                // ReSharper disable once RedundantAssignment
                stateTransition = "";
                if (startupState)
                {
                    stateTransition = "S3";
                    Tpm.Startup(Su.State);
                }
                else
                {
                    stateTransition = "S4";
                    Tpm.Startup(Su.Clear);
                }
            }

            // Check everything is the same
            TpmHandle[] endHandles = GetAllLoadedEntities(Tpm);
            bool match = true;
            if (startHandles.Length == endHandles.Length)
            {
                for (int j = 0; j < startHandles.Length; j++)
                {
                    if (startHandles[j].handle != endHandles[j].handle)
                    {
                        match = false;
                    }
                }
            }
            else
            {
                match = false;
            }
            if (!match)
            {
                string message = "Handle set did not survive " + stateTransition;
                throw new Exception(message);
            }
        }