ctypes: point to buffer in structure

Jesse R jessrobe at gmail.com
Sat Jul 9 14:24:30 EDT 2011


Hey I've been trying to convert this to run through ctypes and i'm
having a hard time

typedef struct _SYSTEM_PROCESS_ID_INFORMATION
{
    HANDLE ProcessId;
    UNICODE_STRING ImageName;
} SYSTEM_PROCESS_IMAGE_NAME_INFORMATION,
*PSYSTEM_PROCESS_IMAGE_NAME_INFORMATION;

to

class SYSTEM_PROCESS_ID_INFORMATION(ctypes.Structure):
    _fields_ = [('pid', ctypes.c_ulong),
                    ('imageName', ctypes.c_wchar_p)]

processNameBuffer = ctypes.create_unicode_buffer(0x100)
pidInfo = SYSTEM_PROCESS_ID_INFORMATION(pid,
ctypes.byref(processNameBuffer))
status = ntdll.NtQuerySystemInformation(0x58, ctypes.byref(pidInfo),
ctypes.sizeof(pidInfo), None)

does anyone know how to get this working?



More information about the Python-list mailing list