I think I just cover both methods there.
Or maybe I forgot one.
Returning just a DWORD:
Code:
DWORD Foo(BYTE* pTemp){
DWORD dwNew;
dwNew = (DWORD)pTemp[4];
return dwNew;
}
And returning a DWORD pointer:
Code:
DWORD Foo(BYTE* pTemp, DWORD& dwBuffer){
memcpy(&dwBuffer, &pTemp[4], sizeof(DWORD));
}
(Not tested)
I think this should avoid unaligned issues.
Unless memcpy works in ways I don't know or the initial source pointer must be aligned, but I don't think it needs to? It's up to the C implementation.