Sign in to follow this  
Followers 0
firsttimer

How to detect a non-windows process is hung?

13 posts in this topic

I  can get the non-windows process id but I cant figure out how to detect when the process is hung.

Anyone have any ideas?

Thanks alot.

Share this post


Link to post
Share on other sites



Search _WinAPI_IsHungAppWindow().


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

_WinAPI_IsHungAppWindow need a windows handle and I cant get a windows handle from a non-windows process.

Share this post


Link to post
Share on other sites

What is the process you are referring to?

Share this post


Link to post
Share on other sites

Search Enum Windows. You should really search these things as your question is asked every month.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

What is the process you are referring to?

 

Process such as svchost.exe.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Is there a better method than



This link might lead you to what you are looking for: '?do=embed' frameborder='0' data-embedContent>>

Is there another method beside the above without using registry or even wmi?

Currently below is the code I'm using now.

----------------------------------------------------------------------------------------------------------------------

$iPID = ProcessExists("notepad.exe")

$hWnd = _GetHwndFromPID($iPID)
Func _GetHwndFromPID($PID)

 $hWnd = 0

 $winlist = WinList()

 Do

  For $i = 1 To $winlist[0][0]

   If $winlist[$i][0] <> "" Then

    $iPID2 = WinGetProcess($winlist[$i][1])

    If $iPID2 = $PID Then

     $hWnd = $winlist[$i][1]

     ExitLoop

    EndIf

   EndIf

  Next

 Until $hWnd <> 0

 Return $hWnd

EndFunc
If _NotResponding($hWnd, 1) Then

    MsgBox(0,"", "Hung Application, closing app now.")

Else

    MsgBox(0,"", "Application running as intended.")

EndIf
Func _NotResponding($hWnd, $closeIfHung = 0)

    If $hWnd == "" Then

        MsgBox(0,"Error","Could not find window")

        Exit

    EndIf

    $retArr = DllCall("user32.dll", "int", "IsHungAppWindow", "hwnd", $hWnd)

    If @error == 0 Then

        If $retArr[0] == 1 Then

            If $closeIfHung Then

                ProcessClose($iPID)

   EndIf

            Return 1

        EndIf

    Else

        Return 0

    EndIf

EndFunc

--------------------------------------------------------------------------------------------------------------------------

As you can see, I need a hwnd or windows handle to use the hung function, but process that dont have a window such as svchost, scheduler.exe etc(including process running in background), how do I get a hwnd or windows handle to use the hung function?

Thank you.

Edited by firsttimer

Share this post


Link to post
Share on other sites

Please try to use AutoIt tags if you can when posting code, unless you have a screen reader.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Please try to use AutoIt tags if you can when posting code, unless you have a screen reader.

Sorry, the aligment when off when I use code tag so I use normal copy and paste yesterday, now recopy and paste again.

Share this post


Link to post
Share on other sites

Its been awhile now, anyone have a solution to my problem here?

Thank you.

Share this post


Link to post
Share on other sites

I dont have a way to make an application hang but the logic is sound in the following:

#include <WinAPISys.au3>
 #include <MsgBoxConstants.au3>


 $pList = ProcessList();list the processes currently running into an array
 For $i = 1 To $pList[0][0];for loop where $pList[0][0] is the total count of the processes running
    $Temp = $pList[$i][1];Processes ID to be used in the loop below
    $HungStatus = _WinAPI_IsHungAppWindow ($Temp);Returns True (1)  or false (0)
    If $HungStatus == 1 Then
        MsgBox(0,"Hung Status","Process ID " & $Temp & " is hung" & " Program name is " & $pList[$i][2])
    EndIf
    Next

Please let me know if that doesn't work.


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites

get the handle that you want then.. This should get you started

$arProc = ProcessList()

For $i = 1 to $arProc[0][0]
    $arStat = ProcessGetStats($arProc[$i][1], 0)
    If IsArray($arStat) Then
        ConsoleWrite("Process Name: " & $arProc[$i][0] & " - Handle: " & StringReplace(_ProcessGetHandle($arProc[$i][0]), @LF, " - ") & @CRLF)
    EndIf
Next

Func _ProcessGetHandle($ioProcName)
    If $ioProcName Then
        Local $sStatus = Run(@ComSpec & " /c WMIC PROCESS WHERE Name='" & $ioProcName & "' GET handlecount", @SystemDir, @SW_HIDE, 8)
        Local $sBuf
        While 1
            $sBuf &= StdoutRead($sStatus)
            If @Error then ExitLoop ; We have lift off, let's move on!
        WEnd
        $sBuf = StringStripCR($sBuf)
        $sBuf = StringRegExpReplace($sBuf, "HandleCount", "")
        $sBuf = StringStripWS($sBuf, 3)
        If StringInStr($sBuf, "No Instance(s) Available.") Then
            ; Just incase we enter a bad process name
            SetError(2)
            Return 0
        EndIf
        Return $sBuf
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc
>link to thread

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0