public static string PrintTdfList(Blaze.TdfList list, int tabs)
        {
            StringBuilder sb  = new StringBuilder();
            string        tab = "";

            for (int i = 0; i < tabs; i++)
            {
                tab += "\t";
            }
            List <long>            li;
            List <string>          ls;
            List <Blaze.TdfStruct> lt;
            int count = 0;

            switch (list.SubType)
            {
            case 0:
                li = ((List <long>)list.List);
                foreach (long l in li)
                {
                    sb.AppendLine(tab + "0x" + l.ToString("X") + "(" + l + "),");
                }
                break;

            case 1:
                ls = ((List <string>)list.List);
                foreach (string s in ls)
                {
                    sb.AppendLine(tab + "\"" + s + "\",");
                }
                break;

            case 3:
                lt = ((List <Blaze.TdfStruct>)list.List);
                foreach (Blaze.TdfStruct tdf in lt)
                {
                    tdf.Type  = 3;
                    tdf.Label = (count++).ToString();
                    sb.Append(PrintTdf(tdf, tabs));
                }
                break;
            }
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private void tv1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode t = e.Node;

            if (t != null && t.Name != "")
            {
                int       n   = Convert.ToInt32(t.Name);
                Blaze.Tdf tdf = inlist[n];
                string    s;
                switch (tdf.Type)
                {
                case 0:
                    Blaze.TdfInteger ti = (Blaze.TdfInteger)tdf;
                    rtb2.Text = "0x" + ti.Value.ToString("X");
                    if (ti.Label == "IP  ")
                    {
                        rtb2.Text += Environment.NewLine + "(" + Blaze.GetStringFromIP(ti.Value) + ")";
                    }
                    break;

                case 1:
                    rtb2.Text = ((Blaze.TdfString)tdf).Value.ToString();
                    break;

                case 2:
                    rtb2.Text  = "Length: " + ((Blaze.TdfBlob)tdf).Data.Length.ToString();
                    rtb2.Text += Environment.NewLine + Blaze.HexDump(((Blaze.TdfBlob)tdf).Data);
                    break;

                case 4:
                    Blaze.TdfList l = (Blaze.TdfList)tdf;
                    s = "";
                    for (int i = 0; i < l.Count; i++)
                    {
                        switch (l.SubType)
                        {
                        case 0:
                            s += "{" + ((List <long>)l.List)[i] + "} ";
                            break;

                        case 1:
                            s += "{" + ((List <string>)l.List)[i] + "} ";
                            break;

                        case 9:
                            Blaze.TrippleVal t2 = ((List <Blaze.TrippleVal>)l.List)[i];
                            s += "{" + t2.v1.ToString("X") + "; " + t2.v2.ToString("X") + "; " + t2.v3.ToString("X") + "} ";
                            break;
                        }
                    }
                    rtb2.Text = s;
                    break;

                case 5:
                    s = "";
                    Blaze.TdfDoubleList ll = (Blaze.TdfDoubleList)tdf;
                    for (int i = 0; i < ll.Count; i++)
                    {
                        s += "{";
                        switch (ll.SubType1)
                        {
                        case 0:
                            List <long> l1 = (List <long>)ll.List1;
                            s += l1[i].ToString("X");
                            break;

                        case 1:
                            List <string> l2 = (List <string>)ll.List1;
                            s += l2[i];
                            break;

                        case 0xA:
                            List <float> lf1 = (List <float>)ll.List1;
                            s += lf1[i].ToString();
                            break;

                        default:
                            s += "(see List1[" + i + "])";
                            break;
                        }
                        s += " ; ";
                        switch (ll.SubType2)
                        {
                        case 0:
                            List <long> l1 = (List <long>)ll.List2;
                            s += l1[i].ToString("X");
                            break;

                        case 1:
                            List <string> l2 = (List <string>)ll.List2;
                            s += l2[i];
                            break;

                        case 0xA:
                            List <float> lf1 = (List <float>)ll.List2;
                            s += lf1[i].ToString();
                            break;

                        default:
                            s += "(see List2[" + i + "])";
                            break;
                        }
                        s += "}\n";
                    }
                    rtb2.Text = s;
                    break;

                case 6:
                    rtb2.Text = "Type: 0x" + ((Blaze.TdfUnion)tdf).UnionType.ToString("X2");
                    break;

                case 7:
                    Blaze.TdfIntegerList til = (Blaze.TdfIntegerList)tdf;
                    s = "";
                    for (int i = 0; i < til.Count; i++)
                    {
                        s += til.List[i].ToString("X");
                        if (i < til.Count - 1)
                        {
                            s += "; ";
                        }
                    }
                    rtb2.Text = s;
                    break;

                case 8:
                    Blaze.TdfDoubleVal dval = (Blaze.TdfDoubleVal)tdf;
                    rtb2.Text = "0x" + dval.Value.v1.ToString("X") + " 0x" + dval.Value.v2.ToString("X");
                    break;

                case 9:
                    Blaze.TdfTrippleVal tval = (Blaze.TdfTrippleVal)tdf;
                    rtb2.Text = "0x" + tval.Value.v1.ToString("X") + " 0x" + tval.Value.v2.ToString("X") + " 0x" + tval.Value.v3.ToString("X");
                    break;

                default:
                    rtb2.Text = "";
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        private TreeNode TdfToTree(Blaze.Tdf tdf)
        {
            TreeNode t, t2, t3;

            switch (tdf.Type)
            {
            case 3:
                t = tdf.ToTree();
                Blaze.TdfStruct str = (Blaze.TdfStruct)tdf;
                if (str.startswith2)
                {
                    t.Text += " (Starts with 2)";
                }
                foreach (Blaze.Tdf td in str.Values)
                {
                    t.Nodes.Add(TdfToTree(td));
                }
                t.Name = (inlistcount++).ToString();
                inlist.Add(tdf);
                return(t);

            case 4:
                t = tdf.ToTree();
                Blaze.TdfList l = (Blaze.TdfList)tdf;
                if (l.SubType == 3)
                {
                    List <Blaze.TdfStruct> l2 = (List <Blaze.TdfStruct>)l.List;
                    for (int i = 0; i < l2.Count; i++)
                    {
                        t2 = new TreeNode("Entry #" + i);
                        if (l2[i].startswith2)
                        {
                            t2.Text += " (Starts with 2)";
                        }
                        List <Blaze.Tdf> l3 = l2[i].Values;
                        for (int j = 0; j < l3.Count; j++)
                        {
                            t2.Nodes.Add(TdfToTree(l3[j]));
                        }
                        t.Nodes.Add(t2);
                    }
                }
                t.Name = (inlistcount++).ToString();
                inlist.Add(tdf);
                return(t);

            case 5:
                t = tdf.ToTree();
                Blaze.TdfDoubleList ll = (Blaze.TdfDoubleList)tdf;
                t2 = new TreeNode("List 1");
                if (ll.SubType1 == 3)
                {
                    List <Blaze.TdfStruct> l2 = (List <Blaze.TdfStruct>)ll.List1;
                    for (int i = 0; i < l2.Count; i++)
                    {
                        t3 = new TreeNode("Entry #" + i);
                        if (l2[i].startswith2)
                        {
                            t2.Text += " (Starts with 2)";
                        }
                        List <Blaze.Tdf> l3 = l2[i].Values;
                        for (int j = 0; j < l3.Count; j++)
                        {
                            t3.Nodes.Add(TdfToTree(l3[j]));
                        }
                        t2.Nodes.Add(t3);
                    }
                    t.Nodes.Add(t2);
                }
                t2 = new TreeNode("List 2");
                if (ll.SubType2 == 3)
                {
                    List <Blaze.TdfStruct> l2 = (List <Blaze.TdfStruct>)ll.List2;
                    for (int i = 0; i < l2.Count; i++)
                    {
                        t3 = new TreeNode("Entry #" + i);
                        if (l2[i].startswith2)
                        {
                            t2.Text += " (Starts with 2)";
                        }
                        List <Blaze.Tdf> l3 = l2[i].Values;
                        for (int j = 0; j < l3.Count; j++)
                        {
                            t3.Nodes.Add(TdfToTree(l3[j]));
                        }
                        t2.Nodes.Add(t3);
                    }
                    t.Nodes.Add(t2);
                }
                t.Name = (inlistcount++).ToString();
                inlist.Add(tdf);
                return(t);

            case 6:
                t = tdf.ToTree();
                Blaze.TdfUnion tu = (Blaze.TdfUnion)tdf;
                if (tu.UnionType != 0x7F)
                {
                    t.Nodes.Add(TdfToTree(tu.UnionContent));
                }
                t.Name = (inlistcount++).ToString();
                inlist.Add(tdf);
                return(t);

            default:
                t      = tdf.ToTree();
                t.Name = (inlistcount++).ToString();
                inlist.Add(tdf);
                return(t);
            }
        }