Searching for a better way to read nppPluginList.dll from Notepad++ install

rainmakers 311 Reputation points
2020-12-04T20:12:46.007+00:00

From the site it appears the nppPluginList.dll located {Notepad++ Install Directory}\plugins\Config\ is an encapsulated signed json file in a dll.
I can read the contents of the file, but there are a few hundred lines of NUL, FF, ACK, SOP, and other gibberish along with the signature at the end of the file. Using some regex I can exclude many of those lines, but is there a more elegant solution to read the contents of the file in case a future version of the file with other information than the json content.

Thanks in advance.
Joe--

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
{count} votes

Accepted answer
  1. rainmakers 311 Reputation points
    2020-12-11T18:14:00.257+00:00

    Thanks again for the script.
    However I think for my purposes using the regex similar to below works better.
    Thanks again all for your assistance.

     $reg = [regex]::New('(\"folder-name.*?homepage\"\:\s+\"h.*?\")','Multiline, Singleline')
    
     $a = Get-Content "C:\Program Files\Notepad++\plugins\Config\nppPluginList.dll"
     $myMatches = $reg.Matches($a)
    
     $i=0
     $mysplits = foreach ($myMatch in $myMatches){
       $mySplit = ($myMatch.Groups[1].Value) -split ",\s+\t" 
       $mySplit1 = $mysplit |foreach {$_ -replace  '^"(.*?)":\s?"(.*?)"$','$1 = $2'}
       $s1 =[System.String]::Join("`r`n", $mySplit1)
       ConvertFrom-StringData -StringData $s1 
       write-debug $i
       $i = $i+1
    
       }
    
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Rich Matheisen 45,096 Reputation points
    2020-12-05T03:13:07.587+00:00

    You're trying to read strings from a binary file? Try this: strings


  2. Rich Matheisen 45,096 Reputation points
    2020-12-07T19:38:07.497+00:00

    This is too long to be a comment, so I have to post it as an answer even though it may not be one.

    From what I recall, "strings" in a compiled object are identified as "Resources" and each of them have a name. If the compiled object has resources that have been localized (e.g. for different languages) then there will be a string for each culture. Given that I think you're looking at a file containing configuration options, I don't know if there are localized versions of the resource.

    This may be what you're looking for: how-to-get-the-string-resources-from-a-dll-file
    . . . as may this: system.resources.resourcemanager

    Pulling strings from a compiled object usually means just looking for strings of characters in specific ranges. This is an example of doing that in PowerShell: ReverseEngineering%5CGet-Strings.ps1


  3. Rich Matheisen 45,096 Reputation points
    2020-12-09T03:54:38.807+00:00

    Well, this isn't the prettiest thing I've ever written, but it seems to work for those web pages:

    $j = Invoke-WebRequest -Uri https://github.com/notepad-plus-plus/nppPluginList/blob/master/src/pl.x64.json
    
    $longstring = @()
    $HTML = New-Object -Com "HTMLFile"
    $HTML.IHTMLDocument2_write($j.content)
    $html.all.tags("TD")|
        ForEach-Object{
            if ($_.id -match 'LC\d+'){
                $i = $_.innerText
                if ($i -and $i.trim().length -gt 0){
                    $longstring += $i
                }
            }
        }
        $longstring | Out-File c:\junk\npp.txt