Skip to content

Commit c3caa1f

Browse files
committed
Cleanup bind.
1 parent c279c2d commit c3caa1f

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

NtApiDotNet/Win32/Rpc/Transport/RpcConnectedClientTransport.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,16 @@ private byte[] SendReceiveRequestPDU(int proc_num, Guid objuuid, byte[] stub_dat
349349
}
350350
}
351351

352-
private void BindNoAuth(Guid interface_id, Version interface_version, Guid transfer_syntax_id, Version transfer_syntax_version)
352+
private void BindNoAuth()
353353
{
354354
PDUBind bind_pdu = new PDUBind(_max_send_fragment, _max_recv_fragment, false);
355-
bind_pdu.Elements.Add(new ContextElement(interface_id, interface_version, transfer_syntax_id, transfer_syntax_version));
355+
bind_pdu.Elements.Add(new ContextElement(_interface_id, _interface_version, _transfer_syntax_id, _transfer_syntax_version));
356356
var recv_pdu = SendReceivePDU(++CallId, bind_pdu, new byte[0], true).Item1;
357357
if (recv_pdu is PDUBindAck bind_ack)
358358
{
359359
if (bind_ack.ResultList.Count != 1 || bind_ack.ResultList[0].Result != PresentationResultType.Acceptance)
360360
{
361-
throw new RpcTransportException($"Bind to {interface_id}:{interface_version} was rejected.");
361+
throw new RpcTransportException($"Bind to {_interface_id}:{_interface_version} was rejected.");
362362
}
363363

364364
_max_recv_fragment = bind_ack.MaxRecvFrag;
@@ -374,23 +374,22 @@ private void BindNoAuth(Guid interface_id, Version interface_version, Guid trans
374374
}
375375
}
376376

377-
private void BindAuth(Guid interface_id, Version interface_version, Guid transfer_syntax_id, Version transfer_syntax_version)
377+
private void BindAuth(bool alter_context)
378378
{
379379
// 8 should be more than enough legs to complete authentication.
380380
int max_legs = _transport_security.AuthenticationType == RpcAuthenticationType.WinNT ? 3 : 8;
381381
int call_id = ++CallId;
382382
int count = 0;
383-
bool alter_context = false;
384383

385384
while (count++ < max_legs)
386385
{
387386
PDUBind bind_pdu = new PDUBind(_max_send_fragment, _max_recv_fragment, alter_context);
388387

389-
bind_pdu.Elements.Add(new ContextElement(interface_id, interface_version, transfer_syntax_id, transfer_syntax_version));
388+
bind_pdu.Elements.Add(new ContextElement(_interface_id, _interface_version, _transfer_syntax_id, _transfer_syntax_version));
390389
if (!_bind_time_features.HasValue)
391390
{
392391
_bind_time_features = BindTimeFeatureNegotiation.None;
393-
bind_pdu.Elements.Add(new ContextElement(interface_id, interface_version,
392+
bind_pdu.Elements.Add(new ContextElement(_interface_id, _interface_version,
394393
BindTimeFeatureNegotiation.SecurityContextMultiplexingSupported));
395394
}
396395

@@ -399,7 +398,7 @@ private void BindAuth(Guid interface_id, Version interface_version, Guid transfe
399398
{
400399
if (bind_ack.ResultList.Count < 1 || bind_ack.ResultList[0].Result != PresentationResultType.Acceptance)
401400
{
402-
throw new RpcTransportException($"Bind to {interface_id}:{interface_version} was rejected.");
401+
throw new RpcTransportException($"Bind to {_interface_id}:{_interface_version} was rejected.");
403402
}
404403

405404
if (bind_ack.ResultList.Count == 2)
@@ -544,11 +543,11 @@ public void Bind(Guid interface_id, Version interface_version, Guid transfer_syn
544543

545544
if (_transport_security.AuthenticationLevel == RpcAuthenticationLevel.None)
546545
{
547-
BindNoAuth(interface_id, interface_version, transfer_syntax_id, transfer_syntax_version);
546+
BindNoAuth();
548547
}
549548
else
550549
{
551-
BindAuth(interface_id, interface_version, transfer_syntax_id, transfer_syntax_version);
550+
BindAuth(false);
552551
}
553552
}
554553

0 commit comments

Comments
 (0)