Dec_ndr_short() public method

public Dec_ndr_short ( ) : int
return int
Esempio n. 1
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				TimeLow = src.Dec_ndr_long();
				TimeMid = (short)src.Dec_ndr_short();
				TimeHiAndVersion = (short)src.Dec_ndr_short();
				ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
				ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
				int nodes = 6;
				int nodei = src.Index;
				src.Advance(1 * nodes);
				if (Node == null)
				{
					if (nodes < 0 || nodes > unchecked(0xFFFF))
					{
						throw new NdrException(NdrException.InvalidConformance);
					}
					Node = new byte[nodes];
				}
				src = src.Derive(nodei);
				for (int i = 0; i < nodes; i++)
				{
					Node[i] = unchecked((byte)src.Dec_ndr_small());
				}
			}
Esempio n. 2
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				Length = src.Dec_ndr_long();
				ImpersonationLevel = (short)src.Dec_ndr_short();
				ContextMode = unchecked((byte)src.Dec_ndr_small());
				EffectiveOnly = unchecked((byte)src.Dec_ndr_small());
			}
Esempio n. 3
0
		/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
		internal virtual void Decode_header(NdrBuffer buf)
		{
			if (buf.Dec_ndr_small() != 5 || buf.Dec_ndr_small() != 0)
			{
				throw new NdrException("DCERPC version not supported");
			}
			Ptype = buf.Dec_ndr_small();
			Flags = buf.Dec_ndr_small();
			if (buf.Dec_ndr_long() != unchecked(0x00000010))
			{
				throw new NdrException("Data representation not supported");
			}
			Length = buf.Dec_ndr_short();
			if (buf.Dec_ndr_short() != 0)
			{
				throw new NdrException("DCERPC authentication not supported");
			}
			CallId = buf.Dec_ndr_long();
		}
Esempio n. 4
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				Idx = src.Dec_ndr_long();
				src.Align(4);
				if (Name == null)
				{
					Name = new Rpc.Unicode_string();
				}
				Name.Length = (short)src.Dec_ndr_short();
				Name.MaximumLength = (short)src.Dec_ndr_short();
				int nameBufferp = src.Dec_ndr_long();
				if (nameBufferp != 0)
				{
					src = src.Deferred;
					int nameBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int nameBufferl = src.Dec_ndr_long();
					int nameBufferi = src.Index;
					src.Advance(2 * nameBufferl);
					if (Name.Buffer == null)
					{
						if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						Name.Buffer = new short[nameBuffers];
					}
					src = src.Derive(nameBufferi);
					for (int i = 0; i < nameBufferl; i++)
					{
						Name.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
			}
Esempio n. 5
0
		/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
		public override void Decode(NdrBuffer buf)
		{
			Decode_header(buf);
			if (Ptype != 12 && Ptype != 2 && Ptype != 3 && Ptype != 13)
			{
				throw new NdrException("Unexpected ptype: " + Ptype);
			}
			if (Ptype == 2 || Ptype == 3)
			{
				AllocHint = buf.Dec_ndr_long();
				buf.Dec_ndr_short();
				buf.Dec_ndr_short();
			}
			if (Ptype == 3 || Ptype == 13)
			{
				Result = buf.Dec_ndr_long();
			}
			else
			{
				Decode_out(buf);
			}
		}
Esempio n. 6
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				Length = (short)src.Dec_ndr_short();
				MaximumLength = (short)src.Dec_ndr_short();
				int bufferp = src.Dec_ndr_long();
				if (bufferp != 0)
				{
					src = src.Deferred;
					int buffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int bufferl = src.Dec_ndr_long();
					int bufferi = src.Index;
					src.Advance(2 * bufferl);
					if (Buffer == null)
					{
						if (buffers < 0 || buffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						Buffer = new short[buffers];
					}
					src = src.Derive(bufferi);
					for (int i = 0; i < bufferl; i++)
					{
						Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
			}
Esempio n. 7
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode_out(NdrBuffer src)
			{
				int infop = src.Dec_ndr_long();
				if (infop != 0)
				{
					src.Dec_ndr_short();
					Info.Decode(src);
				}
				Retval = src.Dec_ndr_long();
			}
Esempio n. 8
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				SidType = src.Dec_ndr_short();
				Rid = src.Dec_ndr_long();
				SidIndex = src.Dec_ndr_long();
			}
Esempio n. 9
0
			/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
			public override void Decode(NdrBuffer src)
			{
				src.Align(4);
				src.Align(4);
				if (Name == null)
				{
					Name = new Rpc.Unicode_string();
				}
				Name.Length = (short)src.Dec_ndr_short();
				Name.MaximumLength = (short)src.Dec_ndr_short();
				int nameBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DnsDomain == null)
				{
					DnsDomain = new Rpc.Unicode_string();
				}
				DnsDomain.Length = (short)src.Dec_ndr_short();
				DnsDomain.MaximumLength = (short)src.Dec_ndr_short();
				int dnsDomainBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DnsForest == null)
				{
					DnsForest = new Rpc.Unicode_string();
				}
				DnsForest.Length = (short)src.Dec_ndr_short();
				DnsForest.MaximumLength = (short)src.Dec_ndr_short();
				int dnsForestBufferp = src.Dec_ndr_long();
				src.Align(4);
				if (DomainGuid == null)
				{
					DomainGuid = new Rpc.UuidT();
				}
				DomainGuid.TimeLow = src.Dec_ndr_long();
				DomainGuid.TimeMid = (short)src.Dec_ndr_short();
				DomainGuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
				DomainGuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
				DomainGuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
				int domainGuidNodes = 6;
				int domainGuidNodei = src.Index;
				src.Advance(1 * domainGuidNodes);
				int sidp = src.Dec_ndr_long();
				if (nameBufferp != 0)
				{
					src = src.Deferred;
					int nameBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int nameBufferl = src.Dec_ndr_long();
					int nameBufferi = src.Index;
					src.Advance(2 * nameBufferl);
					if (Name.Buffer == null)
					{
						if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						Name.Buffer = new short[nameBuffers];
					}
					src = src.Derive(nameBufferi);
					for (int i = 0; i < nameBufferl; i++)
					{
						Name.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (dnsDomainBufferp != 0)
				{
					src = src.Deferred;
					int dnsDomainBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int dnsDomainBufferl = src.Dec_ndr_long();
					int dnsDomainBufferi = src.Index;
					src.Advance(2 * dnsDomainBufferl);
					if (DnsDomain.Buffer == null)
					{
						if (dnsDomainBuffers < 0 || dnsDomainBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						DnsDomain.Buffer = new short[dnsDomainBuffers];
					}
					src = src.Derive(dnsDomainBufferi);
					for (int i = 0; i < dnsDomainBufferl; i++)
					{
						DnsDomain.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (dnsForestBufferp != 0)
				{
					src = src.Deferred;
					int dnsForestBuffers = src.Dec_ndr_long();
					src.Dec_ndr_long();
					int dnsForestBufferl = src.Dec_ndr_long();
					int dnsForestBufferi = src.Index;
					src.Advance(2 * dnsForestBufferl);
					if (DnsForest.Buffer == null)
					{
						if (dnsForestBuffers < 0 || dnsForestBuffers > unchecked(0xFFFF))
						{
							throw new NdrException(NdrException.InvalidConformance);
						}
						DnsForest.Buffer = new short[dnsForestBuffers];
					}
					src = src.Derive(dnsForestBufferi);
					for (int i = 0; i < dnsForestBufferl; i++)
					{
						DnsForest.Buffer[i] = (short)src.Dec_ndr_short();
					}
				}
				if (DomainGuid.Node == null)
				{
					if (domainGuidNodes < 0 || domainGuidNodes > unchecked(0xFFFF))
					{
						throw new NdrException(NdrException.InvalidConformance);
					}
					DomainGuid.Node = new byte[domainGuidNodes];
				}
				src = src.Derive(domainGuidNodei);
				for (int i1 = 0; i1 < domainGuidNodes; i1++)
				{
					DomainGuid.Node[i1] = unchecked((byte)src.Dec_ndr_small());
				}
				if (sidp != 0)
				{
					if (Sid == null)
					{
						Sid = new Rpc.SidT();
					}
					src = src.Deferred;
					Sid.Decode(src);
				}
			}
Esempio n. 10
0
		/// <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;
			}
		}
Esempio n. 11
0
		/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
		public override void Decode_out(NdrBuffer src)
		{
			src.Dec_ndr_short();
			src.Dec_ndr_short();
			src.Dec_ndr_long();
			int n = src.Dec_ndr_short();
			src.Advance(n);
			src.Align(4);
			src.Dec_ndr_small();
			src.Align(4);
			Result = src.Dec_ndr_short();
			src.Dec_ndr_short();
			src.Advance(20);
		}