├── 7-zip.chm ├── AutoHotkey.chm ├── AutoHotkey_H.chm ├── Compiler ├── .gitignore ├── Ahk2Exe.ahk ├── Ahk2Exe.exe ├── Ahk2Exe.ico ├── Ahk2ExeDirectives.htm ├── AutoHotkeyA.exe ├── AutoHotkeyU.exe ├── BinMod.ahk ├── Compiler.ahk ├── Directives.ahk ├── ErrorCodes.md ├── IconChanger.ahk ├── Lib │ ├── AHKType.ahk │ ├── AhkExported.ahk │ ├── AhkMini.ahk │ ├── AhkThread.ahk │ ├── BinRun.ahk │ ├── BinToHex.ahk │ ├── ComVar.ahk │ ├── CreateScript.ahk │ ├── CriticalSection.ahk │ ├── DirGetParent.ahk │ ├── DynaRun.ahk │ ├── ErrorMessage.ahk │ ├── ExtractIconFromExecutable.ahk │ ├── FileGetInfo.ahk │ ├── FileReplace.ahk │ ├── FindFunc.ahk │ ├── FindLabel.ahk │ ├── GetEnv.ahk │ ├── GetExeMachine.ahk │ ├── HIBYTE.ahk │ ├── HIWORD.ahk │ ├── HexToBin.ahk │ ├── IsBom.ahk │ ├── IsFileInUse.ahk │ ├── LOBYTE.ahk │ ├── LOWORD.ahk │ ├── LoadPicture.ahk │ ├── MAKELANGID.ahk │ ├── MAKELCID.ahk │ ├── MAKELONG.ahk │ ├── MAKELPARAM.ahk │ ├── MAKELRESULT.ahk │ ├── MAKEWORD.ahk │ ├── MAKEWPARAM.ahk │ ├── MCodeH.ahk │ ├── ObjByRef.ahk │ ├── ObjShare.ahk │ ├── ResDelete.ahk │ ├── ResDllCreate.ahk │ ├── ResExist.ahk │ ├── ResGet.ahk │ ├── ResPut.ahk │ ├── ResPutFile.ahk │ ├── ResourceIndexToId.ahk │ ├── SetExeSubsystem.ahk │ ├── StrPutVar.ahk │ ├── TT.ahk │ ├── ToChar.ahk │ ├── ToInt.ahk │ ├── ToShort.ahk │ ├── ToUChar.ahk │ ├── ToUInt.ahk │ ├── ToUShort.ahk │ ├── VersionRes.ahk │ ├── WinGetPidList.ahk │ ├── addFile.ahk │ ├── addScript.ahk │ ├── ahkExec.ahk │ └── ahkExecuteLine.ahk ├── LiteZip.txt ├── README.txt ├── ScriptParser.ahk ├── logo.png ├── mpress.exe ├── upx.exe └── v2 │ ├── AutoHotkeyU.exe │ ├── lib.lnk │ └── lib │ ├── BCrypt.ahk │ ├── BinRun.ahk │ ├── BinToHex.ahk │ ├── CenterWindow.ahk │ ├── CreateScript.ahk │ ├── CriticalSection.ahk │ ├── DirGetParent.ahk │ ├── DynaRun.ahk │ ├── EnvUpdate.ahk │ ├── ErrorMessage.ahk │ ├── ExtractIconFromExecutable.ahk │ ├── FileReplace.ahk │ ├── FindFunc.ahk │ ├── FindLabel.ahk │ ├── FontExist.ahk │ ├── GetEnv.ahk │ ├── GetProcessParameter.ahk │ ├── HIBYTE.ahk │ ├── HIWORD.ahk │ ├── HexToBin.ahk │ ├── IsBom.ahk │ ├── IsFileInUse.ahk │ ├── LOBYTE.ahk │ ├── LOWORD.ahk │ ├── MAKELANGID.ahk │ ├── MAKELCID.ahk │ ├── MAKELONG.ahk │ ├── MAKELPARAM.ahk │ ├── MAKELRESULT.ahk │ ├── MAKEWORD.ahk │ ├── MAKEWPARAM.ahk │ ├── MCodeH.ahk │ ├── NewThread.ahk │ ├── ObjByRef.ahk │ ├── ObjShare.ahk │ ├── Progress.ahk │ ├── ResDelete.ahk │ ├── ResDllCreate.ahk │ ├── ResExist.ahk │ ├── ResGet.ahk │ ├── ResPut.ahk │ ├── ResPutFile.ahk │ ├── ResourceIndexToId.ahk │ ├── SQLite3.ahk │ ├── SevenZip.ahk │ ├── SplashImage.ahk │ ├── SplashTextOff.ahk │ ├── SplashTextOn.ahk │ ├── StrBuf.ahk │ ├── ThreadObj.ahk │ ├── ToChar.ahk │ ├── ToInt.ahk │ ├── ToShort.ahk │ ├── ToUChar.ahk │ ├── ToUInt.ahk │ ├── ToUShort.ahk │ ├── URLDownloadToVar.ahk │ ├── WinGetPidList.ahk │ ├── addScript.ahk │ ├── ahkExec.ahk │ ├── ahkExecuteLine.ahk │ ├── ahkLabel.ahk │ └── between.ahk ├── HASH ├── LICENSE ├── README.md ├── Win32a ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll ├── AutoHotkeySC.bin └── vcruntime140.dll ├── Win32a_MT ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll └── AutoHotkeySC.bin ├── Win32w ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll ├── AutoHotkeySC.bin └── vcruntime140.dll ├── Win32w_MT ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll └── AutoHotkeySC.bin ├── lib ├── AhkSelf.ahk ├── Attach.ahk ├── Clip2Object.ahk ├── CryptAES.ahk ├── FileGetVersionInfo.ahk ├── GetProcessWorkingDir.ahk ├── GlobalVarsScript.ahk ├── InjectAhkDll.ahk ├── NumSize.ahk ├── NumType.ahk ├── ObjTree.ahk ├── RapidHotkey.ahk ├── TT.ahk ├── WatchDirectory.ahk ├── WinApi.ahk ├── WinApiDef.ahk ├── Yaml.ahk ├── ZipFileRaw.ahk └── _Input.ahk ├── x64w ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll ├── AutoHotkeySC.bin └── vcruntime140.dll └── x64w_MT ├── AutoHotkey.dll ├── AutoHotkey.exe ├── AutoHotkeyMini.dll └── AutoHotkeySC.bin /7-zip.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/7-zip.chm -------------------------------------------------------------------------------- /AutoHotkey.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/AutoHotkey.chm -------------------------------------------------------------------------------- /AutoHotkey_H.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/AutoHotkey_H.chm -------------------------------------------------------------------------------- /Compiler/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.bin 3 | *.bak -------------------------------------------------------------------------------- /Compiler/Ahk2Exe.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/Ahk2Exe.exe -------------------------------------------------------------------------------- /Compiler/Ahk2Exe.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/Ahk2Exe.ico -------------------------------------------------------------------------------- /Compiler/AutoHotkeyA.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/AutoHotkeyA.exe -------------------------------------------------------------------------------- /Compiler/AutoHotkeyU.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/AutoHotkeyU.exe -------------------------------------------------------------------------------- /Compiler/Compiler.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | #Include ScriptParser.ahk 5 | #Include IconChanger.ahk 6 | #Include Directives.ahk 7 | 8 | AhkCompile(ByRef AhkFile, ExeFile := "", ByRef CustomIcon := "", BinFile := "", UseMPRESS := "", fileCP:="", UseCompression := "", UseInclude := "", UseIncludeResource := "", UsePassword := "AutoHotkey") 9 | { 10 | global ExeFileTmp, ExeFileG 11 | 12 | SetWorkingDir %AhkWorkingDir% 13 | SplitPath AhkFile,, Ahk_Dir,, Ahk_Name 14 | SplitPath ExeFile,, Edir,, Ename 15 | ExeFile := (Edir ? Edir : Ahk_Dir) "\" (xe:= Ename ? Ename : Ahk_Name ) ".exe" 16 | ExeFile := Util_GetFullPath(ExeFile) 17 | if (CustomIcon != "") 18 | { SplitPath CustomIcon,, Idir,, Iname 19 | CustomIcon := (Idir ? Idir : Ahk_Dir) "\" (Iname ? Iname : Ahk_Name ) ".ico" 20 | CustomIcon := Util_GetFullPath(CustomIcon) 21 | } 22 | SetWorkingDir %Ahk_Dir% ; Initial folder for any #Include's 23 | 24 | ; Get temp file name - remove any invalid "path/" from exe name (/ should be \) 25 | ExeFileTmp := Util_TempFile(, "exe~", RegExReplace(xe,"^.*/")) 26 | 27 | if BinFile = 28 | BinFile = %A_ScriptDir%\AutoHotkeySC.bin 29 | 30 | Util_DisplayHourglass() 31 | 32 | IfNotExist, %BinFile% 33 | Util_Error("Error: The selected AutoHotkeySC binary does not exist. (C1)" 34 | , 0x34, """" BinFile """") 35 | 36 | try FileCopy, %BinFile%, %ExeFileTmp%, 1 37 | catch 38 | Util_Error("Error: Unable to copy AutoHotkeySC binary file to destination." 39 | , 0x41, """" ExeFileTmp """") 40 | 41 | DerefIncludeVars.Delete("U_", "V_") ; Clear Directives entries 42 | DerefIncludeVars.Delete("A_WorkFileName") 43 | DerefIncludeVars.Delete("A_PriorLine") 44 | 45 | BinType := AHKType(ExeFileTmp) 46 | DerefIncludeVars.A_AhkVersion := BinType.Version 47 | DerefIncludeVars.A_PtrSize := BinType.PtrSize 48 | DerefIncludeVars.A_IsUnicode := BinType.IsUnicode 49 | 50 | ExeFileG := ExeFile 51 | BundleAhkScript(ExeFileTmp, AhkFile, UseMPRESS, CustomIcon, fileCP, UseCompression, UsePassword) 52 | ; the final step... 53 | Util_Status("Moving .exe to destination") 54 | 55 | Loop 56 | { FileMove, %ExeFileTmp%, %ExeFileG%, 1 57 | if !ErrorLevel 58 | break 59 | Util_HideHourglass() 60 | DetectHiddenWindows On 61 | if !WinExist("ahk_exe " ExeFileG) 62 | Util_Error("Error: Could not move final compiled binary file to " 63 | . "destination. (C1)", 0x45, """" ExeFileG """") 64 | else 65 | { SetTimer Buttons, 50 66 | wk := """" RegExReplace(ExeFileG, "^.+\\") """" 67 | MsgBox 51,Ahk2Exe Query,% "Warning: " wk " is still running, " 68 | . "and needs to be unloaded to allow replacement with this new version." 69 | . "`n`n Press the appropriate button to continue." 70 | . " ('Reload' unloads and reloads the new " wk " without any parameters.)" 71 | IfMsgBox Cancel 72 | Util_Error("Error: Could not move final compiled binary file to " 73 | . "destination. (C2)", 0x45, """" ExeFileG """") 74 | WinClose ahk_exe %ExeFileG% 75 | WinWaitClose ahk_exe %ExeFileG%,,1 76 | IfMsgBox No 77 | Reload := 1 78 | } } 79 | if Reload 80 | run "%ExeFileG%", %ExeFileG%\.. 81 | Util_HideHourglass() 82 | Util_Status("") 83 | } 84 | 85 | Buttons() 86 | { IfWinNotExist Ahk2Exe Query 87 | return 88 | SetTimer,, Off 89 | WinActivate 90 | ControlSetText Button1, &Unload 91 | ControlSetText Button2, && &Reload 92 | } 93 | 94 | BundleAhkScript(ExeFile, AhkFile, UseMPRESS, IcoFile="", fileCP="", UseCompression := 0, UsePassword := "") 95 | { 96 | global AhkPath := UseAhkPath 97 | if (AhkPath = "") 98 | AhkPath := SubStr(BinFile,"SC.bin") ? SubStr(BinFile,1,-5) ".exe" ? BinFile 99 | 100 | if fileCP is space 101 | if SubStr(DerefIncludeVars.A_AhkVersion,1,1) = 2 102 | fileCP := "UTF-8" ; Default for v2 is UTF-8 103 | else fileCP := A_FileEncoding 104 | 105 | try FileEncoding, %fileCP% 106 | catch e 107 | Util_Error("Error: Invalid codepage parameter """ fileCP """ was given.", 0x53) 108 | 109 | SplitPath, AhkFile,, ScriptDir 110 | 111 | ExtraFiles := [] 112 | ,Directives := PreprocessScript(ScriptBody, AhkFile, ExtraFiles) 113 | ,ScriptBody :=Trim(ScriptBody,"`n") 114 | If UseCompression { 115 | FileDelete, %A_AhkDir%\BinScriptBody.ahk 116 | FileAppend, %ScriptBody%, %A_AhkDir%\BinScriptBody.ahk, UTF-8 117 | If SubStr(DerefIncludeVars.A_AhkVersion,1,1) = 2 118 | PID:=DynaRun(" 119 | ( 120 | UsePassword:='' 121 | buf:=Buffer(bufsz:=10485760,00),totalsz:=0,buf1:=Buffer(10485760) 122 | Loop Read, '" A_AhkDir "\BinScriptBody.ahk' 123 | { 124 | If (A_LoopReadLine=''){ 125 | NumPut('Char', 10, buf.Ptr + totalsz) 126 | ,totalsz+=1 127 | continue 128 | } 129 | data:=StrBuf(A_LoopReadLine,'UTF-8') 130 | ,zip:=UsePassword?ZipRawMemory(data,, '" UsePassword "' ):ZipRawMemory(data) 131 | ,CryptBinaryToStringA(zip, zip.size, 0x1|0x40000000, 0, getvar(cryptedsz:=0)) 132 | ,tosavesz:=cryptedsz 133 | ,CryptBinaryToStringA(zip, zip.size, 0x1|0x40000000, buf1, getvar(cryptedsz)) 134 | ,NumPut('Char', 10, buf1.Ptr+cryptedsz) 135 | if (totalsz+tosavesz>bufsz) 136 | newbuf:=Buffer(bufsz*=2),RtlMoveMemory(newbuf,buf,totalsz),buf:=newbuf 137 | RtlMoveMemory(buf.Ptr + totalsz,buf1,tosavesz) 138 | ,totalsz+=tosavesz 139 | } 140 | NumPut('Char', 0, buf.Ptr + totalsz - 1) 141 | If !BinScriptBody := ZipRawMemory(buf.Ptr,totalsz,'" UsePassword "') 142 | ExitApp 143 | f:=FileOpen(A_AhkDir '\..\BinScriptBody.bin','w -rwd'),f.RawWrite(BinScriptBody),f.Close() 144 | )","BinScriptBody","",A_AhkDir "\v2\AutoHotkeyU.exe") 145 | else 146 | PID:=DynaRun(" 147 | ( 148 | VarSetCapacity(buf,bufsz:=10485760,00),totalsz:=0,VarSetCapacity(buf1,10485760) 149 | Loop, Read, " A_AhkDir "\BinScriptBody.ahk 150 | { 151 | If (A_LoopReadLine=""""){ 152 | NumPut(10, &buf, totalsz,""Char"") 153 | ,totalsz+=1 154 | continue 155 | } 156 | len:=StrPutVar(A_LoopReadLine,data,""UTF-8"") 157 | ,sz:=ZipRawMemory(&data, len, zip, """ UsePassword """) 158 | ,DllCall(""crypt32\CryptBinaryToStringA"",""PTR"", &zip,""UInt"", sz,""UInt"", 0x1|0x40000000,""UInt"", 0,""UIntP"", cryptedsz:=0) 159 | ,tosavesz:=cryptedsz 160 | ,DllCall(""crypt32\CryptBinaryToStringA"",""PTR"", &zip,""UInt"", sz,""UInt"", 0x1|0x40000000,""PTR"", &buf1,""UIntP"", cryptedsz) 161 | ,NumPut(10,&buf1,cryptedsz,""Char"") 162 | if (totalsz+tosavesz>bufsz) 163 | VarSetCapacity(buf,bufsz*=2) 164 | RtlMoveMemory((&buf) + totalsz,&buf1,tosavesz) 165 | ,totalsz+=tosavesz 166 | } 167 | NumPut(0,&buf,totalsz-1,""Char"") 168 | If !BinScriptBody_Len := ZipRawMemory(&buf,totalsz,BinScriptBody,""" UsePassword """) 169 | ExitApp 170 | f:=FileOpen(A_AhkDir ""\BinScriptBody.bin"",""w -rwd""),f.RawWrite(&BinScriptBody,BinScriptBody_Len),f.Close() 171 | )","BinScriptBody","",DerefIncludeVars.A_IsUnicode ? A_AhkDir "\AutoHotkeyU.exe" : A_AhkDir "\AutoHotkeyA.exe") 172 | Loop { 173 | Process, Exist, %PID% 174 | } Until (!ErrorLevel) 175 | FileRead,BinScriptBody, *c %A_AhkDir%\BinScriptBody.bin 176 | FileGetSize, BinScriptBody_Len, %A_AhkDir%\BinScriptBody.bin 177 | FileDelete, %A_AhkDir%\BinScriptBody.ahk 178 | FileDelete, %A_AhkDir%\BinScriptBody.bin 179 | } else 180 | VarSetCapacity(BinScriptBody, BinScriptBody_Len:=StrPut(ScriptBody, "UTF-8")) 181 | ,StrPut(ScriptBody, &BinScriptBody, "UTF-8") 182 | 183 | module := DllCall("BeginUpdateResource", "str", ExeFile, "uint", 0, "ptr") 184 | if !module 185 | Util_Error("Error: Error opening the destination file. (C1)", 0x31) 186 | 187 | SetWorkingDir % ScriptDir 188 | 189 | DerefIncludeVars.A_WorkFileName := ExeFile 190 | dirState := ProcessDirectives(ExeFile, module, Directives, IcoFile, UseCompression, UsePassword) 191 | IcoFile := dirState.IcoFile 192 | 193 | if outPreproc := dirState.OutPreproc 194 | { 195 | f := FileOpen(outPreproc, "w", "UTF-8-RAW") 196 | f.RawWrite(BinScriptBody, BinScriptBody_Len) 197 | f.Close() 198 | f := "" 199 | } 200 | 201 | Util_Status("Adding: Master Script") 202 | if !DllCall("UpdateResource", "ptr", module, "ptr", 10, "str", "E4847ED08866458F8DD35F94B37001C0" 203 | , "ushort", 0x409, "ptr", &BinScriptBody, "uint", BinScriptBody_Len, "uint") 204 | goto _FailEnd 205 | 206 | for each,file in ExtraFiles 207 | { 208 | Util_Status("Adding: " file) 209 | StringUpper, resname, file 210 | 211 | IfNotExist, %file% 212 | goto _FailEnd2 213 | If UseCompression{ 214 | FileRead, tempdata, *c %file% 215 | FileGetSize, tempsize, %file% 216 | If !filesize := ZipRawMemory(&tempdata, tempsize, filedata) 217 | Util_Error("Error: Could not compress the file to: " file, 0x43) 218 | } else { 219 | FileRead, filedata, *c %file% 220 | FileGetSize, filesize, %file% 221 | } 222 | 223 | if !DllCall("UpdateResource", "ptr", module, "ptr", 10, "str", resname 224 | , "ushort", 0x409, "ptr", &filedata, "uint", filesize, "uint") 225 | goto _FailEnd2 226 | VarSetCapacity(filedata, 0) 227 | } 228 | 229 | gosub _EndUpdateResource 230 | 231 | if dirState.ConsoleApp 232 | { 233 | Util_Status("Marking executable as a console application...") 234 | if !SetExeSubsystem(ExeFile, 3) 235 | Util_Error("Could not change executable subsystem!", 0x61) 236 | } 237 | SetWorkingDir %A_ScriptDir% 238 | 239 | RunPostExec(dirState) 240 | 241 | for k,v in [{MPRESS:"-x"},{UPX:"--all-methods --compress-icons=0"}][UseMPRESS] 242 | { Util_Status("Compressing final executable with " k " ...") 243 | if FileExist(wk := A_ScriptDir "\" k ".exe") 244 | RunWait % """" wk """ -q " v " """ ExeFile """",, Hide 245 | else Util_Error("Warning: """ wk """ not found.`n`n'Compress exe with " k 246 | . "' specified, but freeware " k ".EXE is not in compiler directory.",0) 247 | , UseMPRESS := 9 248 | } 249 | RunPostExec(dirState, UseMPRESS) 250 | 251 | return ; BundleAhkScript() exits here 252 | 253 | _FailEnd: 254 | gosub _EndUpdateResource 255 | Util_Error("Error adding script file:`n`n" AhkFile, 0x43) 256 | 257 | _FailEnd2: 258 | gosub _EndUpdateResource 259 | Util_Error("Error adding FileInstall file:`n`n" file, 0x44) 260 | 261 | _EndUpdateResource: 262 | if !DllCall("EndUpdateResource", "ptr", module, "uint", 0) 263 | { Util_Error("Error: Error opening the destination file. (C2)", 0 264 | ,,"This error may be caused by your anti-virus checker.`n" 265 | . "Press 'OK' to try again, or 'Cancel' to abandon.") 266 | goto _EndUpdateResource 267 | } 268 | return 269 | } 270 | 271 | class CTempWD 272 | { 273 | __New(newWD) 274 | { 275 | this.oldWD := A_WorkingDir 276 | SetWorkingDir % newWD 277 | } 278 | __Delete() 279 | { 280 | SetWorkingDir % this.oldWD 281 | } 282 | } 283 | 284 | RunPostExec(dirState, UseMPRESS := "") 285 | { for k, v in dirState["PostExec" UseMPRESS] 286 | { Util_Status("PostExec" UseMPRESS ": " v.1) 287 | RunWait % v.1, % v.2 ? v.2 : A_ScriptDir, % "UseErrorLevel " (v.3?"Hide":"") 288 | if (ErrorLevel != 0 && !v.4) 289 | Util_Error("Command failed with RC=" ErrorLevel ":`n" v.1, 0x62) 290 | } } 291 | 292 | Util_GetFullPath(path) 293 | { 294 | VarSetCapacity(fullpath, 260 * (!!A_IsUnicode + 1)) 295 | return DllCall("GetFullPathName", "str", path, "uint", 260, "str", fullpath, "ptr", 0, "uint") ? fullpath : "" 296 | } 297 | -------------------------------------------------------------------------------- /Compiler/Directives.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | #Include 5 | 6 | ProcessDirectives(ExeFile, module, cmds, IcoFile, UseCompression, UsePassword) 7 | { state := { ExeFile: ExeFile, module: module, resLang: 0x409, verInfo: {} 8 | , IcoFile: IcoFile, PostExec:[], PostExec0:[], PostExec1:[], PostExec2:[] } 9 | global priorlines 10 | for k, cmdline in cmds 11 | { while SubStr(cmds[k+A_Index], 1, 4) = "Cont" 12 | cmdline .= SubStr(cmds[k+A_Index], 6) 13 | Util_Status("Processing directive: " cmdline) 14 | state["cmdline"] := cmdline 15 | DerefIncludeVars.A_PriorLine := priorlines.RemoveAt(1) 16 | if !RegExMatch(cmdline, "^(\w+)(?:\s+(.+))?$", o) 17 | Util_Error("Error: Invalid directive: (D1)", 0x63, cmdline) 18 | args := [], nargs := 0 19 | StringReplace, o2, o2, ```,, `n, All 20 | Loop, Parse, o2, `,, %A_Space%%A_Tab% 21 | { 22 | StringReplace, ov, A_LoopField, `n, `,, All 23 | StringReplace, ov, ov, ``n, `n, All 24 | StringReplace, ov, ov, ``r, `r, All 25 | StringReplace, ov, ov, ``t, `t, All 26 | StringReplace, ov, ov,````, ``, All 27 | args.Insert(DerefIncludePath(ov, DerefIncludeVars, 1)), nargs++ 28 | } 29 | fn := Func("Directive_" o1) 30 | if !fn 31 | Util_Error("Error: Invalid directive: (D2)" , 0x63, cmdline) 32 | if (!fn.IsVariadic && (fn.MinParams-1 > nargs || nargs > fn.MaxParams-1)) 33 | Util_Error("Error: Wrongly formatted directive: (D1)", 0x64, cmdline) 34 | fn.(state, args*) 35 | } 36 | if Util_ObjNotEmpty(state.verInfo) 37 | { Util_Status("Changing version information...") 38 | ChangeVersionInfo(ExeFile, module, state.verInfo) 39 | } 40 | if IcoFile := state.IcoFile 41 | { Util_Status("Changing the main icon...") 42 | if !FileExist(IcoFile) 43 | Util_Error("Error changing icon: File does not exist.", 0x35, IcoFile) 44 | if !AddOrReplaceIcon(module, IcoFile, ExeFile, 159) 45 | Util_Error("Error changing icon: Unable to read icon or icon was of the wrong format.", 0x42, IcoFile) 46 | } 47 | return state 48 | } 49 | 50 | Directive_ConsoleApp(state) 51 | { state.ConsoleApp := true 52 | } 53 | Directive_Cont(state, txt*) 54 | { ; Handled above 55 | } 56 | Directive_Debug(state, txt) 57 | { Util_Error( "Debug: " txt, 0) 58 | } 59 | Directive_ExeName(state, txt) 60 | { global ExeFileG 61 | SplitPath ExeFileG,, gdir,,gname 62 | SplitPath txt ,, idir,,iname 63 | ExeFileG := (idir ? idir : gdir) "\" (iname ? iname : gname) ".exe" 64 | } 65 | Directive_Let(state, txt*) 66 | { for k in txt 67 | { wk := StrSplit(txt[k], "=", "`t ", 2) 68 | if (wk.Length() != 2) 69 | Util_Error("Error: Wrongly formatted directive: (D2)",0x64, state.cmdline) 70 | DerefIncludeVars[(name ~= "i)^U_" ? "" : "U_") wk.1] := wk.2 71 | } } 72 | Directive_Obey(state, name, txt, extra:=0) 73 | { global ahkpath 74 | IfExist %ahkpath% 75 | { if !(extra ~= "^[0-9]$") 76 | Util_Error("Error: Wrongly formatted directive: (D3)",0x64, state.cmdline) 77 | wk := Util_TempFile(, "Obey~") 78 | FileAppend % (txt~="^=" ? name ":" : "") txt "`nFileAppend % " name "," wk 0 79 | . "`n#NoEnv", %wk%, UTF-8 80 | Loop % extra 81 | FileAppend % "`nFileAppend % " name A_Index "," wk A_Index, %wk%, UTF-8 82 | RunWait "%ahkpath%" "%wk%",,Hide 83 | Loop % extra + 1 84 | { FileRead result, % wk (cnt := A_Index - 1) 85 | DerefIncludeVars[(name~="i)^U_"?"":"U_") name (cnt ? cnt : "")] := result 86 | } 87 | FileDelete %wk%? 88 | } } 89 | Directive_OutputPreproc(state, fileName) ; Old directive not documented? 90 | { state.OutPreproc := fileName 91 | } 92 | Directive_PostExec(state, txt, when="", WorkingDir="", Hidden=0, IgnoreErrors=0) 93 | { if !({"":1,0:1,1:1,2:1}[when] && {"":1,0:1,1:1}[Hidden] 94 | && {"":1,0:1,1:1}[IgnoreErrors]) 95 | Util_Error("Error: Wrongly formatted directive: (D4)",0x64, state.cmdline) 96 | state["PostExec" when].Push([txt, WorkingDir, Hidden, IgnoreErrors]) 97 | } 98 | Directive_Set(state, name, txt) 99 | { state.verInfo[name] := txt 100 | } 101 | Directive_SetCompanyName(state, txt) 102 | { state.verInfo.CompanyName := txt 103 | } 104 | Directive_SetCopyright(state, txt) 105 | { state.verInfo.LegalCopyright := txt 106 | } 107 | Directive_SetDescription(state, txt) 108 | { state.verInfo.FileDescription := txt 109 | } 110 | Directive_SetFileVersion(state, txt) 111 | { state.verInfo.FileVersion := txt 112 | } 113 | Directive_SetInternalName(state, txt) 114 | { state.verInfo.InternalName := txt 115 | } 116 | Directive_SetLanguage(state, txt) 117 | { state.verInfo.Language := txt 118 | } 119 | Directive_SetLegalTrademarks(state, txt) 120 | { state.verInfo.LegalTrademarks := txt 121 | } 122 | Directive_SetMainIcon(state, txt := "") 123 | { state.IcoFile := txt 124 | } 125 | Directive_SetName(state, txt) 126 | { state.verInfo.InternalName := state.verInfo.ProductName := txt 127 | } 128 | Directive_SetOrigFilename(state, txt) 129 | { state.verInfo.OriginalFilename := txt 130 | } 131 | Directive_SetProductName(state, txt) 132 | { state.verInfo.ProductName := txt 133 | } 134 | Directive_SetProductVersion(state, txt) 135 | { state.verInfo.ProductVersion := txt 136 | } 137 | Directive_SetVersion(state, txt) 138 | { state.verInfo.FileVersion := state.verInfo.ProductVersion := txt 139 | } 140 | 141 | Directive_UpdateManifest(state, admin, name = "", version = "", uiaccess = "") 142 | { xml := ComObjCreate("Msxml2.DOMDocument") 143 | xml.async := false 144 | xml.setProperty("SelectionLanguage", "XPath") 145 | xml.setProperty("SelectionNamespaces" 146 | , "xmlns:v1='urn:schemas-microsoft-com:asm.v1' " 147 | . "xmlns:v3='urn:schemas-microsoft-com:asm.v3'") 148 | if !xml.load("res://" state.ExeFile "/#24/#1") ; Load current manifest 149 | Util_Error("Error: Error opening destination file. (D2)", 0x31) 150 | node := xml.selectSingleNode("/v1:assembly/v1:assemblyIdentity") 151 | if !node ; Not AutoHotkey v1.1? 152 | Util_Error("Error: Error opening destination file. (D3)", 0x31) 153 | (version && node.setAttribute("version", version)) 154 | (name && node.setAttribute("name", name)) 155 | 156 | node := xml.selectSingleNode("/v1:assembly/v3:trustInfo/v3:security" 157 | . "/v3:requestedPrivileges/v3:requestedExecutionLevel") 158 | if !node ; Not AutoHotkey v1.1? 159 | Util_Error("Error: Error opening destination file. (D4)", 0x31) 160 | (admin=1 && node.setAttribute("level", "requireAdministrator")) 161 | (admin=2 && node.setAttribute("level", "highestAvailable")) 162 | (uiaccess && node.setAttribute("uiAccess", "true")) 163 | xml := RTrim(xml.xml, "`r`n") 164 | VarSetCapacity(data, data_size := StrPut(xml, "utf-8") - 1) 165 | StrPut(xml, &data, "utf-8") 166 | 167 | if !DllCall("UpdateResource", "ptr", state.module, "ptr", 24, "ptr", 1 168 | , "ushort", 1033, "ptr", &data, "uint", data_size, "uint") 169 | Util_Error("Error changing the version information. (D2)", 0x67) 170 | } 171 | 172 | Directive_UseResourceLang(state, resLang) 173 | { 174 | if resLang is not integer 175 | Util_Error("Error: Resource language must be an integer between 0 and 0xFFFF.", 0x65, resLang) 176 | if resLang not between 0 and 0xFFFF 177 | Util_Error("Error: Resource language must be an integer between 0 and 0xFFFF.", 0x65, resLang) 178 | state.resLang := resLang+0 179 | } 180 | 181 | Directive_AddResource(state, rsrc, resName := "", UseCompression := false) 182 | { 183 | resType := "" ; auto-detect 184 | if RegExMatch(rsrc, "^\*(\w+)\s+(.+)$", o) 185 | resType := o1, rsrc := o2 186 | resFile := Util_GetFullPath(rsrc) 187 | if !FileExist(rsrc) 188 | Util_Error("Error: specified resource does not exist:", 0x36, rsrc) 189 | SplitPath, resFile, resFileName,, resExt 190 | if !resName 191 | resName := resFileName, defResName := true 192 | StringUpper, resName, resName 193 | if resType = 194 | { 195 | ; Auto-detect resource type 196 | if resExt in bmp,dib 197 | resType := 2 ; RT_BITMAP 198 | else if resExt = ico 199 | resType := 14 ; RT_GROUP_ICON 200 | else if resExt = cur 201 | Util_Error("Error: Cursor resource adding is not supported yet!", 0x27) 202 | else if resExt in htm,html,mht 203 | resType := 23 ; RT_HTML 204 | else if resExt = manifest 205 | { 206 | resType := 24 ; RT_MANIFEST 207 | if defResName 208 | resName := 1 209 | } else 210 | resType := 10 ; RT_RCDATA 211 | } 212 | if resType = 14 213 | { 214 | if resName is not integer 215 | resName := 0 216 | AddOrReplaceIcon(state.module, resFile, state.ExeFile, resName) 217 | return 218 | } 219 | typeType := "str" 220 | nameType := "str" 221 | if resType is integer 222 | if resType between 0 and 0xFFFF 223 | typeType := "uint" 224 | if resName is integer 225 | if resName between 0 and 0xFFFF 226 | nameType := "uint" 227 | If UseCompression && resType=10{ 228 | FileRead, tempdata, *c %resFile% 229 | FileGetSize, tempsize, %resFile% 230 | If !fSize := ZipRawMemory(&tempdata, tempsize, fData) 231 | Util_Error("Error: Could not compress the file to: " file, 0x46) 232 | } 233 | 234 | if resType in 4,5,6,9,23,24 ; Deref text-type resources 235 | { 236 | FileRead fData, %resFile% 237 | fData1 := DerefIncludePath(fData, DerefIncludeVars, 1) 238 | VarSetCapacity(fData, fSize := StrPut(fData1, "utf-8") - 1) 239 | StrPut(fData1, &fdata, "utf-8") 240 | } else { 241 | FileGetSize, fSize, %resFile% 242 | VarSetCapacity(fData, fSize) 243 | FileRead, fData, *c %resFile% 244 | } 245 | pData := &fData 246 | if resType = 2 247 | { 248 | ; Remove BM header in order to make it a valid bitmap resource 249 | if fSize < 14 250 | Util_Error("Error: Impossible BMP file!", 0x66) 251 | pData += 14, fSize -= 14 252 | } 253 | if !DllCall("UpdateResource", "ptr",state.module, typeType,resType, nameType 254 | , resName, "ushort",state.resLang, "ptr",pData, "uint",fSize, "uint") 255 | Util_Error("Error adding resource:", 0x46, rsrc) 256 | VarSetCapacity(fData, 0) 257 | } 258 | 259 | ChangeVersionInfo(ExeFile, hUpdate, verInfo) 260 | { 261 | hModule := DllCall("LoadLibraryEx", "str", ExeFile, "ptr", 0, "ptr", 2, "ptr") 262 | if !hModule 263 | Util_Error("Error: Error opening destination file. (D1)", 0x31) 264 | 265 | hRsrc := DllCall("FindResource", "ptr", hModule, "ptr", 1, "ptr", 16, "ptr") ; Version Info\1 266 | hMem := DllCall("LoadResource", "ptr", hModule, "ptr", hRsrc, "ptr") 267 | vi := new VersionRes(DllCall("LockResource", "ptr", hMem, "ptr")) 268 | DllCall("FreeLibrary", "ptr", hModule) 269 | 270 | ffi := vi.GetDataAddr() 271 | props := SafeGetViChild(SafeGetViChild(vi, "StringFileInfo"), "040904b0") 272 | for k,v in verInfo 273 | { 274 | if !(k = "Language") 275 | SafeGetViChild(props, k).SetText(v) ; All properties 276 | if k in FileVersion,ProductVersion 277 | { ver := VersionTextToNumber(v) 278 | hiPart := (ver >> 32)&0xFFFFFFFF, loPart := ver & 0xFFFFFFFF 279 | if (k = "FileVersion") 280 | NumPut(hiPart, ffi+8, "UInt"), NumPut(loPart, ffi+12, "UInt") 281 | else NumPut(hiPart, ffi+16, "UInt"), NumPut(loPart, ffi+20, "UInt") 282 | } } 283 | VarSetCapacity(newVI, 16384) ; Should be enough 284 | viSize := vi.Save(&newVI) 285 | 286 | if (wk := verInfo.Language) ; Change language? 287 | { NumPut(verInfo.Language, newVI, viSize-4, "UShort") 288 | } 289 | DllCall("UpdateResource", "ptr", hUpdate, "ptr", 16, "ptr", 1 290 | , "ushort", 0x409, "ptr", 0, "uint", 0, "uint") ; Delete lang 0x409 291 | if !DllCall("UpdateResource", "ptr", hUpdate, "ptr", 16, "ptr", 1, "ushort" 292 | , wk ? wk : 0x409, "ptr", &newVI, "uint", viSize, "uint") ; Add new language 293 | Util_Error("Error changing the version information. (D1)", 0x67) 294 | } 295 | 296 | VersionTextToNumber(v) 297 | { 298 | r := 0, i := 0 299 | while i < 4 && RegExMatch(v, "O)^(\d+).?", o) 300 | { 301 | StringTrimLeft, v, v, % o.Len 302 | val := o[1] + 0 303 | r |= (val&0xFFFF) << ((3-i)*16) 304 | i ++ 305 | } 306 | return r 307 | } 308 | 309 | SafeGetViChild(vi, name) 310 | { 311 | c := vi.GetChild(name) 312 | if !c 313 | { 314 | c := new VersionRes() 315 | c.Name := name 316 | vi.AddChild(c) 317 | } 318 | return c 319 | } 320 | 321 | -------------------------------------------------------------------------------- /Compiler/ErrorCodes.md: -------------------------------------------------------------------------------- 1 | Possible Errors 2 | ========================================= 3 | 4 | ### `(0x00+)` General 5 | 6 | - `(0x0)` Compilation was successful. 7 | - `(0x1)` Error: Unknown error. 8 | - `(0x2)` Compilation was cancelled. 9 | - `(0x3)` Error: Bad parameters 10 | 11 | 12 | ### `(0x10+)` Syntax 13 | 14 | - `(0x1)` Error: The script contains syntax errors. 15 | - `(0x2)` Error: Invalid "FileInstall" syntax found. Note that the first parameter must not be specified using a continuation section. 16 | 17 | 18 | ### `(0x20+)` Not supported & AutoHotkey version dependent 19 | 20 | - `(0x1)` Error: #DerefChar is not supported. 21 | - `(0x2)` Error: #Delimiter is not supported. 22 | - `(0x3)` Error: /NoDecompile is not supported. 23 | - `(0x4)` Error: Password protection is not supported. 24 | - `(0x5)` Error: The AutoHotkey build used for auto-inclusion of library functions is not recognized. 25 | - `(0x6)` Error: Legacy AutoHotkey versions (prior to v1.1) can not be used to do auto-inclusion of library functions. 26 | - `(0x7)` Error: Cursor resource adding is not supported yet. 27 | 28 | 29 | ### `(0x30+)` File open & Not found 30 | 31 | - `(0x1)` Error: Error opening the destination file. 32 | - `(0x2)` Script or #include cannot be opened. 33 | - `(0x3)` Error: Source file not specified. 34 | - `(0x4)` Error: The selected AutoHotkeySC binary does not exist. 35 | - `(0x5)` Error changing icon: File does not exist. 36 | - `(0x6)` Error: Specified resource does not exist. 37 | 38 | 39 | ### `(0x40+)` File write 40 | 41 | - `(0x1)` Error: Unable to copy AutoHotkeySC binary file to destination. 42 | - `(0x2)` Error changing icon: Unable to read icon or icon was of the wrong format. 43 | - `(0x3)` Error adding script file 44 | - `(0x4)` Error adding FileInstall file 45 | - `(0x5)` Error: Could not move final compiled binary file to destination. 46 | - `(0x6)` Error adding resource. 47 | 48 | 49 | ### `(0x50+)` Miscellaneous 50 | 51 | - `(0x1)` You cannot drop more than one file of each type into this window! 52 | - `(0x2)` Error: cannot find AutoHotkey help file! 53 | - `(0x3)` Error: Invalid codepage parameter was given. 54 | 55 | 56 | ### `(0x60+)` Compiler directives 57 | 58 | - `(0x1)` Could not change executable subsystem. 59 | - `(0x2)` Command failed with RC=n. 60 | - `(0x3)` Error: Invalid directive. 61 | - `(0x4)` Error: Wrongly formatted directive. 62 | - `(0x5)` Error: Resource language must be an integer between 0 and 0xFFFF. 63 | - `(0x6)` Error: Impossible BMP file. 64 | - `(0x7)` Error changing the version information. 65 | -------------------------------------------------------------------------------- /Compiler/IconChanger.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | 5 | ; This code is based on Ahk2Exe's changeicon.cpp 6 | 7 | AddOrReplaceIcon(re, IcoFile, ExeFile, iconID := 0) 8 | { 9 | global _CI_HighestIconID, _CIG_HighestIconGroupID 10 | 11 | CountIcons(ExeFile) 12 | 13 | if !iconID 14 | { 15 | CountIconGroups(ExeFile) 16 | iconID := ++ _CIG_HighestIconGroupID 17 | } 18 | 19 | ids := EnumIcons(ExeFile, iconID) 20 | if !IsObject(ids) 21 | return false 22 | 23 | f := FileOpen(IcoFile, "r") 24 | if !IsObject(f) 25 | return false 26 | 27 | VarSetCapacity(igh, 8), f.RawRead(igh, 6) 28 | if NumGet(igh, 0, "UShort") != 0 || NumGet(igh, 2, "UShort") != 1 29 | return false 30 | 31 | wCount := NumGet(igh, 4, "UShort") 32 | 33 | VarSetCapacity(rsrcIconGroup, rsrcIconGroupSize := 6 + wCount*14) 34 | NumPut(NumGet(igh, "Int64"), rsrcIconGroup, "Int64") ; fast copy 35 | 36 | ige := &rsrcIconGroup + 6 37 | 38 | ; Delete all the images 39 | Loop, % ids.MaxIndex() 40 | DllCall("UpdateResource", "ptr", re, "ptr", 3, "ptr", ids[A_Index], "ushort", 0x409, "ptr", 0, "uint", 0, "uint") 41 | 42 | Loop, %wCount% 43 | { 44 | thisID := ids[A_Index] 45 | if !thisID 46 | thisID := ++ _CI_HighestIconID 47 | 48 | f.RawRead(ige+0, 12) ; read all but the offset 49 | NumPut(thisID, ige+12, "UShort") 50 | 51 | imgOffset := f.ReadUInt() 52 | oldPos := f.Pos 53 | f.Pos := imgOffset 54 | 55 | VarSetCapacity(iconData, iconDataSize := NumGet(ige+8, "UInt")) 56 | f.RawRead(iconData, iconDataSize) 57 | f.Pos := oldPos 58 | 59 | if !DllCall("UpdateResource", "ptr", re, "ptr", 3, "ptr", thisID, "ushort", 0x409, "ptr", &iconData, "uint", iconDataSize, "uint") 60 | return false 61 | 62 | ige += 14 63 | } 64 | 65 | return !!DllCall("UpdateResource", "ptr", re, "ptr", 14, "ptr", iconID, "ushort", 0x409, "ptr", &rsrcIconGroup, "uint", rsrcIconGroupSize, "uint") 66 | } 67 | 68 | CountIcons(ExeFile) 69 | { 70 | ; RT_ICON = 3 71 | global _CI_HighestIconID 72 | 73 | if _CI_HighestIconID 74 | return 75 | 76 | static pEnumFunc := RegisterCallback("CountIcons_Enum") 77 | 78 | hModule := DllCall("LoadLibraryEx", "str", ExeFile, "ptr", 0, "ptr", 2, "ptr") 79 | if !hModule 80 | return 81 | 82 | _CI_HighestIconID := 0 83 | DllCall("EnumResourceNames", "ptr", hModule, "ptr", 3, "ptr", pEnumFunc, "uint", 0) 84 | 85 | DllCall("FreeLibrary", "ptr", hModule) 86 | } 87 | 88 | CountIconGroups(ExeFile) 89 | { 90 | ; RT_GROUP_ICON = 14 91 | global _CIG_HighestIconGroupID 92 | 93 | if _CIG_HighestIconGroupID 94 | return 95 | 96 | static pEnumFunc := RegisterCallback("CountIconGroups_Enum") 97 | 98 | hModule := DllCall("LoadLibraryEx", "str", ExeFile, "ptr", 0, "ptr", 2, "ptr") 99 | if !hModule 100 | return 101 | 102 | _CIG_HighestIconGroupID := 0 103 | DllCall("EnumResourceNames", "ptr", hModule, "ptr", 14, "ptr", pEnumFunc, "uint", 0) 104 | 105 | DllCall("FreeLibrary", "ptr", hModule) 106 | } 107 | 108 | EnumIcons(ExeFile, iconID) 109 | { 110 | ; RT_GROUP_ICON = 14 111 | hModule := DllCall("LoadLibraryEx", "str", ExeFile, "ptr", 0, "ptr", 2, "ptr") 112 | if !hModule 113 | return 114 | 115 | hRsrc := DllCall("FindResource", "ptr", hModule, "ptr", iconID, "ptr", 14, "ptr") 116 | hMem := DllCall("LoadResource", "ptr", hModule, "ptr", hRsrc, "ptr") 117 | pDirHeader := DllCall("LockResource", "ptr", hMem, "ptr") 118 | pResDir := pDirHeader + 6 119 | 120 | wCount := NumGet(pDirHeader+4, "UShort") 121 | iconIDs := [] 122 | 123 | Loop, %wCount% 124 | { 125 | pResDirEntry := pResDir + (A_Index-1)*14 126 | iconIDs[A_Index] := NumGet(pResDirEntry+12, "UShort") 127 | } 128 | 129 | DllCall("FreeLibrary", "ptr", hModule) 130 | return iconIDs 131 | } 132 | 133 | CountIcons_Enum(hModule, type, name, lParam) 134 | { 135 | global _CI_HighestIconID 136 | if (name < 0x10000) && name > _CI_HighestIconID 137 | _CI_HighestIconID := name 138 | return 1 139 | } 140 | 141 | 142 | CountIconGroups_Enum(hModule, type, name, lParam) 143 | { 144 | global _CIG_HighestIconGroupID 145 | if (name < 0x10000) && name > _CIG_HighestIconGroupID 146 | _CIG_HighestIconGroupID := name 147 | return 1 148 | } 149 | -------------------------------------------------------------------------------- /Compiler/Lib/AHKType.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | 5 | ; Based on code from SciTEDebug.ahk 6 | AHKType(exeName) 7 | { 8 | FileGetVersion, vert, %exeName% 9 | if !vert 10 | return 11 | 12 | StringSplit, vert, vert, . 13 | vert := vert4 | (vert3 << 8) | (vert2 << 16) | (vert1 << 24) 14 | 15 | exeFile := FileOpen(exeName, "r") 16 | if !exeFile 17 | return 18 | exeFile.RawRead(exeData, exeFile.Length) 19 | exeFile.Close() 20 | 21 | Type := {} 22 | 23 | ; Get PtrSize based on machine type in PE header 24 | exeMachine := NumGet(exeData, NumGet(exeData, 60, "uint") + 4, "ushort") 25 | Type.PtrSize := {0x8664: 8, 0x014C: 4}[exeMachine] 26 | if !Type.PtrSize 27 | return ; Not a valid exe (or belongs to an unsupported platform) 28 | 29 | ; Get IsUnicode based on the presence of a string matching our encoding 30 | Type.IsUnicode := (!RegExMatch(exeData, "MsgBox\0") = !A_IsUnicode) ? 1 : "" 31 | 32 | if !(VersionInfoSize := DllCall("version\GetFileVersionInfoSize", "str", exeName, "uint*", null, "uint")) 33 | return 34 | 35 | VarSetCapacity(VersionInfo, VersionInfoSize) 36 | if !DllCall("version\GetFileVersionInfo", "str", exeName, "uint", 0, "uint", VersionInfoSize, "ptr", &VersionInfo) 37 | return 38 | 39 | if !DllCall("version\VerQueryValue", "ptr", &VersionInfo, "str", "\VarFileInfo\Translation", "ptr*", lpTranslate, "uint*", cbTranslate) 40 | return 41 | 42 | wLanguage := NumGet(lpTranslate+0, "UShort") 43 | wCodePage := NumGet(lpTranslate+2, "UShort") 44 | id := Format("{:04X}{:04X}", wLanguage, wCodePage) 45 | 46 | if !DllCall("version\VerQueryValue", "ptr", &VersionInfo, "str", "\StringFileInfo\" id "\FileVersion", "ptr*", pField, "uint*", cbField) 47 | return 48 | Type.Version := StrGet(pField, cbField) 49 | 50 | ; We're dealing with a legacy version if it's prior to v1.1 51 | Type.Era := vert >= 0x01010000 ? "Modern" : "Legacy" 52 | 53 | return Type 54 | } 55 | -------------------------------------------------------------------------------- /Compiler/Lib/AhkExported.ahk: -------------------------------------------------------------------------------- 1 | AhkExported(){ 2 | static init,functions 3 | If !init{ 4 | init:=Object(),functions:="ahkFunction:s==sssssssssss|ahkPostFunction:s==sssssssssss|ahkassign:ui==ss|ahkExecuteLine:t==tuiui|ahkFindFunc:t==s|ahkFindLabel:t==s|ahkgetvar:s==sui|ahkLabel:ui==sui|ahkPause:i==s" 5 | If (DllCall((exe:=!A_AhkPath?A_ScriptFullPath:A_AhkPath) "\ahkgetvar","Str","A_AhkPath","UInt",0,"CDecl Str")) 6 | functions.="|addFile:t==si|addScript:t==si|ahkExec:ui==s" 7 | Loop,Parse,functions,| 8 | {v:=StrSplit(A_LoopField,":"),init[v.1]:=DynaCall(exe "\" v.1,v.2) 9 | If (v.1="ahkFunction") 10 | init["_" v.1]:=DynaCall(exe "\" v.1,"s==stttttttttt") 11 | else if (v.1="ahkPostFunction") 12 | init["_" v.1]:=DynaCall(exe "\" v.1,"i==stttttttttt") 13 | } 14 | } 15 | return init 16 | } -------------------------------------------------------------------------------- /Compiler/Lib/AhkMini.ahk: -------------------------------------------------------------------------------- 1 | ahkmini(script:="",param:="",IsFile:=0,dll:="FC2328B39C194A4788051A3B01B1E7D5"){ 2 | return ahkthread(script,param,IsFile,dll) 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/AhkThread.ahk: -------------------------------------------------------------------------------- 1 | ahkthread_free(obj:=""){ 2 | static objects 3 | if !objects 4 | objects:=[] 5 | if (obj="") 6 | objects:=[] 7 | else if !IsObject(obj) 8 | return objects 9 | else If objects.HasKey(obj) 10 | objects.Remove(obj) 11 | } 12 | ahkthread_release(o){ 13 | o.ahkterminate(o.timeout?o.timeout:0),MemoryFreeLibrary(o[""]) 14 | } 15 | ahkthread(s:="",p:="",IsFile:=0,dll:=""){ 16 | static ahkdll,ahkmini,base,functions 17 | if !base 18 | base:={__Delete:"ahkthread_release"},UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","F903E44B8A904483A1732BA84EA6191F","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkdll) 19 | ,UnZipRawMemory(LockResource(LoadResource(0,hRes:=DllCall("FindResource","PTR",0,"Str","FC2328B39C194A4788051A3B01B1E7D5","PTR",10,"PTR"))),SizeofResource(0,hRes),ahkmini) 20 | ,functions:={_ahkFunction:"s==stttttttttt",_ahkPostFunction:"i==stttttttttt",ahkFunction:"s==sssssssssss",ahkPostFunction:"i==sssssssssss",ahkdll:"ut==sss",ahktextdll:"ut==sss",ahkReady:"",ahkReload:"i==i",ahkTerminate:"i==i",addFile:"ut==sucuc",addScript:"ut==si",ahkExec:"ui==s",ahkassign:"ui==ss",ahkExecuteLine:"ut==utuiui",ahkFindFunc:"ut==s",ahkFindLabel:"ut==s",ahkgetvar:"s==sui",ahkLabel:"ui==sui",ahkPause:"i==s",ahkIsUnicode:""} 21 | obj:={(""):lib:=MemoryLoadLibrary(dll=""?&ahkdll:dll="FC2328B39C194A4788051A3B01B1E7D5"?&ahkmini:dll),base:base} 22 | for k,v in functions 23 | obj[k]:=DynaCall(MemoryGetProcAddress(lib,A_Index>2?k:SubStr(k,2)),v) 24 | If !(s+0!="" || s=0) 25 | obj.hThread:=obj[IsFile?"ahkdll":"ahktextdll"](s,"",p) 26 | ahkthread_free(true)[obj]:=1 ; keep dll loadded even if returned object is freed 27 | return obj 28 | } -------------------------------------------------------------------------------- /Compiler/Lib/BinRun.ahk: -------------------------------------------------------------------------------- 1 | BinRun(pData,cmdLine:="",cmdLineScript:="",Hide:=0,ExeToUse:=""){ 2 | static IMAGE_DOS_HEADER,IMAGE_FILE_HEADER,IMAGE_DATA_DIRECTORY,IMAGE_OPTIONAL_HEADER64,IMAGE_OPTIONAL_HEADER32,IMAGE_NT_HEADERS,IMAGE_NT_HEADERS32,IMAGE_NT_HEADERS64,IMAGE_SECTION_HEADER,FLOATING_SAVE_AREA 3 | ,PROCESS_INFORMATION,STARTUPINFO,M128A,_XMM_SAVE_AREA32,CONTEXT64,CONTEXT32,IMAGE_NT_SIGNATURE,IMAGE_DOS_SIGNATURE,PAGE_EXECUTE_READWRITE,CREATE_SUSPENDED,MEM_COMMIT,MEM_RESERVE,STARTF_USESHOWWINDOW,h2o 4 | if !MEM_COMMIT 5 | IMAGE_DOS_HEADER :="WORD e_magic;WORD e_cblp;WORD e_cp;WORD e_crlc;WORD e_cparhdr;WORD e_minalloc;WORD e_maxalloc;WORD e_ss;WORD e_sp;WORD e_csum;WORD e_ip;WORD e_cs;WORD e_lfarlc;WORD e_ovno;WORD e_res[4];WORD e_oemid;WORD e_oeminfo;WORD e_res2[10];LONG e_lfanew" 6 | ,IMAGE_FILE_HEADER :="WORD Machine;WORD NumberOfSections;DWORD TimeDateStamp;DWORD PointerToSymbolTable;DWORD NumberOfSymbols;WORD SizeOfOptionalHeader;WORD Characteristics" 7 | ,IMAGE_DATA_DIRECTORY :="DWORD VirtualAddress;DWORD Size" 8 | ,IMAGE_OPTIONAL_HEADER64:="WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;ULONGLONG ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;ULONGLONG SizeOfStackReserve;ULONGLONG SizeOfStackCommit;ULONGLONG SizeOfHeapReserve;ULONGLONG SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;BinRun(IMAGE_DATA_DIRECTORY) DataDirectory[16]" 9 | ,IMAGE_OPTIONAL_HEADER32 :="WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;DWORD BaseOfData;DWORD ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;DWORD SizeOfStackReserve;DWORD SizeOfStackCommit;DWORD SizeOfHeapReserve;DWORD SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;BinRun(IMAGE_DATA_DIRECTORY) DataDirectory[16]" 10 | ,IMAGE_NT_HEADERS:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER" (A_PtrSize=8?64:32) ") OptionalHeader" 11 | ,IMAGE_NT_HEADERS32:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER32) OptionalHeader" 12 | ,IMAGE_NT_HEADERS64:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER64) OptionalHeader" 13 | ,IMAGE_SECTION_HEADER:="BYTE Name[8];{DWORD PhysicalAddress;DWORD VirtualSize};DWORD VirtualAddress;DWORD SizeOfRawData;DWORD PointerToRawData;DWORD PointerToRelocations;DWORD PointerToLinenumbers;WORD NumberOfRelocations;WORD NumberOfLinenumbers;DWORD Characteristics" 14 | ,FLOATING_SAVE_AREA :="DWORD ControlWord;DWORD StatusWord;DWORD TagWord;DWORD ErrorOffset;DWORD ErrorSelector;DWORD DataOffset;DWORD DataSelector;BYTE RegisterArea[80];DWORD Cr0NpxState" 15 | ,PROCESS_INFORMATION :="HANDLE hProcess;HANDLE hThread;DWORD dwProcessId;DWORD dwThreadId" 16 | ,STARTUPINFO :="DWORD cb;LPTSTR lpReserved;LPTSTR lpDesktop;LPTSTR lpTitle;DWORD dwX;DWORD dwY;DWORD dwXSize;DWORD dwYSize;DWORD dwXCountChars;DWORD dwYCountChars;DWORD dwFillAttribute;DWORD dwFlags;WORD wShowWindow;WORD cbReserved2;LPBYTE lpReserved2;HANDLE hStdInput;HANDLE hStdOutput;HANDLE hStdError" 17 | ,M128A:="ULONGLONG Low;LONGLONG High" 18 | ,_XMM_SAVE_AREA32 :="WORD ControlWord;WORD StatusWord;BYTE TagWord;BYTE Reserved1;WORD ErrorOpcode;DWORD ErrorOffset;WORD ErrorSelector;WORD Reserved2;DWORD DataOffset;WORD DataSelector;WORD Reserved3;DWORD MxCsr;DWORD MxCsr_Mask;BinRun(M128A) FloatRegisters[8];BinRun(M128A) XmmRegisters[16];BYTE Reserved4[96]" 19 | ,CONTEXT64:="DWORD64 P1Home;DWORD64 P2Home;DWORD64 P3Home;DWORD64 P4Home;DWORD64 P5Home;DWORD64 P6Home;DWORD ContextFlags;DWORD MxCsr;WORD SegCs;WORD SegDs;WORD SegEs;WORD SegFs;WORD SegGs;WORD SegSs;DWORD EFlags;DWORD64 Dr0;DWORD64 Dr1;DWORD64 Dr2;DWORD64 Dr3;DWORD64 Dr6;DWORD64 Dr7;DWORD64 Rax;DWORD64 Rcx;DWORD64 Rdx;DWORD64 Rbx;DWORD64Rsp;DWORD64 Rbp;DWORD64 Rsi;DWORD64 Rdi;DWORD64 R8;DWORD64 R9;DWORD64 R10;DWORD64 R11;DWORD64R12;DWORD64 R13;DWORD64 R14;DWORD64 R15;DWORD64 Rip;{BinRun(_XMM_SAVE_AREA32) FltSave;struct { BinRun(M128A) Header[2];BinRun(M128A) Legacy[8];BinRun(M128A) Xmm0;BinRun(M128A) Xmm1;BinRun(M128A) Xmm2;BinRun(M128A) Xmm3;BinRun(M128A) Xmm4;BinRun(M128A) Xmm5;BinRun(M128A) Xmm6;BinRun(M128A) Xmm7;BinRun(M128A) Xmm8;BinRun(M128A) Xmm9;BinRun(M128A) Xmm10;BinRun(M128A) Xmm11;BinRun(M128A) Xmm12;BinRun(M128A) Xmm13;BinRun(M128A) Xmm14;BinRun(M128A) Xmm15}};BinRun(M128A) VectorRegister[26];DWORD64 VectorControl;DWORD64 DebugControl;DWORD64 LastBranchToRip;DWORD64 LastBranchFromRip;DWORD64 LastExceptionToRip;DWORD64 LastExceptionFromRip" 20 | ,CONTEXT32:="DWORD ContextFlags;DWORD Dr0;DWORD Dr1;DWORD Dr2;DWORD Dr3;DWORD Dr6;DWORD Dr7;BinRun(FLOATING_SAVE_AREA) FloatSave;DWORD SegGs;DWORD SegFs;DWORD SegEs;DWORD SegDs;DWORD Edi;DWORD Esi;DWORD Ebx;DWORD Edx;DWORD Ecx;DWORD Eax;DWORD Ebp;DWORD Eip;DWORD SegCs;DWORD EFlags;DWORD Esp;DWORD SegSs;BYTE ExtendedRegisters[512]" 21 | ,IMAGE_NT_SIGNATURE:=17744,IMAGE_DOS_SIGNATURE:=23117,PAGE_EXECUTE_READWRITE:=64,CREATE_SUSPENDED:=4 22 | ,MEM_COMMIT:=4096,MEM_RESERVE:=8192,STARTF_USESHOWWINDOW:=1 23 | ,h2o:="B29C2D1CA2C24A57BC5E208EA09E162F(){`nPLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162FVarSetCapacity(dmp,sz:=StrLen(hex)//2,0)`nLoop,Parse,hex`nIf (""""!=h.=A_LoopField) && !Mod(A_Index,2)`nNumPut(""0x"" h,&dmp,A_Index/2-1,""UChar""),h:=""""`nreturn ObjLoad(&dmp)`n}`n" 24 | If (pData+0="") 25 | { 26 | ; Try first reading the file from Resource 27 | If res := DllCall("FindResource","PTR",lib:=DllCall("GetModuleHandle","PTR",0,"PTR"),"Str",pData,"PTR",10,"PTR") 28 | VarSetCapacity(data,sz :=DllCall("SizeofResource","PTR",lib,"PTR",res)) 29 | ,DllCall("RtlMoveMemory","PTR",&data,"PTR",DllCall("LockResource","PTR",hres:=DllCall("LoadResource","PTR",lib,"PTR",res,"PTR"),"PTR"),"PTR",sz) 30 | ,DllCall("FreeResource","PTR",hres) 31 | ,UnZipRawMemory(&data,sz,data2)?(data:=data2):"" 32 | else ; else try reading file from disc etc... 33 | FileRead,Data,*c %pData% 34 | pData:=&Data 35 | } 36 | 37 | If InStr(cmdLine,"`n"){ ; a script was given, first line contains the cmdLine 38 | PipeName := "\\.\pipe\AHK" A_TickCount 39 | __PIPE_GA_ := DllCall("CreateNamedPipe","str",PipeName,"UInt",2,"UInt",0,"UInt",255,"UInt",0,"UInt",0,"PTR",0,"PTR",0) 40 | __PIPE_ := DllCall("CreateNamedPipe","str",PipeName,"UInt",2,"UInt",0,"UInt",255,"UInt",0,"UInt",0,"PTR",0,"PTR",0) 41 | if (__PIPE_=-1 or __PIPE_GA_=-1) 42 | Return 0 43 | Script:=SubStr(cmdLine,InStr(cmdLine,"`n")+1) 44 | ,cmdLine:=Trim(SubStr(cmdLine,1,InStr(cmdLine,"`n")),"`n`r") A_Space PipeName 45 | } 46 | 47 | IDH:=Struct(IMAGE_DOS_HEADER,pData) 48 | 49 | if (IDH.e_magic != IMAGE_DOS_SIGNATURE){ 50 | MsgBox ERROR: e_magic not found 51 | return 52 | } 53 | INH := Struct(IMAGE_NT_HEADERS,pData + IDH.e_lfanew) 54 | 55 | if (INH.Signature != IMAGE_NT_SIGNATURE){ 56 | MsgBox ERROR: Signature not found 57 | return 58 | } 59 | 60 | If (A_PtrSize=8&&INH.OptionalHeader.magic=267) ; x86 on x64 61 | pNtHeader:=Struct(IMAGE_NT_HEADERS32,pData + IDH.e_lfanew),ctx:=Struct(Context32),Force32Bit:=1 62 | ,ctx.ContextFlags := (A_PtrSize=8?0x100000:0x10000) | 0x2 ;CONTEXT_INTEGER 63 | ,UsedExe:=ExeToUse?ExeToUse:A_WinDir "\Microsoft.NET\Framework\v2.0.50727\vbc.exe" 64 | else if (A_PtrSize=4&&INH.OptionalHeader.magic=523) ; x64 on x86 not possible 65 | Return false 66 | else 67 | pNtHeader:=INH,UsedExe:=ExeToUse?ExeToUse:A_IsCompiled?A_ScriptFullPath:A_AhkPath 68 | ,ctx:=Struct(A_PtrSize=8?Context64:Context32),ctx.ContextFlags := (A_PtrSize=8?0x100000:0x10000) | 0x2 ;CONTEXT_INTEGER 69 | pi:=Struct(PROCESS_INFORMATION) 70 | ,si:=Struct(STARTUPINFO),si.cb:=sizeof(si),si.dwFlags:=HIDE?STARTF_USESHOWWINDOW:0 ;si.wShowWindow already set to 0 71 | if DllCall("CreateProcess","PTR",0,"STR","""" UsedExe """" A_Space cmdLine (cmdLineScript?A_Space cmdLineScript:"") 72 | ,"PTR",0,"PTR",0,"int",0,"Int",CREATE_SUSPENDED,"PTR",0,"PTR",0,"PTR",si[],"PTR",pi[]){ 73 | if DllCall((Force32Bit?"Wow64":"") "GetThreadContext","PTR",pi.hThread,"PTR", ctx[]){ 74 | pPebImageBase:=ctx[A_PtrSize=8&&!Force32Bit?"Rdx":"Ebx"] + (Force32Bit?4:A_PtrSize)*2 75 | if DllCall("ReadProcessMemory","PTR",pi.hProcess, "PTR", pPebImageBase,"PTR*", dwImagebase,"PTR", (Force32Bit?4:A_PtrSize),"Uint*",NumberOfBytes){ 76 | DllCall("ntdll\NtUnmapViewOfSection","PTR",pi.hProcess, "PTR",dwImagebase) 77 | ,pImagebase := DllCall("VirtualAllocEx","PTR",pi.hProcess, "PTR",pNtHeader.OptionalHeader.ImageBase, "PTR",pNtHeader.OptionalHeader.SizeOfImage,"UInt", MEM_COMMIT|MEM_RESERVE,"UInt", PAGE_EXECUTE_READWRITE,"PTR") 78 | if (pImagebase) 79 | { 80 | if DllCall("WriteProcessMemory","PTR",pi.hProcess,"PTR",pImagebase,"PTR",pData,"PTR",pNtHeader.OptionalHeader.SizeOfHeaders,"UInt*",NumberOfBytes){ 81 | pSecHeader :=Struct(IMAGE_SECTION_HEADER) 82 | ,pSecHeader[] :=pNtHeader.OptionalHeader[""]+pNtHeader.FileHeader.SizeOfOptionalHeader 83 | ,counter := 0 84 | while (++counter < pNtHeader.FileHeader.NumberOfSections+1) 85 | DllCall("WriteProcessMemory","PTR",pi.hProcess,"PTR",pImagebase + pSecHeader.VirtualAddress,"PTR",pData + pSecHeader.PointerToRawData,"PTR",pSecHeader.SizeOfRawData,"UInt*", NumberOfBytes) 86 | ,pSecHeader[]:=pSecHeader[]+sizeof(pSecHeader) 87 | if DllCall("WriteProcessMemory","PTR",pi.hProcess,"PTR",pPebImageBase,"PTR",pNtHeader.OptionalHeader.ImageBase[""],"PTR",(Force32Bit?4:A_PtrSize),"UInt*",NumberOfBytes){ 88 | ctx[A_PtrSize=8&&!Force32Bit?"Rcx":"Eax"] := pImagebase + pNtHeader.OptionalHeader.AddressOfEntryPoint 89 | if DllCall((Force32Bit?"Wow64":"") "SetThreadContext","PTR",pi.hThread, "PTR",ctx[]){ 90 | if DllCall("ResumeThread","PTR",pi.hThread){ 91 | if (Script){ ; use pipe to pass script to new executable 92 | If IsObject(cmdLineScript){ 93 | sz:=ObjDump(cmdLineScript,dmp),hex:=BinToHex(&dmp,sz) 94 | While % _hex:=SubStr(Hex,1 + (A_Index-1)*16370,16370) 95 | _s.= "hex" (A_Index=1?":":".") "=""" _hex """`n" 96 | script:=StrReplace(h2o,"PLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162F",_s) "global A_Args:=B29C2D1CA2C24A57BC5E208EA09E162F()`n" script 97 | } 98 | DllCall("ConnectNamedPipe","PTR",__PIPE_GA_,"PTR",0) 99 | ,DllCall("CloseHandle","PTR",__PIPE_GA_) 100 | ,DllCall("ConnectNamedPipe","PTR",__PIPE_,"PTR",0) 101 | if !DllCall("WriteFile","PTR",__PIPE_,"str",(A_IsUnicode ? chr(0xfeff) : (chr(239) . chr(187) . chr(191))) script 102 | ,"UInt",(StrLen(script))*(A_IsUnicode ? 2 : 1)+(A_IsUnicode?4:6),"UInt*",0,"PTR",0) 103 | Return DllCall("CloseHandle","PTR",__PIPE_),0 104 | DllCall("CloseHandle","PTR",__PIPE_) 105 | } 106 | return pi.dwProcessId 107 | } 108 | } 109 | } 110 | } 111 | } 112 | } 113 | } 114 | DllCall("TerminateProcess","PTR",pi.hProcess,"UInt", 0) 115 | } 116 | return FALSE 117 | } -------------------------------------------------------------------------------- /Compiler/Lib/BinToHex.ahk: -------------------------------------------------------------------------------- 1 | BinToHex(addr,len) { ; Thanks Laszo 2 | static b2h 3 | if !b2h 4 | b2h:=McodeH(A_PtrSize=8?"4C8BC94585C0744F458BD00F1F440000440FB6024983C10248FFC241C0E8044180E80A410FB6C0C0E805442AC04180C041458841FE0FB64AFF80E10F80E90A0FB6C1C0E8052AC880C14149FFCA418849FF75BD458811C3C60100C3":"558BEC578B7D1085FF74398B4D08568B750C8A06C0E8042C0A8AD0C0EA052AC2044188018A06240F2C0A8AD0C0EA052AC204418841014683C1024F75D55EC601005F5DC38B4508C600005F5DC3","i==ttui") 5 | VarSetCapacity(hex,2 * len + 1),b2h[&hex,addr,len] 6 | Return StrGet(&hex,"CP0") 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/ComVar.ahk: -------------------------------------------------------------------------------- 1 | ComVar(Type=0xC){ 2 | static base 3 | if !base 4 | base:={__Get:"ComVarGet",__Set:"ComVarSet",__Delete:"ComVarDel"} 5 | arr:=ComObjArray(Type,1) 6 | DllCall("oleaut32\SafeArrayAccessData","ptr",ComObjValue(arr),"ptr*",arr_data) 7 | return {ref:ComObject(0x4000|Type,arr_data),_:arr,base:base} 8 | } 9 | ComVarGet(cv,p*){ 10 | if !p.MaxIndex() 11 | return cv._[0] 12 | } 13 | ComVarSet(cv,v,p*){ 14 | if !p.MaxIndex() 15 | return cv._[0]:=v 16 | } 17 | ComVarDel(cv){ 18 | DllCall("oleaut32\SafeArrayUnaccessData","ptr",ComObjValue(cv._)) 19 | } -------------------------------------------------------------------------------- /Compiler/Lib/CreateScript.ahk: -------------------------------------------------------------------------------- 1 | CreateScript(script,pw:=""){ 2 | static mScript 3 | StringReplace,script,script,`n,`r`n,A 4 | StringReplace,script,script,`r`r,`r,A 5 | If RegExMatch(script,"m)^[^:]+:[^:]+|[a-zA-Z0-9#_@]+\{}$"){ 6 | If !(mScript){ 7 | If (A_IsCompiled){ 8 | lib := DllCall("GetModuleHandle", "ptr", 0, "ptr") 9 | If !(res := DllCall("FindResource", "ptr", lib, "str", "E4847ED08866458F8DD35F94B37001C0", "ptr", Type:=10, "ptr")){ 10 | MsgBox Could not extract script! 11 | return 12 | } 13 | DataSize := DllCall("SizeofResource", "ptr", lib, "ptr", res, "uint") 14 | ,hresdata := DllCall("LoadResource", "ptr", lib, "ptr", res, "ptr") 15 | ,pData := DllCall("LockResource", "ptr", hresdata, "ptr") 16 | ,UnZipRawMemory(pData,DataSize,Data2,pw)?pData:=&Data2:"" 17 | If (DataSize){ 18 | mScript:=StrGet(pData,"UTF-8") 19 | StringReplace,mScript,mScript,`n,`r`n,A 20 | StringReplace,mScript,mScript,`r,`r`n,A 21 | StringReplace,mScript,mScript,`r`r,`r,A 22 | StringReplace,mScript,mScript,`n`n,`n,A 23 | VarSetCapacity(line,16384*2) 24 | Loop,Parse,mScript,`n,`r 25 | { 26 | DllCall("crypt32\CryptStringToBinary","Str",A_LoopField,"UInt", 0,"UInt", 0x1,"PTR", &line,"UIntP", aSizeEncrypted:=16384*2,"UInt", 0,"UInt", 0) 27 | if (NumGet(&line,"UInt") != 0x04034b50) 28 | break 29 | UnZipRawMemory(&line,aSizeEncrypted,linetext,pw) 30 | ,aScript .= StrGet(&linetext,"UTF-8") "`r`n" 31 | } 32 | if aScript 33 | mScript:= "`r`n" aScript "`r`n" 34 | else mScript :="`r`n" mScript "`r`n" 35 | } 36 | } else { 37 | FileRead,mScript,%A_ScriptFullPath% 38 | StringReplace,mScript,mScript,`n,`r`n,A 39 | StringReplace,mScript,mScript,`r`r,`r,A 40 | mScript := "`r`n" mScript "`r`n" 41 | Loop,Parse,mScript,`n,`r 42 | { 43 | If A_Index=1 44 | mScript:="" 45 | If RegExMatch(A_LoopField,"i)^\s*#include"){ 46 | temp:=RegExReplace(A_LoopField,"i)^\s*#include[\s+|,]") 47 | If InStr(temp,"%"){ 48 | Loop,Parse,temp,`% 49 | { 50 | If (A_Index=1) 51 | temp:=A_LoopField 52 | else if !Mod(A_Index,2) 53 | _temp:=A_LoopField 54 | else { 55 | _temp:=%_temp% 56 | temp.=_temp A_LoopField 57 | _temp:="" 58 | } 59 | } 60 | } 61 | If InStr(FileExist(trim(temp,"<>")),"D"){ 62 | SetWorkingDir % trim(temp,"<>") 63 | continue 64 | } else if InStr(FileExist(temp),"D"){ 65 | SetWorkingDir % temp 66 | continue 67 | } else If (SubStr(temp,1,1) . SubStr(temp,0) = "<>"){ 68 | If !FileExist(_temp:=A_ScriptDir "\lib\" trim(temp,"<>") ".ahk") 69 | If !FileExist(_temp:=A_MyDocuments "\AutoHotkey\lib\" trim(temp,"<>") ".ahk") 70 | If !FileExist(_temp:=SubStr(A_AhkPath,1,InStr(A_AhkPath,"\",1,0)) "lib\" trim(temp,"<>") ".ahk") 71 | If FileExist(_temp:=SubStr(A_AhkPath,1,InStr(A_AhkPath,"\",1,0)) "lib.lnk"){ 72 | FileGetShortcut,_temp,_temp 73 | _temp:=_temp "\" trim(temp,"<>") ".ahk" 74 | } 75 | FileRead,_temp,%_temp% 76 | mScript.= _temp "`r`n" 77 | } else { 78 | FileRead,_temp,%temp% 79 | mScript.= _temp "`r`n" 80 | } 81 | } else mScript.=A_LoopField "`r`n" 82 | } 83 | } 84 | } 85 | Loop,Parse,script,`n,`r 86 | { 87 | If A_Index=1 88 | script= 89 | else If A_LoopField= 90 | Continue 91 | If (RegExMatch(A_LoopField,"^[^:\s]+:[^:\s=]+$")){ 92 | StringSplit,label,A_LoopField,: 93 | If (label0=2 and IsLabel(label1) and IsLabel(label2)){ 94 | script .=SubStr(mScript 95 | , h:=InStr(mScript,"`r`n" label1 ":`r`n") 96 | , InStr(mScript,"`r`n" label2 ":`r`n")-h) . "`r`n" 97 | } 98 | } else if RegExMatch(A_LoopField,"^[^\{}\s]+\{}$"){ 99 | StringTrimRight,label,A_LoopField,2 100 | script .= SubStr(mScript 101 | , h:=RegExMatch(mScript,"i)\n" label "\([^\)\n]*\)\n?\s*\{") 102 | , RegExMatch(mScript "`r`n","\n}\s*\K\n",,h)-h) . "`r`n" 103 | } else 104 | script .= A_LoopField "`r`n" 105 | } 106 | } 107 | StringReplace,script,script,`r`n,`n,All 108 | Return Script 109 | } -------------------------------------------------------------------------------- /Compiler/Lib/CriticalSection.ahk: -------------------------------------------------------------------------------- 1 | CriticalSection(cs:=0){ 2 | static 3 | static i:=0,crisec:={base:{__Delete:"criticalsection"}} 4 | if IsObject(cs){ 5 | Loop i 6 | DeleteCriticalSection(&c%i%) 7 | Return i:=0 8 | } else if cs 9 | return DeleteCriticalSection(cs),cs 10 | i++,VarSetCapacity(c%i%,24),InitializeCriticalSection(&c%i%) 11 | Return &c%i% 12 | } -------------------------------------------------------------------------------- /Compiler/Lib/DirGetParent.ahk: -------------------------------------------------------------------------------- 1 | dirgetparent(path,parent:=1){ 2 | path:=RTrim(path,"\") 3 | while parent>=idx:=A_Index 4 | Loop % path,1 5 | if (idx=parent) 6 | return A_LoopFileDir (A_LoopFileDir?"\":"") 7 | else if path:=A_LoopFileDir 8 | break 9 | } -------------------------------------------------------------------------------- /Compiler/Lib/DynaRun.ahk: -------------------------------------------------------------------------------- 1 | DynaRun(s,pn:="",pr:="",exe:=""){ 2 | static AhkPath,h2o 3 | if !AhkPath 4 | AhkPath:="""" A_AhkPath """" (A_IsCompiled||(A_IsDll&&DllCall(A_AhkPath "\ahkgetvar","Str","A_IsCompiled","CDecl"))?" /E":"") 5 | ,h2o:="B29C2D1CA2C24A57BC5E208EA09E162F(){`nPLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162FVarSetCapacity(dmp,sz:=StrLen(hex)//2,0)`nLoop,Parse,hex`nIf (""""!=h.=A_LoopField) && !Mod(A_Index,2)`nNumPut(""0x"" h,&dmp,A_Index/2-1,""UChar""),h:=""""`nreturn ObjLoad(&dmp)`n}`n" 6 | if (-1=p1:=DllCall("CreateNamedPipe","str",pf:="\\.\pipe\" (pn!=""?pn:"AHK" A_TickCount),"uint",2,"uint",0,"uint",255,"uint",0,"uint",0,"Ptr",0,"Ptr",0)) 7 | || (-1=p2:=DllCall("CreateNamedPipe","str",pf,"uint",2,"uint",0,"uint",255,"uint",0,"uint",0,"Ptr",0,"Ptr",0)) 8 | Return 0 9 | Run % (exe?exe:AhkPath) " """ pf """ " (IsObject(pr)?"": " " pr),,UseErrorLevel HIDE,P 10 | If ErrorLevel 11 | return DllCall("CloseHandle","Ptr",p1),DllCall("CloseHandle","Ptr",p2),0 12 | If IsObject(pr) { 13 | sz:=ObjDump(pr,dmp),hex:=BinToHex(&dmp,sz) 14 | While % _hex:=SubStr(Hex,1 + (A_Index-1)*16370,16370) 15 | _s.= "hex" (A_Index=1?":":".") "=""" _hex """`n" 16 | Arg:=StrReplace(h2o,"PLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162F",_s) "global A_Args:=B29C2D1CA2C24A57BC5E208EA09E162F()`n" 17 | } 18 | DllCall("ConnectNamedPipe","Ptr",p1,"Ptr",0),DllCall("CloseHandle","Ptr",p1),DllCall("ConnectNamedPipe","Ptr",p2,"Ptr",0) 19 | if !DllCall("WriteFile","Ptr",p2,"Wstr",s:=(A_IsUnicode?chr(0xfeff):"") Arg s,"UInt",StrLen(s)*(A_IsUnicode?2:1)+(A_IsUnicode?4:3),"uint*",0,"Ptr",0) 20 | P:=0 21 | DllCall("CloseHandle","Ptr",p2) 22 | Return P 23 | } -------------------------------------------------------------------------------- /Compiler/Lib/ErrorMessage.ahk: -------------------------------------------------------------------------------- 1 | errormessage(E:=0){ 2 | static es,i 3 | if !i 4 | i:=VarSetCapacity(ES,1024) 5 | FormatMessage(0x00001000,0,e?e:A_LastError,0,ES,1024),VarSetCapacity(ES,-1) 6 | return StrReplace(ES,"`r`n"," ") 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/ExtractIconFromExecutable.ahk: -------------------------------------------------------------------------------- 1 | ExtractIconFromExecutable(aFilespec, aIconNumber, aWidth, aHeight){ 2 | static LOAD_LIBRARY_AS_DATAFILE,RT_ICON,RT_GROUP_ICON 3 | if !RT_ICON 4 | LOAD_LIBRARY_AS_DATAFILE:=2,RT_ICON:=3,RT_GROUP_ICON := RT_ICON + 11 5 | hicon := 0 6 | ; If the module is already loaded as an executable, LoadLibraryEx returns its handle. 7 | ; Otherwise each call will receive its own handle to a data file mapping. 8 | if ( hdatafile := LoadLibraryEx(aFilespec, 0, LOAD_LIBRARY_AS_DATAFILE) ){ 9 | group_icon_id := (aIconNumber < 0 ? -aIconNumber : ResourceIndexToId(hdatafile, RT_GROUP_ICON, aIconNumber ? aIconNumber : 1)) 10 | 11 | ;~ HRSRC hres 12 | ;~ HGLOBAL hresdata 13 | ;~ LPVOID presdata 14 | 15 | ; MSDN indicates resources are unloaded when the *process* exits, but also states 16 | ; that the pointer returned by LockResource is valid until the *module* containing 17 | ; the resource is unloaded. Testing seems to indicate that unloading a module indeed 18 | ; unloads or invalidates any resources it contains. 19 | if ((hres := FindResource(hdatafile, group_icon_id, RT_GROUP_ICON)) 20 | && (hresdata := LoadResource(hdatafile, hres)) 21 | && (presdata := LockResource(hresdata))) 22 | { 23 | ; LookupIconIdFromDirectoryEx seems to use whichever is larger of aWidth or aHeight, 24 | ; so one or the other may safely be -1. However, since this behaviour is undocumented, 25 | ; treat -1 as "same as other dimension": 26 | icon_id := LookupIconIdFromDirectoryEx(presdata, TRUE, aWidth == -1 ? aHeight : aWidth, aHeight == -1 ? aWidth : aHeight, 0) 27 | if (icon_id 28 | && (hres := FindResource(hdatafile, icon_id, RT_ICON)) 29 | && (hresdata := LoadResource(hdatafile, hres)) 30 | && (presdata := LockResource(hresdata))) 31 | { 32 | hicon := CreateIconFromResourceEx(presdata, SizeofResource(hdatafile, hres), TRUE, 0x30000, 0, 0, 0) 33 | } 34 | } 35 | 36 | ; Decrements the executable module's reference count or frees the data file mapping. 37 | FreeLibrary(hdatafile) 38 | } 39 | 40 | ; L20: Fall back to ExtractIcon if the above method failed. This may work on some versions of Windows where 41 | ; ExtractIcon supports 16-bit "executables" (such as ICL files) that cannot be loaded by LoadLibraryEx. 42 | ; However, resource ID -1 is not supported, and if multiple icon sizes exist in the file, the first is used 43 | ; rather than the most appropriate. 44 | if (!hicon) 45 | hicon := ExtractIcon(0, aFilespec, aIconNumber > 0 ? aIconNumber - 1 : aIconNumber < -1 ? aIconNumber : 0) 46 | 47 | return hicon 48 | } 49 | -------------------------------------------------------------------------------- /Compiler/Lib/FileGetInfo.ahk: -------------------------------------------------------------------------------- 1 | ;~ MsgBox % FileGetInfo(A_AhkPath,"FileDescription") 2 | FileGetInfo( peFile:="", p*) { ; Written by SKAN, modified by HotKeyIt 3 | ; www.autohotkey.com/forum/viewtopic.php?p=233188#233188 CD:24-Nov-2008 / LM:27-Oct-2010 4 | static DLL:="Version\GetFileVersion" 5 | If ! FSz := DllCall( DLL "InfoSize" (A_IsUnicode ? "W" : "A"), "Str",peFile, "UInt",0 ) 6 | Return DllCall( "SetLastError", UInt,1 ),"" 7 | VarSetCapacity( FVI, FSz, 0 ),DllCall( DLL "Info" ( A_IsUnicode ? "W" : "A"), "Str",peFile, "UInt",0, "UInt",FSz, "PTR",&FVI ) 8 | If !DllCall( "Version\VerQueryValue" (A_IsUnicode ? "W" : "A"), "PTR",&FVI, "Str","\VarFileInfo\Translation", "PTR*",Transl, "PTR",0 ) 9 | Return DllCall( "SetLastError", UInt,2 ),"" 10 | If !Trans:=format("{1:.8X}",NumGet(Transl+0,"UInt")) 11 | Return DllCall( "SetLastError", UInt,3),"" 12 | for k,v in p 13 | { subBlock := "\StringFileInfo\" SubStr(Trans,-3) SubStr(Trans,1,4) "\" v 14 | If ! DllCall( "Version\VerQueryValue" ( A_IsUnicode ? "W" : "A"), "PTR",&FVI, "Str",SubBlock, "PTR*",InfoPtr, "UInt",0 ) 15 | continue 16 | If Value := StrGet( InfoPtr ) 17 | Info .= p.MaxIndex()=1?Value:SubStr( v " ",1,24 ) . A_Tab . Value . "`n" 18 | } Info:=RTrim(Info,"`n") 19 | Return Info 20 | } -------------------------------------------------------------------------------- /Compiler/Lib/FileReplace.ahk: -------------------------------------------------------------------------------- 1 | FileReplace(ByRef data,file,Encoding:=""){ 2 | FileDelete % file 3 | If ErrorLevel&&FileExist(file) 4 | Return 0 5 | If Encoding 6 | FileAppend % data,% file 7 | else FileAppend % data,% file,% Encoding 8 | return !ErrorLevel 9 | } -------------------------------------------------------------------------------- /Compiler/Lib/FindFunc.ahk: -------------------------------------------------------------------------------- 1 | FindFunc(Name){ 2 | return DllCall(A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkFindFunc"):GetProcAddress(A_ModuleHandle,"ahkFindFunc"),"Str",Name,"CDecl PTR") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/FindLabel.ahk: -------------------------------------------------------------------------------- 1 | FindLabel(Name){ 2 | return DllCall(A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkFindLabel"):GetProcAddress(A_ModuleHandle,"ahkFindLabel"),"Str",Name,"CDecl PTR") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/GetEnv.ahk: -------------------------------------------------------------------------------- 1 | GetEnv(){ 2 | global 3 | local __env__:=DllCall("GetEnvironmentStringsW","PTR"),__thisenv__,__temp__,__tempenv__:=__env__ 4 | While __thisenv__:=SubStr(__temp__:=StrGet(__env__,"UTF-16"),1,InStr(__temp__,"=",1,2)-1) 5 | If ((__env__+=StrLen(__temp__)*2+2) && RegExMatch(__thisenv__,"^[\w_]+$")&&!Instr(".comspec.programfiles.","." __thisenv__ ".")) 6 | EnvGet,%__thisenv__%,% __thisenv__ 7 | DllCall("FreeEnvironmentStringsW","PTR",__tempenv__) 8 | } -------------------------------------------------------------------------------- /Compiler/Lib/GetExeMachine.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 3 | ; 4 | 5 | GetExeMachine(exepath){ 6 | if exe := FileOpen(exepath, "r") 7 | { 8 | exe.Seek(60), exe.Seek(exe.ReadUInt()+4) 9 | return exe.ReadUShort() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Compiler/Lib/HIBYTE.ahk: -------------------------------------------------------------------------------- 1 | HIBYTE(a){ 2 | return ToShort(a)>>8&0xff 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/HIWORD.ahk: -------------------------------------------------------------------------------- 1 | HIWORD(a){ 2 | return ToInt(a)>>16&0xffff 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/HexToBin.ahk: -------------------------------------------------------------------------------- 1 | HexToBin(ByRef bin,hex) { ; Thanks Laszo 2 | static h2b 3 | if !h2b 4 | h2b:=McodeH(A_PtrSize=8?"440FB60A48FFC24C8BD14584C9745490450FB6C141C0E806410FB6C0C0E0034402C04502C141C0E004458802440FB60A4584C9742E410FB6C94180E10F49FFC2C0E9064883C2020FB6C1C0E00302C84102C9410AC841884AFF440FB64AFF4584C975ADF3C3":"558BEC568B750C8A0E4684C97447578B7D08538AC1C0E8068AD002D202D202D202C28D1401C0E20488178A0E84C974238AC1C0E8068AD802DB02DB02DB02C380E10F02C10AC288078A4E014783C60284C975C05B5F5E5DC3","i==ta") 5 | VarSetCapacity(bin,StrLen(hex)/2 + 1),h2b[&bin,hex] 6 | Return &bin 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/IsBom.ahk: -------------------------------------------------------------------------------- 1 | isbom(address,bom:=0){ 2 | if (bom="UTF-8") 3 | return 0xBFBBEF=NumGet(address+0,"UInt")&0xFFFFFF 4 | else if (bom="UTF-16") 5 | return 0xFEFF=NumGet(address+0,"UShort")&0xFFFF 6 | else if (bom="UTF-16BE") 7 | return 0xFFFE=NumGet(address+0,"UShort")&0xFFFF 8 | else if (bom="UTF-32") 9 | return 0x0000FEFF=NumGet(address+0,"UInt64")&0xFFFFFFFF 10 | else if (bom="UTF-32BE") 11 | return 0x0000FFFE=NumGet(address+0,"UInt64")&0xFFFFFFFF 12 | else if (!bom) 13 | return (0xBFBBEF=NumGet(address,"UInt")&0xFFFFFF?"UTF-8":0xFEFF=NumGet(address,"UShort")&0xFFFF?"UTF-16":0xFFFE=NumGet(address,"UShort")&0xFFFF?"UTF-16BE":0x0000FEFF=NumGet(address,"UInt64")&0xFFFFFFFF?"UTF-32":0x0000FFFE=NumGet(address,"UInt64")&0xFFFFFFFF?"UTF-32BE":"CP0") 14 | } -------------------------------------------------------------------------------- /Compiler/Lib/IsFileInUse.ahk: -------------------------------------------------------------------------------- 1 | IsFileInUse(f,access:="rwd"){ 2 | return FileExist(f)&&!FileOpen(f,"w -" access) 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/LOBYTE.ahk: -------------------------------------------------------------------------------- 1 | LOBYTE(a){ 2 | return ToChar(a) 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/LOWORD.ahk: -------------------------------------------------------------------------------- 1 | LOWORD(a){ 2 | return ToShort(a) 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/LoadPicture.ahk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/Lib/LoadPicture.ahk -------------------------------------------------------------------------------- /Compiler/Lib/MAKELANGID.ahk: -------------------------------------------------------------------------------- 1 | MAKELANGID(p, s){ 2 | return ToShort(s)<<10|ToShort(p) 3 | } 4 | -------------------------------------------------------------------------------- /Compiler/Lib/MAKELCID.ahk: -------------------------------------------------------------------------------- 1 | MAKELCID(lgid, srtid){ 2 | return ToShort(srtid) << 16 | ToShort(lgid) 3 | } 4 | -------------------------------------------------------------------------------- /Compiler/Lib/MAKELONG.ahk: -------------------------------------------------------------------------------- 1 | MAKELONG(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/MAKELPARAM.ahk: -------------------------------------------------------------------------------- 1 | MAKELPARAM(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/MAKELRESULT.ahk: -------------------------------------------------------------------------------- 1 | MAKELRESULT(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/MAKEWORD.ahk: -------------------------------------------------------------------------------- 1 | MAKEWORD(a, b){ 2 | return ToChar(a) | ToChar(b) << 8 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/MAKEWPARAM.ahk: -------------------------------------------------------------------------------- 1 | MAKEWPARAM(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/MCodeH.ahk: -------------------------------------------------------------------------------- 1 | MCodeH(h,def,p*){ 2 | static f,DynaCalls 3 | If !f 4 | f:={},DynaCalls:={} 5 | If DynaCalls.HasKey(h) 6 | return DynaCalls[h] 7 | f.Insert(h),f.SetCapacity(f.MaxIndex(),len:=StrLen(h)//2) 8 | DllCall("VirtualProtect","PTR",addr:=f.GetAddress(f.MaxIndex()),"Uint",len,"UInt",64,"Uint*",0) 9 | Loop % len 10 | NumPut("0x" SubStr(h,2*A_Index-1,2),addr+0,A_Index-1,"Char") 11 | if p.MaxIndex() 12 | Return DynaCalls[h]:=DynaCall(addr,def,p*) 13 | else Return DynaCalls[h]:=DynaCall(addr,def) 14 | } -------------------------------------------------------------------------------- /Compiler/Lib/ObjByRef.ahk: -------------------------------------------------------------------------------- 1 | objbyref(ByRef _1:="",ByRef _2:="",ByRef _3:="",ByRef _4:="",ByRef _5:="",ByRef _6:="",ByRef _7:="",ByRef _8:="",ByRef _9:="",ByRef _10:="",ByRef _11:="",ByRef _12:="",ByRef _13:="",ByRef _14:="",ByRef _15:="",ByRef _16:="",ByRef _17:="",ByRef _18:="",ByRef _19:="",ByRef _20:="",ByRef _21:="",ByRef _22:="",ByRef _23:="",ByRef _24:="",ByRef _25:="",ByRef _26:="",ByRef _27:="",ByRef _28:="",ByRef _29:="",ByRef _30:="",ByRef _31:="",ByRef _32:="",ByRef _33:="",ByRef _34:="",ByRef _35:="",ByRef _36:="",ByRef _37:="",ByRef _38:="",ByRef _39:="",ByRef _40:="",ByRef _41:="",ByRef _42:="",ByRef _43:="",ByRef _44:="",ByRef _45:="",ByRef _46:="",ByRef _47:="",ByRef _48:="",ByRef _49:="",ByRef _50:="",ByRef _51:="",ByRef _52:="",ByRef _53:="",ByRef _54:="",ByRef _55:="",ByRef _56:="",ByRef _57:="",ByRef _58:="",ByRef _59:="",ByRef _60:="",ByRef _61:="",ByRef _62:="",ByRef _63:="",ByRef _64:="",ByRef _65:="",ByRef _66:="",ByRef _67:="",ByRef _68:="",ByRef _69:="",ByRef _70:="",ByRef _71:="",ByRef _72:="",ByRef _73:="",ByRef _74:="",ByRef _75:="",ByRef _76:="",ByRef _77:="",ByRef _78:="",ByRef _79:="",ByRef _80:="",ByRef _81:="",ByRef _82:="",ByRef _83:="",ByRef _84:="",ByRef _85:="",ByRef _86:="",ByRef _87:="",ByRef _88:="",ByRef _89:="",ByRef _90:="",ByRef _91:="",ByRef _92:="",ByRef _93:="",ByRef _94:="",ByRef _95:="",ByRef _96:="",ByRef _97:="",ByRef _98:="",ByRef _99:="",ByRef _100:="",ByRef _101:="",ByRef _102:="",ByRef _103:="",ByRef _104:="",ByRef _105:="",ByRef _106:="",ByRef _107:="",ByRef _108:="",ByRef _109:="",ByRef _110:="",ByRef _111:="",ByRef _112:="",ByRef _113:="",ByRef _114:="",ByRef _115:="",ByRef _116:="",ByRef _117:="",ByRef _118:="",ByRef _119:="",ByRef _120:="",ByRef _121:="",ByRef _122:="",ByRef _123:="",ByRef _124:="",ByRef _125:="",ByRef _126:="",ByRef _127:="",ByRef _128:="",ByRef _129:="",ByRef _130:="",ByRef _131:="",ByRef _132:="",ByRef _133:="",ByRef _134:="",ByRef _135:="",ByRef _136:="",ByRef _137:="",ByRef _138:="",ByRef _139:="",ByRef _140:="",ByRef _141:="",ByRef _142:="",ByRef _143:="",ByRef _144:="",ByRef _145:="",ByRef _146:="",ByRef _147:="",ByRef _148:="",ByRef _149:="",ByRef _150:="",ByRef _151:="",ByRef _152:="",ByRef _153:="",ByRef _154:="",ByRef _155:="",ByRef _156:="",ByRef _157:="",ByRef _158:="",ByRef _159:="",ByRef _160:="",ByRef _161:="",ByRef _162:="",ByRef _163:="",ByRef _164:="",ByRef _165:="",ByRef _166:="",ByRef _167:="",ByRef _168:="",ByRef _169:="",ByRef _170:="",ByRef _171:="",ByRef _172:="",ByRef _173:="",ByRef _174:="",ByRef _175:="",ByRef _176:="",ByRef _177:="",ByRef _178:="",ByRef _179:="",ByRef _180:="",ByRef _181:="",ByRef _182:="",ByRef _183:="",ByRef _184:="",ByRef _185:="",ByRef _186:="",ByRef _187:="",ByRef _188:="",ByRef _189:="",ByRef _190:="",ByRef _191:="",ByRef _192:="",ByRef _193:="",ByRef _194:="",ByRef _195:="",ByRef _196:="",ByRef _197:="",ByRef _198:="",ByRef _199:="",ByRef _200:="",ByRef _201:="",ByRef _202:="",ByRef _203:="",ByRef _204:="",ByRef _205:="",ByRef _206:="",ByRef _207:="",ByRef _208:="",ByRef _209:="",ByRef _210:="",ByRef _211:="",ByRef _212:="",ByRef _213:="",ByRef _214:="",ByRef _215:="",ByRef _216:="",ByRef _217:="",ByRef _218:="",ByRef _219:="",ByRef _220:="",ByRef _221:="",ByRef _222:="",ByRef _223:="",ByRef _224:="",ByRef _225:="",ByRef _226:="",ByRef _227:="",ByRef _228:="",ByRef _229:="",ByRef _230:="",ByRef _231:="",ByRef _232:="",ByRef _233:="",ByRef _234:="",ByRef _235:="",ByRef _236:="",ByRef _237:="",ByRef _238:="",ByRef _239:="",ByRef _240:="",ByRef _241:="",ByRef _242:="",ByRef _243:="",ByRef _244:="",ByRef _245:="",ByRef _246:="",ByRef _247:="",ByRef _248:="",ByRef _249:="",ByRef _250:="",ByRef _251:="",ByRef _252:="",ByRef _253:="",ByRef _254:=""){ 2 | static _AHkVar,var 3 | if !var 4 | _AHkVar:="{Int64 ContentsInt64,Double ContentsDouble,PTR object},{char *mByteContents,LPTSTR CharContents},{UINT_PTR Length,ObjByRef(_AHKVar) *AliasFor},{UINT_PTR Capacity,UINT_PTR BIV},BYTE HowAllocated,BYTE Attrib,BYTE mScope,BYTE Type,LPTSTR Name",var:=Struct(_AhkVar) 5 | this:=new _ObjByRef 6 | while IsByRef(_%A_Index%){ 7 | var[]:=getvar(_%A_Index%) 8 | ObjRawSet(this,"`a" var.AliasFor.name,var.AliasFor["",""]) 9 | } 10 | return this 11 | } 12 | Class _ObjByRef{ 13 | __GET(key){ 14 | Alias(var,this["`a" key]) 15 | return var 16 | } 17 | __SET(key,ByRef value:=""){ 18 | static var 19 | if !var 20 | var:=Struct("ObjByRef(_AhkVar)") 21 | If !this.HasKey("`a" key){ 22 | If !IsByRef(value) 23 | return 24 | else return var[]:=getvar(value),ObjRawSet(this,"`a" key,var.AliasFor["",""]),"" 25 | } 26 | Alias(thisvar,this["`a" key]) 27 | return thisvar:=value 28 | } 29 | } -------------------------------------------------------------------------------- /Compiler/Lib/ObjShare.ahk: -------------------------------------------------------------------------------- 1 | ObjShare(obj){ 2 | static IDispatch,set:=VarSetCapacity(IDispatch, 16), init := NumPut(0x46000000000000c0, NumPut(0x20400, IDispatch, "int64"), "int64") 3 | if IsObject(obj) 4 | return LresultFromObject(&IDispatch, 0, &obj) 5 | else if ObjectFromLresult(obj, &IDispatch, 0, getvar(com:=0)) 6 | return MessageBox(NULL,A_ThisFunc ": LResult Object could not be created","Error",0) 7 | return ComObject(9,com,1) 8 | } -------------------------------------------------------------------------------- /Compiler/Lib/ResDelete.ahk: -------------------------------------------------------------------------------- 1 | ResDelete(dll,name,type:=10,language:=1033){ 2 | return !(hUpdate:=BeginUpdateResourceW(dll))?0:(result:=EndUpdateResource(hUpdate,!result:=UpdateResource(hUpdate,type,name,language)),result) 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ResDllCreate.ahk: -------------------------------------------------------------------------------- 1 | ResDllCreate(path) { 2 | static Trg,hex 3 | if !hex 4 | VarSetCapacity(Trg,112,0),hex:="504B0304A443DDC85C0000000004000000000000F38D62201B1C60187810E0CAC0E0C3C8C8F0BF9F65374CEC01039F2237233B1798C384A458008A19182134508E052A05A31914107A98C1C22C503D02501A4EA102011CE234027A45C545C90C08A781DDCC84AAC6018C46C128C00D00" 5 | Loop,Parse,hex 6 | If Mod(A_Index,2) 7 | h:=A_LoopField 8 | else NumPut("0x" h A_LoopField,Trg,A_Index/2-1,"UChar") 9 | UnZipRawMemory(&Trg,112,data) 10 | If (0Subsystem is the same for both 32 and 64-bit executables 11 | exe.Seek(60), exe.Seek(exe.ReadUInt()+92) 12 | exe.WriteUShort(subSys) 13 | return true 14 | } 15 | -------------------------------------------------------------------------------- /Compiler/Lib/StrPutVar.ahk: -------------------------------------------------------------------------------- 1 | StrPutVar(string,ByRef var,encoding:="UTF-8"){ 2 | VarSetCapacity(var,StrPut(string,encoding)*((encoding="utf-16"||encoding="cp1200")?2:1),00) 3 | return StrPut(string,&var,encoding),VarSetCapacity(var,-1) 4 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToChar.ahk: -------------------------------------------------------------------------------- 1 | ToChar(ByRef num,buf:=0){ 2 | return NumGet(getvar(buf:=num+0),"Char") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToInt.ahk: -------------------------------------------------------------------------------- 1 | ToInt(ByRef num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"Int") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToShort.ahk: -------------------------------------------------------------------------------- 1 | ToShort(ByRef num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"Short") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToUChar.ahk: -------------------------------------------------------------------------------- 1 | ToUChar(ByRef num,buf:=0){ 2 | return NumGet(getvar(buf:=num+0),"UChar") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToUInt.ahk: -------------------------------------------------------------------------------- 1 | ToUInt(ByRef num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"UInt") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/ToUShort.ahk: -------------------------------------------------------------------------------- 1 | ToUShort(ByRef num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"UShort") 3 | } -------------------------------------------------------------------------------- /Compiler/Lib/VersionRes.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | 5 | class VersionRes 6 | { 7 | Name := "" 8 | ,Data := "" 9 | ,IsText := true 10 | ,DataSize := 0 11 | ,Children := [] 12 | 13 | __New(addr := 0) 14 | { 15 | if !addr 16 | return this 17 | 18 | wLength := NumGet(addr+0, "UShort"), addrLimit := addr + wLength, addr += 2 19 | ,wValueLength := NumGet(addr+0, "UShort"), addr += 2 20 | ,wType := NumGet(addr+0, "UShort"), addr += 2 21 | ,szKey := StrGet(addr, "UTF-16"), addr += 2*(StrLen(szKey)+1), addr := (addr+3)&~3 22 | ,ObjSetCapacity(this, "Data", size := wValueLength*(wType+1)) 23 | ,this.Name := szKey 24 | ,this.DataSize := wValueLength 25 | ,this.IsText := wType 26 | ,DllCall("msvcrt\memcpy", "ptr", this.GetDataAddr(), "ptr", addr, "ptr", size, "cdecl"), addr += size, addr := (addr+3)&~3 27 | ; if wType 28 | ; ObjSetCapacity(this, "Data", -1) 29 | while addr < addrLimit 30 | { 31 | size := (NumGet(addr+0, "UShort") + 3) & ~3 32 | ,this.Children.Insert(new VersionRes(addr)) 33 | ,addr += size 34 | } 35 | } 36 | 37 | _NewEnum() 38 | { 39 | return this.Children._NewEnum() 40 | } 41 | 42 | AddChild(node) 43 | { 44 | this.Children.Insert(node) 45 | } 46 | 47 | GetChild(name) 48 | { 49 | for k,v in this 50 | if v.Name = name 51 | return v 52 | } 53 | 54 | GetText() 55 | { 56 | if this.IsText 57 | return this.Data 58 | } 59 | 60 | SetText(txt) 61 | { 62 | this.Data := txt 63 | this.IsText := true 64 | ,this.DataSize := StrLen(txt)+1 65 | } 66 | 67 | GetDataAddr() 68 | { 69 | return ObjGetAddress(this, "Data") 70 | } 71 | 72 | Save(addr) 73 | { 74 | orgAddr := addr 75 | ,addr += 2 76 | ,NumPut(ds:=this.DataSize, addr+0, "UShort"), addr += 2 77 | ,NumPut(it:=this.IsText, addr+0, "UShort"), addr += 2 78 | ,addr += 2*StrPut(this.Name, addr+0, "UTF-16") 79 | ,addr := (addr+3)&~3 80 | ,realSize := ds*(it+1) 81 | ,DllCall("msvcrt\memcpy", "ptr", addr, "ptr", this.GetDataAddr(), "ptr", realSize, "cdecl"), addr += realSize 82 | ,addr := (addr+3)&~3 83 | for k,v in this 84 | addr += v.Save(addr) 85 | size := addr - orgAddr 86 | ,NumPut(size, orgAddr+0, "UShort") 87 | return size 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Compiler/Lib/WinGetPidList.ahk: -------------------------------------------------------------------------------- 1 | WinGetPidList(WinTitle:="",WinText:="",ExcludeTitle:="",ExcludeText:=""){ 2 | static p,i,EnumProcesses 3 | if !EnumProcesses 4 | i:=VarSetCapacity(p,4096),EnumProcesses:=DynaCall(DllCall("GetProcAddress","PTR",DllCall("LoadLibrary","STR","psapi","PTR"),"AStr","EnumProcesses","PTR"),"tuiui",&p,4096,getvar(i)) 5 | EnumProcesses[],ps:=[] 6 | Loop % i/4 7 | If WinExist(WinTitle " ahk_pid " pid:=NumGet(p,(A_Index-1)*4,"UInt"),WinText,ExcludeTitle,ExcludeText) 8 | ps.Push(pid) 9 | return ps.Count()?ps:"" 10 | } -------------------------------------------------------------------------------- /Compiler/Lib/addFile.ahk: -------------------------------------------------------------------------------- 1 | addFile(Script,waitExecute:=0){ 2 | global 3 | static addFile 4 | if !addFile 5 | addFile:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"addFile"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","addFile","PTR"),"i==si") 6 | return addFile[Script,waitExecute] 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/addScript.ahk: -------------------------------------------------------------------------------- 1 | addScript(Script,waitExecute:=0){ 2 | global 3 | static addScript 4 | if !addScript 5 | addScript:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"addScript"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","addScript","PTR"),"i==si") 6 | return addScript[Script,waitExecute] 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/ahkExec.ahk: -------------------------------------------------------------------------------- 1 | ahkExec(Script){ 2 | global 3 | static ahkExec 4 | if !ahkExec 5 | ahkExec:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExec"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExec","PTR"),"i==s") 6 | Errorlevel := ahkExec[Script] 7 | } -------------------------------------------------------------------------------- /Compiler/Lib/ahkExecuteLine.ahk: -------------------------------------------------------------------------------- 1 | ahkExecuteline(pLine:=0,Mode:=0,Wait:=1){ 2 | global 3 | static ahkExecuteLine 4 | if !ahkExecuteLine 5 | ahkExecuteLine:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExecuteLine"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExecuteLine","PTR"),"t==tuiui") 6 | return ahkExecuteLine[pLine,Mode,Wait] 7 | } -------------------------------------------------------------------------------- /Compiler/README.txt: -------------------------------------------------------------------------------- 1 | Scripted replacement for Ahk2Exe 2 | ================================ 3 | 4 | Installation 5 | ------------ 6 | 7 | Just copy everything to your AutoHotkey\Compiler folder (make sure to backup the existing Ahk2Exe.exe!) 8 | The source code to the compiler can be found at https://github.com/HotKeyIt/Ahk2Exe. 9 | 10 | TODO 11 | ---- 12 | 13 | Handle FileInstall on same-line If* commands. 14 | -------------------------------------------------------------------------------- /Compiler/ScriptParser.ahk: -------------------------------------------------------------------------------- 1 | ; 2 | ; File encoding: UTF-8 with BOM 3 | ; 4 | 5 | PreprocessScript(ByRef ScriptText, AhkScript, ExtraFiles, FileList := "", FirstScriptDir := "", Options := "", iOption := 0) 6 | { global DirDone, BinFile 7 | SplitPath, AhkScript, ScriptName, ScriptDir 8 | if !IsObject(FileList) 9 | { 10 | FileList := [AhkScript] 11 | ScriptText := "; `n" 12 | FirstScriptDir := ScriptDir 13 | IsFirstScript := true 14 | Options := { comm: ";", esc: "``", directives: [] } 15 | 16 | OldWorkingDir := A_WorkingDir 17 | SetWorkingDir, %ScriptDir% 18 | 19 | global priorlines := [] 20 | } 21 | oldLineFile := DerefIncludeVars.A_LineFile 22 | DerefIncludeVars.A_LineFile := AhkScript 23 | 24 | if SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 ; Handle v2 default folder 25 | { 26 | OldWorkingDirv2 := A_WorkingDir 27 | SetWorkingDir %ScriptDir% 28 | } 29 | 30 | IfNotExist, %AhkScript% 31 | if !iOption 32 | Util_Error((IsFirstScript ? "Script" : "#include") " file cannot be opened.", 0x32, """" AhkScript """") 33 | else return 34 | 35 | cmtBlock := false, contSection := false, ignoreSection := false 36 | Loop, Read, %AhkScript% 37 | { 38 | tline := Trim(A_LoopReadLine) 39 | if !cmtBlock 40 | { 41 | if ignoreSection 42 | { 43 | if StrStartsWith(tline, Options.comm "@Ahk2Exe-IgnoreEnd") 44 | ignoreSection := false 45 | continue 46 | } 47 | if !contSection 48 | { 49 | if StrStartsWith(tline, Options.comm) 50 | { 51 | StringTrimLeft, tline, tline, % StrLen(Options.comm) 52 | if !StrStartsWith(tline, "@Ahk2Exe-") 53 | continue 54 | StringTrimLeft, tline, tline, 9 55 | if StrStartsWith(tline, "IgnoreBegin") 56 | ignoreSection := true ;v Skip 'Bin' & their 'Cont' directives 57 | else if Trim(tline) != "" && !(DirDone[A_Index] && IsFirstScript) 58 | Options.directives.Insert(RegExReplace(tline ; Save directive 59 | , "\s+" RegExEscape(Options.comm) ".*$")) ;Strip any actual comments 60 | , priorlines.Push(priorline) ; Will be this directive's A_PriorLine 61 | continue 62 | } 63 | else if tline = 64 | continue 65 | else if StrStartsWith(tline, "/*") 66 | { 67 | if !StrStartsWith(tline, "/*@Ahk2Exe-Keep") 68 | if !(SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 && tline~="\*/$") 69 | cmtBlock := true 70 | continue 71 | } 72 | else if StrStartsWith(tline, "*/") 73 | continue ; Will only happen in a 'Keep' section 74 | } 75 | if StrStartsWith(tline, "(") && !IsFakeCSOpening(SubStr(tline,2)) 76 | contSection := true 77 | else if StrStartsWith(tline, ")") 78 | contSection := false 79 | 80 | priorline := tline ; Save for a directive's A_PriorLine 81 | 82 | tline := RegExReplace(tline, "\s+" RegExEscape(Options.comm) ".*$", "") 83 | if !contSection 84 | && RegExMatch(tline, "i)^#Include(Again)?[ \t]*[, \t]\s*(.*)$", o) 85 | { 86 | if InStr(o2,":",,3) 87 | continue ; included by /iLib 88 | IsIncludeAgain := (o1 = "Again") 89 | IgnoreErrors := false 90 | IncludeFile := o2 91 | if RegExMatch(IncludeFile, "\*[iI]\s+?(.*)", o) 92 | IgnoreErrors := true, IncludeFile := Trim(o1) 93 | 94 | if RegExMatch(IncludeFile, "^<(.+)>$", o) 95 | { 96 | if IncFile2 := FindLibraryFile(o1, FirstScriptDir) 97 | { 98 | IncludeFile := IncFile2 99 | goto _skip_findfile 100 | } 101 | } 102 | 103 | IncludeFile := DerefIncludePath(IncludeFile, DerefIncludeVars) 104 | 105 | if InStr(FileExist(IncludeFile), "D") 106 | { 107 | SetWorkingDir, %IncludeFile% 108 | continue 109 | } 110 | 111 | _skip_findfile: 112 | 113 | IncludeFile := Util_GetFullPath(IncludeFile) 114 | 115 | AlreadyIncluded := false 116 | for k,v in FileList 117 | if (v = IncludeFile) 118 | { 119 | AlreadyIncluded := true 120 | break 121 | } 122 | if(IsIncludeAgain || !AlreadyIncluded) 123 | { 124 | if !AlreadyIncluded 125 | FileList.Insert(IncludeFile) 126 | PreprocessScript(ScriptText, IncludeFile, ExtraFiles, FileList, FirstScriptDir, Options, IgnoreErrors) 127 | } 128 | }else if !contSection && tline ~= "i)^FileInstall[, \t]" 129 | { 130 | if tline ~= "^\w+\s+(:=|\+=|-=|\*=|/=|//=|\.=|\|=|&=|\^=|>>=|<<=)" 131 | continue ; This is an assignment! 132 | 133 | ; workaround for `, detection 134 | EscapeChar := Options.esc 135 | EscapeCharChar := EscapeChar EscapeChar 136 | EscapeComma := EscapeChar "," 137 | EscapeTmp := chr(2) 138 | EscapeTmpD := chr(3) 139 | StringReplace, tline, tline, %EscapeCharChar%, %EscapeTmpD%, All 140 | StringReplace, tline, tline, %EscapeComma%, %EscapeTmp%, All 141 | 142 | if !RegExMatch(tline, "i)^FileInstall[ \t]*[, \t][ \t]*([^,]+?)[ \t]*(,|$)", o) || o1 ~= "[^``]%" 143 | Util_Error("Error: Invalid ""FileInstall"" syntax found. Note that the first parameter must not be specified using a continuation section.", 0x12) 144 | _ := Options.esc 145 | StringReplace, o1, o1, %_%`%, `%, All 146 | StringReplace, o1, o1, %_%`,, `,, All 147 | StringReplace, o1, o1, %_%%_%,, %_%,, All 148 | 149 | ; workaround for `, detection [END] 150 | StringReplace, o1, o1, %EscapeTmp%, `,, All 151 | StringReplace, o1, o1, %EscapeTmpD%, %EscapeChar%, All 152 | StringReplace, tline, tline, %EscapeTmp%, %EscapeComma%, All 153 | StringReplace, tline, tline, %EscapeTmpD%, %EscapeCharChar%, All 154 | 155 | ExtraFiles.Insert(o1) 156 | ScriptText .= tline "`n" 157 | }else if !contSection && RegExMatch(tline, "i)^#CommentFlag\s+(.+)$", o) 158 | Options.comm := o1, ScriptText .= tline "`n" 159 | else if !contSection && RegExMatch(tline, "i)^#EscapeChar\s+(.+)$", o) 160 | Options.esc := o1, ScriptText .= tline "`n" 161 | else if !contSection && RegExMatch(tline, "i)^#DerefChar\s+(.+)$", o) 162 | Util_Error("Error: #DerefChar is not supported.", 0x21) 163 | else if !contSection && RegExMatch(tline, "i)^#Delimiter\s+(.+)$", o) 164 | Util_Error("Error: #Delimiter is not supported.", 0x22) 165 | else 166 | ScriptText .= (contSection ? A_LoopReadLine : tline) "`n" 167 | } else if (tline~="^\*/" 168 | || SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 && tline~="\*/$") 169 | cmtBlock := false ; End block comment 170 | } 171 | 172 | Loop, % !!IsFirstScript ; Like "if IsFirstScript" but can "break" from block 173 | { 174 | global AhkPath := UseAhkPath 175 | if (AhkPath = "") 176 | AhkPath := SubStr(BinFile,-5)="SC.bin" ? SubStr(BinFile,1,-6) ".exe" : BinFile 177 | ; AhkPath := FileExist(AhkPath) ? AhkPath :A_ScriptDir "\..\AutoHotkeyU32.exe" 178 | ; AhkPath := FileExist(AhkPath) ? AhkPath : A_AhkPath 179 | 180 | IfNotExist, %AhkPath% 181 | { Util_Error("Warning: AutoHotkey.exe could not be located!`n`nAuto-include" 182 | . "s from Function Libraries, and 'Obey' directives will not be processed.",0) 183 | break ; Don't bother with auto-includes because the file does not exist 184 | } 185 | Util_Status("Auto-including any functions called from a library...") 186 | AhkTypeRet := AHKType(AhkPath) 187 | if !AhkTypeRet 188 | Util_Error("Error: The AutoHotkey build used for auto-inclusion of library functions is not recognized.", 0x25, AhkPath) 189 | if (AhkTypeRet.Era = "Legacy") 190 | Util_Error("Error: Legacy AutoHotkey versions (prior to v1.1) can not be used to do auto-inclusion of library functions.", 0x26, AhkPath) 191 | tmpErrorLog := Util_TempFile(, "err~") 192 | ilibfile := Util_TempFile(, "ilib~") 193 | RunWait, "%comspec%" /c ""%AhkPath%" /iLib "%ilibfile%" /ErrorStdOut "%AhkScript%" 2>"%tmpErrorLog%"", %FirstScriptDir%, UseErrorLevel Hide 194 | if (ErrorLevel = 2) ;^ Editor may flag, but it's valid syntax 195 | { 196 | FileRead,tmpErrorData,%tmpErrorLog% 197 | Util_Error("Error: The script contains syntax errors.", 0x11,tmpErrorData) 198 | } 199 | FileDelete,%tmpErrorLog% 200 | IfExist, %ilibfile% 201 | { ;ScriptText .= "Exit`n" ; Don't execute Auto_Includes directly 202 | PreprocessScript(ScriptText, ilibfile, ExtraFiles, FileList, FirstScriptDir, Options) 203 | FileDelete, %ilibfile% 204 | } 205 | StringTrimRight, ScriptText, ScriptText, 1 ; remove trailing newline 206 | } 207 | 208 | DerefIncludeVars.A_LineFile := oldLineFile 209 | if OldWorkingDir 210 | SetWorkingDir, %OldWorkingDir% 211 | 212 | if SubStr(DerefIncludeVars.A_AhkVersion,1,1)=2 ; Handle v2 default folder 213 | SetWorkingDir %OldWorkingDirv2% 214 | 215 | if IsFirstScript 216 | return Options.directives 217 | } 218 | 219 | IsFakeCSOpening(tline) 220 | { 221 | Loop, Parse, tline, %A_Space%%A_Tab% 222 | if !StrStartsWith(A_LoopField, "Join") && InStr(A_LoopField, ")") 223 | return true 224 | return false 225 | } 226 | 227 | FindLibraryFile(name, ScriptDir) 228 | { 229 | libs := [ScriptDir "\Lib", A_MyDocuments "\AutoHotkey\Lib", A_ScriptDir "\..\Lib"] 230 | p := InStr(name, "_") 231 | if p 232 | name_lib := SubStr(name, 1, p-1) 233 | 234 | for each,lib in libs 235 | { 236 | file := lib "\" name ".ahk" 237 | IfExist, %file% 238 | return file 239 | 240 | if !p 241 | continue 242 | 243 | file := lib "\" name_lib ".ahk" 244 | IfExist, %file% 245 | return file 246 | } 247 | } 248 | 249 | StrStartsWith(ByRef v, ByRef w) 250 | { 251 | return SubStr(v, 1, StrLen(w)) = w 252 | } 253 | 254 | RegExEscape(t) 255 | { 256 | static _ := "\.*?+[{|()^$" 257 | Loop, Parse, _ 258 | StringReplace, t, t, %A_LoopField%, \%A_LoopField%, All 259 | return t 260 | } 261 | 262 | Util_TempFile(d := "", f := "", xep := "") 263 | { static xe := "" 264 | if xep 265 | xe := xep 266 | if ( !StrLen(d) || !FileExist(d) ) 267 | d := A_Temp 268 | Loop 269 | { DllCall("QueryPerformanceCounter", "Int64*", Counter) 270 | tempName := d "\~Ahk2Exe~" xe "~" f Counter ".tmp" 271 | } until !FileExist(tempName) 272 | return tempName 273 | } 274 | 275 | class DerefIncludeVars 276 | { 277 | static A_IsCompiled := true 278 | } 279 | 280 | DerefIncludePath(path, vars, dosubset := 0) 281 | { 282 | static SharedVars := {A_AhkPath:1, A_AppData:1, A_AppDataCommon:1, A_ComputerName:1, A_ComSpec:1, A_Desktop:1, A_DesktopCommon:1, A_MyDocuments:1, A_ProgramFiles:1, A_Programs:1, A_ProgramsCommon:1, A_Space:1, A_StartMenu:1, A_StartMenuCommon:1, A_Startup:1, A_StartupCommon:1, A_Tab:1, A_Temp:1, A_UserName:1, A_WinDir:1} 283 | p := StrSplit(path, "%") 284 | path := p[1] 285 | n := 2 286 | while n < p.Length() 287 | { 288 | vn := p[n] 289 | subs := StrReplace(StrReplace(vn, "````", "chr(2)"), "``~", "chr(3)") 290 | subs := dosubset ? StrSplit(subs, "~",, 3) : [vn] 291 | subs.2 := StrReplace(StrReplace(subs.2, "chr(2)", "``"), "chr(3)", "~") 292 | subs.3 := StrReplace(StrReplace(subs.3, "chr(2)", "``"), "chr(3)", "~") 293 | if ObjHasKey(vars, subs.1) 294 | path .= subset(vars[subs.1], subs) . p[++n] 295 | else if SharedVars[subs.1] 296 | vn := subs.1, path .= subset(%vn%, subs) . p[++n] 297 | else path .= "%" vn 298 | ++n 299 | } 300 | if (n = p.Length()) 301 | path .= "%" p[n] 302 | return path 303 | } 304 | ; ^^ vv Can subset dereferenced value (only when used in Compiler Directives). 305 | ; 306 | ; Include at end of builtin variable name before end %, p2 [p3] all separated 307 | ; by tilde "~". p2 and p3 will be used as p2, p3 of 'RegExReplace'. 308 | ; 309 | ; E.g. %A_ScriptName~\.[^\.]+$~.exe% replaces extension with .exe. 310 | ; 311 | ; To include tilde as data in p2, p3, preceded with back-tick, i.e. `~ 312 | ; To include back-tick character as data in p2, p3, double it, i.e. `` 313 | 314 | subset(val, subs) ; Returns subset of val using subs.2 & subs.3 315 | { ; if no subs.2 or empty, return val unchanged 316 | return subs.2="" ? val : RegExReplace(val, subs.2, subs.3) 317 | } 318 | -------------------------------------------------------------------------------- /Compiler/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/logo.png -------------------------------------------------------------------------------- /Compiler/mpress.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/mpress.exe -------------------------------------------------------------------------------- /Compiler/upx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/upx.exe -------------------------------------------------------------------------------- /Compiler/v2/AutoHotkeyU.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/v2/AutoHotkeyU.exe -------------------------------------------------------------------------------- /Compiler/v2/lib.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Compiler/v2/lib.lnk -------------------------------------------------------------------------------- /Compiler/v2/lib/BCrypt.ahk: -------------------------------------------------------------------------------- 1 | BCrypt(Algorithm, Buffer, Key:=""){ 2 | static hBCRYPT := LoadLibrary("bcrypt.dll"),BCryptOpenAlgorithmProvider:=DynaCall("bcrypt\BCryptOpenAlgorithmProvider","tstui") 3 | ,BCryptGetProperty:=DynaCall("bcrypt\BCryptGetProperty","tttuitui"),BCryptCreateHash:=DynaCall("bcrypt\BCryptCreateHash","tttuituiui") 4 | ,BCryptHashData:=DynaCall("bcrypt\BCryptHashData","ttuiui"),BCryptFinishHash:=DynaCall("bcrypt\BCryptFinishHash","ttuiui") 5 | ,BCryptDestroyHash:=DynaCall("bcrypt\BCryptDestroyHash","t"),BCryptCloseAlgorithmProvider:=DynaCall("bcrypt\BCryptCloseAlgorithmProvider","tui") 6 | if BCryptOpenAlgorithmProvider(getvar(hAlgo:=0), StrUpper(Algorithm), 0, Key?0x00000008:0) 7 | || BCryptGetProperty(hAlgo, StrPtr("ObjectLength"), getvar(cbHashObj:=0), 4, getvar(cbRes:=0), 0) 8 | || BCryptGetProperty(hAlgo, StrPtr("HashDigestLength"), getvar(cbHash:=0), 4, getvar(cbRes), 0) 9 | return 10 | pbHashObj:=Buffer(cbHashObj) 11 | ,Key ? (pbSecret:=Buffer(cbSecret := StrPut(Key, "UTF-8")),StrPut(Key, pbSecret, "UTF-8"),pb:=pbSecret.Ptr,cb:=cbSecret - 1) : (pb:=cb:=0) 12 | ,aBuffer:=Type(Buffer)!="Buffer" ? (aBuffer:=Buffer(size := StrPut(Buffer, "UTF-8")),StrPut(Buffer, aBuffer, "UTF-8"),size--,aBuffer) : Buffer 13 | ,hash:=(pbHash:=Buffer(cbHash)) && !BCryptCreateHash(hAlgo, getvar(hHash:=0), pbHashObj, cbHashObj, pb, cb , 0) && !BCryptHashData(hHash, aBuffer, aBuffer.size, 0) && !BCryptFinishHash(hHash, pbHash, cbHash, 0) ? BinToHex(pbHash, cbHash) : "" 14 | BCryptDestroyHash(hHash),BCryptCloseAlgorithmProvider(hAlgo, 0) 15 | return hash 16 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/BinRun.ahk: -------------------------------------------------------------------------------- 1 | BinRun(pData,cmdLine:="",cmdLineScript:="",Hide:=0,ExeToUse:=""){ 2 | static IMAGE_DOS_HEADER :="WORD e_magic;WORD e_cblp;WORD e_cp;WORD e_crlc;WORD e_cparhdr;WORD e_minalloc;WORD e_maxalloc;WORD e_ss;WORD e_sp;WORD e_csum;WORD e_ip;WORD e_cs;WORD e_lfarlc;WORD e_ovno;WORD e_res[4];WORD e_oemid;WORD e_oeminfo;WORD e_res2[10];LONG e_lfanew" 3 | ,IMAGE_FILE_HEADER :="WORD Machine;WORD NumberOfSections;DWORD TimeDateStamp;DWORD PointerToSymbolTable;DWORD NumberOfSymbols;WORD SizeOfOptionalHeader;WORD Characteristics" 4 | ,IMAGE_DATA_DIRECTORY :="DWORD VirtualAddress;DWORD Size" 5 | ,IMAGE_OPTIONAL_HEADER64:="WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;ULONGLONG ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;ULONGLONG SizeOfStackReserve;ULONGLONG SizeOfStackCommit;ULONGLONG SizeOfHeapReserve;ULONGLONG SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;BinRun(IMAGE_DATA_DIRECTORY) DataDirectory[16]" 6 | ,IMAGE_OPTIONAL_HEADER32 :="WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;DWORD BaseOfData;DWORD ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;DWORD SizeOfStackReserve;DWORD SizeOfStackCommit;DWORD SizeOfHeapReserve;DWORD SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;BinRun(IMAGE_DATA_DIRECTORY) DataDirectory[16]" 7 | ,IMAGE_NT_HEADERS:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER" (A_PtrSize=8?64:32) ") OptionalHeader" 8 | ,IMAGE_NT_HEADERS32:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER32) OptionalHeader" 9 | ,IMAGE_NT_HEADERS64:="DWORD Signature;BinRun(IMAGE_FILE_HEADER) FileHeader;BinRun(IMAGE_OPTIONAL_HEADER64) OptionalHeader" 10 | ,IMAGE_SECTION_HEADER:="BYTE Name[8];{DWORD PhysicalAddress;DWORD VirtualSize};DWORD VirtualAddress;DWORD SizeOfRawData;DWORD PointerToRawData;DWORD PointerToRelocations;DWORD PointerToLinenumbers;WORD NumberOfRelocations;WORD NumberOfLinenumbers;DWORD Characteristics" 11 | ,FLOATING_SAVE_AREA :="DWORD ControlWord;DWORD StatusWord;DWORD TagWord;DWORD ErrorOffset;DWORD ErrorSelector;DWORD DataOffset;DWORD DataSelector;BYTE RegisterArea[80];DWORD Cr0NpxState" 12 | ,PROCESS_INFORMATION :="HANDLE hProcess;HANDLE hThread;DWORD dwProcessId;DWORD dwThreadId" 13 | ,STARTUPINFO :="DWORD cb;LPTSTR lpReserved;LPTSTR lpDesktop;LPTSTR lpTitle;DWORD dwX;DWORD dwY;DWORD dwXSize;DWORD dwYSize;DWORD dwXCountChars;DWORD dwYCountChars;DWORD dwFillAttribute;DWORD dwFlags;WORD wShowWindow;WORD cbReserved2;LPBYTE lpReserved2;HANDLE hStdInput;HANDLE hStdOutput;HANDLE hStdError" 14 | ,M128A:="ULONGLONG Low;LONGLONG High" 15 | ,_XMM_SAVE_AREA32 :="WORD ControlWord;WORD StatusWord;BYTE TagWord;BYTE Reserved1;WORD ErrorOpcode;DWORD ErrorOffset;WORD ErrorSelector;WORD Reserved2;DWORD DataOffset;WORD DataSelector;WORD Reserved3;DWORD MxCsr;DWORD MxCsr_Mask;BinRun(M128A) FloatRegisters[8];BinRun(M128A) XmmRegisters[16];BYTE Reserved4[96]" 16 | ,CONTEXT64:="DWORD64 P1Home;DWORD64 P2Home;DWORD64 P3Home;DWORD64 P4Home;DWORD64 P5Home;DWORD64 P6Home;DWORD ContextFlags;DWORD MxCsr;WORD SegCs;WORD SegDs;WORD SegEs;WORD SegFs;WORD SegGs;WORD SegSs;DWORD EFlags;DWORD64 Dr0;DWORD64 Dr1;DWORD64 Dr2;DWORD64 Dr3;DWORD64 Dr6;DWORD64 Dr7;DWORD64 Rax;DWORD64 Rcx;DWORD64 Rdx;DWORD64 Rbx;DWORD64Rsp;DWORD64 Rbp;DWORD64 Rsi;DWORD64 Rdi;DWORD64 R8;DWORD64 R9;DWORD64 R10;DWORD64 R11;DWORD64R12;DWORD64 R13;DWORD64 R14;DWORD64 R15;DWORD64 Rip;{BinRun(_XMM_SAVE_AREA32) FltSave;struct { BinRun(M128A) Header[2];BinRun(M128A) Legacy[8];BinRun(M128A) Xmm0;BinRun(M128A) Xmm1;BinRun(M128A) Xmm2;BinRun(M128A) Xmm3;BinRun(M128A) Xmm4;BinRun(M128A) Xmm5;BinRun(M128A) Xmm6;BinRun(M128A) Xmm7;BinRun(M128A) Xmm8;BinRun(M128A) Xmm9;BinRun(M128A) Xmm10;BinRun(M128A) Xmm11;BinRun(M128A) Xmm12;BinRun(M128A) Xmm13;BinRun(M128A) Xmm14;BinRun(M128A) Xmm15}};BinRun(M128A) VectorRegister[26];DWORD64 VectorControl;DWORD64 DebugControl;DWORD64 LastBranchToRip;DWORD64 LastBranchFromRip;DWORD64 LastExceptionToRip;DWORD64 LastExceptionFromRip" 17 | ,CONTEXT32:="DWORD ContextFlags;DWORD Dr0;DWORD Dr1;DWORD Dr2;DWORD Dr3;DWORD Dr6;DWORD Dr7;BinRun(FLOATING_SAVE_AREA) FloatSave;DWORD SegGs;DWORD SegFs;DWORD SegEs;DWORD SegDs;DWORD Edi;DWORD Esi;DWORD Ebx;DWORD Edx;DWORD Ecx;DWORD Eax;DWORD Ebp;DWORD Eip;DWORD SegCs;DWORD EFlags;DWORD Esp;DWORD SegSs;BYTE ExtendedRegisters[512]" 18 | ,IMAGE_NT_SIGNATURE:=17744,IMAGE_DOS_SIGNATURE:=23117,PAGE_EXECUTE_READWRITE:=64,CREATE_SUSPENDED:=4 19 | ,MEM_COMMIT:=4096,MEM_RESERVE:=8192,STARTF_USESHOWWINDOW:=1 20 | ,h2o:="B29C2D1CA2C24A57BC5E208EA09E162F(){`nPLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162Fh:='',dmp:=Buffer(sz:=StrLen(hex)//2,0)`nLoop Parse,hex`nIf (`"`"!=h.=A_LoopField) && !Mod(A_Index,2)`nNumPut(`"UChar`",`"0x`" h,dmp,A_Index/2-1),h:=`"`"`nreturn ObjLoad(dmp.Ptr)`n}`n" 21 | local data:="",data2:="",dmp:="", force32bit:=0, script:="",_s:="" 22 | if (Type(pData)="Buffer") 23 | data:=pData,pData:=data.Ptr 24 | else If (Type(pData)!="Integer") 25 | { 26 | ; Try first reading the file from Resource 27 | If res := FindResource(lib:=GetModuleHandle(),pData,10) 28 | data:=Buffer(sz :=SizeofResource(lib,res)) 29 | ,RtlMoveMemory(data.Ptr,LockResource(hres:=LoadResource(lib,res)),sz) 30 | ,FreeResource(hres) 31 | ,data2:=UnZipRawMemory(data.Ptr,sz)?(data:=data2):"" 32 | else ; else try reading file from disc etc... 33 | Data:=FileRead(pData,"RAW") 34 | pData:=Data.Ptr 35 | } 36 | 37 | If InStr(cmdLine,"`n"){ ; a script was given, first line contains the cmdLine 38 | __PIPE_GA_ := CreateNamedPipe(PipeName := "\\.\pipe\AHK" A_TickCount,2,0,255),__PIPE_ := CreateNamedPipe(PipeName,2,0,255) 39 | if (__PIPE_=-1 || __PIPE_GA_=-1) 40 | Return 0 41 | Script:=SubStr(cmdLine,InStr(cmdLine,"`n")+1),cmdLine:=Trim(SubStr(cmdLine,1,InStr(cmdLine,"`n")),"`n`r") A_Space PipeName 42 | } 43 | 44 | IDH:=Struct(IMAGE_DOS_HEADER,pData) 45 | if (IDH.e_magic != IMAGE_DOS_SIGNATURE){ 46 | MsgBox("ERROR: e_magic not found") 47 | return 48 | } 49 | INH := Struct(IMAGE_NT_HEADERS,pData + IDH.e_lfanew) 50 | 51 | if (INH.Signature != IMAGE_NT_SIGNATURE){ 52 | MsgBox("ERROR: Signature not found") 53 | return 54 | } 55 | 56 | If (A_PtrSize=8&&INH.OptionalHeader.magic=267) ; x86 on x64 57 | pNtHeader:=Struct(IMAGE_NT_HEADERS32,pData + IDH.e_lfanew),ctx:=Struct(Context32),Force32Bit:=1 58 | ,ctx.ContextFlags := (A_PtrSize=8?0x100000:0x10000) | 0x2 ;CONTEXT_INTEGER 59 | ,UsedExe:=ExeToUse?ExeToUse:A_WinDir "\Microsoft.NET\Framework\v2.0.50727\vbc.exe" 60 | else if (A_PtrSize=4&&INH.OptionalHeader.magic=523) ; x64 on x86 not possible 61 | Return false 62 | else 63 | pNtHeader:=INH,UsedExe:=ExeToUse?ExeToUse:A_IsCompiled?A_ScriptFullPath:A_AhkPath 64 | ,ctx:=Struct(A_PtrSize=8?Context64:Context32),ctx.ContextFlags := (A_PtrSize=8?0x100000:0x10000) | 0x2 ;CONTEXT_INTEGER 65 | pi:=Struct(PROCESS_INFORMATION) 66 | ,si:=Struct(STARTUPINFO),si.cb:=sizeof(si),si.dwFlags:=HIDE?STARTF_USESHOWWINDOW:0 ;si.wShowWindow already set to 0 67 | if CreateProcess(0,"`"" UsedExe "`"" A_Space cmdLine (cmdLineScript?A_Space (IsObject(cmdLineScript)?"":cmdLineScript):""),0,0,0,CREATE_SUSPENDED,0,0,si[],pi[]){ 68 | if (Force32Bit && Wow64GetThreadContext(pi.hThread,ctx[])) || (!Force32Bit && GetThreadContext(pi.hThread,ctx[])){ 69 | pPebImageBase:=ctx[A_PtrSize=8&&!Force32Bit?"Rdx":"Ebx"] + (Force32Bit?4:A_PtrSize)*2 70 | if ReadProcessMemory(pi.hProcess, pPebImageBase, getvar(dwImagebase:=0), (Force32Bit?4:A_PtrSize), getvar(NumberOfBytes:=0)){ 71 | DllCall("ntdll\NtUnmapViewOfSection","PTR",pi.hProcess, "PTR",dwImagebase) 72 | pImagebase := VirtualAllocEx(pi.hProcess, pNtHeader.OptionalHeader.ImageBase, pNtHeader.OptionalHeader.SizeOfImage, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE) 73 | if (pImagebase) 74 | { 75 | if WriteProcessMemory(pi.hProcess, pImagebase, pData, pNtHeader.OptionalHeader.SizeOfHeaders, getvar(NumberOfBytes:=0)){ 76 | pSecHeader :=Struct(IMAGE_SECTION_HEADER) 77 | ,off:=pNtHeader.Offset("OptionalHeader") 78 | ,vvv:=pNtHeader.OptionalHeader[""] 79 | ,aaa:=pNTHeader[] 80 | ,pSecHeader[] :=pNtHeader.OptionalHeader[""]+pNtHeader.FileHeader.SizeOfOptionalHeader 81 | ,counter := 0 82 | while (++counter < pNtHeader.FileHeader.NumberOfSections+1){ 83 | WriteProcessMemory(pi.hProcess, pImagebase + pSecHeader.VirtualAddress, pData + pSecHeader.PointerToRawData, pSecHeader.SizeOfRawData, getvar(NumberOfBytes:=0)) 84 | pSecHeader[]:=pSecHeader[]+sizeof(pSecHeader) 85 | } 86 | if WriteProcessMemory(pi.hProcess, pPebImageBase, pNtHeader.OptionalHeader.ImageBase[""], (Force32Bit?4:A_PtrSize), getvar(NumberOfBytes:=0)){ 87 | ctx[A_PtrSize=8&&!Force32Bit?"Rcx":"Eax"] := pImagebase + pNtHeader.OptionalHeader.AddressOfEntryPoint 88 | if (Force32Bit && Wow64SetThreadContext(pi.hThread, ctx[])) || (!Force32Bit && SetThreadContext(pi.hThread, ctx[])){ 89 | if ResumeThread(pi.hThread){ 90 | if (Script){ ; use pipe to pass script to new executable 91 | If IsObject(cmdLineScript){ 92 | dmp:=ObjDump(cmdLineScript),hex:=BinToHex(dmp.Ptr,dmp.size) 93 | While _hex:=SubStr(Hex,1 + (A_Index-1)*16370,16370) 94 | _s.= "hex" (A_Index=1?":":".") "=`"" _hex "`"`n" 95 | script:=chr(0xfeff) StrReplace(h2o,"PLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162F",_s) "A_Args:=B29C2D1CA2C24A57BC5E208EA09E162F()`n" script 96 | } else script:=chr(0xfeff) script 97 | ConnectNamedPipe(__PIPE_GA_),CloseHandle(__PIPE_GA_),ConnectNamedPipe(__PIPE_) 98 | if !WriteFile(__PIPE_, StrPtr(script), StrLen(script)*2,getvar(NumberOfBytes:=0)) 99 | Return (CloseHandle(__PIPE_),0) 100 | CloseHandle(__PIPE_) 101 | } 102 | return pi.dwProcessId 103 | } 104 | } 105 | } 106 | } 107 | } 108 | } 109 | } 110 | TerminateProcess(pi.hProcess) 111 | } 112 | return FALSE 113 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/BinToHex.ahk: -------------------------------------------------------------------------------- 1 | BinToHex(addr,len:=0) { ; Thanks Laszo 2 | static b2h:=McodeH(A_PtrSize=8?"4C8BC94585C0744F458BD00F1F440000440FB6024983C10248FFC241C0E8044180E80A410FB6C0C0E805442AC04180C041458841FE0FB64AFF80E10F80E90A0FB6C1C0E8052AC880C14149FFCA418849FF75BD458811C3C60100C3":"558BEC578B7D1085FF74398B4D08568B750C8A06C0E8042C0A8AD0C0EA052AC2044188018A06240F2C0A8AD0C0EA052AC204418841014683C1024F75D55EC601005F5DC38B4508C600005F5DC3","i==ttui") 3 | b2h((hex:=Buffer(2 * (len?len:addr.size) + 2)).Ptr,Type(addr)="Buffer"?addr.Ptr:addr,len?len:addr.size) 4 | Return StrGet(hex,"CP0") 5 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/CenterWindow.ahk: -------------------------------------------------------------------------------- 1 | CenterWindow(aWidth,aHeight){ 2 | ; Given a the window's width and height, calculates where to position its upper-left corner 3 | ; so that it is centered EVEN IF the task bar is on the left side or top side of the window. 4 | ; This does not currently handle multi-monitor systems explicitly, since those calculations 5 | ; require API functions that don't exist in Win95/NT (and thus would have to be loaded 6 | ; dynamically to allow the program to launch). Therefore, windows will likely wind up 7 | ; being centered across the total dimensions of all monitors, which usually results in 8 | ; half being on one monitor and half in the other. This doesn't seem too terrible and 9 | ; might even be what the user wants in some cases (i.e. for really big windows). 10 | 11 | static rect:=Struct("left,top,right,bottom"),SPI_GETWORKAREA:=48,pt:=Struct("x,y") 12 | DllCall("SystemParametersInfo","Int",SPI_GETWORKAREA,"Int", 0,"PTR", rect[],"Int", 0) ; Get desktop rect excluding task bar. 13 | ; Note that rect.left will NOT be zero if the taskbar is on docked on the left. 14 | ; Similarly, rect.top will NOT be zero if the taskbar is on docked at the top of the screen. 15 | pt.x := rect.left + (((rect.right - rect.left) - aWidth) / 2) 16 | pt.y := rect.top + (((rect.bottom - rect.top) - aHeight) / 2) 17 | return pt 18 | } 19 | -------------------------------------------------------------------------------- /Compiler/v2/lib/CreateScript.ahk: -------------------------------------------------------------------------------- 1 | CreateScript(script, path:="",pw:=""){ 2 | static mScript:="" 3 | local Data2:=aScript:="" 4 | WorkingDir:=A_WorkingDir 5 | script:=StrReplace(StrReplace(script,"`n,`r`n"),"`r`r","`r") 6 | If RegExMatch(script,"m)^[^:]+:[^:]+|[a-zA-Z0-9#_@]+\{}$"){ 7 | If !(mScript){ 8 | If (A_IsCompiled){ 9 | lib := GetModuleHandle() 10 | If !(res := FindResource(lib,"E4847ED08866458F8DD35F94B37001C0",10)){ 11 | MsgBox("Could not extract script!") 12 | return 13 | } 14 | DataSize := SizeofResource(lib, res) 15 | ,hresdata := LoadResource(lib,res) 16 | ,pData := LockResource(hresdata),(Data2:=UnZipRawMemory(pData,DataSize,pw))?pData:=Data2.Ptr:"" 17 | If (DataSize){ 18 | mScript := StrReplace(StrReplace(StrReplace(StrReplace(StrGet(pData,"UTF-8"),"`n","`r`n"),"`r`r","`r"),"`r`r","`r"),"`n`n","`n") 19 | line:=Buffer(16384*2) 20 | Loop Parse, mScript,"`n","`r" 21 | { 22 | CryptStringToBinaryW(StrPtr(A_LoopField), 0, 0x1, line.Ptr, getvar(aSizeEncrypted:=16384*2), 0, 0) 23 | if (NumGet(line,"UInt") != 0x04034b50) 24 | break 25 | aScript .= StrGet(UnZipRawMemory(line.Ptr,aSizeEncrypted,pw),"UTF-8") "`r`n" 26 | } 27 | if aScript 28 | mScript:= "`r`n" aScript "`r`n" 29 | else mScript :="`r`n" mScript "`r`n" 30 | } 31 | } else { 32 | mScript:="`r`n" StrReplace(StrReplace(FileRead(path?path:A_ScriptFullPath),"`n","`r`n"),"`r`r","`r") "`r`n" 33 | Loop Parse, mScript,"`n","`r" 34 | { 35 | If A_Index=1 36 | mScript:="" 37 | If RegExMatch(A_LoopField,"i)^\s*#include"){ 38 | temp:=RegExReplace(A_LoopField,"i)^\s*#include[\s+|,]") 39 | If InStr(temp,"`%") 40 | Loop Parse, temp,"`%" 41 | If A_Index=1 42 | temp:=A_LoopField 43 | else if !Mod(A_Index,2) 44 | _temp:=A_LoopField 45 | else _temp:=%_temp%,temp.=_temp A_LoopField,_temp:="" 46 | If InStr(FileExist(trim(temp,"<>")),"D"){ 47 | SetWorkingDir trim(temp,"<>") 48 | continue 49 | } else If InStr(FileExist(temp),"D"){ 50 | SetWorkingDir temp 51 | continue 52 | } else If (SubStr(temp,1,1) . SubStr(temp,-1) = "<>"){ 53 | If !FileExist(_temp:=A_ScriptDir "\lib\" trim(temp,"<>") ".ahk") 54 | If !FileExist(_temp:=A_MyDocuments "\AutoHotkey\lib\" trim(temp,"<>") ".ahk") 55 | If !FileExist(_temp:=SubStr(A_AhkPath,1,InStr(A_AhkPath,"\",1,-1)) "lib\" trim(temp,"<>") ".ahk") 56 | If FileGetShortcut(SubStr(A_AhkPath,1,InStr(A_AhkPath,"\",1,-1)) "lib.lnk",_temp) 57 | _temp:=_temp "\" trim(temp,"<>") ".ahk" 58 | mScript.= FileRead(_temp) "`r`n" 59 | } else mScript.= FileRead(temp) "`r`n" 60 | } else mScript.=A_LoopField "`r`n" 61 | } 62 | } 63 | } 64 | Loop Parse, script,"`n","`r" 65 | { 66 | If A_Index=1 67 | script:="" 68 | else If A_LoopField="" 69 | Continue 70 | If (RegExMatch(A_LoopField,"^[^:\s]+:[^:\s=]+$")){ 71 | label:=StrSplit(A_LoopField,":") 72 | If (label.Length=2) ; cannot test if global label exist inside function (out of scope): and IsLabel(label[1]) and IsLabel(label[2])) 73 | script .=SubStr(mScript 74 | , h:=InStr(mScript,"`r`n" label[1] ":`r`n") 75 | , InStr(mScript,"`r`n" label[2] ":`r`n")-h) . "`r`n" 76 | } else if RegExMatch(A_LoopField,"^[^\{}\s]+\{}$") 77 | label := SubStr(A_LoopField,1,-2),script .= SubStr(mScript 78 | , h:=RegExMatch(mScript,"i)\n" label "\([^\\)\n]*\)\n?\s*\{") 79 | , RegExMatch(mScript,"\n}\s*\n\K",,h)-h) . "`r`n" 80 | else script .= A_LoopField "`r`n" 81 | } 82 | } 83 | script:=StrReplace(script,"`r`n","`n") 84 | SetWorkingDir WorkingDir 85 | Return Script 86 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/CriticalSection.ahk: -------------------------------------------------------------------------------- 1 | CriticalSection(cs:=0){ 2 | static i:=0,crisec:={base:{__Delete:CriticalSection}} 3 | if IsObject(cs){ 4 | Loop i 5 | DeleteCriticalSection(cs.%i%.Ptr),cs.DeleteProp("" i) 6 | Return i:=0 7 | } else if cs 8 | return (DeleteCriticalSection(cs),cs) 9 | Return (i++,crisec.%i%:=Buffer(A_PtrSize=8?40:24),InitializeCriticalSection(crisec.%i%.Ptr),crisec.%i%.Ptr) 10 | } 11 | -------------------------------------------------------------------------------- /Compiler/v2/lib/DirGetParent.ahk: -------------------------------------------------------------------------------- 1 | dirgetparent(path,parent:=1){ 2 | path:=RTrim(path,"\") 3 | while parent>=idx:=A_Index 4 | Loop Files, path,"FD" 5 | if idx=parent 6 | return A_LoopFileDir (A_LoopFileDir?"\":"") 7 | else if path:=A_LoopFileDir 8 | break 9 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/DynaRun.ahk: -------------------------------------------------------------------------------- 1 | DynaRun(s,pn:="",pr:="",exe:=""){ 2 | static AhkPath:="`"" A_AhkPath "`"" (A_IsCompiled||(A_IsDll&&DllCall(A_AhkPath "\ahkgetvar","Str","A_IsCompiled","Uint",0,"Uint",0,"CDecl"))?" /E":"") 3 | ,h2o:="B29C2D1CA2C24A57BC5E208EA09E162F(){`nPLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162Fh:='',dmp:=Buffer(sz:=StrLen(hex)//2,0)`nLoop Parse, hex`nIf (`"`"!=h.=A_LoopField) && !Mod(A_Index,2)`nNumPut(`"UChar`",`"0x`" h,dmp,A_Index/2-1),h:=`"`"`nreturn ObjLoad(dmp.Ptr)`n}`n" 4 | local dmp:="",_s:="",p1:="",p2:="",Arg:="" 5 | if (-1=p1:=DllCall("CreateNamedPipe","str",pf:="\\.\pipe\" (pn!=""?pn:"AHK" A_TickCount),"uint",2,"uint",0,"uint",255,"uint",0,"uint",0,"Ptr",0,"Ptr",0)) 6 | || (-1=p2:=DllCall("CreateNamedPipe","str",pf,"uint",2,"uint",0,"uint",255,"uint",0,"uint",0,"Ptr",0,"Ptr",0)) 7 | Return 0 8 | try 9 | Run (exe?exe:AhkPath) " `"" pf "`" " (IsObject(pr)?"": " " pr),,"UseErrorLevel HIDE",&P 10 | catch 11 | return (DllCall("CloseHandle","Ptr",p1),DllCall("CloseHandle","Ptr",p2),0) 12 | If IsObject(pr) { 13 | dmp:=ObjDump(pr),hex:=BinToHex(dmp.Ptr,dmp.Size) 14 | While _hex:=SubStr(Hex,1 + (A_Index-1)*16370,16370) 15 | _s.= "hex" (A_Index=1?":":".") "=`"" _hex "`"`n" 16 | Arg:=StrReplace(h2o,"PLACEHOLDERB29C2D1CA2C24A57BC5E208EA09E162F",_s) "global A_Args:=B29C2D1CA2C24A57BC5E208EA09E162F()`n" 17 | } 18 | DllCall("ConnectNamedPipe","Ptr",p1,"Ptr",0),DllCall("CloseHandle","Ptr",p1),DllCall("ConnectNamedPipe","Ptr",p2,"Ptr",0) 19 | if !DllCall("WriteFile","Ptr",p2,"Wstr",s:=chr(0xfeff) Arg s,"UInt",StrLen(s)*2+4,"uint*",0,"Ptr",0) 20 | P:=0 21 | DllCall("CloseHandle","Ptr",p2) 22 | Return P 23 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/EnvUpdate.ahk: -------------------------------------------------------------------------------- 1 | EnvUpdate(){ 2 | static HWND_BROADCAST:=0xFFFF,WM_SETTINGCHANGE:=0x001A,Environment:="Environment" 3 | SendMessage WM_SETTINGCHANGE, 0, StrPtr(Environment),, "ahk_id " HWND_BROADCAST 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ErrorMessage.ahk: -------------------------------------------------------------------------------- 1 | errormessage(E:=0){ 2 | static ES:=Buffer(1024) 3 | FormatMessage(0x00001000,0,e?e:A_LastError,0,ES.Ptr,1024) 4 | return StrReplace(StrGet(ES),"`r`n"," ") 5 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ExtractIconFromExecutable.ahk: -------------------------------------------------------------------------------- 1 | ExtractIconFromExecutable(aFilespec, aIconNumber, aWidth, aHeight){ 2 | static LOAD_LIBRARY_AS_DATAFILE:=2,RT_ICON:=3,RT_GROUP_ICON := RT_ICON + 11 3 | hicon := 0 4 | ; If the module is already loaded as an executable, LoadLibraryEx returns its handle. 5 | ; Otherwise each call will receive its own handle to a data file mapping. 6 | if ( hdatafile := LoadLibraryEx(aFilespec, 0, LOAD_LIBRARY_AS_DATAFILE) ){ 7 | group_icon_id := (aIconNumber < 0 ? -aIconNumber : ResourceIndexToId(hdatafile, RT_GROUP_ICON, aIconNumber ? aIconNumber : 1)) 8 | 9 | ;~ HRSRC hres 10 | ;~ HGLOBAL hresdata 11 | ;~ LPVOID presdata 12 | 13 | ; MSDN indicates resources are unloaded when the *process* exits, but also states 14 | ; that the pointer returned by LockResource is valid until the *module* containing 15 | ; the resource is unloaded. Testing seems to indicate that unloading a module indeed 16 | ; unloads or invalidates any resources it contains. 17 | if ((hres := FindResource(hdatafile, group_icon_id, RT_GROUP_ICON)) 18 | && (hresdata := LoadResource(hdatafile, hres)) 19 | && (presdata := LockResource(hresdata))) 20 | { 21 | ; LookupIconIdFromDirectoryEx seems to use whichever is larger of aWidth or aHeight, 22 | ; so one or the other may safely be -1. However, since this behaviour is undocumented, 23 | ; treat -1 as "same as other dimension": 24 | icon_id := LookupIconIdFromDirectoryEx(presdata, TRUE, aWidth == -1 ? aHeight : aWidth, aHeight == -1 ? aWidth : aHeight, 0) 25 | if (icon_id 26 | && (hres := FindResource(hdatafile, icon_id, RT_ICON)) 27 | && (hresdata := LoadResource(hdatafile, hres)) 28 | && (presdata := LockResource(hresdata))) 29 | { 30 | hicon := CreateIconFromResourceEx(presdata, SizeofResource(hdatafile, hres), TRUE, 0x30000, 0, 0, 0) 31 | } 32 | } 33 | 34 | ; Decrements the executable module's reference count or frees the data file mapping. 35 | FreeLibrary(hdatafile) 36 | } 37 | 38 | ; L20: Fall back to ExtractIcon if the above method failed. This may work on some versions of Windows where 39 | ; ExtractIcon supports 16-bit "executables" (such as ICL files) that cannot be loaded by LoadLibraryEx. 40 | ; However, resource ID -1 is not supported, and if multiple icon sizes exist in the file, the first is used 41 | ; rather than the most appropriate. 42 | if (!hicon) 43 | hicon := ExtractIcon(0, aFilespec, aIconNumber > 0 ? aIconNumber - 1 : aIconNumber < -1 ? aIconNumber : 0) 44 | 45 | return hicon 46 | } 47 | -------------------------------------------------------------------------------- /Compiler/v2/lib/FileReplace.ahk: -------------------------------------------------------------------------------- 1 | FileReplace(data,file,Options:=""){ 2 | If FileExist(file) 3 | FileDelete(file) 4 | if !Options 5 | return FileAppend(data,file) 6 | else return FileAppend(data,file,Options) 7 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/FindFunc.ahk: -------------------------------------------------------------------------------- 1 | FindFunc(Name, thread:=0){ 2 | static ahkFindFunc:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkFindFunc"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkFindFunc","PTR"),"i==sui","",GetCurrentThreadId()) 3 | return ahkFindFunc(Name) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/FindLabel.ahk: -------------------------------------------------------------------------------- 1 | FindLabel(Name,thread:=0){ 2 | static ahkFindLabel:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkFindLabel"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkFindLabel","PTR"),"i==sui","",GetCurrentThreadId()) 3 | return ahkFindLabel(Name) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/FontExist.ahk: -------------------------------------------------------------------------------- 1 | FontExist(aHdc,aTypeface, FontType:=unset, lParam:=unset){ 2 | static DEFAULT_CHARSET:=1,LOGFONT:="LONG lfHeight;LONG lfWidth;LONG lfEscapement;LONG lfOrientation;LONG lfWeight;BYTE lfItalic;BYTE lfUnderline;BYTE lfStrikeOut;BYTE lfCharSet;BYTE lfOutPrecision;BYTE lfClipPrecision;BYTE lfQuality;BYTE lfPitchAndFamily;TCHAR lfFaceName[32]" 3 | ,lf:=Struct(LOGFONT) ;LF_FACESIZE:=32 4 | ,FontEnumProc:=CallbackCreate(FontExist) 5 | if IsSet(lParam){ 6 | NumPut("Char",1,lParam) ; Indicate to the caller that the font exists. 7 | return 0 ; Stop the enumeration after the first, since even one match means the font exists. 8 | } 9 | lf.lfCharSet := DEFAULT_CHARSET ; Enumerate all char sets. 10 | lf.lfPitchAndFamily := 0 ; Must be zero. 11 | StrPut(aTypeface,lf.lfFaceName[""]) 12 | DllCall("EnumFontFamiliesEx","PTR",aHdc,"PTR", lf[],"PTR", FontEnumProc,"CHAR*", font_exists:=0,"Int", 0) 13 | return font_exists 14 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/GetEnv.ahk: -------------------------------------------------------------------------------- 1 | GetEnv(){ 2 | allEnvStr:={} 3 | _EnvStr:=EnvStr:=DllCall("GetEnvironmentStringsW","PTR") 4 | While thisEnvStr:=SubStr(temp:=StrGet(EnvStr,"UTF-16"),1,InStr(temp,"=",1,2)-1) 5 | If ((EnvStr+=StrLen(temp)*2+2) && RegExMatch(thisEnvStr,"^[\w_]+$")) 6 | allEnvStr.%thisEnvStr%:=EnvGet(thisEnvStr) 7 | return (DllCall("FreeEnvironmentStringsW","PTR",_EnvStr), allEnvStr) 8 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/GetProcessParameter.ahk: -------------------------------------------------------------------------------- 1 | GetProcessParameter(dwProcId, parameter:="cmd_line") { 2 | static PROCESS_BASIC_INFORMATION :="PVOID Reserved1;PEB *PebBaseAddress;PVOID Reserved2[2];ULONG_PTR UniqueProcessId;PVOID Reserved3;",PEB :="BYTE Reserved1[2];BYTE BeingDebugged;BYTE Reserved2[1];PVOID Reserved3[2];PEB_LDR_DATA *Ldr;RTL_USER_PROCESS_PARAMETERS *ProcessParameters;PVOID Reserved4[3];PVOID AtlThunkSListPtr;PVOID Reserved5;ULONG Reserved6;PVOID Reserved7;ULONG Reserved8;ULONG AtlThunkSListPtr32;PVOID Reserved9[45];BYTE Reserved10[96];PTR* PostProcessInitRoutine;BYTE Reserved11[128];PVOID Reserved12[1];ULONG SessionId;",PEB_LDR_DATA:="BYTE Reserved1[8];PVOID Reserved2[3];LIST_ENTRY InMemoryOrderModuleList;",LIST_ENTRY :="LIST_ENTRY *Flink;LIST_ENTRY *Blink;",RTL_USER_PROCESS_PARAMETERS :="BYTE Reserved1[16];PVOID Reserved2[10];UNICODE_STRING ImagePathName;UNICODE_STRING CommandLine;",UNICODE_STRING :="USHORT Length;USHORT MaximumLength;PTR Buffer;",MY_RTL_DRIVE_LETTER_CURDIR:="USHORT Flags;USHORT Length;ULONG TimeStamp;LPTSTR DosPath;",MY_CURDIR :="UNICODE_STRING DosPath;VOID* Handle;",MY_RTL_USER_PROCESS_PARAMETERS :="ULONG MaximumLength;ULONG Length;ULONG Flags;ULONG DebugFlags;VOID* ConsoleHandle;ULONG ConsoleFlags;VOID* StandardInput;VOID* StandardOutput;VOID* StandardError;MY_CURDIR CurrentDirectory;UNICODE_STRING DllPath;UNICODE_STRING ImagePathName;UNICODE_STRING CommandLine;VOID* Environment;ULONG StartingX;ULONG StartingY;ULONG CountX;ULONG CountY;ULONG CountCharsX;ULONG CountCharsY;ULONG FillAttribute;ULONG WindowFlags;ULONG ShowWindowFlags;UNICODE_STRING WindowTitle;UNICODE_STRING DesktopInfo;UNICODE_STRING ShellInfo;UNICODE_STRING RuntimeData;MY_RTL_DRIVE_LETTER_CURDIR CurrentDirectores[32];" 3 | static pbi := Struct(PROCESS_BASIC_INFORMATION) 4 | 5 | if (hProcess := OpenProcess(1024 | 16, FALSE, dwProcId)){ ;PROCESS_QUERY_INFORMATION:=1024 | PROCESS_VM_READ:=16 6 | if (pbi := !DllCall("ntdll.dll\NtQueryInformationProcess","Ptr",hProcess, "Ptr", 0, "PTR", pbi[], "Uint", sizeof(pbi),"PTR", NULL) ? pbi : 0) { 7 | if parameter="parent_pid" 8 | return (CloseHandle(hProcess), pbi.Reserved3) 9 | pRtlUserProcParamsAddress:=Struct("MY_RTL_USER_PROCESS_PARAMETERS*") 10 | if ReadProcessMemory(hProcess, pbi["PebBaseAddress"]["ProcessParameters"][""], pRtlUserProcParamsAddress[], sizeof(pRtlUserProcParamsAddress), getvar(nSizeRead:=0)) && (nSizeRead == sizeof(pRtlUserProcParamsAddress)){ 11 | paramStr := Struct(UNICODE_STRING) 12 | if (ReadProcessMemory(hProcess, parameter="working_dir"?pRtlUserProcParamsAddress[1]["CurrentDirectory"]["DosPath"][""]:pRtlUserProcParamsAddress[1]["CommandLine"][""],paramStr[], sizeof(paramStr), getvar(nSizeRead)) && (nSizeRead == sizeof(paramStr))) { 13 | szParameter := Buffer(paramStr["MaximumLength"]) 14 | if (szParameter) { 15 | if (ReadProcessMemory(hProcess, paramStr["buffer"], szParameter.ptr, paramStr["Length"], getvar(nSizeRead)) && (nSizeRead == paramStr["Length"])) 16 | return (CloseHandle(hProcess),StrGet(szParameter,paramStr["Length"]//2)) 17 | else 18 | throw ValueError("Couldn't read parameter string",-1) 19 | } else 20 | throw ValueError("Couldn't allocate memory",-1) 21 | } else 22 | throw ValueError("Couldn't read parameter",-1) 23 | } else 24 | throw ValueError("Couldn't read process memory",-1) 25 | } else 26 | throw ValueError("Couldn't get PEB address",-1) 27 | 28 | } else 29 | throw ValueError("Couldn't open process",-1) 30 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/HIBYTE.ahk: -------------------------------------------------------------------------------- 1 | HIBYTE(a){ 2 | return ToShort(a)>>8&0xff 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/HIWORD.ahk: -------------------------------------------------------------------------------- 1 | HIWORD(a){ 2 | return ToInt(a)>>16&0xffff 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/HexToBin.ahk: -------------------------------------------------------------------------------- 1 | HexToBin(hex) { ; Thanks Laszo 2 | static h2b:=McodeH(A_PtrSize=8?"440FB60A48FFC24C8BD14584C9745490450FB6C141C0E806410FB6C0C0E0034402C04502C141C0E004458802440FB60A4584C9742E410FB6C94180E10F49FFC2C0E9064883C2020FB6C1C0E00302C84102C9410AC841884AFF440FB64AFF4584C975ADF3C3":"558BEC568B750C8A0E4684C97447578B7D08538AC1C0E8068AD002D202D202D202C28D1401C0E20488178A0E84C974238AC1C0E8068AD802DB02DB02DB02C380E10F02C10AC288078A4E014783C60284C975C05B5F5E5DC3","i==ta") 3 | h2b((bin:=Buffer(StrLen(hex)/2 + 1)).Ptr,hex) 4 | Return bin 5 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/IsBom.ahk: -------------------------------------------------------------------------------- 1 | isbom(address,bom:=0){ 2 | return bom="UTF-8"?0xBFBBEF=NumGet(address,"UInt")&0xFFFFFF 3 | : bom="UTF-16"?0xFEFF=NumGet(address,"UShort")&0xFFFF 4 | : bom="UTF-16BE"?0xFFFE=NumGet(address,"UShort")&0xFFFF 5 | : bom="UTF-32"?0x0000FEFF=NumGet(address,"UInt64")&0xFFFFFFFF 6 | : bom="UTF-32BE"?0x0000FFFE=NumGet(address,"UInt64")&0xFFFFFFFF 7 | : !bom?(0xBFBBEF=NumGet(address,"UInt")&0xFFFFFF?"UTF-8":0xFEFF=NumGet(address,"UShort")&0xFFFF?"UTF-16":0xFFFE=NumGet(address,"UShort")&0xFFFF?"UTF-16BE":0x0000FEFF=NumGet(address,"UInt64")&0xFFFFFFFF?"UTF-32":0x0000FFFE=NumGet(address,"UInt64")&0xFFFFFFFF?"UTF-32BE":"CP0"):"" 8 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/IsFileInUse.ahk: -------------------------------------------------------------------------------- 1 | IsFileInUse(f,access:="rwd"){ 2 | return FileExist(f)&&!FileOpen(f,"w -" access) 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/LOBYTE.ahk: -------------------------------------------------------------------------------- 1 | LOBYTE(a){ 2 | return ToChar(a) 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/LOWORD.ahk: -------------------------------------------------------------------------------- 1 | LOWORD(a){ 2 | return ToShort(a) 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKELANGID.ahk: -------------------------------------------------------------------------------- 1 | MAKELANGID(p, s){ 2 | return ToShort(s)<<10|ToShort(p) 3 | } 4 | -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKELCID.ahk: -------------------------------------------------------------------------------- 1 | MAKELCID(lgid, srtid){ 2 | return ToShort(srtid) << 16 | ToShort(lgid) 3 | } 4 | -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKELONG.ahk: -------------------------------------------------------------------------------- 1 | MAKELONG(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKELPARAM.ahk: -------------------------------------------------------------------------------- 1 | MAKELPARAM(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKELRESULT.ahk: -------------------------------------------------------------------------------- 1 | MAKELRESULT(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKEWORD.ahk: -------------------------------------------------------------------------------- 1 | MAKEWORD(a, b){ 2 | return ToChar(a) | ToChar(b) << 8 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MAKEWPARAM.ahk: -------------------------------------------------------------------------------- 1 | MAKEWPARAM(a, b){ 2 | return (ToShort(a) & 0xffff) | (ToShort(b) & 0xffff) << 16 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/MCodeH.ahk: -------------------------------------------------------------------------------- 1 | MCodeH(h,def,p*){ 2 | static f:=[],DynaCalls:=Map() 3 | If DynaCalls.Has(h) 4 | return DynaCalls[h] 5 | f.Push(buf:=Buffer(len:=StrLen(h)//2)) 6 | DllCall("VirtualProtect","PTR",addr:=buf.ptr,"Uint",len,"UInt",64,"Uint*",0) 7 | Loop len 8 | NumPut("Char","0x" SubStr(h,2*A_Index-1,2),addr,A_Index-1) 9 | if p.Length 10 | Return DynaCalls[h]:=DynaCall(addr,def,p*) 11 | else Return DynaCalls[h]:=DynaCall(addr,def) 12 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/NewThread.ahk: -------------------------------------------------------------------------------- 1 | NewThread(s:="Persistent",p:="",t:="AutoHotkey",w:=0xFFFFFFFF,h:=0){ 2 | static Newthread_CloseWindows:=CallbackCreate(NewThread,,2),freecallback:={__Delete:NewThread} 3 | if IsObject(s) 4 | return CallbackFree(Newthread_CloseWindows) 5 | if (IsInteger(s)){ 6 | if IsInteger(p){ 7 | DetectHiddenWindows:=A_DetectHiddenWindows 8 | A_DetectHiddenWindows := 1 9 | If (WinGetClass("ahk_id " s)!="AutoHotkey") 10 | SendMessage_(s,16,0,0) ;WM_CLOSE:=16 11 | A_DetectHiddenWindows:=DetectHiddenWindows 12 | return true 13 | } 14 | success:=true 15 | if hThread:=OpenThread(THREAD_ALL_ACCESS:=2032639,true,s) 16 | EnumThreadWindows(s,Newthread_CloseWindows,0),success:=QueueUserAPC(NumGet(GetProcAddress(t,"g_ThreadExitApp"),"PTR"),hThread,s),CloseHandle(hThread),PostThreadMessage(s, 0, 0, 0) 17 | return success 18 | } 19 | if !IsInteger(h) 20 | h:=LoadLibrary(h) 21 | ahkFunction:=GetProcAddress(h:=h?h:A_ModuleHandle,"ahkFunction"),ahkPostFunction:=GetProcAddress(h,"ahkPostFunction") 22 | ,thread:={ThreadID:ThreadID:=s=""?GetCurrentThreadId():DllCall(GetProcAddress(h,"NewThread"), "Str", (w?"SetEvent(" hEvent:=CreateEvent() ")`n":"") s, "Str", p, "Str", t, "CDECL UInt")} 23 | ,thread._ahkFunction:=DynaCall(ahkFunction,"s==sttttttttttui","",0,0,0,0,0,0,0,0,0,0,ThreadID) 24 | ,thread._ahkPostFunction:=DynaCall(ahkPostFunction,"i==sttttttttttui","",0,0,0,0,0,0,0,0,0,0,ThreadID) 25 | ,thread.ahkFunction:=DynaCall(ahkFunction,"s==sssssssssssui","","","","","","","","","","","",ThreadID) 26 | ,thread.ahkPostFunction:=DynaCall(ahkPostFunction,"i==sssssssssssui","","","","","","","","","","","",ThreadID) 27 | ,thread.addScript:=DynaCall(GetProcAddress(h,"addScript"),"ut==siui","",0,ThreadID) 28 | ,thread.ahkExec:=DynaCall(GetProcAddress(h,"ahkExec"),"ut==sui","",ThreadID) 29 | ,thread.ahkExecuteLine:=DynaCall(GetProcAddress(h,"ahkExecuteLine"),"ut==utuiuiui",0,0,0,ThreadID) 30 | ,thread.ahkFindFunc:=DynaCall(GetProcAddress(h,"ahkFindFunc"),"ut==sui","",ThreadID) 31 | ,thread.ahkFindLabel:=DynaCall(GetProcAddress(h,"ahkFindLabel"),"ut==sui","",ThreadID) 32 | ,thread.ahkgetvar:=DynaCall(GetProcAddress(h,"ahkgetvar"),"s==suiui","",0,ThreadID) 33 | ,thread.ahkassign:=DynaCall(GetProcAddress(h,"ahkassign"),"i==ssui","","",ThreadID) 34 | ,thread.ahkLabel:=DynaCall(GetProcAddress(h,"ahkLabel"),"ui==suiui","",0,ThreadID) 35 | ,thread.ahkPause:=DynaCall(GetProcAddress(h,"ahkPause"),"ui==sui","",ThreadID) 36 | ,thread.ahkReady:=DynaCall(GetProcAddress(h,"ahkReady"),"ui==ui",ThreadID) 37 | ,thread.ahkterminate:=NewThread.Bind(ThreadID,,h) 38 | if w 39 | WaitForSingleObject(hEvent,w),CloseHandle(hEvent) 40 | return thread 41 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ObjByRef.ahk: -------------------------------------------------------------------------------- 1 | Class ObjByRef{ 2 | __new(&_1:=unset,&_2:=unset,&_3:=unset,&_4:=unset,&_5:=unset,&_6:=unset,&_7:=unset,&_8:=unset,&_9:=unset,&_10:=unset,&_11:=unset,&_12:=unset,&_13:=unset,&_14:=unset,&_15:=unset,&_16:=unset,&_17:=unset,&_18:=unset,&_19:=unset,&_20:=unset,&_21:=unset,&_22:=unset,&_23:=unset,&_24:=unset,&_25:=unset,&_26:=unset,&_27:=unset,&_28:=unset,&_29:=unset,&_30:=unset,&_31:=unset,&_32:=unset,&_33:=unset,&_34:=unset,&_35:=unset,&_36:=unset,&_37:=unset,&_38:=unset,&_39:=unset,&_40:=unset,&_41:=unset,&_42:=unset,&_43:=unset,&_44:=unset,&_45:=unset,&_46:=unset,&_47:=unset,&_48:=unset,&_49:=unset,&_50:=unset,&_51:=unset,&_52:=unset,&_53:=unset,&_54:=unset,&_55:=unset,&_56:=unset,&_57:=unset,&_58:=unset,&_59:=unset,&_60:=unset,&_61:=unset,&_62:=unset,&_63:=unset,&_64:=unset,&_65:=unset,&_66:=unset,&_67:=unset,&_68:=unset,&_69:=unset,&_70:=unset,&_71:=unset,&_72:=unset,&_73:=unset,&_74:=unset,&_75:=unset,&_76:=unset,&_77:=unset,&_78:=unset,&_79:=unset,&_80:=unset,&_81:=unset,&_82:=unset,&_83:=unset,&_84:=unset,&_85:=unset,&_86:=unset,&_87:=unset,&_88:=unset,&_89:=unset,&_90:=unset,&_91:=unset,&_92:=unset,&_93:=unset,&_94:=unset,&_95:=unset,&_96:=unset,&_97:=unset,&_98:=unset,&_99:=unset,&_100:=unset,&_101:=unset,&_102:=unset,&_103:=unset,&_104:=unset,&_105:=unset,&_106:=unset,&_107:=unset,&_108:=unset,&_109:=unset,&_110:=unset,&_111:=unset,&_112:=unset,&_113:=unset,&_114:=unset,&_115:=unset,&_116:=unset,&_117:=unset,&_118:=unset,&_119:=unset,&_120:=unset,&_121:=unset,&_122:=unset,&_123:=unset,&_124:=unset,&_125:=unset,&_126:=unset,&_127:=unset,&_128:=unset,&_129:=unset,&_130:=unset,&_131:=unset,&_132:=unset,&_133:=unset,&_134:=unset,&_135:=unset,&_136:=unset,&_137:=unset,&_138:=unset,&_139:=unset,&_140:=unset,&_141:=unset,&_142:=unset,&_143:=unset,&_144:=unset,&_145:=unset,&_146:=unset,&_147:=unset,&_148:=unset,&_149:=unset,&_150:=unset,&_151:=unset,&_152:=unset,&_153:=unset,&_154:=unset,&_155:=unset,&_156:=unset,&_157:=unset,&_158:=unset,&_159:=unset,&_160:=unset,&_161:=unset,&_162:=unset,&_163:=unset,&_164:=unset,&_165:=unset,&_166:=unset,&_167:=unset,&_168:=unset,&_169:=unset,&_170:=unset,&_171:=unset,&_172:=unset,&_173:=unset,&_174:=unset,&_175:=unset,&_176:=unset,&_177:=unset,&_178:=unset,&_179:=unset,&_180:=unset,&_181:=unset,&_182:=unset,&_183:=unset,&_184:=unset,&_185:=unset,&_186:=unset,&_187:=unset,&_188:=unset,&_189:=unset,&_190:=unset,&_191:=unset,&_192:=unset,&_193:=unset,&_194:=unset,&_195:=unset,&_196:=unset,&_197:=unset,&_198:=unset,&_199:=unset,&_200:=unset,&_201:=unset,&_202:=unset,&_203:=unset,&_204:=unset,&_205:=unset,&_206:=unset,&_207:=unset,&_208:=unset,&_209:=unset,&_210:=unset,&_211:=unset,&_212:=unset,&_213:=unset,&_214:=unset,&_215:=unset,&_216:=unset,&_217:=unset,&_218:=unset,&_219:=unset,&_220:=unset,&_221:=unset,&_222:=unset,&_223:=unset,&_224:=unset,&_225:=unset,&_226:=unset,&_227:=unset,&_228:=unset,&_229:=unset,&_230:=unset,&_231:=unset,&_232:=unset,&_233:=unset,&_234:=unset,&_235:=unset,&_236:=unset,&_237:=unset,&_238:=unset,&_239:=unset,&_240:=unset,&_241:=unset,&_242:=unset,&_243:=unset,&_244:=unset,&_245:=unset,&_246:=unset,&_247:=unset,&_248:=unset,&_249:=unset,&_250:=unset,&_251:=unset,&_252:=unset,&_253:=unset,&_254:=unset){ 3 | static _AhkVar:="{Int64 ContentsInt64,Double ContentsDouble,PTR object,PTR mVV},{char *ByteContents,LPTSTR CharContents},{UINT_PTR ByteLength,_AHKVar *AliasFor},UINT_PTR Capacity,BYTE HowAllocated,BYTE Attrib,BYTE Scope,BYTE Type,LPTSTR Name",var:=Struct(_AhkVar) 4 | while IsSetRef(&_%A_Index%) 5 | var[]:=getvar(_%A_Index%),val:=var.AliasFor["",""],this.DefineProp("`a" var.AliasFor["name"],{get : (*)=>val}) 6 | return this 7 | } 8 | __GET(key,param){ 9 | local var:="" 10 | Alias(var,this.%"`a" key%) 11 | return var 12 | } 13 | __SET(key,param,value:=unset){ 14 | static _AhkVar:="{Int64 ContentsInt64,Double ContentsDouble,PTR object,PTR mVV},{char *ByteContents,LPTSTR CharContents},{UINT_PTR ByteLength,_AHKVar *AliasFor},UINT_PTR Capacity,BYTE HowAllocated,BYTE Attrib,BYTE Scope,BYTE Type,LPTSTR Name",var:=Struct("_AhkVar"),val:="" 15 | local thisvar:="" 16 | If !this.HasProp("`a" key) 17 | return (var[]:=value,this.DefineProp("`a" key,{get : (*)=>value}),"") 18 | Alias(thisvar,this.%"`a" key%) 19 | return thisvar:=value 20 | } 21 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ObjShare.ahk: -------------------------------------------------------------------------------- 1 | ObjShare(obj){ 2 | static IDispatch:=Buffer(16), init := NumPut("int64",0x46000000000000c0, NumPut("int64", 0x20400, IDispatch)) 3 | if IsObject(obj) 4 | return LresultFromObject(IDispatch.Ptr, 0, ObjPtr(obj)) 5 | else if ObjectFromLresult(obj, IDispatch.Ptr, 0, getvar(com:=0)) 6 | return MsgBox(A_ThisFunc ": LResult Object could not be created") 7 | return ComValue(9,com,1) 8 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ResDelete.ahk: -------------------------------------------------------------------------------- 1 | ResDelete(dll,name,type:=10,language:=1033){ 2 | return !(hUpdate:=BeginUpdateResourceW(dll))?0:(result:=EndUpdateResource(hUpdate,!result:=UpdateResource(hUpdate,type,name,language)),result) 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ResDllCreate.ahk: -------------------------------------------------------------------------------- 1 | ResDllCreate(path) { 2 | static Trg:=Buffer(112,0),hex:="504B0304A443DDC85C0000000004000000000000F38D62201B1C60187810E0CAC0E0C3C8C8F0BF9F65374CEC01039F2237233B1798C384A458008A19182134508E052A05A31914107A98C1C22C503D02501A4EA102011CE234027A45C545C90C08A781DDCC84AAC6018C46C128C00D00" 3 | Loop Parse,hex 4 | If Mod(A_Index,2) 5 | h:=A_LoopField 6 | else NumPut("UChar","0x" h A_LoopField,Trg,A_Index/2-1) 7 | Data:=UnZipRawMemory(Trg,112) 8 | If 0= 0 && vParams[9].nValue() <= 1000 ) 57 | ; nWeight = vParams[9].nValue() ; Font Weight 58 | g_hFontSplash := CreateFont(0-(nSize*CyPixels)/72,0,0,0,nWeight,0,0,0,DEFAULT_CHARSET,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,FF_DONTCARE,StrGet(default_font_name)) ; Create Font 59 | ; The font is deleted when by g_script's destructor. 60 | } 61 | 62 | SendMessage_(static_win,WM_SETFONT,g_hFontSplash,MAKELPARAM(TRUE, 0)) ; Do Font 63 | ShowWindow(g_hWndSplash,SW_SHOWNOACTIVATE) ; Show the Splash 64 | ; Doesn't help with the brief delay in updating the window that happens when 65 | ; something like URLDownloadToFile is used immediately after SplashTextOn: 66 | ;InvalidateRect(g_hWndSplash, NULL, TRUE) 67 | ; But this does, but for now it seems unnecessary since the user can always do 68 | ; a manual sleep in the extremely rare cases this ever happens (even when it does 69 | ; happen, the window updates eventually, after the download starts, at least on 70 | ; my system. Update: Might as well do it since it's a little nicer this way 71 | ; (the text appears more quickly when the command after the splash is something 72 | ; that might keep our thread tied up and unable to check messages). 73 | Sleep(-1) 74 | ; UpdateWindow() would probably achieve the same effect as the above, but it feels safer to do 75 | ; the above because it ensures that our message queue is empty prior to returning to our caller. 76 | ; return 0 77 | } 78 | -------------------------------------------------------------------------------- /Compiler/v2/lib/StrBuf.ahk: -------------------------------------------------------------------------------- 1 | StrBuf(string, encoding:="UTF-8"){ 2 | return (buf := Buffer(StrPut(string, encoding)),StrPut(string, buf, encoding),buf) 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ThreadObj.ahk: -------------------------------------------------------------------------------- 1 | Class ThreadObj { 2 | static Call(script,cmdLine:="",title:=""){ 3 | if IsObject(script){ 4 | v:=0 5 | try v:=script.A_ScriptHwnd 6 | return v!=0 7 | } 8 | ThreadID:=DllCall(A_AhkPath "\NewThread", "Str", "A_ParentThread:=ObjShare(" ObjShare(super()) ")`nNumPut(`"PTR`",ObjShare(ThreadObj.New())," getvar(pObjShare:=0) ")`nSetEvent(" hEvent:=CreateEvent() ")`n" script, "Str", cmdLine, "Str", title, "CDecl UInt") 9 | ,WaitForSingleObject(hEvent,1000),CloseHandle(hEvent) 10 | return pObjShare?ObjShare(pObjShare):"" 11 | } 12 | static New(){ 13 | return super() 14 | } 15 | __Get(k,p){ 16 | global 17 | return %k% 18 | } 19 | __Set(k,p,v){ 20 | global 21 | return %k%:=v 22 | } 23 | PostCall(func,p*){ 24 | static postcall,params 25 | postcall:=func,params:=p 26 | SetTimer "PostCall",-1 27 | return 28 | PostCall: 29 | %postcall%(params*) 30 | return 31 | } 32 | Call(func,p*){ 33 | return %func%(p*) 34 | } 35 | FuncPtr(func){ 36 | return FindFunc(func) 37 | } 38 | LabelPtr(label){ 39 | return FindLabel(label) 40 | } 41 | Exec(code){ 42 | ahkExec(code) 43 | } 44 | AddScript(script, execute:=0){ 45 | return addScript(script, execute) 46 | } 47 | ExitApp(){ 48 | SetTimer ExitApp,-1 49 | Return 50 | ExitApp: 51 | ExitApp 52 | } 53 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToChar.ahk: -------------------------------------------------------------------------------- 1 | ToChar(num,buf:=0){ 2 | return NumGet(getvar(buf:=num+0),"Char") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToInt.ahk: -------------------------------------------------------------------------------- 1 | ToInt(num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"Int") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToShort.ahk: -------------------------------------------------------------------------------- 1 | ToShort(num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"Short") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToUChar.ahk: -------------------------------------------------------------------------------- 1 | ToUChar(num,buf:=0){ 2 | return NumGet(getvar(buf:=num+0),"UChar") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToUInt.ahk: -------------------------------------------------------------------------------- 1 | ToUInt(num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"UInt") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ToUShort.ahk: -------------------------------------------------------------------------------- 1 | ToUShort(num,buf:=0){ 2 | return num:=NumGet(getvar(buf:=num+0),"UShort") 3 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/URLDownloadToVar.ahk: -------------------------------------------------------------------------------- 1 | URLDownloadToVar(url) => (hObject:=ComObject("WinHttp.WinHttpRequest.5.1"),hObject.Option[2] := 65001,hObject.Open("GET",url),hObject.Send(),hObject.ResponseText) 2 | -------------------------------------------------------------------------------- /Compiler/v2/lib/WinGetPidList.ahk: -------------------------------------------------------------------------------- 1 | WinGetPidList(WinTitle:="",WinText:="",ExcludeTitle:="",ExcludeText:=""){ 2 | static p:=Buffer(40960),i:=0,EnumProcesses:=DynaCall(DllCall("GetProcAddress","PTR",DllCall("LoadLibrary","STR","psapi","PTR"),"AStr","EnumProcesses","PTR"),"tuiui",p.Ptr,40960,getvar(i)) 3 | local dhw,dht,ps:=[] 4 | EnumProcesses() 5 | ,IsObject(WinTitle) ? (dhw:=A_DetectHiddenWindows,DetectHiddenWindows(WinTitle[2]),WinTitle:=WinTitle[1]) : "" 6 | ,IsObject(WinText) ? (dht:=A_DetectHiddenText,DetectHiddenText(WinText[2]),WinText:=WinText[1]) : "" 7 | Loop i/4 8 | If WinExist(WinTitle " ahk_pid " pid:=NumGet(p,(A_Index-1)*4,"UInt"),WinText,ExcludeTitle,ExcludeText) 9 | ps.Push(pid) 10 | IsSet(dhw) ? DetectHiddenWindows(dhw) : "",IsSet(dht) ? DetectHiddenText(dht) : "" 11 | return ps 12 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/addScript.ahk: -------------------------------------------------------------------------------- 1 | addScript(Script,waitExecute:=0){ 2 | static _addScript:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"addScript"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","addScript","PTR"),"i==siui","",0,GetCurrentThreadId()) 3 | return _addScript(Script,waitExecute) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ahkExec.ahk: -------------------------------------------------------------------------------- 1 | ahkExec(Script){ 2 | static _ahkExec:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExec"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExec","PTR"),"i==sui","",GetCurrentThreadId()) 3 | return _ahkExec(Script) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ahkExecuteLine.ahk: -------------------------------------------------------------------------------- 1 | ahkExecuteline(pLine:=0,Mode:=0,Wait:=1){ 2 | static _ahkExecuteLine:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkExecuteLine"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkExecuteLine","PTR"),"t==tuiuiui",0,0,0,GetCurrentThreadId()) 3 | return _ahkExecuteLine(pLine,Mode,Wait) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/ahkLabel.ahk: -------------------------------------------------------------------------------- 1 | ahkLabel(label, DoNotWait:=0){ 2 | static _ahkLabel:=DynaCall(A_IsDll&&A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,"ahkLabel"):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr","ahkLabel","PTR"),"i==suiui","",0,GetCurrentThreadId()) 3 | return _ahkLabel(label,DoNotWait) 4 | } -------------------------------------------------------------------------------- /Compiler/v2/lib/between.ahk: -------------------------------------------------------------------------------- 1 | between(v,lh,hl){ 2 | return v>=(lhlh?hl:lh) 3 | } -------------------------------------------------------------------------------- /HASH: -------------------------------------------------------------------------------- 1 | MD5: 2 | 7-zip.chm: 8C0CCD78611091A9AFFD3C570932D6AA 3 | AutoHotkey.chm: 1835FE3FF20041068978827CFAAA14BE 4 | AutoHotkey_H.chm: BA88DB0BD205F3639C0211672BBC0B88 5 | Win32a\AutoHotkey.dll: 1618A112EC8A9C79817826D10870E0D3 6 | Win32a\AutoHotkey.exe: A4BD9A9235A11BE11843E28D5A45F8AA 7 | Win32a\AutoHotkeyMini.dll: 5AFCBBE38BB89FE4694BFE884E480464 8 | Win32a\AutoHotkeySC.bin: EC5E77BFE358310E126097600C8A56DC 9 | Win32a_MT\AutoHotkey.dll: 7CCC53B2372267C8B2574FE2AD7C302A 10 | Win32a_MT\AutoHotkey.exe: E0F494A7BC0D1E9427562967B7617C45 11 | Win32a_MT\AutoHotkeyMini.dll: 688EFAF6731E6A86FB2DA7512619ABEA 12 | Win32a_MT\AutoHotkeySC.bin: 68942C99AB836F234E42BA59D4436F24 13 | Win32w\AutoHotkey.dll: EFE4DFA9F4BEA8C41ACDDDF216CB5876 14 | Win32w\AutoHotkey.exe: AD4D3EAC2378D6FD2699D8C9CAD78D8B 15 | Win32w\AutoHotkeyMini.dll: D283740F01F26BB94D7F8A099BC7B256 16 | Win32w\AutoHotkeySC.bin: 42226E56FAC9371D994430F26B0551BE 17 | Win32w_MT\AutoHotkey.dll: B1DFCD66F3C642E44F612AFD37709288 18 | Win32w_MT\AutoHotkey.exe: 404F9592142BF48F40420D9CD8CC50CF 19 | Win32w_MT\AutoHotkeyMini.dll: 85866052075F5D4D68A4F004B0E68EB3 20 | Win32w_MT\AutoHotkeySC.bin: 6DBA4060B92D9D18AD685697DD25F569 21 | x64w\AutoHotkey.dll: D01266A3618E1E9ACF1AAB49BF17CE7D 22 | x64w\AutoHotkey.exe: A5222AF79837B9DE4E0306A06BA1DF41 23 | x64w\AutoHotkeyMini.dll: 942426F2A930D015FCE6BF5466559642 24 | x64w\AutoHotkeySC.bin: 3350A7D9CD5012EA4C76A4E4FC98B4AE 25 | x64w_MT\AutoHotkey.dll: 6DB09D2C898FED1052491635BB7E21AA 26 | x64w_MT\AutoHotkey.exe: 24DC1DC0A15F822B9BEBA565902FFADE 27 | x64w_MT\AutoHotkeyMini.dll: 008A0CB132CCC9D4C8E6D2192D9B8ECC 28 | x64w_MT\AutoHotkeySC.bin: BC2081529F30D624884557F387849681 29 | SHA: 30 | 7-zip.chm: B3DFCE90428ABA4B8A689993C668ABB4F3686B24 31 | AutoHotkey.chm: C0AE80E0A501550002A4640E6FB9D9689597F959 32 | AutoHotkey_H.chm: C5E32F7E46F5468A8189F05855FAEF8A90680D98 33 | Win32a\AutoHotkey.dll: B1A87888974093B972DC6FFA1723F725A16B1D55 34 | Win32a\AutoHotkey.exe: 46E757E380D8D3A56ECE704D8BB50C594D50F43E 35 | Win32a\AutoHotkeyMini.dll: 62A5050AEED09EAE014B889206E5227BE81CC32E 36 | Win32a\AutoHotkeySC.bin: E2E1B439C536EA099E59A048E3FAFE0F3922D34F 37 | Win32a_MT\AutoHotkey.dll: 20E636BE76352CA73A7FC36CBC7B1CD545B09013 38 | Win32a_MT\AutoHotkey.exe: 4EB06772CEF63BCC0349DB02DB949FD3E601EEFA 39 | Win32a_MT\AutoHotkeyMini.dll: BE0D10E5AAF8828330D7CB8B1293F21B6D44F657 40 | Win32a_MT\AutoHotkeySC.bin: C4C24F9B8140E366AF28BCEAB89DA991003CBA82 41 | Win32w\AutoHotkey.dll: 9307B69CE806B0865811E7AE43B3256FBDBC90F7 42 | Win32w\AutoHotkey.exe: 2534F045A61375ECF5885E884226B4596618FA9A 43 | Win32w\AutoHotkeyMini.dll: 85E3DB4289580EAC723DC6BF9B14425EF9625FC7 44 | Win32w\AutoHotkeySC.bin: A816F40FF29C7B5A67D4E83A481825CBB4343A31 45 | Win32w_MT\AutoHotkey.dll: 6879C7B0AF9F45C8B2006132164C197E9085D141 46 | Win32w_MT\AutoHotkey.exe: EC5D6FBAFECF4AF55C11F73134B8D9E1454CF4B6 47 | Win32w_MT\AutoHotkeyMini.dll: 6D11396FE3CBB7B4E4F6D42E5D32408987010752 48 | Win32w_MT\AutoHotkeySC.bin: DC45092E5414E6685987DBD38310083E6DFE343E 49 | x64w\AutoHotkey.dll: 716EF4413C44E664D83E50A05F63A03EE8A3B309 50 | x64w\AutoHotkey.exe: 0924A9DE45DB4373DC34DA84765973BC5383D909 51 | x64w\AutoHotkeyMini.dll: A41899269F9CC0C8B1B0890B7E505F5B5E68D2C8 52 | x64w\AutoHotkeySC.bin: 39444C3336765A37BE1B7FAA60421C9A3BF33124 53 | x64w_MT\AutoHotkey.dll: D423C64FB94207290CE16B34756D9B75D6C9741F 54 | x64w_MT\AutoHotkey.exe: C79B0F3DE7F9C57E821735A48A45440AC6710381 55 | x64w_MT\AutoHotkeyMini.dll: 9E9ED8452A2F93A688452E3FE1887CE14495BC46 56 | x64w_MT\AutoHotkeySC.bin: 413673D47720DDB506CF1E198D13F4E7543A25B1 57 | SHA256: 58 | 7-zip.chm: 610070593B804DC33D787E7B5695C523265D2ED82CCF7622205A85A02A6B3708 59 | AutoHotkey.chm: B5F681786BC783B0A42A2CB35DD7F0A56769A2D6C70F8C73156623AF5B508BC8 60 | AutoHotkey_H.chm: 95E7A308DDA2F6E1BBC9BF0D2573ABB4436BE6734E6D7135A82049679ECB184F 61 | Win32a\AutoHotkey.dll: E9253AF42A8088EDC9181621CAA6B99F25EC17F0E979A4E7DA2A5E0275B71093 62 | Win32a\AutoHotkey.exe: 15EC65F9499B1365C9AA4C0B686442A73280FCDB5D28F3EC88B5F4B9C4748525 63 | Win32a\AutoHotkeyMini.dll: 49551843F9009D48F2B2075CA6090B6D8731A2A9E1E5057F3418252074A24425 64 | Win32a\AutoHotkeySC.bin: D29F794A1B034EDD1254821A8909BC4D542EBFCF22E1356D4AD7DAF1F8D1DD9F 65 | Win32a_MT\AutoHotkey.dll: 34EEFE9418B1C6D2994987AFA553BA67491931E8D5570AA53A891562E7AC6344 66 | Win32a_MT\AutoHotkey.exe: F3714A9D02FAF45BF3F94ACB991D18F40DB65A3764425C9746712D7F0929BC04 67 | Win32a_MT\AutoHotkeyMini.dll: 672BAB4B197D5827C259FC2EFE08C4BD9005CD2F22C50C46F41350B851A1D261 68 | Win32a_MT\AutoHotkeySC.bin: 21F56816C4D93022CB2EE4583D4BB2B4E409894D9432C05C3F7185B68C9F353D 69 | Win32w\AutoHotkey.dll: F0B266BF3C635DC66B96B26983BCC36F8FD8BAD4D6AD80A1A32D155AF88D5F17 70 | Win32w\AutoHotkey.exe: 9518709EDBCEF1418D6E8E6CA01F80604B1DB090E9F9CEA38A2FE543186815DF 71 | Win32w\AutoHotkeyMini.dll: E9E7B1BAAA2A29B2FBD26DF8B6CD3CF34BDC6A9B79B82D5038D5CA0156DA7F55 72 | Win32w\AutoHotkeySC.bin: 78712D42767BADD3DD992E292B69A6F95DB8E1E9FA991F185C15D9430B341F5C 73 | Win32w_MT\AutoHotkey.dll: 9F74910C4EFDD9C83541817B8A5E3568F354E8F62C346AEE5333283D2715ABF2 74 | Win32w_MT\AutoHotkey.exe: 2C0435AB67ADDC310FB5ABD08FEEEDDC885D0A3441663E510A13088EA6F41A55 75 | Win32w_MT\AutoHotkeyMini.dll: 0E62E400830C916A596F9FB4BA80D59BC6523FBB3C33ABDB6D69ECA23EC41631 76 | Win32w_MT\AutoHotkeySC.bin: 7DC23E420F7314086C2FBAAE5E3DCD6B98948C03D3A2C137A53BAA2DCB62F891 77 | x64w\AutoHotkey.dll: 67D08D2F7994CD6A83E2A7264827191E0C6829DC4AEDCBE1A6048CDCEE707A1F 78 | x64w\AutoHotkey.exe: 894380C4AE6665185A7974EF0A15E237BFEE0D79B7C99B02D8DC00F8CC415B9D 79 | x64w\AutoHotkeyMini.dll: 159CE7FD74529E745BF13E3AAD17B25D0FD4A21CC4521673F27FC3FA76C9E0C1 80 | x64w\AutoHotkeySC.bin: F6551BCD5EC50D93F50A371F91049B12BB617814D86AB3BD02AE059A10F93D5B 81 | x64w_MT\AutoHotkey.dll: 8C57D1E6BCE51BE5A72437FC4D25DE4BFFC1534DAE85CEC0726227C6ED828E78 82 | x64w_MT\AutoHotkey.exe: EAEC638944D0CE8C3B4EC57F44F65283270ECF54D17CD3DABBE6879F07720F02 83 | x64w_MT\AutoHotkeyMini.dll: 96A54BC974D2B286F96E0B9455E8FC3B64680C5D2A78575EBAB18FCF620A5483 84 | x64w_MT\AutoHotkeySC.bin: D0AB7E5A7CE3FC810BA7F1B673D663153576E90817D2A0DFFBADFF1831EC42FC 85 | SHA512: 86 | 7-zip.chm: E4B7352F952851E3CE7244E124E1061D1289E8D76497D8A754FF9C849ADD16D3C496B1129C39016F757628E8DB5733F42839B06A865A710AE6795B91B1B1B154 87 | AutoHotkey.chm: 922E4E0CD6475F37F9D02EBF3DEA97D63D55F594A3911639126B5178C562308D97186B27153B7BFDC34C8059664785D2B49E3A93F030E7691166F7ED02352D30 88 | AutoHotkey_H.chm: 7D194EF04F09548CC3F962D30A7442520259A0E8EF0C24E20781D1E5A91BA5F67E802139647C5A38AADCCC242572FA15E0AE0A9008DD6D50973CA3C49F350364 89 | Win32a\AutoHotkey.dll: E697E1411CEE89B398222E64C927DCD2B07B90D2557CF1306D2DFB92BED5D60913054EEE5B5FB44CCDACD1FA93D76D04A0BE97B2D9364F25074D8D6FC1387330 90 | Win32a\AutoHotkey.exe: B763840F2932532AF682A32D43F5A61B16BBD4239EED19D22D1D994CA5C657E39461DA4FD8EC2A589835BD0E2DB1F499DEB58127E8A6B5DCD9AC3704297FA533 91 | Win32a\AutoHotkeyMini.dll: 5306A7A0D43F9F74C4274449DDD250905B3C9B3FF3B74FE4FCF8E1BF28A1526E531122E65B8397B87C779EEAFC37655A1F30E8BF2522560A9B622A1BABC4742F 92 | Win32a\AutoHotkeySC.bin: 63C3C6347B9A44FD1AD7BE8021788DA33A2149365FCCF06909C49606AA618C4375145D49756DFDC0969CFBA1E9925692FA708CE423A247FA77B2C55C6D9EF8D0 93 | Win32a_MT\AutoHotkey.dll: D9B15BAFEBCCCDB4D86106F0108819475EE294A05332DAFB260B616CEE05EE39596B3592D7F3FB6205A8A716D8652A4B7D837E8EBB11D253A462470C044B8F74 94 | Win32a_MT\AutoHotkey.exe: FDEBF582FA14F75B12F74FDA9710491E0AD6B54207A0AF9015B3175C47C63680EE8FD23AFF4805CF0C1240A2DD36A62E62D1467643E6936580261B60C5CBEC99 95 | Win32a_MT\AutoHotkeyMini.dll: DE9F9C9DB95EFEB4E5F9478D104CFA7C34F7E8E249C433EE440D2D67FC51F0C9B0014A1227E9EECDFC05F32C2BC9CAB91C0849F3C5ABB96DDE856B38A63DCA2E 96 | Win32a_MT\AutoHotkeySC.bin: 862D7D0AB50B46D379CD562E30894FCE5F33D54B5EF164C2BE384644683E62F9B43E0D4F0C972F87387451C85F80CB75CAB61698592806E80DD0F1D4CF2C3577 97 | Win32w\AutoHotkey.dll: A707C1EEFA4A09829CCC8698AD2F0BB9963B4D65499E2932E86A7EA205848622B860474E13E576AFBD99300C6355B7FA28938C73D231D9459EB845CDD991502D 98 | Win32w\AutoHotkey.exe: 614F1111CF8F37A50D3101C8A53B5BBA46F19BBF166A13438373B1E85B06CD626B5FDADD7E1A686048A261A9600EBB7EA59B4A4AE246316E490723525C57A127 99 | Win32w\AutoHotkeyMini.dll: 5DF31CC2DB1B8986A4CE733E9A5EF1AB0691CE433FF460BCF574219C073E6A57950FE52F0A452F12A08DE6847BAF3061221ACBBA14D245ED6C992CF8A68305A9 100 | Win32w\AutoHotkeySC.bin: 47229B022AAC5C79431E8C6B4EA2A0BFD484325A0EEBD933600DB304B2542FBB16BF1BCE3484A0486391532A150BDE1CA94159C581A9DA1FC4D90BBBA083B8D6 101 | Win32w_MT\AutoHotkey.dll: 317B93755CB50EFB5EC45EC9023BCE986319492B2C9521004871D9CE773A0F507D51AFEAD6F1565809E40B49964C6AC017E838DE3698077694EAFB1B23FCC25F 102 | Win32w_MT\AutoHotkey.exe: 0A46358B9D572ACCEFB28ED0672B82D18F5235FC9DC7F185B58FB20F348D76516C6887033ED6CE2601D379685AAFF1694557DF4B3E7298FBE8B6A20FA736AB32 103 | Win32w_MT\AutoHotkeyMini.dll: E6C12F791D2F36FDD871A022C79CF46C63EDCDC8ABAD7DB5B583D0E58CCC846D1DD254A6D3B5BE2BF6CDED71A609C0B0B55F90E3795EF23F06543B43F6A0C5F2 104 | Win32w_MT\AutoHotkeySC.bin: 1E6F11741677794301405EDAC46E81CC27D5F4C70BA7C0D1DAE6005DD3ADA17375ED829EF0F78D946685768454CBB0A5BD07387A57F71825B574D62A8DD106A7 105 | x64w\AutoHotkey.dll: B3B92D67E66432D323C4D67CB632D9760E47CFAADB1CB9A329255EFEB6E295017BA5437D591292AFB07F396BA08187378A6F19638B36A18DB39BB7D348033FA0 106 | x64w\AutoHotkey.exe: 97C99BF513B04627875A0F812C0526383E736BB022DE0E64B8904F10F9A57A3C0BA15ED738957A0D886123BC21546F53537C5F0C14F3587059E5668E1BBAF751 107 | x64w\AutoHotkeyMini.dll: E0B6D89013EC4698FE4DEF76DC34C30EDCDC007CC4F8B4B36DC43DE9AEB1A7E8A166B75585239A475AD3AB33FE562B7FFD2648A81250068E327884D7D27D8D76 108 | x64w\AutoHotkeySC.bin: AA3A4C0963F3F33AE439A5661AFC02B198931C67B6F9BE7E2BA1FDE59EBA76B3AA9380043427395FA3445300D8405D3DA430ACE6C9D8CF299F1949B27C190D0A 109 | x64w_MT\AutoHotkey.dll: B080808D046A5AEF342A8E8F9FBBFDB0564678E99697075D6B61604FFE2B9323C2163108092890FD9BF5F284A44B1F1D5999F5C4989431D61A5D2AE23AAD5E04 110 | x64w_MT\AutoHotkey.exe: 9B0221C4E58900AB69F56BFE72D7853DAA02E7CCA9C9F66454B6BBF63B0FF2207E11CB4754B57941D758E7A09C0BF7AB71182AB638E1E4B97EC2457EAB80689A 111 | x64w_MT\AutoHotkeyMini.dll: 2979BA31A2C3762D22C6463E331EB05398408BE7BA117E74E42937BC163877EA3578615026F80DFB72000BE977215E30A2AAF9B286EEFEBE0E0A99CBF53AB22A 112 | x64w_MT\AutoHotkeySC.bin: 01D76138284CAC0FC94ABC8026BFF35C10877719E68B10A693048359B090A2197339ECA3F71A92727A3712A077E58D36AA3EF91ADBE4C3A13EACB31E4A58D07E 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ahkdll-v1-release 2 | ================= 3 | 4 | ahkdll v1 release 5 | -------------------------------------------------------------------------------- /Win32a/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a/AutoHotkey.dll -------------------------------------------------------------------------------- /Win32a/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a/AutoHotkey.exe -------------------------------------------------------------------------------- /Win32a/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /Win32a/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a/AutoHotkeySC.bin -------------------------------------------------------------------------------- /Win32a/vcruntime140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a/vcruntime140.dll -------------------------------------------------------------------------------- /Win32a_MT/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a_MT/AutoHotkey.dll -------------------------------------------------------------------------------- /Win32a_MT/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a_MT/AutoHotkey.exe -------------------------------------------------------------------------------- /Win32a_MT/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a_MT/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /Win32a_MT/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32a_MT/AutoHotkeySC.bin -------------------------------------------------------------------------------- /Win32w/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w/AutoHotkey.dll -------------------------------------------------------------------------------- /Win32w/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w/AutoHotkey.exe -------------------------------------------------------------------------------- /Win32w/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /Win32w/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w/AutoHotkeySC.bin -------------------------------------------------------------------------------- /Win32w/vcruntime140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w/vcruntime140.dll -------------------------------------------------------------------------------- /Win32w_MT/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w_MT/AutoHotkey.dll -------------------------------------------------------------------------------- /Win32w_MT/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w_MT/AutoHotkey.exe -------------------------------------------------------------------------------- /Win32w_MT/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w_MT/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /Win32w_MT/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/Win32w_MT/AutoHotkeySC.bin -------------------------------------------------------------------------------- /lib/AhkSelf.ahk: -------------------------------------------------------------------------------- 1 | AhkSelf(){ 2 | static functions :=" 3 | (Join 4 | ahkFunction:s==stttttttttt|ahkPostFunction:i==stttttttttt| 5 | ahkdll:ut==sss|ahktextdll:ut==sss|ahkReady:|ahkReload:i| 6 | ahkTerminate:i=i|addFile:ut==sucuc|addScript:ut==si|ahkExec:ui==s| 7 | ahkassign:ui==ss|ahkExecuteLine:ut=utuiui|ahkFindFunc:ut==s| 8 | ahkFindLabel:ut==s|ahkgetvar:s==sui|ahkLabel:ui==sui|ahkPause:i=s|ahkIsUnicode: 9 | )" 10 | object:={} 11 | Loop,Parse,functions,| 12 | { 13 | v:=StrSplit(A_LoopField,":") 14 | If !FuncPTR:=A_MemoryModule?MemoryGetProcAddress(A_MemoryModule,v.1):DllCall("GetProcAddress","PTR",A_ModuleHandle,"AStr",v.1,"PTR") 15 | continue 16 | If v.1="ahkFunction"||v.1="ahkPostFunction" 17 | dynacall_:=DynaCall(FuncPTR,v.2,"",0,0,0,0,0,0,0,0,0,0) 18 | else 19 | dynacall_:=DynaCall(FuncPtr,v.2) 20 | object[v.1]:=dynacall_ 21 | } 22 | return object 23 | } -------------------------------------------------------------------------------- /lib/Attach.ahk: -------------------------------------------------------------------------------- 1 | /* 2 | Function: Attach 3 | Determines how a control is resized with its parent. 4 | 5 | hCtrl: 6 | - hWnd of the control if aDef is not empty. 7 | - hWnd of the parent to be reset if aDef is empty. If you omit this parameter function will use 8 | the first hWnd passed to it. 9 | With multiple parents you need to specify which one you want to reset. 10 | - Handler name, if parameter is string and aDef is empty. Handler will be called after the function has finished 11 | moving controls for the parent. Handler receives hWnd of the parent as its only argument. 12 | 13 | aDef: 14 | Attach definition string. Space separated list of attach options. If omitted, function working depends on hCtrl parameter. 15 | You can use following elements in the definition string: 16 | 17 | - "x,y,w,h" letters along with coefficients, decimal numbers which can also be specified in m/n form (see example below). 18 | - "r". Use "r1" (or "r") option to redraw control immediately after repositioning, set "r2" to delay redrawing 100ms for the control 19 | (prevents redrawing spam). 20 | - "p" (for "proportional") is the special coefficient. It will make control's dimension always stay in the same proportion to its parent 21 | (so, pin the control to the parent). Although you can mix pinned and non-pinned controls and dimensions that is rarely what you want. 22 | You will generally want to pin every control in the parent. 23 | - "+" or "-" enable or disable function for the control. If control is hidden, you may want to disable the function for 24 | performance reasons, especially if control is container attaching its children. Its perfectly OK to leave invisible controls 25 | attached, but if you have lots of them you can use this feature to get faster and more responsive updates. 26 | When you want to show disabled hidden control, make sure you first attach it back so it can take its correct position 27 | and size while in hidden state, then show it. "+" must be used alone while "-" can be used either alone or in Attach definition string 28 | to set up control as initially disabled. 29 | 30 | Remarks: 31 | Function monitors WM_SIZE message to detect parent changes. That means that it can be used with other eventual container controls 32 | and not only top level windows. 33 | 34 | You should reset the function when you programmatically change the position of the controls in the parent control. 35 | Depending on how you created your GUI, you might need to put "autosize" when showing it, otherwise resetting the Gui before its 36 | placement is changed will not work as intented. Autosize will make sure that WM_SIZE handler fires. Sometimes, however, WM_SIZE 37 | message isn't sent to the window. One example is for instance when some control requires Gui size to be set in advance in which case 38 | you would first have "Gui, Show, w100 h100 Hide" line prior to adding controls, and only Gui, Show after controls are added. This 39 | case will not trigger WM_SIZE message unless AutoSize is added. 40 | 41 | 42 | Examples: 43 | (start code) 44 | Attach(h, "w.5 h1/3 r2") ;Attach control's w, h and redraw it with delay. 45 | Attach(h, "-") ;Disable function for control h but keep its definition. To enable it latter use "+". 46 | Attach(h, "- w.5") ;Make attach definition for control but do not attach it until you call Attach(h, "+"). 47 | Attach() ;Reset first parent. Use when you have only 1 parent. 48 | Attach(hGui2) ;Reset Gui2. 49 | Attach("Win_Redraw") ;Use Win_Redraw function as a Handler. Attach will call it with parent's handle as argument. 50 | Attach(h, "p r2") ;Pin control with delayed refreshing. 51 | 52 | 53 | ; This is how to do delayed refresh of entire window. 54 | ; To prevent redraw spam which can be annoying in some cases, 55 | ; you can choose to redraw entire window only when user has finished resizing it. 56 | ; This is similar to r2 option for controls, except it works with entire parent. 57 | 58 | Attach("OnAttach") ;Set Handler to OnAttach function 59 | ... 60 | 61 | OnAttach( Hwnd ) { 62 | global hGuiToRedraw := hwnd 63 | SetTimer, Redraw, -100 64 | } 65 | 66 | Redraw: 67 | Win_Redraw(hGuiToRedraw) 68 | return 69 | (end code) 70 | Working sample: 71 | (start code) 72 | #SingleInstance, force 73 | Gui, +Resize 74 | Gui, Add, Edit, HWNDhe1 w150 h100 75 | Gui, Add, Picture, HWNDhe2 w100 x+5 h100, pic.bmp 76 | 77 | Gui, Add, Edit, HWNDhe3 w100 xm h100 78 | Gui, Add, Edit, HWNDhe4 w100 x+5 h100 79 | Gui, Add, Edit, HWNDhe5 w100 yp x+5 h100 80 | 81 | gosub SetAttach ;comment this line to disable Attach 82 | Gui, Show, autosize 83 | return 84 | 85 | SetAttach: 86 | Attach(he1, "w.5 h") 87 | Attach(he2, "x.5 w.5 h r") 88 | Attach(he3, "y w1/3") 89 | Attach(he4, "y x1/3 w1/3") 90 | Attach(he5, "y x2/3 w1/3") 91 | return 92 | (end code) 93 | 94 | About: 95 | o 1.1 by majkinetor 96 | o Licensed under BSD 97 | */ 98 | Attach(hCtrl="", aDef="") { 99 | Attach_(hCtrl, aDef, "", "") 100 | } 101 | 102 | Attach_(hCtrl, aDef, Msg, hParent){ 103 | static 104 | static Handler:="",adrWindowInfo:="",adrSetWindowPos:="" 105 | local s1,s2,f,k, enable:=0, reset:=0, oldCritical 106 | 107 | if (aDef = "") { ;Reset if integer, Handler if string 108 | if IsFunc(hCtrl) 109 | return Handler := hCtrl 110 | 111 | ifEqual, adrWindowInfo,, return ;Resetting prior to adding any control just returns. 112 | hParent := hCtrl != "" ? hCtrl+0 : hGui 113 | loop, parse, %hParent%a, %A_Space% 114 | { 115 | hCtrl := A_LoopField, SubStr(%hCtrl%,1,1), aDef := SubStr(%hCtrl%,1,1)="-" ? SubStr(%hCtrl%,2) : %hCtrl%, %hCtrl% := "" 116 | gosub Attach_GetPos 117 | loop, parse, aDef, %A_Space% 118 | { 119 | StringSplit, z, A_LoopField, : 120 | %hCtrl% .= A_LoopField="r" ? "r " : (z1 ":" z2 ":" c%z1% " ") 121 | } 122 | %hCtrl% := SubStr(%hCtrl%, 1, -1) 123 | } 124 | reset := 1, %hParent%_s := %hParent%_pw " " %hParent%_ph 125 | } 126 | 127 | if (hParent = "") { ;Initialize controls 128 | if !adrSetWindowPos 129 | adrSetWindowPos := DllCall("GetProcAddress", "ptr", DllCall("GetModuleHandle", "str", "user32"), A_IsUnicode ? "astr" : "str", "SetWindowPos","ptr") 130 | ,adrWindowInfo := DllCall("GetProcAddress", "ptr", DllCall("GetModuleHandle", "str", "user32"), A_IsUnicode ? "astr" : "str", "GetWindowInfo","ptr") 131 | ,OnMessage(5, A_ThisFunc), VarSetCapacity(B, 60), NumPut(60, B), adrB := &B 132 | ,hGui := DllCall("GetParent", "ptr", hCtrl, "ptr") 133 | 134 | hParent := DllCall("GetParent", "ptr", hCtrl, "ptr") 135 | 136 | if !%hParent%_s 137 | DllCall(adrWindowInfo, "ptr", hParent, "ptr", adrB), %hParent%_pw := NumGet(B, 28,"UInt") - NumGet(B, 20,"UInt"), %hParent%_ph := NumGet(B, 32,"UInt") - NumGet(B, 24,"UInt"), %hParent%_s := !%hParent%_pw || !%hParent%_ph ? "" : %hParent%_pw " " %hParent%_ph 138 | 139 | if InStr(" " aDef " ", "p") 140 | StringReplace, aDef, aDef, p, xp yp wp hp 141 | ifEqual, aDef, -, return SubStr(%hCtrl%,1,1) != "-" ? %hCtrl% := "-" %hCtrl% : 142 | else if (aDef = "+") 143 | if SubStr(%hCtrl%,1,1) != "-" 144 | return 145 | else %hCtrl% := SubStr(%hCtrl%, 2), enable := 1 146 | else { 147 | gosub Attach_GetPos 148 | %hCtrl% := "" 149 | loop, parse, aDef, %A_Space% 150 | { 151 | if (l := A_LoopField) = "-" { 152 | %hCtrl% := "-" %hCtrl% 153 | continue 154 | } 155 | f := SubStr(l,1,1), k := StrLen(l)=1 ? 1 : SubStr(l,2) 156 | if (j := InStr(l, "/")) 157 | k := SubStr(l, 2, j-2) / SubStr(l, j+1) 158 | %hCtrl% .= f ":" k ":" c%f% " " 159 | } 160 | return %hCtrl% := SubStr(%hCtrl%, 1, -1), %hParent%a .= InStr(%hParent%, hCtrl) ? "" : (%hParent%a = "" ? "" : " ") hCtrl 161 | } 162 | } 163 | ifEqual, %hParent%a,, return ;return if nothing to anchor. 164 | 165 | if !reset && !enable { 166 | %hParent%_pw := aDef & 0xFFFF, %hParent%_ph := aDef >> 16 167 | ifEqual, %hParent%_ph, 0, return ;when u create gui without any control, it will send message with height=0 and scramble the controls .... 168 | } 169 | 170 | if !%hParent%_s 171 | %hParent%_s := %hParent%_pw " " %hParent%_ph 172 | 173 | oldCritical := A_IsCritical 174 | critical, 5000 175 | 176 | StringSplit, s, %hParent%_s, %A_Space% 177 | loop, parse, %hParent%a, %A_Space% 178 | { 179 | hCtrl := A_LoopField, aDef := %hCtrl%, uw := uh := ux := uy := r := 0, hCtrl1 := SubStr(%hCtrl%,1,1) 180 | if (hCtrl1 = "-") 181 | ifEqual, reset,, continue 182 | else aDef := SubStr(aDef, 2) 183 | 184 | gosub Attach_GetPos 185 | loop, parse, aDef, %A_Space% 186 | { 187 | StringSplit, z, A_LoopField, : ; opt:coef:initial 188 | ifEqual, z1, r, SetEnv, r, %z2% 189 | if z2=p 190 | c%z1% := z3 * (z1="x" || z1="w" ? %hParent%_pw/s1 : %hParent%_ph/s2), u%z1% := true 191 | else c%z1% := z3 + z2*(z1="x" || z1="w" ? %hParent%_pw-s1 : %hParent%_ph-s2), u%z1% := true 192 | } 193 | flag := 4 | (r=1 ? 0x100 : 0) | (uw OR uh ? 0 : 1) | (ux OR uy ? 0 : 2) ; nozorder=4 nocopybits=0x100 SWP_NOSIZE=1 SWP_NOMOVE=2 194 | ;m(hParent, %hParent%a, hCtrl, %hCTRL%) 195 | DllCall(adrSetWindowPos, "ptr", hCtrl, "ptr", 0, "uint", cx, "uint", cy, "uint", cw, "uint", ch, "uint", flag) 196 | r+0=2 ? Attach_redrawDelayed(hCtrl) : 197 | } 198 | critical %oldCritical% 199 | return Handler != "" ? %Handler%(hParent) : "" 200 | 201 | Attach_GetPos: ;hParent & hCtrl must be set up at this point 202 | DllCall(adrWindowInfo, "ptr", hParent, "ptr", adrB), lx := NumGet(B, 20,"UInt"), ly := NumGet(B, 24,"UInt"), DllCall(adrWindowInfo, "ptr", hCtrl, "ptr", adrB) 203 | ,cx :=NumGet(B, 4,"UInt"), cy := NumGet(B, 8,"UInt"), cw := NumGet(B, 12,"UInt")-cx, ch := NumGet(B, 16,"UInt")-cy, cx-=lx, cy-=ly 204 | return 205 | } 206 | 207 | Attach_redrawDelayed(hCtrl){ 208 | static s 209 | s .= !InStr(s, hCtrl) ? hCtrl " " : "" 210 | SetTimer, %A_ThisFunc%, -100 211 | return 212 | Attach_redrawDelayed: 213 | loop, parse, s, %A_Space% 214 | WinSet, Redraw, , ahk_id %A_LoopField% 215 | s := "" 216 | return 217 | } 218 | -------------------------------------------------------------------------------- /lib/Clip2Object.ahk: -------------------------------------------------------------------------------- 1 | Class Clip2Object { 2 | __Set(key,ByRef raw){ 3 | static _AHKVar := "{Int64 ContentsInt64,Double ContentsDouble,PTR object},{char *mByteContents,LPTSTR CharContents},{UINT_PTR Length,_AHKVar *AliasFor},{UINT_PTR Capacity,UINT_PTR BIV},BYTE HowAllocated,BYTE Attrib,BYTE IsLocal,BYTE Type,LPTSTR Name" 4 | len:=this.SetCapacity(key,(var:=Struct(_AHKVar,getvar(raw))).AliasFor.Length) 5 | return len,DllCall("RtlMoveMemory","PTR",this.GetAddress(key),"PTR",var.AliasFor.mByteContents["",""],"PTR",var.AliasFor.Length) 6 | } 7 | 8 | Restore(key,ByRef raw){ 9 | static _AHKVar := "{Int64 ContentsInt64,Double ContentsDouble,PTR object},{char *mByteContents,LPTSTR CharContents},{UINT_PTR Length,_AHKVar *AliasFor},{UINT_PTR Capacity,UINT_PTR BIV},BYTE HowAllocated,BYTE Attrib,BYTE IsLocal,BYTE Type,LPTSTR Name" 10 | if IsByRef(raw) && VarSetCapacity(raw,len:=this.GetCapacity(key),0) 11 | return Struct(_AhkVar,Struct(_AhkVar,getvar(raw)).AliasFor["",""],{Attrib:1,Length:len}).Length 12 | ,DllCall("RtlMoveMemory","PTR",&raw,"PTR",this.GetAddress(key),"PTR",len) 13 | } 14 | } -------------------------------------------------------------------------------- /lib/CryptAES.ahk: -------------------------------------------------------------------------------- 1 | CryptAES(ByRef lp,sz,pw,e:=1,SID:=256){ 2 | static AES_128:=0x660E,AES_192:=1+AES_128,AES_256:=1+AES_192,SHA1:=1+0x8003 ; MD5 3 | If !DllCall("Advapi32\CryptAcquireContext","Ptr*",hP,"Uint",0,"Uint",0,"Uint",24,"UInt",0xF0000000) ;PROV_RSA_AES, CRYPT_VERIFYCONTEXT 4 | || !DllCall("Advapi32\CryptCreateHash","Ptr",hP,"Uint",SHA1,"Uint",0,"Uint",0,"Ptr*",H ) 5 | || !CryptHashData(H,&pw,StrLen(pw)*2,0) 6 | || !CryptDeriveKey(hP,AES_%SID%,H,SID<<16,getvar(hK:=0)) 7 | || !CryptDestroyHash(H) 8 | return 0 9 | if e 10 | CryptEncrypt(hK,0,1,0,&lp,getvar(sz),sz+16) 11 | else 12 | CryptDecrypt(hK,0,1,0,&lp,getvar(sz)) 13 | CryptDestroyKey(hK),CryptReleaseContext(hP,0) 14 | return sz 15 | } 16 | ;~ CryptAES(ByRef lp,sz,pw,e:=1,SID:=256){ 17 | ;~ static f:="advapi32\Crypt",t:="UPtr",t_:="UPtr*",AES_128:=0x660E,AES_192:=1+AES_128,AES_256:=1+AES_192,SHA1:=1+0x8003 ; MD5 18 | ;~ return e?VarSetCapacity(lp,sz+16):0,DllCall(f "AcquireContext",t_,hP,t,0,t,0,t,24,t,0xF0000000) ;PROV_RSA_AES, CRYPT_VERIFYCONTEXT 19 | ;~ ,DllCall(f "CreateHash",t,hP,t,SHA1,t,0,t,0,t_,H),DllCall(f "HashData",t,H,str,pw,t,StrLen(pw)*2,t,0) 20 | ;~ ,DllCall(f "DeriveKey",t,hP,t,AES_%SID%,t,H,t,SID<<16,t_,hK),DllCall(f "DestroyHash",t,H) 21 | ;~ ,e?DllCall(f "Encrypt",t,hK,t,0,t,1,t,0,t,&lp,t_,sz,t,sz+16):DllCall(f "Decrypt",t,hK,t,0,t,1,t,0,t,&lp,t_,sz) 22 | ;~ ,DllCall(f "DestroyKey",t,hK),DllCall(f "ReleaseContext",t,hP,t,0) 23 | ;~ ,sz 24 | ;~ } -------------------------------------------------------------------------------- /lib/FileGetVersionInfo.ahk: -------------------------------------------------------------------------------- 1 | ;MsgBox % FileGetVersionInfo_AW(A_AhkPath,"FileVersion") 2 | FileGetVersionInfo_AW( peFile="", StringFileInfo="", Delimiter="|") { ; Written by SKAN 3 | ; www.autohotkey.com/forum/viewtopic.php?p=233188#233188 CD:24-Nov-2008 / LM:27-Oct-2010 4 | Static CS, HexVal, Sps=" ", DLL="Version\", StrGet="StrGet" 5 | If ( CS = "" ) 6 | CS := A_IsUnicode ? "W" : "A", HexVal := "msvcrt\s" (A_IsUnicode ? "w": "" ) "printf" 7 | If ! FSz := DllCall( DLL "GetFileVersionInfoSize" CS , Str,peFile, UInt,0 ) 8 | Return "", DllCall( "SetLastError", UInt,1 ) 9 | VarSetCapacity( FVI, FSz, 0 ), VarSetCapacity( Trans,8 * ( A_IsUnicode ? 2 : 1 ) ) 10 | DllCall( DLL "GetFileVersionInfo" CS, Str,peFile, Int,0, UInt,FSz, UInt,&FVI ) 11 | If ! DllCall( DLL "VerQueryValue" CS 12 | , UInt,&FVI, Str,"\VarFileInfo\Translation", UIntP,Translation, UInt,0 ) 13 | Return "", DllCall( "SetLastError", UInt,2 ) 14 | If ! DllCall( HexVal, Str,Trans, Str,"%08X", UInt,NumGet(Translation+0) ) 15 | Return "", DllCall( "SetLastError", UInt,3 ) 16 | Loop, Parse, StringFileInfo, %Delimiter% 17 | { subBlock := "\StringFileInfo\" SubStr(Trans,-3) SubStr(Trans,1,4) "\" A_LoopField 18 | If ! DllCall( DLL "VerQueryValue" CS, UInt,&FVI, Str,SubBlock, UIntP,InfoPtr, UInt,0 ) 19 | Continue 20 | Value := ( A_IsUnicode ? %StrGet%( InfoPtr, DllCall( "lstrlen" CS, UInt,InfoPtr ) ) 21 | : DllCall( "MulDiv", UInt,InfoPtr, Int,1, Int,1, "Str" ) ) 22 | Info .= Value ? ( (InStr(Delimiter,StringFileInfo) ? SubStr( A_LoopField Sps,1,24 ) . A_Tab : "") . Value . Delimiter ) : 23 | } StringTrimRight, Info, Info, 1 24 | Return Info 25 | } -------------------------------------------------------------------------------- /lib/GetProcessWorkingDir.ahk: -------------------------------------------------------------------------------- 1 | ;~ Process, Exist, notepad.exe 2 | ;~ If !PID := ErrorLevel 3 | ;~ Run notepad.exe,,,PID 4 | ;~ MsgBox % GetProcessWorkingDir(PID) 5 | GetProcessWorkingDir(PID){ 6 | static PROCESS_ALL_ACCESS:=0x1F0FFF,MEM_COMMIT := 0x1000,MEM_RELEASE:=0x8000,PAGE_EXECUTE_READWRITE:=64 7 | ,GetCurrentDirectoryW,init:=MCode(GetCurrentDirectoryW,"8BFF558BECFF75088B450803C050FF15A810807CD1E85DC20800") 8 | nDirLength := VarSetCapacity(nDir, 512, 0) 9 | hProcess := DllCall("OpenProcess", "UInt", PROCESS_ALL_ACCESS, "Int",0, "UInt", PID) 10 | if !hProcess 11 | return 12 | pBufferRemote := DllCall("VirtualAllocEx", "Ptr", hProcess, "Ptr", 0, "PTR", nDirLength + 1, "UInt", MEM_COMMIT, "UInt", PAGE_EXECUTE_READWRITE, "Ptr") 13 | 14 | pThreadRemote := DllCall("VirtualAllocEx", "Ptr", hProcess, "Ptr", 0, "PTR", 26, "UInt", MEM_COMMIT, "UInt", PAGE_EXECUTE_READWRITE, "Ptr") 15 | DllCall("WriteProcessMemory", "Ptr", hProcess, "Ptr", pThreadRemote, "Ptr", &GetCurrentDirectoryW, "PTR", 26, "Ptr", 0) 16 | 17 | If hThread := DllCall("CreateRemoteThread", "PTR", hProcess, "UInt", 0, "UInt", 0, "PTR", pThreadRemote, "PTR", pBufferRemote, "UInt", 0, "UInt", 0) 18 | { 19 | DllCall("WaitForSingleObject", "PTR", hThread, "UInt", 0xFFFFFFFF) 20 | DllCall("GetExitCodeThread", "PTR", hThread, "UIntP", lpExitCode) 21 | If lpExitCode { 22 | DllCall("ReadProcessMemory", "PTR", hProcess, "PTR", pBufferRemote, "Str", nDir, "UInt", lpExitCode*2, "UInt", 0) 23 | VarSetCapacity(nDir,-1) 24 | } 25 | DllCall("CloseHandle", "PTR", hThread) 26 | } 27 | DllCall("VirtualFreeEx","PTR",hProcess,"PTR",pBufferRemote,"PTR",nDirLength + 1,"UInt",MEM_RELEASE) 28 | DllCall("VirtualFreeEx","PTR",hProcess,"PTR",pThreadRemote,"PTR",31,"UInt",MEM_RELEASE) 29 | DllCall("CloseHandle", "PTR", hProcess) 30 | 31 | return nDir 32 | } 33 | 34 | -------------------------------------------------------------------------------- /lib/GlobalVarsScript.ahk: -------------------------------------------------------------------------------- 1 | GlobalVarsScript(var="",size=102400,ByRef object=0){ 2 | global 3 | static globalVarsScript 4 | If (var="") 5 | Return globalVarsScript 6 | else if !size { 7 | If !InStr(globalVarsScript,var ":= CriticalObject(" CriticalObject(object,1) "," CriticalObject(object,2) ")`n"){ 8 | If !CriticalObject(object,1) 9 | object:=CriticalObject(object) 10 | globalVarsScript .= var ":= CriticalObject(" CriticalObject(object,1) "," CriticalObject(object,2) ")`n" 11 | } 12 | } else { 13 | Loop,Parse,Var,| 14 | If !InStr(globalVarsScript,"Alias(" A_LoopField "," GetVar(%A_LoopField%) ")`n"){ 15 | %A_LoopField%:="" 16 | If size 17 | VarSetCapacity(%A_LoopField%,size) 18 | globalVarsScript:=globalVarsScript . "Alias(" A_LoopField "," GetVar(%A_LoopField%) ")`n" 19 | } 20 | } 21 | Return globalVarsScript 22 | } -------------------------------------------------------------------------------- /lib/InjectAhkDll.ahk: -------------------------------------------------------------------------------- 1 | /* 2 | notepad := A_WinDir "\notepad.exe" 3 | if A_Is64bitOS && A_PtrSize = 4 4 | notepad := A_WinDir "\SysWOW64\notepad.exe" 5 | 6 | Run % notepad, , , PID 7 | WinWaitActive % "ahk_pid" PID 8 | 9 | Clipboard := "" 10 | rThread := InjectAhkDll(PID, A_AhkDir "\AutoHotkey.dll", "Clipboard := DllCall(""GetModuleHandle"", ""Ptr"", 0, ""Ptr"")") 11 | Sleep 500 12 | MsgBox % "ModuleHandle of Notepad Process: " Clipboard 13 | 14 | OnExit(Func("Close").Bind(PID)) 15 | ExitApp 16 | 17 | Close(PID) { 18 | Process Close, % PID 19 | } 20 | */ 21 | 22 | InjectAhkDll(PID, dll := "AutoHotkey.dll", script := 0) { 23 | static PROCESS_ALL_ACCESS := 0x1F0FFF, MEM_COMMIT := 0x1000, MEM_RELEASE := 0x8000, PAGE_EXECUTE_READWRITE := 64 24 | , hKernel32 := DllCall("LoadLibrary", "Str", "kernel32.dll", "Ptr") 25 | , LoadLibraryA := DllCall("GetProcAddress", "Ptr", hKernel32, "AStr", "LoadLibraryA", "Ptr") 26 | , FreeLibrary := DllCall("GetProcAddress", "Ptr", hKernel32, "AStr", "FreeLibrary", "Ptr") 27 | , Module32First := "Module32First" (A_IsUnicode ? "W" : "") 28 | , Module32Next := "Module32Next" (A_IsUnicode ? "W" : "") 29 | , base := {__Call: "InjectAhkDll", __Delete: "InjectAhkDll"} 30 | 31 | static TH32CS_SNAPMODULE := 0x00000008, INVALID_HANDLE_VALUE := -1 32 | , MAX_PATH := 260, MAX_MODULE_NAME32 := 255, ModuleName := "", init := VarSetCapacity(ModuleName, MAX_PATH * (A_IsUnicode ? 2 : 1)) 33 | , _MODULEENTRY32 := Format(" 34 | ( 35 | DWORD dwSize; 36 | DWORD th32ModuleID; 37 | DWORD th32ProcessID; 38 | DWORD GlblcntUsage; 39 | DWORD ProccntUsage; 40 | BYTE *modBaseAddr; 41 | DWORD modBaseSize; 42 | HMODULE hModule; 43 | TCHAR szModule[{1:}]; 44 | TCHAR szExePath[{2:}]; 45 | )", MAX_MODULE_NAME32 + 1, MAX_PATH) 46 | 47 | if IsObject(PID) 48 | { 49 | if (dll != "Exec" && script) 50 | return DllCall("MessageBox", "Ptr", 0, "Str", "Only Exec method can be used here!", "Str", "Error", "UInt", 0) 51 | 52 | hProc := DllCall("OpenProcess", "UInt", PROCESS_ALL_ACCESS, "Int", 0, "UInt", PID.PID, "Ptr") 53 | if !hProc 54 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not open process for PID: " PID.PID, "Str", "Error", "UInt", 0) 55 | 56 | if !script ; Free Library in remote process (object is being deleted) 57 | { 58 | ; Terminate the thread in ahkdll 59 | hThread := DllCall("CreateRemoteThread", "Ptr", hProc, "Ptr", 0, "Ptr", 0, "Ptr", PID.ahkTerminate, "Ptr", 0, "UInt", 0, "Ptr", 0,"Ptr") 60 | DllCall("WaitForSingleObject", "Ptr", hThread, "UInt", 0xFFFFFFFF) 61 | , DllCall("CloseHandle", "Ptr", hThread) 62 | 63 | ; Free library in remote process 64 | hThread := DllCall("CreateRemoteThread", "Ptr", hProc, "UInt", 0, "UInt", 0, "Ptr", FreeLibrary, "Ptr", PID.hModule, "UInt", 0, "UInt", 0, "Ptr") 65 | DllCall("WaitForSingleObject", "Ptr", hThread, "UInt", 0xFFFFFFFF) 66 | , DllCall("CloseHandle", "Ptr", hThread) 67 | , DllCall("CloseHandle", "Ptr", hProc) 68 | return 69 | } 70 | 71 | nScriptLength := VarSetCapacity(nScript, (StrLen(script) + 1) * (A_IsUnicode ? 2 : 1), 0) 72 | , StrPut(script, &nScript) 73 | 74 | ; Reserve memory in remote process where our script will be saved 75 | if !pBufferRemote := DllCall("VirtualAllocEx", "Ptr", hProc, "Ptr", 0, "Ptr", nScriptLength, "UInt", MEM_COMMIT, "UInt", PAGE_EXECUTE_READWRITE, "Ptr") 76 | return (DllCall("MessageBox", "Ptr", 0, "Str", "Could not reserve memory for process.", "Str", "Error", "UInt", 0) 77 | , DllCall("CloseHandle", "Ptr", hProc)) 78 | 79 | ; Write script to remote process memory 80 | DllCall("WriteProcessMemory", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", &nScript, "Ptr", nScriptLength, "Ptr", 0) 81 | 82 | ; Start execution of code 83 | hThread := DllCall("CreateRemoteThread", "Ptr", hProc, "Ptr", 0, "Ptr", 0, "Ptr", PID.ahkExec, "Ptr", pBufferRemote, "UInt", 0, "Ptr", 0,"Ptr") 84 | if !hThread 85 | { 86 | DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nScriptLength, "UInt", MEM_RELEASE) 87 | , DllCall("CloseHandle", "Ptr", hProc) 88 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not execute script in remote process.", "Str", "Error", "UInt", 0) 89 | } 90 | 91 | ; Wait for thread to finish 92 | DllCall("WaitForSingleObject", "Ptr", hThread, "UInt", 0xFFFFFFFF) 93 | 94 | ; Get Exit code returned by ahkExec (1 = script could be executed / 0 = script could not be executed) 95 | DllCall("GetExitCodeThread", "Ptr", hThread, "UInt*", lpExitCode) 96 | if !lpExitCode 97 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not execute script in remote process.", "Str", "Error", "UInt", 0) 98 | 99 | DllCall("CloseHandle", "Ptr", hThread) 100 | , DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nScriptLength, "UInt", MEM_RELEASE) 101 | , DllCall("CloseHandle", "Ptr", hProc) 102 | return 103 | } 104 | else if !hDll := DllCall("LoadLibrary", "Str", dll, "Ptr") 105 | return (DllCall("MessageBox", "Ptr", 0, "Str", "Could not find " dll " library.", "Str", "Error", "UInt", 0) 106 | , DllCall("CloseHandle", "Ptr", hProc)) 107 | else 108 | { 109 | hProc := DllCall("OpenProcess", "UInt", PROCESS_ALL_ACCESS, "Int", 0, "UInt", DllCall("GetCurrentProcessId"), "Ptr") 110 | DllCall("GetModuleFileName", "Ptr", hDll, "Ptr", &ModuleName, "UInt", MAX_PATH) 111 | DllCall("CloseHandle", "Ptr", hProc) 112 | } 113 | 114 | ; Open Process to PID 115 | hProc := DllCall("OpenProcess", "UInt", PROCESS_ALL_ACCESS, "Int", 0, "UInt", PID, "Ptr") 116 | if !hProc 117 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not open process for PID: " PID, "Str", "Error", "UInt", 0) 118 | 119 | ; Reserve some memory and write dll path (ANSI) 120 | nDirLength := VarSetCapacity(nDir, StrLen(dll) + 1, 0) 121 | , StrPut(dll, &nDir, "CP0") 122 | 123 | ; Reserve memory in remote process 124 | if !pBufferRemote := DllCall("VirtualAllocEx", "Ptr", hProc, "Ptr", 0, "Ptr", nDirLength, "UInt", MEM_COMMIT, "UInt", PAGE_EXECUTE_READWRITE, "Ptr") 125 | return (DllCall("MessageBox", "Ptr", 0, "Str", "Could not reserve memory for process.", "Str", "Error", "UInt", 0) 126 | , DllCall("CloseHandle", "Ptr", hProc)) 127 | 128 | ; Write dll path to remote process memory 129 | DllCall("WriteProcessMemory", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", &nDir, "Ptr", nDirLength, "Ptr", 0) 130 | 131 | ; Start new thread loading our dll 132 | hThread := DllCall("CreateRemoteThread", "Ptr", hProc, "Ptr", 0, "Ptr", 0, "Ptr", LoadLibraryA, "Ptr", pBufferRemote, "UInt", 0, "Ptr", 0, "Ptr") 133 | if !hThread 134 | { 135 | DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nDirLength, "UInt", MEM_RELEASE) 136 | , DllCall("CloseHandle", "Ptr", hProc) 137 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not load " dll " in remote process.", "Str", "Error", "UInt", 0) 138 | } 139 | 140 | ; Wait for thread to finish 141 | DllCall("WaitForSingleObject", "Ptr", hThread, "UInt", 0xFFFFFFFF) 142 | 143 | ; Get Exit code returned by thread (HMODULE for our dll) 144 | DllCall("GetExitCodeThread", "Ptr", hThread, "UInt*", hModule) 145 | 146 | ; Close Thread 147 | DllCall("CloseHandle", "Ptr", hThread) 148 | 149 | if (A_PtrSize = 8) ; use different method to retrieve base address because GetExitCodeThread returns DWORD only 150 | { 151 | hModule := 0, me32 := Struct(_MODULEENTRY32) 152 | 153 | ; Take a snapshot of all modules in the specified process. 154 | hModuleSnap := DllCall("CreateToolhelp32Snapshot", "UInt", TH32CS_SNAPMODULE, "UInt", PID, "Ptr") 155 | 156 | if (hModuleSnap != INVALID_HANDLE_VALUE) 157 | { 158 | ; reset hModule and set the size of the structure before using it. 159 | me32.dwSize := sizeof(_MODULEENTRY32) 160 | 161 | ; Retrieve information about the first module. Exit if unsuccessful 162 | if !DllCall(Module32First, "Ptr", hModuleSnap, "Ptr", me32[]) 163 | { 164 | ; Free memory used for passing dll path to remote thread 165 | DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nDirLength, "UInt", MEM_RELEASE) 166 | , DllCall("CloseHandle", "Ptr", hModuleSnap) ; Must clean up the snapshot object! 167 | return false 168 | } 169 | 170 | ; Now walk the module list of the process,and display information about each module 171 | while(A_Index = 1 || DllCall(Module32Next, "Ptr", hModuleSnap, "Ptr", me32[])) 172 | { 173 | if (StrGet(me32.szExePath[""]) = dll) 174 | { 175 | hModule := me32.modBaseAddr["",""] 176 | break 177 | } 178 | } 179 | 180 | DllCall("CloseHandle","Ptr",hModuleSnap) ; clean up 181 | } 182 | } 183 | 184 | hDll := DllCall("LoadLibrary", "Str", dll, "Ptr") 185 | 186 | ; Calculate pointer to ahkdll and ahkExec functions 187 | ahktextdll := hModule + DllCall("GetProcAddress", "Ptr", hDll, "AStr", "ahktextdll", "Ptr") - hDll 188 | ahkExec := hModule + DllCall("GetProcAddress", "Ptr", hDll, "AStr", "ahkExec", "Ptr") - hDll 189 | ahkTerminate := hModule + DllCall("GetProcAddress", "Ptr", hDll, "AStr", "ahkTerminate", "Ptr") - hDll 190 | 191 | 192 | if script 193 | { 194 | nScriptLength := VarSetCapacity(nScript, (StrLen(script) + 1) * (A_IsUnicode ? 2 : 1), 0) 195 | , StrPut(script, &nScript) 196 | 197 | ; Reserve memory in remote process where our script will be saved 198 | if !pBufferScript := DllCall("VirtualAllocEx", "Ptr", hProc, "Ptr", 0, "Ptr", nScriptLength, "UInt", MEM_COMMIT, "UInt", PAGE_EXECUTE_READWRITE, "Ptr") 199 | return (DllCall("MessageBox", "Ptr", 0, "Str", "Could not reserve memory for process.", "Str", "Error", "UInt", 0) 200 | , DllCall("CloseHandle", "Ptr", hProc)) 201 | 202 | ; Write script to remote process memory 203 | DllCall("WriteProcessMemory", "Ptr", hProc, "Ptr", pBufferScript, "Ptr", &nScript, "Ptr", nScriptLength, "Ptr", 0) 204 | 205 | } 206 | else 207 | pBufferScript := 0 208 | 209 | ; Run ahkdll function in remote thread 210 | hThread := DllCall("CreateRemoteThread", "Ptr", hProc, "Ptr", 0, "Ptr", 0, "Ptr", ahktextdll, "Ptr", pBufferScript, "Ptr", 0, "UInt", 0, "Ptr") 211 | if !hThread ; could not start ahkdll in remote process 212 | { 213 | ; Free memory used for passing dll path to remote thread 214 | DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nDirLength, "UInt", MEM_RELEASE) 215 | , DllCall("CloseHandle", "Ptr", hProc) 216 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not start ahkdll in remote process", "Str", "Error", "UInt", 0) 217 | } 218 | DllCall("WaitForSingleObject", "Ptr", hThread, "UInt", 0xFFFFFFFF) 219 | DllCall("GetExitCodeThread", "Ptr", hThread, "UInt*", lpExitCode) 220 | 221 | ; Release memory and handles 222 | DllCall("VirtualFreeEx", "Ptr", hProc, "Ptr", pBufferRemote, "Ptr", nDirLength, "UInt", MEM_RELEASE) 223 | , DllCall("CloseHandle", "Ptr", hThread) 224 | , DllCall("CloseHandle", "Ptr", hProc) 225 | 226 | if !lpExitCode ; thread could not be created. 227 | return DllCall("MessageBox", "Ptr", 0, "Str", "Could not create a thread in remote process", "Str", "Error", "UInt", 0) 228 | 229 | return {PID: PID, hModule: hModule, ahkExec: ahkExec, ahkTerminate: ahkTerminate, base: base} 230 | } 231 | -------------------------------------------------------------------------------- /lib/NumSize.ahk: -------------------------------------------------------------------------------- 1 | NumSize(v){ 2 | return InStr(v,".")||v>4294967295?8:v>65535?4:v>255?2:v>-129?1:v>-32769?2:v>-2147483649?4:8 3 | } -------------------------------------------------------------------------------- /lib/NumType.ahk: -------------------------------------------------------------------------------- 1 | NumType(v){ 2 | return InStr(v,".")?"Double":v>4294967295?"UInt64":v>65535?"UInt":v>255?"UShort":v>-1?"UChar":v>-129?"Char":v>-32769?"Short":v>-2147483649?"Int":"Int64" 3 | } -------------------------------------------------------------------------------- /lib/RapidHotkey.ahk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/lib/RapidHotkey.ahk -------------------------------------------------------------------------------- /lib/WinApiDef.ahk: -------------------------------------------------------------------------------- 1 | WinApiDef(def){ 2 | static buf,init:=UnZipRawMemory(LoadResource(handle:=GetModuleHandle(A_DllPath),res:=DllCall("FindResource","PTR",handle,"Str","C974C3B7677A402D93B047DA402587C7","PTR",10,"PTR")),SizeOfResource(handle,res),buf),list:=StrGet(&buf,"UTF-8") 3 | defpos:=InStr(list,"\" def)+1, dllpos:=InStr(list,A_Tab,1,defpos)+1 4 | If SubStr(list,defpos+StrLen(def),1)="," 5 | return SubStr(list,dllpos,InStr(list,"\",1,dllpos)-dllpos+1) SubStr(list,defpos,InStr(list,"\",1,defpos+1)-defpos) 6 | } -------------------------------------------------------------------------------- /lib/ZipFileRaw.ahk: -------------------------------------------------------------------------------- 1 | If 0 2 | FileInstall,LiteZip.dll,Used to compress resources 3 | ZipFileRaw(fileIn,fileOut,password:=""){ 4 | static lib:=A_IsCompiled?ResourceLoadLibrary("LiteZip.dll"):MemoryLoadLibrary("LiteZip.dll"), init:=lib?"":MessageBox(0,"Error: LiteZip.dll was not found","Error"), CreateBuffer:=DynaCall(MemoryGetProcAddress(lib,"ZipCreateBuffer"),"t*tuia") 5 | , AddZipBufferRaw:=DynaCall(MemoryGetProcAddress(lib,"ZipAddBufferRaw"),"ttui"),GetMemory:=DynaCall(MemoryGetProcAddress(lib,"ZipGetMemory"),"tt*ui*t*") 6 | , CloseZip:=DynaCall(MemoryGetProcAddress(lib,"ZipClose"),"t"),AddZipBuffer:=DynaCall(MemoryGetProcAddress(lib,"ZipAddBufferW"),"tstui") 7 | If InStr(fileOut,"?") = 1{ ; ? => fileIn is a HEX, e.g. ZipFileRaw("0AC688FF000000AB9F","?C:\Temp\MyFile.txt") 8 | fileOut:=SubStr(fileOut,2),VarSetCapacity(file,sz:=StrLen(fileIn)//2) 9 | Loop sz 10 | NumPut("0x" SubStr(fileIn,2*A_Index-1,2),file,A_Index-1,"Char") 11 | pData:=&file 12 | } else if InStr(fileOut,"|"){ ; Raw Data: "sizeof fileIn|filename", e.g. ZipFileRaw(&fileIn,"20354|C:\Temp\MyFile.zip") 13 | sz:=SubStr(fileOut,1,InStr(fileOut,"|")-1)+0 14 | ,fileOut:=SubStr(fileOut,InStr(fileOut,"|") + 1) 15 | ,pData:=fileIn 16 | } else { ; ZipFileRaw("C:\Temp\MyFile.txt","C:\Temp\MyFile.zip") 17 | FileGetSize,sz,% fileIn 18 | FileRead,file,*c %fileIn% 19 | pData:=&file 20 | } 21 | if !sz{ 22 | MsgBox Error FileIn %fileIn% 23 | return 24 | } 25 | CreateBuffer[hzip,0,sz*2,0] ; *2 to make sure we have enough room 26 | ,AddZipBufferRaw[hzip,pData,sz] , result:=GetMemory[hzip,buffer,len,base] 27 | if (len>=sz) 28 | len:=sz,DllCall("UnmapViewOfFile","PTR",buffer),DllCall("CloseHandle","PTR",base),buffer:=pData 29 | If FileExist(fileout) 30 | FileDelete % fileout 31 | handle := CreateFile(fileout,1073741824,0,0,2,128) ; GENERIC_WRITE,,,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL 32 | if (handle < 1) 33 | MsgBox Error Open File %fileout% 34 | else 35 | { 36 | if password { 37 | DllCall("crypt32\CryptBinaryToStringA","PTR",buffer,"UINT",len,"UInt",0x1,"PTR",0,"UInt*",encLen:=0) 38 | ,VarSetCapacity(buff,16 + encLen,0) 39 | ,DllCall("crypt32\CryptBinaryToStringA","PTR",buffer,"UINT",len,"UInt",0x1,"PTR",&buff,"UInt*",encLen) 40 | if (!encLen:=CryptAES(buff,encLen+1,password)){ ; encLen + 1 due to terminating character returned by first call to CryptBinaryToStringA 41 | MsgBox Error CryptAES 42 | return 43 | } 44 | pBuff:=&buff 45 | } else pBuff:=buffer,encLen:=0 46 | hdr:=Struct("UInt[5]",[0x4034b50,0,len,sz,encLen]) 47 | ,HashData(pBuff,encLen?encLen:len,hdr[] + 4,4) 48 | if !WriteFile(handle,hdr[],sizeof(hdr),getvar(written:=0)) 49 | MsgBox Error WriteFile 50 | if !WriteFile(handle,pBuff,encLen?encLen:len,getvar(written:=0)) 51 | MsgBox Error WriteFile 52 | DllCall("CloseHandle",PTR,handle) 53 | } 54 | if (buffer!=pData) 55 | DllCall("UnmapViewOfFile","PTR",buffer),DllCall("CloseHandle","PTR",base) 56 | return sizeof(hdr) + (encLen?encLen:len) 57 | } 58 | 59 | /* 60 | ZipFileRaw(fileIn,fileOut,pwd:=0){ 61 | static lib:=DllCall("LoadLibrary",Str,"LiteZip.dll"), CreateBuffer:=DynaCall("LiteZip\ZipCreateBuffer","t*tuis") 62 | , AddZipBufferRaw:=DynaCall("LiteZip\ZipAddBufferRaw","ttui"),GetMemory:=DynaCall("LiteZip\ZipGetMemory","tt*ui*t*") 63 | , CloseZip:=DynaCall("LiteZip\ZipClose","t") 64 | If InStr(fileIn,"|"){ 65 | fileIn:=SubStr(fileIn,2) 66 | VarSetCapacity(file,sz:=StrLen(fileIn)//2) 67 | Loop sz 68 | NumPut("0x" SubStr(fileIn,2*A_Index-1,2),file,A_Index-1,"Char") 69 | } else { 70 | FileGetSize,sz,%fileIn% 71 | FileRead,file,*c %fileIn% 72 | } 73 | if !sz{ 74 | MsgBox Error FileIn %fileIn% 75 | return 76 | } 77 | CreateBuffer[hzip,0,sz*2,pwd] ; *2 to make sure we have enough room 78 | AddZipBufferRaw[hzip,&file,sz] 79 | result:=GetMemory[hzip,buffer,len,base] 80 | handle := DllCall("CreateFile","Str",fileout,"UInt",1073741824,"UInt", 0,"PTR", 0,"UInt", 2,"UInt", 128,"PTR", 0) ; GENERIC_WRITE,,,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL 81 | if (handle < 1) 82 | MsgBox Error Open File %fileout% 83 | else 84 | { 85 | VarSetCapacity(hdr,16,0),NumPut(0x4034b50,hdr,"UInt"),NumPut(len,hdr,8,"UInt"),NumPut(sz,hdr,12,"UInt") 86 | DllCall( "shlwapi\HashData", PTR, buffer ; Read data pointer 87 | , UInt, len ; Read data size 88 | , PTR, &hdr + 4 ; Write data pointer 89 | , UInt, 4 ) ; Write data length in bytes 90 | if (!DllCall("WriteFile","PTR",handle,"PTR", &hdr,"UInt", 16,"UInt*", written,"PTR", 0)) 91 | MsgBox Error WriteFile 92 | if (!DllCall("WriteFile","PTR",handle,"PTR", buffer,"UInt", len,"UInt*", written,"PTR", 0)) 93 | MsgBox Error WriteFile 94 | DllCall("CloseHandle",PTR,handle) 95 | } 96 | DllCall("UnmapViewOfFile",PTR,buffer) 97 | DllCall("CloseHandle",PTR,base) 98 | return len 99 | 100 | } 101 | 102 | /* 103 | ZipFileRaw(fileIn,fileOut){ 104 | static lib:=DllCall("LoadLibrary",Str,"LiteZip.dll"),CreateBuffer:=DynaCall("LiteZip\ZipCreateBuffer","t*tuit") 105 | ,AddZipBufferRaw:=DynaCall("LiteZip\ZipAddBufferRaw","ttui"),GetMemory:=DynaCall("LiteZip\ZipGetMemory","tt*ui*t*") 106 | ,CloseZip:=DynaCall("LiteZip\ZipClose","t"),CloseHandle:=DynaCall("CloseHandle","t"),UnmapViewOfFile:=DynaCall("UnmapViewOfFile","t") 107 | ,WriteFile:=DynaCall("WriteFile","ttuiui*t"),HashData:=DynaCall("shlwapi\HashData","tuitui") 108 | ,hdr:=Struct("uint pkhdr,uint hash,uint comprs,uint uncomprs",{pkhdr:0x4034b50}) 109 | hdr.uncomprs:=sz:=FileGetSize(fileIn),file:=FileRead("*c " fileIn) 110 | MsgBox % sz 111 | CreateBuffer[hzip,0,1000000,0],AddZipBufferRaw[hzip,&file,sz],result:=GetMemory[hzip,buffer,len,base] 112 | if 1>handle:=DllCall("CreateFile",Str,fileout,UInt,1073741824,UInt,0,PTR,0,UInt,2,UInt,128,PTR,0,PTR) 113 | return 0 114 | else if hdr.comprs:=len&&!HashData[buffer,len,hdr.hash[""],4] 115 | if !WriteFile[handle,hdr[],16,written,0]||!WriteFile[handle,buffer,len,written,0] 116 | return CloseHandle[handle],0 117 | else CloseHandle[handle] 118 | return UnmapViewOfFile[buffer],CloseHandle[base],len 119 | } -------------------------------------------------------------------------------- /lib/_Input.ahk: -------------------------------------------------------------------------------- 1 | /*! 2 | Library: _Input Class 3 | _Input class is a combination of Hotkey and Hotstrings with advanced features. It serves an advanced, easy to use and invisible interface for user / application communication. Using _Input it is very simple to keep your code very tidy and clear and very easy to maintain. 4 | Author: HotKeyIt 5 | License: http://www.autohotkey.com/forum/viewtopic.php?t=65671 6 | */ 7 | 8 | 9 | /*! 10 | Class: _Input 11 | _Input class is a combination of Hotkey and Hotstrings with advanced features 12 | It serves an advanced, easy to use and invisible interface for user / application communication 13 | Using _Input it is very simple to keep your code very tidy and clear and very easy to maintain 14 | Inherits: No 15 | Example: @file:_Input_Example.ahk 16 | */ 17 | 18 | 19 | 20 | 21 | Class _Input { 22 | Options := "" 23 | EndKeys := "" 24 | MatchList := "" 25 | Parameters := [] 26 | Function := [] 27 | WatchInput := "" 28 | /*! 29 | Constructor: (EndKeys[,WatchInput,Options,MatchList]) 30 | Creates an _Input class. 31 | Parameters: 32 | EndKeys - This Must be an Object containing {Keys:["Function",ParameterKey1,ParameterKey2,[ManyParams1Key1,ManyParams2Key1,...],...]} or {Keys:"Function"}. 33 | * Keys is a RegEx needle that will be searched in all available EndKeys 34 | * Function is the name of the function to call when key was hit 35 | * ParameterKey1... = parameter to pass to function (will be last parameter in function) 36 | * - ParameterKey can be an array that will expand to parameters !!! 37 | !!! NOTE !!! 38 | > ; WHEN USING | SEPARATOR IN ENDKEYS, KEYS MUST BE GIVEN IN ALPHABETICAL ORDER !!! 39 | > MyInput := new _Input({"Enter|Tab":["Enter_Function","Enter","Tab"]}) 40 | > ; FOLLOWING WOULD PRODUCE WRONG PARAMETERS BECAUSE KEYS ARE PROCESSED ALPHABETICALLY SO FIRST ENTER THAN TAB 41 | > MyInput := new _Input({"Tab|Enter":["Input_Enter","Tab","Enter"]}) 42 | * Simple keys can have the value in second param 43 | > ; For example 44 | > MyInput := new _Input({Enter:["Input_Enter","User Pressed Enter"]}) 45 | * NOTE AGAIN WHEN SPECIFYING SEVERAL ENDKEYS LIKE TAB|UP|DOWN THEY HAVE TO BE IN ALPHABETICAL ORDER TO MATCH PARAMETERS SO DOWN|TAB|UP 46 | > ; For example "F.*" would match F1 - F24 and "Numpad" would match all NumPad keys 47 | > ; So pressing F6 causes following call: Pressed_F(InputVar,CtrlDown,AltDown,ShiftDown,6) 48 | > MyInput := new _Input({"F.":["Pressed_F",1,2,3,4,5,6,7,8,9]}) 49 | > 50 | > ; Here pressing F6 causes following call: Pressed_F(InputVar,CtrlDown,AltDown,ShiftDown,1,2,3) 51 | > MyInput := new _Input({"F.":["Pressed_F",1,2,3,4,5,[1,2,3],7,8,9]}) 52 | * Function: 53 | * User function needs to have at least 4 parameters when no parameters were specified 54 | > Input_Enter(ByRef Input,c,a,s){ ; C=CTRL, A=ALT, S=SHIFT 55 | > } 56 | * Otherwise 4 + as many as parameters for given key 57 | > Input_Enter(ByRef Input,c,a,s,e){ ; C=CTRL, A=ALT, S=SHIFT, E = Errorlevel parameter 58 | > } 59 | WatchInput - Name of a function that will be called using a timer and allows to see users input instantly. 60 | > ; For example 61 | > WatchingInput(ByRef Input){ 62 | > ToolTip % Input 63 | > } 64 | Options - see Input command (default set to MIA (accept modifiers/Ignore ahk input/append variable content (A -> only available in AHK_H) 65 | MatchList - see Input command 66 | Example: 67 | > #include <_Input> ; Requred due to _Input Class 68 | > Input := new _Input({"Enter|Tab":["Input_Execute","User pressed Enter","User pressed Tab"] ; Input_Execute will be called when pressed Enter or Tab 69 | > ,Delete:"Input_Delete",Escape:"Input_Exit"} ; Input_Delete will be called when pressed Delete 70 | > ,"Input_Watcher") ; Input_Watcher will be called constantly while Input in progress 71 | > MsgBox % Input.Input() ; Watch Input and show input when finished 72 | > ExitApp 73 | > 74 | > Input_Watcher(ByRef Input){ ; Function will be launched constantly 75 | > ToolTip % Input 76 | > } 77 | > Input_Execute(ByRef Input,c,a,s,e){ 78 | > MsgBox % e "`nUser Input: " Input ; E contains the parameter we supplied above 79 | > } 80 | > Input_Delete(ByRef Input,c,a,s){ 81 | > Input:="" ; Input is ByRef so we can modify it 82 | > } 83 | > Input_Exit(ByRef Input,c,a,s){ 84 | > Return 1 ; Notifies Input Method to finish Input 85 | > } 86 | Returns: 87 | Input object that can be used to grab user or artficial input 88 | */ 89 | __New(EndKeys,WatchInput="",Options="MIA",MatchList=""){ 90 | static _EndKeys:=" AppsKey Backspace Break Browser_Back Browser_Favorites Browser_Forward Browser_Home Browser_Refresh Browser_Search Browser_Stop CapsLock CtrlBreak Delete Down End Enter Escape F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 Help Home Insert LAlt Launch_App1 Launch_App2 Launch_Mail Launch_Media LControl Left LShift LWin Media_Next Media_Play_Pause Media_Prev Media_Stop NumLock Numpad0 Numpad1 Numpad2 Numpad3 Numpad4 Numpad5 Numpad6 Numpad7 Numpad8 Numpad9 NumpadAdd NumpadAdd NumpadClear NumpadDel NumpadDiv NumpadDiv NumpadDot NumpadDown NumpadEnd NumpadEnter NumpadEnter NumpadHome NumpadIns NumpadLeft NumpadMult NumpadMult NumpadPgDn NumpadPgUp NumpadRight NumpadSub NumpadSub NumpadUp Pause PgDn PgUp PrintScreen RAlt RControl Right RShift RWin ScrollLock Sleep Space Tab Up Volume_Down Volume_Mute Volume_Up ^ ° ! "" § $ `% & / ( ) = ? `` ´ * + ~ ' # < > | , . `; : - _ { } [ ] 0 1 2 3 4 5 6 7 8 9 " 91 | this.WatchInput := WatchInput 92 | this.Options := Options 93 | this.MatchList := MatchList 94 | for EndKey,Function in EndKeys 95 | { 96 | If RegExMatch(" Max TimeOut Match ","i)\s(" EndKey ")\s") ; ErrorLevel is not an EndKey: , go different route 97 | { 98 | idx:=1 ; init function parameter index to 0 99 | Loop,Parse,EndKey,| ; in case we have several Errorlevel entries, e.g. Max|Timeout|Match (will launch same function) 100 | { 101 | this.Parameters[A_LoopField]:=[] ; create an array object for parameters 102 | idx++ ; increase index by one, will be set to 1 on first run 103 | If IsObject(Function){ ; parameter is an array object containing function and parameters for function 104 | thisFunction[A_LoopField]:=Function.1 ; function name 105 | this.Parameters[A_LoopField].Insert(Function[idx]) ; function parameters 106 | } else this.Function[A_LoopField]:=Function ; no object was given, so it is a function name only 107 | } 108 | } else { ; ErrorLevel is EndKey: 109 | ; Replace Ctrl to Control and Control+Alt+Shift+Win to LAlt|RAlt.... 110 | EndKey:=RegExReplace(RegExReplace(EndKey,"i)([LR])?Ctrl","$1Control"),"i)(Alt|Control|Shift|Win)","L$1$2|R$1$2") 111 | idx:=1 ; init function parameter index to 0 112 | Loop,Parse,_EndKeys,%A_Space% ; check all available Keys for match in our pattern 113 | { 114 | If (RegExMatch(A_LoopField,"i)^(" EndKey ")$")){ 115 | this.EndKeys .= "{" A_LoopField "}" ; add EndKey to list of EndKeys 116 | this.Parameters["EndKey:" A_LoopField]:=[] ; create an array object for parameters 117 | idx++ ; increase index by one, will be set to 1 on first run 118 | If IsObject(Function){ ; parameter is an array object containing function and parameters for function 119 | this.Function["EndKey:" A_LoopField]:=Function.1 ; function name 120 | this.Parameters["EndKey:" A_LoopField].Insert(Function[idx]) ; function parameters 121 | } else this.Function["EndKey:" A_LoopField]:=Function ; no object was given, so it is a function name only 122 | } 123 | } 124 | } 125 | } 126 | } 127 | 128 | /*! 129 | Method: Input([ByRef InputVar,Timer,Options,MatchList]) 130 | Starts Watching Input 131 | Parameters: 132 | InputVar - ByRef parameter that will be passed to the watching function and key functions 133 | Timer - Determines how often in ms the function WatchInput will be called, default is 50 ms 134 | Options - Use different Options 135 | MatchList - Use different MatchList 136 | AlwaysNotify - Watching Function will be called even if input variable did not change 137 | Returns: Entered (final) input 138 | */ 139 | Input(ByRef Input="",Timer=25,Options="",MatchList="",AlwaysNotify=0){ 140 | If IsFunc(Function:=this.WatchInput) ; check if we have a valid function for watching input 141 | SetTimer,_Input,% Timer ; set timer to run watching function 142 | else Function:="" 143 | FuncObj:=this.Function 144 | Loop { ; repeat command until ErrorLevel=NewInput or a function returns true (1) 145 | Input,Input,% Options!=""?Options:this.Options,% this.EndKeys,% MatchList!=""?MatchList:this.MatchList ; pass parameters created previously 146 | If Function 147 | SetTimer,_Input,Off ; disable watching function while processing input and in case we break 148 | If (ErrorLevel="NewInput" ; NewInput or a function that returns true will break the Loop 149 | || FuncObj[ErrorLevel](Input,GetKeyState("Ctrl","P"),GetKeyState("Alt","P"),GetKeyState("Shift","P"),this.Parameters[ErrorLevel]*)) 150 | break 151 | If Function 152 | SetTimer,_Input,% Timer ; enable watching function again 153 | } 154 | Return Input ; return entered input 155 | 156 | _Input: ; Private label only accessible to Input method 157 | If (!AlwaysNotify && Previous=Input) 158 | return 159 | Function.(Input) ; launch watching function 160 | If !AlwaysNotify 161 | Previous:=Input 162 | Return 163 | } 164 | /*! 165 | End of class 166 | */ 167 | } -------------------------------------------------------------------------------- /x64w/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w/AutoHotkey.dll -------------------------------------------------------------------------------- /x64w/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w/AutoHotkey.exe -------------------------------------------------------------------------------- /x64w/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /x64w/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w/AutoHotkeySC.bin -------------------------------------------------------------------------------- /x64w/vcruntime140.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w/vcruntime140.dll -------------------------------------------------------------------------------- /x64w_MT/AutoHotkey.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w_MT/AutoHotkey.dll -------------------------------------------------------------------------------- /x64w_MT/AutoHotkey.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w_MT/AutoHotkey.exe -------------------------------------------------------------------------------- /x64w_MT/AutoHotkeyMini.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w_MT/AutoHotkeyMini.dll -------------------------------------------------------------------------------- /x64w_MT/AutoHotkeySC.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HotKeyIt/ahkdll-v1-release/67c4e24ef7aee3bd55855ff45c884a88f10de2d2/x64w_MT/AutoHotkeySC.bin --------------------------------------------------------------------------------