void UpdateResolver(ModuleDef module)
 {
     if (module != null)
     {
         module.Context = DsDotNetDocumentBase.CreateModuleContext(documentProvider.AssemblyResolver);
     }
 }
Esempio n. 2
0
 void UpdateResolver(ModuleDef module)
 {
     if (module != null)
     {
         module.Context = DsDotNetDocumentBase.CreateModuleContext(documentTreeView.DocumentService.AssemblyResolver);
     }
 }
Esempio n. 3
0
        public IDsDocument CreateDocument(DsDocumentInfo documentInfo, string filename, bool isModule)
        {
            try {
                // Quick check to prevent exceptions from being thrown
                if (!File.Exists(filename))
                {
                    return(new DsUnknownDocument(filename));
                }

                IPEImage peImage;

                if (Settings.UseMemoryMappedIO)
                {
                    peImage = new PEImage(filename);
                }
                else
                {
                    peImage = new PEImage(File.ReadAllBytes(filename), filename);
                }

                var  dotNetDir = peImage.ImageNTHeaders.OptionalHeader.DataDirectories[14];
                bool isDotNet  = dotNetDir.VirtualAddress != 0 && dotNetDir.Size >= 0x48;
                if (isDotNet)
                {
                    try {
                        var options = new ModuleCreationOptions(DsDotNetDocumentBase.CreateModuleContext(AssemblyResolver));
                        if (isModule)
                        {
                            return(DsDotNetDocument.CreateModule(documentInfo, ModuleDefMD.Load(peImage, options), true));
                        }
                        return(DsDotNetDocument.CreateAssembly(documentInfo, ModuleDefMD.Load(peImage, options), true));
                    }
                    catch {
                    }
                }

                return(new DsPEDocument(peImage));
            }
            catch {
            }

            return(new DsUnknownDocument(filename));
        }