Skip to content

Commit 21e0bbe

Browse files
committed
Fixup COM proxy name.
1 parent 85097aa commit 21e0bbe

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

NtApiDotNet/Ndr/NdrComProxyDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ internal string Format(INdrFormatterInternal context)
8484
base_name = $"{context.FormatComment(unknown_iid)} IUnknown";
8585
}
8686

87-
builder.AppendLine("interface {0} : {1} {{", context.DemangleComName(Name), base_name);
87+
builder.AppendLine("interface {0} : {1} {{", context.GetProxyName(this), base_name);
8888
builder.PushIndent(' ', 4);
8989
foreach (NdrProcedureDefinition proc in Procedures)
9090
{

NtApiDotNet/Ndr/NdrFormatter.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ internal interface INdrFormatterInternal : INdrFormatter
5959
string FormatComment(string comment, params object[] args);
6060
string FormatPointer(string base_type);
6161
string IidToName(Guid iid);
62-
string DemangleComName(string name);
6362
bool ShowProcedureParameterAttributes { get; }
63+
string GetProxyName(NdrComProxyDefinition proxy);
6464
}
6565

6666
/// <summary>
@@ -80,10 +80,12 @@ internal NdrFormatter(IDictionary<Guid, string> iids_to_names, Func<string, stri
8080
_demangle_com_name = demangle_com_name ?? (s => s);
8181
_flags = flags;
8282
}
83+
8384
string INdrFormatterInternal.IidToName(Guid iid)
8485
{
8586
return IidToName(iid);
8687
}
88+
8789
protected string IidToName(Guid iid)
8890
{
8991
if (_iids_to_name.ContainsKey(iid))
@@ -93,9 +95,11 @@ protected string IidToName(Guid iid)
9395
return null;
9496
}
9597

96-
string INdrFormatterInternal.DemangleComName(string name)
98+
string INdrFormatterInternal.GetProxyName(NdrComProxyDefinition proxy)
9799
{
98-
return _demangle_com_name(name);
100+
if (string.IsNullOrWhiteSpace(proxy.Name))
101+
return IidToName(proxy.Iid) ?? $"intf_{proxy.Iid.ToString().Replace('-', '_')}";
102+
return _demangle_com_name(proxy.Name);
99103
}
100104

101105
string INdrFormatterInternal.SimpleTypeToName(NdrFormatCharacter format)
@@ -312,7 +316,7 @@ string INdrFormatter.FormatComProxy(NdrComProxyDefinition com_proxy)
312316
builder.AppendLine(
313317
"class __declspec(uuid(\"{0}\")) {1} : public {2} {{\npublic:",
314318
com_proxy.Iid,
315-
(this as INdrFormatterInternal).DemangleComName(com_proxy.Name),
319+
(this as INdrFormatterInternal).GetProxyName(com_proxy),
316320
base_name
317321
);
318322

0 commit comments

Comments
 (0)