Exemple #1
0
        public void Seal()
        {
            using (this.EnterExit())
            {
                // if libco is used, the jmp_buf for the main cothread can have stack stuff in it.
                // this isn't a problem, since we only savestate when the core is not running, and
                // the next time it's run, that buf will be overridden again.
                // but it breaks xor state verification, so when we seal, nuke it.

                // this could be the responsibility of something else other than the PeRunner; I am not sure yet...
                IImportResolver libco;
                if (_exports.TryGetValue("libco.so", out libco))
                {
                    Console.WriteLine("Calling co_clean()...");
                    CallingConventionAdapters.Waterbox.GetDelegateForFunctionPointer <Action>(libco.GetProcAddrOrThrow("co_clean"))();
                }

                _sealedheap.Seal();
                foreach (var h in _heaps)
                {
                    if (h != _invisibleheap && h != _sealedheap)                     // TODO: if we have more non-savestated heaps, refine this hack
                    {
                        h.Memory.SaveXorSnapshot();
                    }
                }
                foreach (var pe in _modules)
                {
                    pe.SealImportsAndTakeXorSnapshot();
                }
                if (_mmapheap != null)
                {
                    _mmapheap.Memory.SaveXorSnapshot();
                }
            }
        }
Exemple #2
0
        public void Seal()
        {
            using (this.EnterExit())
            {
                // if libco is used, the jmp_buf for the main cothread can have stack stuff in it.
                // this isn't a problem, since we only savestate when the core is not running, and
                // the next time it's run, that buf will be overridden again.
                // but it breaks xor state verification, so when we seal, nuke it.

                // this could be the responsibility of something else other than the PeRunner; I am not sure yet...

                // TODO: MAKE SURE THIS STILL WORKS
                IntPtr co_clean;
                if ((co_clean = _module.GetProcAddrOrZero("co_clean")) != IntPtr.Zero)
                {
                    Console.WriteLine("Calling co_clean()...");
                    CallingConventionAdapters.Waterbox.GetDelegateForFunctionPointer <Action>(co_clean)();
                }

                _sealedheap.Seal();
                foreach (var h in _heaps)
                {
                    if (h != _invisibleheap && h != _sealedheap)                     // TODO: if we have more non-savestated heaps, refine this hack
                    {
                        h.Memory.SaveXorSnapshot();
                    }
                }
                _module.SealImportsAndTakeXorSnapshot();
                _mmapheap?.Memory.SaveXorSnapshot();
            }
        }
Exemple #3
0
 public void Seal()
 {
     Enter();
     try
     {
         _sealedheap.Seal();
     }
     finally
     {
         Exit();
     }
 }