Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5027 > unrolled thread
| Started by | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| First post | 2011-05-09 15:52 -0500 |
| Last post | 2011-05-09 16:44 -0500 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.lang.python
Finding the bitness of an arbitrary executable with Python Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-09 15:52 -0500
Re: Finding the bitness of an arbitrary executable with Python Richard Thomas <chardster@gmail.com> - 2011-05-09 14:02 -0700
Re: Finding the bitness of an arbitrary executable with Python Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2011-05-09 23:10 +0200
Re: Finding the bitness of an arbitrary executable with Python Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-09 16:44 -0500
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2011-05-09 15:52 -0500 |
| Subject | Finding the bitness of an arbitrary executable with Python |
| Message-ID | <mailman.1358.1304974381.9059.python-list@python.org> |
I need to find whether a given file is 32-bit or 64-bit (and raise an
exception if the file doesn't exist or isn't an executable file). I
thought platform.architecture() would do this, but it returns ('64bit',
'') no matter what value I assign to the executable parameter (looks
like it uses the given executable to find info on the underlying system
rather than info on the specific file, reverting to sys.executable if
there are any errors). A quick look on Google doesn't give me anything
useful. Something cross-platform would be nice, but it really only needs
to work on Windows (on win32 binaries).
[toc] | [next] | [standalone]
| From | Richard Thomas <chardster@gmail.com> |
|---|---|
| Date | 2011-05-09 14:02 -0700 |
| Message-ID | <a21ac8dd-4180-462c-8386-b37ec317cea1@j28g2000vbp.googlegroups.com> |
| In reply to | #5027 |
On May 9, 9:52 pm, Andrew Berg <bahamutzero8...@gmail.com> wrote:
> I need to find whether a given file is 32-bit or 64-bit (and raise an
> exception if the file doesn't exist or isn't an executable file). I
> thought platform.architecture() would do this, but it returns ('64bit',
> '') no matter what value I assign to the executable parameter (looks
> like it uses the given executable to find info on the underlying system
> rather than info on the specific file, reverting to sys.executable if
> there are any errors). A quick look on Google doesn't give me anything
> useful. Something cross-platform would be nice, but it really only needs
> to work on Windows (on win32 binaries).
I don't know of anything that does that. If you wanted to do it
yourself the correct place to start is by reading up on the Protable
Executable Format: http://en.wikipedia.org/wiki/PE_format. That page
has references to the MSDN article which is probably most useful.
Other platforms have other executable formats of course but there's no
reason it couldn't exist...
[toc] | [prev] | [next] | [standalone]
| From | Irmen de Jong <irmen.NOSPAM@xs4all.nl> |
|---|---|
| Date | 2011-05-09 23:10 +0200 |
| Message-ID | <4dc85842$0$81484$e4fe514c@news.xs4all.nl> |
| In reply to | #5027 |
On 9-5-2011 22:52, Andrew Berg wrote:
> I need to find whether a given file is 32-bit or 64-bit (and raise an
> exception if the file doesn't exist or isn't an executable file). I
> thought platform.architecture() would do this, but it returns ('64bit',
> '') no matter what value I assign to the executable parameter (looks
> like it uses the given executable to find info on the underlying system
> rather than info on the specific file, reverting to sys.executable if
> there are any errors). A quick look on Google doesn't give me anything
> useful. Something cross-platform would be nice, but it really only needs
> to work on Windows (on win32 binaries).
A few options are mentioned here:
http://stackoverflow.com/questions/1345632/determine-if-an-executable-or-library-is-32-or-64-bits-on-windows
-irmen
[toc] | [prev] | [next] | [standalone]
| From | Andrew Berg <bahamutzero8825@gmail.com> |
|---|---|
| Date | 2011-05-09 16:44 -0500 |
| Message-ID | <mailman.1361.1304977489.9059.python-list@python.org> |
| In reply to | #5030 |
On 2011.05.09 04:10 PM, Irmen de Jong wrote: > http://stackoverflow.com/questions/1345632/determine-if-an-executable-or-library-is-32-or-64-bits-on-windows The code using struct doesn't look terribly complicated, so that could work. I might need to inspect other executable types, but I don't see it being any time soon. Thank you.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web