Re: [ctypes-users] [Tutor] ctypes wintypes
Brought to you by:
theller
From: eryk s. <er...@gm...> - 2017-10-06 18:48:54
|
On Fri, Oct 6, 2017 at 7:26 PM, Michael C <mys...@gm...> 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' |