Jump to content

Registry Searcher


Recommended Posts

okay so i found some code by PsaltyDS that does what i need kind of but im having some trouble making it list propperly

i know the extent of how his code is working and ive changed it quite a bit for my script but for some reason i cant seem

to get past where i am right now... could anyone take a look at this and tell me where im going wrong

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

$Form1 = GUICreate("K1 Registry Scanner", 875, 629, 192, 124)
$TreeView1 = GUICtrlCreateTreeView(0, 0, 353, 593)
$List1 = GUICtrlCreateList("", 360, 0, 513, 591)
$Input1 = GUICtrlCreateInput("Search Criteria", 0, 600, 273, 21)
$Button1 = GUICtrlCreateButton("Search", 280, 600, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Delete", 360, 600, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Quarentine", 648, 600, 75, 25, $WS_GROUP)
$Button4 = GUICtrlCreateButton("Modify", 792, 600, 75, 25, $WS_GROUP)
$Button5 = GUICtrlCreateButton("Delete All", 504, 600, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)


Dim $readvaz[1000]
Dim $item[1000]
$item[0] = 1
$readvaz = 1

$SearchKey = "HKLM\software"
$SearchString = "test"
$Results = _RegSearch($SearchKey, $SearchString)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _RegSearch($sStartKey, $sSearchVal, $iType = 0x07, $fArray = False)
    Local $v, $sVal, $k, $sKey, $sFound = "", $avFound[1] = [0]

    If Not BitAND($iType, 0x07) Then Return SetError(1, 0, 0)
    Local $fKeys = BitAND($iType, 0x1), $fValue = BitAND($iType, 0x2), $fData = BitAND($iType, 0x4)

    If ($fValue Or $fData) Then
        $v = 1
        While 1
            $sVal = RegEnumVal($sStartKey, $v)
            If @error = 0 Then
                If $fValue And StringInStr($sVal, $sSearchVal) Then $sFound &= $sStartKey & "\" & $sVal & @LF
                If $fData Then
                    $readval = RegRead($sStartKey, $sVal)
                    If StringInStr($readval, $sSearchVal) Then
                        $sFound &= $sStartKey & "\" & $sVal & " = " & $readval & @LF
                        if StringLeft($sFound,4) = "HKLM" Then
                            $getit = _GUICtrlTreeView_GetText($TreeView1,$item[$item[0]])
                            If $sStartKey = $getit Then
                                _GUICtrlTreeView_AddChild($TreeView1,$item[$item[0]], $sVal)
                            Else
                                $item[0] += 1
                                $item[$item[0]] = _GUICtrlTreeView_Add($TreeView1,0,$sStartKey)
                                _GUICtrlTreeView_AddChild($TreeView1,$item[$item[0]], $sVal & " = " & $readval)
                            EndIf
                        Else
                            $item[0] += 1
                            $item[$item[0]] = _GUICtrlTreeView_Add($TreeView1,0,$sStartKey)
                            _GUICtrlTreeView_AddChild($TreeView1,$item[$item[0]], $sVal  & " = " & $readval)
                        EndIf
                        EndIf
                    EndIf
                EndIf
                $v += 1
                ExitLoop
        WEnd
    EndIf
    $k = 1
    While 1
        $sKey = RegEnumKey($sStartKey, $k)
        If @error = 0 Then
            If $fKeys And StringInStr($sKey, $sSearchVal) Then $sFound &= $sStartKey & "\" & $sKey & "\" & @LF
            $sFound &= _RegSearch($sStartKey & "\" & $sKey, $sSearchVal, $iType)
;~          Buffadd($sStartKey & "\" & $sKal, $sSearchVal ,$k)
        Else
            ExitLoop
        EndIf
        $k += 1
    WEnd

If StringRight($sFound, 1) = @LF Then $sFound = StringTrimRight($sFound, 1)
        If $fArray Then
        If StringStripWS($sFound, 8) <> "" Then $avFound = StringSplit($sFound, @LF)
        Return $avFound
    Else
        Return $sFound
    EndIf
EndFunc
Link to comment
Share on other sites

It's really a good idea for a tool and autoit seems to be good at facilitating the information queries. However I have never used autoit to for the type of thing your doing so I don't know anything about it. Your code is big can you be more specif as to where the problem might be? I'm going to copy your code for reference in case I want to do something similar. But for now I have no idea why your code isn't working I don't know enough about the functions and what not.

My suggestion is to try and be more specif as to where the error might be happening or what the error is.

good luck with your program

sorry i'm tired your having trouble making it list properly, I'm not sure how that works but you create a list right and then feed items into the list? I'm not sure. I'm not really any help my bad

Edited by songersoft
Link to comment
Share on other sites

Start from this stripped down version (nobody want to pick their way past useless and unused lines of code) and post what it does that you don't want it to, or doesn't do that you want it to...

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>

Opt("GuiOnEventMode", 1)

$Form1 = GUICreate("K1 Registry Scanner", 875, 629, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$TreeView1 = GUICtrlCreateTreeView(0, 0, 353, 593)
GUISetState(@SW_SHOW)

Dim $item[1000]
$item[0] = 1

$SearchKey = "HKLM\software"
$SearchString = "test"
$Results = _RegSearch($SearchKey, $SearchString)

While 1
    Sleep(20)
WEnd

Func _RegSearch($sStartKey, $sSearchVal, $iType = 0x07, $fArray = False)
    Local $v, $sVal, $k, $sKey, $sFound = "", $avFound[1] = [0]

    If Not BitAND($iType, 0x07) Then Return SetError(1, 0, 0)
    Local $fKeys = BitAND($iType, 0x1), $fValue = BitAND($iType, 0x2), $fData = BitAND($iType, 0x4)

    If ($fValue Or $fData) Then
        $v = 1
        While 1
            $sVal = RegEnumVal($sStartKey, $v)
            If @error = 0 Then
                If $fValue And StringInStr($sVal, $sSearchVal) Then $sFound &= $sStartKey & "\" & $sVal & @LF
                If $fData Then
                    $readval = RegRead($sStartKey, $sVal)
                    If StringInStr($readval, $sSearchVal) Then
                        $sFound &= $sStartKey & "\" & $sVal & " = " & $readval & @LF
                        If StringLeft($sFound, 4) = "HKLM" Then
                            $getit = _GUICtrlTreeView_GetText($TreeView1, $item[$item[0]])
                            If $sStartKey = $getit Then
                                _GUICtrlTreeView_AddChild($TreeView1, $item[$item[0]], $sVal)
                            Else
                                $item[0] += 1
                                $item[$item[0]] = _GUICtrlTreeView_Add($TreeView1, 0, $sStartKey)
                                _GUICtrlTreeView_AddChild($TreeView1, $item[$item[0]], $sVal & " = " & $readval)
                            EndIf
                        Else
                            $item[0] += 1
                            $item[$item[0]] = _GUICtrlTreeView_Add($TreeView1, 0, $sStartKey)
                            _GUICtrlTreeView_AddChild($TreeView1, $item[$item[0]], $sVal & " = " & $readval)
                        EndIf
                    EndIf
                EndIf
            EndIf
            $v += 1
            ExitLoop
        WEnd
    EndIf
    $k = 1
    While 1
        $sKey = RegEnumKey($sStartKey, $k)
        If @error = 0 Then
            If $fKeys And StringInStr($sKey, $sSearchVal) Then $sFound &= $sStartKey & "\" & $sKey & "\" & @LF
            $sFound &= _RegSearch($sStartKey & "\" & $sKey, $sSearchVal, $iType)
        Else
            ExitLoop
        EndIf
        $k += 1
    WEnd

    If StringRight($sFound, 1) = @LF Then $sFound = StringTrimRight($sFound, 1)
    If $fArray Then
        If StringStripWS($sFound, 8) <> "" Then $avFound = StringSplit($sFound, @LF)
        Return $avFound
    Else
        Return $sFound
    EndIf
EndFunc   ;==>_RegSearch

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:blink:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...