Beispiel #1
0
 /// <summary>
 /// Reads a single .NET structure at the provided offset.
 /// </summary>
 /// <param name="self">The base pointer value to read from.</param>
 /// <param name="offset">The offset to start reading.</param>
 /// <param name="memoryAllocator">The memory allocator responsible for managing type layouts.</param>
 /// <param name="typeLayout">The type layout to read.</param>
 /// <returns>The read structure.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// Occurs when the offset does not fall within the memory range.
 /// </exception>
 public static IConcreteValue ReadStruct(this IPointerValue self, int offset, IMemoryAllocator memoryAllocator, TypeMemoryLayout typeLayout)
 {
     return(typeLayout.Type.ToTypeSignature().ElementType switch
     {
         ElementType.Boolean => self.ReadInteger8(offset),
         ElementType.Char => self.ReadInteger16(offset),
         ElementType.I1 => self.ReadInteger8(offset),
         ElementType.U1 => self.ReadInteger8(offset),
         ElementType.I2 => self.ReadInteger16(offset),
         ElementType.U2 => self.ReadInteger16(offset),
         ElementType.I4 => self.ReadInteger32(offset),
         ElementType.U4 => self.ReadInteger32(offset),
         ElementType.I8 => self.ReadInteger64(offset),
         ElementType.U8 => self.ReadInteger64(offset),
         ElementType.R4 => self.ReadFloat32(offset),
         ElementType.R8 => self.ReadFloat64(offset),
         ElementType.ValueType => self.ReadStructSlow(offset, memoryAllocator, typeLayout),
         ElementType.I => self.Is32Bit ? (IntegerValue)self.ReadInteger32(offset) : self.ReadInteger64(offset),
         ElementType.U => self.Is32Bit ? (IntegerValue)self.ReadInteger32(offset) : self.ReadInteger64(offset),
         ElementType.Enum => ReadEnumValue(self, offset, memoryAllocator, typeLayout),
         _ => new UnknownValue()
     });
Beispiel #2
0
 /// <summary>
 /// Creates a new relative pointer value.
 /// </summary>
 /// <param name="basePointer">The base memory pointer.</param>
 /// <param name="offset">The offset relative to the base po[inter.</param>
 public RelativePointerValue(IPointerValue basePointer, int offset)
 {
     BasePointer   = basePointer;
     CurrentOffset = offset;
     IsKnown       = basePointer.IsKnown;
 }
Beispiel #3
0
 /// <summary>
 /// Creates a new relative pointer value.
 /// </summary>
 /// <param name="basePointer">The base memory pointer.</param>
 public RelativePointerValue(IPointerValue basePointer)
     : this(basePointer, 0)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Creates a new pointer value.
 /// </summary>
 /// <param name="basePointer">The base pointer value.</param>
 /// <param name="offset">The offset relative to the base pointer.</param>
 public PointerValue(IPointerValue basePointer, int offset)
     : base(basePointer, offset)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Creates a new pointer value.
 /// </summary>
 /// <param name="basePointer">The base pointer value.</param>
 public PointerValue(IPointerValue basePointer)
     : base(basePointer)
 {
 }