Question about nonpaged memory and MDLs

Hello,

on the internet I have seen some codes with this chain of calls, example 1:

mdl = IoAllocateMdl(pointer);
MmBuildMdlForNonPagedPool(mdl);
mapped = MmMapLockedPages(mdl, kernelmode);

copy(mapped, source, count);

MmUnmapLockedPages(mapped);
IoFreeMdl(mdl);

if its supposed that “pointer” is pointing to resident memory, and if they are going to just copy some data, why do they need to lock and map the memory?
why not just:

copy(pointer, source, count);

i am still reading and learning, sorry if its clear.


Alex don