Skip to content

Commit

Permalink
Added C++ format option to Format-RpcServer.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Forshaw committed Jan 21, 2020
1 parent ce67531 commit 50f6c7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 14 additions & 2 deletions NtApiDotNet/Win32/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,20 @@ public string FormatAsText()
/// <returns>The formatted RPC server.</returns>
public string FormatAsText(bool remove_comments)
{
INdrFormatter formatter = DefaultNdrFormatter.Create(remove_comments
? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None);
return FormatAsText(remove_comments, false);
}

/// <summary>
/// Format the RPC server as text.
/// </summary>
/// <param name="remove_comments">True to remove comments from the output.</param>
/// <param name="cpp_format">Formating using C++ pseduo syntax.</param>
/// <returns>The formatted RPC server.</returns>
public string FormatAsText(bool remove_comments, bool cpp_format)
{
DefaultNdrFormatterFlags flags = remove_comments
? DefaultNdrFormatterFlags.RemoveComments : DefaultNdrFormatterFlags.None;
INdrFormatter formatter = cpp_format ? CppNdrFormatter.Create(flags) : DefaultNdrFormatter.Create(flags);
StringBuilder builder = new StringBuilder();
if (!remove_comments)
{
Expand Down
7 changes: 5 additions & 2 deletions NtObjectManager/NtObjectManager.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3581,6 +3581,8 @@ This cmdlet formats a list of RPC servers as text.
The RPC servers to format.
.PARAMETER RemoveComments
When outputing as text remove comments from the output.
.PARAMETER CppFormat
Format output in C++ pseudo syntax rather than C++.
.INPUTS
RpcServer[] The RPC servers to format.
.OUTPUTS
Expand All @@ -3600,12 +3602,13 @@ function Format-RpcServer {
Param(
[parameter(Mandatory=$true, Position=0, ValueFromPipeline)]
[NtApiDotNet.Win32.RpcServer[]]$RpcServer,
[switch]$RemoveComments
[switch]$RemoveComments,
[switch]$CppFormat
)

PROCESS {
foreach($server in $RpcServer) {
$server.FormatAsText($RemoveComments) | Write-Output
$server.FormatAsText($RemoveComments, $CppFormat) | Write-Output
}
}
}
Expand Down

0 comments on commit 50f6c7a

Please sign in to comment.