See posts below for much better and more useful updates of this script
Versions:
v2: http://www.xyplorer.com/xyfc/viewtopic. ... 74#p111439
v3: http://www.xyplorer.com/xyfc/viewtopic. ... 74#p111498
v4: http://www.xyplorer.com/xyfc/viewtopic. ... 74#p111515
v5: http://www.xyplorer.com/xyfc/viewtopic. ... 74#p111533
v6: http://www.xyplorer.com/xyfc/viewtopic. ... 15#p111620
=============
These are the original very basic first versions of the script and CC by me, kept here for history's sake.
Script:
Code: Select all
"Bitness Detector"
//first version, by SammaySarkar, 13th April, 2014
$filext = getpathcomponent(<curitem>,ext);
if ($filext == "exe") || ($filext == "dll") || ($filext == "ocx") || ($filext == "cpl") { $file = "<curitem>"; }
else { $file = inputfile("<curpath>","exe|dll|ocx|cpl", "Choose a valid file"); }
unset $filext;
if ( readfile($file, b, 2,, 1) == "MZ" ) {
$pntr = hexdump(readfile($file, b, 4,, 61),,r);
$pntr = hextodec(gettoken($pntr,2).gettoken($pntr,1));
if ($pntr-8 <= filesize($file)) {
$bitnum = hexdump(readfile($file, b, 6,, $pntr+1),,r);
if ( strpos($bitnum, '64 86') != -1 ) { msg "$file<crlf>is 64 bit."; }
elseif ( strpos($bitnum, '00 02') != -1 ) { msg "$file<crlf>is 64 bit (IA64)."; }
elseif ( strpos($bitnum, '4C 01') != -1 ) { msg "$file<crlf>is 32 bit."; }
elseif (strpos($bitnum, '4E 45') != -1) || (strpos($bitnum, '4C 45') != -1) { msg "$file<crlf>is 16 bit."; }
//elseif( ) { msg"$file<crlf>is bit"; }
else { msg "$file<crlf>is a DOS program."; }
} else { msg "$file<crlf>is probably a DOS program."; }
} else { msg "Cannot detect bitness."; }
Code: Select all
Snip: CustomColumn 1
XYplorer 14.00.0115, 5/14/2014 08:49:06 AM
Action
ConfigureColumn
Caption
Bitness
Type
3
Definition
$file = <cc_item>;
if (readfile($file, b, 2, , 1) == "MZ") {
$pntr = hexdump(readfile($file, b, 4, , 61),,r);
$pntr = hextodec(gettoken($pntr,2).gettoken($pntr,1));
if ($pntr-8 <= filesize($file)) {
$bitnum = hexdump(readfile($file, b, 6,, $pntr+1), ,r);
if (strpos($bitnum, '64 86') != -1) { return "64bit"; }
elseif (strpos($bitnum, '00 02') != -1) { return "~64bit"; }
elseif (strpos($bitnum, '4C 01') != -1) { return "32bit"; }
elseif (strpos($bitnum, '4E 45') != -1)||(strpos($bitnum, '4C 45') != -1) { return "16bit"; }
else { return "DOS"; }
} else { return "~DOS"; }
} else { return "N/A"; }
Format
0
Trigger
1
Item Type
0
Item Filter
exe;dll;ocx;cplIt only detects "plain" 64bit and 32bit files, old DOS exe's and .NET is unsupported.
Check posts below for better detection.
XYplorer Beta Club