Assumed the structure SDATA has no pointer members :) :
BYTE* MakeMemoryDump(vector<sdata>* pVector)
{
BYTE* pData(NULL);
if (pVector) {
int iCount(pVectot->GetCount());
if (iCount) {
pData = new BYTE(iCount * sizeof(SDATA) + sizeof(DWORD));
DWORD* pdwCount = (DWORD*) pData;
*pdwCount = (DWORD) iCount;
SDATA* psData = (SDATA*) (pData + sizeof(DWORD));
for (int i = 0; i < iCount; i++) {
memcpy_s(psData[i], sizeof(SDATA), &pVector->GetAt(i), sizeof(SDATA));
}
}
}
return pData;
}
...and :) :
void ReadMemoryDump(BYTE* pData, vector<sdata>* pToVector)
{
if (pData && pToVector) {
pToVector->Empty();
DWORD* pdwCount = (DWORD*) pData;
SDATA* psData = (SDATA*) (pData + sizeof(DWORD));
for (DWORD dw = 0; dw < *pdwCount; dw++) {
pToVector->Add(*psData[i]);
}
}
}</sdata>