Exemplo n.º 1
0
        public const int KMinimumSize = 16 + 4; // Enough to read UIDs + signature
        #endregion

        #region API
        public static bool IsSymbianImageHeader(byte[] aHeader)
        {
            // We expect to see 16 bytes (3 x UID, 1 x UID checksum) and then
            // the magic word EPOC
            bool ret = false;

            //
            if (aHeader.Length >= KMinimumSize)
            {
                // We expect 16 bytes are the UID + checksum. Next should be the signature.
                string sig = StringParsingUtils.BytesToString(aHeader, 16, 20);
                ret = (sig == KExpectedSignature);
            }
            //
            return(ret);
        }
Exemplo n.º 2
0
        public SIHeaderROM(SIImage aImage, Stream aStream)
            : base(aImage)
        {
            aStream.Seek(0, SeekOrigin.Begin);
            //
            iHeaderData = new byte[KMaximumRomHeaderSize];
            int amountRead = aStream.Read(iHeaderData, 0, KMaximumRomHeaderSize);
            //
            string headerText = StringParsingUtils.BytesToString(iHeaderData, KEpocHeaderLength);

            base.Trace("[SymbianImageHeaderROM] Ctor() - headerText: {0}, amountRead: {1}", headerText, amountRead);
            //
            if (IsEpocHeader(headerText) == false)
            {
                throw new NotSupportedException(string.Format("ROM Image header is unsupported: {0}", headerText));
            }
            //
            ReadHeaderData(iHeaderData);
        }
Exemplo n.º 3
0
        public static SIHeaderROF New(SIImage aImage, Stream aStream)
        {
            byte[] signature  = new byte[4];
            int    readResult = aStream.Read(signature, 0, signature.Length);

            if (readResult != 4)
            {
                throw new Exception("Unable to read ROF signature");
            }

            // Put us back where we were
            aStream.Seek(-signature.Length, SeekOrigin.Current);

            // Convert signature to string and compare against known types.
            string headerText = StringParsingUtils.BytesToString(signature);

            aImage.Trace("[SymbianImageHeaderROF] New() - headerText: {0}", headerText);
            //
            SIHeaderROF ret = null;

            switch (headerText)
            {
            case "ROFX":
                ret = new SIHeaderROFS(aImage, aStream);
                break;

            case "ROFS":
                ret = new SIHeaderROFX(aImage, aStream);
                break;

            default:
                throw new NotSupportedException("Unsupported ROF type");
            }
            //
            return(ret);
        }