hi all

I used "allocateCommonBuffer" function to assign the memory allocation
for
DMA transmission.
At the meantime, the data transferred from AP through "DeciveioCotrol"
function are copied using "RtlCopyMemory" function, and then both data
are
compared using "RtlCompareMemory", there are some difference between
the two
in some circumstances. Why is that so?

The code is as follow:

case IOCTL_SEND_DATA:
pMPG = (PMPG_PARAM) pIrp->AssociatedIrp.SystemBuffer;

pOutBuf = (PULONG) pLDI->DMABuffers[0].Virtual;<--form
allocateCommonBuffer

RtlCopyMemory(pOutBuf, pMPG->pMessage, pMPG->nDataLen);

DbgTrace(("Cnt: %d \n",RtlCompareMemory(

pOutBuf,pMPG->pMessage,pMPG->nDataLen)));
break;

The struct of MPG_PARA is

typedef struct _MPG_PARAM {
ULONG nDataLen;
ULONG pMessage[1];
} MPG_PARAM ,*PMPG_PARAM;


Thanks a lot

Re: RtlCopyMemory problem by Doron

Doron
Fri May 19 22:10:01 CDT 2006

fyi, RtlCompareMemory returns the number of bytes that compare as equal.
note this is not the same behavior as memcmp

http://blogs.msdn.com/doronh/archive/2006/03/06/544908.aspx

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<hatepaul@gmail.com> wrote in message
news:1148013625.175086.112670@y43g2000cwc.googlegroups.com...
> hi all
>
> I used "allocateCommonBuffer" function to assign the memory allocation
> for
> DMA transmission.
> At the meantime, the data transferred from AP through "DeciveioCotrol"
> function are copied using "RtlCopyMemory" function, and then both data
> are
> compared using "RtlCompareMemory", there are some difference between
> the two
> in some circumstances. Why is that so?
>
> The code is as follow:
>
> case IOCTL_SEND_DATA:
> pMPG = (PMPG_PARAM) pIrp->AssociatedIrp.SystemBuffer;
>
> pOutBuf = (PULONG) pLDI->DMABuffers[0].Virtual;<--form
> allocateCommonBuffer
>
> RtlCopyMemory(pOutBuf, pMPG->pMessage, pMPG->nDataLen);
>
> DbgTrace(("Cnt: %d \n",RtlCompareMemory(
>
> pOutBuf,pMPG->pMessage,pMPG->nDataLen)));
> break;
>
> The struct of MPG_PARA is
>
> typedef struct _MPG_PARAM {
> ULONG nDataLen;
> ULONG pMessage[1];
> } MPG_PARAM ,*PMPG_PARAM;
>
>
> Thanks a lot
>



Re: RtlCopyMemory problem by Mark

Mark
Sun May 21 11:23:31 CDT 2006

On 18 May 2006 21:40:25 -0700, hatepaul@gmail.com wrote:

>hi all
>
>I used "allocateCommonBuffer" function to assign the memory allocation
>for
>DMA transmission.
>At the meantime, the data transferred from AP through "DeciveioCotrol"
>function are copied using "RtlCopyMemory" function, and then both data
>are
>compared using "RtlCompareMemory", there are some difference between
>the two
>in some circumstances. Why is that so?
>

Assuming that you are evaluating the results of RtlCompareMemory
correctly, there should be no differences. That said, of course if
either buffer can be asynchronously modified while you are doing your
comparison, then of course comparisons would be a problem.


>The code is as follow:
>
>case IOCTL_SEND_DATA:
>pMPG = (PMPG_PARAM) pIrp->AssociatedIrp.SystemBuffer;
>
>pOutBuf = (PULONG) pLDI->DMABuffers[0].Virtual;<--form
>allocateCommonBuffer
>
>RtlCopyMemory(pOutBuf, pMPG->pMessage, pMPG->nDataLen);
>
>DbgTrace(("Cnt: %d \n",RtlCompareMemory(
>
>pOutBuf,pMPG->pMessage,pMPG->nDataLen)));
>break;
>
>The struct of MPG_PARA is
>
>typedef struct _MPG_PARAM {
>ULONG nDataLen;
>ULONG pMessage[1];
>} MPG_PARAM ,*PMPG_PARAM;
>
>
>Thanks a lot


=====================
Mark Roddy DDK MVP
Windows Vista/2003/XP/2000 Consulting
Device and Filesystem Drivers
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: RtlCopyMemory problem by hatepaul

hatepaul
Sun May 21 21:24:00 CDT 2006

Thanks all

I have try to compare memoey by use loop
I found the data is different form 1436 to end, form begin to 1435 byte
is correct
so I think the problem is same like Mark say
should I need to use a spin lock to protect it or another method ??