public static unsafe IEnumerable <XrefInstance> XrefScan(MethodBase methodBase)
        {
            var fieldValue = UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(methodBase)?.GetValue(null);

            if (fieldValue == null)
            {
                return(Enumerable.Empty <XrefInstance>());
            }

            var cachedAttribute = methodBase.GetCustomAttribute <CachedScanResultsAttribute>(false);

            if (cachedAttribute == null)
            {
                XrefScanMetadataRuntimeUtil.CallMetadataInitForMethod(methodBase);

                return(XrefScanImpl(DecoderForAddress(*(IntPtr *)(IntPtr)fieldValue)));
            }

            if (cachedAttribute.XrefRangeStart == cachedAttribute.XrefRangeEnd)
            {
                return(Enumerable.Empty <XrefInstance>());
            }

            XrefScanMethodDb.CallMetadataInitForMethod(cachedAttribute);

            return(XrefScanMethodDb.CachedXrefScan(cachedAttribute).Where(it => it.Type == XrefType.Method || XrefGlobalClassFilter(it.Pointer)));
        }
Beispiel #2
0
        public MethodBase TryResolve()
        {
            if (Type != XrefType.Method)
            {
                throw new InvalidOperationException("Can't resolve non-method xrefs");
            }

            return(XrefScanMethodDb.TryResolvePointer(Pointer));
        }
        public static IEnumerable <XrefInstance> UsedBy(MethodBase methodBase)
        {
            var cachedAttribute = methodBase.GetCustomAttribute <CachedScanResultsAttribute>(false);

            if (cachedAttribute == null || cachedAttribute.RefRangeStart == cachedAttribute.RefRangeEnd)
            {
                return(Enumerable.Empty <XrefInstance>());
            }

            return(XrefScanMethodDb.ListUsers(cachedAttribute));
        }