Found when run GetExeMachine function in Ahk2exe
Code: Select all
GetExeMachine(exepath)
{
exe := FileOpen(exepath, "r")
if !exe
return
exe.Seek(60), exe.Seek(exe.ReadUInt()+4)
return exe.ReadUShort()
}
Code: Select all
exe.Seek(60)
Code: Select all
GetExeMachine(exepath)
{
exe := FileOpen(exepath, "r")
if !exe
return
exe.Seek(60), exe.Seek(exe.ReadUInt()+4)
return exe.ReadUShort()
}
Code: Select all
exe.Seek(60)
Code: Select all
ExeFile:= "..."
MsgBox % GetExeMachine(ExeFile) ; 0x8664 (34404) = 64-bit, 0x014C (332) = 32-bit
MsgBox % GetBinaryType(ExeFile) ; 6 = 64-bit, 0 = 32-bit
GetExeMachine(ExeFile) {
f := FileOpen(ExeFile, "r")
If (!IsObject(f)) {
MsgBox 0x10, Error, % GetErrorMessage(A_LastError)
Return 0
}
f.Seek(60)
f.Seek(f.ReadUInt() + 4)
Return f.ReadUShort(), f.Close()
}
GetErrorMessage(ErrorCode, LanguageId := 0) {
VarSetCapacity(ErrorMsg, 8192)
DllCall("Kernel32.dll\FormatMessage"
, "UInt", 0x1200 ; FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
, "UInt", 0
, "UInt", ErrorCode + 0
, "UInt", LanguageId
, "Str" , ErrorMsg
, "UInt", 8192)
Return StrGet(&ErrorMsg)
}
GetBinaryType(ExeFile) {
Return DllCall("Kernel32.dll\GetBinaryTypeW", "WStr", ExeFile, "Ptr*", BinaryType) ? BinaryType : -1
}
Code: Select all
ExeFile:= "..."
MsgBox GetExeMachine(ExeFile) ; 0x8664 (34404) = 64-bit, 0x014C (332) = 32-bit
MsgBox GetBinaryType(ExeFile) ; 6 = 64-bit, 0 = 32-bit
GetExeMachine(ExeFile) {
Local f, Machine
f := FileOpen(ExeFile, "r")
If (!IsObject(f)) {
MsgBox(GetErrorMessage(A_LastError), "Error", 0x10)
Return 0
}
f.Seek(60)
f.Seek(f.ReadUInt() + 4)
Machine := f.ReadUShort()
f.Close()
Return Machine
}
GetErrorMessage(ErrorCode, LanguageId := 0) {
VarSetCapacity(ErrorMsg, 8192)
DllCall("Kernel32.dll\FormatMessage"
, "UInt", 0x1200 ; FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS
, "UInt", 0
, "UInt", ErrorCode + 0
, "UInt", LanguageId
, "Str" , ErrorMsg
, "UInt", 8192)
Return StrGet(&ErrorMsg)
}
GetBinaryType(ExeFile) {
Return DllCall("Kernel32.dll\GetBinaryTypeW", "WStr", ExeFile, "Ptr*", BinaryType) ? BinaryType : -1
}
Users browsing this forum: No registered users and 30 guests