object CreateData(MDTables helper) { switch (_type) { case Types.UInt16: return((ushort)_rawData);; case Types.UInt32: return((uint)_rawData); case Types.String: return(helper.GetString((int)_rawData)); case Types.Guid: return(helper.GetGuid((int)_rawData)); case Types.Blob: return(helper.GetBlob((int)_rawData)); //case Types.UserString: // return _helper.GetBlob((int)_rawData); default: break; } if ((int)_type < 64) { return(new RID(_type, _rawData)); } return(new CodedToken(_type, _rawData, helper)); }
public MModule(BinaryReader reader) { try { _mh = new ModHeaders(reader); } catch //(Exception e) { return; } //imports try { _imp = new ImpExports(reader, this); } catch //(Exception e) { return; } //relocs try { _fix = new Relocations(reader, this); } catch //(Exception e) { return; } //heaps try { _stringHeap = new MDStringHeap(reader, _mh.MetaDataHeaders.StringStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.StringStreamHeader.Size, _mh.MetaDataHeaders.StringStreamHeader.Name); _blobHeap = new MDBlobHeap(reader, _mh.MetaDataHeaders.BlobStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.BlobStreamHeader.Size, _mh.MetaDataHeaders.BlobStreamHeader.Name); _GUIDHeap = new MDGUIDHeap(reader, _mh.MetaDataHeaders.GUIDStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.GUIDStreamHeader.Size, _mh.MetaDataHeaders.GUIDStreamHeader.Name); if (_mh.MetaDataHeaders.USStreamHeader != null) { _USHeap = new MDBlobHeap(reader, _mh.MetaDataHeaders.USStreamHeader.Offset + _mh.MetaDataHeaders.StorageSigAndHeader.Start, _mh.MetaDataHeaders.USStreamHeader.Size, _mh.MetaDataHeaders.USStreamHeader.Name); } } catch //(Exception e) { return; } //tables try { reader.BaseStream.Position = _mh.MetaDataTableHeader.End; _tables = new MDTables(reader, this); } catch //(Exception e) { return; } }
public TableCell(Types type, BinaryReader reader, MDTables helper) { _type = type; try { // Fixed if (type == Types.UInt16) { _rawData = reader.ReadUInt16(); } if (type == Types.UInt32) { _rawData = reader.ReadUInt32(); } // Heap if (type == Types.String) { _rawData = ((helper.GetStringIndexSize() == 2) ? (uint)reader.ReadUInt16() : reader.ReadUInt32()); } if (type == Types.Guid) { _rawData = ((helper.GetGuidIndexSize() == 2) ? (uint)reader.ReadUInt16() : reader.ReadUInt32()); } if (type == Types.Blob) { _rawData = ((helper.GetBlobIndexSize() == 2) ? (uint)reader.ReadUInt16() : reader.ReadUInt32()); } // Rid if ((int)type < 64) { Table table = helper.GetTable(type); _rawData = (uint)(((uint)type << 24) | ((table.Count < 65536) ? (uint)reader.ReadUInt16() : reader.ReadUInt32())); } // Coded token (may need to be uncompressed from 2-byte form) else if ((int)type < 97) { int codedToken = (helper.SizeOfType(type) == 2) ? reader.ReadUInt16() : reader.ReadInt32(); Types[] referredTables = (Types[])helper.CodedTokenTypes(type); int tableIndex = (int)(codedToken & ~(-1 << helper.CodedTokenBits(referredTables.Length))); int index = (int)(codedToken >> helper.CodedTokenBits(referredTables.Length)); int token = helper.ToToken(referredTables[tableIndex], index - 1); _rawData = (uint)token; } _data = CreateData(helper); } catch //(Exception e) { _type = Types.String; _data = "Unreadable cell: " + type + " " + _rawData; } }
public Table(Types type, Types[] colTypes, String[] colNames, MDTables helper, BinaryReader reader) { _type = type; _helper = helper; _colDescs = new ColDesc[colTypes.Length]; for (int i = 0; i < _colDescs.Length; i++) { _colDescs[i] = new ColDesc(colTypes[i], colNames[i]); } _rows = new Row[helper.GetTableRows(type)]; _rowSize = 0; foreach (ColDesc cd in _colDescs) { _rowSize += _helper.SizeOfType(cd.Type); } data = reader.ReadBytes(_rowSize * Count); }
public CodedToken(Types type, uint raw, MDTables helper) { _rawData = raw; _type = type; }