@@ -2159,20 +2159,19 @@ function Set-ExecutionAlias
21592159function Start-NtTokenViewer {
21602160 param (
21612161 [Parameter (Mandatory = $true , Position = 0 )]
2162- [NtApiDotNet.NtToken ] $Token ,
2162+ [NtApiDotNet.NtObject ] $Handle ,
21632163 [string ]$Text
21642164 )
21652165
2166- Use-NtObject ($dup_token = $Token .Duplicate ()) {
2167- $dup_token .Inherit = $true
2168- $cmdline = [string ]::Format(" TokenViewer --handle={0}" , $dup_token .Handle.DangerousGetHandle ())
2166+ Use-NtObject ($dup_handle = $Handle .Duplicate ()) {
2167+ $dup_handle .Inherit = $true
2168+ $cmdline = [string ]::Format(" TokenViewer --handle={0}" , $dup_handle .Handle.DangerousGetHandle ())
21692169 if ($Text -ne " " ) {
21702170 $cmdline += " "" --text=$Text "" "
21712171 }
21722172 $config = New-Win32ProcessConfig $cmdline - ApplicationName " $PSScriptRoot \TokenViewer.exe" - InheritHandles
2173- $config.InheritHandleList.Add ($dup_token.Handle.DangerousGetHandle ())
2174- Use-NtObject ($p = New-Win32Process - Config $config ) {
2175- }
2173+ $config.InheritHandleList.Add ($dup_handle.Handle.DangerousGetHandle ())
2174+ Use-NtObject ($p = New-Win32Process - Config $config ) {}
21762175 }
21772176}
21782177
@@ -2255,10 +2254,8 @@ function Show-NtToken {
22552254 }
22562255 switch ($PSCmdlet.ParameterSetName ) {
22572256 " FromProcess" {
2258- Use-NtObject ($t = Get-NtToken - Primary - Process $Process ) {
2259- $text = " $ ( $Process.Name ) :$ ( $Process.ProcessId ) "
2260- Start-NtTokenViewer $t - Text $text
2261- }
2257+ $text = " $ ( $Process.Name ) :$ ( $Process.ProcessId ) "
2258+ Start-NtTokenViewer $Process - Text $text
22622259 }
22632260 " FromName" {
22642261 Use-NtObject ($ps = Get-NtProcess - Name $Name - Access QueryLimitedInformation) {
0 commit comments