Permalink
Browse files

Fix compiling Ahk2Exe itself and more

  • Loading branch information...
HotKeyIt committed Feb 14, 2015
1 parent 94d1b34 commit d355d9ea5481dc52ac4bee5a751d47f9a6fe76a5
Showing with 20 additions and 15 deletions.
  1. +5 −3 Ahk2Exe.ahk
  2. +1 −1 Compiler.ahk
  3. +1 −2 IconChanger.ahk
  4. +5 −3 Lib/ZipFileRaw.ahk
  5. +8 −6 ScriptParser.ahk
View
@@ -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))
@@ -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, *
}
View
@@ -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
View
@@ -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
@@ -78,7 +78,6 @@ EnumIcons(ExeFile, iconID)
wCount := NumGet(pDirHeader+4, "UShort")
,iconIDs := []
Loop, %wCount%
{
pResDirEntry := pResDir + (A_Index-1)*14
View
@@ -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
View
@@ -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, "/*")
{
@@ -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.")
@@ -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)

0 comments on commit d355d9e

Please sign in to comment.