protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } int length = accessor.ReadCompressedInteger(); if (length > 0) { _guidString = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _unmanagedTypeString = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _typeName = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _cookie = accessor.ReadString(length, Encoding.UTF8); } }
private static Project Read(IBinaryAccessor accessor, string basePath) { if (HeaderSignature != accessor.ReadString(6, Encoding.UTF8)) { throw new ProjectException(SR.ProjectNotValid); } accessor.Position += 2; var state = new ProjectReadState(); state.BasePath = basePath; return(new Project(accessor, state)); }
internal static ResourceEntry Load(IBinaryAccessor accessor, long basePosition) { uint nameOrId = accessor.ReadUInt32(); uint dataOrTable = accessor.ReadUInt32(); long origPosition = accessor.Position; accessor.Position = basePosition + (dataOrTable & 0x7fffffff); ResourceEntry entry; if ((dataOrTable & 0x80000000) != 0) { // High bit 1. The lower 31 bits are the address of another resource directory table (the next level down). entry = ResourceTableEntry.Load(accessor, basePosition); } else { // High bit 0. Address of a Resource Data entry (a leaf). entry = ResourceDataEntry.Load(accessor); } accessor.Position = origPosition; if ((nameOrId & 0x80000000) != 0) { // High bit 1. The address of a string that gives the Type, Name, or Language ID entry, depending on level of table. accessor.Position = basePosition + (nameOrId & 0x7fffffff); int length = accessor.ReadUInt16(); entry._name = accessor.ReadString(length, Encoding.Unicode); accessor.Position = origPosition; } else { // High bit 0. A 32-bit integer that identifies the Type, Name, or Language ID entry. entry._id = (int)(nameOrId & 0x7fffffff); } return(entry); }
protected void Load(IBinaryAccessor accessor) { int typeLength = accessor.ReadCompressedInteger(); string typeName = accessor.ReadString(typeLength, Encoding.UTF8); _type = TypeSignature.Parse(typeName, true) as TypeReference; if (_type == null) { throw new InvalidDataException(); } _type = (TypeReference)_type.Relocate(_module); accessor.ReadCompressedInteger(); // Blob size int argumentCount = accessor.ReadCompressedInteger(); _namedArguments = new CustomAttributeNamedArgumentCollection(this); _namedArguments.Load(accessor, argumentCount); }
protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } _variantType = (UnmanagedVariantType)accessor.ReadCompressedInteger(); if (accessor.IsEof()) { return; } int length = accessor.ReadCompressedInteger(); if (length > 0) { _userDefinedSubType = accessor.ReadString(length, Encoding.UTF8); } }
internal static string ReadBlobString(IBinaryAccessor accessor) { int len = 0; byte b = accessor.ReadByte(); if (b == 0) { return(string.Empty); } if (b == 0xff) { return(null); } if ((b & 0x80) == 0) { // 1 byte len = b; } else if ((b & 0x40) == 0) { // 2 byte len = (b & ~0x80) << 8; len |= accessor.ReadByte(); } else { // 4 byte len = (b & ~0xc0) << 24; len |= accessor.ReadByte() << 16; len |= accessor.ReadByte() << 8; len |= accessor.ReadByte(); } return(accessor.ReadString(len, Encoding.UTF8)); }