private unsafe static bool ValidateUintArray(ushort *pDataPool, uint offsetInPool, int poolSize)
{
if (offsetInPool == 0)
return true;
if (offsetInPool + 2 > poolSize) // string offset + string length + null termination.
return false;
// Get location of count and make sure its on an odd word
// (odd words would end in 2 as pointers, we want pCount%4 to be 2 so that
// when we get past the count our uints are uint aligned)
ushort* pCount = pDataPool + offsetInPool;
if (((int)(pCount) & 2) != 2)
return false;
int arrayLength = pCount[0];
if (offsetInPool + (arrayLength * 2) + 2 > poolSize) // array length * 2 (words/dword) + string + null termination
return false;
return true;
}