Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Fix reading binary columns #66

Merged
merged 1 commit into from
Jan 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/MSIExtract.Core/Msi/ViewWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ public IList<object[]> Records
values[i] = sourceRecord.GetInteger(i + 1);
else if (_columns[i].IsStream)
{
var tempBuffer = new byte[_columns[i].Size + 1];
var allData = new byte[_columns[i].Size + 1];
int totalBytesRead = 0;
int bytesReadThisCall;

using var stream = sourceRecord.GetStream(i);
do
using (var stream = sourceRecord.GetStream(i + 1))
{
// It seems to read the Binary table with _columns[i].Size ==0 tempBuffer must be at least 1 in length or an ExecutionEngineException occurs.
bytesReadThisCall = stream.Read(tempBuffer, 0, tempBuffer.Length);
Buffer.BlockCopy(tempBuffer, 0, allData, totalBytesRead, bytesReadThisCall);
totalBytesRead += bytesReadThisCall;
Debug.Assert(bytesReadThisCall > 0);
} while (bytesReadThisCall > 0 && (totalBytesRead < _columns[i].Size));
values[i] = allData;
var tempBuffer = new byte[512];
var allData = new byte[stream.Length];
int totalBytesRead = 0;
int bytesReadThisCall;
do
{
bytesReadThisCall = stream.Read(tempBuffer, 0, tempBuffer.Length);
Buffer.BlockCopy(tempBuffer, 0, allData, totalBytesRead, bytesReadThisCall);
totalBytesRead += bytesReadThisCall;
Debug.Assert(bytesReadThisCall > 0);
} while (bytesReadThisCall > 0 && (totalBytesRead < allData.Length));
values[i] = allData;
}
}
else if (_columns[i].IsObject)
{
Expand Down