コード例 #1
0
        internal void WriteByteArray(Byte[] b, int len, int offsetBuffer, TdsParserStateObject stateObj)
        {
            int offset = offsetBuffer;

            while (len > 0)
            {
                if ((stateObj._outBytesUsed + len) > stateObj._outBuff.Length)
                {
                    int remainder = stateObj._outBuff.Length - stateObj._outBytesUsed;

                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, remainder);

                    offset += remainder;
                    stateObj._outBytesUsed += remainder;

                    if (stateObj._outBytesUsed == stateObj._outBuff.Length)
                    {
                        stateObj.WritePacket(0);
                    }

                    len -= remainder;
                }
                else
                {
                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, len);

                    stateObj._outBytesUsed += len;

                    break;
                }
            }
        }
コード例 #2
0
        internal void WriteByte(byte b, TdsParserStateObject stateObj)
        {
            if (stateObj._outBytesUsed == stateObj._outBuff.Length)
            {
                stateObj.WritePacket(0);
            }

            stateObj._outBuff[stateObj._outBytesUsed++] = b;
        }
コード例 #3
0
 internal void WriteShort(int v, TdsParserStateObject stateObj)
 {
     if ((stateObj._outBytesUsed + 2) > stateObj._outBuff.Length)
     {
         WriteByte((byte)(v & 0xff), stateObj);
         WriteByte((byte)((v >> 8) & 0xff), stateObj);
     }
     else
     {
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)(v & 0xFF);
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)((v >> 8) & 0xFF);
     }
 }
コード例 #4
0
        internal void WriteString(string s, int length, int offset, TdsParserStateObject stateObj)
        {
            int cBytes = 2 * length;

            if (cBytes < (stateObj._outBuff.Length - stateObj._outBytesUsed))
            {
                CopyStringToBytes(s, offset, stateObj._outBuff, stateObj._outBytesUsed, length);
                stateObj._outBytesUsed += cBytes;
            }
            else
            {
                if (stateObj._bTmp == null || stateObj._bTmp.Length < cBytes)
                {
                    stateObj._bTmp = new byte[cBytes];
                }

                CopyStringToBytes(s, offset, stateObj._bTmp, 0, length);
                WriteByteArray(stateObj._bTmp, cBytes, 0, stateObj);
            }
        }
コード例 #5
0
 private void WriteString(string s, TdsParserStateObject stateObj)
 {
     WriteString(s, s.Length, 0, stateObj);
 }
コード例 #6
0
 internal void WriteInt(int v, TdsParserStateObject stateObj)
 {
     WriteByteArray(BitConverter.GetBytes(v), 4, 0, stateObj);
 }
コード例 #7
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
 private void WriteString(string s, TdsParserStateObject stateObj)
 {
     WriteString(s, s.Length, 0, stateObj);
 }
コード例 #8
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
        internal void WriteString(string s, int length, int offset, TdsParserStateObject stateObj)
        {
            int cBytes = 2 * length;

            if (cBytes < (stateObj._outBuff.Length - stateObj._outBytesUsed))
            {
                CopyStringToBytes(s, offset, stateObj._outBuff, stateObj._outBytesUsed, length);
                stateObj._outBytesUsed += cBytes;
            }
            else
            {
                if (stateObj._bTmp == null || stateObj._bTmp.Length < cBytes)
                {
                    stateObj._bTmp = new byte[cBytes];
                }

                CopyStringToBytes(s, offset, stateObj._bTmp, 0, length);
                WriteByteArray(stateObj._bTmp, cBytes, 0, stateObj);
            }
        }
コード例 #9
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
 internal void WriteInt(int v, TdsParserStateObject stateObj)
 {
     WriteByteArray(BitConverter.GetBytes(v), 4, 0, stateObj);
 }
コード例 #10
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
 internal void WriteShort(int v, TdsParserStateObject stateObj)
 {
     if ((stateObj._outBytesUsed + 2) > stateObj._outBuff.Length)
     {
         WriteByte((byte)(v & 0xff), stateObj);
         WriteByte((byte)((v >> 8) & 0xff), stateObj);
     }
     else
     {
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)(v & 0xFF);
         stateObj._outBuff[stateObj._outBytesUsed++] = (byte)((v >> 8) & 0xFF);
     }
 }
コード例 #11
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
        internal void WriteByteArray(Byte[] b, int len, int offsetBuffer, TdsParserStateObject stateObj)
        {
            int offset = offsetBuffer;

            while (len > 0)
            {
                if ((stateObj._outBytesUsed + len) > stateObj._outBuff.Length)
                {
                    int remainder = stateObj._outBuff.Length - stateObj._outBytesUsed;

                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, remainder);

                    offset += remainder;
                    stateObj._outBytesUsed += remainder;

                    if (stateObj._outBytesUsed == stateObj._outBuff.Length)
                    {
                        stateObj.WritePacket(0);
                    }

                    len -= remainder;
                }
                else
                {
                    Buffer.BlockCopy(b, offset, stateObj._outBuff, stateObj._outBytesUsed, len);

                    stateObj._outBytesUsed += len;

                    break;
                }
            }
        }
コード例 #12
0
ファイル: BadCheckedAdd1.cs プロジェクト: CheneyWu/coreclr
        internal void WriteByte(byte b, TdsParserStateObject stateObj)
        {
            if (stateObj._outBytesUsed == stateObj._outBuff.Length)
            {
                stateObj.WritePacket(0);
            }

            stateObj._outBuff[stateObj._outBytesUsed++] = b;
        }