#Region ;**** Directives created by AutoIt3Wrapper_GUI **** ;~ #AutoIt3Wrapper_Icon=C:\Windows\Resources\Some Personal Icons\ComododClean.ico #AutoIt3Wrapper_Compile_Both=N #AutoIt3Wrapper_UseX64=Y ;~ #AutoIt3Wrapper_Run_Au3Stripper=y ;~ #Au3Stripper_Parameters=/StripOnly #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- #ce ----------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #Include #include #include #include #include #include #include #include #include #include #include #include #include "_ModStatusMessages2.au3" ; By Kobashi, modified by MBee for optional non-display of time & file logging, etc; Global Const $GC_ComodoMainWinTitle = "COMODO Firewall 11" Global Const $GC_ComodoAdvSettingsTitle = "COMODO Advanced Settings" Global Const $GC_SysTray_Tooltip_Title = "Comodo Firewall" Local $L_Systray_WinHdl, $L_SysTray_Overflow_Btn_Hdl, $L_SysTray_Btn_Num, $L_SysTray_Btn_Count ; ; Global Const $GC_CaseOne = 1, $GC_CaseTwo = 2 Local $L_WinX, $L_Win7, $L_ComodoMainWinHdl, $L_ComodoAdvSetWinHdl Local $L_WhichWin, $L_InitWinHdl, $L_NewWinHdl, $L_ContinueMain Const $C_ThisAppName = "MyComodoPurge" Const $C_VersionStr = "v0.03" Global Const $GC_OurTitle = $C_ThisAppName & " " & $C_VersionStr Global $G_TokenHdl, $G_PrivelegeAra Global $G_TimeoutSecs ; ; ; ;--- AutoItSetOption("MustDeclareVars", 1) ; 1 = Mst declare cariables AutoItSetOption("WinTitleMatchMode", 2) ; 2 = Matches any substring in titles AutoItSetOption("MouseCoordMode", 0) ; 0 = Use coordinates relative to Window AutoItSetOption("MouseClickDownDelay", 20) ; 50 = Num of msecs to hold mouse down after click ; ; ; Definitions of first parameter values for _ExtMsgBoxSet(): ;~ 1 = No Taskbar Button ;~ 2 = TOPMOST Style not set ;~ 4 = Buttons use default font ;~ 8 = Expand Tabs to ensure adequate sizing of GUI ;~ 16 = "Do not display again" checkbox ;~ 32 = Show no icon on title bar ;~ 64 = Disable EMB closure [X] and SysMenu Close Const $C_ExtMsgBoxStyle = 2 + 4 + 64 ; See value descriptions above for meanings ; Definitions for first parameter of _ExtMsgBox() -- Which Icon to display ;~ 0 - No icon ;~ 8 - UAC ;~ 16 - Stop ) ;~ 32 - Query ) or equivalent $MB/$EMB_ICON constant ;~ 48 - Exclamation ) ;~ 64 - Information ) ;~ 128 - Countdown digits if $iTimeout set ;~ Any other numeric value returns Error 1 ;~ Full path and name of exe - main exe icon displayed ;~ Full path and name of icon - icon displayed Const $C_ExtMsgBoxIcon = 48 ; ; Global $L_StatMsg_ShowStatus ; True if user wants to output status messages. Assume not. Global $L_StatMsg_ShowTime ; True if user wants to include the time with the msg Global $L_StatMsg_LogToFile ; True if user wants to log messages to file as well Global $L_StatMsg_LogFileHdl ; Handle to output log file (or 0 if unused) ; Local $L_Stat, $L_Error, $Lf_Extended, $L_MsgTxt, $L_ExpectedWinHdl Local $L_PosAra[4], $L_SizeAra[2] Local $L_TimeOut, $L_StartTimeHdl, $L_ActWinHdl ; ; ;+ + + + + + + + + + + + ; ; Entry Point ; ;- - - - - - - - - - - - ; If @Compiled = 1 Then $G_TimeoutSecs = 15 Else $G_TimeoutSecs = 600 EndIf ; TEMP DEBUG CODE Global $L_ShowStatus = False ; True for debug, else False Global $L_LogToFile = True ; Produce status message output log file If $L_ShowStatus Or $L_LogToFile Then $L_Stat = StatusMsgs_Create($L_ShowStatus, True, $L_LogToFile, @ScriptDir & "\ErrorLog.txt") If $L_Stat <> 1 Then MsgBox($MB_SYSTEMMODAL, $GC_OurTitle, "Error: Cannot create output file for debug messsage log - Exiting") Exit -1 EndIf _MyUpdStatusMsg("Creating RECentral Timer Debug Status Msg Output") EndIf ; END DEBUG CODE ; ; ; Determine which OS we're running... ; $L_WinX = False $L_Win7 = False If @OSVersion = "WIN_10" Then $L_WinX = True Else If @OSVersion = "WIN_7" Then $L_Win7 = True EndIf EndIf If ( (Not $L_WinX) And (Not $L_Win7) ) Then MsgBox($MB_OK + $MB_ICONERROR, $GC_OurTitle, "FATAL: OS isn't Win X -OR- Win 7! WEIRD! - Aborting") Exit -2 EndIf _MyUpdStatusMsg("$L_WinX = " & $L_WinX & " - $L_Win7 = " & $L_Win7) ; ; ; Activate the Main / "Wizard" Window ; $L_Stat = _MyOpenComodoWizardWin() If $L_Stat < 0 Then _MyUpdStatusMsg("FATAL: Unable to activate Firewall Wizard Window - Stat= " & $L_Stat & " -- Aborting") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Unable to activate Firewall Wizard Window - Stat= " & $L_Stat & " -- Aborting") Exit $L_Stat EndIf _MyUpdStatusMsg("Main/Wizard Win Open") ; ; ; Now ensure the Main window is active, and return window handle ; $L_ExpectedWinHdl = $L_Stat $L_Stat = _MyWaitForWin( $L_ExpectedWinHdl, $GC_ComodoMainWinTitle, "" ) If $L_Stat <= 0 Then _MyUpdStatusMsg("ERROR: _MyWaitForWin(1) Returned: " & $L_Stat & " -- Exiting") MsgBox($MB_OK, $GC_OurTitle, "ERROR: _MyWaitForWin(1) Returned: " & $L_Stat & " -- Exiting") Exit -3 EndIf $L_ComodoMainWinHdl = $L_Stat ; ; ; Place the window in a specific position, making calculating or referencing coords reliable ; Sleep( 1000 ) $L_Stat = WinMove( $L_ComodoMainWinHdl, "", 492, 100 ) If ($L_Stat = 0) Or ($L_Stat <> $L_ComodoMainWinHdl) Then _MyUpdStatusMsg("FATAL: Unable to position Firewall Wizard Window - Aborting") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Unable to position Firewall Wizard Window - Aborting") Exit -2 EndIf $L_Stat = _MyWaitForWin( "", "", "492 | 100 | 770 | 516" ) If $L_Stat <= 0 Then _MyUpdStatusMsg("ERROR: _MyWaitForWin(2) Returned: " & $L_Stat & " -- Exiting") MsgBox($MB_OK, $GC_OurTitle, "ERROR: _MyWaitForWin(2) Returned: " & $L_Stat & " -- Exiting") Exit -4 EndIf _MyUpdStatusMsg("Main/Wizard Win Moved") ; ; ; Sleep( 500 ) $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 120, 65) ; WizWin -> "Settings" _MyUpdStatusMsg("Settings Button Clicked") $L_Stat = _MyWaitForWin( "", $GC_ComodoAdvSettingsTitle ) If $L_Stat <= 0 Then _MyUpdStatusMsg("ERROR: _MyWaitForWin(3) Returned: " & $L_Stat & " -- Exiting") MsgBox($MB_OK, $GC_OurTitle, "ERROR: _MyWaitForWin(3) Returned: " & $L_Stat & " -- Exiting") Exit -5 EndIf $L_ComodoAdvSetWinHdl = $L_Stat Sleep( 1000 ) $L_Stat = WinMove( $L_ComodoAdvSetWinHdl, "", 260, 44, 1056, 681 ) If ($L_Stat = 0) Or ($L_Stat <> $L_ComodoAdvSetWinHdl) Then _MyUpdStatusMsg("FATAL: Unable to position Firewall Settings Window - Aborting") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Unable to position Firewall Settings Window - Aborting") Exit -2 EndIf $L_Stat = _MyWaitForWin( $L_ComodoAdvSetWinHdl, "260 | 44 | 1056 | 681" ) If $L_Stat <= 0 Then _MyUpdStatusMsg("ERROR: _MyWaitForWin(3) Returned: " & $L_Stat & " -- Exiting") MsgBox($MB_OK, $GC_OurTitle, "ERROR: _MyWaitForWin(3) Returned: " & $L_Stat & " -- Exiting") Exit -6 EndIf _MyUpdStatusMsg("Settings Win Moved") $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 50, 235 ) ; Settings/General -> "Firewall" Sleep( 750 ) _MyUpdStatusMsg("Firewall Button Clicked") $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 80, 163 ) ; Firewall -> "Application Rules" Sleep( 600 ) _MyUpdStatusMsg("Application Rules Button Clicked") $L_InitWinHdl = WinGetHandle("[ACTIVE]", "") $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 638, 168 ) ; Application Rules -> "Purge" Sleep(350) $L_ContinueMain = False $L_TimeOut = False $L_StartTimeHdl = TimerInit() Do $L_ActWinHdl = WinGetHandle("[ACTIVE]", "") If $L_ActWinHdl <> $L_InitWinHdl Then $L_NewWinHdl = $L_ActWinHdl $L_ContinueMain = True ExitLoop EndIf Sleep(200) If TimerDiff($L_StartTimeHdl) > $G_TimeoutSecs * 1000 Then ; 30 seconds * Num msecs per sec $L_TimeOut = True EndIf Until $L_ContinueMain Or $L_TimeOut ; If $L_TimeOut Then _MyUpdStatusMsg("Application Purge Timed Out") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Application Purge Timed Out - Aborting") Exit -32 EndIf $L_PosAra = WinGetPos($L_NewWinHdl) If ( ($L_PosAra[2] > 530) And ($L_PosAra[2] < 534) And _ ($L_PosAra[3] > 575) And ($L_PosAra[3] < 579) ) Then ; 532, 577 $L_WhichWin = $GC_CaseOne Else If ( ($L_PosAra[2] > 474) And ($L_PosAra[2] < 478) And _ ($L_PosAra[3] < 163) And ($L_PosAra[3] > 160) ) Then ; 476, 161 $L_WhichWin = $GC_CaseTwo EndIf EndIf If $L_WhichWin = 0 Then ; Logic error - Must be one or the other _MyUpdStatusMsg("Logic Error: After Purge button click, neither expected outcomes occurred! - Exiting") Exit -40 EndIf _MyUpdStatusMsg("Application Purge Button Wait Complete. Outcome = Case: " & $L_WhichWin) Sleep(400) If $L_WhichWin = $GC_CaseOne Then $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 334, 549 ) ; Purge -> "OK" Else ;~ $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 337, 550 ) ; Purge -> "OK" $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 405, 140 ) ; Purge -> "OK" EndIf $L_TimeOut = False $L_StartTimeHdl = TimerInit() Do $L_ActWinHdl = WinGetHandle("[ACTIVE]", "") If $L_ActWinHdl = $L_ComodoAdvSetWinHdl Then ; If the Purge win closed and we're back to Settings... $L_ContinueMain = True ExitLoop EndIf Sleep(200) If TimerDiff($L_StartTimeHdl) > $G_TimeoutSecs * 1000 Then ; 30 seconds * Num msecs per sec $L_TimeOut = True EndIf Until $L_ContinueMain Or $L_TimeOut ; If $L_TimeOut Then _MyUpdStatusMsg("Application Purge OK Timed Out") MsgBox($MB_OK, $GC_OurTitle, "FATAL: Application Purge OK Timed Out - Aborting") Exit -41 EndIf Sleep(500) $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 51, 341 ) ; Application Rules -> "HIPS" Sleep(350) _MyUpdStatusMsg("HIPS Button Clicked") Sleep( 350 ) $L_Stat = MouseClick( $MOUSE_CLICK_MAIN, 82, 196 ) ; HIPS -> "HIPS Rules" If $L_WhichWin = $GC_CaseOne Then $L_WhichWin = $GC_CaseOne Else EndIf Sleep( 2000 ) _MyUpdStatusMsg("Success - Exiting") MsgBox($MB_OK, $GC_OurTitle, "Success - Exiting") Exit 0 ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyWaitForWin( $arg_ExpectedWinHdl, $arg_ExpectedWinTitle, $arg_ExpectedWinPosSet="" ) ; Local $Lf_Stat, $Lf_Error, $Lf_AraIsJustSize, $Lf_WinOrderChanged, $Lf_ExpectedWinReady Local $Lf_TargetWinHdl, $Lf_ActWinHdl, $Lf_StartTimeHdl, $Lf_TimeOut Local $Lf_DesiredWinExists, $Lf_WinSizePosCheckType, $Lf_PosSetCount, $Lf_CurWinPosAra[4] Local $Lf_PosSetIntAra[1] = [0] _MyUpdStatusMsg("In _MyWaitForWin(A) - $arg_ExpectedWinHdl / $arg_ExpectedWinTitle / $arg_ExpectedWinPosSet =: " & _ $arg_ExpectedWinHdl & " -- " & $arg_ExpectedWinTitle & " -- '" & $arg_ExpectedWinPosSet & " '") If ($arg_ExpectedWinHdl = "") And ($arg_ExpectedWinTitle = "") And ($arg_ExpectedWinPosSet = "") Then Return -10 ; MUST specify at least one of these EndIf $Lf_WinSizePosCheckType = 0 $Lf_PosSetCount = 0 If $arg_ExpectedWinPosSet = "" Then ; If we DON'T need to check size or position... _MyUpdStatusMsg("In _MyWaitForWin(B) - About to call MyWaitForCondition( " & $arg_ExpectedWinHdl & " , '" & $arg_ExpectedWinTitle & "'") $Lf_Stat = _MyWaitForCondition( $arg_ExpectedWinHdl, $arg_ExpectedWinTitle ) If IsHWnd( $Lf_Stat ) = 1 Then Return $Lf_Stat Else _MyUpdStatusMsg("In _MyWaitForWin(C) - Back from MyWaitForCondition() with ERROR = " & $Lf_Stat ) Return $Lf_Stat EndIf Else Local $Lf_TmpPosStrAra = StringSplit( $arg_ExpectedWinPosSet, "|" ) $Lf_PosSetCount = $Lf_TmpPosStrAra[0] ReDim $Lf_PosSetIntAra[$Lf_PosSetCount] If $Lf_PosSetCount = 2 Then $Lf_WinSizePosCheckType = 1 ; 1 = Check Size ONLY $Lf_PosSetIntAra[0] = Int( $Lf_TmpPosStrAra[1] ) $Lf_PosSetIntAra[1] = Int( $Lf_TmpPosStrAra[2] ) ElseIf $Lf_PosSetCount = 4 Then $Lf_WinSizePosCheckType = 2 ; 2 = Check Size And Position $Lf_PosSetIntAra[0] = Int( $Lf_TmpPosStrAra[1] ) $Lf_PosSetIntAra[1] = Int( $Lf_TmpPosStrAra[2] ) $Lf_PosSetIntAra[2] = Int( $Lf_TmpPosStrAra[3] ) $Lf_PosSetIntAra[3] = Int( $Lf_TmpPosStrAra[4] ) Else _MyUpdStatusMsg("FATAL in _MyWaitForWin(): Array size error") Return -2 EndIf Local $TempStr = "In _MyWaitForWin(D) - About to call MyWaitForCondition( " & $arg_ExpectedWinHdl & " , " & $arg_ExpectedWinTitle & _ " , " & $Lf_WinSizePosCheckType & " , " & $Lf_PosSetIntAra & "[# " & $Lf_PosSetCount & "] = [" For $p = 0 To $Lf_PosSetCount -2 $TempStr &= $Lf_PosSetIntAra[$p] & ", " Next $TempStr &= "]" _MyUpdStatusMsg($TempStr) $Lf_Stat = _MyWaitForCondition( $arg_ExpectedWinHdl, $arg_ExpectedWinTitle, $Lf_WinSizePosCheckType, $Lf_PosSetIntAra ) ; Wait for Size/Pos If IsHWnd( $Lf_Stat ) = 1 Then Return $Lf_Stat Else _MyUpdStatusMsg("In _MyWaitForWin(E) - Back from MyWaitForCondition() with ERROR = " & Int($Lf_Stat) ) Return $Lf_Stat EndIf EndIf EndFunc ;==> _MyWaitForWin ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyWaitForCondition($arg_ExpectedWinHdl, $arg_ExpectedWinTitle, $arg_ConditionType=0, $arg_ExpectedIntWinPosAra ="") Local $Lf_Stat, $Lf_WinSizePosCheckType, $Lf_DesiredWinExists, $Lf_TimeOut, $Lf_StartTimeHdl, $Lf_ActWinHdl $Lf_WinSizePosCheckType = $arg_ConditionType $Lf_TimeOut = False $Lf_StartTimeHdl = TimerInit() $Lf_DesiredWinExists = False Do If (IsArray($arg_ExpectedIntWinPosAra) = 0) Or ($arg_ExpectedIntWinPosAra = "") Then ; If no PosAra/Param 4 specified... If $arg_ExpectedWinHdl <> "" Then If WinExists($arg_ExpectedWinHdl) = 1 Then $Lf_ActWinHdl = $arg_ExpectedWinHdl $Lf_DesiredWinExists = True EndIf ElseIf $arg_ExpectedWinTitle <> "" Then If WinExists($arg_ExpectedWinTitle) = 1 Then $Lf_ActWinHdl = WinGetHandle( $arg_ExpectedWinTitle ) $Lf_DesiredWinExists = True EndIf Else Return -10 ; MUST specify at least one input argument group EndIf If $Lf_DesiredWinExists Then Return $Lf_ActWinHdl EndIf Else ; If we know nothing about expected win title or handle... ; ... Then must check either size or size+pos $Lf_Stat = _MyCheckWinBySizeOrPos( $arg_ExpectedIntWinPosAra, $Lf_WinSizePosCheckType ) If IsHWnd( $Lf_Stat ) = 1 Then $Lf_ActWinHdl = $Lf_Stat $Lf_DesiredWinExists = True Else Return $Lf_Stat EndIf EndIf If Not $Lf_DesiredWinExists Then Sleep(500) If TimerDiff($Lf_StartTimeHdl) > $G_TimeoutSecs * 1000 Then ; 10 seconds * Num msecs per sec $Lf_TimeOut = True EndIf EndIf Until $Lf_DesiredWinExists Or $Lf_TimeOut If $Lf_TimeOut Then Return -20 EndIf Return $Lf_ActWinHdl ; Shouldn't get here, though EndFunc ;==> MyWaitForCondition ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyCheckWinBySizeOrPos( $arg_SizeOrPosIntAra, $arg_WinSizePosCheckType ) Local $Lf_CisParantPid, $Lf_NumCisKidPids, $Lf_ThisCisKidPid, $Lf_NumKidWins, $Lf_ThisWinHdl, $Lf_PosAra[4] Local $Lf_DesiredWinExists, $Lf_CmdLine, $Lf_AtError, $Lf_AtExtended $Lf_CisParantPid = ProcessExists( "cistray.exe" ) If $Lf_CisParantPid = 0 Then Return -100 EndIf $Lf_DesiredWinExists = False Local $Lf_CisKidPidsAra = _WinAPI_EnumChildProcess( $Lf_CisParantPid ) If @error <> 0 Then Return -110 EndIf $Lf_NumCisKidPids = $Lf_CisKidPidsAra[0][0] If $Lf_NumCisKidPids = 0 Then Return -120 EndIf For $i = 1 To $Lf_NumCisKidPids -1 If $Lf_CisKidPidsAra[$i][1] = "cis.exe" Then $Lf_ThisCisKidPid = $Lf_CisKidPidsAra[$i][0] $Lf_CmdLine = _MyGetCmdLine( $Lf_ThisCisKidPid ) $Lf_AtError = @error $Lf_AtExtended = @extended If StringInStr($Lf_CmdLine, "--alertsUI", $STR_NOCASESENSEBASIC) > 0 Then ; If this is probably the Shadow CIS process... ContinueLoop EndIf _MyUpdStatusMsg("In MyCheckWinBySizeOrPos() - About to call: _WinAPI_EnumProcessWindows(" & $Lf_ThisCisKidPid & " )") Local $Lf_ThisProcWinListAra = _WinAPI_EnumProcessWindows( $Lf_ThisCisKidPid ) $Lf_AtError = @error If IsArray($Lf_ThisProcWinListAra) = 1 Then If $Lf_ThisProcWinListAra[0][0] < 1 Then Return -130 EndIf Else If $Lf_AtError <> 0 Then Return -131 EndIf EndIf $Lf_NumKidWins = $Lf_ThisProcWinListAra[0][0] If $Lf_NumKidWins = 0 Then ContinueLoop EndIf ; We get here if there is at least one kid process window... For $j = 1 To $Lf_NumKidWins -1 $Lf_ThisWinHdl = $Lf_ThisProcWinListAra[$j][0] $Lf_PosAra = WinGetPos( $Lf_ThisWinHdl ) If $arg_WinSizePosCheckType = 1 Then ; Only need to check size If ($Lf_PosAra[3] > ($arg_SizeOrPosIntAra[0] -2)) And ($Lf_PosAra[3] < ($arg_SizeOrPosIntAra[0] +2)) And _ ($Lf_PosAra[4] > ($arg_SizeOrPosIntAra[1] -2)) And ($Lf_PosAra[4] < ($arg_SizeOrPosIntAra[1] +2)) Then $Lf_DesiredWinExists = True Return $Lf_ThisWinHdl ; Success EndIf Else ; Must check size AND position If (($Lf_PosAra[3] > ($arg_SizeOrPosIntAra[0] -2)) And ($Lf_PosAra[3] < ($arg_SizeOrPosIntAra[0] +2)) And _ ($Lf_PosAra[4] > ($arg_SizeOrPosIntAra[1] -2)) And ($Lf_PosAra[4] < ($arg_SizeOrPosIntAra[1] +2))) And _ (($Lf_PosAra[0] > ($arg_SizeOrPosIntAra[0] -2)) And ($Lf_PosAra[0] < ($arg_SizeOrPosIntAra[0] +2)) And _ ($Lf_PosAra[1] > ($arg_SizeOrPosIntAra[1] -2)) And ($Lf_PosAra[1] < ($arg_SizeOrPosIntAra[1] +2))) Then $Lf_DesiredWinExists = True Return $Lf_ThisWinHdl ; Successful EndIf EndIf Next EndIf Next If $Lf_DesiredWinExists Then Return 47 Else Return -1 EndIf EndFunc ;==> MyCheckWinBySizeOrPos ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyGetCmdLine( $arg_PID ) Local $Lf_ProcHdl, $Lf_TokenHdl, $Lf_PrivelegeAra, $Lf_Stat, $Lf_AtError, $Lf_Extended, $Lf_ErrMsgStr Local $Lf_CmdLineStr ; ; First we need the target process' handle, which we get via it's PID ; $Lf_ProcHdl = _WinAPI_OpenProcess( $PROCESS_QUERY_INFORMATION, 0, $arg_PID ) $Lf_AtError = @error If $Lf_AtError <> 0 Then $Lf_ErrMsgStr= _WinAPI_GetLastErrorMessage() _MyUpdStatusMsg("In MyGetCmdLine(1) - ERROR: '" & $Lf_ErrMsgStr & "' from _WinAPI_OpenProcess() -- ABORTING!") SetError( $Lf_AtError, 0 ) Return "!-300 : " & $Lf_ErrMsgStr EndIf ; ; ; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes ; Local $Lf_TokenHdl = _WinAPI_OpenProcessToken( BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY), $Lf_ProcHdl ) $Lf_AtError = @error $Lf_Extended = @extended If ($Lf_TokenHdl = 0) Or ($Lf_AtError <> 0) Then $Lf_ErrMsgStr = _WinAPI_GetLastErrorMessage() _MyUpdStatusMsg("In MyGetCmdLine(1) - ERROR: '" & $Lf_ErrMsgStr & "' from _WinAPI_AdjustTokenPrivileges() Failed -- ABORTING!") SetError( $Lf_AtError, $Lf_Extended ) Return "!-310 : " & $Lf_ErrMsgStr EndIf $Lf_Stat = _WinAPI_AdjustTokenPrivileges($Lf_TokenHdl, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $Lf_PrivelegeAra) $Lf_AtError = @error $Lf_Extended = @extended If ($Lf_Stat <> 1) Or ($Lf_AtError <> 0) Then $Lf_ErrMsgStr = _WinAPI_GetLastErrorMessage() _MyUpdStatusMsg("In MyGetCmdLine(2) - ERROR: '" & $Lf_ErrMsgStr & "' from _WinAPI_AdjustTokenPrivileges() Failed -- ABORTING!") _MyRestorePrivileges($Lf_TokenHdl, $Lf_PrivelegeAra) SetError( $Lf_AtError, $Lf_Extended ) Return "!-320 : " & $Lf_ErrMsgStr EndIf ; ; Retrieve command-line for this particular Comodo Firewall process... ; ; ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ; ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! THE NEXT CALL RETURNS @error = 40 (decimal) - I don't know why, since I should have the privilege !!!!!!!!! ; $Lf_CmdLineStr = _WinAPI_GetProcessCommandLine( $arg_PID ) $Lf_AtError = @error If ($Lf_CmdLineStr = "") Or ($Lf_AtError <> 0) Then $Lf_ErrMsgStr = _WinAPI_GetLastErrorMessage() _MyUpdStatusMsg("In MyGetCmdLine(3) - ERROR: '" & $Lf_ErrMsgStr & "' from _WinAPI_AdjustTokenPrivileges() Failed -- ABORTING!") _MyRestorePrivileges($Lf_TokenHdl, $Lf_PrivelegeAra) SetError( $Lf_AtError, $Lf_Extended ) Return "!-330 : " & $Lf_ErrMsgStr EndIf _MyRestorePrivileges($Lf_TokenHdl, $Lf_PrivelegeAra) SetError( 0, 0 ) Return $Lf_CmdLineStr EndFunc ;==> MyGetCmdLine ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyRestorePrivileges( $arg_TokenHdl, $arg_PrivelegeAra ) Local $Lf_Stat, $Lf_NewPrivAra, $Lf_AtError, $Lf_AtExtended ;~ _WinAPI_AdjustTokenPrivileges($arg_TokenHdl, $Lf_NewPrivAra, 0, $arg_PrivelegeAra) $Lf_Stat = _WinAPI_AdjustTokenPrivileges( $arg_TokenHdl, -1, 0, $arg_PrivelegeAra ) $Lf_AtError = @error $Lf_AtExtended = @extended If $Lf_Stat <> 1 Then _MyUpdStatusMsg("In MyRestorePrivileges(1) - @error = " & $Lf_AtError & " -- Abort") Return -500 EndIf _WinAPI_CloseHandle($arg_TokenHdl) Return 0 EndFunc ;==> MyRestorePrivileges ; ; ;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ; ; Func _MyOpenComodoWizardWin() ; The functions this one calls are NOT my code. I will credit other developers later... Local $L_Stat $L_SysTray_Btn_Num = Get_Systray_Index($GC_SysTray_Tooltip_Title) If $L_SysTray_Btn_Num = -1 Then Return -1 Else Sleep(1500) ; right click and select ninth menu item (down) _GUICtrlToolbar_ClickButton($L_Systray_WinHdl, $L_SysTray_Btn_Num, "right", True) Sleep(1000) Send("{DOWN 9}") Sleep(350) Send("{ENTER}") $L_Stat = WinWaitActive($GC_ComodoMainWinTitle, "") If $L_Stat = 0 Then Return -20 Return $L_Stat ; At this point, $L_Stat is window's handle EndIf Return 0 EndFunc ;==> MyOpenComodoWizardWin Func Get_Systray_Index($arg_Systray_Title) ; Find systray handle $L_Systray_WinHdl = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then Return -4 EndIf ; Get systray item count Local $L_SysTray_Btn_Count = _GUICtrlToolbar_ButtonCount($L_Systray_WinHdl) If $L_SysTray_Btn_Count = 0 Then ; check overflow section of systray Return Get_OverflowSystray_Index($arg_Systray_Title) EndIf ; Look for wanted tooltip For $L_SysTray_Btn_Num = 0 To $L_SysTray_Btn_Count - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($L_Systray_WinHdl, $L_SysTray_Btn_Num), $arg_Systray_Title) <> 0 Then ExitLoop Next If $L_SysTray_Btn_Num = $L_SysTray_Btn_Count Then Return Get_OverflowSystray_Index($arg_Systray_Title) Else Return $L_SysTray_Btn_Num ; Found EndIf EndFunc ;==> Get_Systray_Index Func Get_OverflowSystray_Index($arg_Systray_Title) $L_Systray_WinHdl = ControlGetHandle('[Class:NotifyIconOverflowWindow]', '', '[Class:ToolbarWindow32;Instance:1]') If $L_SysTray_Btn_Count = 0 Then Return -3 EndIf For $L_SysTray_Btn_Num = 0 To $L_SysTray_Btn_Count - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($L_Systray_WinHdl, $L_SysTray_Btn_Num), $arg_Systray_Title) <> 0 Then ExitLoop Next If $L_SysTray_Btn_Num < $L_SysTray_Btn_Count Then $L_SysTray_Overflow_Btn_Hdl = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[CLASS:Button; INSTANCE:1]') _GUICtrlButton_Click($L_SysTray_Overflow_Btn_Hdl) Return $L_SysTray_Btn_Num ; Found Else Return -1 EndIf EndFunc ;==> Get_OverflowSystray_Index Func GetPopUpSelText() Local $L_PopupListAra = _WinAPI_EnumWindowsPopup() Local $L_WinHdl = $L_PopupListAra[1][0] Local $L_ClassNum = $L_PopupListAra[1][1] If $L_ClassNum = "#32768" Then ; This is a "standard" Windows API popup menu Local $L_MenuHdl = _SendMessage($L_WinHdl, $MN_GETHMENU, 0, 0) If _GUICtrlMenu_IsMenu($L_MenuHdl) Then Local $L_Count = _GUICtrlMenu_GetItemCount($L_MenuHdl) For $j = 0 To $L_Count - 1 If _GUICtrlMenu_GetItemHighlighted($L_MenuHdl, $j) Then Return _GUICtrlMenu_GetItemText($L_MenuHdl, $j) EndIf Next EndIf EndIf Return "" EndFunc ;==> GetPopUpSelText