This is my next question following writing a byte array from as string using an unknown dll
So I managed to write the byte array, now I want to read it back using the same dll.
I have tried the following:
int BufSize = 60000000; // Size of file I/O buffers.
int BufSizeM1M = BufSize - 1000000; // The max amount of data read in at any one time.
using (WinFileIO WFIO = new WinFileIO())
{
WFIO.OpenForReading(path);
WFIO.ReadBlocks(BufSizeM1M);
WFIO.Close();
WFIO.Dispose();
}
this is the WinFileIO.ReadBlocks function:
public int ReadBlocks(int BytesToRead)
{
// This function reads a total of BytesToRead at a time. There is a limit of 2gb per call.
int BytesReadInBlock = 0, BytesRead = 0, BlockByteSize;
byte* pBuf = (byte*)pBuffer;
// Do until there are no more bytes to read or the buffer is full.
do
{
BlockByteSize = Math.Min(BlockSize, BytesToRead - BytesRead);
if (!ReadFile(pHandle, pBuf, BlockByteSize, &BytesReadInBlock, 0))
{
Win32Exception WE = new Win32Exception();
ApplicationException AE = new ApplicationException("WinFileIO:ReadBytes - Error occurred reading a file. - "
+ WE.Message);
throw AE;
}
if (BytesReadInBlock == 0)
break;
BytesRead += BytesReadInBlock;
pBuf += BytesReadInBlock;
} while (BytesRead < BytesToRead);
return BytesRead;
}
My question is, how would one use the function to read an actual file?