Accessing windows structures through ctypes.

R

Rajat

Hi,

Using ctypes can I access the windows structures like:

PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB),
PEB_LDR_DATA, etc?


Regards,
Rajat
 
A

alex23

R

Rajat

ctypes.wintypes lists all of the Windows structures included with the
module.

You should be able to use ctypes.Structure class to roll your own:

Thanks Alex. As you suggested, I'm trying to implemenet the below
structure, windows PEB, in Python:

typedef struct _PEB {
BYTE Reserved1[2];
BYTE BeingDebugged;
BYTE Reserved2[21];
PPEB_LDR_DATA LoaderData;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
BYTE Reserved3[520];
PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine;
BYTE Reserved4[136];
ULONG SessionId;
} PEB;

My equivalent Python structure is:
class PEB(Structure):
_fields_ = [("Reserved1", wintypes.BYTE * 2),
("BeingDebugged", wintypes.BYTE),
("Reserved2", wintypes.BYTE * 2),
("Reserved3", c_void_p),
("Ldr", pointer(PEB_LDR_DATA)),
("ProcessParameters", pointer
(RTL_USER_PROCESS_PARAMETERS)),
("Reserved4", wintypes.BYTE * 104),
("Reserved5", c_void_p),
(),
("Reserved6", wintypes.BYTE),
("Reserved7", c_void_p),
("SessionId", c_ulong)]

I'm not sure what needs to go in the above empty tuple for
"PPS_POST_PROCESS_INIT_ROUTINE PostProcessInitRoutine" (in Original
PEB).

Please suggest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top