I'm working with memory mapped files and I have a block of memory that I've mapped to.

I want to write a function that returns a pointer to a portion of the mapped memory at an offset and length so I can write to it.
I've never worked with memory at this level, is what I'm attempting possible?

I know that mapping functions can map to a part of the file at length and offset but I'm not sure if I should make multiple calls to map the memory from the file or just map the memory once and work with the portions I'm interested in using my proposed GetMemory function

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);