Memory function equivalent to that found in fread
-
I'm looking for a method that mimics the functionality of fread without a file pointer. I want to read from a buffer into a buffer, for a number of bytes and move the pointer to the source buffer by the number of bytes returned - like fread. Anyone done anything like this? Thanks in advance
Jer 29:11
-
I'm looking for a method that mimics the functionality of fread without a file pointer. I want to read from a buffer into a buffer, for a number of bytes and move the pointer to the source buffer by the number of bytes returned - like fread. Anyone done anything like this? Thanks in advance
Jer 29:11
BYTE* pDest = <Destination Buffer>;
BYTE* pSrc = <Source Buffer>;
SIZE_T size = <Size to Read>;MemoryRead(pDest, pSrc, size);
SIZE_T MemoryRead(BYTE* pDest, BYTE* pSrc, SIZE_T size)
{
CopyMemory(pDest, pSrc, size);
pSrc += size;return size;
}«_Superman_» I love work. It gives me something to do between weekends.
-
BYTE* pDest = <Destination Buffer>;
BYTE* pSrc = <Source Buffer>;
SIZE_T size = <Size to Read>;MemoryRead(pDest, pSrc, size);
SIZE_T MemoryRead(BYTE* pDest, BYTE* pSrc, SIZE_T size)
{
CopyMemory(pDest, pSrc, size);
pSrc += size;return size;
}«_Superman_» I love work. It gives me something to do between weekends.
-
BYTE* pDest = <Destination Buffer>;
BYTE* pSrc = <Source Buffer>;
SIZE_T size = <Size to Read>;MemoryRead(pDest, pSrc, size);
SIZE_T MemoryRead(BYTE* pDest, BYTE* pSrc, SIZE_T size)
{
CopyMemory(pDest, pSrc, size);
pSrc += size;return size;
}«_Superman_» I love work. It gives me something to do between weekends.
-
I spoke too soon! Actually, it doesn't quite work like fread. CopyMemory - defined as RtlCopyMemory needs size as an input. fread on the other hand returns the number of bytes read. Thanks for responding but I still don't have the solution.
Jer 29:11
The reason is very clear. A file has an end and when you give a size, it will read either the mentioned size or till the end of the file. But a memory read either succeeds or fails.
«_Superman_» I love work. It gives me something to do between weekends.
-
The reason is very clear. A file has an end and when you give a size, it will read either the mentioned size or till the end of the file. But a memory read either succeeds or fails.
«_Superman_» I love work. It gives me something to do between weekends.