internal override void Read(ModuleReader reader, MemberHeader header) { // Get the module. ChelaModule module = GetModule(); // Read the type. type = module.GetType(reader.ReadUInt()); // Read the number of indices. int numIndices = reader.ReadByte(); if (numIndices > 0) { indices = new IChelaType[numIndices]; } // Read the indices. for (int i = 0; i < numIndices; ++i) { indices[i] = module.GetType(reader.ReadUInt()); } // Read the get accessor. getAccessor = (Function)module.GetMember(reader.ReadUInt()); // Read the set accessor. setAccessor = (Function)module.GetMember(reader.ReadUInt()); }
private void ReadData() { // Only read once the data. if (readedData) { return; } readedData = true; ModuleReader reader = new ModuleReader(new MemoryStream(rawData)); // Get the module. ChelaModule module = GetModule(); // Read the template. template = (Structure)module.GetMember(reader.ReadUInt()); // Read the factory. factory = (Scope)module.GetMember(reader.ReadUInt()); // Read the generic instance. genericInstance = GenericInstance.Read(template.GetGenericPrototype(), reader, module); // Initialize. Initialize(template, genericInstance); rawData = null; }
internal override void Read(ModuleReader reader, MemberHeader header) { // Get the module. ChelaModule module = GetModule(); // Read the type. actualType = module.GetType(reader.ReadUInt()); }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the types into the member list. memberList = new List <Structure>(); int numtypes = (int)header.memberSize / 4; for (int i = 0; i < numtypes; ++i) { memberList.Add((Structure)GetModule().GetMember(reader.ReadUInt())); } }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the children. uint nummembers = header.memberSize / 4u; for (uint i = 0; i < nummembers; ++i) { uint child = reader.ReadUInt(); AddMember(GetModule().GetMember(child)); } }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the functions into the member list. memberList = new List <Function> (); int numfunctions = (int)header.memberSize / 4; for (int i = 0; i < numfunctions; ++i) { memberList.Add((Function)GetModule().GetMember(reader.ReadUInt())); } }
public static GenericInstance Read(GenericPrototype prototype, ModuleReader reader, ChelaModule module) { // Read the type count. int count = reader.ReadByte(); // Read the types. IChelaType[] types = new IChelaType[count]; for (int i = 0; i < count; ++i) { types[i] = module.GetType(reader.ReadUInt()); } // Create the readed instance. return(new GenericInstance(prototype, types)); }
public static void GetEmbeddedModule(ModuleReader reader) { // Read the MZ signature. if (reader.ReadByte() != 'M' || reader.ReadByte() != 'Z') { throw new ModuleException("Invalid PE signature."); } // Read the PE offset. reader.SetPosition(0x3c); uint peOffset = reader.ReadUInt(); // Read the PE\0\0 sinature reader.SetPosition(peOffset); if (reader.ReadByte() != 'P' || reader.ReadByte() != 'E' || reader.ReadByte() != 0 || reader.ReadByte() != 0) { throw new ModuleException("Unsupported MS DOS programs."); } // Read the COFF header. CoffHeader header = new CoffHeader(); header.Read(reader); // Ignore the optional header. reader.Skip(header.optionalHeaderSize); // Read the sections until finding the .cbm section. CoffSectionHeader sectionHeader = new CoffSectionHeader(); for (int i = 0; i < header.numSections; ++i) { // Read the section header. sectionHeader.Read(reader); // If this is the .cbm section, done. if (sectionHeader.name == ".cbm") { reader.SetPosition(sectionHeader.rawDataPointer); return; } } // Couldn't find embedded module. throw new ModuleException("Couldn't find embedded Chela module."); }
public static void GetEmbeddedModule(ModuleReader reader) { // Read the MZ signature. if(reader.ReadByte() != 'M' || reader.ReadByte() != 'Z') throw new ModuleException("Invalid PE signature."); // Read the PE offset. reader.SetPosition(0x3c); uint peOffset = reader.ReadUInt(); // Read the PE\0\0 sinature reader.SetPosition(peOffset); if(reader.ReadByte() != 'P' || reader.ReadByte() != 'E' || reader.ReadByte() != 0 || reader.ReadByte() != 0) throw new ModuleException("Unsupported MS DOS programs."); // Read the COFF header. CoffHeader header = new CoffHeader(); header.Read(reader); // Ignore the optional header. reader.Skip(header.optionalHeaderSize); // Read the sections until finding the .cbm section. CoffSectionHeader sectionHeader = new CoffSectionHeader(); for(int i = 0; i < header.numSections; ++i) { // Read the section header. sectionHeader.Read(reader); // If this is the .cbm section, done. if(sectionHeader.name == ".cbm") { reader.SetPosition(sectionHeader.rawDataPointer); return; } } // Couldn't find embedded module. throw new ModuleException("Couldn't find embedded Chela module."); }
internal override void Read(ModuleReader reader, MemberHeader header) { // Get the module. ChelaModule module = GetModule(); // Read the type. actualType = module.GetType(reader.ReadUInt()); }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the types into the member list. memberList = new List<Structure>(); int numtypes = (int)header.memberSize / 4; for (int i = 0; i < numtypes; ++i) memberList.Add((Structure)GetModule().GetMember (reader.ReadUInt ())); }
private void ReadData() { // Only read once the data. if(readedData) return; readedData = true; ModuleReader reader = new ModuleReader(new MemoryStream(rawData)); // Get the module. ChelaModule module = GetModule(); // Read the template. template = (Structure)module.GetMember(reader.ReadUInt()); // Read the factory. factory = (Scope)module.GetMember(reader.ReadUInt()); // Read the generic instance. genericInstance = GenericInstance.Read(template.GetGenericPrototype(), reader, module); // Initialize. Initialize(template, genericInstance); rawData = null; }
internal override void Read(ModuleReader reader, MemberHeader header) { // Get the module. ChelaModule module = GetModule(); // Read the type. type = module.GetType(reader.ReadUInt()); // Read the number of indices. int numIndices = reader.ReadByte(); if(numIndices > 0) indices = new IChelaType[numIndices]; // Read the indices. for(int i = 0; i < numIndices; ++i) indices[i] = module.GetType(reader.ReadUInt()); // Read the get accessor. getAccessor = (Function)module.GetMember(reader.ReadUInt()); // Read the set accessor. setAccessor = (Function)module.GetMember(reader.ReadUInt()); }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the children. uint nummembers = header.memberSize/4u; for(uint i = 0; i < nummembers; ++i) { uint child = reader.ReadUInt(); AddMember(GetModule().GetMember(child)); } }
internal override void Read(ModuleReader reader, MemberHeader header) { // Read the functions into the member list. memberList = new List<Function> (); int numfunctions = (int)header.memberSize/4; for(int i = 0; i < numfunctions; ++i) memberList.Add((Function)GetModule().GetMember(reader.ReadUInt())); }