示例#1
0
        /// <summary>
        /// Encode the instance of current class into bytes.
        /// </summary>
        /// <returns>The encoded bytes.</returns>
        public byte[] ToBytes()
        {
            UpdateInterrelatedFields();

            byte[] header = PacUtility.ObjectToMemory(NativePacType);

            byte[][] bodyReferences = new byte[NativePacType.cBuffers][];

            for (int i = 0; i < NativePacType.cBuffers; i++)
            {
                if (pacInfoBuffers[i] == null)
                {
                    continue;
                }
                bodyReferences[i] = pacInfoBuffers[i].EncodeBuffer();

                int length = bodyReferences[i].Length;
                // double check the totalLength
                // NativePacType.Buffers[index].cbBufferSize has been updated in previous
                // UpdateInterrelatedFields() method, given by each pacInfoBuffer's
                // CalculateSize() method.
                // following evaluation double check whether CalculateSize() method's
                // result conforms to EncodeBuffer() method's result.
                // Note: some kind of pacInfoBuffers return EncodeBuffer().Length as the
                // CalculateSize(), such as NDR encoded structures. But some other
                // pacInfoBuffers can calculate totalLength without encoding the structure.
                AssertBufferSize(NativePacType.Buffers, i, length);
            }

            return(ConcatenateBuffers(header, bodyReferences));
        }
示例#2
0
        /// <summary>
        /// Encode the instance of current class into byte array,
        /// according to TD specification.
        /// </summary>
        /// <returns>The encoded byte array</returns>
        internal override byte[] EncodeBuffer()
        {
            byte[] header = PacUtility.ObjectToMemory(NativeUpnDnsInfo);

            int length = CalculateSize();

            byte[] result = new byte[length];

            // header
            Buffer.BlockCopy(header, 0, result, 0, header.Length);

            // upn content
            Buffer.BlockCopy(Encoding.Unicode.GetBytes(upn), 0, result,
                             NativeUpnDnsInfo.UpnOffset, NativeUpnDnsInfo.UpnLength);
            // dns domain content
            Buffer.BlockCopy(Encoding.Unicode.GetBytes(dnsDomain), 0, result,
                             NativeUpnDnsInfo.DnsDomainNameOffset, NativeUpnDnsInfo.DnsDomainNameLength);

            return(result);
        }
 /// <summary>
 /// Encode the instance of current class into byte array,
 /// according to TD specification.
 /// </summary>
 /// <returns>The encoded byte array</returns>
 internal override byte[] EncodeBuffer()
 {
     return(PacUtility.ObjectToMemory(NativePacSignatureData));
 }
示例#4
0
 /// <summary>
 /// Set _NTLM_SUPPLEMENTAL_CREDENTIAL to Credentials.
 /// Credentials is a pointer, pointing to a byte array.
 /// The byte array is the NDR-encoded _NTLM_SUPPLEMENTAL_CREDENTIAL.
 /// </summary>
 /// <param name="ntlmCredential">the embedded _NTLM_SUPPLEMENTAL_CREDENTIAL instance.</param>
 public void SetNtlmCredential(_NTLM_SUPPLEMENTAL_CREDENTIAL ntlmCredential)
 {
     Credentials    = PacUtility.ObjectToMemory <_NTLM_SUPPLEMENTAL_CREDENTIAL>(ntlmCredential);
     CredentialSize = (uint)Credentials.Length;
 }
 /// <summary>
 /// Encode the instance of current class into byte array,
 /// according to TD specification.
 /// </summary>
 /// <returns>The encoded byte array</returns>
 internal override byte[] EncodeBuffer()
 {
     return(PacUtility.ObjectToMemory(NativePacClientInfo));
 }