' Check if a binary (EXE or DLL) is 32 bit (x86) or 64 bit (x64)

Dim path
path = "c:\windows\system32\notepad.exe"

Set BinaryStream = CreateObject("ADODB.Stream")

BinaryStream.Type = 1
BinaryStream.Open

BinaryStream.LoadFromFile path
  
skip = BinaryStream.Read(&H3C)
positionSignature = BinaryStream.Read(4)

strPosition=""
For lngCounter = 0 to UBound(positionSignature)
    car= Ascb(Midb(positionSignature,lngCounter + 1, 1))
    strPosition=MyHex(car) & strPosition
Next

positionSignature = CInt("&H" & strPosition)

BinaryStream.Position = positionSignature

'WScript.Echo positionSignature

arr_signature = BinaryStream.Read(6)

signature=""
For lngCounter = 0 to UBound(arr_signature)
    car= Ascb(Midb(arr_signature,lngCounter + 1, 1))
    signature = signature & MyHex(car)
Next

BinaryStream.Close

'WScript.Echo signature

If signature="504500004C01"Then
  WScript.Echo"x86"
ElseIf signature="504500006486"Then
  WScript.Echo"x64"
EndIf



Function MyHex(c)
  s=Hex(c)
  If Len(s)=1Then
    s="0" & s
  EndIf
  MyHex=s
EndFunction

search for scripts

VbsEdit contains all these sample scripts!


Download Now!



Download   Home   Scripts

Copyright © 2001-2022 adersοft