Chuck Esterbrook | 1 Jun 2003 02:59
Picon
Favicon

Enumerate DLL funcs?

Once I have a DLL such as "windll.user32", is there a way to enumerate 
the functions it exports?

Just curious,
--

-- 
Chuck
http://ChuckEsterbrook.com

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
Chuck Esterbrook | 2 Jun 2003 06:47
Picon
Favicon

Some comments and questions

Hi,

ctypes is great. I've already been using it and it's nice to be able 
call DLL funcs just by...calling them!  :-)

Requested tweaks:

- The docs refer to the A and W functions in Windows as "ANSI" and 
"UNICODE". That should be "ASCII" instead of "ANSI". You can confirm 
with "Programming Windows, 5th ed" by Petzold.

- When I say windll.user32.asdf a ValueError is raised. I think that 
should be an AttributeError instead, which is what I was expecting in 
some code I wrote.

- Minor typo in docs: "So out callback function..." --> "So our callback 
function..."

Questions:

- The SF project page says that the mailing list for ctypes is not yet 
archived. Yet I swear I was just reading the archive a day or two ago! 
Anyone know what's going on there?

- I see that various types like int are automatically accepted as 
arguments to functions. Why not floats as well?

- Can I enumerate/introspect what the functions and values that a DLL 
exports?

(Continue reading)

Niki Spahiev | 2 Jun 2003 12:44
Picon

Re: Some comments and questions

Chuck Esterbrook wrote:

> Requested tweaks:
> 
> - The docs refer to the A and W functions in Windows as "ANSI" and 
> "UNICODE". That should be "ASCII" instead of "ANSI". You can confirm 
> with "Programming Windows, 5th ed" by Petzold.

No its ANSI (0-255) and uses current ANSI code page (ACP) to translate 
to UNICODE on real win32 platforms. ASCII (0-127) has no code pages.

Niki Spahiev

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
Thomas Heller | 2 Jun 2003 17:44
Favicon

Re: Enumerate DLL funcs?

Chuck Esterbrook <ChuckEsterbrook <at> yahoo.com> writes:

> Once I have a DLL such as "windll.user32", is there a way to enumerate 
> the functions it exports?
> 
> Just curious,

Not in ctypes, and as far as I know there's no windows api function
which does it. A useful tool to see them is here:
http://www.dependencywalker.com/

Thomas

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
Thomas Heller | 2 Jun 2003 17:49
Favicon

Re: Some comments and questions

Chuck Esterbrook <ChuckEsterbrook <at> yahoo.com> writes:

> Hi,
> 
> ctypes is great. I've already been using it and it's nice to be able 
> call DLL funcs just by...calling them!  :-)
> 
> 
> Requested tweaks:
> 
> - The docs refer to the A and W functions in Windows as "ANSI" and 
> "UNICODE". That should be "ASCII" instead of "ANSI". You can confirm 
> with "Programming Windows, 5th ed" by Petzold.
> 

At least ANSI is used throughout the MSDN docs. But I would be happy to
be corrected, can you quote what Petzold says (I have only the first
edition IIRC)?

> - When I say windll.user32.asdf a ValueError is raised. I think that 
> should be an AttributeError instead, which is what I was expecting in 
> some code I wrote.
> 
> - Minor typo in docs: "So out callback function..." --> "So our callback 
> function..."
> 

I will fix these ASAP.

> 
(Continue reading)

Chuck Esterbrook | 2 Jun 2003 19:35
Picon
Favicon

Re: Some comments and questions

On Monday 02 June 2003 08:49 am, Thomas Heller wrote:
> Chuck Esterbrook <ChuckEsterbrook <at> yahoo.com> writes:
> > - The docs refer to the A and W functions in Windows as "ANSI" and
> > "UNICODE". That should be "ASCII" instead of "ANSI". You can
> > confirm with "Programming Windows, 5th ed" by Petzold.
>
> At least ANSI is used throughout the MSDN docs. But I would be happy
> to be corrected, can you quote what Petzold says (I have only the
> first edition IIRC)?

pg 33: "Instead, there are two entry points, one named MessageBoxA (the 
ASCII version) and the other named MessageBoxW (the widecharacter 
version)."

But if the MSDN docs say "ANSI", then perhaps Petzold is (gasp) wrong.  
:-)

--

-- 
Chuck
http://ChuckEsterbrook.com

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
Andrew Smart | 3 Jun 2003 17:30
Picon

Beginners question: generating ctypes out of header files

Hi,

I have a typical "beginners" question:
is there a tool out to generate ctypes/Python code out of the content
of a C/C++ header file?

I found only stuff for COM in the examples. May I be blind? :-)

Andrew

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
Thomas Heller | 3 Jun 2003 17:56
Favicon

Re: Beginners question: generating ctypes out of header files

"Andrew Smart" <Andrew.Smart <at> smart-knowhow.de> writes:

> Hi,
> 
> I have a typical "beginners" question:
> is there a tool out to generate ctypes/Python code out of the content
> of a C/C++ header file?

No, not yet. I don't yet intend to write such a tool myself since I
mostly use ctypes to call windows api functions, and IMO it's nearly
impossible to parse MS VC header files ;-)

Jimy Retzlaff has posted a script to generate ctypes code from VB
declarations, maybe this can be used as a start if someone wants to try
it.

It can be found by searching for "VB DLL Function Declarations" in the
archives:

http://aspn.activestate.com/ASPN/search?query=VB+DLL+Function+Declarations&x=0&y=0&type=Archive_ctypes-users_list

http://tinyurl.com/dcwm

Thomas

-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
(Continue reading)

Chuck Esterbrook | 5 Jun 2003 04:08
Picon
Favicon

Re: Beginners question: generating ctypes out of header files

On Tuesday 03 June 2003 08:30 am, Andrew Smart wrote:
> Hi,
>
> I have a typical "beginners" question:
> is there a tool out to generate ctypes/Python code out of the content
> of a C/C++ header file?
>
> I found only stuff for COM in the examples. May I be blind? :-)
>
> Andrew

Hey, I'm looking for one two!  I'd like to use it on things like 
WINUSER.H.

I was contemplating hijaacking portions of SWIG which already has a C 
preprocessor and C parser (implemented in C). Perhaps those parts can 
be SWIGed or invoked from ctypes so that we can use them from Python.

But then maybe we could just use SWIG anyway? I haven't tried it yet on 
a WIN32 API header, but I suspect there must be a monkey wrech 
somewhere, or win32all would already be wrapping everything...

--

-- 
Chuck
http://ChuckEsterbrook.com

-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
(Continue reading)

Niki Spahiev | 5 Jun 2003 09:48
Picon

Re: Beginners question: generating ctypes out of header files

Chuck Esterbrook wrote:

> Hey, I'm looking for one two!  I'd like to use it on things like 
> WINUSER.H.
> 
> I was contemplating hijaacking portions of SWIG which already has a C 
> preprocessor and C parser (implemented in C). Perhaps those parts can 
> be SWIGed or invoked from ctypes so that we can use them from Python.
> 

boost.python has pyste which uses gcc-xml to autogenerate classes.
Also there is SWIG xml output.
Once i saw python module cdecl which parses C type declarations.

HTH
Niki Spahiev

-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.

Gmane