#include #include #include #NoTrayIcon $guiname = "Ethnel-MiniGuard :: Configuration" $db_process = @ScriptDir & "\db\db_process.eth" $db_good = @ScriptDir & "\db\db_good.eth" $db_bliste = @ScriptDir & "\db\db_bliste.eth" $db_pbtmp = @ScriptDir & "\db\db_pbtmp.eth" $gui = GUICreate($guiname,500,300,-1,-1,-1,0x00000080) $bt_etat = GUICtrlCreateLabel("",360,3,130,18,BitOR(0x01,0x1000)) $bt_refresh = GUICtrlCreateButton("Actualiser les listes",220,2,120,19) $tabconfig = GUICtrlCreateTab(3,3,494,294) GUICtrlCreateTabItem("Liste blanche") GUICtrlCreateLabel("Liste blanche",250,27,230,30,0x01) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,15,-1,4) GUICtrlCreateLabel("Ajouter ou supprimer des processus" & @crlf & "de la liste blanche (autoriser).",250,70,230,30,0x01) $listbl = GUICtrlCreateList("",8,27,230,266) $addbla = GUICtrlCreateButton("+",250,120,20,20) $addblb = GUICtrlCreateInput("",275,120,200,20) $delbla = GUICtrlCreateButton("-",250,150,20,20) $delblb = GUICtrlCreateInput("",275,150,200,20) GUICtrlCreateTabItem("Liste noire") GUICtrlCreateLabel("Liste noire",250,27,230,30,0x01) GUICtrlSetBkColor(-1,0xFFFFFF) GUICtrlSetFont(-1,15,-1,4) GUICtrlCreateLabel("Ajouter ou supprimer des processus" & @crlf & "de la liste noire (bloquer).",250,70,230,30,0x01) $listno = GUICtrlCreateList("",8,27,230,266) $addnoa = GUICtrlCreateButton("+",250,120,20,20) $addnob = GUICtrlCreateInput("",275,120,200,20) $delnoa = GUICtrlCreateButton("-",250,150,20,20) $delnob = GUICtrlCreateInput("",275,150,200,20) GUICtrlCreateTabItem("Options") GUICtrlCreateGroup("Informations",8,27,230,60) GUICtrlCreateGroup("Réglages du programme",8,92,230,195) GUICtrlCreateGroup("Divers",250,27,230,215) GUICtrlCreateLabel("Vous pouvez regler plusieurs options dans ce menu.",15,40,220,40) $optsave = GUICtrlCreateButton("Sauvegarder",250,248,230,40) GUICtrlSetFont(-1,15) $startupg = GUICtrlCreateCheckbox("Démarrer avec le système",15,110) if FileExists(@StartupDir & "\Ethnel-MiniGuard.lnk") then ControlCommand($guiname,"",$startupg,"check","") endif GUICtrlCreateTabItem("") _StatGuard() _ListBlanche() _ListNoire() GUISetState() while 1 $msg = GUIGetMsg() Select case $msg = -3 exit case $msg = $bt_etat _ClicStat() case $msg = $addbla _AddBlanche() case $msg = $addnoa _AddNoire() case $msg = $delbla _DelBlanche() case $msg = $delnoa _DelNoire() case $msg = $bt_refresh _Refresh() case $msg = $optsave _SaveConfig() EndSelect WEnd Func _Refresh() _StatGuard() _ListBlanche() _ListNoire() EndFunc Func _ClicStat() If ProcessExists("Guard.exe") Then ProcessClose("Guard.exe") sleep(1000) else ShellExecute(@scriptdir & "\Guard.exe","",@scriptdir) endif _StatGuard() EndFunc func _StatGuard() If ProcessExists("Guard.exe") Then GUICtrlSetData($bt_etat," Etat : En fonctionnement") GUICtrlSetColor($bt_etat,0xFFFFFF) GUICtrlSetBkColor($bt_etat,0x00FF21) else GUICtrlSetData($bt_etat," Etat : Arreter") GUICtrlSetColor($bt_etat,0xFFFFFF) GUICtrlSetBkColor($bt_etat,0xFF0000) endif EndFunc func _ListBlanche() _GUICtrlListBox_ResetContent($listbl) $guardbl = _FileCountLines($db_good) for $i2 = 1 to $guardbl GUICtrlSetData($listbl,FileReadLine($db_good,$i2)) Next EndFunc Func _ListNoire() _GUICtrlListBox_ResetContent($listno) $guardno = _FileCountLines($db_bliste) for $i2 = 1 to $guardno GUICtrlSetData($listno,FileReadLine($db_bliste,$i2)) Next EndFunc func _AddBlanche() $readablb = GUICtrlRead($addblb) if $readablb <> "" then GUICtrlSetData($listbl,$readablb) FileWrite($db_process,$readablb & @crlf) FileWrite($db_good,$readablb & @crlf) GUICtrlSetData($addblb,"") EndIf _ListBlanche() EndFunc func _AddNoire() $readanob = GUICtrlRead($addnob) if $readanob <> "" then GUICtrlSetData($listno,$readanob) FileWrite($db_process,$readanob & @crlf) FileWrite($db_bliste,$readanob & @crlf) GUICtrlSetData($addnob,"") EndIf _ListNoire() EndFunc Func _DelBlanche() $delxblb = GUICtrlRead($delblb) if $delxblb <> "" then $openxblb = FileOpen($db_good,0) $readxblb = FileRead($openxblb) FileClose($openxblb) $stxblb = StringReplace($readxblb,$delxblb & @crlf,"") $openxblbp = FileOpen($db_process,0) $readxblbp = FileRead($openxblbp) FileClose($openxblbp) $stxblbp = StringReplace($readxblbp,$delxblb & @crlf,"") $rw1blb = FileOpen($db_good,2) FileWrite($rw1blb,$stxblb) FileClose($rw1blb) $rw2blb = FileOpen($db_process,2) FileWrite($rw2blb,$stxblbp) FileClose($rw2blb) GUICtrlSetData($delblb,"") endif _ListBlanche() EndFunc Func _DelNoire() $delxnob = GUICtrlRead($delnob) if $delxnob <> "" then $openxnob = FileOpen($db_bliste,0) $readxnob = FileRead($openxnob) FileClose($openxnob) $stxnob = StringReplace($readxnob,$delxnob & @crlf,"") $openxnobp = FileOpen($db_process,0) $readxnobp = FileRead($openxnobp) FileClose($openxnobp) $stxnobp = StringReplace($readxnobp,$delxnob & @crlf,"") $rw1nob = FileOpen($db_bliste,2) FileWrite($rw1nob,$stxnob) FileClose($rw1nob) $rw2nob = FileOpen($db_process,2) FileWrite($rw2nob,$stxnobp) FileClose($rw2nob) GUICtrlSetData($delnob,"") endif _ListNoire() EndFunc Func _SaveConfig() if GUICtrlRead($startupg) == "1" then FileCreateShortcut(@scriptdir & "\Guard.exe",@startupdir & "\Ethnel-MiniGuard.lnk",@scriptdir) Else FileDelete(@startupdir & "\Ethnel-MiniGuard.lnk") EndIf EndFunc