Announcement

Collapse
No announcement yet.

Registry plugin

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Registry plugin

    Features:

    - Powerful registry search:
       -fast algorithm
       -principle of turn in stack (first in -> last out)
        i.e. search from first registry key to last
       -search for key, value and/or string in any root
       -search with name and/or type
       -search with banner support
       -search with subkeys or not
    - Read value of any type
    - Write value of any type
    - Create key
    - Delete key       (same as DeleteRegKey)
    - Delete value    (same as DeleteRegValue)


    Some performance info:

    Search in all HKEY_LOCAL_MACHINE where 60351 keys, 84714 values, 84714 strings

    Search only NOT existed value:    (/K=0 /V=1 /S=0 /N=`#Not Existed#`)
      With /B=0: 0 min 9 sec 580 ms
      With /B=1: 0 min 16 sec 300 ms
      With /B=2: 1 min 19 sec 486 ms

    Search any keys, values, strings:  (/K=1 /V=1 /S=1 /N=``)
      With /B=0: 2 min 46 sec 664 ms
      With /B=1: 2 min 56 sec 974 ms
      With /B=2: 6 min 2 sec 668 ms
    Attached Files
    my functions

  • #2
    Hey Instructor, nice work.

    I had started experimenting doing something similiar with the system plugin. But yours looks much better!

    Any chance you'll be adding support to import/export REG files?

    Comment


    • #3
      Hi, Comperio.

      Import/export simply doing with API RegSaveKey, RegRestoreKey and RegReplaceKey, BUT:

      [MSDN]
      Remarks

      There are two different registry hive file formats. Registry hives created on current operating systems typically cannot be loaded by earlier ones.
      RegRestoreKey
      [MSDN]
      Requirements
      Windows NT/2000/XP: Included in Windows NT 3.1 and later.
      Windows 95/98/Me: Unsupported.
      Header: Declared in Winreg.h; include Windows.h.
      Library: Use Advapi32.lib.
      Unicode: Implemented as Unicode and ANSI versions.
      So, probably there is only way to save multi-OS compatibility - write manually REG parser. I'll think that I can do.
      my functions

      Comment


      • #4
        hmmm. I see your point. But, if you can do it, I think importing/exporting REG files would be a very cool feature.

        And something you might consider:
        Most of the time, (at least for me anyway), reg files would be used as a means to backup and restore on the same system. So I don't think it's too important that a reg file created on a 9x computer is compatible with a XP computer. (Personally, if I were going to import reg files as part of an install, then I'd probably have 2 files--one for XP and one for 2K).

        But that's just me... Someone else may have a different view...

        Comment


        • #5
          Are you a developer who uses NSIS to distribute your application? Are you a Winamp plug-in developer who wants to use NSIS to distribute your plug-in? Have suggestions for other people like you? This is the place.
          my functions

          Comment


          • #6
            Changes:
            -Merged with REGEDIT4 plugin, probably this will be more comfortable for user.
             Increase plugin size to 13Kb, but you can simply recompile it, only with functions you need (see defines at the beginning of registry.c).

            -Fixed: registry:eleteKey in NT systems didn't delete subkeys

            -Fixed: problem with compiling "RegistryTest.nsi" when nxs plugin isn't exist

            -Now registry::RestoreKey checks if file exist


            "Registry" plugin v1.1
            Attached Files
            my functions

            Comment


            • #7
              Changes:
              -Fixed: Double calling GlobalFree in some case, that can cause crash
              (registry::Find, registry::Close)

              -Fixed: REG_RESOURCE_LIST, REG_NONE readed as string, instead of binary
              (registry::Find, registry::Read)

              -Added: Converts string to hex values
              (registry::StrToHex)

              -Added: Converts hex values to string
              (registry::HexToStr)

              -Full registry value types support, added:
              REG_FULL_RESOURCE_DESCRIPTOR
              REG_RESOURCE_REQUIREMENTS_LIST
              REG_QWORD


              BTW:
              While testing plugin in Microsoft XP I was found errors in REGEDIT with /a switch:
              -National characters incorrect exports from registry in hex format
              (first hex digit: c->1 d->2 e->3 f->4)
              -Special escape sequence "\n" is not replaced with "\\n"


              "Registry" plugin v1.2
              Attached Files
              my functions

              Comment


              • #8
                Short question cause urgent

                can i find all entries "defaulticon" with it ?
                And can i export them ?

                ###
                well that works, but i have empty entries

                code:
                [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.nsc\DefaultIcon]
                @=''

                it has to be
                code:
                [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.nsc\DefaultIcon]
                @="dxmasf.dll,-502"

                not all are empty
                code:
                [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Scripting Host\Script Extensions\.JS\DefaultIcon]
                @='%SystemRoot%\System32\wscript.exe,3'

                PHP Code:
                Name "DefaultIcon"
                OutFile "DefaultIcon.exe"

                Section 
                SectionEnd

                Function .onInit
                  IfFileExists 
                "DefaultIcon.reg" 0 noreg
                    Delete DefaultIcon
                .reg
                  noreg
                :

                  
                FileOpen $R1 "DefaultIcon.reg" w
                  FileWrite $R1 
                "REGEDIT4"
                  
                FileWriteByte $R1 "13"
                  
                FileWriteByte $R1 "10"
                  
                FileWriteByte $R1 "13"
                  
                FileWriteByte $R1 "10"

                  
                registry::Open /NOUNLOAD "HKEY_LOCAL_MACHINE" "/K=1 /V=1 /S=1 /B=1 /N='DefaultIcon'" .r0
                  StrCmp 
                $-1 end

                  loop
                :
                    
                registry::Find /NOUNLOAD .r1 .r2 .r3 .r4
                    IfErrors end
                    StrCmp 
                $"" end
                    StrCmp 
                $"" end
                    
                ;StrCmp $"" loop
                    
                ;StrCmp $"" loop

                    FileWrite $R1 
                "[HKEY_LOCAL_MACHINE\$1\$2]"
                    
                FileWriteByte $R1 "13"
                    
                FileWriteByte $R1 "10"
                    
                FileWrite $R1 "@='$3'"
                    
                FileWriteByte $R1 "13"
                    
                FileWriteByte $R1 "10"
                    
                FileWriteByte $R1 "13"
                    
                FileWriteByte $R1 "10"

                  
                Goto loop

                  end
                :
                  
                registry::Close

                FileClose $R1
                FunctionEnd 
                Last edited by Brummelchen; 18 August 2005, 13:50.
                Greets, Brummelchen

                Comment


                • #9
                  Ok, i did it this way..
                  PHP Code:
                  Name "DefaultIcon"
                  OutFile "DefaultIcon.exe"
                  AutoCloseWindow true

                  Section 
                  SectionEnd

                  Function .onInit
                    IfFileExists 
                  "DefaultIcon.reg" 0 noreg
                      Delete DefaultIcon
                  .reg
                    noreg
                  :

                    
                  FileOpen $R1 "DefaultIcon.reg" w
                    FileWrite $R1 
                  "REGEDIT4"
                    
                  FileWriteByte $R1 "13"
                    
                  FileWriteByte $R1 "10"
                    
                  FileWriteByte $R1 "13"
                    
                  FileWriteByte $R1 "10"

                    
                  registry::Open /NOUNLOAD "HKEY_LOCAL_MACHINE" "/K=1 /V=1 /S=1 /B=1 /N='DefaultIcon'" .r0
                    StrCmp 
                  $-1 end

                    loop
                  :
                      
                  registry::Find /NOUNLOAD .r1 .r2 .r3 .r4
                      IfErrors end
                      StrCmp 
                  $"" end
                      StrCmp 
                  $"" end
                      
                  ;StrCmp $"" loop
                      
                  ;StrCmp $"" loop

                      ReadRegStr $R2 HKLM 
                  "$1\$2" ""

                      
                  ;MessageBox MB_OKCANCEL "'$1\$2'$\n'$R2'$\n'$3''" IDCANCEL end

                      FileWrite $R1 
                  "[HKEY_LOCAL_MACHINE\$1\$2]"
                      
                  FileWriteByte $R1 "13"
                      
                  FileWriteByte $R1 "10"

                      
                  StrCmp $"" write_reg1
                        FileWrite $R1 
                  "@='$3'"
                        
                  Goto write_reg2
                      write_reg1
                  :
                        
                  FileWrite $R1 "@='$R2'"
                      
                  write_reg2:
                      
                  FileWriteByte $R1 "13"
                      
                  FileWriteByte $R1 "10"
                      
                  FileWriteByte $R1 "13"
                      
                  FileWriteByte $R1 "10"

                    
                  Goto loop

                    end
                  :
                    
                  registry::Close

                  FileClose $R1
                  FunctionEnd 
                  Greets, Brummelchen

                  Comment


                  • #10
                    well that works, but i have empty entries
                    This because "DefaultIcon" it is key (REG_KEY) and when key is found value and string are empty.
                    not all are empty
                    Do you use v1.2? In previos versions in NT systems strings not always updated.
                    my functions

                    Comment


                    • #11
                      Changes:
                      -Fixed: Cross-calling functions. Now posible for example:
                        registry::Open /NOUNLOAD ...
                        registry::Find /NOUNLOAD ...
                        registry::Read /NOUNLOAD ...
                        registry::Write /NOUNLOAD ...
                        registry::Close

                      -Fixed: registry::Read, when reading not existed value, returns "INVALID" registry type instead of "" (all output variables must be empty)

                      -Fixed: REG_LINK readed as string instead of binary

                      -Now posible to find default values (any type) or/and empty strings (REG_SZ, REG_EXPAND_SZ). Options with /N="" searches for empty names and without /N= for all names


                      "Registry" plugin v1.3
                      Attached Files
                      my functions

                      Comment


                      • #12
                        well - see - "defaulticon" can be in the path
                        [...\DefaultIcon]
                        and as an entry.
                        "DefaultIcon"=

                        And the example below has it both in the path...
                        but only one of it is read out

                        yes, was 1.2 and 1.3 shows same behaviour.

                        code:
                        [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.nsc\DefaultIcon]
                        @=''

                        code:
                        [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Scripting Host\Script Extensions\.JS\DefaultIcon]
                        @='%SystemRoot%\System32\wscript.exe,3'

                        Greets, Brummelchen

                        Comment


                        • #13
                          Try "Search and write founded in text file" example in RegistryTest.nsi with your registry::Open parameters and check output file.

                          [edit]
                          I have tested it with options you wrote before ["HKEY_LOCAL_MACHINE" "/K=1 /V=1 /S=1 /B=1 /N='DefaultIcon'"] and all fine.
                          [/edit]

                          [edit2]
                          Tested on XP and all fine. Founded ".JS" key, "DefaultIcon" is value - check your script:
                          code:

                          REG_SZ:"SOFTWARE\Microsoft\Windows Scripting Host\Script Extensions\.JS" "DefaultIcon"="%SystemRoot%\System32\wscript.exe,3"

                          [/edit2]
                          Last edited by Instructor; 19 August 2005, 23:12.
                          my functions

                          Comment


                          • #14
                            its not "JS"-problem, its here
                            code:
                            [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.nsc\DefaultIcon]
                            @=''

                            has to be
                            code:
                            [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.nsc\DefaultIcon]
                            @="dxmasf.dll,-502"

                            on some reason it is empty - try the first script above and test it pls (not the second)
                            Greets, Brummelchen

                            Comment


                            • #15
                              Why you didn't test "Search and write founded in text file"? With it no problem there is something in your script. Like I said before if you find registry key then string is EMPTY, registry::Find can't find registry key and they default string at the same time. You need to read it.
                              Try this:
                              code:

                              Name "DefaultIcon"
                              OutFile "DefaultIcon.exe"
                              AutoCloseWindow true

                              !include "WordFunc.nsh"
                              !insertmacro WordReplace

                              Section
                              StrCpy $R0 HKEY_LOCAL_MACHINE
                              FileOpen $R1 "DefaultIcon.reg" w
                              FileWrite $R1 "REGEDIT4$\r$\n$\r$\n"

                              registry::Open /NOUNLOAD "$R0" "/K=1 /V=0 /S=0 /B=1 /N='DefaultIcon'" .r0
                              StrCmp $0 -1 end

                              loop:
                              registry::Find /NOUNLOAD .r0 .r1 .r2 .r3
                              StrCmp $3 "" end

                              registry::Read /NOUNLOAD "$R0\$0\$1" "" .r4 .r5 .r6 .r7
                              StrCmp $6 "" loop

                              ${WordReplace} "$6" "\" "\\" "+" $6
                              ${WordReplace} "$6" '"' '\"' "+" $6
                              FileWrite $R1 '[$R0\$0\$1]$\r$\n'
                              FileWrite $R1 '@="$6"$\r$\n$\r$\n'
                              Goto loop

                              end:
                              registry::Close
                              FileClose $R1
                              SectionEnd

                              Last edited by Instructor; 21 August 2005, 07:05.
                              my functions

                              Comment

                              Working...
                              X