Пример #1
0
		/// <summary>
		///     Adds plugins in the assembly to the protection list.
		/// </summary>
		/// <param name="context">The working context.</param>
		/// <param name="protections">The working list of protections.</param>
		/// <param name="packers">The working list of packers.</param>
		/// <param name="components">The working list of components.</param>
		/// <param name="asm">The assembly.</param>
		protected static void AddPlugins(
			ConfuserContext context, IList<Protection> protections, IList<Packer> packers,
			IList<ConfuserComponent> components, Assembly asm) {
			foreach(var module in asm.GetLoadedModules())
				foreach (var i in module.GetTypes()) {
					if (i.IsAbstract || !HasAccessibleDefConstructor(i))
						continue;

					if (typeof(Protection).IsAssignableFrom(i)) {
						try {
							protections.Add((Protection)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate protection '" + i.Name + "'.", ex);
						}
					}
					else if (typeof(Packer).IsAssignableFrom(i)) {
						try {
							packers.Add((Packer)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate packer '" + i.Name + "'.", ex);
						}
					}
					else if (typeof(ConfuserComponent).IsAssignableFrom(i)) {
						try {
							components.Add((ConfuserComponent)Activator.CreateInstance(i));
						}
						catch (Exception ex) {
							context.Logger.ErrorException("Failed to instantiate component '" + i.Name + "'.", ex);
						}
					}
				}
			context.CheckCancellation();
		}
Пример #2
0
        private void ShowAssembly(Assembly assembly)
        {
            this.txtResult.AppendText("\r\nAssembly FullName:" + assembly.FullName);
            this.txtResult.AppendText("\r\nAssembly Location:" + assembly.Location);
            this.txtResult.AppendText("\r\nAssembly CodeBase:" + assembly.CodeBase);
            this.txtResult.AppendText("\r\nAssembly EscapedCodeBase:" + assembly.EscapedCodeBase);
            //this.txtResult.AppendText("\r\nAssembly EntryPoint:" + assembly.EntryPoint.DeclaringType);
            Module[] modules = assembly.GetLoadedModules();
            foreach (Module module in modules)
            {
                ShowModule(module);
            }

            this.txtResult.AppendText("\r\nAssembly GlobalAssemblyCache:" + assembly.GlobalAssemblyCache);
            this.txtResult.AppendText("\r\nAssembly ImageRuntimeVersion:" + assembly.ImageRuntimeVersion);
            this.txtResult.AppendText("\r\nAssembly ReflectionOnly:" + assembly.ReflectionOnly);
            //this.txtResult.AppendText("\r\nAssembly Location:" + assembly.);
            //this.txtResult.AppendText("\r\nAssembly Location:" + assembly.Location);
        }
Пример #3
0
        public static void ShowAssembly(Assembly assembly)
        {
            Console.WriteLine("Assembly FullName:" + assembly.FullName);
                Console.WriteLine("Assembly Location:" + assembly.Location);
                Console.WriteLine("Assembly CodeBase:"+assembly.CodeBase);
                Console.WriteLine("Assembly EscapedCodeBase:" + assembly.EscapedCodeBase);
                //Console.WriteLine("Assembly EntryPoint:" + assembly.EntryPoint.DeclaringType);
                Module[] modules = assembly.GetLoadedModules();
                foreach(Module module in modules)
                {
                   ShowModule(module);
                }

                Console.WriteLine("Assembly GlobalAssemblyCache:" + assembly.GlobalAssemblyCache);
                Console.WriteLine("Assembly ImageRuntimeVersion:" + assembly.ImageRuntimeVersion);
                Console.WriteLine("Assembly ReflectionOnly:" + assembly.ReflectionOnly);
                //Console.WriteLine("Assembly Location:" + assembly.);
                //Console.WriteLine("Assembly Location:" + assembly.Location);
        }