Beispiel #1
0
 public void Show(Program program, ProgramResourceInstance resource)
 {
     var uiSvc = services.RequireService<IDecompilerShellUiService>();
     var rsrcToString = ResourceToString(resource);
     var wnd = uiSvc.FindDocumentWindow("resEdit", resource);
     if (wnd == null)
     {
         wnd = uiSvc.CreateDocumentWindow(
             "resEdit",
             resource,
             resource.Name,
             new ResourceEditorInteractor(program, resource));
     }
     wnd.Show();
 }
Beispiel #2
0
        /// <summary>
        /// Reads in the NE image resources.
        /// </summary>
        //$REFACTOR: resource loading seems to want to belong in a separate file.
        private void LoadResources(List<ProgramResource> resources)
        {
            var rsrcTable = new LeImageReader(RawImage, this.lfaNew + offRsrcTable);
            var rdr = rsrcTable.Clone();
            ushort size_shift = rdr.ReadLeUInt16();
            ProgramResourceGroup bitmaps = null;
            ProgramResourceGroup iconGroups = null;
            ProgramResourceGroup icons = null;
            var iconIds = new Dictionary<ushort, ProgramResourceInstance>();
            ushort rsrcType = rdr.ReadLeUInt16();
            while (rsrcType != 0)
            {
                var resGrp = new ProgramResourceGroup { Name = GetResourceType(rsrcType) };
                if (rsrcType == NE_RSCTYPE_GROUP_ICON)
                    iconGroups = resGrp;
                else if (rsrcType == NE_RSCTYPE_ICON)
                    icons = resGrp;
                else if (rsrcType == NE_RSCTYPE_BITMAP)
                    bitmaps = resGrp;

                ushort typeCount = rdr.ReadLeUInt16();
                uint resLoader = rdr.ReadLeUInt32();
                for (int count = typeCount; count > 0; --count)
                {
                    ushort nameOffset = rdr.ReadLeUInt16();
                    ushort nameLength = rdr.ReadLeUInt16();
                    ushort nameFlags = rdr.ReadLeUInt16();
                    ushort nameId = rdr.ReadLeUInt16();
                    ushort nameHandle = rdr.ReadLeUInt16();
                    ushort nameUsage = rdr.ReadLeUInt16();

                    string resname;
                    if ((nameId & 0x8000) != 0)
                    {
                        resname = (nameId & ~0x8000).ToString();
                    }
                    else
                    {
                        resname = ReadByteLengthString(rsrcTable, nameId);
                    }

                    var offset = (uint)nameOffset << size_shift;
                    var rdrRsrc = new LeImageReader(base.RawImage, offset);
                    var rsrc = rdrRsrc.ReadBytes((uint)nameLength << size_shift);

                    var rsrcInstance = new ProgramResourceInstance
                    {
                        Name = resname,
                        Type = "Win16_" + resGrp.Name,
                        Bytes = rsrc,
                    };
                    resGrp.Resources.Add(rsrcInstance);

                    if (rsrcType == NE_RSCTYPE_ICON)
                        iconIds[(ushort)(nameId & ~0x8000)] = rsrcInstance;
                }
                resources.Add(resGrp);

                rsrcType = rdr.ReadLeUInt16();
            }

            PostProcessIcons(iconGroups, icons, iconIds, resources);
            PostProcessBitmaps(bitmaps);
        }
 public ResourceEditorInteractor(Program program, ProgramResourceInstance resource)
 {
     this.program = program;
     this.resource = resource;
 }
Beispiel #4
0
 private string ResourceToString(ProgramResourceInstance resource)
 {
     return string.Format("{0}:{1}", resource.Type, resource.Name);
 }
Beispiel #5
0
 private string ResourceToString(ProgramResourceInstance resource)
 {
     var items = new List<string>();
     return string.Format("{0}:{1}", resource.Type, resource.Name);
 }