Re: [Tutor] ctypes wintypes
eryk sun <[email protected]> Fri, 6 Oct 2017 23:29:36 +0100
| Newsgroups | gmane.comp.python.ctypes,gmane.comp.python.tutor |
|---|---|
| Message-ID | <CACL+1atJ5xQgdES5GKrEHwJpvEUWX4kXSLQGwWbTnJmYtS_qBw@mail.gmail.com> |
On Fri, Oct 6, 2017 at 11:05 PM, Michael C <[email protected]> wrote: > For this read process memory, if I am trying compose a LPCVOID > lpBaseAddress, am I not making a variable that equals to mbi.BaseAddress, > and then making a pointer pointing to it? > > start_address = mbi.BaseAddress > LPCVOID = ctypes.byref(start_address) LPCVOID is a pointer type; don't use it as a variable name because it's confusing to someone who's reading your code. The `BaseAddress` field is an LPVOID, which is an alias for ctypes.c_void_p. Simple C types such as c_void_p are automatically converted to Python native types such as int, bytes, and str. It's fine that mbi.BaseAddress is a Python int. With argtypes defined for ReadProcessMemory, ctypes will convert the int back to a void pointer for you automatically. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot