Skip to content

Commit 0c40679

Browse files
committed
Reworked source. Added support for a search binding handle for querying the endpoint mapper.
1 parent 87ac71e commit 0c40679

9 files changed

Lines changed: 421 additions & 274 deletions

NtApiDotNet/NtApiDotNet.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@
301301
<Compile Include="Win32\AppModel\AppModelUtils.cs" />
302302
<Compile Include="Win32\AppModel\IApplicationActivationManager.cs" />
303303
<Compile Include="Win32\ConsoleSession.cs" />
304+
<Compile Include="Win32\Rpc\CrackedBindingString.cs" />
304305
<Compile Include="Win32\Debugger\ArrayTypeInformation.cs" />
305306
<Compile Include="Win32\Debugger\BaseTypeInformation.cs" />
306307
<Compile Include="Win32\Debugger\DataSymbolInformation.cs" />
@@ -359,6 +360,10 @@
359360
<Compile Include="Win32\RpcServerParserFlags.cs" />
360361
<Compile Include="Win32\SafeHandles\SafeLsaLogonHandle.cs" />
361362
<Compile Include="Utilities\ASN1\DERParser.cs" />
363+
<Compile Include="Win32\SafeHandles\SafeRpcBindingHandle.cs" />
364+
<Compile Include="Win32\SafeHandles\SafeRpcIfIdVectorHandle.cs" />
365+
<Compile Include="Win32\SafeHandles\SafeRpcInquiryHandle.cs" />
366+
<Compile Include="Win32\SafeHandles\SafeRpcStringHandle.cs" />
362367
<Compile Include="Win32\Security\Authentication\ASN1AuthenticationToken.cs" />
363368
<Compile Include="Win32\Security\Authentication\AuthenticationKey.cs" />
364369
<Compile Include="Win32\Security\Authentication\GSSAPIUtils.cs" />
@@ -557,7 +562,9 @@
557562
<ItemGroup>
558563
<None Include="Readme.txt" />
559564
</ItemGroup>
560-
<ItemGroup />
565+
<ItemGroup>
566+
<Folder Include="Win32\Rpc\Internal\" />
567+
</ItemGroup>
561568
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
562569
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
563570
Other similar extension points exist, see Microsoft.Common.targets.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2018 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
using NtApiDotNet.Win32.SafeHandles;
16+
17+
namespace NtApiDotNet.Win32.Rpc
18+
{
19+
internal class CrackedBindingString
20+
{
21+
public string ObjUuid { get; }
22+
public string Protseq { get; }
23+
public string NetworkAddr { get; }
24+
public string Endpoint { get; }
25+
public string NetworkOptions { get; }
26+
27+
public CrackedBindingString(string string_binding)
28+
{
29+
SafeRpcStringHandle objuuid = null;
30+
SafeRpcStringHandle protseq = null;
31+
SafeRpcStringHandle endpoint = null;
32+
SafeRpcStringHandle networkaddr = null;
33+
SafeRpcStringHandle networkoptions = null;
34+
35+
try
36+
{
37+
int status = Win32NativeMethods.RpcStringBindingParse(string_binding,
38+
out objuuid, out protseq, out networkaddr, out endpoint, out networkoptions);
39+
if (status == 0)
40+
{
41+
ObjUuid = objuuid.ToString();
42+
Protseq = protseq.ToString();
43+
Endpoint = endpoint.ToString();
44+
NetworkAddr = networkaddr.ToString();
45+
NetworkOptions = networkoptions.ToString();
46+
}
47+
else
48+
{
49+
ObjUuid = string.Empty;
50+
Protseq = string.Empty;
51+
Endpoint = string.Empty;
52+
NetworkAddr = string.Empty;
53+
NetworkOptions = string.Empty;
54+
}
55+
}
56+
finally
57+
{
58+
objuuid?.Dispose();
59+
protseq?.Dispose();
60+
endpoint?.Dispose();
61+
networkaddr?.Dispose();
62+
networkoptions?.Dispose();
63+
}
64+
}
65+
}
66+
}

NtApiDotNet/Win32/Rpc/RpcClientBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using NtApiDotNet.Ndr;
1616
using NtApiDotNet.Ndr.Marshal;
1717
using NtApiDotNet.Win32.Rpc.Transport;
18+
using NtApiDotNet.Win32.SafeHandles;
1819
using System;
1920
using System.Collections.Generic;
2021
using System.Diagnostics;

NtApiDotNet/Win32/RpcEndpoint.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
using NtApiDotNet.Win32.Rpc;
15+
using NtApiDotNet.Win32.Rpc;
16+
using NtApiDotNet.Win32.SafeHandles;
1617
using System;
1718

1819
namespace NtApiDotNet.Win32

0 commit comments

Comments
 (0)