Re: [Tutor] ctypes wintypes
eryk sun <[email protected]> Fri, 6 Oct 2017 19:48:06 +0100
| Newsgroups | gmane.comp.python.ctypes,gmane.comp.python.tutor |
|---|---|
| Message-ID | <CACL+1astabNggqpEQWLnkxzW1_YFVynO1KHuw0e0KqScjU4fTw@mail.gmail.com> |
On Fri, Oct 6, 2017 at 7:26 PM, Michael C <[email protected]> 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' ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot