Re: Real newbie question: RtlCopyMemory by James
James
Thu Sep 04 10:09:19 CDT 2003
1) You've not shown the type declarations for FIRSTBUFFER, SECBUFFER and
THIRDBUFFER. Depending on what the types are, that could be a mistake.
For example, if these are buffer descriptors -- like UNICODE_STRING --
you're using the descriptors' sizes and not that of the buffer.
2) Your 3 RtlCopyMemory are copying from the so-called buffers into your
buffer variable, overlaying it.
3) As a consequence of 2), NdisFreeMemory is almost guaranteed to fail
in one manner or another.
Sam Gordon wrote:
> PCHAR *buffer = NULL;
> FIRSTBUFFER firstbuffer;
> SECBUFFER secbuffer;
> THIRDBUFFER thirdbuffer;
>
> NdisAllocateMemoryWithTag((PCHAR*)&buffer,sizeof
> (firstbuffer) + sizeof(secbuffer) + sizeof
> (thirdbuffer),'ALC');
>
> RtlCopyMemory(buffer,&firstbuffer,sizeof(firstbuffer));
>
> RtlCopyMemory(buffer + sizeof _
> (firstbuffer),&secbuffer,sizeof(secbuffer));
>
> RtlCopyMemory(buffer + sizeof(firstbuffer) + sizeof
> (secbuffer),&thirdbuffer,sizeof(thirdbuffer));
>
> NdisFreeMemory((PCHAR*)&buffer,sizeof(firstbuffer) +
> sizeof(secbuffer) + sizeof(thirdbuffer),0);
--
If replying by e-mail, please remove "nospam." from the address.
James Antognini
Windows DDK MVP