Beispiel #1
0
        /// <summary>
        /// Read icon group from PE file header
        /// </summary>
        /// <param name="reader">reader that holds the PE image</param>
        /// <param name="iconImageData">all the ResourceEntry objects that hold the image data for the icon</param>
        public bool Read(BinaryReader reader, List<ResourceEntry> iconImageData)
        {
            try
            {
                Group = PEHeader.FromBinaryReader<GRPICONDIR>(reader);

                if (Group.idReserved != 0)
                {
                    RC.WriteWarning(0109, Rpx.Strings.Error_0109);

                    return false;
                }

                if (Group.idType != 1)
                {
                    RC.WriteWarning(0110, Rpx.Strings.Error_0110);

                    return false;
                }

                for (int i = 0; i < Group.idCount; i++)
                {
                    GRPICONDIRENTRY entry = PEHeader.FromBinaryReader<GRPICONDIRENTRY>(reader);

                    IconImage image = new IconImage();
                    image.Entry = entry;

                    foreach (ResourceEntry bmp in iconImageData)
                    {
                        if (bmp.Name == entry.ID)
                        {
                            image.Resource = bmp;

                            Entries.Add(image);

                            break;
                        }
                    }
                }

                return true;
            }
            catch (Exception ex)
            {
                RC.WriteException(0111, Rpx.Strings.Error_0111, ex);

                return false;
            }            
        }