internal void Load(BuildModule module) { if (_module != null) { throw new InvalidOperationException(); } _module = module; if (_isNew) { if (_bufferLength == 0) { var image = _module.Image; _moduleTableOffset = BuildAssembly.RowSize * image.GetAssemblyCount(); _typeTableOffset = _moduleTableOffset + BuildModule.RowSize; _methodTableOffset = _typeTableOffset + (BuildType.RowSize * image.GetTypeDefCount()); _fieldTableOffset = _methodTableOffset + (BuildMethod.RowSize * image.GetMethodCount()); _propertyTableOffset = _fieldTableOffset + (BuildField.RowSize * image.GetFieldCount()); _eventTableOffset = _propertyTableOffset + (BuildProperty.RowSize * image.GetPropertyCount()); _resourceTableOffset = _eventTableOffset + (BuildEvent.RowSize * image.GetEventCount()); _bufferLength = _resourceTableOffset + (BuildResource.RowSize * image.GetManifestResourceCount()); } _buffer = new byte[_bufferLength]; _blobs = new BlobList(); _strings = new StringSerializer(); _signatures = new SignatureList(_strings); _objects = new ModuleObjectState(this); } else { using (var accessor = new StreamAccessor(new FileStream(_stateFilePath, FileMode.Open, FileAccess.Read, FileShare.None))) { _bufferLength = accessor.Read7BitEncodedInt(); _buffer = accessor.ReadBytes(_bufferLength); _objects = new ModuleObjectState(this, accessor); _blobs = new BlobList(accessor); var stringBlob = new Blob(accessor.ReadBytes(accessor.Read7BitEncodedInt())); StrongCryptoUtils.Decrypt(stringBlob.GetBuffer(), 0, stringBlob.Length); _strings = new StringSerializer(new BlobAccessor(stringBlob)); _signatures = new SignatureList(accessor, _strings); } } _strings.DelayWrite = true; _signatures.DelayWrite = true; }
private void ReadStrings(IBinaryAccessor accessor, ProjectReadState state) { int blobSize = accessor.Read7BitEncodedInt(); byte[] buffer = accessor.ReadBytes(blobSize); StrongCryptoUtils.Decrypt(buffer, 0, blobSize); var blob = new Blob(buffer); int pos = 0; int count = blob.Read7BitEncodedInt(ref pos); var strings = new string[count]; var encoding = Encoding.UTF8; for (int i = 0; i < count; i++) { strings[i] = blob.ReadLengthPrefixedString(ref pos, encoding); } state.Strings = strings; }