示例#1
0
        void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
        {
            if (!(((TreeGridItem)treeResources.SelectedItem)?.Values[3] is libexeinfo.NE.Resource resource))
            {
                pnlResource.Content = null;
                return;
            }

            byte[] data = ((libexeinfo.NE.Resource)((TreeGridItem)treeResources.SelectedItem).Values[3]).data;

            switch (((TreeGridItem)treeResources.SelectedItem).Values[2])
            {
            case "RT_STRING":
                pnlResource.Content = panelNeStrings;
                panelNeStrings.Update(data, libexeinfo.NE.TargetOS.OS2);
                break;

            case "RT_ACCELTABLE":
                pnlResource.Content = panelNeAccelerators;
                panelNeAccelerators.Update(data, libexeinfo.NE.TargetOS.OS2);
                break;

            case "RT_BITMAP":
            case "RT_POINTER":
                // TODO: Some do not contain valid OS/2 bitmaps
                try
                {
                    pnlResource.Content = panelOs2Bitmap;
                    panelOs2Bitmap.Update(data);
                }
                catch { goto default; }

                break;

            case "RT_MENU":
                if (BitConverter.ToUInt32(data, 0) == 40)
                {
                    // Some OS/2 executables contain Windows "RT_ICON" resources, in OS/2 NE format
                    pnlResource.Content = panelWindowsIcon;
                    panelWindowsIcon.Update(data);
                    break;
                }

                goto default;

            default:
                pnlResource.Content = panelHexDump;
                panelHexDump.Update(data);
                break;
            }
        }
示例#2
0
        public void Update(byte[] data, string type)
        {
            bool recognized = type == Consts.B_LARGE_ICON_TYPE || type == Consts.B_MINI_ICON_TYPE ||
                              type == Consts.B_PNG_FORMAT;

            if (type == Consts.B_PNG_FORMAT)
            {
                Bitmap png = new Bitmap(data);
                if (png.Width == 0 || png.Height == 0)
                {
                    txtSize.Text  = $"{png.Width}x{png.Height} pixels";
                    imgIcon.Image = png;

                    lblSize.Text     = "Size";
                    lblSize.Visible  = true;
                    txtSize.Visible  = true;
                    pnlPanel.Visible = false;
                    return;
                }

                recognized = false;
            }

            if (data == null || !recognized)
            {
                imgIcon.Image    = null;
                lblSize.Text     = "No data";
                lblSize.Visible  = false;
                txtSize.Visible  = false;
                pnlPanel.Visible = false;
                panelHexDump.Update(data);
                return;
            }

            int width  = type == Consts.B_LARGE_ICON_TYPE ? 32 : 16;
            int height = width;

            List <int> pixels = data.Select(p => (int)Consts.ArgbSystemPalette[p]).ToList();

            txtSize.Text  = $"{width}x{height} pixels";
            imgIcon.Image = new Bitmap(width, height, PixelFormat.Format32bppRgba, pixels);

            lblSize.Text     = "Size";
            lblSize.Visible  = true;
            txtSize.Visible  = true;
            pnlPanel.Visible = false;
        }
示例#3
0
        public void Update(byte[] data)
        {
            if (data == null)
            {
                imgIcon.Image     = null;
                lblSize.Text      = "No data";
                lblColors.Visible = false;
                lblSize.Visible   = false;
                txtColors.Visible = false;
                txtSize.Visible   = false;
                pnlPanel.Visible  = false;
                return;
            }

            libexeinfo.Windows.DecodedBitmap icon;

            try { icon = Bitmap.DecodeIcon(data); }
            catch { icon = null; }

            if (icon == null)
            {
                imgIcon.Image     = null;
                lblSize.Text      = "Undecoded";
                lblColors.Visible = false;
                lblSize.Visible   = false;
                txtColors.Visible = false;
                txtSize.Visible   = false;
                pnlPanel.Visible  = true;
                panelHexDump.Update(data);
                return;
            }

            txtSize.Text   = $"{icon.Width}x{icon.Height} pixels";
            txtColors.Text = $"{1 << (int)icon.BitsPerPixel} ({icon.BitsPerPixel} bpp)";
            imgIcon.Image  =
                new Eto.Drawing.Bitmap((int)icon.Width, (int)icon.Height, PixelFormat.Format32bppRgba, icon.Pixels);

            lblSize.Text      = "Size";
            lblColors.Visible = true;
            lblSize.Visible   = true;
            txtColors.Visible = true;
            txtSize.Visible   = true;
            pnlPanel.Visible  = false;
        }
示例#4
0
        void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
        {
            if (((TreeGridItem)treeResources.SelectedItem)?.Values[3] == null)
            {
                pnlResource.Content = null;
                return;
            }

            byte[] data = ((TreeGridItem)treeResources.SelectedItem)?.Values[3] as byte[];
            string type = ((TreeGridItem)treeResources.SelectedItem)?.Values[2] as string;

            switch (type)
            {
            case "RT_STRING":
                pnlResource.Content = panelPeStrings;
                panelPeStrings.Update(data);
                break;

            case "RT_ICON":
                pnlResource.Content = panelWindowsIcon;
                panelWindowsIcon.Update(data);
                break;

            case "RT_VERSION":
                pnlResource.Content = panelPeVersion;
                panelPeVersion.Update(data);
                break;

            case "RT_MANIFEST":
                pnlResource.Content = panelText;
                panelText.Update(data, Encoding.UTF8);
                break;

            default:
                pnlResource.Content = panelHexDump;
                panelHexDump.Update(data);
                break;
            }
        }
示例#5
0
        void TreeResourcesOnSelectionChanged(object sender, EventArgs eventArgs)
        {
            if (((TreeGridItem)treeResources.SelectedItem)?.Values[4] == null)
            {
                pnlResource.Content = null;
                return;
            }

            byte[] data = ((TreeGridItem)treeResources.SelectedItem)?.Values[4] as byte[];
            string type = ((TreeGridItem)treeResources.SelectedItem)?.Values[3] as string;

            switch (type)
            {
            case Consts.B_MIME_STRING_TYPE:
                pnlResource.Content = panelText;
                panelText.Update(data, Encoding.ASCII);
                break;

            case Consts.B_LARGE_ICON_TYPE:
            case Consts.B_MINI_ICON_TYPE:
            case Consts.B_PNG_FORMAT:
                pnlResource.Content = panelBeIcon;
                panelBeIcon.Update(data, type);
                break;

            case Consts.B_VERSION_INFO_TYPE:
                pnlResource.Content = panelBeVersion;
                panelBeVersion.Update(data, bigEndian);
                break;

            default:
                pnlResource.Content = panelHexDump;
                panelHexDump.Update(data);
                break;
            }
        }
示例#6
0
        public void Update(byte[] data)
        {
            if (data == null)
            {
                imgIcon.Image     = null;
                grdIcons.Visible  = false;
                lblType.Text      = "No data";
                lblColors.Visible = false;
                lblSize.Visible   = false;
                txtType.Visible   = false;
                txtColors.Visible = false;
                txtSize.Visible   = false;
                pnlPanel.Visible  = false;
                return;
            }

            DecodedBitmap[] icons = Bitmap.DecodeBitmap(data);

            if (icons == null || icons.Length == 0)
            {
                try
                {
                    libexeinfo.Windows.DecodedBitmap winIcon = null;

                    if (BitConverter.ToUInt32(data, 4) == 40)
                    {
                        byte[] cursor = new byte[data.Length - 4];
                        Array.Copy(data, 4, cursor, 0, cursor.Length);
                        winIcon = libexeinfo.Windows.Bitmap.DecodeIcon(cursor);
                    }
                    else if (BitConverter.ToUInt32(data, 0) == 40)
                    {
                        winIcon = libexeinfo.Windows.Bitmap.DecodeIcon(data);
                    }

                    if (winIcon != null)
                    {
                        icons = new[]
                        {
                            new DecodedBitmap
                            {
                                BitsPerPixel = winIcon.BitsPerPixel,
                                Height       = winIcon.Height,
                                Pixels       = winIcon.Pixels,
                                Type         = "Windows cursor",
                                Width        = winIcon.Width
                            }
                        }
                    }
                    ;
                }
                catch { icons = null; }
            }

            if (icons == null || icons.Length == 0)
            {
                imgIcon.Image     = null;
                grdIcons.Visible  = false;
                lblType.Text      = "Undecoded";
                lblColors.Visible = false;
                lblSize.Visible   = false;
                txtType.Visible   = false;
                txtColors.Visible = false;
                txtSize.Visible   = false;
                pnlPanel.Visible  = true;
                panelHexDump.Update(data);
                return;
            }

            txtType.Text   = icons[0].Type;
            txtSize.Text   = $"{icons[0].Width}x{icons[0].Height} pixels";
            txtColors.Text = $"{1 << (int)icons[0].BitsPerPixel} ({icons[0].BitsPerPixel} bpp)";
            imgIcon.Image  = new Eto.Drawing.Bitmap((int)icons[0].Width, (int)icons[0].Height,
                                                    PixelFormat.Format32bppRgba, icons[0].Pixels);
            grdIcons.DataStore   = icons;
            grdIcons.SelectedRow = 0;
            grdIcons.Visible     = icons.Length != 1;

            lblType.Text      = "Type";
            lblColors.Visible = true;
            lblSize.Visible   = true;
            txtType.Visible   = true;
            txtColors.Visible = true;
            txtSize.Visible   = true;
            pnlPanel.Visible  = false;
        }