/// <summary> /// Loads the assembly and marks the project. /// </summary> /// <param name="proj">The project.</param> /// <param name="context">The working context.</param> /// <returns><see cref="MarkerResult" /> storing the marked modules and packer information.</returns> protected internal virtual MarkerResult MarkProject(DotProtectProject proj, DotProtectContext context) { Packer packer = null; Dictionary <string, string> packerParams = null; if (proj.Packer != null) { if (!packers.ContainsKey(proj.Packer.Id)) { context.Logger.ErrorFormat("Cannot find packer with ID '{0}'.", proj.Packer.Id); throw new DotProtectception(null); } if (proj.Debug) { context.Logger.Warn("Generated Debug symbols might not be usable with packers!"); } packer = packers[proj.Packer.Id]; packerParams = new Dictionary <string, string>(proj.Packer, StringComparer.OrdinalIgnoreCase); } var modules = new List <Tuple <ProjectModule, ModuleDefMD> >(); var extModules = new List <byte[]>(); foreach (ProjectModule module in proj) { if (module.IsExternal) { extModules.Add(module.LoadRaw(proj.BaseDirectory)); continue; } ModuleDefMD modDef = module.Resolve(proj.BaseDirectory, context.Resolver.DefaultModuleContext); context.CheckCancellation(); if (proj.Debug) { modDef.LoadPdb(); } context.Resolver.AddToCache(modDef); modules.Add(Tuple.Create(module, modDef)); } foreach (var module in modules) { context.Logger.InfoFormat("Loading '{0}'...", module.Item1.Path); Rules rules = ParseRules(proj, module.Item1, context); context.Annotations.Set(module.Item2, SNKey, LoadSNKey(context, module.Item1.SNKeyPath == null ? null : Path.Combine(proj.BaseDirectory, module.Item1.SNKeyPath), module.Item1.SNKeyPassword)); context.Annotations.Set(module.Item2, RulesKey, rules); foreach (IDnlibDef def in module.Item2.FindDefinitions()) { ApplyRules(context, def, rules); context.CheckCancellation(); } // Packer parameters are stored in modules if (packerParams != null) { ProtectionParameters.GetParameters(context, module.Item2)[packer] = packerParams; } } return(new MarkerResult(modules.Select(module => module.Item2).ToList(), packer, extModules)); }
/// <summary> /// Initializes a new instance of the <see cref="MarkerResult" /> class. /// </summary> /// <param name="modules">The modules.</param> /// <param name="packer">The packer.</param> /// <param name="extModules">The external modules.</param> public MarkerResult(IList <ModuleDefMD> modules, Packer packer, IList <byte[]> extModules) { Modules = modules; Packer = packer; ExternalModules = extModules; }