コード例 #1
0
        public static MethodDefinition GetMethodDefinitionFromStackFrameDepth(uint depth, Pointer stackFrame)
        {
            if (stackFrame.IsNull)
            {
                stackFrame = Intrinsic.GetStackFrame();
            }

            stackFrame = GetStackFrame(depth + 0, stackFrame);

            var address = GetReturnAddressFromStackFrame(stackFrame);

            return(Runtime.Internal.GetMethodDefinition(address));
        }
コード例 #2
0
        public static Pointer GetStackFrame(uint depth, Pointer stackFrame)
        {
            if (stackFrame.IsNull)
            {
                stackFrame = Intrinsic.GetStackFrame();
            }

            while (depth > 0)
            {
                depth--;

                stackFrame = GetPreviousStackFrame(stackFrame);

                if (stackFrame.IsNull)
                {
                    return(Pointer.Zero);
                }
            }

            return(stackFrame);
        }
コード例 #3
0
        public static SimpleStackTraceEntry GetStackTraceEntry(uint depth, Pointer stackFrame, Pointer eip)
        {
            var entry = new SimpleStackTraceEntry();

            Pointer address;

            if (depth == 0 && !eip.IsNull)
            {
                address = eip;
            }
            else
            {
                if (stackFrame.IsNull)
                {
                    stackFrame = Intrinsic.GetStackFrame();
                }

                if (!eip.IsNull)
                {
                    depth--;
                }

                stackFrame = GetStackFrame(depth, stackFrame);

                address = GetReturnAddressFromStackFrame(stackFrame);
            }

            var methodDef = Runtime.Internal.GetMethodDefinition(address);

            if (methodDef.IsNull)
            {
                return(entry);
            }

            entry.MethodDefinition = methodDef;
            entry.Offset           = (uint)methodDef.Method.GetOffset(address);
            return(entry);
        }