-
Posts
3,915 -
Joined
-
Last visited
-
Days Won
15
KaFu last won the day on October 26 2024
KaFu had the most liked content!
About KaFu

- Birthday 09/06/1974
Profile Information
-
Member Title
Hey, it's just me, KhaFoo...
-
Location
Germany, Hamburg
-
WWW
https://funk.eu
KaFu's Achievements
-
argumentum reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
It's hard to tell the reason without knowing the internal workings of DllOpen() vs DllCall() with and without a handle. Also that it's only related to uncompiled 32bit scripts makes it even more hard to explain. And that it seems not a common problem, but only few people seem to experience (or realize) it or seem to be able to reproduce it. It seems to be related to a certain system setup only, though I think at least @UEZ, @@therks and myself stumbled over it now. -
argumentum reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
No, all uncompiled 32bits scripts using CreateFileMappingW, CreateSemaphoreW and also CreateMutexW fail when called like Local $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", $tSecurityAttributes, "bool", 1, "wstr", $sOccurrenceName) but work when called with a either a global or local variable for kernel32.dll like Local $h_DLL_Kernel32 = DllOpen("kernel32.dll") Local $aHandle = DllCall($h_DLL_Kernel32, "handle", "CreateMutexW", "struct*", $tSecurityAttributes, "bool", 1, "wstr", $sOccurrenceName) -
KaFu reacted to a post in a topic: New _Singleton() need opinion
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Wow, now it's getting really wild 🙄. After reading this post by @therks (which I didn't see that time, kudos!), I gave it a try. Now if I don't call the dlls directly, but open the kernel32.dll frist via dllopen, then it works for my uncompiled 32bit scripts too . #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $hSemaphore = _SingletonSemaphore_Org("TestSemaphore", 1) If $hSemaphore = 0 Then MsgBox(16, "Warning - _SingletonSemaphore_Org - Does not work for me from an uncompiled 32bit script", "An occurrence of test is already running", 30) Exit Else MsgBox(64, "OK - _SingletonSemaphore_Org - Does not work for me from an uncompiled 32bit script", "The first occurrence of test is running", 30) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hSemaphore) EndIf Func _SingletonSemaphore_Org($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 $hStartEvent = DllCall("kernel32.dll", 'handle', 'CreateSemaphoreW', 'struct*', 0, 'long', 0, 'long', 1, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Return 0 ; meh Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc Global $hDLL_Kernel32 = DllOpen("kernel32.dll") Local $hSemaphore = _SingletonSemaphore_DllOpen("TestSemaphore", 1) If $hSemaphore = 0 Then MsgBox(16, "Warning - _SingletonSemaphore_DllOpen - Works for me from an uncompiled 32bit script too", "An occurrence of test is already running", 30) Exit Else MsgBox(64, "OK - _SingletonSemaphore_DllOpen - Works for me from an uncompiled 32bit script too", "The first occurrence of test is running", 30) DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hSemaphore) endif Func _SingletonSemaphore_DllOpen($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 ; Local $hDLL_Kernel32 = DllOpen("kernel32.dll") $hStartEvent = DllCall($hDLL_Kernel32, 'handle', 'CreateSemaphoreW', 'struct*', 0, 'long', 0, 'long', 1, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall($hDLL_Kernel32, "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall($hDLL_Kernel32, "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Return 0 ; meh Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonSemaphore Edit: Same result for CreateFileMappingW. Using a handle from dllopen it works for uncompiled 32bit scripts, using a direct dllcall to kernel32.dll it does not work. -
KaFu reacted to a post in a topic: New _Singleton() need opinion
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Sadly the same result, all works (compiled 32bit and 64bit and uncompiled 64bit), only uncompiled 32bit code still does not work. -
KaFu reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
I think they are all different means of accessing shared memory... and that there's something underlying principle that prevents my un-compiled 32bit scripts, on a x64 OS, run through SciTE to access this shared memory space. No need to change to WinExist or something, as the compiled code works fine. Just testing on the fly won't work, only hard-coded through msgbox or similar debugging means. -
KaFu reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Yes, tried that, didn't change the outcome. Also strange is that _WinAPI_IsWow64Process() still reports 1 after the successful call of _WinAPI_Wow64EnableWow64FsRedirection(False), I would have expected a 0 then. But maybe _WinAPI_IsWow64Process() still is true even if the redirection has been disable. Also tried "Wow64DisableWow64FsRedirection", also didn't help. -
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Hi @UEZ, did you ever solve this wow64 related topic here? I have the feeling that my topic could be related to the Wow64 redirection too. Is there anything Wow64 related that the autoit3.exe compiler does? Or in the manifest? My 32bit compiled scripts work as expected, un-compiled scripts running as 32 bit from SciTE fail. -
argumentum reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Thanks for testing and following up! So it really seems like there's something freaky in my own setup going on, good to know that at least it's not a common problem. I'll post a result, if I ever find out what it was 🙃. Best Regards -
KaFu reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
I'm using Win10 Home 22H2 64bit, AutoIt 3.3.16.1 and SciTE 32-bit, Version 4.4.6, Mar 12 2022 10:14:43 -
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
It's getting even more strange. When I use x64 (#AutoIt3Wrapper_UseX64=y), it seems to work for me too in both directions. When I switch to x86 (#AutoIt3Wrapper_UseX64=n) and - start SciTE first, the executable can detect the existing filemapping - start the executable first, SciTE can not detect the existing filemapping -
KaFu reacted to a post in a topic: CreateSemaphoreW and CreateFileMappingW in SciTE
-
WildByDesign reacted to a post in a topic: goto specific line in rich edit control
-
CreateSemaphoreW and CreateFileMappingW in SciTE
KaFu replied to KaFu's topic in AutoIt General Help and Support
Returns 0 on first run as exe and also on subsequent runs in SciTE. -
goto specific line in rich edit control
KaFu replied to TheAutomator's topic in AutoIt General Help and Support
Works fine on my Win10 too. -
UPDATED INFO - ImageSearch issues - Does It Still Work??
KaFu replied to jimdaway's topic in AutoIt General Help and Support
There's a comment in that thread somewhere at the end that seems to hint that it only works with bmp? -
Hello Team, I've encountered a strange behavior and currently can not track down the reasons. Maybe it's related to my specific Installation only? Or hopefully someone else can reproduce the issue. I've got two different approaches for a singleton script, one with CreateSemaphoreW and one with CreateFileMappingW. ; https://www.autoitscript.com/forum/topic/185203-new-_singleton-need-opinion/ ; by Terenz Local $hSemaphore = _SingletonSemaphore If _SingletonSemaphore("TestSemaphore", 1) = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hSemaphore) Func _SingletonSemaphore($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 $hStartEvent = DllCall('kernel32.dll', 'handle', 'CreateSemaphoreW', 'struct*', 0, 'long', 0, 'long', 1, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonSemaphore ; https://www.autoitscript.com/forum/topic/185203-new-_singleton-need-opinion/ ; by Terenz Local $hFilemapping = _SingletonMap("Testmapping", 1) If $hFilemapping = 0 Then MsgBox(16, "Warning", "An occurrence of test is already running") Exit EndIf MsgBox(64, "OK", "The first occurrence of test is running") DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hFilemapping) Func _SingletonMap($sOccurrenceName, $iFlag = 0) Local Const $ERROR_ALREADY_EXISTS = 183 Local $tInt64 = DllStructCreate('int64') Local $tQWord = DllStructCreate('dword;dword', DllStructGetPtr($tInt64)) DllStructSetData($tInt64, 1, 1) Local $iSize_HiDWord = DllStructGetData($tQWord, 2), $iSize_LoDWord = DllStructGetData($tQWord, 1) Local $hStartEvent = DllCall('kernel32.dll', 'handle', 'CreateFileMappingW', 'handle', -1, 'struct*', 0, 'dword', 0x0004, 'dword', $iSize_HiDWord, 'dword', $iSize_LoDWord, 'wstr', $sOccurrenceName) If @error Then Return SetError(@error, @extended, 0) Local $hError = DllCall("kernel32.dll", "dword", "GetLastError") If $hError[0] = $ERROR_ALREADY_EXISTS Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hStartEvent[0]) If @error Then Return SetError(@error, @extended, 0) If BitAND($iFlag, 1) Then Return SetError($hError[0], $hError[0], 0) Else Exit -1 EndIf EndIf Return $hStartEvent[0] EndFunc ;==>_SingletonMap Now if I compile the code and run it from the created executable, the first instance shows the "first occurrence" message and all subsequent instances (while the fist message box is still open) will result in the "already running" message box. If I leave the "first occurrence" message box open then run the code in parallel form SciTE, that code will produce another "first occurrence" message box, but I expected an "already running" message box here too. What might be the reason for the different results, running the code directly or through SciTE?
-
KaFu reacted to a post in a topic: Round Corner GUI and Controls UDF
-
KaFu reacted to a post in a topic: Need help converting uint32 to 32-bit binary
-
Possible to handle this hard crash error?
KaFu replied to a41943041024's topic in AutoIt General Help and Support
Maybe you don't close all handles correctly? That might choke your system. Check that all open handles are closed, for files and graphic objects. Take a look at these functions (among others, most common): FileClose() StdioClose() _WinAPI_CloseHandle() _WinAPI_DeleteObject() _GDIPlus_BitmapDispose() _GDIPlus_GraphicsDispose()