예제 #1
0
        void Search(DnSpyFile ownerModule, string nsOwner, TypeDef type)
        {
            var res = filter.GetFilterResult(type);

            if (res.FilterResult == FilterResult.Hidden)
            {
                return;
            }

            if (res.IsMatch && (IsMatch(type.FullName, type) || IsMatch(type.Name, type)))
            {
                onMatch(new SearchResult {
                    Language          = language,
                    Object            = type,
                    NameObject        = type,
                    TypeImageInfo     = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                    LocationObject    = new NamespaceSearchResult(nsOwner),
                    LocationImageInfo = GetImage("Namespace"),
                    DnSpyFile         = ownerModule,
                });
            }

            SearchMembers(ownerModule, type);

            foreach (var subType in type.GetTypes())
            {
                cancellationToken.ThrowIfCancellationRequested();
                Search(ownerModule, subType);
            }
        }
예제 #2
0
        void Search(DnSpyFile ownerModule, TypeDef type, MethodDef method)
        {
            var res = filter.GetFilterResult(method);

            if (res.FilterResult == FilterResult.Hidden)
            {
                return;
            }

            ImplMap im;

            if (res.IsMatch && (IsMatch(method.Name, method) || ((im = method.ImplMap) != null && (IsMatch(im.Name, im) || IsMatch(im.Module == null ? null : im.Module.Name, null)))))
            {
                onMatch(new SearchResult {
                    Language          = language,
                    Object            = method,
                    NameObject        = method,
                    TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                    LocationObject    = type,
                    LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                    DnSpyFile         = ownerModule,
                });
                return;
            }

            res = filter.GetFilterResultParamDefs(method);
            if (res.FilterResult != FilterResult.Hidden)
            {
                foreach (var pd in method.ParamDefs)
                {
                    res = filter.GetFilterResult(method, pd);
                    if (res.FilterResult == FilterResult.Hidden)
                    {
                        continue;
                    }
                    if (res.IsMatch && IsMatch(pd.Name, pd))
                    {
                        onMatch(new SearchResult {
                            Language          = language,
                            Object            = method,
                            NameObject        = method,
                            TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                            LocationObject    = type,
                            LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                            DnSpyFile         = ownerModule,
                        });
                        return;
                    }
                }
            }

            SearchBody(ownerModule, type, method);
        }
예제 #3
0
        void Search(LoadedAssembly ownerModule, TypeDef type, MethodDef method)
        {
            var res = filter.GetFilterResult(method);

            if (res.FilterResult == FilterResult.Hidden)
            {
                return;
            }

            if (res.IsMatch && IsMatch(method.Name, method))
            {
                onMatch(new SearchResult {
                    Language          = language,
                    Object            = method,
                    NameObject        = method,
                    TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                    LocationObject    = type,
                    LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                    LoadedAssembly    = ownerModule,
                });
                return;
            }

            res = filter.GetFilterResultParamDefs(method);
            if (res.FilterResult != FilterResult.Hidden)
            {
                foreach (var pd in method.ParamDefs)
                {
                    res = filter.GetFilterResult(method, pd);
                    if (res.FilterResult == FilterResult.Hidden)
                    {
                        continue;
                    }
                    if (res.IsMatch && IsMatch(pd.Name, pd))
                    {
                        onMatch(new SearchResult {
                            Language          = language,
                            Object            = method,
                            NameObject        = method,
                            TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                            LocationObject    = type,
                            LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                            LoadedAssembly    = ownerModule,
                        });
                        return;
                    }
                }
            }

            SearchBody(ownerModule, type, method);
        }
예제 #4
0
		void Search(LoadedAssembly ownerModule, TypeDef type, EventDef evt) {
			var res = filter.GetFilterResult(evt);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			if (res.IsMatch && IsMatch(evt.Name, evt)) {
				onMatch(new SearchResult {
					Language = language,
					Object = evt,
					NameObject = evt,
					TypeImageInfo = EventTreeNode.GetImageInfo(evt, BackgroundType.Search),
					LocationObject = type,
					LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
					LoadedAssembly = ownerModule,
				});
			}
		}
예제 #5
0
		void Search(LoadedAssembly ownerModule, TypeDef type, PropertyDef prop) {
			var res = filter.GetFilterResult(prop);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			if (res.IsMatch && IsMatch(prop.Name, prop)) {
				onMatch(new SearchResult {
					Language = language,
					Object = prop,
					NameObject = prop,
					TypeImageInfo = PropertyTreeNode.GetImageInfo(prop, BackgroundType.Search),
					LocationObject = type,
					LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
					LoadedAssembly = ownerModule,
				});
			}
		}
예제 #6
0
		void Search(LoadedAssembly ownerModule, TypeDef type, FieldDef field) {
			var res = filter.GetFilterResult(field);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			ImplMap im;
			if (res.IsMatch && (IsMatch(field.Name, field) || ((im = field.ImplMap) != null && (IsMatch(im.Name, im) || IsMatch(im.Module == null ? null : im.Module.Name, null))))) {
				onMatch(new SearchResult {
					Language = language,
					Object = field,
					NameObject = field,
					TypeImageInfo = FieldTreeNode.GetImageInfo(field, BackgroundType.Search),
					LocationObject = type,
					LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
					LoadedAssembly = ownerModule,
				});
			}
		}
예제 #7
0
		void Search(LoadedAssembly ownerModule, TypeDef type) {
			var res = filter.GetFilterResult(type);
			if (res.FilterResult == FilterResult.Hidden)
				return;

			if (res.IsMatch && (IsMatch(type.FullName, type) || IsMatch(type.Name, type))) {
				onMatch(new SearchResult {
					Language = language,
					Object = type,
					NameObject = type,
					TypeImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
					LocationObject = type.DeclaringType,
					LocationImageInfo = TypeTreeNode.GetImageInfo(type.DeclaringType, BackgroundType.Search),
					LoadedAssembly = ownerModule,
				});
			}

			SearchMembers(ownerModule, type);
		}
예제 #8
0
        void Search(LoadedAssembly ownerModule, TypeDef type, FieldDef field)
        {
            var res = filter.GetFilterResult(field);

            if (res.FilterResult == FilterResult.Hidden)
            {
                return;
            }

            if (res.IsMatch && IsMatch(field.Name, field))
            {
                onMatch(new SearchResult {
                    Language          = language,
                    Object            = field,
                    NameObject        = field,
                    TypeImageInfo     = FieldTreeNode.GetImageInfo(field, BackgroundType.Search),
                    LocationObject    = type,
                    LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                    LoadedAssembly    = ownerModule,
                });
            }
        }
예제 #9
0
        void SearchBody(DnSpyFile ownerModule, TypeDef type, MethodDef method, out bool loadedBody)
        {
            loadedBody = false;
            CilBody body;

            var res = filter.GetFilterResultLocals(method);

            if (res.FilterResult != FilterResult.Hidden)
            {
                body = method.Body;
                if (body == null)
                {
                    return;                     // Return immediately. All code here depends on a non-null body
                }
                loadedBody = true;

                foreach (var local in body.Variables)
                {
                    res = filter.GetFilterResult(method, local);
                    if (res.FilterResult == FilterResult.Hidden)
                    {
                        continue;
                    }
                    if (res.IsMatch && IsMatch(local.Name, local))
                    {
                        onMatch(new SearchResult {
                            Language          = language,
                            Object            = method,
                            NameObject        = method,
                            TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                            LocationObject    = type,
                            LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                            DnSpyFile         = ownerModule,
                        });
                        return;
                    }
                }
            }

            res = filter.GetFilterResultBody(method);
            if (res.FilterResult == FilterResult.Hidden)
            {
                return;
            }
            if (!res.IsMatch)
            {
                return;
            }

            body = method.Body;
            if (body == null)
            {
                return;                 // Return immediately. All code here depends on a non-null body
            }
            loadedBody = true;
            foreach (var instr in body.Instructions)
            {
                object operand;
                // Only check numbers and strings. Don't pass in any type of operand to IsMatch()
                switch (instr.OpCode.Code)
                {
                case Code.Ldc_I4_M1: operand = -1; break;

                case Code.Ldc_I4_0: operand = 0; break;

                case Code.Ldc_I4_1: operand = 1; break;

                case Code.Ldc_I4_2: operand = 2; break;

                case Code.Ldc_I4_3: operand = 3; break;

                case Code.Ldc_I4_4: operand = 4; break;

                case Code.Ldc_I4_5: operand = 5; break;

                case Code.Ldc_I4_6: operand = 6; break;

                case Code.Ldc_I4_7: operand = 7; break;

                case Code.Ldc_I4_8: operand = 8; break;

                case Code.Ldc_I4:
                case Code.Ldc_I4_S:
                case Code.Ldc_R4:
                case Code.Ldc_R8:
                case Code.Ldstr: operand = instr.Operand; break;

                default: operand = null; break;
                }
                if (operand != null && IsMatch(null, operand))
                {
                    onMatch(new SearchResult {
                        Language          = language,
                        Object            = method,
                        NameObject        = method,
                        TypeImageInfo     = MethodTreeNode.GetImageInfo(method, BackgroundType.Search),
                        LocationObject    = type,
                        LocationImageInfo = TypeTreeNode.GetImageInfo(type, BackgroundType.Search),
                        DnSpyFile         = ownerModule,
                    });
                    break;
                }
            }
        }