Skip to content

Commit 50f6c7a

Browse files
author
James Forshaw
committed
Added C++ format option to Format-RpcServer.
1 parent ce67531 commit 50f6c7a

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

NtApiDotNet/Win32/RpcServer.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,20 @@ public string FormatAsText()
5656
/// <returns>The formatted RPC server.</returns>
5757
public string FormatAsText(bool remove_comments)
5858
{
59-
INdrFormatter formatter = DefaultNdrFormatter.Create(remove_comments
60-
? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None);
59+
return FormatAsText(remove_comments, false);
60+
}
61+
62+
/// <summary>
63+
/// Format the RPC server as text.
64+
/// </summary>
65+
/// <param name="remove_comments">True to remove comments from the output.</param>
66+
/// <param name="cpp_format">Formating using C++ pseduo syntax.</param>
67+
/// <returns>The formatted RPC server.</returns>
68+
public string FormatAsText(bool remove_comments, bool cpp_format)
69+
{
70+
DefaultNdrFormatterFlags flags = remove_comments
71+
? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None;
72+
INdrFormatter formatter = cpp_format ? CppNdrFormatter.Create(flags) : DefaultNdrFormatter.Create(flags);
6173
StringBuilder builder = new StringBuilder();
6274
if (!remove_comments)
6375
{

NtObjectManager/NtObjectManager.psm1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3581,6 +3581,8 @@ This cmdlet formats a list of RPC servers as text.
35813581
The RPC servers to format.
35823582
.PARAMETER RemoveComments
35833583
When outputing as text remove comments from the output.
3584+
.PARAMETER CppFormat
3585+
Format output in C++ pseudo syntax rather than C++.
35843586
.INPUTS
35853587
RpcServer[] The RPC servers to format.
35863588
.OUTPUTS
@@ -3600,12 +3602,13 @@ function Format-RpcServer {
36003602
Param(
36013603
[parameter(Mandatory=$true, Position=0, ValueFromPipeline)]
36023604
[NtApiDotNet.Win32.RpcServer[]]$RpcServer,
3603-
[switch]$RemoveComments
3605+
[switch]$RemoveComments,
3606+
[switch]$CppFormat
36043607
)
36053608

36063609
PROCESS {
36073610
foreach($server in $RpcServer) {
3608-
$server.FormatAsText($RemoveComments) | Write-Output
3611+
$server.FormatAsText($RemoveComments, $CppFormat) | Write-Output
36093612
}
36103613
}
36113614
}

0 commit comments

Comments
 (0)