[Tutor] ctypes wintypes

eryk sun eryksun at gmail.com
Fri Oct 6 14:48:06 EDT 2017


On Fri, Oct 6, 2017 at 7:26 PM, Michael C
<mysecretrobotfactory at gmail.com> wrote:
>
> I started out with what you gave me:
>
[...]
>
> I am trying to acquire "lpMinimumApplicationAddress" and
> "lpMaximumApplicationAddress" from system_info, so I did this,
>
>>code
> Kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
> Kernel32.GetSystemInfo(LPSYSTEM_INFO)
> print(LPLPSYSTEM_INFO.lpMinimumApplicationAddress)

It's the same pattern as before. Create a SYSTEM_INFO instance, which
allocates the block of memory for the information, and pass
GetSystemInfo a pointer. For example:

    kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
    kernel32.GetSystemInfo.restype = None
    kernel32.GetSystemInfo.argtypes = (LPSYSTEM_INFO,)

    sysinfo = SYSTEM_INFO()
    kernel32.GetSystemInfo(ctypes.byref(sysinfo))

Here are the minimum and maximum addresses for a 64-bit process,
formatted in hexadecimal:

    >>> hex(sysinfo.lpMinimumApplicationAddress)
    '0x10000'
    >>> hex(sysinfo.lpMaximumApplicationAddress)
    '0x7ffffffeffff'


More information about the Tutor mailing list