#include-once #include #include Func Thread_Call($opcode , $control_wait = 1 , $timeout = 2000 , $thread_wait_show = 0) Local $pExecutableCode = _MemVirtualAlloc(0, BinaryLen($opcode), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) Local $tCodeBuffer = DllStructCreate("byte a["&BinaryLen($opcode)&"]", $pExecutableCode) DllStructSetData($tCodeBuffer, 1, $opcode) Local $Check_return = 0 Local $Recvice_retcode = DllStructCreate("int a[1];") Local $aRet = DllCall("kernel32.dll", "handle", "CreateThread", "ptr", 0, "dword_ptr", 0, "ptr", $pExecutableCode, "ptr", DllStructGetPtr($Recvice_retcode), "dword", 0, "dword*", 0) If @error Then msgbox(0,1,"CreateThread error:" & @error & @CRLF) ElseIf $aRet[0] = 0 Then msgbox(0,2,"CreateThread error:" & "Null" & @CRLF) Else Local $hThread = $aRet[0] if $control_wait = 1 Then $aRet = DllCall("kernel32.dll", "dword", "WaitForSingleObject", "handle", $hThread, "dword", $timeout) If @error Then MsgBox(0,3,"WaitForSingleObject error: " & @error & @CRLF) Else Switch $aRet[0] Case -1, 0xFFFFFFFF $aRet = DllCall("kernel32.dll", "bool", "TerminateThread", "handle", $hThread, "int", -1) if $thread_wait_show = 1 then msgbox(0,4,"WAIT_FAILED") EndIf Case 0x00000102 $aRet = DllCall("kernel32.dll", "bool", "TerminateThread", "handle", $hThread, "int", -1) if $thread_wait_show = 1 then msgbox(0,5,"WAIT_TIMEOUT") EndIf Case 0x00000080 $aRet = DllCall("kernel32.dll", "bool", "TerminateThread", "handle", $hThread, "int", -1) if $thread_wait_show = 1 then msgbox(0,"a","WAIT_ABANDONED") EndIf Case 0x00000000 $Check_return = 1 if $thread_wait_show = 1 then MsgBox(0,"s","Wait success") EndIf Case Else if $thread_wait_show = 1 then msgbox(0,"b","Unknow = "& $aRet[0]) EndIf EndSwitch EndIf EndIf EndIf if $control_wait = 1 Then _MemGlobalFree($pExecutableCode) $tCodeBuffer = 0 _WinAPI_CloseHandle($hThread) EndIf if $Check_return == 1 and $Check_return <> Null then Return $Recvice_retcode.a EndIf EndFunc