Ejemplo n.º 1
0
        public void Start( )
        {
            if ( xtr.HasAttributes )
            {
                mt.MagicPriority = System.Convert.ToInt32( xtr.GetAttribute( "priority" ) );
            }

            while ( xtr.Read( ) )
            {
                switch ( xtr.NodeType )
                {
                    case XmlNodeType.Element:
                        if ( xtr.Name == "match" )
                        {
                            Match m = new Match( );

                            MatchReader mr = new MatchReader( xtr, m );

                            mr.Start( );

                            mt.Matches.Add( m );
                        }
                        break;

                    case XmlNodeType.EndElement:
                        if ( xtr.Name == "magic" )
                            return;
                        break;

                }
            }
        }
Ejemplo n.º 2
0
        private void BuildByteArrays( string tabs, string matchname, byte[] bmatchvalue, Match match )
        {
            AddByteArray( tabs, matchname, bmatchvalue, 0 );

            if ( match.Mask != null )
            {
                byte[] bmask = HexStringToByteArray( match.Mask );

                AddByteArray( tabs, matchname, bmask, 1 );
            }
        }
Ejemplo n.º 3
0
        public void Start( )
        {
            if ( xtr.HasAttributes )
            {
                m.MatchValue = xtr.GetAttribute( "value" );

                string match_type = xtr.GetAttribute( "type" );

                if ( match_type == "string" )
                    m.MatchType = MatchTypes.TypeString;
                else
                if ( match_type == "host16" )
                    m.MatchType = MatchTypes.TypeHost16;
                else
                if ( match_type == "host32" )
                    m.MatchType = MatchTypes.TypeHost32;
                else
                if ( match_type == "big16" )
                    m.MatchType = MatchTypes.TypeBig16;
                else
                if ( match_type == "big32" )
                    m.MatchType = MatchTypes.TypeBig32;
                else
                if ( match_type == "little16" )
                    m.MatchType = MatchTypes.TypeLittle16;
                else
                if ( match_type == "little32" )
                    m.MatchType = MatchTypes.TypeLittle32;
                else
                if ( match_type == "byte" )
                    m.MatchType = MatchTypes.TypeByte;

                string offset = xtr.GetAttribute( "offset" );

                if ( offset.IndexOf( ":" ) != -1 )
                {
                    string[] split = offset.Split( new char[] { ':' } );

                    if ( split.Length == 2 )
                    {
                        m.Offset = System.Convert.ToInt32( split[ 0 ] );
                        m.OffsetEnd = System.Convert.ToInt32( split[ 1 ] );
                    }

                }
                else
                    m.Offset = System.Convert.ToInt32( offset );

                string mask = xtr.GetAttribute( "mask" );

                if ( mask != "" )
                    m.Mask = mask;
            }

            if ( xtr.IsEmptyElement )
                return;

            while ( xtr.Read( ) )
            {
                switch ( xtr.NodeType )
                {
                    case XmlNodeType.Element:
                        if ( xtr.Name == "match" )
                        {
                            Match nm = new Match( );

                            SubMatchReader mr = new SubMatchReader( xtr, nm );

                            mr.Start( );

                            m.Matches.Add( nm );
                        }
                        break;

                    case XmlNodeType.EndElement:
                        if ( xtr.Name == "match" )
                            return;
                        break;

                }
            }
        }
Ejemplo n.º 4
0
        public MatchReader( XmlTextReader xtr, Match m )
        {
            this.xtr = xtr;

            this.m = m;
        }
Ejemplo n.º 5
0
        public SubMatchReader( XmlTextReader xtr, Match sm )
        {
            this.xtr = xtr;

            this.sm = sm;
        }