Exemplo n.º 1
0
        public VCSubfragment(BinaryReader reader, VCFragment parentFragment, CTFLanguage language, long baseAddress)
        {
            // see DIOpenCBF_FragValHandle
            reader.BaseStream.Seek(baseAddress, SeekOrigin.Begin);
            ulong bitflags = reader.ReadUInt16();

            Name_CTF = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            if (parentFragment.CCFHandle == 5)
            {
                // fragment should be parsed as PBSGetDumpAsStringFn, though internally we perceive this as the same
            }
            Dump                     = CaesarReader.ReadBitflagDumpWithReader(ref bitflags, reader, parentFragment.VarcodeDumpSize, baseAddress);
            Description_CTF          = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            QualifierUsuallyDisabled = CaesarReader.ReadBitflagStringWithReader(ref bitflags, reader, baseAddress);
            Unk3                     = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            Unk4                     = CaesarReader.ReadBitflagInt16(ref bitflags, reader, -1);
            SupplementKey            = CaesarReader.ReadBitflagStringWithReader(ref bitflags, reader, baseAddress);
            NameCTFResolved          = language.GetString(Description_CTF);

            //int subfragmentIdk2 = reader.ReadInt32();
            //int subfragmentName = reader.ReadInt32();
            //int subfragmentIdkIncremented = reader.ReadInt32();
            //Console.WriteLine($"Subfragment: {subfragmentIdk1:X} {subfragmentIdk2:X} {language.GetString(subfragmentName)} {subfragmentIdkIncremented:X}");
            //PrintDebug();
        }
Exemplo n.º 2
0
        private void CreateEnvironmentContexts(ECU parentEcu, CTFLanguage language)
        {
            /*
             * EnvironmentContexts = new EnvironmentContext[EnvironmentContextsPoolOffsets.Count];
             *
             * foreach (EnvironmentContext env in parentEcu.GlobalEnvironmentContexts)
             * {
             *  for (int i = 0; i < EnvironmentContextsPoolOffsets.Count; i++)
             *  {
             *      if (env.PoolIndex == EnvironmentContextsPoolOffsets[i])
             *      {
             *          EnvironmentContexts[i] = env;
             *      }
             *  }
             * }
             */
            EnvironmentContexts = new DiagService[EnvironmentContextsPoolOffsets.Count];

            foreach (DiagService env in parentEcu.GlobalEnvironmentContexts)
            {
                for (int i = 0; i < EnvironmentContextsPoolOffsets.Count; i++)
                {
                    if (env.PoolIndex == EnvironmentContextsPoolOffsets[i])
                    {
                        EnvironmentContexts[i] = env;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public Scale(BinaryReader reader, long baseAddress, CTFLanguage language)
        {
            BaseAddress = baseAddress;
            Language    = language;

            reader.BaseStream.Seek(BaseAddress, SeekOrigin.Begin);

            ulong bitflags = reader.ReadUInt16();

            Unk1 = CaesarReader.ReadBitflagInt32(ref bitflags, reader);         // typically qualifier
            Unk2 = CaesarReader.ReadBitflagInt32(ref bitflags, reader);         // typically description

            PrepLowBound = CaesarReader.ReadBitflagInt32(ref bitflags, reader); // could be float
            PrepUpBound  = CaesarReader.ReadBitflagInt32(ref bitflags, reader); // could be float

            MultiplyFactor = CaesarReader.ReadBitflagFloat(ref bitflags, reader);
            AddConstOffset = CaesarReader.ReadBitflagFloat(ref bitflags, reader);

            SICount  = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            OffsetSI = CaesarReader.ReadBitflagInt32(ref bitflags, reader);

            USCount  = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            OffsetUS = CaesarReader.ReadBitflagInt32(ref bitflags, reader);

            EnumDescription = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            UnkC            = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
        }
Exemplo n.º 4
0
        public void CreateDiagServices(BinaryReader reader, CTFLanguage language)
        {
            byte[] diagjobPool = ReadDiagjobPool(reader);
            // arrays since list has become too expensive
            DiagService[] globalDiagServices = new DiagService[DiagJob_EntryCount];


            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(diagjobPool)))
            {
                for (int diagjobIndex = 0; diagjobIndex < DiagJob_EntryCount; diagjobIndex++)
                {
                    int  offset             = poolReader.ReadInt32();
                    int  size               = poolReader.ReadInt32();
                    uint crc                = poolReader.ReadUInt32();
                    uint config             = poolReader.ReadUInt16();
                    long diagjobBaseAddress = offset + DiagJob_BlockOffset;
                    // Console.WriteLine($"DJ @ {offset:X} with size {size:X}");

                    DiagService dj = new DiagService(reader, language, diagjobBaseAddress, diagjobIndex, this);
                    // GlobalDiagServices.Add(dj);
                    globalDiagServices[diagjobIndex] = dj;
                }
            }

            GlobalDiagServices = new List <DiagService>(globalDiagServices);
        }
Exemplo n.º 5
0
        public void CreateEcuVariants(BinaryReader reader, CTFLanguage language)
        {
            ECUVariants.Clear();
            byte[] ecuVariantPool = ReadVariantPool(reader);

            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(ecuVariantPool)))
            {
                for (int ecuVariantIndex = 0; ecuVariantIndex < EcuVariant_EntryCount; ecuVariantIndex++)
                {
                    poolReader.BaseStream.Seek(ecuVariantIndex * EcuVariant_EntrySize, SeekOrigin.Begin);

                    int    entryOffset         = poolReader.ReadInt32();
                    int    entrySize           = poolReader.ReadInt32();
                    ushort poolEntryAttributes = poolReader.ReadUInt16();
                    long   variantBlockAddress = entryOffset + EcuVariant_BlockOffset;

                    ECUVariant variant = new ECUVariant(reader, this, language, variantBlockAddress, entrySize);
                    ECUVariants.Add(variant);
                    // Console.WriteLine($"Variant Entry @ 0x{entryOffset:X} with size 0x{entrySize:X} and CRC {poolEntryAttributes:X8}, abs addr {variantBlockAddress:X8}");

#if DEBUG
                    int resultLimit = 1999;
                    if (ecuVariantIndex >= resultLimit)
                    {
                        Console.WriteLine($"Breaking prematurely to create only {resultLimit} variant(s) (debug)");
                        break;
                    }
#endif
                }
            }
        }
Exemplo n.º 6
0
        // void __cdecl DiagServiceReadPresentation(int *inBase, DECODED_PRESENTATION *outPresentation)
        // Looks like its actually a presentation
        // See DIDiagservice* functions
        public DiagPreparation(BinaryReader reader, CTFLanguage language, long baseAddress, int bitPosition, ushort modeConfig, ECU parentEcu, DiagService parentDiagService)
        {
            BitPosition       = bitPosition;
            ModeConfig        = modeConfig;
            Language          = language;
            BaseAddress       = baseAddress;
            ParentECU         = parentEcu;
            ParentDiagService = parentDiagService;

            reader.BaseStream.Seek(baseAddress, SeekOrigin.Begin);
            ulong bitflags = reader.ReadUInt32();


            Qualifier           = CaesarReader.ReadBitflagStringWithReader(ref bitflags, reader, baseAddress);
            Name_CTF            = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            Unk1                = CaesarReader.ReadBitflagUInt8(ref bitflags, reader);
            Unk2                = CaesarReader.ReadBitflagUInt8(ref bitflags, reader);
            AlternativeBitWidth = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            IITOffset           = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            InfoPoolIndex       = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            PresPoolIndex       = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            Field1E             = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            SystemParam         = CaesarReader.ReadBitflagInt16(ref bitflags, reader, -1);
            DumpMode            = CaesarReader.ReadBitflagInt16(ref bitflags, reader);
            DumpSize            = CaesarReader.ReadBitflagInt32(ref bitflags, reader);
            if (DumpMode == 5)
            {
                // dump is actually a string, use
                // CaesarReader.ReadBitflagDumpWithReaderAsString
            }
            Dump = CaesarReader.ReadBitflagDumpWithReader(ref bitflags, reader, DumpSize, baseAddress);

            SizeInBits = GetSizeInBits(reader);
            // PrintDebug();
        }
Exemplo n.º 7
0
        public CTFHeader(BinaryReader reader, long baseAddress, int headerSize)
        {
            BaseAddress = baseAddress;
            reader.BaseStream.Seek(BaseAddress, SeekOrigin.Begin);
            ulong ctfBitflags = reader.ReadUInt16();

            CtfUnk1                = CaesarReader.ReadBitflagInt32(ref ctfBitflags, reader);
            Qualifier              = CaesarReader.ReadBitflagStringWithReader(ref ctfBitflags, reader, BaseAddress);
            CtfUnk3                = CaesarReader.ReadBitflagInt16(ref ctfBitflags, reader);
            CtfUnk4                = CaesarReader.ReadBitflagInt32(ref ctfBitflags, reader);
            CtfLanguageCount       = CaesarReader.ReadBitflagInt32(ref ctfBitflags, reader);
            CtfLanguageTableOffset = CaesarReader.ReadBitflagInt32(ref ctfBitflags, reader);
            CtfUnkString           = CaesarReader.ReadBitflagStringWithReader(ref ctfBitflags, reader, BaseAddress);

            long ctfLanguageTableOffsetRelativeToDefintions = CtfLanguageTableOffset + BaseAddress;

            // parse every language record
            CtfLanguages = new List <CTFLanguage>();
            for (int languageEntry = 0; languageEntry < CtfLanguageCount; languageEntry++)
            {
                long languageTableEntryOffset = ctfLanguageTableOffsetRelativeToDefintions + (languageEntry * 4);

                reader.BaseStream.Seek(languageTableEntryOffset, SeekOrigin.Begin);
                long        realLanguageEntryAddress = reader.ReadInt32() + ctfLanguageTableOffsetRelativeToDefintions;
                CTFLanguage language = new CTFLanguage(reader, realLanguageEntryAddress, headerSize);
                CtfLanguages.Add(language);
            }
        }
Exemplo n.º 8
0
 public void Restore(CTFLanguage language, ECU parentEcu)
 {
     ParentECU = parentEcu;
     foreach (VCFragment fragment in VCFragments)
     {
         fragment.Restore(parentEcu, this, language);
     }
 }
Exemplo n.º 9
0
 public void Restore(CTFLanguage language)
 {
     Language = language;
     foreach (ComParameter cp in CommunicationParameters)
     {
         cp.Restore(language);
     }
 }
Exemplo n.º 10
0
 public void Restore(CTFLanguage language)
 {
     Language = language;
     foreach (Scale s in Scales)
     {
         s.Restore(language);
     }
 }
Exemplo n.º 11
0
 public void Restore(ECU parentEcu, VCDomain parentDomain, CTFLanguage language)
 {
     ParentECU    = parentEcu;
     ParentDomain = parentDomain;
     foreach (VCSubfragment subfragment in Subfragments)
     {
         subfragment.Restore(language);
     }
 }
Exemplo n.º 12
0
 private void CreateVCDomains(BinaryReader reader, ECU parentEcu, CTFLanguage language)
 {
     VCDomains = new List <VCDomain>();
     foreach (int variantCodingDomainEntry in VCDomainPoolOffsets)
     {
         VCDomain vcDomain = new VCDomain(reader, parentEcu, language, variantCodingDomainEntry);
         VCDomains.Add(vcDomain);
     }
 }
Exemplo n.º 13
0
 private void CreateXrefs(BinaryReader reader, ECU parentEcu, CTFLanguage language)
 {
     Xrefs = new int[Xref_Count];
     reader.BaseStream.Seek(BaseAddress + Xref_Offset, SeekOrigin.Begin);
     for (int i = 0; i < Xref_Count; i++)
     {
         Xrefs[i] = reader.ReadInt32();
     }
 }
Exemplo n.º 14
0
 public void CreateUnk(BinaryReader reader, CTFLanguage language)
 {
     byte[] unkPool = ReadECUUnkPool(reader);
     using (BinaryReader poolReader = new BinaryReader(new MemoryStream(unkPool)))
     {
         for (int unkIndex = 0; unkIndex < Unk_EntryCount; unkIndex++)
         {
         }
     }
 }
Exemplo n.º 15
0
        private void CreateDTCs(ECU parentEcu, CTFLanguage language)
        {
            int dtcPoolSize = DTCsPoolOffsetsWithBounds.Count;

            DTCs = new DTC[dtcPoolSize];

            for (int i = 0; i < dtcPoolSize; i++)
            {
                if (i == DTCsPoolOffsetsWithBounds[i].Item1)
                {
                    DTCs[i]           = parentEcu.GlobalDTCs[i];
                    DTCs[i].XrefStart = DTCsPoolOffsetsWithBounds[i].Item2;
                    DTCs[i].XrefCount = DTCsPoolOffsetsWithBounds[i].Item3;
                }
            }
            DTCsPoolOffsetsWithBounds.Sort((x, y) => x.Item1.CompareTo(y.Item1));
            int lowestIndex = 0;
            int loopMax     = ParentECU.GlobalDTCs.Count;

            for (int i = 0; i < dtcPoolSize; i++)
            {
                if (DTCs[i] != null)
                {
                    continue;
                }
                for (int globalIndex = lowestIndex; globalIndex < loopMax; globalIndex++)
                {
                    if (ParentECU.GlobalDTCs[globalIndex].PoolIndex == DTCsPoolOffsetsWithBounds[i].Item1)
                    {
                        DTCs[i]           = parentEcu.GlobalDTCs[globalIndex];
                        DTCs[i].XrefStart = DTCsPoolOffsetsWithBounds[i].Item2;
                        DTCs[i].XrefCount = DTCsPoolOffsetsWithBounds[i].Item3;
                        lowestIndex       = globalIndex;
                        break;
                    }
                }
            }

            /*
             * // same thing as above, just more readable and slower
             * foreach (DTC dtc in parentEcu.GlobalDTCs)
             * {
             *  for (int i = 0; i < DTCsPoolOffsetsWithBounds.Count; i++)
             *  {
             *      if (dtc.PoolIndex == DTCsPoolOffsetsWithBounds[i].Item1)
             *      {
             *          // this is only valid on the assumption that DTC instances are unique (e.g. not shared from a base variant)
             *          dtc.XrefStart = DTCsPoolOffsetsWithBounds[i].Item2;
             *          dtc.XrefCount = DTCsPoolOffsetsWithBounds[i].Item3;
             *          DTCs[i] = dtc;
             *      }
             *  }
             * }
             */
        }
Exemplo n.º 16
0
        private void CreateDiagServices(ECU parentEcu, CTFLanguage language)
        {
            // unlike variant domains, storing references to the parent objects in the ecu is preferable since this is relatively larger
            //DiagServices = new List<DiagService>();

            DiagServices = new DiagService[DiagServicesPoolOffsets.Count];

            /*
             * // computationally expensive, 40ish % runtime is spent here
             * // easier to read, below optimization essentially accomplishes this in a shorter period
             *
             * foreach (DiagService diagSvc in parentEcu.GlobalDiagServices)
             * {
             *  for (int i = 0; i < DiagServicesPoolOffsets.Count; i++)
             *  {
             *      if (diagSvc.PoolIndex == DiagServicesPoolOffsets[i])
             *      {
             *          DiagServices[i] = diagSvc;
             *      }
             *  }
             * }
             */
            // optimization hack
            int poolSize = DiagServicesPoolOffsets.Count;

            for (int i = 0; i < poolSize; i++)
            {
                if (i == DiagServicesPoolOffsets[i])
                {
                    DiagServices[i] = parentEcu.GlobalDiagServices[i];
                }
            }
            DiagServicesPoolOffsets.Sort();
            int lowestIndex = 0;
            int loopMax     = parentEcu.GlobalDiagServices.Count;

            for (int i = 0; i < poolSize; i++)
            {
                if (DiagServices[i] != null)
                {
                    continue;
                }
                for (int globalIndex = lowestIndex; globalIndex < loopMax; globalIndex++)
                {
                    if (parentEcu.GlobalDiagServices[globalIndex].PoolIndex == DiagServicesPoolOffsets[i])
                    {
                        DiagServices[i] = parentEcu.GlobalDiagServices[globalIndex];
                        lowestIndex     = globalIndex;
                        break;
                    }
                }
            }
        }
Exemplo n.º 17
0
 private void CreateVCDomains(ECU parentEcu, CTFLanguage language)
 {
     VCDomains = new List <VCDomain>();
     foreach (int variantCodingDomainEntry in VCDomainPoolOffsets)
     {
         /*
          * VCDomain vcDomain = new VCDomain(reader, parentEcu, language, variantCodingDomainEntry);
          * VCDomains.Add(vcDomain);
          */
         VCDomains.Add(ParentECU.GlobalVCDs[variantCodingDomainEntry]);
     }
 }
Exemplo n.º 18
0
        public static CaesarContainer DeserializeContainer(string json)
        {
            CaesarContainer container = JsonConvert.DeserializeObject <CaesarContainer>(json);
            // at this point, the container needs to restore its internal object references before it is fully usable
            CTFLanguage language = container.CaesarCTFHeader.CtfLanguages[0];

            foreach (ECU ecu in container.CaesarECUs)
            {
                ecu.Restore(language, container);
            }

            return(container);
        }
Exemplo n.º 19
0
        private void CreateEnvironmentContexts(ECU parentEcu, CTFLanguage language)
        {
            int envPoolSize = EnvironmentContextsPoolOffsets.Count;

            EnvironmentContexts = new DiagService[envPoolSize];

            for (int i = 0; i < envPoolSize; i++)
            {
                if (i == EnvironmentContextsPoolOffsets[i])
                {
                    EnvironmentContexts[i] = parentEcu.GlobalEnvironmentContexts[i];
                }
            }
            EnvironmentContextsPoolOffsets.Sort();
            int lowestIndex = 0;
            int loopMax     = parentEcu.GlobalEnvironmentContexts.Count;

            for (int i = 0; i < envPoolSize; i++)
            {
                if (EnvironmentContexts[i] != null)
                {
                    continue;
                }
                for (int globalIndex = lowestIndex; globalIndex < loopMax; globalIndex++)
                {
                    if (parentEcu.GlobalEnvironmentContexts[globalIndex].PoolIndex == EnvironmentContextsPoolOffsets[i])
                    {
                        EnvironmentContexts[i] = parentEcu.GlobalEnvironmentContexts[globalIndex];
                        lowestIndex            = globalIndex;
                        break;
                    }
                }
            }

            /*
             * // same thing, more readable, much slower
             * foreach (DiagService env in parentEcu.GlobalEnvironmentContexts)
             * {
             *  for (int i = 0; i < EnvironmentContextsPoolOffsets.Count; i++)
             *  {
             *      if (env.PoolIndex == EnvironmentContextsPoolOffsets[i])
             *      {
             *          EnvironmentContexts[i] = env;
             *      }
             *  }
             * }
             */
        }
Exemplo n.º 20
0
 public void CreateVCDomains(BinaryReader reader, CTFLanguage language)
 {
     byte[]     vcPool     = ReadVarcodingPool(reader);
     VCDomain[] globalVCDs = new VCDomain[VcDomain_EntryCount];
     using (BinaryReader poolReader = new BinaryReader(new MemoryStream(vcPool)))
     {
         for (int vcdIndex = 0; vcdIndex < VcDomain_EntryCount; vcdIndex++)
         {
             int      entryOffset     = poolReader.ReadInt32();
             int      entrySize       = poolReader.ReadInt32();
             uint     entryCrc        = poolReader.ReadUInt32();
             long     vcdBlockAddress = entryOffset + VcDomain_BlockOffset;
             VCDomain vcd             = new VCDomain(reader, language, vcdBlockAddress, vcdIndex, this);
             globalVCDs[vcdIndex] = vcd;
         }
     }
     GlobalVCDs = new List <VCDomain>(globalVCDs);
 }
Exemplo n.º 21
0
        private void CreateDTCs(ECU parentEcu, CTFLanguage language)
        {
            DTCs = new DTC[DTCsPoolOffsetsWithBounds.Count];

            foreach (DTC dtc in parentEcu.GlobalDTCs)
            {
                for (int i = 0; i < DTCsPoolOffsetsWithBounds.Count; i++)
                {
                    if (dtc.PoolIndex == DTCsPoolOffsetsWithBounds[i].Item1)
                    {
                        // this is only valid on the assumption that DTC instances are unique (e.g. not shared from a base variant)
                        dtc.XrefStart = DTCsPoolOffsetsWithBounds[i].Item2;
                        dtc.XrefCount = DTCsPoolOffsetsWithBounds[i].Item3;
                        DTCs[i]       = dtc;
                    }
                }
            }
        }
Exemplo n.º 22
0
        public void CreateDTCs(BinaryReader reader, CTFLanguage language)
        {
            byte[] dtcPool    = ReadECUDtcPool(reader);
            DTC[]  globalDtcs = new DTC[Dtc_EntryCount];
            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(dtcPool)))
            {
                for (int dtcIndex = 0; dtcIndex < Dtc_EntryCount; dtcIndex++)
                {
                    int  offset         = poolReader.ReadInt32();
                    int  size           = poolReader.ReadInt32();
                    uint crc            = poolReader.ReadUInt32();
                    long dtcBaseAddress = offset + Dtc_BlockOffset;

                    DTC dtc = new DTC(reader, language, dtcBaseAddress, dtcIndex, this);
                    globalDtcs[dtcIndex] = dtc;
                }
            }
            GlobalDTCs = new List <DTC>(globalDtcs);
        }
Exemplo n.º 23
0
        public void CreateInternalPresentations(BinaryReader reader, CTFLanguage language)
        {
            byte[]             internalPresentationsPool   = ReadECUInternalPresentationsPool(reader);
            DiagPresentation[] globalInternalPresentations = new DiagPresentation[InternalPresentations_EntryCount];

            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(internalPresentationsPool)))
            {
                for (int internalPresentationsIndex = 0; internalPresentationsIndex < InternalPresentations_EntryCount; internalPresentationsIndex++)
                {
                    int offset = poolReader.ReadInt32();
                    int size   = poolReader.ReadInt32();

                    long             internalPresentationsBaseAddress = offset + InternalPresentations_BlockOffset;
                    DiagPresentation pres = new DiagPresentation(reader, internalPresentationsBaseAddress, internalPresentationsIndex, language);
                    globalInternalPresentations[internalPresentationsIndex] = pres;
                }
            }
            GlobalInternalPresentations = new List <DiagPresentation>(globalInternalPresentations);
        }
Exemplo n.º 24
0
        private void CreateDiagServices(BinaryReader reader, ECU parentEcu, CTFLanguage language)
        {
            // unlike variant domains, storing references to the parent objects in the ecu is preferable since this is relatively larger
            //DiagServices = new List<DiagService>();

            // computationally expensive, 40ish % runtime is spent here
            DiagServices = new DiagService[DiagServicesPoolOffsets.Count];

            foreach (DiagService diagSvc in parentEcu.GlobalDiagServices)
            {
                for (int i = 0; i < DiagServicesPoolOffsets.Count; i++)
                {
                    if (diagSvc.PoolIndex == DiagServicesPoolOffsets[i])
                    {
                        DiagServices[i] = diagSvc;
                    }
                }
            }
        }
Exemplo n.º 25
0
        public void Restore(CTFLanguage language, ECU parentEcu)
        {
            Language  = language;
            ParentECU = parentEcu;

            CreateVCDomains(parentEcu, language);
            CreateDiagServices(parentEcu, language);
            CreateDTCs(parentEcu, language);
            CreateEnvironmentContexts(parentEcu, language);

            /*
             * // no restoring required
             * foreach (ECUVariantPattern vp in VariantPatterns)
             * {
             *  vp.Restore();
             * }
             */
            // CreateComParameters(reader, parentEcu); // already serialized in json
        }
Exemplo n.º 26
0
 public void Restore(CTFLanguage language, CaesarContainer parentContainer)
 {
     Language        = language;
     ParentContainer = parentContainer;
     foreach (VCDomain vc in GlobalVCDs)
     {
         vc.Restore(language, this);
     }
     foreach (DTC dtc in GlobalDTCs)
     {
         dtc.Restore(language, this);
     }
     foreach (DiagService ds in GlobalDiagServices)
     {
         ds.Restore(language, this);
     }
     foreach (DiagService ds in GlobalEnvironmentContexts)
     {
         ds.Restore(language, this);
     }
     foreach (DiagPresentation pres in GlobalPresentations)
     {
         pres.Restore(language);
     }
     foreach (DiagPresentation pres in GlobalInternalPresentations)
     {
         pres.Restore(language);
     }
     foreach (ECUInterface iface in ECUInterfaces)
     {
         iface.Restore(language);
     }
     foreach (ECUInterfaceSubtype iface in ECUInterfaceSubtypes)
     {
         iface.Restore(language);
     }
     foreach (ECUVariant variant in ECUVariants)
     {
         variant.Restore(language, this);
     }
 }
Exemplo n.º 27
0
        public DTC(BinaryReader reader, CTFLanguage language, long baseAddress, int poolIndex, ECU parentEcu)
        {
            ParentECU   = parentEcu;
            PoolIndex   = poolIndex;
            BaseAddress = baseAddress;
            Language    = language;
            reader.BaseStream.Seek(baseAddress, SeekOrigin.Begin);

            ulong bitflags = reader.ReadUInt16();

            Qualifier = CaesarReader.ReadBitflagStringWithReader(ref bitflags, reader, baseAddress);

            Description_CTF = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
            Reference_CTF   = CaesarReader.ReadBitflagInt32(ref bitflags, reader, -1);
#if DEBUG
            if (bitflags > 0)
            {
                Console.WriteLine($"DTC {Qualifier} has additional unparsed fields : 0x{bitflags:X}");
            }
#endif
        }
Exemplo n.º 28
0
        public void CreateEnvironments(BinaryReader reader, CTFLanguage language)
        {
            /*
             * byte[] envPool = ReadECUEnvPool(reader);
             * EnvironmentContext[] globalEnvs = new EnvironmentContext[Env_EntryCount];
             * using (BinaryReader poolReader = new BinaryReader(new MemoryStream(envPool)))
             * {
             *  for (int envIndex = 0; envIndex < Env_EntryCount; envIndex++)
             *  {
             *      int offset = poolReader.ReadInt32();
             *      int size = poolReader.ReadInt32();
             *      long envBaseAddress = offset + Env_BlockOffset;
             *
             *      // Console.WriteLine($"0x{envBaseAddress:X}");
             *      EnvironmentContext env = new EnvironmentContext(reader, language, envBaseAddress, envIndex, this);
             *      globalEnvs[envIndex] = env;
             *  }
             * }
             * GlobalEnvironmentContexts = new List<EnvironmentContext>(globalEnvs);
             */
            byte[]        envPool    = ReadECUEnvPool(reader);
            DiagService[] globalEnvs = new DiagService[Env_EntryCount];
            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(envPool)))
            {
                for (int envIndex = 0; envIndex < Env_EntryCount; envIndex++)
                {
                    int  offset         = poolReader.ReadInt32();
                    int  size           = poolReader.ReadInt32();
                    long envBaseAddress = offset + Env_BlockOffset;

                    // Console.WriteLine($"0x{envBaseAddress:X}");
                    DiagService env = new DiagService(reader, language, envBaseAddress, envIndex, this);
                    globalEnvs[envIndex] = env;
                }
            }
            GlobalEnvironmentContexts = new List <DiagService>(globalEnvs);
        }
Exemplo n.º 29
0
        public void Restore(CTFLanguage language, ECU parentEcu)
        {
            Language  = language;
            ParentECU = parentEcu;
            foreach (DiagPreparation dp in InputPreparations)
            {
                dp.Restore(language, parentEcu, this);
            }
            foreach (List <DiagPreparation> dpl in OutputPreparations)
            {
                foreach (DiagPreparation dp in dpl)
                {
                    dp.Restore(language, parentEcu, this);
                }
            }

            /*
             * // nothing in comparam to restore
             * foreach (ComParameter cp in DiagComParameters)
             * {
             *
             * }
             */
        }
Exemplo n.º 30
0
        public void CreatePresentations(BinaryReader reader, CTFLanguage language)
        {
            byte[] presentationsPool = ReadECUPresentationsPool(reader);
            // arrays since list has become too expensive
            // DiagService[] globalDiagServices = new DiagService[DiagJob_EntryCount];
            DiagPresentation[] globalPresentations = new DiagPresentation[Presentations_EntryCount];

            using (BinaryReader poolReader = new BinaryReader(new MemoryStream(presentationsPool)))
            {
                for (int presentationsIndex = 0; presentationsIndex < Presentations_EntryCount; presentationsIndex++)
                {
                    int offset = poolReader.ReadInt32();
                    int size   = poolReader.ReadInt32();

                    long presentationsBaseAddress = offset + Presentations_BlockOffset;
                    // string offsetLog = $"Pres @ 0x{offset:X} with size 0x{size:X} base 0x{presentationsBaseAddress:X}";

                    DiagPresentation pres = new DiagPresentation(reader, presentationsBaseAddress, presentationsIndex, language);
                    globalPresentations[presentationsIndex] = pres;
                }
                // Console.WriteLine($"Entry count/size for presentations : {Presentations_EntryCount}, {Presentations_EntrySize}");
            }
            GlobalPresentations = new List <DiagPresentation>(globalPresentations);
        }