internal virtual void Encode_header(NdrBuffer buf) { buf.Enc_ndr_small(5); buf.Enc_ndr_small(0); buf.Enc_ndr_small(Ptype); buf.Enc_ndr_small(Flags); buf.Enc_ndr_long(unchecked(0x00000010)); buf.Enc_ndr_short(Length); buf.Enc_ndr_short(0); buf.Enc_ndr_long(CallId); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_long(Length); dst.Enc_ndr_short(ImpersonationLevel); dst.Enc_ndr_small(ContextMode); dst.Enc_ndr_small(EffectiveOnly); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_long(TimeLow); dst.Enc_ndr_short(TimeMid); dst.Enc_ndr_short(TimeHiAndVersion); dst.Enc_ndr_small(ClockSeqHiAndReserved); dst.Enc_ndr_small(ClockSeqLow); int nodes = 6; int nodei = dst.Index; dst.Advance(1 * nodes); dst = dst.Derive(nodei); for (int i = 0; i < nodes; i++) { dst.Enc_ndr_small(Node[i]); } }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode_in(NdrBuffer dst) { dst.Enc_ndr_short(MaxXmit); dst.Enc_ndr_short(MaxRecv); dst.Enc_ndr_long(0); dst.Enc_ndr_small(1); dst.Enc_ndr_small(0); dst.Enc_ndr_short(0); dst.Enc_ndr_short(0); dst.Enc_ndr_small(1); dst.Enc_ndr_small(0); Binding.Uuid.Encode(dst); dst.Enc_ndr_short(Binding.Major); dst.Enc_ndr_short(Binding.Minor); DcerpcConstants.DcerpcUuidSyntaxNdr.Encode(dst); dst.Enc_ndr_long(2); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_long(Idx); dst.Enc_ndr_short(Name.Length); dst.Enc_ndr_short(Name.MaximumLength); dst.Enc_ndr_referent(Name.Buffer, 1); if (Name.Buffer != null) { dst = dst.Deferred; int nameBufferl = Name.Length / 2; int nameBuffers = Name.MaximumLength / 2; dst.Enc_ndr_long(nameBuffers); dst.Enc_ndr_long(0); dst.Enc_ndr_long(nameBufferl); int nameBufferi = dst.Index; dst.Advance(2 * nameBufferl); dst = dst.Derive(nameBufferi); for (int i = 0; i < nameBufferl; i++) { dst.Enc_ndr_short(Name.Buffer[i]); } } }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer buf) { int start = buf.GetIndex(); int allocHintIndex = 0; buf.Advance(16); if (Ptype == 0) { allocHintIndex = buf.GetIndex(); buf.Enc_ndr_long(0); buf.Enc_ndr_short(0); buf.Enc_ndr_short(GetOpnum()); } Encode_in(buf); Length = buf.GetIndex() - start; if (Ptype == 0) { buf.SetIndex(allocHintIndex); AllocHint = Length - allocHintIndex; buf.Enc_ndr_long(AllocHint); } buf.SetIndex(start); Encode_header(buf); buf.SetIndex(start + Length); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_short(Length); dst.Enc_ndr_short(MaximumLength); dst.Enc_ndr_referent(Buffer, 1); if (Buffer != null) { dst = dst.Deferred; int bufferl = Length / 2; int buffers = MaximumLength / 2; dst.Enc_ndr_long(buffers); dst.Enc_ndr_long(0); dst.Enc_ndr_long(bufferl); int bufferi = dst.Index; dst.Advance(2 * bufferl); dst = dst.Derive(bufferi); for (int i = 0; i < bufferl; i++) { dst.Enc_ndr_short(Buffer[i]); } } }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode_in(NdrBuffer dst) { Handle.Encode(dst); dst.Enc_ndr_short(Level); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_short(SidType); dst.Enc_ndr_long(Rid); dst.Enc_ndr_long(SidIndex); }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode(NdrBuffer dst) { dst.Align(4); dst.Enc_ndr_short(Name.Length); dst.Enc_ndr_short(Name.MaximumLength); dst.Enc_ndr_referent(Name.Buffer, 1); dst.Enc_ndr_short(DnsDomain.Length); dst.Enc_ndr_short(DnsDomain.MaximumLength); dst.Enc_ndr_referent(DnsDomain.Buffer, 1); dst.Enc_ndr_short(DnsForest.Length); dst.Enc_ndr_short(DnsForest.MaximumLength); dst.Enc_ndr_referent(DnsForest.Buffer, 1); dst.Enc_ndr_long(DomainGuid.TimeLow); dst.Enc_ndr_short(DomainGuid.TimeMid); dst.Enc_ndr_short(DomainGuid.TimeHiAndVersion); dst.Enc_ndr_small(DomainGuid.ClockSeqHiAndReserved); dst.Enc_ndr_small(DomainGuid.ClockSeqLow); int domainGuidNodes = 6; int domainGuidNodei = dst.Index; dst.Advance(1 * domainGuidNodes); dst.Enc_ndr_referent(Sid, 1); if (Name.Buffer != null) { dst = dst.Deferred; int nameBufferl = Name.Length / 2; int nameBuffers = Name.MaximumLength / 2; dst.Enc_ndr_long(nameBuffers); dst.Enc_ndr_long(0); dst.Enc_ndr_long(nameBufferl); int nameBufferi = dst.Index; dst.Advance(2 * nameBufferl); dst = dst.Derive(nameBufferi); for (int i = 0; i < nameBufferl; i++) { dst.Enc_ndr_short(Name.Buffer[i]); } } if (DnsDomain.Buffer != null) { dst = dst.Deferred; int dnsDomainBufferl = DnsDomain.Length / 2; int dnsDomainBuffers = DnsDomain.MaximumLength / 2; dst.Enc_ndr_long(dnsDomainBuffers); dst.Enc_ndr_long(0); dst.Enc_ndr_long(dnsDomainBufferl); int dnsDomainBufferi = dst.Index; dst.Advance(2 * dnsDomainBufferl); dst = dst.Derive(dnsDomainBufferi); for (int i = 0; i < dnsDomainBufferl; i++) { dst.Enc_ndr_short(DnsDomain.Buffer[i]); } } if (DnsForest.Buffer != null) { dst = dst.Deferred; int dnsForestBufferl = DnsForest.Length / 2; int dnsForestBuffers = DnsForest.MaximumLength / 2; dst.Enc_ndr_long(dnsForestBuffers); dst.Enc_ndr_long(0); dst.Enc_ndr_long(dnsForestBufferl); int dnsForestBufferi = dst.Index; dst.Advance(2 * dnsForestBufferl); dst = dst.Derive(dnsForestBufferi); for (int i = 0; i < dnsForestBufferl; i++) { dst.Enc_ndr_short(DnsForest.Buffer[i]); } } dst = dst.Derive(domainGuidNodei); for (int i1 = 0; i1 < domainGuidNodes; i1++) { dst.Enc_ndr_small(DomainGuid.Node[i1]); } if (Sid != null) { dst = dst.Deferred; Sid.Encode(dst); } }
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> public override void Encode_in(NdrBuffer dst) { Handle.Encode(dst); Sids.Encode(dst); Names.Encode(dst); dst.Enc_ndr_short(Level); dst.Enc_ndr_long(Count); }
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> /// <exception cref="System.IO.IOException"></exception> public virtual void Sendrecv(DcerpcMessage msg) { byte[] stub; byte[] frag; NdrBuffer buf; NdrBuffer fbuf; bool isLast; bool isDirect; DcerpcException de; if (State == 0) { Bind(); } isDirect = true; stub = BufferCache.GetBuffer(); try { int off; int tot; int n; buf = new NdrBuffer(stub, 0); msg.Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; msg.CallId = _callId++; msg.Encode(buf); if (SecurityProvider != null) { buf.SetIndex(0); SecurityProvider.Wrap(buf); } tot = buf.GetLength() - 24; off = 0; while (off < tot) { n = tot - off; if ((24 + n) > MaxXmit) { msg.Flags &= ~DcerpcConstants.DcerpcLastFrag; n = MaxXmit - 24; } else { msg.Flags |= DcerpcConstants.DcerpcLastFrag; isDirect = false; msg.AllocHint = n; } msg.Length = 24 + n; if (off > 0) { msg.Flags &= ~DcerpcConstants.DcerpcFirstFrag; } if ((msg.Flags & (DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag)) != (DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag)) { buf.Start = off; buf.Reset(); msg.Encode_header(buf); buf.Enc_ndr_long(msg.AllocHint); buf.Enc_ndr_short(0); buf.Enc_ndr_short(msg.GetOpnum()); } DoSendFragment(stub, off, msg.Length, isDirect); off += n; } DoReceiveFragment(stub, isDirect); buf.Reset(); buf.SetIndex(8); buf.SetLength(buf.Dec_ndr_short()); if (SecurityProvider != null) { SecurityProvider.Unwrap(buf); } buf.SetIndex(0); msg.Decode_header(buf); off = 24; if (msg.Ptype == 2 && msg.IsFlagSet(DcerpcConstants.DcerpcLastFrag) == false) { off = msg.Length; } frag = null; fbuf = null; while (msg.IsFlagSet(DcerpcConstants.DcerpcLastFrag) == false) { int stubFragLen; if (frag == null) { frag = new byte[MaxRecv]; fbuf = new NdrBuffer(frag, 0); } DoReceiveFragment(frag, isDirect); fbuf.Reset(); fbuf.SetIndex(8); fbuf.SetLength(fbuf.Dec_ndr_short()); if (SecurityProvider != null) { SecurityProvider.Unwrap(fbuf); } fbuf.Reset(); msg.Decode_header(fbuf); stubFragLen = msg.Length - 24; if ((off + stubFragLen) > stub.Length) { // shouldn't happen if alloc_hint is correct or greater byte[] tmp = new byte[off + stubFragLen]; Array.Copy(stub, 0, tmp, 0, off); stub = tmp; } Array.Copy(frag, 24, stub, off, stubFragLen); off += stubFragLen; } buf = new NdrBuffer(stub, 0); msg.Decode(buf); } finally { BufferCache.ReleaseBuffer(stub); } if ((de = msg.GetResult()) != null) { throw de; } }