Bugs and flaws or stupid me?

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
User avatar
Posts: 459
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania

Bugs and flaws or stupid me?

22 Feb 2018, 08:33

Talking about AHK_H v1.1.28.00-H002 (Unicode). Tests were performed on Windows 7 Ultimate 32bit.

First, ResGet() is flawed. It never resets data var size, neither does it zero-fill it before using it. As a result, a variable reused by the user for different operations can and will contain leftovers from previous operations, when new contents size is less than previous contents size. Learned this the hard way, after lots of crashes and apparently impossible errors. One line is to be changed in Compiler\Lib\ResGet.ahk as follows:
VarsetCapacity(data,0),VarsetCapacity(data,sz:=SizeofResource(hModule,hResource), 0),RtlMoveMemory(&data,pData,sz)

In previous tests, the same function also did not return any value, result was always blank. I ended up giving up on checking the size value but this is not right.

However, I'm not sure how/if that function ends up in the compiled exe. This brings us to the second issue: the script I'm working on needs both ResGet() and ResExist(). Unfortunately, none of them can be called dynamically, which is a show stopper because script compatibility with AHK_L cannot be ensured when calling them directly and without calling them the script will be crippled in AHK_H as well as in AHK_L.
What I've tried and didn't work:

Code: [Select all] [Download] GeSHi © Codebox Plus

myFunc() {
re := "ResExist", rg := "ResGet" ; tried setting them Static or Global (outside the function), to no avail
If %re%(A_ScriptFullPath, "SOME_FILE_NAME.AHK", "LIB")
%rg%(data, A_ScriptFullPath, "SOME_FILE_NAME.AHK", "LIB")
script := StrGet(&data, "UTF-8")
FileAppend, %script%, test_filename.ahk, UTF-8
; various operations

Which brings us to the third issue: StrGet() and FileAppend can't seem to work as a pair. If I leave the StrGet() call as is above, the main script will crash. Why? I don't know. The original file that has been embedded in the resources is definitely UTF-8. I can check with Resource Hacker and the file text is displayed correctly there. Main script is also UTF-8 but there is no FileEncoding command/directive.
If I remove second parameter ("UTF-8") from the call, main script works correctly, file is retrieved and loaded fine in a separate thread, just as it should. But…

But the FileAppend command will save either gibberish or - at best - a correct file with duplicated UTF-8 BOM, that is three extra bytes in the beginning of the file. Granted, that command was put there only for debug purposes after all those failed attempts at extracting files (ahk scripts) from resources. But still, should one need such a combination of commands and functions, this one seems to fail one way or another.

Maybe I lost it, maybe I'm limited, retarded or whatever - I could live with that, but in my humble opinion such simple things should work flawlessly and perfectly intertwined. If logic and intuition can't help, user will be put off.

Now someone pray tell how/if the above issues could be fixed on the user side, apart from the data in ResGet which I already fixed locally.

@ HotkeyIt: please fix at least the XP silent crash issue mentioned in a previous topic, so I could compile and test on this XP machine. Thank you.

P.S. Bonus flaw: ResGet is missing from the online documentation index, it's only listed in some "Related" lists for other functions.

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 1 guest