Topic: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64  (Read 2911 times)

0 Members and 1 Guest are viewing this topic.

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
Lancelot pointed it out to me, the neat li'll tool Sigcheck cannot be used for projects due to its licensing terms.
So I'm looking for another way to determine the platform of a given file like Sigcheck does (amongst others).

Let's have a look at Mark Russinovich's tool:
sigcheck -accepteula -q filename.ext | findstr /c:"MachineType"
This will produce an output like this:
        MachineType:    64-bit

I'd like to have another method of gaining the information x86|x64 when checking a file.
The benefit is obvious, we could foobar filename.ext, put the result into %Baz% and use it for instance in:
Set,%PluginArch%,%Baz%

Any suggestions, tips and hacks?
« Last Edit: October 28, 2015, 12:14:58 PM by Mikka »

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #1 on: October 28, 2015, 12:19:35 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Also, sometimes .exe is not compatible to NT5x ;)

it will also be nice to detect , side by side with Mikka's MachineType   :thumbsup:

Following Topic ........ :turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #2 on: October 28, 2015, 12:51:26 PM »

wingers

  • Chef
  • ***
  • Date Registered: Oct 2012
  • Posts: 163
Hi

Not sure if this is of any use to you or not - apologies in advance if not....   just something I came across a while back for another project:-

Freeware command line tool to detect if a exe is 32 or 64 bit =  http://securityxploded.com/exe-64bit-detector.php

Also used to be a tool called dumpbin as part of the Windows SDK which came with Visual Studio - not sure if still available or relevant

Finally found this - if you look down to a lower post there is a dropbox link with utility and the source code which may be handy? = http://superuser.com/questions/468575/is-there-a-command-line-tool-to-check-32-bit-or-64-bit-of-an-exe


Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #3 on: October 29, 2015, 12:40:43 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
Freeware command line tool to detect if a exe is 32 or 64 bit =  http://securityxploded.com/exe-64bit-detector.php
The license of this tool seems to be suitable. Might be a candidate.

Also used to be a tool called dumpbin as part of the Windows SDK which came with Visual Studio - not sure if still available or relevant
I didn't find a copy (and haven't installed VS myself).

Finally found this - if you look down to a lower post there is a dropbox link with utility and the source code which may be handy? = http://superuser.com/questions/468575/is-there-a-command-line-tool-to-check-32-bit-or-64-bit-of-an-exe
Minimalist solution and quite small, unfortunately it checks the existence of only one property (either 32bit or 64bit).
The combination of is32.exe and is64.exe would be better.

(Knowing whether an executable is or is not compatible to NT5x is also reasonable.
By the way, does Sigcheck detect this?)

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #4 on: October 29, 2015, 01:35:59 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
This looks quite interesting: Determining if App Executable is 32-bit or 64-bit.
I'm no C# developer. But looking at this code, I'd say this is not a complete program source yet.

Which code do I need to add in order to have a compilable cs file? For that I want to use
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
Always eager to learn something new. :cool:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #5 on: October 29, 2015, 01:47:08 AM »

JFX

  • Code Baker
  • Sr. Chef
  • ****
  • Date Registered: Dec 2010
  • Posts: 815
GetExeArch.exe "filename"

will set %ErrorLevel% to

0 - unknown
1 - I386
2 - IA64
3 - AMD64

* GetExeArch.7z (3.03 kB - downloaded 89 times.)

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #6 on: October 29, 2015, 02:07:41 AM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Thanks JFX,

This tools deserves another topic :smile:  :happy_dance:

This is what I was looking for  :cheerleader: :magic:
 I remember I seached same thing in very past too ;)....

I will test tonight or tomorrow  :thumbsup:





*
I did not check Sigcheck yet,

To test things:
here is none official Sumatra x64
https://www.dropbox.com/s/t5cvxuew6r063of/201510291500_SumatraPDF_v3.1_x64.7z?dl=0
that does not work on XPx64
"... is not a valid 32bit application."

deserves your hands JFX  :cool:

:turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #7 on: October 29, 2015, 02:18:03 AM »

JFX

  • Code Baker
  • Sr. Chef
  • ****
  • Date Registered: Dec 2010
  • Posts: 815
Hi Lancelot,

in the exe header OS version 6.0 is set as minimum requirement.

Not sure if there is a reason, but it seems to work after "downgrading" it.
http://www17.zippyshare.com/v/RSbDKgXh/file.html

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #8 on: October 29, 2015, 02:24:42 AM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Not sure if there is a reason, but it seems to work after "downgrading" it.

There is no reason,
it is I believe accidental,

reason is, compiler setting, I guess VS xxx (or whatever... ;) ) default compiler setting set to OS version 6.0

I reported it to Sumatra Official (preview x64) and they fixed it, and final Sumatra Release works ok...

Still, it will be nice to have a small tool to check "OS version" of .exe  :wink:



btw,
maybe a topic with "JFX Tools"  :cool:
to gather all these nice useful tools   :showoff:

:turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #9 on: October 29, 2015, 12:28:24 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Added GetExeArch.exe to Macro Library with Call,FileArch

Macro Library Call Topic -> http://TheOven.org/index.php?topic=45 -> Ctrl+F Call,FileArch

 :yahoo: :celebrate: :cancan:

:turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #10 on: October 29, 2015, 12:34:09 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
(Knowing whether an executable is or is not compatible to NT5x is also reasonable.
By the way, does Sigcheck detect this?)
no  :wink:
 well nothing urgent, time passes slowly and nicely :turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #11 on: October 29, 2015, 10:11:00 PM »

paraglider

  • Chef
  • ***
  • Date Registered: Mar 2011
  • Posts: 138
Try my tool at:

http://wb.paraglidernc.com/Files/pearch.zip

Will set the same exitcode as above. Also outputs:

<ARCH>  X.Y

where <ARCH> is AMD64 / I386 / IA64

X.Y = 5.1, 5.2, 6.0 etc being the major subsystem version.minor sub system version

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #12 on: October 30, 2015, 12:01:18 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
To get this straight, we now have the ML command Call,FileArch that returns the processor architecture.
What about an option to tell a 32 bit or 64 bit executable/library file apart (return value "x86" or "x64")?

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #13 on: October 30, 2015, 03:09:30 AM »

paraglider

  • Chef
  • ***
  • Date Registered: Mar 2011
  • Posts: 138
Both utilities return the architecture of the specified program. Not the os architecture.

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #14 on: October 30, 2015, 07:28:22 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
That's quite a roundabout way:
I'd have to match 0 to false, 1 to "x86", 2 to "x64", and 3 to "x64" as well.
Why can't we simply have x86 / x64 as return values, besides false if unknown or nonexisting file?

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #15 on: October 30, 2015, 08:59:24 AM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
To get this straight, we now have the ML command Call,FileArch that returns the processor architecture.
as paraglider underlined,
and written at Call topic,
Call,FileArch returns File processor architecture.

for hostos architecture,

Call,HostOSArch
available
Macro Library - Call - http://theoven.org/index.php?topic=45

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #16 on: October 30, 2015, 11:00:41 AM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Try my tool at:

 :thumbsup:

a mini request,
if you can add output like:
Quote
[Result]
AMD64 6.0
Arch=AMD64
OS=6.0

life will be easier for inireaders  :cool:

:turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #17 on: October 30, 2015, 11:40:05 AM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
@Lancelot:
I'd vote for a more practice-oriented implementation with an explicit return value.
0,1,2,3, x... that's error-prone and rather cumbersome!

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #18 on: October 30, 2015, 12:25:12 PM »

Lancelot

  • Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 6944
Hi Mikka,

changed
Call,FleArch
return values to

NotFound
Unknown
I386
IA64
AMD64

:turtle:

Re: Getting meta data "MachineType" or "Platform" of any file: x86 vs. x64
« Reply #19 on: October 30, 2015, 12:54:20 PM »

Mikka

  • Code Baker
  • Chef
  • ***
  • Location: Germany
  • Date Registered: May 2012
  • Posts: 234
That's better, thanks.
:smile:

GetExeArch is the versatile approach of what I'm after. For x86+x64 plugins I'm content with the basic approach.
Usually, I don't care if the exe is IA64 or AMD64, I'd pull that through StrFormat,Right,%FileArch%,2,%Bits% and pass this on to
Set,%PluginArch%,x%Bits%.

One more question, what's the purpose of var in Call,FileArch,var,<File>?
Got that part now, var lets us name a specific file handler:

Code: [Select]
Call,FileArch,SumatraInstaller,%DownloadFolder%\sumatrapdf-x64.exe
StrFormat,Right,%SumatraInstaller%,2,%Bits%
Set,%PluginArch%,x%Bits%
« Last Edit: October 30, 2015, 01:12:45 PM by Mikka, Reason: Post scriptum »

 

Powered by EzPortal