コード例 #1
0
        /// <summary>
        /// Processes a signal
        /// </summary>
        /// <param name="action">The action</param>
        /// <returns>The signal context</returns>
        public ISignalContext ProcessSignal(SignalAction action)
        {
            X86SignalContext context = new X86SignalContext();

            // Push arguments
            *--context.Stack = 0;      // Context (unused)
            *--context.Stack = 0x7331; // TODO: siginfo
            *--context.Stack = action.SignalNumber;

            // Return address of signal handling method
            *--context.Stack = (int)Util.MethodToPtr(SignalAction.ReturnFromSignal);

            // Backup regs so we can restore later
            Memory.Memcpy(context.Sysregs, m_sysRegs, sizeof(RegsDirect));

            // Modify regs to return to
            m_sysRegs->ESP = (int)context.Stack;
            m_sysRegs->EIP = (int)action.Sigaction.Handler;
            m_sysRegs->EAX = 0;
            m_sysRegs->EBX = 0;
            m_sysRegs->ECX = 0;
            m_sysRegs->EDX = 0;
            m_sysRegs->ESI = 0;
            m_sysRegs->EDI = 0;

            return(context);
        }
コード例 #2
0
        /// <summary>
        /// Returns from signal (restores original context)
        /// </summary>
        /// <param name="oldContext">Old context</param>
        public void ReturnFromSignal(ISignalContext oldContext)
        {
            X86SignalContext old = (X86SignalContext)oldContext;

            Memory.Memcpy(m_sysRegs, old.Sysregs, sizeof(RegsDirect));
        }