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); }
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); }
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); }
private static string ExtractParameters(ref string aText) { const string KOperatorChevronText = "operator <<"; // DoAppendFormatList<TDes16, (int)2>(T1&, const T3&, std::__va_list, T2*) // DoAppendFormatList<TDes16, (int)2>(T1&, TBuf<(int)256>, std::__va_list, T2*) // Method<TDes16>::Wibble( something ) // Method::Wibble( RPointerArray<HBufC> ) // RTest::operator ()(int, int, const unsigned short*) // TDesC16::Left(int) const // CObjectCon::AtL(int) const // User::Panic(const TDesC16&, int) // operator <<(RWriteStream&, const unsigned char&) // Handle special case of "operator <<" confusing matters string workingText = aText; int operatorOpeningChevronPos = aText.IndexOf(KOperatorChevronText); if (operatorOpeningChevronPos >= 0) { aText = aText.Substring(0, operatorOpeningChevronPos + KOperatorChevronText.Length); workingText = workingText.Substring(operatorOpeningChevronPos + KOperatorChevronText.Length); } else { aText = string.Empty; } string ret = string.Empty; // int closingPos = 0; int openingPos = 0; int templatePos = 0; // while (openingPos >= 0) { if (templatePos >= 0) { templatePos = workingText.IndexOf("<", templatePos); } openingPos = workingText.IndexOf("(", openingPos); if (templatePos >= 0 && templatePos < openingPos) { // Template region appears before the next bracket. Skip // over all characters until we hit the end of the template // section int endingPos = templatePos; StringParsingUtils.SkipToEndOfSection(ref workingText, ref endingPos, '<', '>'); if (endingPos < 0) { // Matching closing brace was never found - dealing with operator << ? templatePos = -1; } else { // Something like DoAppendFormatList<TDes16, (int)2>(T1&, const T3&, std::__va_list, T2*) ??? templatePos = endingPos; openingPos = endingPos; } } else if (openingPos >= 0) { // Skipped over any template nonsense. Work backward from the end // in order to locate start of parameters. closingPos = workingText.LastIndexOf(')'); openingPos = closingPos; StringParsingUtils.SkipToBeginningOfSection(ref workingText, ref openingPos, '(', ')'); string parameters = workingText.Substring(openingPos + 1, (closingPos - openingPos) - 1).Trim(); ret = parameters; workingText = workingText.Substring(0, openingPos + 1) + workingText.Substring(closingPos); aText = aText + workingText; break; } } // return(ret); }