Пример #1
0
        private static IntPtr Create()
        {
            IntPtr  precodePtr = Precode.DetectPrecode.GetPrecodePtr();
            Precode precode    = Precode.Create(precodePtr);

            return(precode.TargetPtr);
        }
Пример #2
0
        private static IntPtr GoThroughPrecode(Precode precode)
        {
            if (precode is StubPrecode || precode is RemotingPrecode)
            {
                if (precode.TargetPtr == ThePreStub.Address)
                {
                    return(IntPtr.Zero);
                }

                var addr = Utils.FollowRelJmp(precode.JmpToTargetPtr);
                if (addr == ThePreStub.Address)
                {
                    return(IntPtr.Zero);
                }
                else if (FixupPrecode.IsFixupPrecode(addr))
                {
                    return(GoThroughFixupPrecode(FixupPrecode.Create(addr)));
                }

                return(addr);
            }

            if (precode is FixupPrecode)
            {
                return(GoThroughFixupPrecode((FixupPrecode)precode));
            }

            throw new NotSupportedException("Unsupported precode type.");
        }
Пример #3
0
        private IntPtr GetCompiledCodeAddressWithPrecode()
        {
            var precode = GetPrecode();
            var result  = GoThroughPrecode(precode);

            if (result != IntPtr.Zero)
            {
                Debug.Assert(result != ThePreStub.Address);
                Debug.Assert(result != FixupPrecode.PrecodeFixupThunk);
                Debug.Assert(!Precode.HasPrecode(result));
            }

            return(result);
        }
Пример #4
0
        public Precode GetPrecode()
        {
            if (!HasPrecode)
            {
                throw new InvalidOperationException("Method does not have a precode.");
            }

            if (_precode == null)
            {
                _precode = Precode.Create(Address);
            }

            return(_precode);
        }