/// <summary>Converts the path to a resource into bitmap image which can be used as the 'Source' of an Image.</summary>
 /// <param name="resourcePath">
 ///    The path to the resource from the root of the project or the root of the ClientBin (depending on 'location').<BR/>
 /// </param>
 /// <param name="location">Flag indicating whether the image is packaged in the XAP on the client, or is in the ClientBin on the server.</param>
 /// <returns></returns>
 public static BitmapImage ToImageSource(this string resourcePath, ImageLocation location)
 {
     switch (location)
     {
         case ImageLocation.Client: return resourcePath.ToImageSource(Assembly.GetCallingAssembly());
         case ImageLocation.Server: return new BitmapImage { UriSource = new Uri(resourcePath, UriKind.Relative) };
         default: throw new ArgumentOutOfRangeException(location.ToString());
     }
 }
示例#2
0
 public XCoff64Loader(IServiceProvider services, ImageLocation imageUri, byte[] rawImage) :
     base(services, imageUri, rawImage)
 {
     this.PreferredBaseAddress = Address.Ptr64(0x0010_0000);
 }
示例#3
0
 public T64Loader(IServiceProvider services, ImageLocation imageUri, byte[] bytes)
     : base(services, imageUri, bytes)
 {
 }
示例#4
0
 public XbeLoader(IServiceProvider services, ImageLocation imageUri, byte[] rawImage)
     : base(services, imageUri, rawImage)
 {
     rdr = new LeImageReader(rawImage);
     ctx = null !;
 }
示例#5
0
 public WasmLoader(IServiceProvider services, ImageLocation imageLocation, byte[] imgRaw)
     : base(services, imageLocation, imgRaw)
 {
     PreferredBaseAddress = Address.Ptr32(0);
 }
示例#6
0
 public ProgramImageLoader(IServiceProvider services, ImageLocation imageLocation, byte[] imgRaw)
     : base(services, imageLocation, imgRaw)
 {
 }
示例#7
0
        private void Decompile(Dictionary <string, object> pArgs)
        {
            pArgs.TryGetValue("--loader", out object imgLoader);
            var addrLoad = ParseAddress(pArgs, "--base");

            try
            {
                var     fileName      = (string)pArgs["filename"];
                var     filePath      = Path.GetFullPath(fileName);
                var     imageLocation = ImageLocation.FromUri(filePath);
                var     loadedImage   = ldr.Load(imageLocation, (string)imgLoader, addrLoad);
                Project project;
                switch (loadedImage)
                {
                case Program loadedProgram:
                    project = Project.FromSingleProgram(loadedProgram);
                    break;

                case Project loadedProject:
                    project = loadedProject;
                    break;

                default:
                    this.listener.Error("Cannot decompile {0}.", fileName);
                    return;
                }
                var decompiler = new Decompiler(project, services);
                dcSvc.Decompiler = decompiler;

                var program = decompiler.Project.Programs[0];
                program.User.ExtractResources = ShouldExtractResources(program, pArgs);

                if (pArgs.TryGetValue("heuristics", out var oHeur))
                {
                    decompiler.Project.Programs[0].User.Heuristics = ((string[])oHeur).ToSortedSet();
                }
                if (pArgs.TryGetValue("metadata", out var oMetadata))
                {
                    decompiler.Project.MetadataFiles.Add(new MetadataFile
                    {
                        Location = ImageLocation.FromUri((string)oMetadata)
                    });
                }
                if (pArgs.ContainsKey("dasm-address"))
                {
                    decompiler.Project.Programs[0].User.ShowAddressesInDisassembly = true;
                }
                if (pArgs.ContainsKey("dasm-bytes"))
                {
                    decompiler.Project.Programs[0].User.ShowBytesInDisassembly = true;
                }
                if (pArgs.TryGetValue("aggressive-branch-removal", out object oAggressiveBranchRemoval))
                {
                    decompiler.Project.Programs[0].User.AggressiveBranchRemoval =
                        oAggressiveBranchRemoval is bool flag && flag;
                }
                if (pArgs.TryGetValue("debug-types", out var oProcRange))
                {
                    decompiler.Project.Programs[0].DebugProcedureRange = ((int, int))oProcRange;
                }
                if (pArgs.TryGetValue("debug-trace-proc", out object oTraceProcs))
                {
                    decompiler.Project.Programs[0].User.DebugTraceProcedures =
                        (HashSet <string>)oTraceProcs;
                }
                decompiler.ExtractResources();
                decompiler.ScanPrograms();
                if (!pArgs.ContainsKey("scan-only"))
                {
                    decompiler.AnalyzeDataFlow();
                    decompiler.ReconstructTypes();
                    decompiler.StructureProgram();
                    decompiler.WriteDecompilerProducts();
                }
            }
            catch (Exception ex)
            {
                listener.Error(ex, "An error occurred during decompilation.");
            }
        }
示例#8
0
 public FakeArchiveLoader(IServiceProvider services, ImageLocation uri, byte[] bytes) :
     base(services, uri, bytes)
 {
 }
示例#9
0
 public Blob(ImageLocation location, byte[] image)
 {
     this.Image    = image;
     this.Location = location;
 }
        public static SimpleButton InitWithImage(this SimpleButton button, ApplicationIcon applicationIcon, IconSize iconSize, string text = null, ImageLocation imageLocation = ImageLocation.MiddleLeft, string toolTip = null)
        {
            button.Image         = applicationIcon.ToImage(iconSize);
            button.ImageLocation = imageLocation;
            if (text != null)
            {
                button.Text = text;
            }

            if (toolTip != null)
            {
                button.ToolTip = toolTip;
            }

            return(button);
        }
 public static SimpleButton InitWithImage(this SimpleButton button, ApplicationIcon applicationIcon, string text = null, ImageLocation imageLocation = ImageLocation.MiddleLeft, string toolTip = null)
 {
     return(button.InitWithImage(applicationIcon, IconSizes.Size16x16, text: text, imageLocation: imageLocation, toolTip: toolTip));
 }
示例#12
0
 public OmfLoader(IServiceProvider services, ImageLocation imageLocation, byte[] rawImage)
     : base(services, imageLocation, rawImage)
 {
     this.rawImage = rawImage;
 }
示例#13
0
        /// <summary>
        /// Finds the given image file in the given location and returns it as a <see cref="BitmapImage"/>.
        /// </summary>
        /// <param name="imageLocation">Where is the image.</param>
        /// <param name="imageName">Image name without file extension.</param>
        /// <returns>Return with a <see cref="BitmapImage"/></returns>
        public BitmapImage GetBitmapImageByName(ImageLocation imageLocation, string imageName)
        {
            string imagePath = GetAbsoluteImagePath(_imageLocationMap[imageLocation], imageName);

            return(new BitmapImage(new Uri(@$ "pack://application:,,,/{imagePath}", UriKind.Absolute)));
        }
示例#14
0
 public SavFileLoader(IServiceProvider services, ImageLocation imageUri, byte[] imgRaw) : base(services, imageUri, imgRaw)
 {
     this.PreferredBaseAddress = Address.Ptr16(0);
 }
 public MpwPascalInterfaceLoader(IServiceProvider services, ImageLocation imageUri, byte[] bytes)
     : base(services, imageUri, bytes)
 {
     this.bytes = bytes;
 }
示例#16
0
 private void Given_ExeLoader()
 {
     this.exeLoader = new ExeImageLoader(null, ImageLocation.FromUri("file:FOO.EXE"), writer.ToArray());
     this.exeLoader.ReadCommonExeFields();
 }
示例#17
0
 public TarLoader(IServiceProvider services, ImageLocation location, byte[] imgRaw)
     : base(services, location, imgRaw)
 {
 }
示例#18
0
 public SnesParser(IServiceProvider services, ImageLocation imageUri, byte[] imgRaw) : base(services, imageUri, imgRaw)
 {
 }
示例#19
0
 public NSO0Loader(IServiceProvider services, ImageLocation imageUri, byte[] rawBytes)
     : base(services, imageUri, rawBytes)
 {
 }
示例#20
0
 public void SetImageLocation(ImageLocation pImageLocation)
 {
     ImageLocation = pImageLocation;
 }
示例#21
0
 private void Given_PeLoader()
 {
     peldr = new PeImageLoader(sc, ImageLocation.FromUri("file:test.exe"), fileImage, RvaPeHdr);
 }
示例#22
0
 public ImageLoader(IServiceProvider services, ImageLocation imageLocation, byte[] imgRaw)
 {
     this.Services      = services;
     this.ImageLocation = imageLocation;
     this.RawImage      = imgRaw;
 }
示例#23
0
 public HexLoader(IServiceProvider services, ImageLocation imageLocation, byte[] imgRaw)
     : base(services, imageLocation, imgRaw)
 {
     listener = null !;
 }
示例#24
0
        public void ImLoc_CreateFromFileUri()
        {
            var imloc = ImageLocation.FromUri(@"file:///c:/This is plus+hash#.so");

            Assert.AreEqual(@"c:/This is plus+hash#.so", imloc.FilesystemPath);
        }
示例#25
0
 public D64Archive(IServiceProvider services, ImageLocation archiveUri, List <ArchiveDirectoryEntry> entries)
 {
     this.services    = services;
     this.Location    = archiveUri;
     this.RootEntries = entries;
 }
示例#26
0
 private void When_CreateLoader()
 {
     ldr = new MachOLoader(sc, ImageLocation.FromUri("file:foo.o"), writer.Bytes);
 }
示例#27
0
 public T64Archive(ImageLocation archiveUri, List <ArchiveDirectoryEntry> entries)
 {
     this.Location    = archiveUri;
     this.RootEntries = entries;
 }
示例#28
0
 public ArLoader(IServiceProvider services, ImageLocation location, byte[] imgRaw)
     : base(services, location, imgRaw)
 {
     symbols = new Dictionary <string, uint>();
 }
示例#29
0
 public ArArchive(ImageLocation archLocation)
     : base(archLocation, '/', StringComparer.InvariantCulture)
 {
 }
示例#30
0
 public ScriptFile(IServiceProvider services, ImageLocation scriptLocation, byte[] bytes)
 {
     this.Location = scriptLocation;
 }
示例#31
0
 private string GetCaps(ImageLocation location)
 {
     return String.Concat(Enum.GetName(typeof(ImageLocation), location).Where(l => char.IsUpper(l)));
 }
示例#32
0
 public LeLoader(IServiceProvider services, ImageLocation imageLocation, byte[] rawImage)
     : base(services, imageLocation, rawImage)
 {
     this.PreferredBaseAddress = Address.Ptr32(0x0010_0000);
 }