-
Causes Crashes
Hey Guys
Code:
void CMiscFunctions::CopyValueToBuffer(BYTE *pDataToCopy, BYTE *pBuffer, DWORD *dwLengthOfBuffer, DWORD dwSizeOfData)
{
DWORD i = *dwLengthOfBuffer;
for(DWORD y = 0; y < dwSizeOfData; y++, i++)
{
pBuffer[i] = pDataToCopy[y];
}
*dwLengthOfBuffer = i;
}
This little piece of code works fine copying one buffer to the other up to 59kb if the buffer is bigger then this the program crashes any ideas. I originally had int y not DWORD y and was convinced it was the problem but it still causes a crash.
Any Ideas
Peter
-
First place I would look -
You need to use an unsigned counter & pointer datatype. Your datatype is 'rolling over'. maybe including DWORD SizeOfData.
-
:confused:I don't understand your usage of i. You first set it to the size of buffer, then increment it and use it as index. Or do you always supply 0 for dwLengthOfBuffer. If so, you should write i = 0; instead of i = *dwLengthOfBuffer.
I can't help you with the 59k problem. Maybe you show us the declaration of the buffers and the function call.