private SqlEnvChange[] ProcessEnvChange(int tokenLength, TdsParserStateObject stateObj) { int num4 = 0; int index = 0; SqlEnvChange[] changeArray = new SqlEnvChange[3]; while (tokenLength > num4) { int num3; ushort num5; if (index >= changeArray.Length) { SqlEnvChange[] changeArray2 = new SqlEnvChange[changeArray.Length + 3]; for (int i = 0; i < changeArray.Length; i++) { changeArray2[i] = changeArray[i]; } changeArray = changeArray2; } SqlEnvChange env = new SqlEnvChange { type = stateObj.ReadByte() }; changeArray[index] = env; index++; switch (env.type) { case 1: case 2: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 3: this.ReadTwoStringFields(env, stateObj); if (!(env.newValue == "iso_1")) { break; } this._defaultCodePage = 0x4e4; this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); goto Label_03E0; case 4: { this.ReadTwoStringFields(env, stateObj); int size = int.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); if (this._physicalStateObj.SetPacketSize(size)) { this._physicalStateObj._sniPacket.Dispose(); uint qInfo = (uint) size; SNINativeMethodWrapper.SNISetInfo(this._physicalStateObj.Handle, SNINativeMethodWrapper.QTypes.SNI_QUERY_CONN_BUFSIZE, ref qInfo); this._physicalStateObj._sniPacket = new SNIPacket(this._physicalStateObj.Handle); } goto Label_03E0; } case 5: this.ReadTwoStringFields(env, stateObj); this._defaultLCID = int.Parse(env.newValue, NumberStyles.Integer, CultureInfo.InvariantCulture); goto Label_03E0; case 6: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 7: env.newLength = stateObj.ReadByte(); if (env.newLength == 5) { env.newCollation = this.ProcessCollation(stateObj); this._defaultCollation = env.newCollation; int codePage = this.GetCodePage(env.newCollation, stateObj); if (codePage != this._defaultCodePage) { this._defaultCodePage = codePage; this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); } this._defaultLCID = env.newCollation.LCID; } env.oldLength = stateObj.ReadByte(); if (env.oldLength == 5) { env.oldCollation = this.ProcessCollation(stateObj); } env.length = (3 + env.newLength) + env.oldLength; goto Label_03E0; case 8: case 9: case 10: case 11: case 12: case 0x11: env.newLength = stateObj.ReadByte(); if (env.newLength <= 0) { goto Label_02B0; } env.newLongValue = stateObj.ReadInt64(); goto Label_02B8; case 13: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 15: env.newLength = stateObj.ReadInt32(); env.newBinValue = new byte[env.newLength]; stateObj.ReadByteArray(env.newBinValue, 0, env.newLength); env.oldLength = stateObj.ReadByte(); env.length = 5 + env.newLength; goto Label_03E0; case 0x10: case 0x12: this.ReadTwoBinaryFields(env, stateObj); goto Label_03E0; case 0x13: this.ReadTwoStringFields(env, stateObj); goto Label_03E0; case 20: { env.newLength = stateObj.ReadUInt16(); byte protocol = stateObj.ReadByte(); ushort port = stateObj.ReadUInt16(); ushort length = stateObj.ReadUInt16(); string servername = stateObj.ReadString(length); env.newRoutingInfo = new RoutingInfo(protocol, port, servername); num5 = stateObj.ReadUInt16(); num3 = 0; goto Label_03C9; } default: goto Label_03E0; } string s = env.newValue.Substring(2); this._defaultCodePage = int.Parse(s, NumberStyles.Integer, CultureInfo.InvariantCulture); this._defaultEncoding = Encoding.GetEncoding(this._defaultCodePage); goto Label_03E0; Label_02B0: env.newLongValue = 0L; Label_02B8: env.oldLength = stateObj.ReadByte(); if (env.oldLength > 0) { env.oldLongValue = stateObj.ReadInt64(); } else { env.oldLongValue = 0L; } env.length = (3 + env.newLength) + env.oldLength; goto Label_03E0; Label_03BC: stateObj.ReadByte(); num3++; Label_03C9: if (num3 < num5) { goto Label_03BC; } env.length = (env.newLength + num5) + 5; Label_03E0: num4 += env.length; } return changeArray; }
internal void ReadSqlValueInternal(SqlBuffer value, byte tdsType, int typeId, int length, TdsParserStateObject stateObj) { int num4; switch (tdsType) { case 0x7f: goto Label_011A; case 0xa5: case 0xad: case 0x22: case 0x25: case 0x2d: { byte[] buff = new byte[length]; stateObj.ReadByteArray(buff, 0, length); value.SqlBinary = new SqlBinary(buff, true); return; } case 0x6d: if (length != 4) { goto Label_013B; } goto Label_012D; case 110: if (length == 4) { goto Label_0173; } goto Label_014E; case 0x6f: if (length != 4) { goto Label_01A2; } goto Label_0187; case 0x7a: goto Label_0173; case 0x62: this.ReadSqlVariant(value, length, stateObj); return; case 0x68: case 50: value.Boolean = stateObj.ReadByte() != 0; return; case 0x23: case 0x2e: case 0x2f: case 0x31: case 0x33: case 0x35: case 0x36: case 0x37: case 0x39: return; case 0x24: { byte[] buffer2 = new byte[length]; stateObj.ReadByteArray(buffer2, 0, length); value.SqlGuid = new SqlGuid(buffer2, true); return; } case 0x26: if (length == 1) { break; } if (length == 2) { goto Label_00FE; } if (length != 4) { goto Label_011A; } goto Label_010C; case 0x30: break; case 0x34: goto Label_00FE; case 0x38: goto Label_010C; case 0x3a: goto Label_0187; case 0x3b: goto Label_012D; case 60: goto Label_014E; case 0x3d: goto Label_01A2; case 0x3e: goto Label_013B; default: return; } value.Byte = stateObj.ReadByte(); return; Label_00FE: value.Int16 = stateObj.ReadInt16(); return; Label_010C: value.Int32 = stateObj.ReadInt32(); return; Label_011A: value.Int64 = stateObj.ReadInt64(); return; Label_012D: value.Single = stateObj.ReadSingle(); return; Label_013B: value.Double = stateObj.ReadDouble(); return; Label_014E: num4 = stateObj.ReadInt32(); uint num3 = stateObj.ReadUInt32(); long num2 = (num4 << 0x20) + num3; value.SetToMoney(num2); return; Label_0173: value.SetToMoney((long) stateObj.ReadInt32()); return; Label_0187: value.SetToDateTime(stateObj.ReadUInt16(), stateObj.ReadUInt16() * SqlDateTime.SQLTicksPerMinute); return; Label_01A2: value.SetToDateTime(stateObj.ReadInt32(), (int) stateObj.ReadUInt32()); }
private void ProcessDone(SqlCommand cmd, SqlDataReader reader, ref RunBehavior run, TdsParserStateObject stateObj) { int num2; ushort status = stateObj.ReadUInt16(); ushort curCmd = stateObj.ReadUInt16(); if (this._isYukon) { num2 = (int) stateObj.ReadInt64(); } else { num2 = stateObj.ReadInt32(); if (((this._state == TdsParserState.OpenNotLoggedIn) && (stateObj._inBytesRead > stateObj._inBytesUsed)) && (stateObj.PeekByte() == 0)) { num2 = stateObj.ReadInt32(); } } if (0x20 == (status & 0x20)) { stateObj._attentionReceived = true; } if ((cmd != null) && (0x10 == (status & 0x10))) { if (curCmd != 0xc1) { cmd.InternalRecordsAffected = num2; } if (stateObj._receivedColMetaData || (curCmd != 0xc1)) { cmd.OnStatementCompleted(num2); } } stateObj._receivedColMetaData = false; if (((2 == (2 & status)) && (this._errors == null)) && (!stateObj._errorTokenReceived && (RunBehavior.Clean != (RunBehavior.Clean & run)))) { this.Errors.Add(new SqlError(0, 0, 11, this._server, SQLMessage.SevereError(), "", 0)); if ((reader != null) && !reader.IsInitialized) { run = RunBehavior.UntilDone; } } if ((0x100 == (0x100 & status)) && (RunBehavior.Clean != (RunBehavior.Clean & run))) { this.Errors.Add(new SqlError(0, 0, 20, this._server, SQLMessage.SevereError(), "", 0)); if ((reader != null) && !reader.IsInitialized) { run = RunBehavior.UntilDone; } } this.ProcessSqlStatistics(curCmd, status, num2); if (1 != (status & 1)) { stateObj._errorTokenReceived = false; if (stateObj._inBytesUsed >= stateObj._inBytesRead) { stateObj._pendingData = false; } } if (!stateObj._pendingData && stateObj._hasOpenResult) { stateObj.DecrementOpenResultCount(); } }