@@ -2001,8 +2001,8 @@ NtApiDotNet.Ndr.NdrParser - The NDR parser.
20012001$ndr = New-NdrParser
20022002Get an NDR parser for the current process.
20032003. EXAMPLE
2004- New-NdrParserNew -Process $p -SymbolResolver $resolver
2005- Get an NDR parser for a specific process with a know resolver.
2004+ New-NdrParser -Process $p -SymbolResolver $resolver
2005+ Get an NDR parser for a specific process with a known resolver.
20062006#>
20072007function New-NdrParser {
20082008 Param (
@@ -2014,7 +2014,8 @@ function New-NdrParser {
20142014
20152015function Convert-HashTableToIidNames {
20162016 Param (
2017- [Hashtable ]$IidToName
2017+ [Hashtable ]$IidToName ,
2018+ [NtApiDotNet.Ndr.NdrComProxyDefinition []]$Proxy
20182019 )
20192020 $dict = [System.Collections.Generic.Dictionary [Guid , string ]]::new()
20202021 if ($IidToName -ne $null ) {
@@ -2024,6 +2025,12 @@ function Convert-HashTableToIidNames {
20242025 }
20252026 }
20262027
2028+ if ($Proxy -ne $null ) {
2029+ foreach ($p in $Proxy ) {
2030+ $dict.Add ($p.Iid , $p.Name )
2031+ }
2032+ }
2033+
20272034 if (! $dict.ContainsKey (" 00000000-0000-0000-C000-000000000046" )) {
20282035 $dict.Add (" 00000000-0000-0000-C000-000000000046" , " IUnknown" )
20292036 }
@@ -2035,6 +2042,45 @@ function Convert-HashTableToIidNames {
20352042 return $dict
20362043}
20372044
2045+ <#
2046+ . SYNOPSIS
2047+ Parses COM proxy information from a DLL.
2048+ . DESCRIPTION
2049+ This cmdlet parses the COM proxy information from a specified DLL.
2050+ . PARAMETER Path
2051+ The path to the DLL containing the COM proxy information.
2052+ . PARAMETER Clsid
2053+ Optional CLSID for the object used to find the proxy information.
2054+ . OUTPUTS
2055+ The parsed proxy information and complex types.
2056+ . EXAMPLE
2057+ $p = Get-NdrComProxy c:\path\to\proxy.dll
2058+ Parse the proxy information from c:\path\to\proxy.dll
2059+ . EXAMPLE
2060+ $p = Get-NdrComProxy $env:SystemRoot\system32\combase.dll -Clsid "00000320-0000-0000-C000-000000000046"
2061+ Parse the proxy information from combase.dll with a specific proxy CLSID.
2062+ #>
2063+ function Get-NdrComProxy {
2064+ Param (
2065+ [parameter (Mandatory , Position = 0 )]
2066+ [string ]$Path ,
2067+ [Guid ]$Clsid = [Guid ]::Empty,
2068+ [NtApiDotNet.Win32.ISymbolResolver ]$SymbolResolver
2069+ )
2070+ $Path = Resolve-Path $Path - ErrorAction Stop
2071+ Use-NtObject ($parser = New-NdrParser - SymbolResolver $SymbolResolver ) {
2072+ $proxies = $parser.ReadFromComProxyFile ($Path , $Clsid )
2073+ $props = @ {
2074+ Path = $Path ;
2075+ Proxies = $proxies ;
2076+ ComplexTypes = $parser.ComplexTypes ;
2077+ IidToNames = Convert-HashTableToIidNames - Proxy $proxies ;
2078+ }
2079+ $obj = New-Object –TypeName PSObject –Prop $props
2080+ Write-Output $obj
2081+ }
2082+ }
2083+
20382084<#
20392085. SYNOPSIS
20402086Format an NDR procedure.
@@ -2060,7 +2106,7 @@ function Format-NdrProcedure {
20602106 [CmdletBinding ()]
20612107 Param (
20622108 [parameter (Mandatory , Position = 0 , ValueFromPipeline = $true )]
2063- [NtApiDotNet.Ndr.NdrProcedureDefinition ]$Procedure ,
2109+ [NtApiDotNet.Ndr.NdrProcedureDefinition ]$Procedure ,
20642110 [Hashtable ]$IidToName
20652111 )
20662112
@@ -2099,8 +2145,8 @@ Format a complex type with a known IID to name mapping.
20992145function Format-NdrComplexType {
21002146 [CmdletBinding ()]
21012147 Param (
2102- [parameter (Mandatory , Position = 0 , ValueFromPipeline = $true )]
2103- [NtApiDotNet.Ndr.NdrComplexTypeReference ]$ComplexType ,
2148+ [parameter (Mandatory , Position = 0 , ValueFromPipeline )]
2149+ [NtApiDotNet.Ndr.NdrComplexTypeReference ]$ComplexType ,
21042150 [Hashtable ]$IidToName
21052151 )
21062152
@@ -2141,7 +2187,7 @@ Format a COM proxy with a known IID to name mapping.
21412187function Format-NdrComProxy {
21422188 [CmdletBinding ()]
21432189 Param (
2144- [parameter (Mandatory , Position = 0 , ValueFromPipeline = $true )]
2190+ [parameter (Mandatory , Position = 0 , ValueFromPipeline )]
21452191 [NtApiDotNet.Ndr.NdrComProxyDefinition ]$Proxy ,
21462192 [Hashtable ]$IidToName ,
21472193 [ScriptBlock ]$DemangleComName
0 commit comments