コード例 #1
0
        private void ProcessExif(byte[] section)
        {
            int num1 = 6;

            byte[] numArray1 = section;
            int    index1    = num1;
            int    num2      = index1 + 1;

            if (numArray1[index1] != 0)
            {
                return;
            }

            byte[] numArray2 = section;
            int    index2    = num2;
            int    index3    = index2 + 1;

            if (numArray2[index2] != 0)
            {
                return;
            }

            if (section[index3] == 73 && section[index3 + 1] == 73)
            {
                _isLittleEndian = true;
            }
            else
            {
                if (section[index3] != 77 || section[index3 + 1] != 77)
                {
                    return;
                }
                _isLittleEndian = false;
            }
            int offset1 = index3 + 2;
            int num3    = ExifIo.ReadUShort(section, offset1, _isLittleEndian);
            int offset2 = offset1 + 2;

            if (num3 != 42)
            {
                return;
            }
            int num4 = ExifIo.ReadInt(section, offset2, _isLittleEndian);

            if ((num4 < 8 || num4 > 16) && (num4 < 16 || num4 > section.Length - 16))
            {
                return;
            }

            ProcessExifDir(section, num4 + 8, 8, section.Length - 8, 0, ExifIFD.Exif);
        }
コード例 #2
0
        private void ProcessExifDir(byte[] section, int offsetDir, int offsetBase, int length, int depth, ExifIFD ifd)
        {
            if (depth > 4)
            {
                return;
            }

            ushort num1 = ExifIo.ReadUShort(section, offsetDir, _isLittleEndian);

            if (offsetDir + 2 + 12 * num1 >= offsetDir + length)
            {
                return;
            }

            for (int num2 = 0; num2 < (int)num1; ++num2)
            {
                int     sectionOffset = DirOffset(offsetDir, num2);
                ExifTag exifTag       = new ExifTag(section, sectionOffset, offsetBase, length, _isLittleEndian);
                if (exifTag.IsValid)
                {
                    switch (exifTag.Tag)
                    {
                    case 34665:
                        int offsetDir1 = offsetBase + exifTag.GetInt(0);
                        if (offsetDir1 <= offsetBase + length)
                        {
                            ProcessExifDir(section, offsetDir1, offsetBase, length, depth + 1, ExifIFD.Exif);
                        }
                        continue;

                    case 34853:
                        int offsetDir2 = offsetBase + exifTag.GetInt(0);
                        if (offsetDir2 <= offsetBase + length)
                        {
                            ProcessExifDir(section, offsetDir2, offsetBase, length, depth + 1, ExifIFD.Gps);
                        }
                        continue;

                    default:
                        exifTag.Populate(Info, ifd);
                        continue;
                    }
                }
            }
            if (DirOffset(offsetDir, num1) + 4 <= offsetBase + length)
            {
                int num2 = ExifIo.ReadInt(section, offsetDir + 2 + 12 * num1, _isLittleEndian);
                if (num2 > 0)
                {
                    int offsetDir1 = offsetBase + num2;
                    if (offsetDir1 <= offsetBase + length && offsetDir1 >= offsetBase)
                    {
                        ProcessExifDir(section, offsetDir1, offsetBase, length, depth + 1, ifd);
                    }
                }
            }
            if (Info.ThumbnailData != null || Info.ThumbnailOffset <= 0 || Info.ThumbnailSize <= 0)
            {
                return;
            }

            Info.ThumbnailData = new byte[Info.ThumbnailSize];
            Array.Copy(section, offsetBase + Info.ThumbnailOffset, Info.ThumbnailData, 0, Info.ThumbnailSize);
        }