Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

char * and memcpy

17 views
Skip to first unread message

Doug Harrison [MVP]

unread,
Sep 10, 2001, 12:43:27 PM9/10/01
to
Manfred Naumann wrote:

>Im trying to scan some memory i got from ReadProcessMemory for 4 DWORD
>values in a row. the array of DWORD ( initiator ) contains them. The Problem
>is: the MessageBox ( first one ) doesnt show real data! its just a number
>which is increased each loop. Can anyone tell me whats wrong?
>
>char * pdest;
>pdest = new char [1677220];
>[..somereadprocessmemory stuff..]
>DWORD buffer2=0;
>char *p;
> while (i< (bytesread/4))
> {
> p=(char*)pdest+nbase;
> memcpy(&buffer2, &p, sizeof(DWORD));

Change &p to p.

Also, if you use sizeof(buffer2) instead of sizeof(DWORD), it's a
little easier to maintain the memcpy in the face of changes to
buffer2's type.

--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.eluent.com
Tools for Visual C++ and Windows

Raj Kulkarni

unread,
Sep 10, 2001, 12:46:56 PM9/10/01
to
Reset your clock to the correct time, and maybe somebody will help you.


"Manfred Naumann" <so...@keinemail.de> wrote in message
news:#mdlUAhOBHA.1692@tkmsftngp04...


> Im trying to scan some memory i got from ReadProcessMemory for 4 DWORD
> values in a row. the array of DWORD ( initiator ) contains them. The
Problem
> is: the MessageBox ( first one ) doesnt show real data! its just a number
> which is increased each loop. Can anyone tell me whats wrong?
>
> char * pdest;
> pdest = new char [1677220];
> [..somereadprocessmemory stuff..]
> DWORD buffer2=0;
> char *p;
> while (i< (bytesread/4))
> {
> p=(char*)pdest+nbase;
> memcpy(&buffer2, &p, sizeof(DWORD));

> sprintf(tmp,"Got this DWORD %d at Address%d",buffer2,nbase);
> MessageBox(tmp);
> if (buffer2 == initiator[j])
> j++;
> else
> j = 0;
> if (j==4)
> {
> sprintf(buff,"GOT IT!!!! %d",buffer2);
> MessageBox(buff);
> }
>
> nbase+=4;
> i++;
>
> }
>
> delete []pdest;
>
>
>
>
>


Manfred Naumann

unread,
Sep 10, 2001, 2:40:27 PM9/10/01
to
done - im sorry
"Raj Kulkarni" <rajku...@gl.com> schrieb im Newsbeitrag
news:e97M0ghOBHA.1392@tkmsftngp03...
0 new messages