Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/31/2025 in Posts

  1. Nine

    CreateTimerQueueTimer

    Nevertheless, I do not trust the proposed code ( that I gave you ) is a solution with AutoIt. The ASM code simply calls (in a few nano secs) the SendMessageW API. So why does it seem to work ? You ask me. Well it is not obvious to answer since I do not own the core AutoIt code. But my take on it, will go those few options : 1- the latency between AutoIt statement is larger than the time it takes to execute the ASM code 2- for "not that I know of" reason, the ASM routine is uninterruptible state 3- Windows execute ASM functions into a separate thread Anyway, it was fun to look deeper into this challenging thread...Good luck !
    1 point
  2. Nine

    CreateTimerQueueTimer

    Here : #include <Memory.au3> #include <WindowsConstants.au3> #include <WinAPIError.au3> #include <WinAPIHObj.au3> #include <WinAPISys.au3> Global Const $WT_EXECUTELONGFUNCTION = 0x00000010 ; The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread. Global Const $WT_EXECUTEINTIMERTHREAD = 0x00000020 ; The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations. Global Const $WT_EXECUTEINPERSISTENTTHREAD = 0x00000080 ; The callback function is queued to a thread that never terminates. Local $a_h_CreateTimerQueue = DllCall("kernel32.dll", "handle", "CreateTimerQueue") ConsoleWrite("CreateTimerQueue = " & $a_h_CreateTimerQueue[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Local $i_TimerQueue_Start_after = 100 Local $i_TimerQueue_Repeat_after = 100 Local $pCallback = _RegisterSyncCallback(_CallBackFunction) ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx Local $a_hCall = DllCall("kernel32.dll", "bool", "CreateTimerQueueTimer", _ "handle*", 0, _ "handle", $a_h_CreateTimerQueue[0], _ "ptr", $pCallback, _ "ptr", 678, _ "dword", $i_TimerQueue_Start_after, _ "dword", $i_TimerQueue_Repeat_after, _ "ulong", $WT_EXECUTEINTIMERTHREAD) Local $phNewTimer = $a_hCall[1] ConsoleWrite("CreateTimerQueueTimer = " & $a_hCall[0] & @TAB & $phNewTimer & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Local $timer = TimerInit() While Sleep(10) ConsoleWrite("+ " & TimerDiff($timer) & @CRLF) If TimerDiff($timer) > 5000 Then ConsoleWrite("! fire Exitloop event" & @CRLF) ExitLoop EndIf WEnd Local $a_hCall = DllCall("kernel32.dll", "bool", "DeleteTimerQueueTimer", _ "handle", $a_h_CreateTimerQueue[0], _ "handle", $phNewTimer, _ "handle", 0) ConsoleWrite("DeleteTimerQueueTimer = " & $a_hCall[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) ConsoleWrite("_WinAPI_CloseHandle($phNewTimer) = " & _WinAPI_CloseHandle($phNewTimer) & @CRLF) Local $a_hCall = DllCall("kernel32.dll", "bool", "DeleteTimerQueueEx", "handle", $a_h_CreateTimerQueue[0], "handle", 0) ConsoleWrite("DeleteTimerQueueEx = " & $a_hCall[0] & @CRLF & @CRLF) ConsoleWrite(_WinAPI_GetLastError() & @TAB & _WinAPI_GetLastErrorMessage() & @CRLF & @CRLF) Func _CallBackFunction($lParam, $TimerOrWaitFired) ConsoleWrite("_CallBackFunction fired = " & $lParam & @TAB & $TimerOrWaitFired & @CRLF) EndFunc ;==>_CallBackFunction Func _RegisterSyncCallback($Function) Local Static $hGUI Local Static $pSendMessage Local Static $iMsg If Not $hGUI Then $hGUI = GUICreate("RegisterSyncCallback_Msg", 300, 200) $iMsg = $WM_APP GUIRegisterMsg($iMsg, RegisterSyncCallback_Msg) $pSendMessage = _WinAPI_GetProcAddress(_WinAPI_GetModuleHandle("user32.dll"), "SendMessageW") ConsoleWrite("$hGUI: " & Hex($hGUI) & @CRLF) ConsoleWrite("$pSendMessage: " & Hex($pSendMessage) & @CRLF) ConsoleWrite("$iMsg: " & Hex($iMsg) & @CRLF) EndIf If @AutoItX64 Then Return MsgBox(0, "Error", "This is a x86 Sample :(") ;add x64 code yourself Local $pRemoteCode = _MemVirtualAlloc(0, 96, $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) If Not $pRemoteCode Then MsgBox(0, "Error", "_MemVirtualAlloc :(") Local $tCodeBuffer = DllStructCreate("byte[96]", $pRemoteCode) Local $hHandle = DllCallbackRegister($Function, "none", "int;int") Local $sOPCode = "0x68" & SwapEndian($pRemoteCode + 29) & _ "FF74240868" & SwapEndian($iMsg) & "68" & SwapEndian($hGUI) & _ "B8" & SwapEndian($pSendMessage) & "FFD0C20800" & _ SwapEndian(DllCallbackGetPtr($hHandle)) DllStructSetData($tCodeBuffer, 1, $sOPCode) ConsoleWrite("$tCodeBuffer: " & DllStructGetData($tCodeBuffer, 1) & @CRLF) Return $pRemoteCode EndFunc ;==>_RegisterSyncCallback Func RegisterSyncCallback_Msg($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite(">RegisterSyncCallback_Msg Called" & @CRLF) ;ConsoleWrite("$hWnd: " & Hex($hWnd) & @CRLF) ;ConsoleWrite("$iMsg: " & Hex($iMsg) & @CRLF) ;ConsoleWrite("$wParam: " & Hex($wParam) & @CRLF) ;ConsoleWrite("$lParam: " & Hex($lParam) & @CRLF) Local $tStruct = DllStructCreate("ptr pFunction", $lParam) DllCallAddress("none", $tStruct.pFunction, "int", $wParam, "int", 1) EndFunc ;==>RegisterSyncCallback_Msg Func SwapEndian($uInt) Local $iLen = @AutoItX64 ? 16 : 8, $sHex = Hex($uInt, $iLen), $sRes For $i = $iLen - 2 To 0 Step -2 $sRes &= StringMid($sHex, $i + 1, 2) Next Return $sRes EndFunc What the ASM code is doing : 0: 68 1d 00 c3 03 push 0x3c3001d ; hHandle for lParam 5: ff 74 24 08 push DWORD PTR [esp+0x8] ; Parameter for wParam 9: 68 00 80 00 00 push 0x8000 ; iMsg e: 68 4e 07 06 00 push 0x6074e ; hGUI 13: b8 60 5d 4e 76 mov eax,0x764e5d60 18: ff d0 call eax ; SendMessageW 1a: c2 08 00 ret 0x8
    1 point
  3. WildByDesign

    DwmColorBlurMica

    The first post has been updated to version 0.7. The overall speed of the event hook is faster in this release which is nice. I cleaned up the event hook function to make it perform better. This release is mostly geared toward improving the File Explorer handling in the hook. I had to differentiate between classic File Explorer and modern File Explorer. Classic File Explorer has no issues with DwmExtendFrameIntoClientArea or Blur Behind and therefore can be applied immediately and stays applied. Modern File Explorer, on the other hand, is a "laggy" beast. It loses client area coloring from DwmExtendFrameIntoClientArea any time it loses and regains focus which I solved in a previous release. But it also doesn't always apply 100% of the time when you first start it due to a timing issue with how laggy it is. This can be different depending on the speed of any users' CPU. So I added ExplorerPaintDelay to the config file with a default value of 200ms which fixes it 100% of the time on my system. But I made it a config option because it might be different on other users' systems depending on hardware specs and how "laggy" modern File Explorer is. Modern File Explorer sometimes had an issue applying Blur Behind when starting File Explorer. I noticed that if you click on the taskbar and back on File Explorer, it fixes it. I will try to fix it properly when I have more time, but for now I have fixed it (100%) with a workaround in the blur behind function: If $sClassName = "CabinetWClass" Then WinActivate("[CLASS:Shell_TrayWnd]") WinActivate($hWnd) EndIf So that extra bit is only needed for File Explorer. All handling of both classic and modern File Explorer is super smooth in this release. File Explorer startup, losing and regaining focus, etc. It all works beautifully. And all of that extra work was only needed because modern File Explorer is such a "laggy" monstrosity. Classic File Explorer is and was always fast. Modern File Explorer has always been slow and "laggy" and Microsoft seems to have no desire to improve it.
    1 point
  4. jugador

    CreateTimerQueueTimer

    may be then try with this https://www.autohotkey.com/boards/viewtopic.php?f=6&t=21223 instead of DllCallbackRegister
    1 point
×
×
  • Create New...