2017-04-02 00:36:06 +00:00
|
|
|
// This code is derived from jcifs smb client library <jcifs at samba dot org>
|
|
|
|
// Ported by J. Arturo <webmaster at komodosoft dot net>
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
using SharpCifs.Dcerpc.Ndr;
|
|
|
|
using SharpCifs.Util;
|
|
|
|
|
|
|
|
namespace SharpCifs.Dcerpc
|
|
|
|
{
|
2017-06-21 06:46:57 +00:00
|
|
|
public class DcerpcBind : DcerpcMessage
|
|
|
|
{
|
|
|
|
internal static readonly string[] ResultMessage =
|
|
|
|
{
|
|
|
|
"0",
|
|
|
|
"DCERPC_BIND_ERR_ABSTRACT_SYNTAX_NOT_SUPPORTED",
|
|
|
|
"DCERPC_BIND_ERR_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED",
|
|
|
|
"DCERPC_BIND_ERR_LOCAL_LIMIT_EXCEEDED"
|
|
|
|
};
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
internal static string GetResultMessage(int result)
|
|
|
|
{
|
|
|
|
return result < 4 ? ResultMessage[result] : "0x" + Hexdump.ToHexString(result, 4);
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
public override DcerpcException GetResult()
|
|
|
|
{
|
|
|
|
if (Result != 0)
|
|
|
|
{
|
|
|
|
return new DcerpcException(GetResultMessage(Result));
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
internal DcerpcBinding Binding;
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
internal int MaxXmit;
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
internal int MaxRecv;
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
public DcerpcBind()
|
|
|
|
{
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
internal DcerpcBind(DcerpcBinding binding, DcerpcHandle handle)
|
|
|
|
{
|
|
|
|
this.Binding = binding;
|
|
|
|
MaxXmit = handle.MaxXmit;
|
|
|
|
MaxRecv = handle.MaxRecv;
|
|
|
|
Ptype = 11;
|
2017-04-02 00:36:06 +00:00
|
|
|
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
2017-06-21 06:46:57 +00:00
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
public override int GetOpnum()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
/// <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);
|
2017-04-02 00:36:06 +00:00
|
|
|
DcerpcConstants.DcerpcUuidSyntaxNdr.Encode(dst);
|
2017-06-21 06:46:57 +00:00
|
|
|
dst.Enc_ndr_long(2);
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
|
2017-06-21 06:46:57 +00:00
|
|
|
/// <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);
|
|
|
|
}
|
|
|
|
}
|
2017-04-02 00:36:06 +00:00
|
|
|
}
|