示例#1
0
        /// <summary>
        /// Creates a literal from the memory contents, given an address and type.
        /// </summary>
        /// <param name="address">The address to read from.</param>
        /// <param name="type">The type, reporting the size.</param>
        public Literal CreateLiteral(long address, Type type)
        {
            Literal toret = null;
            var ptrType = type as Ptr;

            // Special case: char* is a StringLiteral
            if ( ptrType != null
              && ptrType.AssociatedType == this.Machine.TypeSystem.GetCharType() )
            {
                byte[] str = this.ReadStringFromMemory( address );
                toret = new StrLiteral( this.Machine, new string( Machine.TextEncoding.GetChars( str ) ) );
            } else {
                toret = type.CreateLiteral( this.Machine, this.Read( address, type.Size ) );
            }

            if ( toret == null ) {
                throw new EngineException( L18n.Get( L18n.Id.ExcUnknownType ) );
            }

            return toret;
        }
示例#2
0
 /// <summary>
 /// Creates a literal of the given type.
 /// </summary>
 /// <returns>The literal, as a <see cref="Literal"/> object.</returns>
 /// <param name="t">The type, as a <see cref="Type"/> object.</param>
 /// <param name="raw">A vector of bytes.</param>
 public Literal CreateLiteral(Type t, byte[] raw)
 {
     return t.CreateLiteral( this.Machine, raw );
 }