Skip to content

Commit ecf1ab0

Browse files
committed
Added function to get the COM proxy information.
1 parent 525c11f commit ecf1ab0

File tree

2 files changed

+54
-8
lines changed

2 files changed

+54
-8
lines changed

NtObjectManager/NtObjectManager.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ FunctionsToExport = 'Get-AccessibleAlpcPort', 'Set-NtTokenPrivilege',
6060
'Resolve-NtObjectAddress', 'Invoke-NtToken', 'Get-NtFilteredToken', 'Get-NtLowBoxToken', 'Get-NtSecurityDescriptor',
6161
'Set-NtSecurityDescriptor', 'Add-NtVirtualMemory', 'Get-NtVirtualMemory', 'Remove-NtVirtualMemory', 'Set-NtVirtualMemory',
6262
'Read-NtVirtualMemory', 'Write-NtVirtualMemory', 'Get-EmbeddedAuthenticodeSignature', 'Get-NtSidName', 'New-SymbolResolver',
63-
'New-NdrParser', 'Format-NdrComplexType', 'Format-NdrProcedure', 'Format-NdrComProxy'
63+
'New-NdrParser', 'Format-NdrComplexType', 'Format-NdrProcedure', 'Format-NdrComProxy', 'Get-NdrComProxy'
6464

6565
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
6666
CmdletsToExport = 'Add-NtKey', 'Get-NtDirectory', 'Get-NtEvent', 'Get-NtFile',

NtObjectManager/NtObjectManager.psm1

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,8 +2001,8 @@ NtApiDotNet.Ndr.NdrParser - The NDR parser.
20012001
$ndr = New-NdrParser
20022002
Get 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
#>
20072007
function New-NdrParser {
20082008
Param(
@@ -2014,7 +2014,8 @@ function New-NdrParser {
20142014

20152015
function 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
20402086
Format 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.
20992145
function 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.
21412187
function 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

Comments
 (0)