tags:

views:

37

answers:

2

Hellow every one. I was wondering whether it would be possible to write a python script that retrieves header information from an .exe file. I tried googling but didn't really find any results that were usable.

Thanks.

Sept

A: 

Of course it is possible to write a Python script to retrieve header information from an XYZ file. Three simple steps:

(1) Find docs for the header part of an XYZ file; read them.

(2) Read the docs for the Python struct module or ctypes module or both.

(3) Write and test the script.

Which step are you having trouble with?

John Machin
Hi. Thanks for your quick reply.
Sept
Basically all parts of it except step 3. I am not new to pytohn but i am new to this kind of programming. Could you maybe offer a short code snippet or the like? A practical example. I would be very grateful.
Sept
@Sept: I can't imagine how a short code snippet could provide a practical example. Besides, you said you weren't having trouble with step 3. If you are serious about developing your skills in this area, here is one of the shortest practical examples: (1) google for docs on the DBF (dbaseIII, Foxpro, etc) format (2) find Raymond Hettinger's dbase3 reading script in the Python Cookbook (3) compare at least the header-reading part of the script with the docs
John Machin
+1  A: 

There is pefile : multi-platform Python module to read and work with Portable Executable (aka PE) files. Most of the information in the PE Header is accessible, as well as all the sections, section's information and data.

Michał Niklas