carteblanche619 Posted December 4, 2013 Share Posted December 4, 2013 I am working on this code but its having a bug... When you run this code and connect a USB device, after the scanner GUI finishes, you cannot safely remove your USB device without killing this app. Why is this happening and how to avoid it??? Plz Helpexpandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $RemFix, $Rome = 9999, $Agree = 9999, $fScanning = False $Test_GUI = GUICreate("Test_GUI", 306, 307, 192, 124) $Button1 = GUICtrlCreateButton("F1", 16, 16, 81, 81) $Button2 = GUICtrlCreateButton("F2", 112, 16, 81, 81) $Button3 = GUICtrlCreateButton("F3", 208, 16, 81, 81) $Button4 = GUICtrlCreateButton("F4", 16, 112, 81, 81) $Button5 = GUICtrlCreateButton("F5", 112, 112, 81, 81) $Button6 = GUICtrlCreateButton("F6", 208, 112, 81, 81) $Button7 = GUICtrlCreateButton("F7", 16, 208, 81, 81) $Button8 = GUICtrlCreateButton("F8", 112, 208, 81, 81) $Button9 = GUICtrlCreateButton("F9", 208, 208, 81, 81) $cScan = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $Test_GUI) $DBT_DEVICEARRIVAL = "0x00008000" GUIRegisterMsg($WM_DEVICECHANGE, "_Auto") ;Setting listener for device arrival While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $Test_GUI Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $Button1, $Button2, $Button3, $Button4, $Button5, $Button6, $Button7, $Button8, $Button9 _Rome() Case $cScan _Scan() $fScanning = False EndSwitch Case $Rome Switch $aMsg[0] Case $GUI_EVENT_CLOSE, $Agree GUIDelete($Rome) $Rome = 9999 $Agree = 9999 EndSwitch EndSwitch WEnd Func _Rome() $Rome = GUICreate("Rome", 261, 182, 325, 182) $Label1 = GUICtrlCreateLabel("Rome was not Built in a day", 16, 48, 234, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") $Agree = GUICtrlCreateButton("Ok...I Agree", 40, 104, 177, 41) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW, $Rome) Return EndFunc ;==>_Rome Func _Scan() ;;Creation of GUI $child = GUICreate("Scanning", 300, 80, @DesktopWidth - 310, @DesktopHeight - 120, BitOR($WS_SYSMENU, $WS_POPUP)) GUICtrlCreateLabel("Scanning", 10, 10) $Prog = GUICtrlCreateProgress(10, 30, 280, 20) $StatusInfo = GUICtrlCreateLabel("Status:Ready ", 10, 60) $DirInfo = GUICtrlCreateLabel("Drive:", 255, 60) $DirName = GUICtrlCreateLabel(" ", 285, 60) For $i = 1 To $RemFix[0] If $RemFix[$i] == "c:" Or $RemFix[$i] == "d:" Or $RemFix[$i] == "e:" Or $RemFix[$i] == "f:" Or $RemFix[$i] == "g:" Or $RemFix[$i] == "h:" Or $RemFix[$i] == "i:" Or $RemFix[$i] == "j:" Or $RemFix[$i] == "k:" Or $RemFix[$i] == "l:" Or $RemFix[$i] == "m:" Or $RemFix[$i] == "n:" Or $RemFix[$i] == "o:" Or $RemFix[$i] == "p:" Or $RemFix[$i] == "q:" Or $RemFix[$i] == "r:" Or $RemFix[$i] == "s:" Or $RemFix[$i] == "t:" Or $RemFix[$i] == "u:" Or $RemFix[$i] == "v:" Or $RemFix[$i] == "w:" Or $RemFix[$i] == "x:" Or $RemFix[$i] == "y:" Or $RemFix[$i] == "z:" Then GUISetState(@SW_SHOW) FileChangeDir($RemFix[$i]) GUICtrlSetData($StatusInfo, "Status:Scanning") GUICtrlSetData($DirName, $RemFix[$i]) For $val = 0 To 100 GUICtrlSetData($Prog, $val) Sleep(10) Next EndIf GUICtrlSetData($StatusInfo, "Status:Ready") GUICtrlSetData($DirInfo, "Drive: ") Next GUIDelete($child) EndFunc ;==>_Scan Func _Auto($hWndGUI, $MsgID, $WParam, $LParam) If $hWndGUI = $Test_GUI And $WParam = $DBT_DEVICEARRIVAL Then ;;Get Removable devices names $RemFix = DriveGetDrive("REMOVABLE") If $RemFix = '' Then Return Else GUICtrlSendToDummy($cScan) EndIf EndIf EndFunc ;==>_Auto Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 (edited) In case anyone's interested, i can solve my problem by using some part of this... but I am not able to figure out which part :/expandcollapse popup#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Unlocker.ico #AutoIt3Wrapper_Outfile=Unlocker.exe #AutoIt3Wrapper_Outfile_x64=Unlocker[64].exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Description=File - Directory Unlocker #AutoIt3Wrapper_Res_Fileversion=1.0.0.11 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 6 #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3" #AutoIt3Wrapper_Run_Obfuscator=y #Obfuscator_Parameters=/so #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.8.1 Author : Apud_Angelorum aka THAT1ANONYMOUSDUDE Credits: Yashid, monoceres, wraithdu, Manko, JScript, Larry, _ SmOke_N and mrRevoked, Trancexx And thanks to anyone who I have taken other code from but cannot remember where I found it or who made it. Script Function: Unlock files and directories. Autoit Unlocker - AutoIt script. #ce ---------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiListView.au3> #include <GuiToolTip.au3> #region - Globals - ;If @OSArch <> "X86" Then Exit MsgBox(16, "Advisory!", "This application is not compatable with the architecture of this operating system." & @CR & "The application will now exit.") Global Const $hNTDLL = DllOpen("ntdll.dll") Global Const $hPSAPI = DllOpen("psapi.dll") Global Const $hUSER32 = DllOpen("user32.dll") Global Const $hKERNEL32 = DllOpen("kernel32.dll") Global Const $hADVAPI32 = DllOpen("advapi32.dll") Global Const $Compiled = @Compiled Global Const $Is64 = @AutoItX64 Global $temporariis Global $Datum Global $ProcessHwnd Global $CurrentProcess Global Const $Critical[13] = [ _ 'winlogon.exe', _ 'services.exe', _ 'csrss.exe', _ 'smss.exe', _ 'lsass.exe', _ 'alg.exe', _ 'svchost.exe', _ 'spoolsv.exe', _ 'wdfmgr.exe', _ 'dwm.exe', _ 'logonui.exe', _ 'wininit.exe', _ 'lsm.exe' _ ] ;~ Global $sMicroSeconds = DllStructCreate("int64 100;int64 200") ;~ DllStructSetData($sMicroSeconds, 1, -10) ;~ DllStructSetData($sMicroSeconds, 2, -20) ;~ Global $1MS = DllStructGetPtr($sMicroSeconds, 1);very short sleep calls to keep CPU low when enumerating process handles ;~ Global $2MS = DllStructGetPtr($sMicroSeconds, 2) Global $HasIconResource = 0 Global $hResEnumProc Global $OwnerPrivilages = 0 Global $FileObject = 0 Global $ListView1 Global $StatusBar1 Global $progress Global $hProgress Global $GUIMINWID = 592; Resizing / minimum width Global $GUIMINHT = 465; Resizing / minimum hight Global Const $WS_RESIZABLE = 0x00070000 Global $hGUI Global Const $DUPLICATE_CLOSE_SOURC = 0x00000001 #endregion - Globals - _Main(FileSelectFolder('', '')) Func _Main($BaseLocation) If Not FileExists($BaseLocation) Then Terminate() AutoItSetOption("GUIOnEventMode", 1) #region - GUI - $hGUI = GUICreate("AutoIt - UnLocker", $GUIMINWID, $GUIMINHT, -1, -1, BitOR($WS_RESIZABLE, $WS_CAPTION, $WS_POPUP)) GUISetOnEvent(-3, "Terminate") If Not $Compiled Then GUISetIcon("Unlocker.ico") $StatusBar1 = _GUICtrlStatusBar_Create($hGUI) Local $StatusBar1_PartsWidth[4] = [100, 350, 99999, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "Status: Idle", 0) $progress = GUICtrlCreateProgress(0, 0, -1, -1) $hProgress = GUICtrlGetHandle($progress) _GUICtrlStatusBar_EmbedControl($StatusBar1, 2, $hProgress) _GUICtrlStatusBar_SetMinHeight($StatusBar1, 20) $ListView1 = GUICtrlCreateListView("Process|Path Locked|PID|Handle|Process Path", 8, 8, 577, 401) GUICtrlSetOnEvent(-1, "SortIt") GUICtrlSetResizing(-1, 102) _GUICtrlListView_RegisterSortCallBack($ListView1) DllCall($hUSER32, "lresult", "SendMessageW", "hwnd", GUICtrlGetHandle($ListView1), "uint", 0x1000 + 30, "wparam", 0, "lparam", 85) DllCall($hUSER32, "lresult", "SendMessageW", "hwnd", GUICtrlGetHandle($ListView1), "uint", 0x1000 + 30, "wparam", 1, "lparam", 200) DllCall($hUSER32, "lresult", "SendMessageW", "hwnd", GUICtrlGetHandle($ListView1), "uint", 0x1000 + 30, "wparam", 3, "lparam", 50) DllCall($hUSER32, "lresult", "SendMessageW", "hwnd", GUICtrlGetHandle($ListView1), "uint", 0x1000 + 30, "wparam", 4, "lparam", 200) GUICtrlCreateButton("Quit", 528, 416, 57, 22) GUICtrlSetOnEvent(-1, "Terminate") GUICtrlSetResizing(-1, 768 + 4 + 64) GUICtrlCreateButton("Unlock All", 440, 416, 81, 22) GUICtrlSetOnEvent(-1, "UnlockAll") GUICtrlSetResizing(-1, 768 + 4 + 64) _GuiCtrlSetTip(-1, "Will unlock all items in the list view, use with caution!", "Warning!", @ScriptFullPath & ",99", 3, 0x000000, 0xFFFF00, 1000) GUICtrlCreateButton("Unlock", 368, 416, 65, 22) GUICtrlSetOnEvent(-1, "Unlock") GUICtrlSetResizing(-1, 768 + 4 + 64) GUICtrlCreateButton("Kill Process", 280, 416, 81, 22) GUICtrlSetOnEvent(-1, "_ProcessClose") GUICtrlSetResizing(-1, 768 + 4 + 64) _GuiCtrlSetTip(-1, "Take coution not to terminate a critical process!", "Warning!", @ScriptFullPath & ",99", 3, 0x000000, 0xFF0000, 1000) Local $Context = GUICtrlCreateContextMenu($ListView1) GUICtrlCreateMenuItem("Unlock", $Context) GUICtrlSetOnEvent(-1, "Unlock") GUICtrlCreateMenuItem("Terminate", $Context) GUICtrlSetOnEvent(-1, "_ProcessClose") GUIRegisterMsg(0x0024, "WM_GETMINMAXINFO") GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE") GUISetState() #endregion - GUI - AdjustPrivilege(20) Local $aHandles = _ListHwnds(0, $Is64);change second parameter to true in order to skip critical system files. ;Local $aModuals = _ProcessListModules() If @error Then Exit MsgBox(16, "Error Code: " & @error & " Extended: " & @extended, "The application has encounterd an error and will now close, sorry for the inconvenience.", 0, $hGUI) If UBound($aHandles) < 1 Then Exit MsgBox(64, "Advisory", "No handles seem to have been fetched during the process, the application will now close.", 0, $hGUI) Local $Datum Local $Entry = 0 Local $Temp Local $Size = UBound($aHandles) - 1 Local $Items = 0 _GUICtrlStatusBar_SetText($StatusBar1, "Stage 4 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Building List...", 1) For $I = 0 To $Size ;If Random(0,5,1) = 3 Then DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $2MS) GUICtrlSetData($progress, 100 * $I / $Size) If StringInStr($aHandles[$I][2], $BaseLocation, 2) Then $Datum = _ProcessGetPath($aHandles[$I][0]) ;$aHandles[$I][0] $Temp = $Datum $Datum = StringSplit($Datum, "\") $Entry = $Datum[$Datum[0]] & "|" & $aHandles[$I][2] & "|" & $aHandles[$I][0] & "|" & String($aHandles[$I][1]) & "|" & $Temp If $Is64 Then GUICtrlCreateListViewItem($Entry, $ListView1) Else _CheckIconResource($Temp, GUICtrlCreateListViewItem($Entry, $ListView1)) EndIf $Items += 1 EndIf Next GUICtrlSetData($progress, 0) If Not $Is64 Then _GUICtrlStatusBar_SetText($StatusBar1, "Stage 5 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Discovering Dlls...", 1) $aHandles = _ListModules() $Size = UBound($aHandles) - 1 _GUICtrlStatusBar_SetText($StatusBar1, "Stage 6 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Building List...", 1) For $I = 0 To $Size ;If Random(0,5,1) = 3 Then DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $2MS) GUICtrlSetData($progress, 100 * $I / $Size) If $aHandles[$I][4] = 65535 Then ContinueLoop If StringInStr($aHandles[$I][1], $BaseLocation, 2) Then $Datum = _ProcessGetPath($aHandles[$I][2]) ;$aHandles[$I][0] $Temp = $Datum $Datum = StringSplit($Datum, "\") $Entry = "*" & $Datum[$Datum[0]] & "|" & $aHandles[$I][1] & "|" & $aHandles[$I][2] & "|" & String($aHandles[$I][3]) & "|" & $Temp ; signify dll _CheckIconResource($Temp, GUICtrlCreateListViewItem($Entry, $ListView1)) $Items += 1 EndIf Next GUICtrlSetData($progress, 0) EndIf _GUICtrlStatusBar_SetText($StatusBar1, "Status: Idle", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Listing " & $Items & " item(s)", 1) Sleep(999999999) Exit EndFunc ;==>_Main #region - EVENTS - Func _ProcessClose() Local $Temp Local $Data = FetchListViewEntry($ListView1, 3) If @error Then Return If ProcessClose($Data[0]) Then GUICtrlDelete($Data[1]) Local $ItemCount = _GUICtrlListView_GetItemCount($ListView1) For $I = 0 To $ItemCount GUICtrlSetData($progress, 100 * $I / $ItemCount) $Temp = _GUICtrlListView_GetItemText($ListView1, $I, 2) If (Int($Temp) = Int($Data[0])) Then _GUICtrlListView_DeleteItem($ListView1, $I) $I = 0 EndIf Next GUICtrlSetData($progress, 0) EndFunc ;==>_ProcessClose Func UnlockAll() Switch MsgBox(3 + 48 + 256 + 262144, "Warning!", "This is not recomended! This can also take a long time, continue?", 0, $hGUI) Case 6 Local $ItemCount = _GUICtrlListView_GetItemCount($ListView1) Local $PID Local $Handle Local $Stolen Local $Name Local $Test[2] $CurrentProcess = DllCall($hKERNEL32, "handle", "GetCurrentProcess") Beep(100,100) For $I = 0 To $ItemCount GUICtrlSetData($progress, 100 * $I / $ItemCount) $Name = _GUICtrlListView_GetItemText($ListView1, $I, 0) $PID = _GUICtrlListView_GetItemText($ListView1, $I, 2) $Handle = _GUICtrlListView_GetItemText($ListView1, $I, 3) Switch StringLeft($Name, 1) Case "*" $Test[0] = _ProcessListModulesCount($PID) _UnloadDll($PID, $Handle) $Test[1] = _ProcessListModulesCount($PID) Switch ($Test[0] <> $Test[1]) Case True _GUICtrlListView_DeleteItem($ListView1,$I) EndSwitch Case Else $ProcessHwnd = DllCall("Kernel32.dll", "ptr", "OpenProcess", "dword", $PROCESS_DUP_HANDLE, "int", 0, "dword", $PID) If @error Or Not $ProcessHwnd[0] Then ContinueLoop $ProcessHwnd = $ProcessHwnd[0] $Stolen = DllCall($hKERNEL32, "int", _ "DuplicateHandle", _ "ptr", $ProcessHwnd, _ "ptr", $Handle, _ "ptr", $CurrentProcess[0], _ "ptr", 0, _ "dword", 2, _ "int", 0, _ "dword", $DUPLICATE_CLOSE_SOURC _ ) If Not @error Then; And Not $Stolen[0] Then ; I don't get why the return value is zero even though it works :/ _GUICtrlListView_DeleteItem($ListView1,$I) DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $Stolen[4]) EndIf DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $ProcessHwnd) EndSwitch Next DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $CurrentProcess[0]) GUICtrlSetData($progress, 0) Return Case Else Return EndSwitch EndFunc ;==>UnlockALl Func Unlock() Local $Stolen Local $Return = FetchListViewEntry($ListView1, 4) Local $Ext = FetchListViewEntry($ListView1, 3) Local $Name = FetchListViewEntry($ListView1, 1, 0) Local $Test[2] Local $temporariis[3] If @error Then Return 0 Switch StringLeft($Name, 1) Case "*" $Test[0] = _ProcessListModulesCount($Ext[0]) _UnloadDll($Ext[0], $Return[0]) $Test[1] = _ProcessListModulesCount($Ext[0]) Switch ($Test[0] <> $Test[1]) Case True $temporariis[0] = FetchListViewEntry($ListView1, 1, 0) $temporariis[1] = FetchListViewEntry($ListView1, 2, 0) $temporariis[2] = FetchListViewEntry($ListView1, 3, 0) GUICtrlSetData($Return[1], $temporariis[0] & "|" & $temporariis[1] & "|" & $temporariis[2] & "|CLOSED!") GUICtrlSetBkColor($Return[1], 0x00FF00) Case Else GUICtrlSetBkColor($Return[1], 0xFF0000) EndSwitch Case Else $CurrentProcess = DllCall($hKERNEL32, "handle", "GetCurrentProcess") $ProcessHwnd = DllCall("Kernel32.dll", "ptr", "OpenProcess", "dword", $PROCESS_DUP_HANDLE, "int", 0, "dword", $Ext[0]) If @error Or Not $ProcessHwnd[0] Then DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $CurrentProcess[0]) GUICtrlSetBkColor($Return[1], 0xFF0000) Return EndIf $ProcessHwnd = $ProcessHwnd[0] $Stolen = DllCall($hKERNEL32, "int", _; no need to check for errors here since we already have access for doing this "DuplicateHandle", _ "ptr", $ProcessHwnd, _ "ptr", $Return[0], _ "ptr", $CurrentProcess[0], _ "ptr", 0, _ "dword", 2, _ "int", 0, _ "dword", $DUPLICATE_CLOSE_SOURC _ ) If Not @error Then; And Not $Stolen[0] Then ; I don't get why the return value is zero even though it works :/ $Stolen = $Stolen[4] DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $ProcessHwnd) DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $Stolen) $temporariis[0] = FetchListViewEntry($ListView1, 1, 0) $temporariis[1] = FetchListViewEntry($ListView1, 2, 0) $temporariis[2] = FetchListViewEntry($ListView1, 3, 0) GUICtrlSetData($Return[1], $temporariis[0] & "|" & $temporariis[1] & "|" & $temporariis[2] & "|CLOSED!") GUICtrlSetBkColor($Return[1], 0x00FF00) Else GUICtrlSetBkColor($Return[1], 0xFF0000) EndIf EndSwitch Return 0 EndFunc ;==>Unlock Func SortIt() _GUICtrlListView_SortItems($ListView1, GUICtrlGetState($ListView1)) EndFunc ;==>SortIt #endregion - EVENTS - #region - Main - ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ListHwnds ; Description ...: Returns a list of obtainable handles in a specified process, some handles cannot be obtained. This is limited ; to directories only! In order to unlock files in use, I'd recommend an application like the well known ; "unlocker.exe" that uses a kernel mode driver to handle this. ; Syntax ........: _ListHwnds([$PID = 0[, $IgnoreSys = 0[, $FileObject]]]) ; Parameters ....: $PID - [optional] PID of process to retrieve hwnds from. Default is 0, which is all processes. ; $IgnoreSys - [optional] True to ignore system files, false otherwise. Default is false. ; $FileObject - [Internal] Ignore this parameter, it is used only by the function. ; Return values .: An array of hwnds and process inforamtion. ; Authors .......: Yashied, monoceres, wraithdu, Manko, THAT1ANONYMOUSDUDE ; Modified ......: ; Remarks .......: This function is a compilation of different peoples code, a lot of yashideds winapiex code ; was taken to create this, the reason I took functions apart and created this frankenstein-ish function ; is for speed, I must also give credit to everyone listed in Authors because I have also taken bits and ; snips of code from them. I noticed that this was too slow when including winapiex.au3 so I took apart ; the things that were needed and the end result was this function which is monsterously faster than before. ; ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/139347-autoit-unlocker/ ; http://www.autoitscript.com/forum/topic/83145-basic-file-unlocker/page__st__20 ; http://www.autoitscript.com/forum/topic/84939-prodller-unknown-code-running-befriend-or-kill/page__view__findpost__p__703384 ; ; Example .......: No ; =============================================================================================================================== Func _ListHwnds($PID = 0, $IgnoreSys = 0, $FileObject = 0) If $FileObject = 0 Then If Not IsArray($FileObject) Then $FileObject = _ListHwnds(False, False, -1) If @error Then Return SetError(1, @error, 0) EndIf EndIf Local $tSHI Local $tHandle Local $pData Local $Ret Local $Size Local $ResultCount Local $IgnoreList Local $temporariis Local $OS Switch @OSVersion Case "WIN_XP", "WIN_7" $OS = 1 EndSwitch $tSHI = DllStructCreate('ulong;byte[4194304]') $Ret = DllCall($hNTDLL, 'uint', 'NtQuerySystemInformation', 'uint', 16, 'ptr', DllStructGetPtr($tSHI), 'ulong', DllStructGetSize($tSHI), 'ulong*', 0) If @error Then Return SetError(2, 0, 0) Else If $Ret[0] Then Return SetError(3, 0, 0) EndIf EndIf Local $Status, $Op $pData = DllStructGetPtr($tSHI, 2) ;$Size = DllStructGetSize(DllStructCreate('ulong;ubyte;ubyte;ushort;ptr;ulong')) #region - Globalization - If $FileObject = -1 Then _GUICtrlStatusBar_SetText($StatusBar1, "Stage 1 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Discovering object types...", 1) Local $aObject[1][2] #cs In an attempt to make this globally operable with on a multitude of varying operating system types I have taken the approach of discovering the system file object type by using this code below in order to avoid depending on a static value that may not be accurate. #CE Local $tPOTI = DllStructCreate('ushort;ushort;ptr;byte[128]') $Status = DllStructGetData($tSHI, 1) For $I = 1 To $Status GUICtrlSetData($progress, 100 * $I / $Status) ;If Random(0,5,1) = 3 Then DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $1MS) If $Is64 Then $OP = 4 + ($i - 1) * 24 Else $OP = ($i - 1) * 16 EndIf $tHandle = DllStructCreate('align 4;ulong;ubyte;ubyte;ushort;ptr;ulong', $pData + $OP) If DllStructGetData($tHandle, 1) <> @AutoItPID Then ContinueLoop; only search our process for now $temporariis = Ptr(DllStructGetData($tHandle, 4)) Local $Ret2 = DllCall($hNTDLL, 'uint', 'NtQueryObject', 'ptr', $temporariis, 'uint', 2, 'ptr', DllStructGetPtr($tPOTI), 'ulong', DllStructGetSize($tPOTI), 'ptr', 0) If @error Then ContinueLoop;I figured we don't need to return any errors, we can still continue without fear here. ;Return SetError(4, 0, 0) Else If $Ret2[0] Then ContinueLoop ;Return SetError(5, 0, 0) EndIf EndIf ;DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $1MS) Local $pData2 = DllStructGetData($tPOTI, 3) If Not $pData2 Then ContinueLoop ;Return SetError(6, 0, 0) EndIf Local $Length = DllCall($hKERNEL32, 'int', 'lstrlenW', 'ptr', $pData2) If @error Then ContinueLoop ;Return SetError(7, 0, 0) EndIf $Length = $Length[0] If @error Then ContinueLoop ;Return SetError(8, 0, 0) EndIf If Not $Length Then ContinueLoop ;Return SetError(9, 0, 0) EndIf Local $tString = DllStructCreate('wchar[' & ($Length + 1) & ']', $pData2) If @error Then ContinueLoop ;Return SetError(10, 0, 0) EndIf If DllStructGetData($tString, 1) == "File" Then; Or DllStructGetData($tString, 1) == "Process" Then;we found the type needed ;I believe we can't really do anything with process objects so I may remove this part in the furure. For $M = 0 To UBound($aObject) - 1 If $aObject[$M][0] == DllStructGetData($tHandle, 2) Then ContinueLoop (2); for some reason I get an error here when using continueloop Next $aObject[0][0] = DllStructGetData($tHandle, 2);return it so we can use it to find them $aObject[0][1] = DllStructGetData($tString, 1) Return SetError(0, 0, $aObject) EndIf Next Return SetError(13, 0, 0) EndIf #endregion - Globalization - Local $CurrentPID Local $iTotalHandles Local $Result[99999][4] If $IgnoreSys Then For $I = 0 To UBound($Critical) - 1 $temporariis = ProcessList($Critical[$I]) For $x = 1 To $temporariis[0][0] $IgnoreList &= $temporariis[$x][1] & "|" Next Next EndIf ;~ If $PID Then ;~ Local $pHandle = DllCall($hKERNEL32, "ptr", "OpenProcess", "int", 0x1F0FFF, "int", 0, "int", $PID) ;~ $iTotalHandles = DllCall($hKERNEL32,"int","GetProcessHandleCount","ptr",$pHandle[0],"DWORD*",0) ;~ DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $pHandle[0]) ;~ $iTotalHandles = $iTotalHandles[2] ;~ Else ;~ Local $tPI = DllStructCreate($TagPERFORMANCE_INFORMATION) ;~ DllCall($hPSAPI, 'int', 'GetPerformanceInfo', 'ptr', DllStructGetPtr($tPI), 'dword', DllStructGetSize($tPI)) ;~ $iTotalHandles = DllStructGetData($tPI, 12) ;~ EndIf $Status = DllStructGetData($tSHI, 1) _GUICtrlStatusBar_SetText($StatusBar1, "Stage 2 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Filtering...", 1) For $I = 1 To $Status GUICtrlSetData($progress, 100 * $I / $Status) If $Is64 Then $OP = 4 + ($i - 1) * 24 Else $OP = ($i - 1) * 16 EndIf $tHandle = DllStructCreate('align 4;ulong;ubyte;ubyte;ushort;ptr;ulong', $pData + $OP) $CurrentPID = DllStructGetData($tHandle, 1) If $CurrentPID <> 0 And $CurrentPID <> 4 Then If $PID Then If Not ($CurrentPID == $PID) Then ContinueLoop EndIf If $IgnoreSys Then If StringInStr($IgnoreList, $CurrentPID, 2) <> 0 Then ContinueLoop EndIf #region - Danger Zone - ;We need to avoid these attributes or we will freeze indefinately. $temporariis = DllStructGetData($tHandle, 6) If $temporariis == 0x00120189 Then ContinueLoop If $temporariis == 0x0012019f Then ContinueLoop If $temporariis == 0x00100000 Then ContinueLoop If $OS Then If Not 0x00100020 == $temporariis Then ContinueLoop Else ;Just include it since I don't really know what I should be looking for on any other OS... EndIf ;If Random(0,5,1) = 3 Then DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $1MS) #endregion - Danger Zone - $Ret = DllStructGetData($tHandle, 2) If $Ret = $FileObject[0][0] Then $ResultCount += 1 ;ReDim $Result[$ResultCount + 1][4] $Result[$ResultCount - 1][0] = $CurrentPID $Result[$ResultCount - 1][1] = Ptr(DllStructGetData($tHandle, 4)) $Result[$ResultCount - 1][2] = DllStructGetData($tHandle, 2) ;If CloseHandle($CurrentPID,Ptr(DllStructGetData($tHandle, 4))) Then ConsoleWrite(DllStructGetData($tHandle, 2) & @CR); Don't do it D: EndIf EndIf Next If Not $ResultCount Then Return SetError(11, 0, 0) Else ReDim $Result[$ResultCount][3] EndIf Local $hSource Local $hObject Local $TempDat[99999][3] Local $TempCount Local $LastPID Local $hTarget = DllCall($hKERNEL32, "handle", "GetCurrentProcess") If @error Then Return SetError(14, 0, 0) $hTarget = $hTarget[0] Local $struct = DllStructCreate("char[255];") Local $Temp = DriveGetDrive("ALL") Local $drivesinfo[UBound($Temp) - 1][2] For $I = 0 To UBound($drivesinfo) - 1 $drivesinfo[$I][0] = $Temp[$I + 1] DllCall($hKERNEL32, "dword", "QueryDosDevice", "str", $drivesinfo[$I][0], "ptr", DllStructGetPtr($struct), "dword", 255) $drivesinfo[$I][1] = DllStructGetData($struct, 1) Next Local $PUBLIC_OBJECT_TYPE_INFORMATION = "ushort Length;" & _ "ushort MaximumLength;" & _ "ptr Buffer;" & _ ;UNICODE_STRING struct "wchar Reserved[260];" Local $poti = DllStructCreate($PUBLIC_OBJECT_TYPE_INFORMATION) Local $devicestr Local $Solid $iTotalHandles = UBound($Result) - 1 _GUICtrlStatusBar_SetText($StatusBar1, "Stage 3 of 6", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Resolving Objects...", 1) For $I = 0 To $iTotalHandles GUICtrlSetData($progress, 100 * $I / $iTotalHandles) If Not $LastPID Or $Result[$I][0] <> $LastPID Then If $LastPID Then DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $hSource) $hSource = DllCall($hKERNEL32, 'int', "OpenProcess", "int", $PROCESS_DUP_HANDLE, "int", 0, "int", $Result[$I][0]) If @error Then ContinueLoop $hSource = $hSource[0] $LastPID = $Result[$I][0] EndIf $hObject = DllCall($hKERNEL32, _;there is a small chance that we can freeze here... "bool", "DuplicateHandle", _; if we do freeze here, our script can only be killed by "handle", $hSource, _; killing the process that we tried to hijack a handle from. "handle", $Result[$I][1], _ "handle", $hTarget, _ "handle*", 0, _ "dword", 0, _ "bool", 0, _ "dword", $DUPLICATE_SAME_ACCESS _ ) If @error Then ContinueLoop $hObject = $hObject[4] $Solid = False If $Result[$I][2] = $FileObject[0][0] Then DllCall($hNTDLL, "ulong", "NtQueryObject", "ptr", $hObject, "int", 1, "ptr", DllStructGetPtr($poti), "ulong", DllStructGetSize($poti), "ulong*", "") $devicestr = DllStructCreate("wchar[" & Ceiling(DllStructGetData($poti, "Length") / 2) & "];", DllStructGetData($poti, "buffer")) $devicestr = DllStructGetData($devicestr, 1) For $y = 0 To UBound($drivesinfo) - 1 If StringLeft($devicestr, StringLen($drivesinfo[$y][1])) = $drivesinfo[$y][1] Then $Solid = StringUpper($drivesinfo[$y][0]) & StringTrimLeft($devicestr, StringLen($drivesinfo[$y][1])) ExitLoop EndIf Next Else $Solid = DllCall("kernel32.dll", "int", "GetProcessId", "hwnd", $hObject) If Not @error Then $Solid = _ProcessGetPath($Solid[0]) Else $Solid = "N/A" EndIf EndIf ;If Random(0,5,1) = 3 Then DllCall($hNTDLL, "dword", "NtDelayExecution", "int", 0, "ptr", $1MS) ; uncomment to save CPU resources If $Solid Then $TempCount += 1 ;ReDim $TempDat[$TempCount + 1][3] $TempDat[$TempCount - 1][0] = $Result[$I][0];pid $TempDat[$TempCount - 1][1] = $Result[$I][1];hwnd $TempDat[$TempCount - 1][2] = $Solid EndIf DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $hObject) Next DllCall($hKERNEL32, 'ptr', 'CloseHandle', 'ptr', $hSource) GUICtrlSetData($progress, 0) If $TempCount Then ReDim $TempDat[$TempCount][3] Return SetError(0, 0, $TempDat) Else Return SetError(12, 0, 0) EndIf EndFunc ;==>_ListHwnds ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProcessListModules ; Description ...: Returns loaded dlls in a process ; Syntax ........: _ProcessListModules($dwPID) ; Parameters ....: $dwPID - Process ID. ; Return values .: Array with lots of info ; Author ........: Smoke_N ; Example .......: No ; =============================================================================================================================== Func _ListModules() ;If $dwPID = 0 Or $dwPID = 4 Then Return @error Local $modlist[99999][7] Local $iAdd = 0 Local Const $TH32CS_SNAPMODULE = 0x08 Local $Plist = ProcessList() For $x = 1 To $Plist[0][0] GUICtrlSetData($progress, 100 * $x / $Plist[0][0]) If Not $Plist[$x][1] Or $Plist[$x][1] = 4 Then ContinueLoop Local $aDLLCall = DllCall($hKERNEL32, "ptr", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPMODULE, "dword", $Plist[$x][1]) Local $hModuleSnap = $aDLLCall[0] Local $tagMODULEENTRY32 = DllStructCreate("dword;dword;dword;dword;dword;byte;dword;ptr;char[256];char[257]") DllStructSetData($tagMODULEENTRY32, 1, DllStructGetSize($tagMODULEENTRY32)) $aDLLCall = DllCall($hKERNEL32, "int", "Module32First", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) $aDLLCall = DllCall($hKERNEL32, "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) While 1 If Not $aDLLCall[0] Then ExitLoop While 1 ;~ typedef struct tagMODULEENTRY32 { ;$avArray[$iAdd][0] = DllStructGetData($tagMODULEENTRY32, 1) ;~ DWORD dwSize; ;$avArray[$iAdd][1] = DllStructGetData($tagMODULEENTRY32, 2) ;~ DWORD th32ModuleID; $modlist[$iAdd][2] = DllStructGetData($tagMODULEENTRY32, 3) ;~ DWORD th32ProcessID; ;$avArray[$iAdd][3] = DllStructGetData($tagMODULEENTRY32, 4) ;~ DWORD GlblcntUsage; $modlist[$iAdd][4] = DllStructGetData($tagMODULEENTRY32, 5) ;~ DWORD ProccntUsage; ;$avArray[$iAdd][5] = DllStructGetData($tagMODULEENTRY32, 6) ;~ BYTE * modBaseAddr; ;$modlist[$iAdd][2] = DllStructGetData($tagMODULEENTRY32, 7) ;~ DWORD modBaseSize; $modlist[$iAdd][3] = DllStructGetData($tagMODULEENTRY32, 8) ;~ HMODULE hModule; $modlist[$iAdd][0] = DllStructGetData($tagMODULEENTRY32, 9) ;~ char szModule[MAX_MODULE_NAME32 + 1]; $modlist[$iAdd][1] = StringLower(DllStructGetData($tagMODULEENTRY32, 10));~ char szExePath[MAX_PATH]; ;~ } MODULEENTRY32; $aDLLCall = DllCall($hKERNEL32, "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) $iAdd += 1 If Not $aDLLCall[0] Then ExitLoop 2 WEnd WEnd Next ReDim $modlist[$iAdd][5] GUICtrlSetData($progress, 0) DllCall($hKERNEL32, "int", "CloseHandle", "ptr", $hModuleSnap) Return $modlist EndFunc ;==>_ListModules Func _ProcessListModulesCount($dwPID) Local $iAdd = 0 Local Const $TH32CS_SNAPMODULE = 0x08 Local $aDLLCall = DllCall($hKERNEL32, "ptr", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPMODULE, "dword", $dwPID) Local $hModuleSnap = $aDLLCall[0] Local $tagMODULEENTRY32 = DllStructCreate("dword;dword;dword;dword;dword;byte;dword;ptr;char[256];char[257]") DllStructSetData($tagMODULEENTRY32, 1, DllStructGetSize($tagMODULEENTRY32)) $aDLLCall = DllCall($hKERNEL32, "int", "Module32First", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) $aDLLCall = DllCall($hKERNEL32, "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) If $aDLLCall[0] Then While 1 $aDLLCall = DllCall($hKERNEL32, "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32)) $iAdd += 1 If Not $aDLLCall[0] Then ExitLoop WEnd EndIf DllCall($hKERNEL32, "int", "CloseHandle", "ptr", $hModuleSnap) Return $iAdd EndFunc ;==>_ProcessListModulesCount ; #FUNCTION# ==================================================================================================================== ; Name ..........: _UnloadDll ; Description ...: Unloads a dll from the given process ; Syntax ........: _UnloadDll($PID, $hMod[, $tries = 20]) ; Parameters ....: $PID - Process ID. ; $hMod - A handle value of the dll in the process. ; $tries - [optional] Number of attempts to try. Default is 20. ; Return values .: None ; Author ........: Manko? ; Example .......: No ; =============================================================================================================================== Func _UnloadDll($PID, $hMod, $tries = 20) Local $hThread Local $pHandle = DllCall($hKERNEL32, "int", "OpenProcess", "int", BitOR($PROCESS_CREATE_THREAD, $PROCESS_QUERY_INFORMATION, $PROCESS_VM_OPERATION, $PROCESS_VM_WRITE, $PROCESS_VM_READ), "int", 0, "int", $PID) Local $modHandle = DllCall($hKERNEL32, "long", "GetModuleHandle", "str", "kernel32.dll") Local $FreeLibrary = DllCall($hKERNEL32, "long", "GetProcAddress", "long", $modHandle[0], "str", "FreeLibrary") For $I = 1 To $tries $hThread = DllCall($hKERNEL32, "int", "CreateRemoteThread", "int", $pHandle[0], "int", 0, "int", 0, "long", $FreeLibrary[0], "long", $hMod, "int", 0, "int", 0) DllCall($hKERNEL32, "int", "CloseHandle", "int", $hThread[0]) Next DllCall($hKERNEL32, "int", "CloseHandle", "int", $modHandle[0]) DllCall($hKERNEL32, "int", "CloseHandle", "int", $pHandle[0]) Return True EndFunc ;==>_UnloadDll ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ProcessGetPath ; Description ...: Gets the image base of a process ; Syntax ........: _ProcessGetPath($vProcess) ; Parameters ....: $vProcess - Process ID. ; Return values .: Image base of given process ; Author ........: JScript, Larry, SmOke_N and mrRevoked ; Example .......: No ; =============================================================================================================================== Func _ProcessGetPath($vProcess) Local $i_PID, $aProcessHandle, $tDLLStruct, $iError, $sProcessPath $i_PID = ProcessExists($vProcess) If Not $i_PID Then Return SetError(1, 0, "");process doesn't exist? $aProcessHandle = DllCall($hKERNEL32, "int", "OpenProcess", "int", $PROCESS_QUERY_INFORMATION + $PROCESS_VM_READ, "int", 0, "int", $i_PID) $iError = @error If $iError Or $aProcessHandle[0] = 0 Then Return SetError(2, $iError, "");openprocess failed EndIf $tDLLStruct = DllStructCreate("char[1000]") DllCall($hPSAPI, "long", "GetModuleFileNameEx", "int", $aProcessHandle[0], "int", 0, "ptr", DllStructGetPtr($tDLLStruct), "long", DllStructGetSize($tDLLStruct)) $iError = @error DllCall($hKERNEL32, "int", "CloseHandle", "int", $aProcessHandle[0]) If $iError Then $tDLLStruct = 0 Return SetError(4, $iError, "");getmodulefilenamex failed EndIf $sProcessPath = DllStructGetData($tDLLStruct, 1) $tDLLStruct = 0;format the output If StringLen($sProcessPath) < 2 Then Return SetError(5, 0, "");is empty or non readable If StringLeft($sProcessPath, 4) = "\??\" Then $sProcessPath = StringReplace($sProcessPath, "\??\", "") If StringLeft($sProcessPath, 20) = "\SystemRoot\System32" Then $sProcessPath = StringReplace($sProcessPath, "\SystemRoot\System32", @SystemDir) Return SetError(0, 0, $sProcessPath) EndFunc ;==>_ProcessGetPath Func AdjustPrivilege($Type) Local $aReturn = DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", $Type, "int", 1, "int", 0, "int*", 0) If @error Or $aReturn[0] Then Return SetError(1, 0, 0) Return SetError(0, 0, 1) EndFunc ;==>AdjustPrivilege #endregion - Main - #region - Find Icon - #CS This section is used to check if a file has resources in order to display them in the list view controls. #CE Func _CheckIconResource($Host, $CTRL) If Not FileExists($Host) Then GUICtrlSetImage($CTRL, "shell32.dll", 3, 0) If _CheckIcon($Host) Then Return GUICtrlSetImage($CTRL, $Host, 0, 0) GUICtrlSetImage($CTRL, "shell32.dll", 3, 0) Return EndFunc ;==>_CheckIconResource Func _CheckIcon($hModule) Local $Loaded = 1 $hModule = _WinAPI_LoadLibraryEx($hModule, 0x00000003) If Not $hModule Then Return SetError(1, 0, 0) $hResEnumProc = DllCallbackRegister('_EnumResTypesProc', 'int', 'ptr;ptr;long_ptr') DllCall('kernel32.dll', 'int', 'EnumResourceTypesW', 'ptr', $hModule, 'ptr', DllCallbackGetPtr($hResEnumProc), 'long_ptr', 0) DllCallbackFree($hResEnumProc) If $Loaded Then _WinAPI_FreeLibrary($hModule) If Not $HasIconResource Then Return 0 $HasIconResource = 0 Return 1 EndFunc ;==>_CheckIcon Func _EnumResTypesProc($hModule, $iType, $lParam) If Number($iType) = 14 Then $HasIconResource = 1 DllCallbackFree($hResEnumProc) EndIf Return 1 EndFunc ;==>_EnumResTypesProc #endregion - Find Icon - #region - Misc - ; #FUNCTION# ==================================================================================================================== ; Name ..........: FetchListViewEntry ; Description ...: Gets the list view sub item information ; Syntax ........: FetchListViewEntry($Hndl, $Item) ; Parameters ....: $Hndl - List view control handle. ; $Item - List view item to grab starting at 1. ; Return values .: An array with the list view control item handle and its text. ; - Index 0 is the item text ; - Index 1 is the handle ; Sets @error to a positive value if function failed. ; ; Author ........: THAT1ANONYMOUSDUDE ; Example .......: No ; =============================================================================================================================== Func FetchListViewEntry($Hndl, $Item, $Array = 1) If Not IsNumber($Item) Then Return SetError(1, 0, 0) $Item = $Item - 1 Local $String = GUICtrlRead(GUICtrlRead($Hndl)) Local $M = StringSplit($String, "|", 2) If @error Then Return SetError(2, 0, 0) If $Array Then Local $Ret[2] = [$M[$Item], GUICtrlRead($Hndl)] Else Return $M[$Item] EndIf Return $Ret EndFunc ;==>FetchListViewEntry ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GuiCtrlSetTip ; Description ...: Easy to use wrapper for the GUIToolTip UDF. ; Syntax ........: _GuiCtrlSetTip($hControl, $sText[, $sTitle = ""[, $iIcon = 0[, $iOptions = 0[, $iBackGroundColor = -1[, ; $itextColor = -1[, $iDelay = 500]]]]]]) ; Parameters ....: $hControl - A handle to the control, use -1 to assign to the last recently created control. ; $sText - Tip text that will be displayed when the mouse is hovered over the control. ; $sTitle - [optional] The title for the tooltip Requires IE5+ ; $iIcon - [optional] Pre-defined icon to show next to the title: Requires IE5+. Requires a title. ; | 0 = No icon ; | 1 = Info icon ; | 2 = Warning icon ; | 3 = Error Icon ; | - This parameter can also be a string in the below example format~ ; | [@WindowsDir & "\Explorer.exe,100"] where 100 is the icon index in the file that ; | contains the icon resource to use, this can be any file with icon resources. ; $iOptions - [optional] Sets different options for how the tooltip will be displayed ; | (Can be added together): ; | 1 = Display as Balloon Tip Requires IE5+ ; | 2 = Center the tip horizontally along the control. ; $iBackGroundColor - [optional] A hex RGB color value to use for the tip background color. ; $itextColor - [optional] A hex RGB color value to use for the tip text color. ; $iDelay - [optional] A positive vale in miliseconds to set the tips delay time. Default is 500. ; Return values .: The newly created tooltip handle ; Author ........: THAT1ANONYMOUSDUDE ; Modified ......: ; Remarks .......: Just a wrapper for the GUIToolTip UDF. ; Related .......: None ; Link ..........: ; Example .......: _GUICtrlSetTip(-1,"Test tip with text, title, Icon & balloon style.","Optional title",1,1) ; =============================================================================================================================== Func _GuiCtrlSetTip($hControl, $sText, $sTitle = "", $iIcon = 0, $iOptions = 0, $iBackGroundColor = -1, $itextColor = -1, $iDelay = 500) If Not IsHWnd($hControl) Then $hControl = GUICtrlGetHandle($hControl) If Not IsHWnd($hControl) Then Return SetError(1, 0, 0) If $sText = "" Then Return SetError(1, 0, 0) Local $aReturn Local $hicon Local $ExtStyle = 0 Switch $iOptions Case 0 $iOptions = 9 $ExtStyle = 0 Case 1 $iOptions = 9 $ExtStyle = $TTS_BALLOON Case 2 $iOptions = 11 $ExtStyle = 0 Case 3 $iOptions = 11 $ExtStyle = $TTS_BALLOON Case Else $iOptions = 9 EndSwitch Local $hToolTip = _GUIToolTip_Create($hControl, BitOR($ExtStyle, $TTS_ALWAYSTIP, $TTS_NOPREFIX)) _GUIToolTip_AddTool($hToolTip, 0, $sText, $hControl, 0, 0, 0, 0, $iOptions, 0) $hicon = DllStructCreate("ptr") If IsNumber($iIcon) And $iIcon <= 3 Then Switch $iIcon Case 1 $iIcon = -104 Case 2 $iIcon = -101 Case 3 $iIcon = -103 Case Else $iIcon = 0 EndSwitch If $iIcon <> 0 Then $aReturn = DllCall("Shell32.dll", "uint", "ExtractIconExW", "wstr", @SystemDir & "\user32.dll", "int", $iIcon, "ptr", 0, "ptr", DllStructGetPtr($hicon), "uint", 1) If Not @error And $aReturn[0] Then $hicon = DllStructGetData($hicon, 1) Else $hicon = 0 EndIf Else $hicon = 0 EndIf _GUIToolTip_SetTitle($hToolTip, $sTitle, $hicon) DllCall("User32.dll", "none", "DestroyIcon", "handle", $hicon) Else $iIcon = StringSplit($iIcon, ",") If $iIcon[0] > 1 Then $aReturn = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $iIcon[$iIcon[0] - 1], "int", -1 * (Int($iIcon[$iIcon[0]])), "ptr", 0, "ptr", DllStructGetPtr($hicon), "uint", 1) If Not @error And $aReturn[0] Then $hicon = DllStructGetData($hicon, 1) Else $hicon = 0 EndIf _GUIToolTip_SetTitle($hToolTip, $sTitle, $hicon) DllCall("user32.dll", "none", "DestroyIcon", "handle", $hicon) Else _GUIToolTip_SetTitle($hToolTip, $sTitle, $hicon);probably a handle EndIf EndIf If $iBackGroundColor <> -1 Or $itextColor <> -1 Then DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", "", "wstr", "") If $iBackGroundColor <> -1 Then _GUIToolTip_SetTipBkColor($hToolTip, BitAND(BitShift(String(Binary($iBackGroundColor)), 8), 0xFFFFFF)) If $itextColor <> -1 Then _GUIToolTip_SetTipTextColor($hToolTip, BitAND(BitShift(String(Binary($itextColor)), 8), 0xFFFFFF)) _GUIToolTip_SetDelayTime($hToolTip, 0, $iDelay) Return $hToolTip EndFunc ;==>_GuiCtrlSetTip Func MY_WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) _GUICtrlStatusBar_Resize($StatusBar1) AdlibRegister("FixIt", 10) Return 'GUI_RUNDEFMSG' EndFunc ;==>MY_WM_SIZE Func FixIt() AdlibUnRegister("FixIt") _GUICtrlStatusBar_EmbedControl($StatusBar1, 2, $hProgress) EndFunc ;==>FixIt Func WM_GETMINMAXINFO($hWnd, $Msg, $WPARAM, $lParam) Local $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID / 1.1) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT / 1.1) ; min Y ;DllStructSetData($tagMaxinfo, 9, @DesktopWidth); max X ;DllStructSetData($tagMaxinfo, 10, @DesktopHeight) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO #endregion - Misc - Func Terminate() GUIDelete($hGUI) OnAutoItExitUnRegister("Terminate") DllClose($hNTDLL) DllClose($hPSAPI) DllClose($hUSER32) DllClose($hKERNEL32) Exit 0 EndFunc ;==>Terminate Edited December 4, 2013 by carteblanche619 Link to comment Share on other sites More sharing options...
kylomas Posted December 4, 2013 Share Posted December 4, 2013 (edited) CB, The first script you posted does not end on my system (Win7 64bit). However, that script does NOT do anything. Define what you are trying to do and we can help. kylomas Edited December 4, 2013 by kylomas Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 (edited) My entire source code is available on GITHub, so no problem posting here...expandcollapse popup#include <Constants.au3> #include <GuiToolbar.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <IE.au3> #include <String.au3> #include <Misc.au3> ;;AutoClean Initialization $DBT_DEVICEARRIVAL = "0x00008000" GUIRegisterMsg($WM_DEVICECHANGE , "_Auto") ;;Mask Critical Errors and Exceptions with AUTO IT handler Global Const $SEM_FAILCRITICALERRORS = 1 SetErrorMode($SEM_FAILCRITICALERRORS) ; This is the line where you are telling: I'll handle possible displaying of critical errors . Here, system sends error handler to calling process ;ConsoleWrite(FileOpen("A:") & @CRLF) ; This line would create system's critical-error-handler message box for my system if I haven't called SetErrorMode passing SEM_FAILCRITICALERRORS argument ;;Setting Global Variables Global Const $hKERNEL32 = DllOpen("kernel32.dll") Global $Location, $FLocation, $Progress, $Val_Quick_Or_Full, $StatusBar Global $TAutoQuick, $TAutoFull, $TAutoDisable, $MAutoQuick, $MAutoFull, $MAutoDisable ,$AutoBtn ;Global $MAdminAlwaysEnable ,$MAdminAlwaysDisable ,$MStartupEnable ,$MStartupDisable ,$MMinimizeEnable ,$MMinimizeDisable Global $CDelete0Code = 'ping -n 0 localhost >nul & del *.ini & del *.inf & del *.lnk & ren *.vbs *.vbs.txt & del *.init & ren " " recovered & ping -n 0 localhost >nul' Global $CDelete1Code = 'ping -n 0 localhost >nul & del *.ini & del *.inf & del *.lnk & ren *.vbs *.vbs.txt & del *.init & attrib -s -h -a /s /d *.* & ren " " recovered & ping -n 0 localhost >nul' Global $CDisinfect0Code = 'ping -n 0 localhost >nul & ren *.inf *.ini.txt & ren *.ini *.ini.txt & ren *.lnk *.lnk.txt & ren *.vbs *.vbs.txt & ren *.init *.init.txt & ren " " recovered & ping -n 0 localhost >nul' Global $CDisinfect1Code = 'ping -n 0 localhost >nul & ren *.inf *.ini.txt & ren *.ini *.ini.txt & ren *.lnk *.lnk.txt & ren *.vbs *.vbs.txt & ren *.init *.init.txt & attrib -s -h -a /s /d *.* & ren " " recovered & ping -n 0 localhost >nul' Global $HideCode = 'ping -n 0 localhost >nul & attrib +s +h +a /s /d *.* & ping -n 0 localhost >nul' Global $UnhideCode = 'ping -n 0 localhost >nul & attrib -s -h -a /s /d *.* & ping -n 0 localhost >nul' Global $RemFix,$Developer,$About,$Current,$New,$Password ;Global $cScan ;;Autorun Definitions Global $_USB=0x00000004 Global $_CD=0x00000020 Global $_Network=0x00000010 Global $_RAM=0x00000040 Global $_Fixed=0x00000008 Global $_Unknown=0x00000001 Global $_Sum=0x00 ;;Set AUTO Mode If FileExists( @TempDir & "\hfv_fullscan.ini" ) Then $Val_Quick_Or_Full = 2 Else $Val_Quick_Or_Full = 1 EndIf ; FileOpen(@TempDir & "\hfv_id3.txt" ,32) ; $Image = FileRead(@TempDir & "\hfv_id3.txt") ; FileClose(-1) ; ;MsgBox(64,"Data Is",GuiCtrlRead($Image)) ; FileOpen(@TempDir & "\hfv_id3.jpg" ,2) ; FileWrite(@TempDir & "\hfv_id3.jpg",$Image) ; FileClose(-1) ;;Check Admin Privilege If IsAdmin() Then If FileExists( @SystemDir & "\win_hconfig.ini" ) Then _Main() Else FileOpen(@SystemDir & "\win_hconfig.ini" ,2) FileWrite(@SystemDir & "\win_hconfig.ini","789F8434FE870A5973820B7E32EE04CBFF98E77EA79B308585EF96EF8CFA6C29402DE189CABC6DE6042E89A3632FDCDDCA83444FFE40FF1CB3F9A711BD58CDF8C095EE4DAD94D0DC25C19E256F32A95EEE51E54D57A4EF9DD7C6CA4AB8790888") FileClose(-1) _Passwd() EndIf Else If FileExists( @SystemDir & "\win_hconfig.ini" ) Then _Main() Else $NoPass = MsgBox(52,"Warning","Password is not set for HFV Cleaner yet" & @CRLF & "To ensure security, set password by running HFV Cleaner" & @CRLF & "as an Admin or ask your system administrator to do it." & @CRLF & "Would you like to set password now?") If $NoPass = 6 Then ShellExecute(@AutoItExe, "", "", "runas") Else _Main() EndIf EndIf EndIf ;;User Password Prompt Func _Passwd() #Region ### START Koda GUI section ### Form= $FirstRun = GUICreate("First Run", 413, 90, 302, 218, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateLabel("Welcome User,", 16, 8, 77, 17) GUICtrlCreateLabel("It seems like this is the first time you ", 32, 32, 173, 17) GUICtrlCreateLabel("For Security Purpose, Kindly enter a Password", 32, 64, 221, 17) GUICtrlCreateLabel("have launched HFV Cleaner on this System", 32, 48, 215, 17) GUISetState(@SW_SHOW) ;$Config = GUICtrlCreateInput("", 264, 16, 129, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Config = GUICtrlCreateInput("", 264, 16, 129, 21, 0x21) $OK = GUICtrlCreateButton("OK", 264, 48, 131, 25) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE MsgBox(16, "Error", "You Must Enter a Password to continue") Case $nMsg = $OK Or _IsPressed("0D") $Encrypted = _StringEncrypt(1,GUICtrlRead($Config),"yourkeyhere",5) FileOpen(@SystemDir & "\win_hconfig.ini" ,2) FileWrite(@SystemDir & "\win_hconfig.ini",$Encrypted) FileClose(-1) GUIDelete ($FirstRun) _Main() EndSelect WEnd EndFunc ;==>Passwd Func _Main() #Region ### START Koda GUI section ### Form=c:\documents and settings\owner\my documents\downloads\compressed\koda\forms\hfv.kxf ;;GUI Initialization $Main = GUICreate("HFV Cleaner Pro", 521, 444, 249, 164, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) ;;$Main = GUICreate("Main", 521, 444, 249, 164, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) ;;Create a Dummy GUI ;$cScan = GUICtrlCreateDummy() ;;Storing Home Directory $Home=@ScriptDir ;;Placing Manual in Temp FileInstall("C:\HFV 4.0 Build 2013.12.01\Manual.pdf",@TempDir & "\Manual.pdf",1) ;;MENU Items $MFile = GUICtrlCreateMenu("&File") $MAdmin = GUICtrlCreateMenuItem("Run As Admin", $MFile) $MAdminAlways = GUICtrlCreateMenu("Start As Admin", $MFile) $MAdminAlwaysEnable = GUICtrlCreateMenuItem("Enable", $MAdminAlways) $MAdminAlwaysDisable = GUICtrlCreateMenuItem("Disable", $MAdminAlways) $MStartup = GUICtrlCreateMenu("Run At Startup",$Mfile) $MStartupEnable = GUICtrlCreateMenuItem("Enable", $MStartup) $MStartupDisable = GUICtrlCreateMenuItem("Disable", $MStartup) $MMinimize = GUICtrlCreateMenu("Start In Tray",$Mfile) $MMinimizeEnable = GUICtrlCreateMenuItem("Enable", $MMinimize) $MMinimizeDisable = GUICtrlCreateMenuItem("Disable", $MMinimize) $MExit = GUICtrlCreateMenuItem("Exit", $MFile) $MTools = GUICtrlCreateMenu("&Tools") $Mchangepass = GUICtrlCreateMenuItem("Change Password", $MTools) $MAuto = GUICtrlCreateMenu("AUTO", $MTools) $MAutoEnable = GUICtrlCreateMenu("Enable", $MAuto) $MAutoQuick = GUICtrlCreateMenuItem( "Quick Scan" ,$MAutoEnable) $MAutoFull = GUICtrlCreateMenuItem( "Full Scan" ,$MAutoEnable) $MAutoDisable = GUICtrlCreateMenuItem("Disable", $MAuto) $MHelp = GUICtrlCreateMenu("&Help") $MManual = GUICtrlCreateMenuItem("User Manual", $MHelp) $MAbout = GUICtrlCreateMenuItem("About", $MHelp) ;;TRAY Items Opt("TrayMenuMode", 1) $TRestore = TrayCreateItem("Restore", -1, -1, 0) $cleanUSB = TrayCreateMenu("Auto Clean USB", -1, -1, 0) $TAutoQuick = TrayCreateItem("Quick Scan", $cleanUSB, -1, 1) $TAutoFull = TrayCreateItem("Full Scan", $cleanUSB, -1, 1) $TAutoDisable = TrayCreateItem("Disable", $cleanUSB, -1, 1) $cleanDIR = TrayCreateItem("Clean a Directory", -1, -1, 0) $TAdmin = TrayCreateItem("Run As Admin", -1, -1, 0) TrayCreateItem("", -1, -1, 0) $aboutitem = TrayCreateItem("About", -1, -1, 0) $exititem = TrayCreateItem("Exit", -1, -1, 0) TraySetState() ;;App Items $Location = GUICtrlCreateInput("", 16, 32, 489, 21) $Current = GUICtrlCreateButton("Use Current Directory", 16, 64, 235, 25) $Add = GUICtrlCreateButton("Add", 264, 64, 115, 25) $Browse = GUICtrlCreateButton("Browse", 392, 64, 115, 25) $Step_1 = GUICtrlCreateGroup("Step 1 : Select Infected Directory/Directories", 8, 8, 505, 97) GUICtrlCreateGroup("", -99, -99, 1, 1) $Step_2 = GUICtrlCreateGroup("Step 2 : Pick a Mode", 8, 120, 505, 193, -1, $WS_EX_TRANSPARENT) $Mode = GUICtrlCreateTab(24, 144, 473, 153) $Cleaner = GUICtrlCreateTabItem("Cleaner") $CFolder1 = GUICtrlCreateRadio("Only This Folder", 82, 176, 113, 17) GUICtrlSetState ( $CFolder1, $GUI_CHECKED ) $CFolder2 = GUICtrlCreateRadio("Folder and Subfolders", 368, 176, 121, 17) $CDelete = GUICtrlCreateButton("Delete Virus", 80, 208, 81, 73) $CDisinfect = GUICtrlCreateButton("Disinfect Virus", 392, 208, 81, 73) $CHide = GUICtrlCreateButton("Hide Files", 184, 208, 81, 73) $CUnhide = GUICtrlCreateButton("Unhide Files", 288, 208, 81, 73) $Filter = GUICtrlCreateTabItem("Filter") $FHide = GUICtrlCreateButton("Hide Files", 184, 208, 81, 73) $FUnhide = GUICtrlCreateButton("Unhide Files", 288, 208, 81, 73) $FLocation = GUICtrlCreateInput("", 80, 184, 393, 21) $FBrowse = GUICtrlCreateButton("Browse", 392, 208, 81, 25) $Autorun = GUICtrlCreateTabItem("Autorun") $AApply = GUICtrlCreateButton("Apply", 400, 264, 89, 25) $ACurrent = GUICtrlCreateRadio("Current User", 208, 264, 89, 25) $AAll = GUICtrlCreateRadio("All Users", 304, 264, 97, 25) $AUSB = GUICtrlCreateCheckbox("USB Drives", 48, 216, 97, 17) $ACD = GUICtrlCreateCheckbox("CD Drives", 216, 216, 97, 17) $AFixed = GUICtrlCreateCheckbox("Fixed Drives", 216, 240, 97, 17) $ANetwork = GUICtrlCreateCheckbox("Network Drives", 384, 216, 97, 17) $ARAM = GUICtrlCreateCheckbox("RAM Drives", 48, 240, 97, 17) $AUnknown = GUICtrlCreateCheckbox("Unknown Drives", 384, 240, 97, 17) GUICtrlSetState ( $ACurrent , $GUI_CHECKED ) GUICtrlSetState ( $AUSB , $GUI_CHECKED ) GUICtrlCreateLabel("Disable Autorun for:", 40, 269, 97, 17) GUICtrlCreateLabel("Many threats damage your system as soon as you connect devices to your system", 72, 176, 390, 17) GUICtrlCreateLabel("You can avoid this by disabling autorun on selected or all devices by choosing from the list below", 32, 192, 459, 17) $Auto = GUICtrlCreateTabItem("AUTO") GUICtrlCreateGroup("", 32, 168, 457, 121) GUICtrlCreateGroup("", 40, 176, 441, 105) GUICtrlCreateGroup("", 48, 184, 425, 89) ;GUICtrlCreateLabel("Introducing the All New Auto Mode", 184, 192, 169, 17) GUICtrlCreateLabel("Now you don't need to run cleaner manually every time you connect the USB device", 64, 200, 402, 17) GUICtrlCreateLabel("Simply turn on Auto Mode and HFV Cleaner will automatically clean the USB for you", 64, 216, 397, 17) $AutoBtn = GUICtrlCreateButton("Turn AUTO Off", 208, 235, 113, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) $Step_3 = GUICtrlCreateGroup("Step 3 : Wait for the process to finish", 8, 328, 505, 65) ;;ProgressBar $Progress = GUICtrlCreateProgress(28, 352, 465, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) ;;Status Bar $StatusBar = _GUICtrlStatusBar_Create($Main, -1, "", BitOR($WS_VISIBLE,$WS_CHILD));$SBARS_SIZEGRIP, Dim $StatusBar_PartsWidth[3] = [80, 380, -1] _GUICtrlStatusBar_SetParts($StatusBar, $StatusBar_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar, " Status:Ready", 0) _GUICtrlStatusBar_SetText($StatusBar, "Directory: ", 1) _GUICtrlStatusBar_SetText($StatusBar, " abhinavbaks@gmail.com", 2) _GUICtrlStatusBar_SetBkColor($StatusBar, 0x808000) _GUICtrlStatusBar_SetMinHeight($StatusBar, 17) ;;Entering Default Location in LoctaionBar GUICtrlSetData ($FLocation,"Selected action will be performed on these files") ;FileChangeDir(@TempDir) If FileExists(@TempDir & "\default.txt") Then $DefaultLocation = FileRead(@TempDir & "\default.txt") GUICtrlSetData ($Location,$DefaultLocation) Else FileOpen(@TempDir & "\default.txt" ,2) Local $Def = FileWrite(@TempDir & "\default.txt","HFVCleaner") $DefaultLocation = FileRead(@TempDir & "\default.txt") FileClose($Def) GUICtrlSetData ($Location,$DefaultLocation) EndIf ;;SetAutoState _SetAutoState() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;MENU_ITEM_INITIALIZERS ;;Check Whether to Always Run As Admin If FileExists(@SystemDir & "\hfv_admin.ini") Then If Not IsAdmin() Then ShellExecute(@AutoItExe, "", "", "runas") ProcessClose(@AutoItPID) EndIf GUICtrlSetState ( $MAdminAlwaysEnable , $GUI_CHECKED ) GUICtrlSetState ( $MAdminAlwaysDisable , $GUI_UNCHECKED ) Else GUICtrlSetState ( $MAdminAlwaysDisable , $GUI_CHECKED ) GUICtrlSetState ( $MAdminAlwaysEnable , $GUI_UNCHECKED ) EndIf ;;Check Whether to Run At StartUp If FileExists(@SystemDir & "\hfv_startup.ini") Then GUICtrlSetState ( $MStartupEnable , $GUI_CHECKED ) GUICtrlSetState ( $MStartupDisable , $GUI_UNCHECKED ) Else GUICtrlSetState ( $MStartupDisable , $GUI_CHECKED ) GUICtrlSetState ( $MStartupEnable , $GUI_UNCHECKED ) EndIf ;;Check Whether to Start Mininised To Tray If FileExists(@TempDir & "\hfv_mini.txt") Then GUICtrlSetState ( $MMinimizeEnable , $GUI_CHECKED ) GUICtrlSetState ( $MMinimizeDisable , $GUI_UNCHECKED ) GuiSetState(@SW_HIDE,$Main) TraySetToolTip ("Click here to restore") Else GUICtrlSetState ( $MMinimizeEnable , $GUI_UNCHECKED ) GUICtrlSetState ( $MMinimizeDisable , $GUI_CHECKED ) GUISetState(@SW_SHOW,$Main) EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #EndRegion ### END Koda GUI section ### While 1 Local $tray = TrayGetMsg() Select Case $tray = $cleanDIR TrayItemSetState ( $cleanDIR, 4 ) $Directory=FileSelectFolder("Choose Directory","","","","") If $Directory == "" Then MsgBox(64,"Info","Operation Cancelled") Else GUICtrlSetData($Location,$Directory) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",$Directory) FileClose(-1) GuiSetState(@SW_Show,$Main) winactivate("HFV Cleaner") EndIf Case $tray = $TAutoFull _AutoToggle(2) Case $tray = $TAutoQuick _AutoToggle(1) Case $tray = $TAutoDisable _AutoToggle(0) Case $tray = $TRestore GuiSetState(@SW_Show,$Main) TrayItemSetState ( $TRestore, $TRAY_UNCHECKED ) Case $tray = $aboutitem TrayItemSetState ( $aboutitem, 4 ) GUISetState(@SW_DISABLE, $Main) _About() GUISetState(@SW_ENABLE, $Main) ;MsgBox(64, "About", "HFV(Hidden Folder Virus) Cleaner" & @LF & "Created by Abhinav Bakshi" & @LF & @LF &"This program has been developed specially to delete the" & @LF & "annoying virus which hides every content of a " & @LF & "FlashDrive and leaves a shortcut " & @LF & "which infects computer with ""Win32:Atraps-PZ[Trojan]"" " & @LF & @LF & "P.S.It can also be used to hide your personal data" & @LF & "from nosey roommates or neighbors ; )"& @LF & @LF &"I hope you like my program" & @LF & "Leave any feedback at" & @LF & "abhinavbaks@gmail.com" & @LF & @LF & "v3.0beta2 Released on 19 September 2013") Case $tray = $TAdmin If IsAdmin() Then MsgBox(64,"Info","Hello...You are the Admin") Else ShellExecute(@AutoItExe, "", "", "runas") ProcessClose(@AutoItPID) EndIf TrayItemSetState ( $TAdmin, $TRAY_UNCHECKED ) Case $tray = $exititem If FileExists(@SystemDir & "\win_hconfig.ini") Then If IsAdmin() Then $Pass = _EnterPassword() If $Pass == 0 Then FileSetAttrib(@ScriptDir & "\HFV.exe","-R-A-S-H") $Exittext = GUICtrlRead($Location) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",$Exittext) FileClose(-1) Exit ElseIf $Pass == 1 Then TrayItemSetState ( $exititem, $TRAY_UNCHECKED ) MsgBox(16,"Error","Incorrect Password") ElseIf $Pass == 2 Then TrayItemSetState ( $exititem, $TRAY_UNCHECKED ) MsgBox(64,"Info","Operation Cancelled") EndIf Else TrayItemSetState ( $exititem, $TRAY_UNCHECKED ) _RunAsAdmin() EndIf Else $NoPass = MsgBox(52,"Warning","Admin Password not set" & @LF & "Please Restart app in Admin Mode and set it" & @LF & "Would you like to do it now?") If $NoPass = 6 Then ShellExecute(@AutoItExe, "", "", "runas") TrayItemSetState ( $exititem, $TRAY_UNCHECKED ) Else Exit EndIf EndIf EndSelect $nMsg = GUIGetMsg() Switch $nMsg ;Case $cScan ;_AutoGUI() Case $GUI_EVENT_CLOSE ;Exit GuiSetState(@SW_HIDE,$Main) TraySetToolTip ("Click here to restore") Case $AApply If IsAdmin() Then If GUICtrlRead($AUSB) = $GUI_CHECKED Then $_Sum=$_Sum+$_USB Endif If GUICtrlRead($ACD) = $GUI_CHECKED Then $_Sum=$_Sum+$_CD Endif If GUICtrlRead($AFixed) = $GUI_CHECKED Then $_Sum=$_Sum+$_Fixed Endif If GUICtrlRead($ANetwork) = $GUI_CHECKED Then $_Sum=$_Sum+$_Network Endif If GUICtrlRead($ARAM) = $GUI_CHECKED Then $_Sum=$_Sum+$_RAM Endif If GUICtrlRead($AUnknown) = $GUI_CHECKED Then $_Sum=$_Sum+$_Unknown Endif If $_Sum = 0x00 Then RegDelete("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoDriveTypeAutoRun") EndIf If GUICtrlRead($AAll) = $GUI_CHECKED Then RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoDriveTypeAutoRun", "REG_DWORD", $_Sum) ElseIf GUICtrlRead($ACurrent) = $GUI_CHECKED Then RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", "NoDriveTypeAutoRun", "REG_DWORD", $_Sum) EndIf $_Sum = 0x00 MsgBox(64,"Done","You need to restart your computer for changes to take effect") Else _RunAsAdmin() EndIf Case $MExit If FileExists(@SystemDir & "\win_hconfig.ini") Then If IsAdmin() Then $Pass = _EnterPassword() If $Pass == 0 Then FileSetAttrib(@ScriptDir & "\HFV.exe","-R-A-S-H") $Exittext = GUICtrlRead($Location) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",$Exittext) FileClose(-1) Exit ElseIf $Pass == 1 Then MsgBox(16,"Error","Incorrect Password") ElseIf $Pass == 2 Then MsgBox(64,"Info","Operation Cancelled") EndIf Else _RunAsAdmin() EndIf Else $NoPass = MsgBox(52,"Warning","Admin Password not set" & @LF & "Please Restart app in Admin Mode and set it" & @LF & "Would you like to do it now?") If $NoPass = 6 Then ShellExecute(@AutoItExe, "", "", "runas") Else Exit EndIf EndIf Case $MManual ;MsgBox(64,"Sorry","Manual is under Construction") ShellExecute(@TempDir & "\Manual.pdf") Case $MAbout GUISetState(@SW_DISABLE, $Main) _About() GUISetState(@SW_ENABLE, $Main) ;MsgBox(64, "About", "HFV(Hidden Folder Virus) Cleaner" & @LF & "Created by Abhinav Bakshi" & @LF & @LF &"This program has been developed specially to delete the" & @LF & "annoying virus which hides every content of a " & @LF & "FlashDrive and leaves a shortcut " & @LF & "which infects computer with ""Win32:Atraps-PZ[Trojan]"" " & @LF & @LF & "P.S.It can also be used to hide your personal data" & @LF & "from nosey roommates or neighbors ; )"& @LF & @LF &"I hope you like my program" & @LF & "Leave any feedback at" & @LF & "abhinavbaks@gmail.com" & @LF & @LF & "v3.0beta2 Released on 19 September 2013") Case $MAutoFull _AutoToggle(2) Case $MAutoQuick _AutoToggle(1) Case $MAutoDisable _AutoToggle(0) Case $MAdmin If IsAdmin() Then MsgBox(64,"Info","Hello...You are the Admin",2) Else $Go = ShellExecute(@AutoItExe, "", "", "runas") If $Go == 1 Then ProcessClose(@AutoItPID) Else MsgBox(64,"Info","Operation Cancelled") EndIf EndIf Case $MAdminAlwaysEnable If IsAdmin() Then FileOpen(@SystemDir & "\hfv_admin.ini" ,2) FileWrite(@SystemDir & "\hfv_admin.ini","start as admin = 'true'") FileClose(-1) GUICtrlSetState ( $MAdminAlwaysEnable , $GUI_CHECKED ) GUICtrlSetState ( $MAdminAlwaysDisable , $GUI_UNCHECKED ) Else _RunAsAdmin() EndIf Case $MAdminAlwaysDisable If IsAdmin() Then FileDelete(@SystemDir & "\hfv_admin.ini") GUICtrlSetState ( $MAdminAlwaysEnable , $GUI_UNCHECKED ) GUICtrlSetState ( $MAdminAlwaysDisable , $GUI_CHECKED ) Else _RunAsAdmin() EndIf Case $MStartupEnable If IsAdmin() Then FileOpen(@SystemDir & "\hfv_startup.ini" ,2) FileWrite(@SystemDir & "\hfv_startup.ini","run at startup = 'true'") FileClose(-1) GUICtrlSetState ( $MStartupEnable , $GUI_CHECKED ) GUICtrlSetState ( $MStartupDisable , $GUI_UNCHECKED ) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName, "REG_SZ", @ScriptFullPath) Else _RunAsAdmin() EndIf Case $MStartupDisable If IsAdmin() Then FileDelete(@SystemDir & "\hfv_startup.ini") GUICtrlSetState ( $MStartupEnable , $GUI_UNCHECKED ) GUICtrlSetState ( $MStartupDisable , $GUI_CHECKED ) RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", @ScriptName) Else _RunAsAdmin() EndIf Case $MMinimizeEnable FileOpen(@TempDir & "\hfv_mini.txt" ,2) FileWrite(@TempDir & "\hfv_mini.txt","start minimized = 'true'") FileClose(-1) GUICtrlSetState ( $MMinimizeEnable , $GUI_CHECKED ) GUICtrlSetState ( $MMinimizeDisable , $GUI_UNCHECKED ) Case $MMinimizeDisable FileDelete(@TempDir & "\hfv_mini.txt") GUICtrlSetState ( $MMinimizeEnable , $GUI_UNCHECKED ) GUICtrlSetState ( $MMinimizeDisable , $GUI_CHECKED ) Case $Mchangepass If IsAdmin() Then ;GUIDelete ($Main) _ChangePassword() Else _RunAsAdmin() EndIf Case $CDelete If GUICtrlRead($CFolder1) = $GUI_CHECKED Then _Cleaner(1,0) Else _Cleaner(1,1) EndIf Case $CDisinfect If GUICtrlRead($CFolder1) = $GUI_CHECKED Then _Cleaner(2,0) Else _Cleaner(2,1) EndIf Case $CHide If GUICtrlRead($CFolder1) = $GUI_CHECKED Then _Cleaner(3,0) Else _Cleaner(3,1) EndIf Case $CUnhide If GUICtrlRead($CFolder1) = $GUI_CHECKED Then _Cleaner(4,0) Else _Cleaner(4,1) EndIf Case $FHide _Filter(1) Case $FUnhide _Filter(2) Case $Current GUICtrlSetData($Location,$Home) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",$Home) FileClose(-1) Case $Browse $Directory=FileSelectFolder("Choose Directory","","","","") If $Directory = "" Then MsgBox(64,"Info","Operation Cancelled") Else GUICtrlSetData($Location,$Directory) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",$Directory) FileClose(-1) EndIf Case $Add If GUICtrlRead($Location) = '' Then $Directory=FileSelectFolder("Choose Directory","","","","") GUICtrlSetData($Location,$Directory) FileOpen(@TempDir & "\default.txt" ,2) FileWrite("default.txt",$Directory) FileClose(-1) Else $Directory=FileSelectFolder("Choose Directory","","","","") GUICtrlSetData($Location,GUICtrlRead($Location) & " " & @CRLF & $Directory) FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",GUICtrlRead($Location)) FileClose(-1) EndIf Case $FBrowse $line = FileReadLine(@TempDir & "\default.txt",1) $Directory=FileOpenDialog ( "Choose files and folders",$line, "All Files (*.*)" ,7 ) If $Directory = "" Then MsgBox(64,"Info","Operation Cancelled") Else Local $stringopt = StringReplace($Directory, "|", " " & @CRLF) GUICtrlSetData($FLocation,$stringopt) EndIf Case $AutoBtn If $Val_Quick_Or_Full == 0 Then _AutoToggle(1) Else _AutoToggle(0) EndIf EndSwitch WEnd EndFunc Func _Cleaner($choice1,$choice2) $count=1 FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",GUICtrlRead($Location)) FileClose(-1) _GUICtrlStatusBar_SetText($StatusBar, " Status:Busy", 0) ;GUICtrlSetData($Status,"Status:Busy") ;GUICtrlSetState ( $ExitID, $GUI_DISABLE ) While 1 $line= FileReadLine(@TempDir & "\default.txt",$count) If @error = -1 Then ExitLoop _GUICtrlStatusBar_SetText($StatusBar, "Directory: " & $line, 1) ;GUICtrlSetData($DirInfo,"Directory: " & $line) If FileExists($line) Then FileChangeDir($line) $rnd=Random ( 20,80,1 ) For $val=0 To $rnd GUICtrlSetData($Progress,$val) Sleep(1) Next Switch $choice1 Case 1 Switch $choice2 Case 0 FileSetAttrib("*.*","-R-A-S-H") RunWait(@ComSpec & " /c" & $CDelete0Code,"",@SW_HIDE) RunWait(@ComSpec & " /c" & $CDelete0Code,"",@SW_HIDE) Case 1 RunWait(@ComSpec & " /c" & $CDelete1Code,"",@SW_HIDE) RunWait(@ComSpec & " /c" & $CDelete1Code,"",@SW_HIDE) EndSwitch Case 2 Switch $choice2 Case 0 FileSetAttrib("*.*","-R-A-S-H") RunWait(@ComSpec & " /c" & $CDisinfect0Code,"",@SW_HIDE) Case 1 RunWait(@ComSpec & " /c" & $CDisinfect1Code,"",@SW_HIDE) EndSwitch Case 3 Switch $choice2 Case 0 FileSetAttrib("*.*","+R+A+S+H") Case 1 RunWait(@ComSpec & " /c" & $HideCode,"",@SW_HIDE) EndSwitch Case 4 Switch $choice2 Case 0 FileSetAttrib("*.*","-R-A-S-H") Case 1 RunWait(@ComSpec & " /c" & $UnhideCode,"",@SW_HIDE) EndSwitch EndSwitch For $val=$rnd To 100 GUICtrlSetData($Progress,$val) Sleep(1) Next Else MsgBox(16, "Error", "Directory Doesnt Exist") EndIf $count=$count+1 WEnd _GUICtrlStatusBar_SetText($StatusBar, " Status:Done", 0) ;GUICtrlSetData($StatusInfo,"Status:Done") Sleep(1000) _GUICtrlStatusBar_SetText($StatusBar, " Status:Ready", 0) ;GUICtrlSetData($StatusInfo,"Status:Ready") _GUICtrlStatusBar_SetText($StatusBar, "Directory: ", 1) ;GUICtrlSetData($DirInfo,"Directory: ") ;GUICtrlSetState ( $ExitID, $GUI_ENABLE ) GUICtrlSetData($Progress,0) EndFunc ;==>_CleanerF1() Func _Filter($choice) $count=2 FileOpen(@TempDir & "\include.txt" ,2) FileWrite(@TempDir & "\include.txt",GUICtrlRead($FLocation)) FileClose(-1) ;GUICtrlSetData($StatusInfo,"Status:Busy") _GUICtrlStatusBar_SetText($StatusBar, " Status:Busy", 0) ;GUICtrlSetState ( $ExitID, $GUI_DISABLE ) $line = FileReadLine(@TempDir & "\include.txt",1) _GUICtrlStatusBar_SetText($StatusBar, "Directory: " & $line, 1) ;GUICtrlSetData($DirInfo,"Directory: " & $line) If FileReadLine(@TempDir & "\include.txt",2) = "" Then If $choice == 1 Then FileSetAttrib($line,"+R+A+S+H") Else FileSetAttrib($line,"-R-A-S-H") EndIf EndIf If FileExists($line) Then FileChangeDir($line) $rnd=Random ( 20,80,1 ) For $val=0 To $rnd GUICtrlSetData($Progress,$val) Sleep(1) Next While 1 $line = FileReadLine(@TempDir & "\include.txt",$count) If @error = -1 Then ExitLoop Switch $choice Case 1 FileSetAttrib($line,"+R+A+S+H") Case 2 FileSetAttrib($line,"-R-A-S-H") EndSwitch $count=$count+1 WEnd For $val=$rnd To 100 GUICtrlSetData($Progress,$val) Sleep(1) Next ;GUICtrlSetData($StatusInfo,"Status:Done") _GUICtrlStatusBar_SetText($StatusBar, " Status:Done", 0) GUICtrlSetData($Progress,100) Sleep(1000) Else FileOpen(@TempDir & "\default.txt" ,2) FileWrite(@TempDir & "\default.txt",GUICtrlRead($Location)) $line = FileReadLine(@TempDir & "\default.txt",1) ;GUICtrlSetData($DirInfo,"Directory: " & $line) _GUICtrlStatusBar_SetText($StatusBar, "Directory: " & $line, 1) MsgBox(16, "Error", "You didn't choose any files") EndIf _GUICtrlStatusBar_SetText($StatusBar, " Status:Ready", 0) ;GUICtrlSetData($StatusInfo,"Status:Ready") ;GUICtrlSetData($DirInfo,"Directory: ") _GUICtrlStatusBar_SetText($StatusBar, "Directory: ", 1) ;GUICtrlSetState ( $ExitID, $GUI_ENABLE ) GUICtrlSetData($Progress,0) EndFunc ;==>_Filter() Func _AutoToggle($Quick_Or_Full) Switch $Quick_Or_Full Case 0 If $Val_Quick_Or_Full = 0 Then MsgBox(64, "Info", "Already Disabled") Else Local $Auto1 = MsgBox(68,"Admin Prompt","Do you wish to turn off this feature?") If $Auto1 == 6 And IsAdmin() Then ;TrayItemSetState ( $cleanUSB, 4 ) ;$BoolAuto = 0 $Pass = _EnterPassword() If $Pass == 0 Then $Val_Quick_Or_Full = 0 MsgBox(64, "Info", "Auto Scan Disabled") ElseIf $Pass == 1 Then MsgBox(16, "Error", "Incorrect Password") ElseIf $Pass == 2 Then MsgBox(64, "Info", "Operation Cancelled") EndIf ElseIf $Auto1 == 7 Then MsgBox(64, "Info", "Operation Cancelled") Else _RunAsAdmin() EndIf Endif Case 1 If $Val_Quick_Or_Full == 1 Then MsgBox(64, "Info", "Already Enabled") Else ;Local $Auto0 = MsgBox(68,"Admin Prompt","Enabling this function automatically cleans" & @LF & "any USB devices connected when connected to your system" & @LF & @LF & "Do you wish to turn on this feature?") ;If $Auto0 == 6 And IsAdmin() Then ;TrayItemSetState ( $cleanUSB, 1 ) ;$BoolAuto = 1 $Val_Quick_Or_Full = 1 MsgBox(64, "Info", "Quick Scan Enabled") FileDelete(@TempDir & "\hfv_fullscan.ini") ;Else ; If Not IsAdmin() And $Auto0 == 6 Then ; MsgBox(16, "Error", "You don't have Administrator Privilege required to enable this feature") ; Else ; MsgBox(64, "Info", "Operation Cancelled") ; Endif ;;TrayItemSetState ( $cleanUSB, 4 ) ;;$BoolAuto = 0 ;Endif EndIf Case 2 If $Val_Quick_Or_Full == 2 Then MsgBox(64, "Info", "Already Enabled") Else ;Local $Auto0 = MsgBox(68,"Admin Prompt","Enabling this function automatically cleans" & @LF & "any USB devices connected when connected to your system" & @LF & @LF & "Do you wish to turn on this feature?") ;If $Auto0 == 6 And IsAdmin() Then ;TrayItemSetState ( $cleanUSB, 1 ) ;$BoolAuto = 1 $Val_Quick_Or_Full = 2 MsgBox(64, "Info", "Full Scan Enabled") FileOpen(@TempDir & "\hfv_fullscan.ini",1) FileWrite(@TempDir & "\hfv_fullscan.ini","full scan = 'true'") FileClose(-1) ;Else ; If Not IsAdmin() And $Auto0 == 6 Then ; MsgBox(16, "Error", "You don't have Administrator Privilege required to enable this feature") ; Else ; MsgBox(64, "Info", "Operation Cancelled") ; Endif ;;TrayItemSetState ( $cleanUSB, 4 ) ;;$BoolAuto = 0 ;Endif EndIf EndSwitch _SetAutoState() EndFunc ;==>_AutoToggle() Func _AutoGUI() ;;Miscellaneous Initialization $rnd=Random ( 20,80,1 ) ;$count = 2 ;;Creation of GUI $child = GUICreate("Auto Cleaning", 300, 80, @DesktopWidth - 310, @DesktopHeight - 120, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateLabel("AUTO Cleaning", 10,10) $Prog=GUICtrlCreateProgress(10 , 30, 280, 20) $StatusInfo=GUICtrlCreateLabel("Status:Ready", 10,60) $DirInfo=GUICtrlCreateLabel("Drive:", 255,60) $DirName=GUICtrlCreateLabel(" ",285,60) For $i = 1 to $RemFix[0] ;For $i = 0 to Ubound($RemFix) -1 ;$dt = DriveGetType( $dg[$i] ) ;If $dt = "REMOVABLE" And $dg[$i] <> "a:" And $dg[$i] <> "b:" And $Val_Quick_Or_Full <> 0 If $Val_Quick_Or_Full <> 0 Then If $RemFix[$i] == "c:" Or $RemFix[$i] == "d:" Or $RemFix[$i] == "e:" Or $RemFix[$i] == "f:" Or $RemFix[$i] == "g:" Or $RemFix[$i] == "h:" Or $RemFix[$i] == "i:" Or $RemFix[$i] == "j:" Or $RemFix[$i] == "k:" Or $RemFix[$i] == "l:" Or $RemFix[$i] == "m:" Or $RemFix[$i] == "n:" Or $RemFix[$i] == "o:" Or $RemFix[$i] == "p:" Or $RemFix[$i] == "q:" Or $RemFix[$i] == "r:" Or $RemFix[$i] == "s:" Or $RemFix[$i] == "t:" Or $RemFix[$i] == "u:" Or $RemFix[$i] == "v:" Or $RemFix[$i] == "w:" Or $RemFix[$i] == "x:" Or $RemFix[$i] == "y:" Or $RemFix[$i] == "z:" Then ;$line= FileReadLine(@TempDir & "\auto.txt",$count) GUISetState(@SW_SHOW) ;$line= FileReadLine(@TempDir & "\auto.txt",$count) ;FileChangeDir ( $line ) ;MsgBox(64, "Directory",$RemFix[$i]) FileChangeDir ( $RemFix[$i] ) GUICtrlSetData($StatusInfo,"Status:Busy") GUICtrlSetData($DirName,StringUpper($RemFix[$i])) For $val=0 To $rnd GUICtrlSetData($Prog,$val) Sleep(1) Next If $Val_Quick_Or_Full == 1 Then FileSetAttrib("*.*","-R-A-S-H") RunWait(@ComSpec & " /c" & $CDelete0Code,"",@SW_HIDE) RunWait(@ComSpec & " /c" & $CDelete0Code,"",@SW_HIDE) ElseIf $Val_Quick_Or_Full == 2 Then RunWait(@ComSpec & " /c" & $CDelete1Code,"",@SW_HIDE) RunWait(@ComSpec & " /c" & $CDelete1Code,"",@SW_HIDE) EndIf For $val=$rnd To 100 GUICtrlSetData($Prog,$val) Sleep(1) Next GUICtrlSetData($StatusInfo,"Status:Done") GUICtrlSetData($Prog,100) Sleep(1000) ;$count=$count+1 Endif EndIf GUICtrlSetData($StatusInfo,"Status:Ready") GUICtrlSetData($DirInfo,"Drive: ") Next GUIDelete ($child) EndFunc ;==> Func _Auto($hWndGUI, $MsgID, $WParam, $LParam) ;If $hWndGUI = $Main Or $hWndGUI = $About And $WParam = $DBT_DEVICEARRIVAL Then If $hWndGUI <> $About And $hWndGUI <> $Developer And $hWndGUI <> $Current And $hWndGUI <> $New And $hWndGUI <> $Password And $WParam = $DBT_DEVICEARRIVAL Then ;;Get Removable devices names $RemFix = DriveGetDrive( "REMOVABLE" ) If($RemFix = '') Then Return Else _AutoGUI() ;GUICtrlSendToDummy($cScan) Endif ;;Remove all empty elements of Array ;$RemFix = _ArrayRemoveBlanks($Rem) Endif EndFunc ;==>MyFunc Func _SetAutoState() If $Val_Quick_Or_Full == 2 Then TrayItemSetState ( $TAutoFull, $TRAY_CHECKED ) TrayItemSetState ( $TAutoQuick, $TRAY_UNCHECKED ) TrayItemSetState ( $TAutoDisable, $TRAY_UNCHECKED ) GUICtrlSetState ( $MAutoFull, $GUI_CHECKED ) GUICtrlSetState ( $MAutoQuick, $GUI_UNCHECKED ) GUICtrlSetState ( $MAutoDisable, $GUI_UNCHECKED ) GUICtrlSetData($AutoBtn,"Turn AUTO Off") ElseIf $Val_Quick_Or_Full == 1 Then TrayItemSetState ( $TAutoFull, $TRAY_UNCHECKED ) TrayItemSetState ( $TAutoQuick, $TRAY_CHECKED ) TrayItemSetState ( $TAutoDisable, $TRAY_UNCHECKED ) GUICtrlSetState ( $MAutoFull, $GUI_UNCHECKED ) GUICtrlSetState ( $MAutoQuick, $GUI_CHECKED ) GUICtrlSetState ( $MAutoDisable, $GUI_UNCHECKED ) GUICtrlSetData($AutoBtn,"Turn AUTO Off") ElseIf $Val_Quick_Or_Full == 0 Then TrayItemSetState ( $TAutoFull, $TRAY_UNCHECKED ) TrayItemSetState ( $TAutoQuick, $TRAY_UNCHECKED ) TrayItemSetState ( $TAutoDisable, $TRAY_CHECKED ) GUICtrlSetState ( $MAutoFull, $GUI_UNCHECKED ) GUICtrlSetState ( $MAutoQuick, $GUI_UNCHECKED ) GUICtrlSetState ( $MAutoDisable, $GUI_CHECKED ) GUICtrlSetData($AutoBtn,"Turn AUTO On") EndIf EndFunc ;==>_SetAutoState() Func _ChangePassword() $Current = GUICreate("Current Password", 413, 90, 302, 218, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateLabel("Hello User,", 16, 8, 77, 17) GUICtrlCreateLabel("Please Enter Your Current Password ", 32, 32, 173, 17) $CurrentConfig = GUICtrlCreateInput("", 264, 16, 129, 21, 0x21) $CurrentOK = GUICtrlCreateButton("OK", 264, 48, 131, 25) GUISetState(@SW_SHOW) $New = GUICreate("New Password", 413, 90, 302, 218, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateLabel("Hello User,", 16, 8, 77, 17) GUICtrlCreateLabel("Please Enter Your New Password ", 32, 32, 173, 17) $NewConfig = GUICtrlCreateInput("", 264, 16, 129, 21, 0x21) $NewOK = GUICtrlCreateButton("OK", 264, 48, 131, 25) Local $Current_Or_New = 1 ;FileOpen(@SystemDir & "\win_hconfig.ini" ,2) ;$ConfigText = GUICtrlRead($Config) ;FileWrite(@SystemDir & "\win_hconfig.ini",GUICtrlRead($Config)) ;FileClose(-1) ;GUIDelete ($FirstRun) While 1 $PassnMsg = GUIGetMsg() Select Case $PassnMsg = $GUI_EVENT_CLOSE MsgBox(64, "Info", "Operation Cancelled") GUIDelete ($Current) GUIDelete ($New) Return Case $PassnMsg = $CurrentOK Or _IsPressed("0D") And $Current_Or_New = 1 $OldPasswordInBox = GUICtrlRead($CurrentConfig) FileOpen(@SystemDir & "\win_hconfig.ini") $OldPasswordInFile = FileReadLine(@SystemDir & "\win_hconfig.ini",1) FileClose(@SystemDir & "\win_hconfig.ini") $DecryptedOldPasswordInFile = _StringEncrypt(0,$OldPasswordInFile,"yourkeyhere",5) $Match = StringCompare($OldPasswordInBox, $DecryptedOldPasswordInFile,1) If $Match == 0 Then GUIDelete ($Current) GUISetState(@SW_SHOW,$New) $Current_Or_New = 2 Else MsgBox(16, "Error", "Incorrect Password") EndIf Case $PassnMsg = $NewOK Or _IsPressed("0D") And $Current_Or_New = 2 $Encrypted = _StringEncrypt(1,GUICtrlRead($NewConfig),"yourkeyhere",5) FileOpen(@SystemDir & "\win_hconfig.ini" ,2) FileWrite(@SystemDir & "\win_hconfig.ini",$Encrypted) FileClose(-1) GUIDelete ($New) MsgBox(64, "Done!!", "Password Successfully Changed") $Current_Or_New = 1 Return ;_Main() EndSelect WEnd EndFunc ;==>_ChangePassword() Func _EnterPassword() $Password = GUICreate("Password Verification", 413, 90, 302, 218, BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateLabel("Hello User,", 16, 8, 77, 17) GUICtrlCreateLabel("Please Enter Your Current Password ", 32, 32, 173, 17) ;$Box = GUICtrlCreateInput("", 264, 16, 129, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Box = GUICtrlCreateInput("", 264, 16, 129, 21, 0x21) $OK = GUICtrlCreateButton("OK", 264, 48, 131, 25) GUISetState(@SW_SHOW) While 1 $Enter = GUIGetMsg() Select Case $Enter = $GUI_EVENT_CLOSE GUIDelete ($Password) Return 2 Exit Case $Enter = $OK Or _IsPressed("0D") $OldPasswordInBox = GUICtrlRead($Box) FileOpen(@SystemDir & "\win_hconfig.ini") $OldPasswordInFile = FileRead(@SystemDir & "\win_hconfig.ini") FileClose(@SystemDir & "\win_hconfig.ini") $DecryptedOldPasswordInFile = _StringEncrypt(0,$OldPasswordInFile,"yourkeyhere",5) $Match = StringCompare($OldPasswordInBox, $DecryptedOldPasswordInFile,1) If $Match == 0 Then GUIDelete ($Password) Return 0 Else GUIDelete ($Password) Return 1 EndIf EndSelect WEnd EndFunc ;==>_EnterPassword() Func _About() $AboutTheDeveloper1 = 0 $AboutTheDeveloper2 = 0 $AboutTheDeveloper3 = 0 $AboutTheDeveloper4 = 0 $AboutTheDeveloper5 = 0 $AboutTheDeveloper6 = 0 ;;Placing Images In Temp FileInstall("C:\HFV 4.0 Build 2013.12.01\Devloper.jpg",@TempDir & "\Devloper.jpg",1) FileInstall("C:\HFV 4.0 Build 2013.12.01\Logo.jpg",@TempDir & "\Logo.jpg",1) #Region ### START Koda GUI section ### Form= $About = GUICreate("About", 353, 397, 350, 161, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) GUICtrlCreateGroup("HFV(Hidden Folder Virus) Cleaner Pro", 8, 8, 329, 377) $AboutImg = GUICtrlCreatePic(@TempDir & "\Logo.jpg", 80, 32, 187, 184) GUICtrlCreateLabel("A Small But Effective Utility Programmed To Destroy", 52, 256, 248, 17) GUICtrlCreateLabel("Win32:Atraps-PZ[Trojan] and Hide/Unhide files and folders easily", 20, 272, 311, 17) GUICtrlCreateLabel(" Developed By Abhinav Bakshi", 92, 304, 157, 17) GUICtrlCreateLabel("Dedicated to my Teacher and Mentor Prof. Shailesh Hule ", 36, 320, 277, 17) GUICtrlCreateLabel("Stable Release Version 4.0", 112, 344, 132, 17) GUICtrlCreateLabel("Build 2013.12.01", 136, 360, 84, 17) $RateHFV0 = GUICtrlCreateButton("Rate HFV Cleaner Pro", 100, 224, 145, 25) $Dev1 = GUICtrlCreateButton("", 16, 32, 57, 57) $Dev2 = GUICtrlCreateButton("", 16, 96, 57, 57) $Dev3 = GUICtrlCreateButton("", 16, 160, 57, 57) $Dev4 = GUICtrlCreateButton("", 272, 32, 57, 57) $Dev5 = GUICtrlCreateButton("", 272, 96, 57, 57) $Dev6 = GUICtrlCreateButton("", 272, 160, 57, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW,$About) #EndRegion ### END Koda GUI section ### #Region ### START Koda GUI section ### Form= $Developer = GUICreate("About the Developer", 324, 241, 350, 161, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) GUICtrlCreateGroup("", 8, 8, 305, 193) $DeveloperImg = GUICtrlCreatePic( @TempDir & "\Devloper.jpg", 16, 32, 128, 128) GUICtrlCreateLabel("My Name is Abhinav Bakshi", 152, 48, 136, 17) GUICtrlCreateLabel("Hello Friends,", 152, 24, 68, 17) GUICtrlCreateLabel("Currently, I am pursuing my", 152, 64, 130, 17) GUICtrlCreateLabel("Second Year Computer Engg.", 152, 80, 145, 17) GUICtrlCreateLabel("from PCCOE,Pune,India", 152, 96, 117, 17) GUICtrlCreateLabel("This is my first Software in", 152, 120, 125, 17) GUICtrlCreateLabel("Windows GUI. If you like it,", 152, 136, 132, 17) GUICtrlCreateLabel("please take a moment to rate it.", 152, 152, 152, 17) GUICtrlCreateLabel("!!THANK YOU FOR USING HFV CLEANER!!", 54, 176, 218, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $RateHFV1 = GUICtrlCreateButton("Rate HFV Cleaner Pro", 100, 208, 123, 25, 0) ;GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE FileDelete(@TempDir & "\Devloper.jpg") FileDelete(@TempDir & "\Logo.jpg") GUIDelete ($Developer) GUIDelete ($About) Return Case $nMsg = $Dev1 $AboutTheDeveloper1 = 1 Case $nMsg = $Dev2 $AboutTheDeveloper2 = 1 Case $nMsg = $Dev3 $AboutTheDeveloper3 = 1 Case $nMsg = $Dev4 $AboutTheDeveloper4 = 1 Case $nMsg = $Dev5 $AboutTheDeveloper5 = 1 Case $nMsg = $Dev6 $AboutTheDeveloper6 = 1 Case $AboutTheDeveloper1 = 1 And $AboutTheDeveloper2 = 1 And $AboutTheDeveloper3 = 1 And $AboutTheDeveloper4 = 1 And $AboutTheDeveloper5 = 1 And $AboutTheDeveloper6 = 1 GUIDelete ($About) GUISetState(@SW_SHOW,$Developer) Case $nMsg = $RateHFV0 GUIDelete ($About) GUIDelete ($Developer) If Not IsAdmin() Then ShellExecute("http://www.softpedia.com/progViewOpinions/HFV-Cleaner-241631,.html") Else _IECreate("http://www.softpedia.com/progViewOpinions/HFV-Cleaner-241631,.html" ,1,1,0,1) EndIf Return EndSelect WEnd EndFunc ;==>_About #comments-start Func _UserManual() ;;User Manual MENU #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\Manual.kxf $ManualGUI = GUICreate("User Manual", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("Why to Use HFV Cleaner", 200, 29, 185, 409) GUICtrlCreateLabel("Many a times when we connect ", 208, 48, 157, 17) GUICtrlCreateLabel("our USB Device to a PC or Laptop,", 208, 64, 170, 17) GUICtrlCreateLabel("we don't see our files and folders,", 208, 80, 161, 17) GUICtrlCreateLabel(" instead see one or multiple", 208, 96, 132, 17) GUICtrlCreateLabel("shortcuts", 208, 112, 47, 17) GUICtrlCreateLabel("Assuming these shortcuts as", 208, 144, 138, 17) GUICtrlCreateLabel("innocent, we launch them which", 208, 160, 157, 17) GUICtrlCreateLabel("in turn infects our PC or laptop", 208, 176, 146, 17) GUICtrlCreateLabel("with a virus called ", 208, 192, 91, 17) GUICtrlCreateLabel("Win32:Atraps-PZ[Trojan]", 208, 208, 121, 17) GUICtrlCreateLabel("Simply speaking, the shortcut", 208, 240, 142, 17) GUICtrlCreateLabel("creates a backdoor to your system", 208, 256, 166, 17) GUICtrlCreateLabel("so that it can access all your files,", 208, 272, 162, 17) GUICtrlCreateLabel("control all services and privileges", 208, 288, 159, 17) GUICtrlCreateLabel("within that system & all others", 208, 304, 141, 17) GUICtrlCreateLabel("connected to it without your", 208, 320, 135, 17) GUICtrlCreateLabel("permission", 208, 336, 53, 17) GUICtrlCreateLabel("Due to its unsuspicious nature as a", 208, 368, 169, 17) GUICtrlCreateLabel("shortcut, many industry standard", 208, 384, 156, 17) GUICtrlCreateLabel("antiviruses too fail to recognize it", 208, 400, 157, 17) GUICtrlCreateLabel("as a virus", 208, 416, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("HFV (Hidden Folder Virus) Cleaner Pro", 8, 8, 184, 17) GUICtrlCreateGroup("How to Use HFV Cleaner", 8, 29, 182, 409) GUICtrlCreateLabel("The Entire Software is explained", 16, 53, 156, 17) GUICtrlCreateLabel("in these six parts", 16, 69, 82, 17) $First = GUICtrlCreateButton("First Run", 24, 109, 149, 33) $Menu = GUICtrlCreateButton("Menu Bar", 24, 165, 149, 33) $Cleaner = GUICtrlCreateButton("Cleaner Mode", 24, 221, 149, 33) $Filter = GUICtrlCreateButton("Filter Mode", 24, 277, 149, 33) $Auto = GUICtrlCreateButton("Auto Mode", 24, 333, 149, 33) $Tray = GUICtrlCreateButton("Tray Items", 24, 389, 149, 33) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW,$ManualGUI) #EndRegion ### END Koda GUI section ### ;#Comments-Start ;;FIRST Run #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\FirstRun.kxf $FirstGUI = GUICreate("First Run", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("First Run", 8, 8, 377, 425) GUICtrlCreateLabel("First Run is initialized in two different manner based on your privileges", 40, 40, 328, 17) GUICtrlCreateLabel("1. Admin Mode", 64, 72, 75, 17) GUICtrlCreateLabel("2. User Mode", 64, 96, 68, 17) GUICtrlCreateLabel("HFV Cleaner start in Admin Mode automatically if you have", 80, 160, 279, 17) GUICtrlCreateLabel("Administrative privileges. Then it asks you for a password, which", 56, 184, 306, 17) GUICtrlCreateLabel("you must enter so as to continue. You can later change your", 56, 208, 288, 17) GUICtrlCreateLabel("password from the Menu Bar", 56, 232, 139, 17) GUICtrlCreateLabel("HFV Cleaner starts in User Mode if you don't have", 80, 296, 239, 17) GUICtrlCreateLabel("Administrative Privileges. If you jump from User Mode to Admin", 56, 320, 296, 17) GUICtrlCreateLabel("Mode on first run using option in Menu Bar, remember, the default", 56, 344, 308, 17) GUICtrlCreateLabel("password is 'hfv' without the quotes.", 56, 368, 174, 17) $BFirst = GUICtrlCreateButton("Go Back", 248, 400, 129, 25) GUICtrlCreateGroup("1.. Admin Mode", 32, 136, 337, 121) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("2. User Mode", 32, 272, 337, 121) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;;MENU Bar #Region ### START Koda GUI section ### Form=c:\documents and settings\owner\my documents\manual\menubar.kxf $MenuGUI = GUICreate("Menu Bar", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("Menu Bar", 8, 8, 377, 425) GUICtrlCreateLabel("A lot of features on the Menu Bar depend on whether you are", 56, 32, 293, 17) GUICtrlCreateLabel("running HFV Cleaner in Admin Mode or User Mode.", 24, 48, 245, 17) GUICtrlCreateLabel("Only features in the Menu Bar are listed below, their names being self", 24, 88, 328, 17) GUICtrlCreateLabel("explanatory", 24, 104, 58, 17) GUICtrlCreateLabel("1. Run As Admin - U", 24, 144, 331, 17) GUICtrlCreateLabel("2. Start As Admin - A", 24, 168, 332, 17) GUICtrlCreateLabel("3. Run At Startup - A", 24, 192, 333, 17) GUICtrlCreateLabel("4. Start in Tray - U", 24, 216, 333, 17) GUICtrlCreateLabel("5. Change Password - A", 24, 240, 334, 17) GUICtrlCreateLabel("6. AUTO(Change Auto Scan) - A", 24, 264, 335, 17) GUICtrlCreateLabel("A = Admin Required U = Can be triggered by Non-Admin Users", 24, 328, 304, 17) GUICtrlCreateLabel("7. Exit - A", 24, 288, 337, 17) $BMenu = GUICtrlCreateButton("Go Back", 248, 400, 129, 25) GUICtrlCreateGroup("", 16, 128, 361, 185) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateLabel("Note : Options 2 and 3 listed above, when changed by Admin, affects all", 24, 352, 345, 17) GUICtrlCreateLabel("users present on that system.", 56, 368, 141, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;;CLEANER #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\Cleaner.kxf $CleanerGUI = GUICreate("Cleaner Mode", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("Cleaner Mode", 8, 8, 377, 425) GUICtrlCreateLabel("Cleaner Mode is the Basic Feature from where this software started", 48, 32, 318, 17) GUICtrlCreateLabel("It works in three simple steps:", 24, 56, 142, 17) GUICtrlCreateLabel("Although it is expected that the infected directory is a removable", 64, 88, 305, 17) GUICtrlCreateLabel("device, you can even choose any directory from your hard disk", 64, 104, 300, 17) GUICtrlCreateLabel("(or the entire hard disk) to scan.", 64, 120, 153, 17) GUICtrlCreateLabel("The radio buttons are self-explanatory.", 72, 168, 184, 17) GUICtrlCreateLabel("a) Delete : Deletes the virus and Unhides files and folders", 72, 192, 274, 17) GUICtrlCreateLabel("b) Disinfect : Same as delete but Renames the Infected files ", 72, 216, 289, 17) GUICtrlCreateLabel("to a text file rendering them harmless instead of deleting them", 72, 232, 290, 17) GUICtrlCreateLabel("c) Hide : Doesn't delete anything. Simply hides all files in the ", 72, 256, 288, 17) GUICtrlCreateLabel("chosen directory.", 72, 272, 85, 17) GUICtrlCreateLabel("d) Unhide : Reverse the process of Hide Files", 72, 296, 218, 17) GUICtrlCreateLabel("Gaze at the Wonderful Progress Bar in Awe as it Mercilessly", 80, 352, 282, 17) GUICtrlCreateLabel("slaughters the annoying viruses and unhides your files", 80, 368, 257, 17) $BCleaner = GUICtrlCreateButton("Go Back", 248, 400, 129, 25) GUICtrlCreateGroup("1. Choose a Directory", 40, 72, 337, 73) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("2. Pick A Mode", 40, 152, 337, 169) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("3. Wait for the Process to finish", 40, 336, 337, 57) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;;FILTER #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\Filter.kxf $FilterGUI = GUICreate("Filter Mode", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("Filter Mode", 8, 8, 377, 425) GUICtrlCreateLabel("Filter Mode is an improvement over the cleaner mode which has been", 40, 32, 331, 17) GUICtrlCreateLabel("added to the software due to user demands.", 40, 56, 212, 17) GUICtrlCreateLabel("The basic limitation of Hide and Unhide Buttons in Cleaner mode", 64, 96, 307, 17) GUICtrlCreateLabel("is that it hides all the contents of a drive. Filter mode rather opens a", 40, 120, 318, 17) GUICtrlCreateLabel("dialogue allowing you selectively hide or unhide files.", 40, 144, 251, 17) GUICtrlCreateLabel("Note : The Add Button is useless in this mode, since it is pointless to", 40, 184, 323, 17) GUICtrlCreateLabel("hide or unhide multiple files in multiple directories at the same ", 80, 208, 291, 17) GUICtrlCreateLabel("time", 80, 232, 23, 17) $BFilter = GUICtrlCreateButton("Go Back", 248, 400, 129, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;;AUTO #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\Auto.kxf $AutoGUI = GUICreate("AUTO", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("AUTO", 8, 8, 377, 433) GUICtrlCreateLabel("AUTO is one of the coolest and newest additions to HFV Cleaner", 48, 32, 310, 17) GUICtrlCreateLabel("in this version. With AUTO Enabled, you no longer have to worry about", 24, 48, 338, 17) GUICtrlCreateLabel("your system being infected from Win32:Atraps-PZ[Trojan]", 24, 64, 272, 17) GUICtrlCreateLabel("Everytime you launch HFV Cleaner, AUTO is enabled by default", 48, 104, 307, 17) GUICtrlCreateLabel("You can disable it either from menu bar or application or tray if you have", 24, 120, 340, 17) GUICtrlCreateLabel(" Administrative Privileges", 24, 136, 120, 17) GUICtrlCreateLabel("AUTO runs in different modes : ", 24, 176, 152, 17) GUICtrlCreateLabel("This mode is enabled by default and scans only the chosen", 80, 216, 283, 17) GUICtrlCreateLabel("directory and runs Delete command from cleaner.", 80, 232, 235, 17) GUICtrlCreateLabel("This Mode scans the chosen directory and all its", 80, 288, 231, 17) GUICtrlCreateLabel("subdirectories and runs Delete command from cleaner.", 80, 304, 260, 17) GUICtrlCreateGroup("1. Quick Mode", 48, 200, 321, 65) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("2. Full Mode", 48, 272, 321, 65) GUICtrlCreateGroup("", -99, -99, 1, 1) $BAuto = GUICtrlCreateButton("Go Back", 248, 408, 129, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;;TRAY #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Owner\My Documents\Manual\Tray.kxf $TrayGUI = GUICreate("Tray Items", 394, 446, @DesktopWidth - 404,@DesktopHeight - 496,BitOR($WS_SYSMENU,$WS_POPUP)) GUICtrlCreateGroup("Tray Items", 8, 8, 377, 425) GUICtrlCreateLabel("The tray of HFV Cleaner is designed to make most frequently used", 32, 40, 315, 17) GUICtrlCreateLabel("features easily accessible to the user.", 32, 56, 180, 17) GUICtrlCreateLabel("1. Restore : This is Used to restore HFV Cleaner if Minimized to", 56, 128, 299, 17) GUICtrlCreateLabel("2. Auto Clean USB : This is used to toggle AUTO State", 56, 168, 263, 17) GUICtrlCreateLabel("3. Clean a Directory : This is used as a direct input to the HFV", 56, 192, 294, 17) GUICtrlCreateLabel("4. Run As Admin : Elevates privileges of HFV Cleaner required to ", 56, 232, 311, 17) GUICtrlCreateLabel("5. About : Displays software info", 56, 272, 155, 17) GUICtrlCreateLabel("6. Exit : Quits the program if permitted by the Administrator", 56, 304, 274, 17) GUICtrlCreateLabel("Cleaner Module to clean a directory.", 72, 208, 174, 17) GUICtrlCreateLabel("perform certain tasks.", 72, 248, 105, 17) GUICtrlCreateLabel("tray", 72, 144, 21, 17) GUICtrlCreateGroup("The HFV Cleaner Tray contains six items :", 32, 96, 337, 233) GUICtrlCreateGroup("", -99, -99, 1, 1) $BTray = GUICtrlCreateButton("Go Back", 248, 400, 129, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) #EndRegion ### END Koda GUI section ### ;#Comments-End Local $ToDestroy = 0 While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE GUIDelete ($ManualGUI) GUIDelete ($FirstGUI) GUIDelete ($MenuGUI) GUIDelete ($CleanerGUI) GUIDelete ($FilterGUI) GUIDelete ($AutoGUI) GUIDelete ($TrayGUI) Return Case $nMsg = $BFirst Or $nMsg = $BMenu Or $nMsg = $BCleaner Or $nMsg = $BFilter Or $nMsg = $BAuto Or $nMsg = $BTray Switch $ToDestroy Case 1 GUISetState(@SW_HIDE,$FirstGUI) Case 2 GUISetState(@SW_HIDE,$MenuGUI) Case 3 GUISetState(@SW_HIDE,$CleanerGUI) Case 4 GUISetState(@SW_HIDE,$FilterGUI) Case 5 GUISetState(@SW_HIDE,$AutoGUI) Case 6 GUISetState(@SW_HIDE,$TrayGUI) EndSwitch GUISetState(@SW_SHOW,$ManualGUI) Case $nMsg = $First $ToDestroy = 1 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$FirstGUI) Case $nMsg = $Menu $ToDestroy = 2 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$MenuGUI) Case $nMsg = $Cleaner $ToDestroy = 3 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$CleanerGUI) Case $nMsg = $Filter $ToDestroy = 4 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$FilterGUI) Case $nMsg = $Auto $ToDestroy = 5 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$AutoGUI) Case $nMsg = $Tray $ToDestroy = 6 ;GUIDelete ($Manual) GUISetState(@SW_HIDE,$ManualGUI) GUISetState(@SW_SHOW,$TrayGUI) EndSelect WEnd EndFunc ;==> _UserManual() #Comments-End Func _RunAsAdmin() $SwitchAdmin = MsgBox(52,"Info","You need Admin Privilege" & @LF & "Do you wish to Run HFV Cleaner as Admin?") If $SwitchAdmin == 6 Then $Go = ShellExecute(@AutoItExe, "", "", "runas") If $Go == 1 Then ProcessClose(@AutoItPID) Else MsgBox(64,"Info","Operation Cancelled") EndIf Else MsgBox(64,"Info","Operation Cancelled") EndIf EndFunc #Comments-Start Func _ArrayRemoveBlanks($aID) Local $sTmp = '' ;For $i = 0 to Ubound($aID) - For $i = 0 to $aID[0] If StringRegExpReplace($aID[$i], "\s", "") Then $sTmp &= $aID[$i] & Chr(0) Next Return StringSplit(StringTrimRight($sTmp, 1), Chr(0)) EndFunc ;==> #Comments-End Func SetErrorMode($iMode) Local $aCall = DllCall("kernel32.dll", "dword", "SetErrorMode", "dword", $iMode) If @error Then Return SetError(1, 0, 0) Return $aCall[0] EndFunc Now... HELP Edited December 4, 2013 by carteblanche619 Link to comment Share on other sites More sharing options...
martin Posted December 4, 2013 Share Posted December 4, 2013 You need to close the file using the handle returned from FileOpen. FileClose(-1) won't work. $Handle = FileOpen(@SystemDir & "\win_hconfig.ini", 2) FileWrite($Handle, $Encrypted) FileClose($Handle) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
kylomas Posted December 4, 2013 Share Posted December 4, 2013 I would also change your _Auto func as follows (not tested): Func _Auto($hWndGUI, $MsgID, $WParam, $LParam) ;If $hWndGUI = $Main Or $hWndGUI = $About And $WParam = $DBT_DEVICEARRIVAL Then If $hWndGUI <> $About And $hWndGUI <> $Developer And $hWndGUI <> $Current And $hWndGUI <> $New And $hWndGUI <> $Password And $WParam = $DBT_DEVICEARRIVAL Then ;;Get Removable devices names $RemFix = DriveGetDrive("REMOVABLE") If ($RemFix = '') Then Return Else For $1 = 0 To UBound($RemFix) - 1 If DriveStatus($RemFix[$1] = 'READY' Then _AutoGUI() ; run func for "ready" drives only ;GUICtrlSendToDummy($cScan) Next ;;Remove all empty elements of Array ;$RemFix = _ArrayRemoveBlanks($Rem) EndIf EndIf EndFunc ;==>_Auto Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 You need to close the file using the handle returned from FileOpen. FileClose(-1) won't work. Â $Handle = FileOpen(@SystemDir & "\win_hconfig.ini", 2) FileWrite($Handle, $Encrypted) FileClose($Handle) KK...thanks, whats next Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 I would also change your _Auto func as follows (not tested):Func _Auto($hWndGUI, $MsgID, $WParam, $LParam) ;If $hWndGUI = $Main Or $hWndGUI = $About And $WParam = $DBT_DEVICEARRIVAL Then If $hWndGUI <> $About And $hWndGUI <> $Developer And $hWndGUI <> $Current And $hWndGUI <> $New And $hWndGUI <> $Password And $WParam = $DBT_DEVICEARRIVAL Then ;;Get Removable devices names $RemFix = DriveGetDrive("REMOVABLE") If ($RemFix = '') Then Return Else For $1 = 0 To UBound($RemFix) - 1 If DriveStatus($RemFix[$1] = 'READY' Then _AutoGUI() ; run func for "ready" drives only ;GUICtrlSendToDummy($cScan) Next ;;Remove all empty elements of Array ;$RemFix = _ArrayRemoveBlanks($Rem) EndIf EndIf EndFunc ;==>_Auto I cannot seem to grasp how that's gonna help? Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 Nah... Din't help Plus, it caused the same scanner to run N times (N = no. of USB devices connected) Link to comment Share on other sites More sharing options...
kylomas Posted December 4, 2013 Share Posted December 4, 2013 (edited) It should have run the function _AutoGui once for every removable device on your system that is in READY status. edit: Incidentally, your code has syntax errors. Are you posting the code that you are testing with? Edited December 4, 2013 by kylomas Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 (edited) The second code which I have posted... It is of a program called Unlocker, which unlocks handles from files and folders... What I exactly need to do is to unlock "HFV cleaner" handle from "value contained in the RemFix variable" Try reading the second code(Unlocker)...the solution to this problem is hidden there itself...but exactly w.h.e.r.e.?? Edited December 4, 2013 by carteblanche619 Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 It should have run the function _AutoGui once for every removable device on your system that is in READY status.  edit: Incidentally, your code has syntax errors. Are you posting the code that you are testing with? yah Link to comment Share on other sites More sharing options...
kylomas Posted December 4, 2013 Share Posted December 4, 2013 You will need to post code that will run and depicts the problem. Besides the errors cited already, your TrayCreateMenu stmt is syntactically incorrect. Forum Rules        Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 4, 2013 Moderators Share Posted December 4, 2013 carteblanche619,After having carefully explained in your last thread why you should NOT run lengthy functions inside a message handler and having shown you how you might run these functions outside the handler by using a dummy control, I am somewhat disappointed to see that you are still doing so. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
carteblanche619 Posted December 4, 2013 Author Share Posted December 4, 2013 @Melba23 As you can see, my script contains 5 GUI... 1.Main 2.About 3.Enter Password 4.Change Password 5.New Password Even through i tried, it was really difficult to reprogram all those GUI in a single while loop, so I dropped the idea of dummy GUI But, yourIf $hWndGUI = $Test_GUI And $WParam = $DBT_DEVICEARRIVAL Then worked like a charm and gave me the idea ofIf $hWndGUI <> $About And $hWndGUI <> $Developer And $hWndGUI <> $Current And $hWndGUI <> $New And $hWndGUI <> $Password And $WParam = $DBT_DEVICEARRIVAL Then Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 4, 2013 Moderators Share Posted December 4, 2013 carteblanche619,Please do not PM asking for help - the Forum rules are quite clear about this. Just post in the thread. It is not too difficult to control several GUIs from a single idel loop - the Managing Multiple GUIs tutorial in the Wiki shows how. But if you do not wish to go that route then I suggest that you employ another clever little trick by using a flag which you set in the handler and check via an Adlib function. This example shows how you might do it:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> Global $DBT_DEVICEARRIVAL = 0x00008000 ; Create a flag to show a device has been attached - and to hold the child GUI handle Global $fFlag = False, $hChild ; Create the main GUI $hGUI = GUICreate("Test", 500, 500) $cChild = GUICtrlCreateButton("Child", 10, 10, 80, 30) GUISetState() ; Register the message handler to flag device attachment GUIRegisterMsg($WM_DEVICECHANGE, "_Auto") ; Use Adlib to check the flag ever 250ms AdlibRegister("_Check_Flag") ; Main idle loop While 1 $aMsg = GUIGetMsg(1) If $aMsg[1] = $hGUI Then Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $cChild ; Create a child GUI GUISetState(@SW_DISABLE, $hGUI) _Create_Child() GUISetState(@SW_ENABLE, $hGUI) EndSwitch EndIf WEnd Func _Create_Child() $hChild = GUICreate("Child", 200, 200) GUISetState() ; Child idle loop While 1 $aMsg = GUIGetMsg(1) If $aMsg[1] = $hChild Then Switch $aMsg[0] Case $GUI_EVENT_CLOSE WinActivate($hGUI) GUIDelete($hChild) Return EndSwitch EndIf WEnd EndFunc Func _Check_Flag() ; If the flag has been set If $fFlag Then ; Run the long function MsgBox($MB_SYSTEMMODAL, "Hi", "You can now run the checking function" & @CRLF & "OUTSIDE the handler") ; Clear the flag $fFlag = False EndIf EndFunc Func _Auto($hWnd, $iMsg, $wParam, $lParam) ; If a device has been attached If $wParam = $DBT_DEVICEARRIVAL Then Switch $hWnd ; Check ALL the GUIs Case $hGUI, $hChild ; If the child has been created this will fire twice ConsoleWrite("Setting flag" & @CRLF) ; Set the flag $fFlag = True EndSwitch EndIf EndFunc ;==>_AutoEven though the flag will be set as many times as you have GUIs open (try with and without the child to see this in the SciTE console) you only check the flag every 250ms and also only clear the flag after the long check function - so there is essentially no chance that you will get the function running multiple times as you used to see with your earlier code. Please ask if anything is unclear. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now