public static AnswerRecord ReadAnswerRecord(byte[] bBuffer, int startIndex) { AnswerRecord retval = new AnswerRecord(); retval.mOriginalBuffer = new byte[bBuffer.Length]; retval.mStartIndex = startIndex; Array.Copy(bBuffer, 0, retval.mOriginalBuffer, 0, bBuffer.Length); UInt16 i = GetUInt16(bBuffer, startIndex); int offset = 0; if (i > 0xc000) { retval.mName = GetNameAtLocation(bBuffer, i - 0xc000); offset = 2; } else { retval.Name = GetNameAtLocation(bBuffer, i); offset = i; } retval.mNameBufferLength = GetLabelLength(bBuffer, startIndex); retval.mType = GetUInt16(bBuffer, startIndex + offset); retval.mClass = GetUInt16(bBuffer, startIndex + offset + 2); retval.TTL = GetUInt32(bBuffer, startIndex + offset + 4); UInt16 RDLength = GetUInt16(bBuffer, startIndex + offset + 8); retval.mData = new byte[RDLength]; Array.Copy(bBuffer, startIndex + offset + 10, retval.mData, 0, RDLength); retval.mLength = offset + RDLength + 10; if (retval.Type == (UInt16)TYPECODE.NS) { retval = new NameServerRecord(retval); } if (retval.Type == (UInt16)TYPECODE.A) { retval = new AddressRecord(retval); } if (retval.Type == (UInt16)TYPECODE.MX) { retval = new MailExchangeRecord(retval); } if (retval.Type == (UInt16)TYPECODE.CNAME) { retval = new CanonicalNameRecord(retval); } if (retval.Type == (UInt16)TYPECODE.SOA) { retval = new StartOfAuthorityRecord(retval); } if (retval.Type == (UInt16)TYPECODE.TXT) { retval = new TextRecord(retval); } if (retval.Type == (UInt16)TYPECODE.PTR) { retval = new PointerRecord(retval); } return(retval); }
/// <summary> /// Initializes data based on the <see cref="PointerRecord"/>. /// </summary> private void Initialize(PointerRecord record) { Tag = Engine.CodeTypeTag.Pointer; BasicType = DIA.BasicType.NoType; Size = record.Size; Name = ElementType.Name + "*"; ElementType.PointerType = this; }
/// <summary> /// Gets pointer size from pointer type record. /// </summary> /// <param name="pointerRecord">The pointer record.</param> private static ulong GetPointerSize(PointerRecord pointerRecord) { if (pointerRecord.Size != 0) { return(pointerRecord.Size); } return(pointerRecord.PointerKind == PointerKind.Near64 ? 8U : 4U); }
public FileHost(string filename, PointerRecord pointerRecord, string mimeType, long port, string resultingFilename, string realurl) { this.Port = port; this.MimeType = mimeType; this.FileName = filename; this.PointerRecord = pointerRecord; this.ResultingFilename = resultingFilename; this.RealUrl = realurl; this.Guid = Guid.NewGuid(); }
/// <summary> /// Reads type record for the specified type index. /// </summary> /// <param name="typeIndex">Type record index in <see cref="references"/> list.</param> /// <returns></returns> private TypeRecord ReadType(int typeIndex) { IBinaryReader reader = typeRecordsSubStreamPerThread.Value; RecordReference reference = references[typeIndex]; TypeRecord typeRecord; long dataEnd = reference.DataOffset + reference.DataLen; reader.Position = reference.DataOffset; switch (reference.Kind) { case TypeLeafKind.LF_MODIFIER: typeRecord = ModifierRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_PROCEDURE: typeRecord = ProcedureRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_MFUNCTION: typeRecord = MemberFunctionRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_LABEL: typeRecord = LabelRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_MFUNC_ID: typeRecord = MemberFunctionIdRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_ARGLIST: typeRecord = ArgumentListRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_SUBSTR_LIST: typeRecord = StringListRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_POINTER: typeRecord = PointerRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_NESTTYPE: typeRecord = NestedTypeRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_FIELDLIST: typeRecord = FieldListRecord.Read(reader, reference.Kind, reference.DataLen); break; case TypeLeafKind.LF_ENUM: typeRecord = EnumRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_CLASS: case TypeLeafKind.LF_STRUCTURE: case TypeLeafKind.LF_INTERFACE: typeRecord = ClassRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_ARRAY: typeRecord = ArrayRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_BITFIELD: typeRecord = BitFieldRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_METHODLIST: typeRecord = MethodOverloadListRecord.Read(reader, reference.Kind, reference.DataLen); break; case TypeLeafKind.LF_UNION: typeRecord = UnionRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_VTSHAPE: typeRecord = VirtualFunctionTableShapeRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_UDT_MOD_SRC_LINE: typeRecord = UdtModuleSourceLineRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_STRING_ID: typeRecord = StringIdRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_BUILDINFO: typeRecord = BuildInfoRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_FUNC_ID: typeRecord = FunctionIdRecord.Read(reader, reference.Kind); break; default: #if DEBUG throw new NotImplementedException($"Unknown reference kind: {reference.Kind}"); #else return(null); #endif } if (reader.Position + 4 < dataEnd || reader.Position > dataEnd) { throw new Exception("Parsing went wrong"); } return(typeRecord); }
/// <summary> /// Combines modifier options with pointer record data. /// </summary> /// <param name="modifierOptions">The modifier options.</param> /// <param name="pointerRecord">The pointer record.</param> private static ModifierOptions CombineModifierOptions(ModifierOptions modifierOptions, PointerRecord pointerRecord) { if (pointerRecord.IsConst) { modifierOptions |= ModifierOptions.Const; } if (pointerRecord.IsVolatile) { modifierOptions |= ModifierOptions.Volatile; } if (pointerRecord.IsUnaligned) { modifierOptions |= ModifierOptions.Unaligned; } return(modifierOptions); }
/// <summary> /// Initializes a new instance of the <see cref="PdbComplexPointerType"/> class. /// </summary> /// <param name="pdb">The PDB file reader.</param> /// <param name="typeIndex">Type index.</param> /// <param name="pointerRecord">The pointer record.</param> /// <param name="modifierOptions">The modifier options.</param> internal PdbComplexPointerType(PdbFileReader pdb, TypeIndex typeIndex, PointerRecord pointerRecord, ModifierOptions modifierOptions) : base(pdb, typeIndex, CombineModifierOptions(modifierOptions, pointerRecord), pointerRecord.ReferentType, GetPointerSize(pointerRecord), pointerRecord.Mode == PointerMode.LValueReference, pointerRecord.Mode == PointerMode.RValueReference) { PointerRecord = pointerRecord; }