Esempio n. 1
0
 private void ReadImports(Stream s)
 {
     imports     = new Dictionary <FBGuid, FBGuid>();
     importNames = new Dictionary <FBGuid, string>();
     if (guidCache == null)
     {
         for (int i = 0; i < header.importCount; i++)
         {
             imports.Add(new FBGuid(s), new FBGuid(s));
         }
     }
     else
     {
         for (int i = 0; i < header.importCount; i++)
         {
             FBGuid outside = new FBGuid(s);
             FBGuid inside  = new FBGuid(s);
             imports.Add(outside, inside);
             string ex = outside.ToString().Replace("-", "");
             if (guidCache.ContainsKey(ex))
             {
                 importNames.Add(outside, guidCache[ex]);
             }
         }
     }
 }
Esempio n. 2
0
 public EBXHeader(Stream s)
 {
     magic = Helpers.ReadUInt(s);
     if (magic != 0x0fb2d1ce)
     {
         return;
     }
     metaSize             = Helpers.ReadUInt(s);
     payloadSize          = Helpers.ReadUInt(s);
     importCount          = Helpers.ReadUInt(s);
     typeCount            = Helpers.ReadUShort(s);
     numGUIDRepeater      = Helpers.ReadUShort(s);
     unk01                = Helpers.ReadUShort(s);
     typeDescriptorCount  = Helpers.ReadUShort(s);
     fieldDescriptorCount = Helpers.ReadUShort(s);
     typeStringTableSize  = Helpers.ReadUShort(s);
     stringTableSize      = Helpers.ReadUInt(s);
     arrayCount           = Helpers.ReadUInt(s);
     arrayOffset          = Helpers.ReadUInt(s);
     GUID             = new FBGuid(s);
     unk02            = Helpers.ReadULong(s);
     arrayBlockOffset = metaSize + stringTableSize + arrayOffset;
     _isvalid         = true;
 }
Esempio n. 3
0
            public TreeNode ToNode(EBX ebx, Dictionary <FBGuid, FBGuid> imports, Dictionary <FBGuid, string> importNames)
            {
                TreeNode result = new TreeNode(ebx.keywords[layout.nameHash]);
                byte     t      = layout.GetFieldType();

                switch (t)
                {
                case 3:
                    if ((uint)data - 1 < ebx.nodelist.Count && (int)(uint)data > 0)
                    {
                        result.Text = "ref " + ebx.nodelist[(int)(uint)data - 1].Text;
                    }
                    else
                    {
                        int    idx        = (int)((uint)data & 0x7FFFFFFF);
                        string importname = "";
                        if (idx >= 0 && idx < imports.Count)
                        {
                            FBGuid guid = imports.Keys.ElementAt <FBGuid>(idx);
                            if (importNames.ContainsKey(guid))
                            {
                                importname = importNames[guid];
                            }
                        }
                        result.Nodes.Add("import ref " + idx + "(" + importname + ")");
                    }
                    break;

                case 0:
                case 2:
                    result.Nodes.Add(((EBXNodeType)data).ToNode(ebx, imports, importNames));
                    break;

                case 4:
                    List <EBXNodeField> list = (List <EBXNodeField>)data;
                    foreach (EBXNodeField field in list)
                    {
                        result.Nodes.Add(field.ToNode(ebx, imports, importNames));
                    }
                    break;

                case 7:
                case 8:
                    result.Nodes.Add((string)data);
                    break;

                case 0xA:
                case 0xB:
                case 0xC:
                    result.Nodes.Add(((byte)data).ToString("X"));
                    break;

                case 0xD:
                case 0xE:
                    result.Nodes.Add(((ushort)data).ToString("X"));
                    break;

                case 0xF:
                case 0x10:
                    result.Nodes.Add(((uint)data).ToString("X"));
                    break;

                case 0x13:
                    result.Nodes.Add(((float)data).ToString());
                    break;

                case 0x09:
                case 0x19:
                case 0x11:
                case 0x12:
                case 0x14:
                case 0x17:
                    result.Nodes.Add(((ulong)data).ToString("X"));
                    break;

                case 0x15:
                case 0x16:
                    string s = "";
                    foreach (byte b in (byte[])data)
                    {
                        s += b.ToString("X2");
                    }
                    result.Nodes.Add(s);
                    break;

                default:
                    result.Nodes.Add("unknown field type 0x" + t.ToString("X"));
                    break;
                }
                return(result);
            }