August 26th, 2013, 04:36 PM
This is an alternative way of doing it. In this case GetMemory() returns a pointer to new memory of the size specified which contains a copy of the memory pointed to by m_lpData from position offset...
August 26th, 2013, 04:15 PM
You don't return a 'block of memory'. You return a pointer to a particular memory location which the caller then uses as required.
Based on your example use, I think this test program shows what...
August 26th, 2013, 02:36 PM
Sorry but still don't understand.
Lets say that m_lpdata points to memory location 1000.
At memory location starting 1000 say the data is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
...
August 26th, 2013, 02:06 PM
If you just want to return a pointer to some part of memory, then all you need is the start and offset - you don't need the length.:confused:
August 26th, 2013, 01:24 PM
LPVOID m_lpData;
LPVOID GetMemory(DWORD pos, DWORD length)
{
BYTE* buffer = (BYTE*)m_lpData;
buffer += pos;
// how to get a length of the memory?
return ((LPVOID)buffer);