Accessing private members from powershell

前端 未结 4 1430
日久生厌
日久生厌 2021-01-12 10:39

I\'m trying to get Uri to stop encoding \'/\' As explained here: GETting a URL with an url-encoded slash

But how to achieve the same in powershell ?

I\'m tr

4条回答
  •  [愿得一人]
    2021-01-12 11:28

    Taking that other post as what you need, you want this:

    $uri = [uri]"http://example.com/%2F"
    $f = [uri].getfield("m_Flags", "nonpublic,instance")
    $v = [int]($f.getvalue($uri))
    $f.setvalue($uri, [uint64]($v -band (-bnot 0x30)))
    

    PowerShell's -bnot and -band bitwise operators don't work with any types bigger than [int] so I'm downcasting to [int] which does not overflow for the above case (which means flag values beyond [int]::maxvalue are not present.)

提交回复
热议问题