Re: NtQuerySystemInformation
Thor Andreas Tangen <[email protected]> Wed, 28 Oct 2015 14:15:43 +0100
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CA+wbTUpa5A9pz+VGtA+sN+uK93j+5ec0pSARZLM+wsaVE_7C4w@mail.gmail.com> |
Why not call it as
spi = SYSTEM_HANDLE_INFORMATION()
retlen = c_ulong()
res = windll.ntdll.NtQuerySystemInformation(SystemHandleInformation,
byref(spi),
sizeof(spi),
byref(retlen))
On Wed, Oct 28, 2015 at 2:03 PM, Diez B. Roggisch <[email protected]> wrote:
> Have you tried defining the signature of NtQuerySystemInformation? It
> could be that arguments are being truncated.
>
> Also, is that really a CDLL, not a WINDLL?
>
> Cheers,
>
> Diez
>
> On 28 Oct 2015, at 13:31, Cristian Badescu <[email protected]>
> wrote:
>
> Hello,
>
> I am trying to get handles information by using NtQuerySystemInformation
> but my code fails for some reason. I am using the following code to call
> NtQuerySystemInformation:
>
> from ctypes import *
> from ctypes.util import *
>
> class SYSTEM_HANDLE(Structure):
>
> _fields_ = [("ProcessId", c_ulong),
> ("ObjetTypeNumber", c_byte),
> ("Flags", c_byte),
> ("Handle", c_ushort),
> ("Object", c_void_p ),
> ("GrantedAccess", c_ulong)
> ]
>
> class SYSTEM_HANDLE_INFORMATION(Structure):
>
> _fields_ = [("HandleCount", c_ulong),
> ("Handles", SYSTEM_HANDLE * 1)
> ]
>
> handleInfoSize = 65536
>
> SystemHandleInformation = 16
>
> c_lib=CDLL(find_library("c"))
> malloc=c_lib.malloc
> malloc.restype=c_void_p
> handleInfo = malloc(handleInfoSize)
>
> pHandleInfo = cast(handleInfo, POINTER(SYSTEM_HANDLE_INFORMATION))
>
> retVal = cdll.ntdll.NtQuerySystemInformation(SystemHandleInformation, pHandleInfo, handleInfoSize, None)
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> ctypes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ctypes-users
>
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> ctypes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ctypes-users
>
>
------------------------------------------------------------------------------
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users