Re: [Tutor] using while loop for read process memory
Michael C <[email protected]> Sun, 8 Oct 2017 16:49:31 -0700
| Newsgroups | gmane.comp.python.ctypes,gmane.comp.python.tutor |
|---|---|
| Message-ID | <CANyKM1gkG8qfXthYFFxEdMj3S=maq_w++MncVMqLdmc=3HPdJQ@mail.gmail.com> |
--===============7034264788432699456== Content-Type: multipart/alternative; boundary="001a113500c8be0fc8055b11b977" --001a113500c8be0fc8055b11b977 Content-Type: text/plain; charset="UTF-8" thank for replying, but I am toast, so I'll reply tomorrow, thanks! On Sun, Oct 8, 2017 at 4:46 PM, Alan Gauld via Tutor <[email protected]> wrote: > On 08/10/17 20:18, Michael C wrote: > > This is the red part > > index = current_address > > end = current_address + mbi.RegionSize > > > > while index < end: > > if ReadProcessMemory(Process, index, ctypes.byref(buffer), \ > > ctypes.sizeof(buffer), > > ctypes.byref(nread)): > > ## value comparison to be implemented. > > pass > > else: > > raise ctypes.WinError(ctypes.get_last_error()) > > > > index += 1 > > I haven't been following this closely so may be way off here, > but does this mean you are incrementing the memory address > by 1? If so you are only increasing the pointer by 1 byte > but you are, presumably, reading multiple bytes at a time > (the size of the buffer presumably). > > Do you perhaps need to treat the buffer as a byte array > and use something like the struct module to decode it? > (assuming you know what you are reading...?) > > But I may be way off, I'm just going on a cursory look. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > --001a113500c8be0fc8055b11b977 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">thank for replying, but I am toast, so I'll reply tomo= rrow,<div>thanks!</div></div><div class=3D"gmail_extra"><br><div class=3D"g= mail_quote">On Sun, Oct 8, 2017 at 4:46 PM, Alan Gauld via Tutor <span dir= =3D"ltr"><<a href=3D"mailto:[email protected]" target=3D"_blank">tutor@py= thon.org</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style= =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span cl= ass=3D"">On 08/10/17 20:18, Michael C wrote:<br> > This is the red part=C2=A0<br> > =C2=A0 index =3D current_address<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 end =3D current_address + mbi.RegionSize<b= r> ><br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 while index < end:<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if ReadProcessMemory(Process= , index, ctypes.byref(buffer), \<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ctypes.sizeof(buffer),<br> > ctypes.byref(nread)):<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ## value compa= rison to be implemented.<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pass=C2=A0 =C2= =A0<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 else:<br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = raise ctypes.WinError(ctypes.get_<wbr>last_error())<br> ><br> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 index +=3D 1<br> <br> </span>I haven't been following this closely so may be way off here,<br= > but does this mean you are incrementing the memory address<br> by 1? If so you are only increasing the pointer by 1 byte<br> but you are, presumably, reading multiple bytes at a time<br> (the size of the buffer presumably).<br> <br> Do you perhaps need to treat the buffer as a byte array<br> and use something like the struct module to decode it?<br> (assuming you know what you are reading...?)<br> <br> But I may be way off, I'm just going on a cursory look.<br> <br> --<br> Alan G<br> Author of the Learn to Program web site<br> <a href=3D"http://www.alan-g.me.uk/" rel=3D"noreferrer" target=3D"_blank">h= ttp://www.alan-g.me.uk/</a><br> <a href=3D"http://www.amazon.com/author/alan_gauld" rel=3D"noreferrer" targ= et=3D"_blank">http://www.amazon.com/author/<wbr>alan_gauld</a><br> Follow my photo-blog on Flickr at:<br> <a href=3D"http://www.flickr.com/photos/alangauldphotos" rel=3D"noreferrer"= target=3D"_blank">http://www.flickr.com/photos/<wbr>alangauldphotos</a><br= > <br> <br> ______________________________<wbr>_________________<br> Tutor maillist=C2=A0 -=C2=A0 <a href=3D"mailto:[email protected]">Tutor@pyth= on.org</a><br> To unsubscribe or change subscription options:<br> <a href=3D"https://mail.python.org/mailman/listinfo/tutor" rel=3D"noreferre= r" target=3D"_blank">https://mail.python.org/<wbr>mailman/listinfo/tutor</a= ><br> </blockquote></div><br></div> --001a113500c8be0fc8055b11b977-- --===============7034264788432699456== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot --===============7034264788432699456== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users --===============7034264788432699456==--