private void LoadDLL(string path) { var fi = new FileInfo(path); if (!fi.Exists) { Console.WriteLine("File \"{0}\" does not exist.", fi.Name); return; } var b = File.ReadAllBytes(fi.FullName); var ad = AssemblyDef.Load(b); var newName = new string(ad.Name.ToString().Take(6).ToArray()) + DateTime.Now.Ticks.ToString(); //Arbitrary, take first 6 chars. ad.Name = new UTF8String(newName); using (var ms = new MemoryStream()) { ad.Write(ms); var ass = Assembly.Load(ms.ToArray()); var t = ass.GetType("script.Main"); var m = t.GetMethod("Bootstrap", BindingFlags.Static | BindingFlags.Public); m.Invoke(null, null); } }
private void materialRaisedButton2_Click(object sender, EventArgs e) { materialProgressBar1.Value = 0; Thread thread = new Thread(new ThreadStart(this.Progress)); thread.IsBackground = true; thread.Start(); if (materialLabel1.Text == "Is .NET Assembly: No") { MessageBox.Show("Not a valid dotnet assembly!", "K Protector"); return; } try { AssemblyDef asm = AssemblyDef.Load(materialSingleLineTextField1.Text); Context krawk = new Context(asm); var rule = new Rule(enable_Constants, enable_calli, enable_cflow, enable_debug, enable_renamer, rename_assembly, antide4dot, refproxy); new Krawk_Protector.Utils.Core(krawk, rule).DoObfuscation(); var opts = new NativeModuleWriterOptions(krawk.ManifestModule as ModuleDefMD); opts = Writer.Run(krawk); if (materialSingleLineTextField1.Text.Contains(".exe")) { (asm.ManifestModule as ModuleDefMD).NativeWrite(materialSingleLineTextField1.Text.Replace(".exe", "_Obf.exe"), opts); } if (materialSingleLineTextField1.Text.Contains(".dll")) { (asm.ManifestModule as ModuleDefMD).NativeWrite(materialSingleLineTextField1.Text.Replace(".dll", "_Obf.dll"), opts); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
protected static AssemblyDef CompileLegacy(string code, bool optimize, bool useDebug, int compilerVersion) { CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary <string, string> { { "CompilerVersion", "v" + new Version(compilerVersion, 0) } }); CompilerParameters options = new CompilerParameters(); options.CompilerOptions = "/unsafe /o" + (optimize ? "+" : "-") + (useDebug ? " /debug" : ""); if (compilerVersion >= 4) { options.ReferencedAssemblies.Add("System.Core.dll"); } CompilerResults results = provider.CompileAssemblyFromSource(options, code); try { if (results.Errors.Count > 0) { StringBuilder b = new StringBuilder("Compiler error:"); foreach (var error in results.Errors) { b.AppendLine(error.ToString()); } throw new Exception(b.ToString()); } return(AssemblyDef.Load(results.PathToAssembly)); } finally { File.Delete(results.PathToAssembly); results.TempFiles.Delete(); } }
private void LoadDLL(string path, string type) { var fi = new FileInfo(path); if (!fi.Exists) { Console.WriteLine("File \"{0}\" does not exist.", fi.Name); return; } var b = File.ReadAllBytes(fi.FullName); //Copy to buffer var ad = AssemblyDef.Load(b); var prevName = ad.Name.ToString(); prevName = prevName.Substring(0, Math.Min(prevName.Length, 6)); //Arbitrary, take first 6 chars. ad.Name = new UTF8String(prevName + DateTime.Now.Ticks.ToString()); using (var ms = new MemoryStream()) { ad.Write(ms); var ass = Assembly.Load(ms.ToArray()); var t = ass.GetType(type); var m = t.GetMethod("Bootstrap", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); m.Invoke(null, null); Console.WriteLine(type); } }
/// <summary> /// This load the types from the source assembly. /// </summary> /// <param name="ctx"></param> /// <returns>true if it manage to load all the types correctly; false otherwise</returns> public bool LoadTypes() { try { ModuleDef module = null; for (var i = 0; i < sourceMap.Count; ++i) { if (module == null || (module != null && module.Name != sourceMap[i].module)) { if (!File.Exists(sourceMap[i].module)) { return(typesLoadedCorrectly = false); } module = AssemblyDef.Load(sourceMap[i].module).ManifestModule; } MethodDef foundMethod = module.Find(sourceMap[i].@namespace, true).FindMethod(sourceMap[i].name); sourceMap[i].matchingMethods = new List <MethodDef>() { foundMethod }; } } catch (Exception ex) { GC.KeepAlive(ex); return(typesLoadedCorrectly = false); } return(typesLoadedCorrectly = true); }
/// <summary> /// Faker! /// </summary> static void Sign(string path, string key, Version v, string newPath = null) { var dll = AssemblyDef.Load(path); //If you want the dll to be platform: x64 instead of AnyCPU (x64 first), use this option. It shouldn't be used here. //var option = new ModuleWriterOptions(dll.ManifestModule) {PEHeadersOptions = {Machine = Machine.AMD64}}; dll.HasPublicKey = true; dll.PublicKey = new PublicKey(key); if (v != null) { dll.Version = v; } if (newPath == null) { dll.Write(path); //dll.Write(path, option); } else { dll.Write(Path.Combine(newPath, $"{dll.Name}.dll")); //dll.Write(Path.Combine(newPath, $"{dll.Name}.dll"), option); } }
static List <AssemblyDef> LoadAssemblies(string[] lst) { AssemblyResolver asmResolver = new AssemblyResolver(); ModuleContext modCtx = new ModuleContext(asmResolver); asmResolver.DefaultModuleContext = modCtx; asmResolver.EnableTypeDefCache = true; foreach (var path in lst) { asmResolver.PreSearchPaths.Add(path); } List <AssemblyDef> assemblies = new List <AssemblyDef>(); foreach (var asm in lst) { try { var def = AssemblyDef.Load(File.ReadAllBytes(asm)); def.Modules[0].Context = modCtx; asmResolver.AddToCache(def); assemblies.Add(def); } catch { //Ignore } } return(assemblies); }
public void Load(string filename) { AssemblyDef assembly = AssemblyDef.Load(filename); LoadedAssembly = assembly; Loaded = true; }
private void button2_Click(object sender, EventArgs e) { AssemblyDef assembly = AssemblyDef.Load(textBox1.Text); ModuleContext modCtx = ModuleDefMD.CreateModuleContext(); ModuleDefMD module = ModuleDefMD.Load(textBox1.Text, modCtx); if (antide4dot == true) { antiDe4Dot(module); module.Write(textBox3.Text + ".exe"); } if (nameprotection == true) { ProtectName(assembly, module); module.Write(textBox3.Text + ".exe"); } if (fakeobfu == true) { fakeobfuscation(module); module.Write(textBox3.Text + ".exe"); } if (junkattribute == true) { junkattrib(module); module.Write(textBox3.Text + ".exe"); } if (encryptstring == true) { encryptString(module); module.Write(textBox3.Text + ".exe"); } MessageBox.Show("🍓 🎀 𝕌𝕎𝕌 𝕋𝕙𝕒𝕟𝕜𝕤 𝕗𝕠𝕣 𝕦𝕤𝕚𝕟𝕘 𝕍𝕒𝕡𝕠𝕣𝕆𝕓𝕗𝕦𝕤𝕔𝕒𝕥𝕠𝕣 𝕌𝕎𝕌 🎀 🍓", "🍓 🎀 𝕌𝕎𝕌 𝕋𝕙𝕒𝕟𝕜𝕤 𝕗𝕠𝕣 𝕦𝕤𝕚𝕟𝕘 𝕍𝕒𝕡𝕠𝕣𝕆𝕓𝕗𝕦𝕤𝕔𝕒𝕥𝕠𝕣 𝕌𝕎𝕌 🎀 🍓", MessageBoxButtons.OK, MessageBoxIcon.Information); }
static void Main(string[] args) { var asmDef = AssemblyDef.Load(args[0]); var method = asmDef.ManifestModule.EntryPoint.DeclaringType.FindMethod("Foo"); var asmResolver = new AssemblyResolver(); var modCtx = new ModuleContext(asmResolver); var ast = new ILAST(method, modCtx); Console.WriteLine("-------------------------------"); Console.WriteLine(" Standard AST"); Console.WriteLine("-------------------------------"); foreach (Element element in ast.Elements) { Console.WriteLine("{0}: {1}", element.GetType().Name, element); } ILAST.SimplifyElements(ast.Elements); Console.WriteLine("\n-------------------------------"); Console.WriteLine(" Simplified AST"); Console.WriteLine("-------------------------------"); foreach (Element element in ast.Elements) { Console.WriteLine("{0}: {1}", element.GetType().Name, element); } Console.WriteLine(asmDef); }
void UnpackAllAssemblies(AssemblyDef asm) { foreach (var res in asm.ManifestModule.Resources) { if (!(res is EmbeddedResource)) { continue; } if (!res.IsPrivate) { continue; } var _res = res as EmbeddedResource; byte[] decAsm; if (StaticDecryptAssembly(asm, _res.GetResourceData(), out decAsm)) { try { var tmpAsm = Ctx.Deobfuscator.DeobfuscateAssembly(AssemblyDef.Load(decAsm)); tmpAsm.Write(Path.GetDirectoryName(Ctx.Filename) + "\\" + tmpAsm.Name + tmpAsm.GetExtension()); Ctx.UIProvider.WriteVerbose("Unpacked: {0}", 2, true, tmpAsm.Name + tmpAsm.GetExtension()); //var tester = new Unpacker(); //Ctx.Assembly = tmpAsm; //tester.Initialize(); //if (tester.Detect()) // UnpackAllAssemblies(tmpAsm); } catch (BadImageFormatException) { } } } }
static List <AssemblyDef> LoadAssemblies(string target) { AssemblyResolver asmResolver = new AssemblyResolver(); ModuleContext modCtx = new ModuleContext(asmResolver); asmResolver.DefaultModuleContext = modCtx; asmResolver.EnableTypeDefCache = true; var directory = Path.GetFullPath(Path.GetDirectoryName(target)); asmResolver.PreSearchPaths.Add(directory); List <AssemblyDef> assemblies = new List <AssemblyDef>(); foreach (var asm in Directory.GetFiles(directory, "*.*") .Where(f => Path.GetExtension(f.ToLower()) == ".exe" || Path.GetExtension(f.ToLower()) == ".dll")) { try { var def = AssemblyDef.Load(asm); def.Modules[0].Context = modCtx; asmResolver.AddToCache(def); assemblies.Add(def); } catch { //Ignore } } return(assemblies); }
private TypeDef typeDef(string name) { var tmpAsm = AssemblyDef.Load(Application.ExecutablePath); var importmeType = tmpAsm.ManifestModule.Find(name, false); return(importmeType); }
private IEnumerable <EmbeddedResource> DecryptResources(string resName) { var res = Ctx.Assembly.ManifestModule.Resources.First(x => x.Name == resName) as EmbeddedResource; if (res == null) { throw new Exception("Resource not found: " + resName); } Stream manifestResourceStream = new MemoryStream(res.GetResourceData()); var buffer = new byte[manifestResourceStream.Length]; manifestResourceStream.Read(buffer, 0, buffer.Length); var num = (byte)DemutatedKeys["res"].DemutatedInts[0]; for (var i = 0; i < buffer.Length; i++) { buffer[i] = (byte)(buffer[i] ^ num); num = (byte)((num * DemutatedKeys["res"].DemutatedInts[1]) % 256); } using ( var reader = new BinaryReader(new DeflateStream(new MemoryStream(buffer), CompressionMode.Decompress))) { buffer = reader.ReadBytes(reader.ReadInt32()); var tmpAsm = AssemblyDef.Load(buffer); foreach (var res2 in tmpAsm.ManifestModule.Resources.Where(r => r is EmbeddedResource)) { yield return(res2 as EmbeddedResource); } } yield return(null); }
private void InnerPatch(IEnumerable <Type> processors, string dll) { _logger.Info(Strings.Patching, dll); var module = AssemblyDef.Load(Mod.GetFile(dll)).Modules.Single(); foreach (var processor in processors) { try { var proc = Activator.CreateInstance(processor, this, module); var tran = LoadFiles(LocalizationSourcePath, processor); processor.GetMethod(nameof(Processor <Content> .PatchContents))?.Invoke(proc, new[] { tran }); } catch (Exception ex) { _logger.Warn(Strings.ProcExceptionOccur, processor.FullName); _logger.Error(ex); } } using (var ms = new MemoryStream()) { module.Assembly.Write(ms); Mod.Files[dll] = ms.ToArray(); } }
public static void DoReflection() { if (assembly_bytes == null || assembly_bytes.Length == 0) { return; } AssemblyDef asm = AssemblyDef.Load(assembly_bytes); if (asm.ManifestModule.EntryPoint != null) { Importer importer = new Importer(asm.ManifestModule); IMethod MessageBox_Show = importer.Import(typeof(System.Windows.Forms.MessageBox).GetMethod("Show", new Type[] { typeof(string) })); IList <Instruction> instrs = asm.ManifestModule.EntryPoint.Body.Instructions; instrs.Insert(0, new Instruction(OpCodes.Ldstr, "Injected Message!")); instrs.Insert(1, new Instruction(OpCodes.Call, MessageBox_Show)); instrs.Insert(2, new Instruction(OpCodes.Pop)); } using (MemoryStream ms = new MemoryStream()) { asm.Write(ms); assembly_bytes = ms.ToArray(); } }
private void metroButton2_Click(object sender, EventArgs e) { AssemblyDef assembly = AssemblyDef.Load(metroTextBox1.Text); ModuleContext modCtx = ModuleDefMD.CreateModuleContext(); ModuleDefMD module = ModuleDefMD.Load(metroTextBox1.Text, modCtx); if (antide4dot == true) { antiDe4Dot(module); module.Write(metroTextBox3.Text + ".exe"); } if (protectname == true) { ProtectName(assembly, module); module.Write(metroTextBox3.Text + ".exe"); } if (fakeobf == true) { fakeobfuscation(module); module.Write(metroTextBox3.Text + ".exe"); } if (junkatrb == true) { junkattrib(module); module.Write(metroTextBox3.Text + ".exe"); } if (encryptstring == true) { encryptString(module); module.Write(metroTextBox3.Text + ".exe"); } MessageBox.Show("Thank you for using the obfuscator :)", "Thank you for using the obfuscator :)", MessageBoxButtons.OK, MessageBoxIcon.Information); }
static void Main(string[] args) { Console.Title = ".NET ControlFlow"; Console.WriteLine("Basic .NET ControlFlow based in dnlib"); if (args[0] == "" || args[0] == null) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid args."); Console.ReadLine(); } else { string path = args[0]; AssemblyDef assembly = AssemblyDef.Load(path); Context ctx = new Context(assembly); ControlFlow(ctx); var Options = new ModuleWriterOptions(ctx.ManifestModule); Options.Logger = DummyLogger.NoThrowInstance; string pathloc = path.Replace(".exe", ""); assembly.Write(pathloc + "-WithControlFlow.exe", Options); Console.WriteLine("Saved in -> " + pathloc + " - WithControlFlow.exe"); Console.ReadLine(); } }
public DNContext(string asmToLoad) { var pa = AssemblyDef.Load(asmToLoad); reflectionOnlyAsm = Assembly.ReflectionOnlyLoadFrom(asmToLoad); var refs = reflectionOnlyAsm.GetReferencedAssemblies(); References = refs.Select(r => new AssemblyNameInfo(r)).ToArray(); //stdLibAsms = refs.Where(n => //{ // try // { // return Assembly.ReflectionOnlyLoad(n.FullName).GlobalAssemblyCache; // } // catch // { // return false; // } //}).Select(TranslateReference).Select(n => new AsmInfo(pa.MainModule.AssemblyResolver.Resolve(n))).ToList(); primaryAssembly = new AsmInfo(pa); // load types after stdlib/gac references are loaded SigComparer = new SigComparer(SigComparerOptions.PrivateScopeIsComparable); RefComparer = new DNReflectionComparer(this); Resolver = new MemberResolver(this); }
private static void InnerPatch(TmodFileWrapper.ITmodFile modFile, IEnumerable <Type> processors, string dll = null) { if (string.IsNullOrWhiteSpace(dll)) { dll = modFile.HasFile("All.dll") ? "All.dll" : "Windows.dll"; } Logger.Info(Strings.Patching, dll); var module = AssemblyDef.Load(modFile.GetFile(dll)).Modules.Single(); foreach (var processor in processors) { try { var proc = Activator.CreateInstance(processor, modFile, module, _language); var tran = LoadFiles(SourcePath, processor); processor.GetMethod(nameof(Processor <Content> .PatchContents))?.Invoke(proc, new[] { tran }); } catch (Exception ex) { Logger.Warn(Strings.ProcExceptionOccur, processor.FullName); Logger.Error(ex); } } using (var ms = new MemoryStream()) { module.Assembly.Write(ms); modFile.Files[dll] = ms.ToArray(); } }
public void BuildClient(string Port, string DNS, string Name, string ClientTag, string UpdateInterval) { VanillaRatStub.ClientSettings.DNS = DNS; VanillaRatStub.ClientSettings.Port = Port; VanillaRatStub.ClientSettings.ClientTag = ClientTag; VanillaRatStub.ClientSettings.UpdateInterval = UpdateInterval; string FullName = "VanillaRatStub.ClientSettings"; var Assembly = AssemblyDef.Load("VanillaRatStub.exe"); var Module = Assembly.ManifestModule; if (Module != null) { var Settings = Module.GetTypes().Where(type => type.FullName == FullName).FirstOrDefault(); if (Settings != null) { var Constructor = Settings.FindMethod(".cctor"); if (Constructor != null) { Constructor.Body.Instructions[0].Operand = VanillaRatStub.ClientSettings.DNS; Constructor.Body.Instructions[2].Operand = VanillaRatStub.ClientSettings.Port; Constructor.Body.Instructions[4].Operand = VanillaRatStub.ClientSettings.ClientTag; Constructor.Body.Instructions[6].Operand = VanillaRatStub.ClientSettings.UpdateInterval; if (!Directory.Exists(Environment.CurrentDirectory + @"\Clients")) { Directory.CreateDirectory(Environment.CurrentDirectory + @"\Clients"); } Assembly.Write(Environment.CurrentDirectory + @"\Clients\" + Name + ".exe"); } } return; } }
private void Dump(IEnumerable <Type> processors) { LocalizationSourcePath = LocalizationSourcePath ?? Mod.Name; if (Directory.Exists(LocalizationSourcePath) && DefaultConfigurations.FolderMapper.Values.Any(dir => { var path = Path.Combine(LocalizationSourcePath, dir); return(Directory.Exists(path) && Directory.GetFiles(path).Length > 0); })) { throw new Exception("Non-empty source folder as output path"); } Directory.CreateDirectory(LocalizationSourcePath); foreach (var folder in DefaultConfigurations.FolderMapper.Values) { Directory.CreateDirectory(Path.Combine(LocalizationSourcePath, folder)); } _logger.Warn("Directory created: {0}", Mod.Name); var module = AssemblyDef.Load(Mod.GetMainAssembly()).Modules.Single(); foreach (var processor in processors) { try { var proc = Activator.CreateInstance(processor, this, module); var contents = (IReadOnlyList <Content>)processor.GetMethod(nameof(Processor <Content> .DumpContents))?.Invoke(proc, new object[0]); if (contents == null) { _logger.Warn(Strings.ProcNotUsed, processor.Name); continue; } _logger.Debug("Using " + processor.Name); foreach (var val in contents.GroupBy(x => x.Namespace, x => x)) { File.WriteAllText( DefaultConfigurations.GetPath(Mod, processor, val.Key + ".json"), JsonConvert.SerializeObject(val.ToList(), Formatting.Indented) ); _logger.Info(Strings.DumpNamespace, val.Key); } } catch (Exception ex) { _logger.Warn(Strings.ProcExceptionOccur, processor.FullName); _logger.Error(ex); } } }
private IEnumerable <EmbeddedResource> DecryptResources(string resName) { var res = Ctx.Assembly.ManifestModule.Resources.First(x => x.Name == resName) as EmbeddedResource; if (res == null) { throw new Exception("Resource not found: " + resName); } Stream resStream = new MemoryStream(res.GetResourceData()); var buff = new byte[resStream.Length]; resStream.Read(buff, 0, buff.Length); var num = (byte)DemutatedKeys["res"].DemutatedInts[0]; for (var i = 0; i < buff.Length; i++) { buff[i] = (byte)(buff[i] ^ num); num = (byte)((num * DemutatedKeys["res"].DemutatedInts[1]) % 256); } var s = new MemoryStream(buff); var decoder = new Lzma.LzmaDecoder(); var prop = new byte[5]; s.Read(prop, 0, 5); decoder.SetDecoderProperties(prop); long outSize = 0; for (int i = 0; i < 8; i++) { int v = s.ReadByte(); if (v < 0) { throw (new Exception()); } outSize |= ((long)(byte)v) << (8 * i); } var b = new byte[outSize]; var z = new MemoryStream(b, true); long compressedSize = s.Length - 13; decoder.Code(s, z, compressedSize, outSize); z.Position = 0; using (var rdr = new BinaryReader(z)) { buff = rdr.ReadBytes(rdr.ReadInt32()); var tmpAsm = AssemblyDef.Load(buff); foreach (var res2 in tmpAsm.ManifestModule.Resources.Where(r => r is EmbeddedResource)) { yield return(res2 as EmbeddedResource); } } yield return(null); }
void Modify(ModuleDefMD module) { publicmodule = module; if (xeno_) { xenocode(); } if (smart_) { smartassembly(); } if (agile_) { agile(); } if (goliath_) { goliath(); } if (yano_) { yano(); } if (crypto_) { crypto(); } if (confuserex_) { confuserex(); } if (babel_) { babel(); } if (dotfus_) { dotfuscator(); } if (nine_) { ninerays(); } if (bithelm_) { bithelmet(); } if (mango_) { mango(); } if (dnguard_) { dnguard(); } AssemblyDef ass = AssemblyDef.Load(textBox1.Text); saveFileDialog1.ShowDialog(); }
/// <summary> /// Resolves by path. /// </summary> /// <returns></returns> private AssemblyDef ResolvePath() { if (Path == null) { return(null); } return(SafeLoad(() => AssemblyDef.Load(File.ReadAllBytes(Path)))); }
private static async Task WriteToFileAsync(string resourceName, string matching, string fileDirectory, bool compressed) { if (!Directory.Exists(fileDirectory) || !PathUtilities.UserHasDirectoryAccessRights(fileDirectory, FileSystemRights.Modify)) { throw new IOException("The Launcher's base directory does not exists"); } var filePath = Path.Combine(fileDirectory, matching); try { using var rs = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (rs == null) { throw new NullReferenceException(nameof(rs)); } var assemblyStream = new MemoryStream(); await rs.CopyToAsync(assemblyStream); if (compressed) { assemblyStream = await rs.DecompressAsync(); } assemblyStream.Position = 0; #if !DEBUG if (File.Exists(filePath)) { var embeddedAssembly = AssemblyDef.Load(assemblyStream, new ModuleContext(new AssemblyResolver(), null)); var embeddedFileVersionString = embeddedAssembly.CustomAttributes .Find(typeof(AssemblyFileVersionAttribute).FullName)?.ConstructorArguments[0].Value.ToString(); if (File.ReadAllBytes(filePath).Length > 0) { var existingVersionString = FileVersionInfo.GetVersionInfo(filePath).FileVersion; var existingVersion = Version.Parse(existingVersionString); if (string.IsNullOrEmpty(embeddedFileVersionString)) { return; } var embeddedAssemblyFileVersion = Version.Parse(embeddedFileVersionString); if (embeddedAssemblyFileVersion <= existingVersion) { return; } } assemblyStream.Position = 0; } #endif Logger.Debug($"Writing file: '{filePath}'"); await WriteToFileAsync(assemblyStream, filePath); } catch (Exception ex) { throw new IOException("Error writing necessary launcher files to disk!", ex); } }
public static MethodDef GetTestMethod(Type containingType, string name) { var assembly = AssemblyDef.Load(containingType.Assembly.Location); var module = assembly.ManifestModule; var type = module.GetTypes().Single(t => t.Name == containingType.Name && t.DeclaringType?.Name == containingType.DeclaringType?.Name); return(type.FindMethod(name)); }
private static AssemblyDef LoadAssembly(string cbDirectory, string name) { var path = Path.Combine(cbDirectory, name); var expectedName = Path.GetFileNameWithoutExtension(name); var assembly = AssemblyDef.Load(path); Trace.Assert(assembly.Name == expectedName, $"{name} does not contain the correct assembly!"); return(assembly); }
AssemblyInfo getAssemblyInfo(byte[] decryptedData, EmbeddedResource resource) { var asm = AssemblyDef.Load(decryptedData); var fullName = asm.FullName; var simpleName = asm.Name.String; var extension = DeobUtils.getExtension(asm.Modules[0].Kind); return(new AssemblyInfo(decryptedData, fullName, simpleName, extension, resource)); }
private AssemblyDef LoadFile(string path) { var assemblyBytes = File.ReadAllBytes(path); var assemblyDef = AssemblyDef.Load(assemblyBytes); assemblyDef.ManifestModule.Location = path; _cache[assemblyDef] = assemblyDef; return(assemblyDef); }