Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Accessing windows structures through ctypes.

Reply
Thread Tools

Accessing windows structures through ctypes.

 
 
Rajat
Guest
Posts: n/a
 
      07-02-2009
Hi,

Using ctypes can I access the windows structures like:

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


Regards,
Rajat

 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      07-02-2009
On Jul 2, 3:42*pm, Rajat <rajat.dud...@gmail.com> wrote:
> Using ctypes can I access the windows structures like:
>
> PROCESS_INFORMATION_BLOCK, Process Environment Block(PEB),
> PEB_LDR_DATA, etc?


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:

http://docs.python.org/library/ctype...red-data-types
http://code.activestate.com/recipes/208699/
http://msdn.microsoft.com/en-us/libr...55(VS.85).aspx

 
Reply With Quote
 
 
 
 
Rajat
Guest
Posts: n/a
 
      07-02-2009

> > Using ctypes can I access the windows structures like:

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

>
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
structures, structures and more structures (questions about nestedstructures) Alfonso Morra C Programming 11 09-24-2005 07:42 PM
STRUCTURES accessing using i archilleswaterland@hotmail.com C Programming 6 04-10-2005 09:29 PM
STRUCTURES accessing using i archilleswaterland@hotmail.com C Programming 0 04-10-2005 06:30 PM
Adding items to listbox through java script then accessing through asp.net Brian Henry ASP .Net 5 08-03-2004 02:10 AM
Type Casting IPv4 and IPv6 structures to Generic Structures tweak C Programming 14 06-11-2004 02:43 PM



Advertisments