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('kernel32', 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"><<a href=3D"mailto:[email protected]" target=3D"_bl=
ank">[email protected]</a>></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's not it, Python is perfectly happy with 0x0400 as=
a literal.<br>
<br>
Michael, is the code you'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>
"David A. Van Arnem" <<a href=3D"mailto:[email protected]">d=
[email protected]</a>> wrote:<br>
<br>
> Hi Michael,<br>
><br>
> I believe Python doesn't accept a hex representation like "0x=
0400".=C2=A0 In<br>
> situations where I've needed a hex value like that, I've used =
something<br>
> like:<br>
><br>
> PROCESS_QUERY_INFORMATION =3D int("400", 16)<br>
><br>
> This creates an integer from the string "400" in base 16 (he=
x).<br>
><br>
> David<br>
><br>
> On 12/09/2016 03:25 PM, Michael C wrote:<br>
> > Hi all:<br>
> ><br>
> >=C2=A0 =C2=A0 =C2=A0 =C2=A0 I am trying to write my own memory sca=
nner, but I have encountered a<br>
> > few problem. Apparently, directly specifying "<br>
> > PROCESS_QUERY_INFORMATION|<wbr>PROCESS_VM_READ" is not ok, s=
ince the interpreter<br>
> > returns "NameError: name 'PROCESS_QUERY_INFORMATION'=
is not defined"<br>
> ><br>
> > so I should do what I did here, to define it for myself first? is=
this<br>
> > correct?<br>
> ><br>
> > Thanks<br>
> ><br>
> > Code:<br>
> ><br>
> > import ctypes<br>
> ><br>
> > kernel32 =3D ctypes.WinDLL('kernel32', use_last_error=3DT=
rue)<br>
> ><br>
> > PROCESS_QUERY_INFORMATION =3D 0x0400<br>
> > PROCESS_VM_READ =3D 0x0010<br>
> ><br>
> > ph =3D kernel32.OpenProcess(PROCESS_<wbr>QUERY_INFORMATION|PROCES=
S_VM_<wbr>READ,False,<br>
> > 20224)<br>
> ><br>
> > print(ph)<br>
> ><br>
> ><br>
> ><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"noreferrer" target=3D"_blank">http://sdm.link/xeonphi</a><br>
> ><br>
> ><br>
> ><br>
> > ______________________________<wbr>_________________<br>
> > ctypes-users mailing list<br>
> > <a href=3D"mailto:[email protected]">ctypes-user=
s@lists.<wbr>sourceforge.net</a><br>
> > <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>
> ><br>
><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==--