コード例 #1
0
ファイル: LoadOmf.cs プロジェクト: meloscheng/dos-debugger
        private static SegmentGroup ConvertGroupDefinition(
            GroupDefinition def, Dictionary <object, object> objectMap)
        {
            SegmentGroup group = new SegmentGroup();

            group.Name     = def.Name;
            group.Segments = new LogicalSegment[def.Segments.Count];
            for (int i = 0; i < group.Segments.Length; i++)
            {
                group.Segments[i] = (LogicalSegment)objectMap[def.Segments[i]];
            }
            return(group);
        }
コード例 #2
0
ファイル: LoadOmf.cs プロジェクト: meloscheng/dos-debugger
 private static SegmentGroup ConvertGroupDefinition(
     GroupDefinition def, Dictionary<object, object> objectMap)
 {
     SegmentGroup group = new SegmentGroup();
     group.Name = def.Name;
     group.Segments = new LogicalSegment[def.Segments.Count];
     for (int i = 0; i < group.Segments.Length; i++)
     {
         group.Segments[i] = (LogicalSegment)objectMap[def.Segments[i]];
     }
     return group;
 }
コード例 #3
0
ファイル: LoadOmf.cs プロジェクト: meloscheng/dos-debugger
        /// <summary>
        /// Returns null if LibraryEnd record is encountered before
        /// MODEND or MODEND32 record is encountered.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static ObjectModule LoadObject(FileFormats.Omf.Records.RecordContext context)
        {
            ObjectModule module = new ObjectModule();

            Dictionary <object, object> objectMap =
                new Dictionary <object, object>();

            // Convert meta-data.
            module.Name       = context.ObjectName;
            module.SourceName = context.SourceName;

            // Convert segments.
            foreach (SegmentDefinition def in context.Segments)
            {
                LogicalSegment segment = ConvertSegmentDefinition(def, objectMap, module);
                objectMap[def] = segment;
                module.Segments.Add(segment);
            }

            // Convert segment groups.
            foreach (GroupDefinition def in context.Groups)
            {
                SegmentGroup group = ConvertGroupDefinition(def, objectMap);
                module.Groups.Add(group);
                objectMap[def] = group;
            }

            // Convert external names.
            foreach (ExternalNameDefinition def in context.ExternalNames)
            {
                ExternalSymbol symbol = new ExternalSymbol
                {
                    Name      = def.Name,
                    TypeIndex = def.TypeIndex,
                };
                module.ExternalNames.Add(symbol);
                objectMap[def] = symbol;
            }

            // Convert aliases.
            foreach (AliasDefinition def in context.Aliases)
            {
                module.Aliases.Add(new SymbolAlias
                {
                    AliasName      = def.AliasName,
                    SubstituteName = def.SubstituteName
                });
            }

            // Convert public names.
            foreach (PublicNameDefinition def in context.PublicNames)
            {
                module.DefinedNames.Add(ConvertPublicNameDefinition(def, objectMap));
            }

            // Convert fixups.
            foreach (SegmentDefinition def in context.Segments)
            {
                LogicalSegment segment = (LogicalSegment)objectMap[def];
                foreach (FixupDefinition f in def.Fixups)
                {
                    segment.Fixups.Add(ConvertFixupDefinition(f, objectMap));
                }
            }

            return(module);
        }