|
| 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 | +} |
0 commit comments