Esempio n. 1
0
        public override CodeSourceCollection CreateSources(string aFileName)
        {
            SIImage image = SIImage.New(base.Tracer, aFileName);

            if (image == null)
            {
                throw new NotSupportedException("The specified image file is not supported");
            }

            // We need to make a source and (single) collection for each content object within the image.
            // This enables relocation support when an image is actually used (i.e. read & decompress code
            // on demand, rather than up front).
            CodeSourceCollection sources = new CodeSourceCollection();

            //
            foreach (SIContent content in image)
            {
                CodeCollection collection = CodeCollection.New(base.IdAllocator, aFileName, content.FileName);
                collection.IsRelocatable = content.IsRelocationSupported;

                // The URI must be unique
                string    uri    = string.Format("{0} [{1}]", aFileName, content.FileName);
                ImgSource source = new ImgSource(uri, this, collection, content);
                sources.Add(source);
            }
            //
            return(sources);
        }
        internal SIHeaderE32Image(SIImage aImage, SymbianStreamReaderLE aReader)
            : base(aImage)
        {
            long startPos = aReader.Position;

            //
            iUids      = new TCheckedUid(aReader);
            iSignature = aReader.ReadUInt32();
            //
            if (iSignature != KExpectedSignatureUInt32)   // 'EPOC'
            {
                throw new E32ImageNotSupportedException("Invalid signature");
            }
            //
            iHeaderCrc       = aReader.ReadUInt32();
            iModuleVersion   = aReader.ReadUInt32();
            iCompressionType = SIHeaderE32Image.ReadCompressionType(aReader);
            iToolsVersion    = new TVersion(aReader);
            iTimeLo          = aReader.ReadUInt32();
            iTimeHi          = aReader.ReadUInt32();
            iFlags           = aReader.ReadUInt32();
            //
            iCodeSize    = aReader.ReadInt32();
            iDataSize    = aReader.ReadInt32();
            iHeapSizeMin = aReader.ReadInt32();
            iHeapSizeMax = aReader.ReadInt32();
            iStackSize   = aReader.ReadInt32();
            iBssSize     = aReader.ReadInt32();
            //
            iEntryPoint = aReader.ReadUInt32();
            iCodeBase   = aReader.ReadUInt32();
            iDataBase   = aReader.ReadUInt32();
            //
            iDllRefTableCount = aReader.ReadInt32();
            iExportDirOffset  = aReader.ReadUInt32();
            iExportDirCount   = aReader.ReadInt32();
            //
            iTextSize        = aReader.ReadInt32();
            iCodeOffset      = aReader.ReadUInt32();
            iDataOffset      = aReader.ReadUInt32();
            iImportOffset    = aReader.ReadUInt32();
            iCodeRelocOffset = aReader.ReadUInt32();
            iDataRelocOffset = aReader.ReadUInt32();
            //
            iProcessPriority = aReader.ReadInt16();
            //
            iCpuIdentifier = aReader.ReadUInt16();
            //
            iUncompressedSize = aReader.ReadUInt32();
            //
            iS = new SSecurityInfo(aReader);
            iExceptionDescriptor = aReader.ReadUInt32();
            iSpare2         = aReader.ReadUInt16();
            iExportDescSize = aReader.ReadUInt16();
            iExportDescType = aReader.ReadUInt8();
            //
            iHeaderSize = (uint)(aReader.Position - startPos);
        }
Esempio n. 3
0
        public override SIImage CreateImage(ITracer aTracer, Stream aStream, string aName)
        {
            SIImage ret = null;
            //
            bool isSupported = SIROFS.IsROFS(aStream);

            if (isSupported)
            {
                ret = new SIROFS(aTracer, aStream, aName);
            }
            //
            return(ret);
        }
        public override SIImage CreateImage(ITracer aTracer, Stream aStream, string aName)
        {
            SIImage ret = null;
            //
            bool isSupported = SymbianImageE32.IsImageFile(aStream);

            if (isSupported)
            {
                ret = new SymbianImageE32(aName, (uint)aStream.Length, aStream.Position, new SIStream(aStream), aTracer);
            }
            //
            return(ret);
        }
Esempio n. 5
0
        protected SIHeaderROF(SIImage aImage, Stream aStream)
            : base(aImage)
        {
            // Skip over identifier
            aStream.Seek(4, SeekOrigin.Begin);

            // Read header size and then put us back at the start of the stream
            // ready to read the entire header.
            int headerSize = aStream.ReadByte();

            aStream.Seek(0, SeekOrigin.Begin);
            //
            iHeaderData = new byte[headerSize];
            aStream.Read(iHeaderData, 0, iHeaderData.Length);
            //
            ReadHeaderData(iHeaderData);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
 protected SIContent(SIImage aImage)
 {
     iImage = aImage;
 }
Esempio n. 9
0
 public SIHeaderROFX(SIImage aImage, Stream aStream)
     : base(aImage, aStream)
 {
 }
Esempio n. 10
0
 protected SIHeader(SIImage aImage)
 {
     iImage = aImage;
 }