Re: How come this is different?

Michael C <[email protected]> Fri, 9 Dec 2016 16:03:36 -0800
Newsgroups gmane.comp.python.ctypes
Message-ID <CANyKM1hs-C_j9wbhLrm_A2Q9BYaKnATd1HLzesc_kPpbOPCVFw@mail.gmail.com>
--===============8404595206414729891==
Content-Type: multipart/alternative; boundary=001a11c1511e2cf4a10543429aa7

--001a11c1511e2cf4a10543429aa7
Content-Type: text/plain; charset=UTF-8

Oh this is my entire work in progress, I pull those out to figure out the
windows API line by line, so I do have a .py containing only those, as seen
here:

import ctypes

kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)

PROCESS_QUERY_INFORMATION = 0x0400
PROCESS_VM_READ = 0x0010

ph = kernel32.OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,False,
20224)
print(ph)


On Fri, Dec 9, 2016 at 3:26 PM, Rob Gaddi <[email protected]>
wrote:

> That's not it, Python is perfectly happy with 0x0400 as a literal.
>
> Michael, is the code you've provided below all copied and pasted from your
> actual code, or did you retype any of it?  Is it all in fact at the
> 0-indent level and in the same file?  Likewise is that error report copied
> and pasted, or are you just paraphrasing?
>
> On Fri, 9 Dec 2016 15:33:12 -0700
> "David A. Van Arnem" <[email protected]> wrote:
>
> > Hi Michael,
> >
> > I believe Python doesn't accept a hex representation like "0x0400".  In
> > situations where I've needed a hex value like that, I've used something
> > like:
> >
> > PROCESS_QUERY_INFORMATION = int("400", 16)
> >
> > This creates an integer from the string "400" in base 16 (hex).
> >
> > David
> >
> > On 12/09/2016 03:25 PM, Michael C wrote:
> > > Hi all:
> > >
> > >        I am trying to write my own memory scanner, but I have
> encountered a
> > > few problem. Apparently, directly specifying "
> > > PROCESS_QUERY_INFORMATION|PROCESS_VM_READ" is not ok, since the
> interpreter
> > > returns "NameError: name 'PROCESS_QUERY_INFORMATION' is not defined"
> > >
> > > so I should do what I did here, to define it for myself first? is this
> > > correct?
> > >
> > > Thanks
> > >
> > > Code:
> > >
> > > import ctypes
> > >
> > > kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
> > >
> > > PROCESS_QUERY_INFORMATION = 0x0400
> > > PROCESS_VM_READ = 0x0010
> > >
> > > ph = kernel32.OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_
> READ,False,
> > > 20224)
> > >
> > > print(ph)
> > >
> > >
> > >
> > > ------------------------------------------------------------
> ------------------
> > > Developer Access Program for Intel Xeon Phi Processors
> > > Access to Intel Xeon Phi processor-based developer platforms.
> > > With one year of Intel Parallel Studio XE.
> > > Training and support from Colfax.
> > > Order your platform today.http://sdm.link/xeonphi
> > >
> > >
> > >
> > > _______________________________________________
> > > ctypes-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/ctypes-users
> > >
> >
>
>
> --
> Rob Gaddi, Highland Technology
> 18 Otis St.
> San Francisco, CA 94103
> 415-551-1700
>
> ------------------------------------------------------------
> ------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/xeonphi
> _______________________________________________
> ctypes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ctypes-users
>

--001a11c1511e2cf4a10543429aa7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Oh this is my entire work in progress, I pull those out to=
 figure out the windows API line by line, so I do have a .py containing onl=
y those, as seen here:<div><br></div><div><div>import ctypes</div><div><br>=
</div><div>kernel32 =3D ctypes.WinDLL(&#39;kernel32&#39;, use_last_error=3D=
True)</div><div><br></div><div>PROCESS_QUERY_INFORMATION =3D 0x0400</div><d=
iv>PROCESS_VM_READ =3D 0x0010</div><div><br></div><div>ph =3D kernel32.Open=
Process(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,False, 20224)</div><div>p=
rint(ph)</div></div><div><br></div></div><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote">On Fri, Dec 9, 2016 at 3:26 PM, Rob Gaddi <span dir=
=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a>&gt;</span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">That&#39;s not it, Python is perfectly happy with 0x0400 as=
 a literal.<br>
<br>
Michael, is the code you&#39;ve provided below all copied and pasted from y=
our actual code, or did you retype any of it?=C2=A0 Is it all in fact at th=
e 0-indent level and in the same file?=C2=A0 Likewise is that error report =
copied and pasted, or are you just paraphrasing?<br>
<div class=3D"HOEnZb"><div class=3D"h5"><br>
On Fri, 9 Dec 2016 15:33:12 -0700<br>
&quot;David A. Van Arnem&quot; &lt;<a href=3D"mailto:[email protected]">d=
[email protected]</a>&gt; wrote:<br>
<br>
&gt; Hi Michael,<br>
&gt;<br>
&gt; I believe Python doesn&#39;t accept a hex representation like &quot;0x=
0400&quot;.=C2=A0 In<br>
&gt; situations where I&#39;ve needed a hex value like that, I&#39;ve used =
something<br>
&gt; like:<br>
&gt;<br>
&gt; PROCESS_QUERY_INFORMATION =3D int(&quot;400&quot;, 16)<br>
&gt;<br>
&gt; This creates an integer from the string &quot;400&quot; in base 16 (he=
x).<br>
&gt;<br>
&gt; David<br>
&gt;<br>
&gt; On 12/09/2016 03:25 PM, Michael C wrote:<br>
&gt; &gt; Hi all:<br>
&gt; &gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 I am trying to write my own memory sca=
nner, but I have encountered a<br>
&gt; &gt; few problem. Apparently, directly specifying &quot;<br>
&gt; &gt; PROCESS_QUERY_INFORMATION|<wbr>PROCESS_VM_READ&quot; is not ok, s=
ince the interpreter<br>
&gt; &gt; returns &quot;NameError: name &#39;PROCESS_QUERY_INFORMATION&#39;=
 is not defined&quot;<br>
&gt; &gt;<br>
&gt; &gt; so I should do what I did here, to define it for myself first? is=
 this<br>
&gt; &gt; correct?<br>
&gt; &gt;<br>
&gt; &gt; Thanks<br>
&gt; &gt;<br>
&gt; &gt; Code:<br>
&gt; &gt;<br>
&gt; &gt; import ctypes<br>
&gt; &gt;<br>
&gt; &gt; kernel32 =3D ctypes.WinDLL(&#39;kernel32&#39;, use_last_error=3DT=
rue)<br>
&gt; &gt;<br>
&gt; &gt; PROCESS_QUERY_INFORMATION =3D 0x0400<br>
&gt; &gt; PROCESS_VM_READ =3D 0x0010<br>
&gt; &gt;<br>
&gt; &gt; ph =3D kernel32.OpenProcess(PROCESS_<wbr>QUERY_INFORMATION|PROCES=
S_VM_<wbr>READ,False,<br>
&gt; &gt; 20224)<br>
&gt; &gt;<br>
&gt; &gt; print(ph)<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ------------------------------<wbr>------------------------------=
<wbr>------------------<br>
&gt; &gt; Developer Access Program for Intel Xeon Phi Processors<br>
&gt; &gt; Access to Intel Xeon Phi processor-based developer platforms.<br>
&gt; &gt; With one year of Intel Parallel Studio XE.<br>
&gt; &gt; Training and support from Colfax.<br>
&gt; &gt; Order your platform today.<a href=3D"http://sdm.link/xeonphi" rel=
=3D"noreferrer" target=3D"_blank">http://sdm.link/xeonphi</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ______________________________<wbr>_________________<br>
&gt; &gt; ctypes-users mailing list<br>
&gt; &gt; <a href=3D"mailto:[email protected]">ctypes-user=
s@lists.<wbr>sourceforge.net</a><br>
&gt; &gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/ctypes-us=
ers" rel=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/<wb=
r>lists/listinfo/ctypes-users</a><br>
&gt; &gt;<br>
&gt;<br>
<br>
<br>
</div></div><span class=3D"HOEnZb"><font color=3D"#888888">--<br>
Rob Gaddi, Highland Technology<br>
18 Otis St.<br>
San Francisco, CA 94103<br>
<a href=3D"tel:415-551-1700" value=3D"+14155511700">415-551-1700</a><br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
------------------------------<wbr>------------------------------<wbr>-----=
-------------<br>
Developer Access Program for Intel Xeon Phi Processors<br>
Access to Intel Xeon Phi processor-based developer platforms.<br>
With one year of Intel Parallel Studio XE.<br>
Training and support from Colfax.<br>
Order your platform today.<a href=3D"http://sdm.link/xeonphi" rel=3D"norefe=
rrer" target=3D"_blank">http://sdm.link/xeonphi</a><br>
______________________________<wbr>_________________<br>
ctypes-users mailing list<br>
<a href=3D"mailto:[email protected]">ctypes-users@lists.<w=
br>sourceforge.net</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/ctypes-users" rel=
=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/<wbr>lists/=
listinfo/ctypes-users</a><br>
</div></div></blockquote></div><br></div>

--001a11c1511e2cf4a10543429aa7--


--===============8404595206414729891==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
--===============8404595206414729891==
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

--===============8404595206414729891==--