1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// 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
{
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"
};
internal static string GetResultMessage(int result)
{
return result < 4 ? ResultMessage[result] : "0x" + Hexdump.ToHexString(result, 4
);
}
public override DcerpcException GetResult()
{
if (Result != 0)
{
return new DcerpcException(GetResultMessage(Result));
}
return null;
}
internal DcerpcBinding Binding;
internal int MaxXmit;
internal int MaxRecv;
public DcerpcBind()
{
}
internal DcerpcBind(DcerpcBinding binding, DcerpcHandle handle)
{
this.Binding = binding;
MaxXmit = handle.MaxXmit;
MaxRecv = handle.MaxRecv;
Ptype = 11;
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
}
public override int GetOpnum()
{
return 0;
}
/// <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);
DcerpcConstants.DcerpcUuidSyntaxNdr.Encode(dst);
dst.Enc_ndr_long(2);
}
/// <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);
}
}
}
|