internal SBL3(string FileName) { Binary = null; // First try to parse as FFU try { if (FFU.IsFFU(FileName)) { FFU FFUFile = new(FileName); Binary = FFUFile.GetPartition("SBL3"); } } catch { } // If not succeeded, then try to parse it as raw image if (Binary == null) { byte[] SBL3Pattern = new byte[] { 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF }; byte[] SBL3Mask = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; UInt32?Offset = ByteOperations.FindPatternInFile(FileName, SBL3Pattern, SBL3Mask, out byte[] SBL3Header); if (Offset != null) { UInt32 Length = ByteOperations.ReadUInt32(SBL3Header, 0x10) + 0x28; // SBL3 Image Size + Header Size Binary = new byte[Length]; FileStream Stream = new(FileName, FileMode.Open, FileAccess.Read); Stream.Seek((long)Offset, SeekOrigin.Begin); Stream.Read(Binary, 0, (int)Length); Stream.Close(); } } }