Esempio n. 1
0
 static PEFile LoadPEFile(string fileName, BamlDecompilerSettings settings)
 {
     return(new PEFile(
                fileName,
                new FileStream(fileName, FileMode.Open, FileAccess.Read),
                streamOptions: PEStreamOptions.PrefetchEntireImage,
                metadataOptions: MetadataReaderOptions.None
                ));
 }
Esempio n. 2
0
        static BamlDecompilerTypeSystem CreateTypeSystemFromFile(string fileName, BamlDecompilerSettings settings)
        {
            var file     = LoadPEFile(fileName, settings);
            var resolver = new UniversalAssemblyResolver(fileName, settings.ThrowOnAssemblyResolveErrors,
                                                         file.DetectTargetFrameworkId(), file.DetectRuntimePack(),
                                                         PEStreamOptions.PrefetchMetadata,
                                                         MetadataReaderOptions.None);

            return(new BamlDecompilerTypeSystem(file, resolver));
        }
Esempio n. 3
0
 internal XamlDecompiler(BamlDecompilerTypeSystem typeSystem, BamlDecompilerSettings settings)
 {
     this.typeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem));
     this.settings   = settings;
     this.module     = typeSystem.MainModule;
     if (module.TypeSystemOptions.HasFlag(TypeSystemOptions.Uncached))
     {
         throw new ArgumentException("Cannot use an uncached type system in the decompiler.");
     }
 }
Esempio n. 4
0
        public static XamlContext Construct(IDecompilerTypeSystem typeSystem, BamlDocument document, CancellationToken token, BamlDecompilerSettings bamlDecompilerOptions)
        {
            var ctx = new XamlContext(typeSystem);

            ctx.CancellationToken = token;
            ctx.Settings          = bamlDecompilerOptions ?? new BamlDecompilerSettings();

            ctx.Baml     = BamlContext.ConstructContext(typeSystem, document, token);
            ctx.RootNode = BamlNode.Parse(document, token);

            ctx.BuildPIMappings(document);
            ctx.BuildNodeMap(ctx.RootNode as BamlBlockNode);

            return(ctx);
        }
Esempio n. 5
0
 public XamlDecompiler(PEFile module, IAssemblyResolver assemblyResolver, BamlDecompilerSettings settings)
     : this(new BamlDecompilerTypeSystem(module, assemblyResolver), settings)
 {
 }
Esempio n. 6
0
 public XamlDecompiler(string fileName, IAssemblyResolver assemblyResolver, BamlDecompilerSettings settings)
     : this(LoadPEFile(fileName, settings), assemblyResolver, settings)
 {
 }
Esempio n. 7
0
 public XamlDecompiler(string fileName, BamlDecompilerSettings settings)
     : this(CreateTypeSystemFromFile(fileName, settings), settings)
 {
 }