[Tutor] ctypes wintypes
eryk sun
eryksun at gmail.com
Fri Oct 6 18:29:36 EDT 2017
On Fri, Oct 6, 2017 at 11:05 PM, Michael C
<mysecretrobotfactory at gmail.com> 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.
More information about the Tutor
mailing list