Skip to content

Commit

Permalink
Fix compiling Ahk2Exe itself and more
Browse files Browse the repository at this point in the history
  • Loading branch information
HotKeyIt committed Feb 14, 2015
1 parent 94d1b34 commit d355d9e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
8 changes: 5 additions & 3 deletions Ahk2Exe.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,11 @@ hRSrc := DllCall("FindResource", "PTR", 0,"STR", "LOGO.PNG", "PTR", 10)
sData := SizeofResource(0, hRSrc)
hRes := LoadResource(0, hRSrc)
pData := LockResource(hRes)
If NumGet(pData+0,0,"UInt")=0x04034b50
sData:=UnZipRawMemory(pData,resLogo),pData:=&resLogo
hGlob := GlobalAlloc(2, sData) ; 2=GMEM_MOVEABLE
pGlob := GlobalLock(hGlob)
#DllImport,memcpy,msvcrt\memcpy,ptr,,ptr,,uint,,CDecl
#DllImport,memcpy,msvcrt\memcpy,ptr,,ptr,,ptr,,CDecl
memcpy(pGlob, pData, sData)
GlobalUnlock(hGlob)
CreateStreamOnHGlobal(hGlob, 1, getvar(pStream:=0))
Expand Down Expand Up @@ -376,15 +378,15 @@ ConvertCLI:
If UseEncrypt && !UsePassword
{
if !CLIMode
MsgBox, 64, Ahk2Exe, Conversion complete.
MsgBox, 64, Ahk2Exe, Error compiling`, no password supplied: %ExeFile%
else
FileAppend, Error compiling`, no password supplied: %ExeFile%`n, *
return
}
else If (UseEncrypt && SubStr(BinFile,-3)!=".bin")
{
if !CLIMode
MsgBox, 64, Ahk2Exe, Resulting exe will not be protected properly, use .bin file to have more secure protection.
MsgBox, 64, Ahk2Exe, Resulting exe will not be protected properly, use AutoHotkeySC.bin file to have more secure protection.
else
FileAppend, Warning`, Resulting exe will not be protected properly`, use AutoHotkeySC.bin file to have more secure protection.: %ExeFile%`n, *
}
Expand Down
2 changes: 1 addition & 1 deletion Compiler.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ BundleAhkScript(ExeFile, AhkFile, IcoFile := "", UseCompression := 0, UsePasswor
if !DllCall("UpdateResource", "ptr", module, "ptr", 10, "str", resname
, "ushort", 0x409, "ptr", &filedata, "uint", filesize, "uint")
goto _FailEnd2
VarSetCapacity(filedata, 0)
}
VarSetCapacity(filedata, 0)

gosub _EndUpdateResource

Expand Down
3 changes: 1 addition & 2 deletions IconChanger.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EnumIcons(ExeFile, iconID)
return

_EI_HighestIconID := 0
if EnumResourceNames(hModule, 3, pEnumFunc) = 0
if DllCall("EnumResourceNames","PTR",hModule,"PTR",3,"PTR", pEnumFunc) = 0
{
FreeLibrary(hModule)
return
Expand All @@ -78,7 +78,6 @@ EnumIcons(ExeFile, iconID)

wCount := NumGet(pDirHeader+4, "UShort")
,iconIDs := []

Loop, %wCount%
{
pResDirEntry := pResDir + (A_Index-1)*14
Expand Down
8 changes: 5 additions & 3 deletions Lib/ZipFileRaw.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
If 0
FileInstall,LiteZip.dll,Used to compress resources
ZipFileRaw(fileIn,fileOut,password:=""){
static l:="LiteZip\Zip",lib:=LoadLibrary("LiteZip.dll"), init:=lib?"":MessageBox(0,"Error: LiteZip.dll was not found","Error"), CreateBuffer:=DynaCall(l "CreateBuffer","t*tuia")
, AddZipBufferRaw:=DynaCall(l "AddBufferRaw","ttui"),GetMemory:=DynaCall(l "GetMemory","tt*ui*t*")
, CloseZip:=DynaCall(l "Close","t"),AddZipBuffer:=DynaCall(l "AddBufferW","tstui")
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")
, AddZipBufferRaw:=DynaCall(MemoryGetProcAddress(lib,"ZipAddBufferRaw"),"ttui"),GetMemory:=DynaCall(MemoryGetProcAddress(lib,"ZipGetMemory"),"tt*ui*t*")
, CloseZip:=DynaCall(MemoryGetProcAddress(lib,"ZipClose"),"t"),AddZipBuffer:=DynaCall(MemoryGetProcAddress(lib,"ZipAddBufferW"),"tstui")
If InStr(fileOut,"?") = 1{ ; ? => fileIn is a HEX, e.g. ZipFileRaw("0AC688FF000000AB9F","?C:\Temp\MyFile.txt")
fileOut:=SubStr(fileOut,2),VarSetCapacity(file,sz:=StrLen(fileIn)//2)
Loop sz
Expand Down
14 changes: 8 additions & 6 deletions ScriptParser.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ PreprocessScript(ByRef ScriptText, AhkScript, ExtraFiles, FileList := "", FirstS
if !StrStartsWith(tline, "@Ahk2Exe-")
continue
tline := SubStr(tline, 10)
if tline = "IgnoreBegin"
if (tline = "IgnoreBegin")
ignoreSection := true
else if tline != ""
else if (tline != "")
Options.directives.Insert(tline)
continue
}
else if tline = ""
else if (tline = "")
continue
else if StrStartsWith(tline, "/*")
{
Expand Down Expand Up @@ -108,9 +108,9 @@ PreprocessScript(ByRef ScriptText, AhkScript, ExtraFiles, FileList := "", FirstS
FileList.Insert(IncludeFile)
PreprocessScript(ScriptText, IncludeFile, ExtraFiles, FileList, FirstScriptDir, Options, IgnoreErrors)
}
}else if !contSection && tline ~= "i)^FileInstall[, \t]"
}else if (!contSection && tline ~= "i)^FileInstall[, \t]")
{
if tline ~= "^\w+\s+(:=|+=|-=|\*=|/=|//=|\.=|\|=|&=|\^=|>>=|<<=)"
if (tline ~= "^\w+\s+(:=|\+=|-=|\*=|/=|//=|\.=|\|=|&=|\^=|>>=|<<=)")
continue ; This is an assignment!
if !RegExMatch(tline, "i)^FileInstall[ \t]*[, \t][ \t]*([^,]+?)[ \t]*(,|$)", o) || o1 ~= "[^``]%" ; TODO: implement `, detection
Util_Error("Error: Invalid ""FileInstall"" syntax found. Note that the first parameter must not be specified using a continuation section.")
Expand Down Expand Up @@ -139,13 +139,15 @@ PreprocessScript(ByRef ScriptText, AhkScript, ExtraFiles, FileList := "", FirstS
SB_SetText("Auto-including any functions called from a library...")
ilibfile := A_Temp "\_ilib.ahk"
FileDelete, %ilibfile%
FileDelete, %ilibfile%.script
static AhkPath := A_IsCompiled ? A_ScriptDir "\..\AutoHotkey.exe" : A_AhkPath
AhkType := AHKType(AhkPath)
if AhkType = FAIL
Util_Error("Error: The AutoHotkey build used for auto-inclusion of library functions is not recognized.", 1, AhkPath)
if AhkType = Legacy
Util_Error("Error: Legacy AutoHotkey versions (prior to v1.1) are not allowed as the build used for auto-inclusion of library functions.", 1, AhkPath)
RunWait, "%AhkPath%" /iLib "%ilibfile%" /ErrorStdOut "%AhkScript%", %FirstScriptDir%, UseErrorLevel
FileAppend,%ScriptText%,%ilibfile%.script
RunWait, "%AhkPath%" /iLib "%ilibfile%" /ErrorStdOut "%ilibfile%.script", %FirstScriptDir%, UseErrorLevel
if (ErrorLevel = 2)
Util_Error("Error: The script contains syntax errors.")
If FileExist(ilibfile)
Expand Down

0 comments on commit d355d9e

Please sign in to comment.