mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-04 13:22:52 +01:00
update sharpcifs
This commit is contained in:
@@ -19,87 +19,84 @@ 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"
|
||||
};
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
public override DcerpcException GetResult()
|
||||
{
|
||||
if (Result != 0)
|
||||
{
|
||||
return new DcerpcException(GetResultMessage(Result));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal DcerpcBinding Binding;
|
||||
internal DcerpcBinding Binding;
|
||||
|
||||
internal int MaxXmit;
|
||||
internal int MaxXmit;
|
||||
|
||||
internal int MaxRecv;
|
||||
internal int MaxRecv;
|
||||
|
||||
public DcerpcBind()
|
||||
{
|
||||
}
|
||||
public DcerpcBind()
|
||||
{
|
||||
}
|
||||
|
||||
internal DcerpcBind(DcerpcBinding binding, DcerpcHandle handle)
|
||||
{
|
||||
this.Binding = binding;
|
||||
MaxXmit = handle.MaxXmit;
|
||||
MaxRecv = handle.MaxRecv;
|
||||
Ptype = 11;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
/// <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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,105 +20,103 @@ using SharpCifs.Util.Sharpen;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public class DcerpcBinding
|
||||
{
|
||||
private static Hashtable _interfaces;
|
||||
public class DcerpcBinding
|
||||
{
|
||||
private static Hashtable _interfaces;
|
||||
|
||||
static DcerpcBinding()
|
||||
{
|
||||
_interfaces = new Hashtable();
|
||||
_interfaces.Put("srvsvc", Srvsvc.GetSyntax());
|
||||
_interfaces.Put("lsarpc", Lsarpc.GetSyntax());
|
||||
_interfaces.Put("samr", Samr.GetSyntax());
|
||||
_interfaces.Put("netdfs", Netdfs.GetSyntax());
|
||||
}
|
||||
static DcerpcBinding()
|
||||
{
|
||||
_interfaces = new Hashtable();
|
||||
_interfaces.Put("srvsvc", Srvsvc.GetSyntax());
|
||||
_interfaces.Put("lsarpc", Lsarpc.GetSyntax());
|
||||
_interfaces.Put("samr", Samr.GetSyntax());
|
||||
_interfaces.Put("netdfs", Netdfs.GetSyntax());
|
||||
}
|
||||
|
||||
public static void AddInterface(string name, string syntax)
|
||||
{
|
||||
_interfaces.Put(name, syntax);
|
||||
}
|
||||
public static void AddInterface(string name, string syntax)
|
||||
{
|
||||
_interfaces.Put(name, syntax);
|
||||
}
|
||||
|
||||
internal string Proto;
|
||||
internal string Proto;
|
||||
|
||||
internal string Server;
|
||||
internal string Server;
|
||||
|
||||
internal string Endpoint;
|
||||
internal string Endpoint;
|
||||
|
||||
internal Hashtable Options;
|
||||
internal Hashtable Options;
|
||||
|
||||
internal Uuid Uuid;
|
||||
internal Uuid Uuid;
|
||||
|
||||
internal int Major;
|
||||
internal int Major;
|
||||
|
||||
internal int Minor;
|
||||
internal int Minor;
|
||||
|
||||
internal DcerpcBinding(string proto, string server)
|
||||
{
|
||||
this.Proto = proto;
|
||||
this.Server = server;
|
||||
}
|
||||
internal DcerpcBinding(string proto, string server)
|
||||
{
|
||||
this.Proto = proto;
|
||||
this.Server = server;
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
internal virtual void SetOption(string key, object val)
|
||||
{
|
||||
if (key.Equals("endpoint"))
|
||||
{
|
||||
Endpoint = val.ToString().ToLower();
|
||||
if (Endpoint.StartsWith("\\pipe\\"))
|
||||
{
|
||||
string iface = (string)_interfaces.Get(Runtime.Substring(Endpoint, 6));
|
||||
if (iface != null)
|
||||
{
|
||||
int c;
|
||||
int p;
|
||||
c = iface.IndexOf(':');
|
||||
p = iface.IndexOf('.', c + 1);
|
||||
Uuid = new Uuid(Runtime.Substring(iface, 0, c));
|
||||
Major = Convert.ToInt32(Runtime.Substring(iface, c + 1, p));
|
||||
Minor = Convert.ToInt32(Runtime.Substring(iface, p + 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new DcerpcException("Bad endpoint: " + Endpoint);
|
||||
}
|
||||
if (Options == null)
|
||||
{
|
||||
Options = new Hashtable();
|
||||
}
|
||||
Options.Put(key, val);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
internal virtual void SetOption(string key, object val)
|
||||
{
|
||||
if (key.Equals("endpoint"))
|
||||
{
|
||||
Endpoint = val.ToString().ToLower();
|
||||
if (Endpoint.StartsWith("\\pipe\\"))
|
||||
{
|
||||
string iface = (string)_interfaces.Get(Runtime.Substring(Endpoint, 6));
|
||||
if (iface != null)
|
||||
{
|
||||
int c;
|
||||
int p;
|
||||
c = iface.IndexOf(':');
|
||||
p = iface.IndexOf('.', c + 1);
|
||||
Uuid = new Uuid(Runtime.Substring(iface, 0, c));
|
||||
Major = Convert.ToInt32(Runtime.Substring(iface, c + 1, p));
|
||||
Minor = Convert.ToInt32(Runtime.Substring(iface, p + 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new DcerpcException("Bad endpoint: " + Endpoint);
|
||||
}
|
||||
if (Options == null)
|
||||
{
|
||||
Options = new Hashtable();
|
||||
}
|
||||
Options.Put(key, val);
|
||||
}
|
||||
|
||||
internal virtual object GetOption(string key)
|
||||
{
|
||||
if (key.Equals("endpoint"))
|
||||
{
|
||||
return Endpoint;
|
||||
}
|
||||
if (Options != null)
|
||||
{
|
||||
return Options.Get(key);
|
||||
}
|
||||
internal virtual object GetOption(string key)
|
||||
{
|
||||
if (key.Equals("endpoint"))
|
||||
{
|
||||
return Endpoint;
|
||||
}
|
||||
if (Options != null)
|
||||
{
|
||||
return Options.Get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
/* string ret = proto + ":" + server + "[" + endpoint;
|
||||
if (options != null)
|
||||
{
|
||||
Iterator iter = (Iterator) options.Keys.GetEnumerator();
|
||||
while (iter.HasNext())
|
||||
{
|
||||
object key = iter.Next();
|
||||
object val = options.Get(key);
|
||||
ret += "," + key + "=" + val;
|
||||
}
|
||||
}
|
||||
ret += "]";
|
||||
return ret; */
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
/*
|
||||
string ret = proto + ":" + server + "[" + endpoint;
|
||||
if (options != null)
|
||||
{
|
||||
Iterator iter = (Iterator) options.Keys.GetEnumerator();
|
||||
while (iter.HasNext())
|
||||
{
|
||||
object key = iter.Next();
|
||||
object val = options.Get(key);
|
||||
ret += "," + key + "=" + val;
|
||||
}
|
||||
}
|
||||
ret += "]";
|
||||
return ret;
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,24 +16,25 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public static class DcerpcConstants
|
||||
{
|
||||
public static Uuid DcerpcUuidSyntaxNdr = new Uuid("8a885d04-1ceb-11c9-9fe8-08002b104860");
|
||||
public static class DcerpcConstants
|
||||
{
|
||||
public static Uuid DcerpcUuidSyntaxNdr = new Uuid("8a885d04-1ceb-11c9-9fe8-08002b104860"
|
||||
);
|
||||
|
||||
public static int DcerpcFirstFrag = unchecked(0x01);
|
||||
public static int DcerpcFirstFrag = unchecked(0x01);
|
||||
|
||||
public static int DcerpcLastFrag = unchecked(0x02);
|
||||
public static int DcerpcLastFrag = unchecked(0x02);
|
||||
|
||||
public static int DcerpcPendingCancel = unchecked(0x04);
|
||||
public static int DcerpcPendingCancel = unchecked(0x04);
|
||||
|
||||
public static int DcerpcReserved1 = unchecked(0x08);
|
||||
public static int DcerpcReserved1 = unchecked(0x08);
|
||||
|
||||
public static int DcerpcConcMpx = unchecked(0x10);
|
||||
public static int DcerpcConcMpx = unchecked(0x10);
|
||||
|
||||
public static int DcerpcDidNotExecute = unchecked(0x20);
|
||||
public static int DcerpcDidNotExecute = unchecked(0x20);
|
||||
|
||||
public static int DcerpcMaybe = unchecked(0x40);
|
||||
public static int DcerpcMaybe = unchecked(0x40);
|
||||
|
||||
public static int DcerpcObjectUuid = unchecked(0x80);
|
||||
}
|
||||
public static int DcerpcObjectUuid = unchecked(0x80);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,49 +16,33 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public static class DcerpcError
|
||||
{
|
||||
public static int DcerpcFaultOther = unchecked(0x00000001);
|
||||
public static class DcerpcError
|
||||
{
|
||||
public static int DcerpcFaultOther = unchecked(0x00000001);
|
||||
|
||||
public static int DcerpcFaultAccessDenied = unchecked(0x00000005);
|
||||
public static int DcerpcFaultAccessDenied = unchecked(0x00000005);
|
||||
|
||||
public static int DcerpcFaultCantPerform = unchecked(0x000006D8);
|
||||
public static int DcerpcFaultCantPerform = unchecked(0x000006D8);
|
||||
|
||||
public static int DcerpcFaultNdr = unchecked(0x000006F7);
|
||||
public static int DcerpcFaultNdr = unchecked(0x000006F7);
|
||||
|
||||
public static int DcerpcFaultInvalidTag = unchecked(0x1C000006);
|
||||
public static int DcerpcFaultInvalidTag = unchecked(0x1C000006);
|
||||
|
||||
public static int DcerpcFaultContextMismatch = unchecked(0x1C00001A);
|
||||
public static int DcerpcFaultContextMismatch = unchecked(0x1C00001A);
|
||||
|
||||
public static int DcerpcFaultOpRngError = unchecked(0x1C010002);
|
||||
public static int DcerpcFaultOpRngError = unchecked(0x1C010002);
|
||||
|
||||
public static int DcerpcFaultUnkIf = unchecked(0x1C010003);
|
||||
public static int DcerpcFaultUnkIf = unchecked(0x1C010003);
|
||||
|
||||
public static int DcerpcFaultProtoError = unchecked(0x1c01000b);
|
||||
public static int DcerpcFaultProtoError = unchecked(0x1c01000b);
|
||||
|
||||
public static int[] DcerpcFaultCodes = {
|
||||
DcerpcFaultOther,
|
||||
DcerpcFaultAccessDenied,
|
||||
DcerpcFaultCantPerform,
|
||||
DcerpcFaultNdr,
|
||||
DcerpcFaultInvalidTag,
|
||||
DcerpcFaultContextMismatch,
|
||||
DcerpcFaultOpRngError,
|
||||
DcerpcFaultUnkIf,
|
||||
DcerpcFaultProtoError
|
||||
};
|
||||
public static int[] DcerpcFaultCodes = { DcerpcFaultOther, DcerpcFaultAccessDenied
|
||||
, DcerpcFaultCantPerform, DcerpcFaultNdr, DcerpcFaultInvalidTag, DcerpcFaultContextMismatch
|
||||
, DcerpcFaultOpRngError, DcerpcFaultUnkIf, DcerpcFaultProtoError };
|
||||
|
||||
public static string[] DcerpcFaultMessages =
|
||||
{
|
||||
"DCERPC_FAULT_OTHER",
|
||||
"DCERPC_FAULT_ACCESS_DENIED",
|
||||
"DCERPC_FAULT_CANT_PERFORM",
|
||||
"DCERPC_FAULT_NDR",
|
||||
"DCERPC_FAULT_INVALID_TAG",
|
||||
"DCERPC_FAULT_CONTEXT_MISMATCH",
|
||||
"DCERPC_FAULT_OP_RNG_ERROR",
|
||||
"DCERPC_FAULT_UNK_IF",
|
||||
"DCERPC_FAULT_PROTO_ERROR"
|
||||
};
|
||||
}
|
||||
public static string[] DcerpcFaultMessages = { "DCERPC_FAULT_OTHER"
|
||||
, "DCERPC_FAULT_ACCESS_DENIED", "DCERPC_FAULT_CANT_PERFORM", "DCERPC_FAULT_NDR",
|
||||
"DCERPC_FAULT_INVALID_TAG", "DCERPC_FAULT_CONTEXT_MISMATCH", "DCERPC_FAULT_OP_RNG_ERROR"
|
||||
, "DCERPC_FAULT_UNK_IF", "DCERPC_FAULT_PROTO_ERROR" };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,73 +21,73 @@ using SharpCifs.Util.Sharpen;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
|
||||
public class DcerpcException : IOException
|
||||
{
|
||||
internal static string GetMessageByDcerpcError(int errcode)
|
||||
{
|
||||
int min = 0;
|
||||
|
||||
public class DcerpcException : IOException
|
||||
{
|
||||
internal static string GetMessageByDcerpcError(int errcode)
|
||||
{
|
||||
int min = 0;
|
||||
int max = DcerpcError.DcerpcFaultCodes.Length;
|
||||
while (max >= min)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
while (max >= min)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
if (errcode > DcerpcError.DcerpcFaultCodes[mid])
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (errcode < DcerpcError.DcerpcFaultCodes[mid])
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DcerpcError.DcerpcFaultMessages[mid];
|
||||
}
|
||||
}
|
||||
}
|
||||
return "0x" + Hexdump.ToHexString(errcode, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "0x" + Hexdump.ToHexString(errcode, 8);
|
||||
}
|
||||
|
||||
private int _error;
|
||||
private int _error;
|
||||
|
||||
private Exception _rootCause;
|
||||
private Exception _rootCause;
|
||||
|
||||
internal DcerpcException(int error) : base(GetMessageByDcerpcError(error))
|
||||
{
|
||||
this._error = error;
|
||||
}
|
||||
internal DcerpcException(int error) : base(GetMessageByDcerpcError(error))
|
||||
{
|
||||
this._error = error;
|
||||
}
|
||||
|
||||
public DcerpcException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
public DcerpcException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
|
||||
public DcerpcException(string msg, Exception rootCause) : base(msg)
|
||||
{
|
||||
this._rootCause = rootCause;
|
||||
}
|
||||
public DcerpcException(string msg, Exception rootCause) : base(msg)
|
||||
{
|
||||
this._rootCause = rootCause;
|
||||
}
|
||||
|
||||
public virtual int GetErrorCode()
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
public virtual int GetErrorCode()
|
||||
{
|
||||
return _error;
|
||||
}
|
||||
|
||||
public virtual Exception GetRootCause()
|
||||
{
|
||||
return _rootCause;
|
||||
}
|
||||
public virtual Exception GetRootCause()
|
||||
{
|
||||
return _rootCause;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (_rootCause != null)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
Runtime.PrintStackTrace(_rootCause, pw);
|
||||
return base.ToString() + "\n" + sw;
|
||||
}
|
||||
return base.ToString();
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (_rootCause != null)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
Runtime.PrintStackTrace(_rootCause, pw);
|
||||
return base.ToString() + "\n" + sw;
|
||||
}
|
||||
return base.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,312 +22,311 @@ using SharpCifs.Util.Sharpen;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public abstract class DcerpcHandle
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
protected internal static DcerpcBinding ParseBinding(string str)
|
||||
{
|
||||
int state;
|
||||
int mark;
|
||||
int si;
|
||||
char[] arr = str.ToCharArray();
|
||||
string proto = null;
|
||||
string key = null;
|
||||
DcerpcBinding binding = null;
|
||||
state = mark = si = 0;
|
||||
do
|
||||
{
|
||||
char ch = arr[si];
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (ch == ':')
|
||||
{
|
||||
proto = Runtime.Substring(str, mark, si);
|
||||
mark = si + 1;
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
public abstract class DcerpcHandle
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
protected internal static DcerpcBinding ParseBinding(string str)
|
||||
{
|
||||
int state;
|
||||
int mark;
|
||||
int si;
|
||||
char[] arr = str.ToCharArray();
|
||||
string proto = null;
|
||||
string key = null;
|
||||
DcerpcBinding binding = null;
|
||||
state = mark = si = 0;
|
||||
do
|
||||
{
|
||||
char ch = arr[si];
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (ch == ':')
|
||||
{
|
||||
proto = Runtime.Substring(str, mark, si);
|
||||
mark = si + 1;
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
if (ch == '\\')
|
||||
{
|
||||
mark = si + 1;
|
||||
break;
|
||||
}
|
||||
state = 2;
|
||||
goto case 2;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (ch == '\\')
|
||||
{
|
||||
mark = si + 1;
|
||||
break;
|
||||
}
|
||||
state = 2;
|
||||
goto case 2;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
if (ch == '[')
|
||||
{
|
||||
string server = Runtime.Substring(str, mark, si).Trim();
|
||||
if (server.Length == 0)
|
||||
{
|
||||
server = "127.0.0.1";
|
||||
}
|
||||
binding = new DcerpcBinding(proto, Runtime.Substring(str, mark, si));
|
||||
mark = si + 1;
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (ch == '[')
|
||||
{
|
||||
string server = Runtime.Substring(str, mark, si).Trim();
|
||||
if (server.Length == 0)
|
||||
{
|
||||
server = "127.0.0.1";
|
||||
}
|
||||
binding = new DcerpcBinding(proto, Runtime.Substring(str, mark, si));
|
||||
mark = si + 1;
|
||||
state = 5;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 5:
|
||||
{
|
||||
if (ch == '=')
|
||||
{
|
||||
key = Runtime.Substring(str, mark, si).Trim();
|
||||
mark = si + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ch == ',' || ch == ']')
|
||||
{
|
||||
string val = Runtime.Substring(str, mark, si).Trim();
|
||||
if (key == null)
|
||||
{
|
||||
key = "endpoint";
|
||||
}
|
||||
binding.SetOption(key, val);
|
||||
key = null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
if (ch == '=')
|
||||
{
|
||||
key = Runtime.Substring(str, mark, si).Trim();
|
||||
mark = si + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ch == ',' || ch == ']')
|
||||
{
|
||||
string val = Runtime.Substring(str, mark, si).Trim();
|
||||
if (key == null)
|
||||
{
|
||||
key = "endpoint";
|
||||
}
|
||||
binding.SetOption(key, val);
|
||||
key = null;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
si = arr.Length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
si++;
|
||||
}
|
||||
while (si < arr.Length);
|
||||
if (binding == null || binding.Endpoint == null)
|
||||
{
|
||||
throw new DcerpcException("Invalid binding URL: " + str);
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
default:
|
||||
{
|
||||
si = arr.Length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
si++;
|
||||
}
|
||||
while (si < arr.Length);
|
||||
if (binding == null || binding.Endpoint == null)
|
||||
{
|
||||
throw new DcerpcException("Invalid binding URL: " + str);
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
protected internal DcerpcBinding Binding;
|
||||
protected internal DcerpcBinding Binding;
|
||||
|
||||
protected internal int MaxXmit = 4280;
|
||||
protected internal int MaxXmit = 4280;
|
||||
|
||||
protected internal int MaxRecv;
|
||||
protected internal int MaxRecv;
|
||||
|
||||
protected internal int State;
|
||||
protected internal int State;
|
||||
|
||||
protected internal IDcerpcSecurityProvider SecurityProvider;
|
||||
protected internal IDcerpcSecurityProvider SecurityProvider;
|
||||
|
||||
private static int _callId = 1;
|
||||
private static int _callId = 1;
|
||||
|
||||
/// <exception cref="UnknownHostException"></exception>
|
||||
/// <exception cref="System.UriFormatException"></exception>
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
public static DcerpcHandle GetHandle(string url, NtlmPasswordAuthentication auth)
|
||||
{
|
||||
if (url.StartsWith("ncacn_np:"))
|
||||
{
|
||||
return new DcerpcPipeHandle(url, auth);
|
||||
}
|
||||
throw new DcerpcException("DCERPC transport not supported: " + url);
|
||||
}
|
||||
/// <exception cref="UnknownHostException"></exception>
|
||||
/// <exception cref="System.UriFormatException"></exception>
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
public static DcerpcHandle GetHandle(string url, NtlmPasswordAuthentication auth)
|
||||
{
|
||||
if (url.StartsWith("ncacn_np:"))
|
||||
{
|
||||
return new DcerpcPipeHandle(url, auth);
|
||||
}
|
||||
throw new DcerpcException("DCERPC transport not supported: " + url);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Bind()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
try
|
||||
{
|
||||
State = 1;
|
||||
DcerpcMessage bind = new DcerpcBind(Binding, this);
|
||||
Sendrecv(bind);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
State = 0;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Bind()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
try
|
||||
{
|
||||
State = 1;
|
||||
DcerpcMessage bind = new DcerpcBind(Binding, this);
|
||||
Sendrecv(bind);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
State = 0;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Sendrecv(DcerpcMessage msg)
|
||||
{
|
||||
byte[] stub;
|
||||
byte[] frag;
|
||||
NdrBuffer buf;
|
||||
NdrBuffer fbuf;
|
||||
bool isLast;
|
||||
bool isDirect;
|
||||
DcerpcException de;
|
||||
if (State == 0)
|
||||
{
|
||||
Bind();
|
||||
}
|
||||
isDirect = true;
|
||||
stub = BufferCache.GetBuffer();
|
||||
try
|
||||
{
|
||||
int off;
|
||||
int tot;
|
||||
int n;
|
||||
buf = new NdrBuffer(stub, 0);
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Sendrecv(DcerpcMessage msg)
|
||||
{
|
||||
byte[] stub;
|
||||
byte[] frag;
|
||||
NdrBuffer buf;
|
||||
NdrBuffer fbuf;
|
||||
bool isLast;
|
||||
bool isDirect;
|
||||
DcerpcException de;
|
||||
if (State == 0)
|
||||
{
|
||||
Bind();
|
||||
}
|
||||
isDirect = true;
|
||||
stub = BufferCache.GetBuffer();
|
||||
try
|
||||
{
|
||||
int off;
|
||||
int tot;
|
||||
int n;
|
||||
buf = new NdrBuffer(stub, 0);
|
||||
msg.Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
msg.CallId = _callId++;
|
||||
msg.Encode(buf);
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
buf.SetIndex(0);
|
||||
SecurityProvider.Wrap(buf);
|
||||
}
|
||||
tot = buf.GetLength() - 24;
|
||||
off = 0;
|
||||
while (off < tot)
|
||||
{
|
||||
n = tot - off;
|
||||
if ((24 + n) > MaxXmit)
|
||||
{
|
||||
msg.CallId = _callId++;
|
||||
msg.Encode(buf);
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
buf.SetIndex(0);
|
||||
SecurityProvider.Wrap(buf);
|
||||
}
|
||||
tot = buf.GetLength() - 24;
|
||||
off = 0;
|
||||
while (off < tot)
|
||||
{
|
||||
n = tot - off;
|
||||
if ((24 + n) > MaxXmit)
|
||||
{
|
||||
msg.Flags &= ~DcerpcConstants.DcerpcLastFrag;
|
||||
n = MaxXmit - 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = MaxXmit - 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Flags |= DcerpcConstants.DcerpcLastFrag;
|
||||
isDirect = false;
|
||||
msg.AllocHint = n;
|
||||
}
|
||||
msg.Length = 24 + n;
|
||||
if (off > 0)
|
||||
{
|
||||
isDirect = false;
|
||||
msg.AllocHint = n;
|
||||
}
|
||||
msg.Length = 24 + n;
|
||||
if (off > 0)
|
||||
{
|
||||
msg.Flags &= ~DcerpcConstants.DcerpcFirstFrag;
|
||||
}
|
||||
if (
|
||||
(msg.Flags & (DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag))
|
||||
!= (DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag)
|
||||
)
|
||||
{
|
||||
buf.Start = off;
|
||||
buf.Reset();
|
||||
msg.Encode_header(buf);
|
||||
buf.Enc_ndr_long(msg.AllocHint);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_short(msg.GetOpnum());
|
||||
}
|
||||
DoSendFragment(stub, off, msg.Length, isDirect);
|
||||
off += n;
|
||||
}
|
||||
DoReceiveFragment(stub, isDirect);
|
||||
buf.Reset();
|
||||
buf.SetIndex(8);
|
||||
buf.SetLength(buf.Dec_ndr_short());
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
SecurityProvider.Unwrap(buf);
|
||||
}
|
||||
buf.SetIndex(0);
|
||||
msg.Decode_header(buf);
|
||||
off = 24;
|
||||
}
|
||||
if ((msg.Flags & (DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag)) != (DcerpcConstants.DcerpcFirstFrag |
|
||||
DcerpcConstants.DcerpcLastFrag))
|
||||
{
|
||||
buf.Start = off;
|
||||
buf.Reset();
|
||||
msg.Encode_header(buf);
|
||||
buf.Enc_ndr_long(msg.AllocHint);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_short(msg.GetOpnum());
|
||||
}
|
||||
DoSendFragment(stub, off, msg.Length, isDirect);
|
||||
off += n;
|
||||
}
|
||||
DoReceiveFragment(stub, isDirect);
|
||||
buf.Reset();
|
||||
buf.SetIndex(8);
|
||||
buf.SetLength(buf.Dec_ndr_short());
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
SecurityProvider.Unwrap(buf);
|
||||
}
|
||||
buf.SetIndex(0);
|
||||
msg.Decode_header(buf);
|
||||
off = 24;
|
||||
if (msg.Ptype == 2 && msg.IsFlagSet(DcerpcConstants.DcerpcLastFrag) == false)
|
||||
{
|
||||
off = msg.Length;
|
||||
}
|
||||
frag = null;
|
||||
fbuf = null;
|
||||
{
|
||||
off = msg.Length;
|
||||
}
|
||||
frag = null;
|
||||
fbuf = null;
|
||||
while (msg.IsFlagSet(DcerpcConstants.DcerpcLastFrag) == false)
|
||||
{
|
||||
int stubFragLen;
|
||||
if (frag == null)
|
||||
{
|
||||
frag = new byte[MaxRecv];
|
||||
fbuf = new NdrBuffer(frag, 0);
|
||||
}
|
||||
DoReceiveFragment(frag, isDirect);
|
||||
fbuf.Reset();
|
||||
fbuf.SetIndex(8);
|
||||
fbuf.SetLength(fbuf.Dec_ndr_short());
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
SecurityProvider.Unwrap(fbuf);
|
||||
}
|
||||
fbuf.Reset();
|
||||
msg.Decode_header(fbuf);
|
||||
stubFragLen = msg.Length - 24;
|
||||
if ((off + stubFragLen) > stub.Length)
|
||||
{
|
||||
// shouldn't happen if alloc_hint is correct or greater
|
||||
byte[] tmp = new byte[off + stubFragLen];
|
||||
Array.Copy(stub, 0, tmp, 0, off);
|
||||
stub = tmp;
|
||||
}
|
||||
Array.Copy(frag, 24, stub, off, stubFragLen);
|
||||
off += stubFragLen;
|
||||
}
|
||||
buf = new NdrBuffer(stub, 0);
|
||||
msg.Decode(buf);
|
||||
}
|
||||
finally
|
||||
{
|
||||
BufferCache.ReleaseBuffer(stub);
|
||||
}
|
||||
if ((de = msg.GetResult()) != null)
|
||||
{
|
||||
throw de;
|
||||
}
|
||||
}
|
||||
{
|
||||
int stubFragLen;
|
||||
if (frag == null)
|
||||
{
|
||||
frag = new byte[MaxRecv];
|
||||
fbuf = new NdrBuffer(frag, 0);
|
||||
}
|
||||
DoReceiveFragment(frag, isDirect);
|
||||
fbuf.Reset();
|
||||
fbuf.SetIndex(8);
|
||||
fbuf.SetLength(fbuf.Dec_ndr_short());
|
||||
if (SecurityProvider != null)
|
||||
{
|
||||
SecurityProvider.Unwrap(fbuf);
|
||||
}
|
||||
fbuf.Reset();
|
||||
msg.Decode_header(fbuf);
|
||||
stubFragLen = msg.Length - 24;
|
||||
if ((off + stubFragLen) > stub.Length)
|
||||
{
|
||||
// shouldn't happen if alloc_hint is correct or greater
|
||||
byte[] tmp = new byte[off + stubFragLen];
|
||||
Array.Copy(stub, 0, tmp, 0, off);
|
||||
stub = tmp;
|
||||
}
|
||||
Array.Copy(frag, 24, stub, off, stubFragLen);
|
||||
off += stubFragLen;
|
||||
}
|
||||
buf = new NdrBuffer(stub, 0);
|
||||
msg.Decode(buf);
|
||||
}
|
||||
finally
|
||||
{
|
||||
BufferCache.ReleaseBuffer(stub);
|
||||
}
|
||||
if ((de = msg.GetResult()) != null)
|
||||
{
|
||||
throw de;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetDcerpcSecurityProvider(IDcerpcSecurityProvider securityProvider
|
||||
)
|
||||
{
|
||||
this.SecurityProvider = securityProvider;
|
||||
}
|
||||
public virtual void SetDcerpcSecurityProvider(IDcerpcSecurityProvider securityProvider
|
||||
)
|
||||
{
|
||||
this.SecurityProvider = securityProvider;
|
||||
}
|
||||
|
||||
public virtual string GetServer()
|
||||
{
|
||||
if (this is DcerpcPipeHandle)
|
||||
{
|
||||
return ((DcerpcPipeHandle)this).Pipe.GetServer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public virtual string GetServer()
|
||||
{
|
||||
if (this is DcerpcPipeHandle)
|
||||
{
|
||||
return ((DcerpcPipeHandle)this).Pipe.GetServer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual Principal GetPrincipal()
|
||||
{
|
||||
if (this is DcerpcPipeHandle)
|
||||
{
|
||||
return ((DcerpcPipeHandle)this).Pipe.GetPrincipal();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public virtual Principal GetPrincipal()
|
||||
{
|
||||
if (this is DcerpcPipeHandle)
|
||||
{
|
||||
return ((DcerpcPipeHandle)this).Pipe.GetPrincipal();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Binding.ToString();
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Binding.ToString();
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal abstract void DoSendFragment(byte[] buf, int off, int length, bool isDirect);
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal abstract void DoSendFragment(byte[] buf, int off, int length,
|
||||
bool isDirect);
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal abstract void DoReceiveFragment(byte[] buf, bool isDirect);
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal abstract void DoReceiveFragment(byte[] buf, bool isDirect);
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public abstract void Close();
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public abstract void Close();
|
||||
|
||||
public DcerpcHandle()
|
||||
{
|
||||
MaxRecv = MaxXmit;
|
||||
}
|
||||
}
|
||||
public DcerpcHandle()
|
||||
{
|
||||
MaxRecv = MaxXmit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,133 +18,133 @@ using SharpCifs.Dcerpc.Ndr;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public abstract class DcerpcMessage : NdrObject
|
||||
{
|
||||
protected internal int Ptype = -1;
|
||||
public abstract class DcerpcMessage : NdrObject
|
||||
{
|
||||
protected internal int Ptype = -1;
|
||||
|
||||
protected internal int Flags;
|
||||
protected internal int Flags;
|
||||
|
||||
protected internal int Length;
|
||||
protected internal int Length;
|
||||
|
||||
protected internal int CallId;
|
||||
protected internal int CallId;
|
||||
|
||||
protected internal int AllocHint;
|
||||
protected internal int AllocHint;
|
||||
|
||||
protected internal int Result;
|
||||
protected internal int Result;
|
||||
|
||||
public virtual bool IsFlagSet(int flag)
|
||||
{
|
||||
return (Flags & flag) == flag;
|
||||
}
|
||||
public virtual bool IsFlagSet(int flag)
|
||||
{
|
||||
return (Flags & flag) == flag;
|
||||
}
|
||||
|
||||
public virtual void UnsetFlag(int flag)
|
||||
{
|
||||
Flags &= ~flag;
|
||||
}
|
||||
public virtual void UnsetFlag(int flag)
|
||||
{
|
||||
Flags &= ~flag;
|
||||
}
|
||||
|
||||
public virtual void SetFlag(int flag)
|
||||
{
|
||||
Flags |= flag;
|
||||
}
|
||||
public virtual void SetFlag(int flag)
|
||||
{
|
||||
Flags |= flag;
|
||||
}
|
||||
|
||||
public virtual DcerpcException GetResult()
|
||||
{
|
||||
if (Result != 0)
|
||||
{
|
||||
return new DcerpcException(Result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public virtual DcerpcException GetResult()
|
||||
{
|
||||
if (Result != 0)
|
||||
{
|
||||
return new DcerpcException(Result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal virtual void Encode_header(NdrBuffer buf)
|
||||
{
|
||||
buf.Enc_ndr_small(5);
|
||||
buf.Enc_ndr_small(0);
|
||||
buf.Enc_ndr_small(Ptype);
|
||||
buf.Enc_ndr_small(Flags);
|
||||
buf.Enc_ndr_long(unchecked(0x00000010));
|
||||
buf.Enc_ndr_short(Length);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_long(CallId);
|
||||
}
|
||||
internal virtual void Encode_header(NdrBuffer buf)
|
||||
{
|
||||
buf.Enc_ndr_small(5);
|
||||
buf.Enc_ndr_small(0);
|
||||
buf.Enc_ndr_small(Ptype);
|
||||
buf.Enc_ndr_small(Flags);
|
||||
buf.Enc_ndr_long(unchecked(0x00000010));
|
||||
buf.Enc_ndr_short(Length);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_long(CallId);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
internal virtual void Decode_header(NdrBuffer buf)
|
||||
{
|
||||
if (buf.Dec_ndr_small() != 5 || buf.Dec_ndr_small() != 0)
|
||||
{
|
||||
throw new NdrException("DCERPC version not supported");
|
||||
}
|
||||
Ptype = buf.Dec_ndr_small();
|
||||
Flags = buf.Dec_ndr_small();
|
||||
if (buf.Dec_ndr_long() != unchecked(0x00000010))
|
||||
{
|
||||
throw new NdrException("Data representation not supported");
|
||||
}
|
||||
Length = buf.Dec_ndr_short();
|
||||
if (buf.Dec_ndr_short() != 0)
|
||||
{
|
||||
throw new NdrException("DCERPC authentication not supported");
|
||||
}
|
||||
CallId = buf.Dec_ndr_long();
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
internal virtual void Decode_header(NdrBuffer buf)
|
||||
{
|
||||
if (buf.Dec_ndr_small() != 5 || buf.Dec_ndr_small() != 0)
|
||||
{
|
||||
throw new NdrException("DCERPC version not supported");
|
||||
}
|
||||
Ptype = buf.Dec_ndr_small();
|
||||
Flags = buf.Dec_ndr_small();
|
||||
if (buf.Dec_ndr_long() != unchecked(0x00000010))
|
||||
{
|
||||
throw new NdrException("Data representation not supported");
|
||||
}
|
||||
Length = buf.Dec_ndr_short();
|
||||
if (buf.Dec_ndr_short() != 0)
|
||||
{
|
||||
throw new NdrException("DCERPC authentication not supported");
|
||||
}
|
||||
CallId = buf.Dec_ndr_long();
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer buf)
|
||||
{
|
||||
int start = buf.GetIndex();
|
||||
int allocHintIndex = 0;
|
||||
buf.Advance(16);
|
||||
if (Ptype == 0)
|
||||
{
|
||||
allocHintIndex = buf.GetIndex();
|
||||
buf.Enc_ndr_long(0);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_short(GetOpnum());
|
||||
}
|
||||
Encode_in(buf);
|
||||
Length = buf.GetIndex() - start;
|
||||
if (Ptype == 0)
|
||||
{
|
||||
buf.SetIndex(allocHintIndex);
|
||||
AllocHint = Length - allocHintIndex;
|
||||
buf.Enc_ndr_long(AllocHint);
|
||||
}
|
||||
buf.SetIndex(start);
|
||||
Encode_header(buf);
|
||||
buf.SetIndex(start + Length);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer buf)
|
||||
{
|
||||
int start = buf.GetIndex();
|
||||
int allocHintIndex = 0;
|
||||
buf.Advance(16);
|
||||
if (Ptype == 0)
|
||||
{
|
||||
allocHintIndex = buf.GetIndex();
|
||||
buf.Enc_ndr_long(0);
|
||||
buf.Enc_ndr_short(0);
|
||||
buf.Enc_ndr_short(GetOpnum());
|
||||
}
|
||||
Encode_in(buf);
|
||||
Length = buf.GetIndex() - start;
|
||||
if (Ptype == 0)
|
||||
{
|
||||
buf.SetIndex(allocHintIndex);
|
||||
AllocHint = Length - allocHintIndex;
|
||||
buf.Enc_ndr_long(AllocHint);
|
||||
}
|
||||
buf.SetIndex(start);
|
||||
Encode_header(buf);
|
||||
buf.SetIndex(start + Length);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer buf)
|
||||
{
|
||||
Decode_header(buf);
|
||||
if (Ptype != 12 && Ptype != 2 && Ptype != 3 && Ptype != 13)
|
||||
{
|
||||
throw new NdrException("Unexpected ptype: " + Ptype);
|
||||
}
|
||||
if (Ptype == 2 || Ptype == 3)
|
||||
{
|
||||
AllocHint = buf.Dec_ndr_long();
|
||||
buf.Dec_ndr_short();
|
||||
buf.Dec_ndr_short();
|
||||
}
|
||||
if (Ptype == 3 || Ptype == 13)
|
||||
{
|
||||
Result = buf.Dec_ndr_long();
|
||||
}
|
||||
else
|
||||
{
|
||||
Decode_out(buf);
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer buf)
|
||||
{
|
||||
Decode_header(buf);
|
||||
if (Ptype != 12 && Ptype != 2 && Ptype != 3 && Ptype != 13)
|
||||
{
|
||||
throw new NdrException("Unexpected ptype: " + Ptype);
|
||||
}
|
||||
if (Ptype == 2 || Ptype == 3)
|
||||
{
|
||||
AllocHint = buf.Dec_ndr_long();
|
||||
buf.Dec_ndr_short();
|
||||
buf.Dec_ndr_short();
|
||||
}
|
||||
if (Ptype == 3 || Ptype == 13)
|
||||
{
|
||||
Result = buf.Dec_ndr_long();
|
||||
}
|
||||
else
|
||||
{
|
||||
Decode_out(buf);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int GetOpnum();
|
||||
public abstract int GetOpnum();
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Encode_in(NdrBuffer dst);
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Encode_in(NdrBuffer dst);
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Decode_out(NdrBuffer src);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Decode_out(NdrBuffer src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,115 +22,114 @@ using SharpCifs.Util.Sharpen;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public class DcerpcPipeHandle : DcerpcHandle
|
||||
{
|
||||
internal SmbNamedPipe Pipe;
|
||||
public class DcerpcPipeHandle : DcerpcHandle
|
||||
{
|
||||
internal SmbNamedPipe Pipe;
|
||||
|
||||
internal SmbFileInputStream In;
|
||||
internal SmbFileInputStream In;
|
||||
|
||||
internal SmbFileOutputStream Out;
|
||||
internal SmbFileOutputStream Out;
|
||||
|
||||
internal bool IsStart = true;
|
||||
internal bool IsStart = true;
|
||||
|
||||
/// <exception cref="UnknownHostException"></exception>
|
||||
/// <exception cref="System.UriFormatException"></exception>
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
public DcerpcPipeHandle(string url, NtlmPasswordAuthentication auth)
|
||||
{
|
||||
Binding = ParseBinding(url);
|
||||
url = "smb://" + Binding.Server + "/IPC$/" + Runtime.Substring(Binding.Endpoint, 6);
|
||||
string @params = string.Empty;
|
||||
string server;
|
||||
string address;
|
||||
server = (string)Binding.GetOption("server");
|
||||
if (server != null)
|
||||
{
|
||||
@params += "&server=" + server;
|
||||
}
|
||||
address = (string)Binding.GetOption("address");
|
||||
if (server != null)
|
||||
{
|
||||
@params += "&address=" + address;
|
||||
}
|
||||
if (@params.Length > 0)
|
||||
{
|
||||
url += "?" + Runtime.Substring(@params, 1);
|
||||
}
|
||||
Pipe = new SmbNamedPipe(url,
|
||||
(unchecked(0x2019F) << 16)
|
||||
| SmbNamedPipe.PipeTypeRdwr
|
||||
| SmbNamedPipe.PipeTypeDceTransact,
|
||||
auth);
|
||||
}
|
||||
/// <exception cref="UnknownHostException"></exception>
|
||||
/// <exception cref="System.UriFormatException"></exception>
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
public DcerpcPipeHandle(string url, NtlmPasswordAuthentication auth)
|
||||
{
|
||||
Binding = ParseBinding(url);
|
||||
url = "smb://" + Binding.Server + "/IPC$/" + Runtime.Substring(Binding.Endpoint
|
||||
, 6);
|
||||
string @params = string.Empty;
|
||||
string server;
|
||||
string address;
|
||||
server = (string)Binding.GetOption("server");
|
||||
if (server != null)
|
||||
{
|
||||
@params += "&server=" + server;
|
||||
}
|
||||
address = (string)Binding.GetOption("address");
|
||||
if (server != null)
|
||||
{
|
||||
@params += "&address=" + address;
|
||||
}
|
||||
if (@params.Length > 0)
|
||||
{
|
||||
url += "?" + Runtime.Substring(@params, 1);
|
||||
}
|
||||
Pipe = new SmbNamedPipe(url, (unchecked(0x2019F) << 16) | SmbNamedPipe.PipeTypeRdwr
|
||||
| SmbNamedPipe.PipeTypeDceTransact, auth);
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal override void DoSendFragment(byte[] buf, int off, int length, bool isDirect)
|
||||
{
|
||||
if (Out != null && Out.IsOpen() == false)
|
||||
{
|
||||
throw new IOException("DCERPC pipe is no longer open");
|
||||
}
|
||||
if (In == null)
|
||||
{
|
||||
In = (SmbFileInputStream)Pipe.GetNamedPipeInputStream();
|
||||
}
|
||||
if (Out == null)
|
||||
{
|
||||
Out = (SmbFileOutputStream)Pipe.GetNamedPipeOutputStream();
|
||||
}
|
||||
if (isDirect)
|
||||
{
|
||||
Out.WriteDirect(buf, off, length, 1);
|
||||
return;
|
||||
}
|
||||
Out.Write(buf, off, length);
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal override void DoSendFragment(byte[] buf, int off, int length,
|
||||
bool isDirect)
|
||||
{
|
||||
if (Out != null && Out.IsOpen() == false)
|
||||
{
|
||||
throw new IOException("DCERPC pipe is no longer open");
|
||||
}
|
||||
if (In == null)
|
||||
{
|
||||
In = (SmbFileInputStream)Pipe.GetNamedPipeInputStream();
|
||||
}
|
||||
if (Out == null)
|
||||
{
|
||||
Out = (SmbFileOutputStream)Pipe.GetNamedPipeOutputStream();
|
||||
}
|
||||
if (isDirect)
|
||||
{
|
||||
Out.WriteDirect(buf, off, length, 1);
|
||||
return;
|
||||
}
|
||||
Out.Write(buf, off, length);
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal override void DoReceiveFragment(byte[] buf, bool isDirect)
|
||||
{
|
||||
int off;
|
||||
int flags;
|
||||
int length;
|
||||
if (buf.Length < MaxRecv)
|
||||
{
|
||||
throw new ArgumentException("buffer too small");
|
||||
}
|
||||
if (IsStart && !isDirect)
|
||||
{
|
||||
// start of new frag, do trans
|
||||
off = In.Read(buf, 0, 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
off = In.ReadDirect(buf, 0, buf.Length);
|
||||
}
|
||||
if (buf[0] != 5 && buf[1] != 0)
|
||||
{
|
||||
throw new IOException("Unexpected DCERPC PDU header");
|
||||
}
|
||||
flags = buf[3] & unchecked(0xFF);
|
||||
// next read is start of new frag
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
protected internal override void DoReceiveFragment(byte[] buf, bool isDirect)
|
||||
{
|
||||
int off;
|
||||
int flags;
|
||||
int length;
|
||||
if (buf.Length < MaxRecv)
|
||||
{
|
||||
throw new ArgumentException("buffer too small");
|
||||
}
|
||||
if (IsStart && !isDirect)
|
||||
{
|
||||
// start of new frag, do trans
|
||||
off = In.Read(buf, 0, 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
off = In.ReadDirect(buf, 0, buf.Length);
|
||||
}
|
||||
if (buf[0] != 5 && buf[1] != 0)
|
||||
{
|
||||
throw new IOException("Unexpected DCERPC PDU header");
|
||||
}
|
||||
flags = buf[3] & unchecked(0xFF);
|
||||
// next read is start of new frag
|
||||
IsStart = (flags & DcerpcConstants.DcerpcLastFrag) == DcerpcConstants.DcerpcLastFrag;
|
||||
length = Encdec.Dec_uint16le(buf, 8);
|
||||
if (length > MaxRecv)
|
||||
{
|
||||
throw new IOException("Unexpected fragment length: " + length);
|
||||
}
|
||||
while (off < length)
|
||||
{
|
||||
off += In.ReadDirect(buf, off, length - off);
|
||||
}
|
||||
}
|
||||
length = Encdec.Dec_uint16le(buf, 8);
|
||||
if (length > MaxRecv)
|
||||
{
|
||||
throw new IOException("Unexpected fragment length: " + length);
|
||||
}
|
||||
while (off < length)
|
||||
{
|
||||
off += In.ReadDirect(buf, off, length - off);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public override void Close()
|
||||
{
|
||||
State = 0;
|
||||
if (Out != null)
|
||||
{
|
||||
Out.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public override void Close()
|
||||
{
|
||||
State = 0;
|
||||
if (Out != null)
|
||||
{
|
||||
Out.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ using SharpCifs.Dcerpc.Ndr;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public interface IDcerpcSecurityProvider
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
void Wrap(NdrBuffer outgoing);
|
||||
public interface IDcerpcSecurityProvider
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
void Wrap(NdrBuffer outgoing);
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
void Unwrap(NdrBuffer incoming);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception>
|
||||
void Unwrap(NdrBuffer incoming);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,26 +18,26 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class LsaPolicyHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public LsaPolicyHandle(DcerpcHandle handle, string server, int access)
|
||||
{
|
||||
if (server == null)
|
||||
{
|
||||
server = "\\\\";
|
||||
}
|
||||
MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
public class LsaPolicyHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public LsaPolicyHandle(DcerpcHandle handle, string server, int access)
|
||||
{
|
||||
if (server == null)
|
||||
{
|
||||
server = "\\\\";
|
||||
}
|
||||
MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
internal class LsarSidArrayX : Lsarpc.LsarSidArray
|
||||
{
|
||||
internal LsarSidArrayX(Sid[] sids)
|
||||
{
|
||||
NumSids = sids.Length;
|
||||
this.Sids = new Lsarpc.LsarSidPtr[sids.Length];
|
||||
for (int si = 0; si < sids.Length; si++)
|
||||
{
|
||||
this.Sids[si] = new Lsarpc.LsarSidPtr();
|
||||
this.Sids[si].Sid = sids[si];
|
||||
}
|
||||
}
|
||||
}
|
||||
internal class LsarSidArrayX : Lsarpc.LsarSidArray
|
||||
{
|
||||
internal LsarSidArrayX(Sid[] sids)
|
||||
{
|
||||
NumSids = sids.Length;
|
||||
this.Sids = new Lsarpc.LsarSidPtr[sids.Length];
|
||||
for (int si = 0; si < sids.Length; si++)
|
||||
{
|
||||
this.Sids[si] = new Lsarpc.LsarSidPtr();
|
||||
this.Sids[si].Sid = sids[si];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,25 +19,25 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcDfsRootEnum : Netdfs.NetrDfsEnumEx
|
||||
{
|
||||
public MsrpcDfsRootEnum(string server) : base(server, 200, unchecked(0xFFFF), new Netdfs.DfsEnumStruct(), new NdrLong(0))
|
||||
{
|
||||
Info.Level = Level;
|
||||
Info.E = new Netdfs.DfsEnumArray200();
|
||||
Ptype = 0;
|
||||
public class MsrpcDfsRootEnum : Netdfs.NetrDfsEnumEx
|
||||
{
|
||||
public MsrpcDfsRootEnum(string server) : base(server, 200, unchecked(0xFFFF), new Netdfs.DfsEnumStruct(), new NdrLong(0))
|
||||
{
|
||||
Info.Level = Level;
|
||||
Info.E = new Netdfs.DfsEnumArray200();
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IFileEntry[] GetEntries()
|
||||
{
|
||||
Netdfs.DfsEnumArray200 a200 = (Netdfs.DfsEnumArray200)Info.E;
|
||||
SmbShareInfo[] entries = new SmbShareInfo[a200.Count];
|
||||
for (int i = 0; i < a200.Count; i++)
|
||||
{
|
||||
entries[i] = new SmbShareInfo(a200.S[i].DfsName, 0, null);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
public virtual IFileEntry[] GetEntries()
|
||||
{
|
||||
Netdfs.DfsEnumArray200 a200 = (Netdfs.DfsEnumArray200)Info.E;
|
||||
SmbShareInfo[] entries = new SmbShareInfo[a200.Count];
|
||||
for (int i = 0; i < a200.Count; i++)
|
||||
{
|
||||
entries[i] = new SmbShareInfo(a200.S[i].DfsName, 0, null);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcEnumerateAliasesInDomain : Samr.SamrEnumerateAliasesInDomain
|
||||
{
|
||||
public MsrpcEnumerateAliasesInDomain(SamrDomainHandle domainHandle, int acctFlags
|
||||
, Samr.SamrSamArray sam) : base(domainHandle, 0, acctFlags, null, 0)
|
||||
{
|
||||
this.Sam = sam;
|
||||
Ptype = 0;
|
||||
public class MsrpcEnumerateAliasesInDomain : Samr.SamrEnumerateAliasesInDomain
|
||||
{
|
||||
public MsrpcEnumerateAliasesInDomain(SamrDomainHandle domainHandle, int acctFlags
|
||||
, Samr.SamrSamArray sam) : base(domainHandle, 0, acctFlags, null, 0)
|
||||
{
|
||||
this.Sam = sam;
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcGetMembersInAlias : Samr.SamrGetMembersInAlias
|
||||
{
|
||||
public MsrpcGetMembersInAlias(SamrAliasHandle aliasHandle, Lsarpc.LsarSidArray sids
|
||||
) : base(aliasHandle, sids)
|
||||
{
|
||||
this.Sids = sids;
|
||||
Ptype = 0;
|
||||
public class MsrpcGetMembersInAlias : Samr.SamrGetMembersInAlias
|
||||
{
|
||||
public MsrpcGetMembersInAlias(SamrAliasHandle aliasHandle, Lsarpc.LsarSidArray sids
|
||||
) : base(aliasHandle, sids)
|
||||
{
|
||||
this.Sids = sids;
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,17 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcLookupSids : Lsarpc.LsarLookupSids
|
||||
{
|
||||
internal Sid[] sids;
|
||||
public class MsrpcLookupSids : Lsarpc.LsarLookupSids
|
||||
{
|
||||
internal Sid[] sids;
|
||||
|
||||
public MsrpcLookupSids(LsaPolicyHandle policyHandle, Sid[] sids)
|
||||
: base(policyHandle,
|
||||
new LsarSidArrayX(sids),
|
||||
new Lsarpc.LsarRefDomainList(),
|
||||
new Lsarpc.LsarTransNameArray(),
|
||||
1,
|
||||
sids.Length)
|
||||
{
|
||||
this.sids = sids;
|
||||
Ptype = 0;
|
||||
public MsrpcLookupSids(LsaPolicyHandle policyHandle, Sid[] sids) : base(policyHandle
|
||||
, new LsarSidArrayX(sids), new Lsarpc.LsarRefDomainList(), new Lsarpc.LsarTransNameArray
|
||||
(), 1, sids.Length)
|
||||
{
|
||||
this.sids = sids;
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,23 +16,20 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcLsarOpenPolicy2 : Lsarpc.LsarOpenPolicy2
|
||||
{
|
||||
public MsrpcLsarOpenPolicy2(string server, int access, LsaPolicyHandle policyHandle)
|
||||
: base(server,
|
||||
new Lsarpc.LsarObjectAttributes(),
|
||||
access,
|
||||
policyHandle)
|
||||
{
|
||||
ObjectAttributes.Length = 24;
|
||||
Lsarpc.LsarQosInfo qos = new Lsarpc.LsarQosInfo();
|
||||
qos.Length = 12;
|
||||
qos.ImpersonationLevel = 2;
|
||||
qos.ContextMode = 1;
|
||||
qos.EffectiveOnly = 0;
|
||||
ObjectAttributes.SecurityQualityOfService = qos;
|
||||
Ptype = 0;
|
||||
public class MsrpcLsarOpenPolicy2 : Lsarpc.LsarOpenPolicy2
|
||||
{
|
||||
public MsrpcLsarOpenPolicy2(string server, int access, LsaPolicyHandle policyHandle
|
||||
) : base(server, new Lsarpc.LsarObjectAttributes(), access, policyHandle)
|
||||
{
|
||||
ObjectAttributes.Length = 24;
|
||||
Lsarpc.LsarQosInfo qos = new Lsarpc.LsarQosInfo();
|
||||
qos.Length = 12;
|
||||
qos.ImpersonationLevel = 2;
|
||||
qos.ContextMode = 1;
|
||||
qos.EffectiveOnly = 0;
|
||||
ObjectAttributes.SecurityQualityOfService = qos;
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ using SharpCifs.Dcerpc.Ndr;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcQueryInformationPolicy : Lsarpc.LsarQueryInformationPolicy
|
||||
{
|
||||
public MsrpcQueryInformationPolicy(LsaPolicyHandle policyHandle, short level, NdrObject info)
|
||||
: base(policyHandle, level, info)
|
||||
{
|
||||
Ptype = 0;
|
||||
public class MsrpcQueryInformationPolicy : Lsarpc.LsarQueryInformationPolicy
|
||||
{
|
||||
public MsrpcQueryInformationPolicy(LsaPolicyHandle policyHandle, short level, NdrObject
|
||||
info) : base(policyHandle, level, info)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcSamrConnect2 : Samr.SamrConnect2
|
||||
{
|
||||
public MsrpcSamrConnect2(string server, int access, SamrPolicyHandle policyHandle)
|
||||
: base(server, access, policyHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
public class MsrpcSamrConnect2 : Samr.SamrConnect2
|
||||
{
|
||||
public MsrpcSamrConnect2(string server, int access, SamrPolicyHandle policyHandle
|
||||
) : base(server, access, policyHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcSamrConnect4 : Samr.SamrConnect4
|
||||
{
|
||||
public MsrpcSamrConnect4(string server, int access, SamrPolicyHandle policyHandle)
|
||||
: base(server, 2, access, policyHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
public class MsrpcSamrConnect4 : Samr.SamrConnect4
|
||||
{
|
||||
public MsrpcSamrConnect4(string server, int access, SamrPolicyHandle policyHandle
|
||||
) : base(server, 2, access, policyHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,13 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcSamrOpenAlias : Samr.SamrOpenAlias
|
||||
{
|
||||
public MsrpcSamrOpenAlias(SamrDomainHandle handle,
|
||||
int access,
|
||||
int rid,
|
||||
SamrAliasHandle aliasHandle)
|
||||
: base(handle, access, rid, aliasHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
public class MsrpcSamrOpenAlias : Samr.SamrOpenAlias
|
||||
{
|
||||
public MsrpcSamrOpenAlias(SamrDomainHandle handle, int access, int rid, SamrAliasHandle
|
||||
aliasHandle) : base(handle, access, rid, aliasHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,8 @@ namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcSamrOpenDomain : Samr.SamrOpenDomain
|
||||
{
|
||||
public MsrpcSamrOpenDomain(SamrPolicyHandle handle,
|
||||
int access,
|
||||
Rpc.SidT sid,
|
||||
SamrDomainHandle domainHandle)
|
||||
: base(handle, access, sid, domainHandle)
|
||||
public MsrpcSamrOpenDomain(SamrPolicyHandle handle, int access, Rpc.SidT sid, SamrDomainHandle
|
||||
domainHandle) : base(handle, access, sid, domainHandle)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
|
||||
@@ -18,38 +18,38 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcShareEnum : Srvsvc.ShareEnumAll
|
||||
{
|
||||
internal class MsrpcShareInfo1 : SmbShareInfo
|
||||
{
|
||||
internal MsrpcShareInfo1(MsrpcShareEnum enclosing, Srvsvc.ShareInfo1 info1)
|
||||
{
|
||||
this._enclosing = enclosing;
|
||||
NetName = info1.Netname;
|
||||
Type = info1.Type;
|
||||
Remark = info1.Remark;
|
||||
}
|
||||
public class MsrpcShareEnum : Srvsvc.ShareEnumAll
|
||||
{
|
||||
internal class MsrpcShareInfo1 : SmbShareInfo
|
||||
{
|
||||
internal MsrpcShareInfo1(MsrpcShareEnum enclosing, Srvsvc.ShareInfo1 info1)
|
||||
{
|
||||
this._enclosing = enclosing;
|
||||
NetName = info1.Netname;
|
||||
Type = info1.Type;
|
||||
Remark = info1.Remark;
|
||||
}
|
||||
|
||||
private readonly MsrpcShareEnum _enclosing;
|
||||
}
|
||||
private readonly MsrpcShareEnum _enclosing;
|
||||
}
|
||||
|
||||
public MsrpcShareEnum(string server)
|
||||
: base("\\\\" + server, 1, new Srvsvc.ShareInfoCtr1(), -1, 0, 0)
|
||||
{
|
||||
Ptype = 0;
|
||||
public MsrpcShareEnum(string server) : base("\\\\" + server, 1, new Srvsvc.ShareInfoCtr1
|
||||
(), -1, 0, 0)
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IFileEntry[] GetEntries()
|
||||
{
|
||||
Srvsvc.ShareInfoCtr1 ctr = (Srvsvc.ShareInfoCtr1)Info;
|
||||
MsrpcShareInfo1[] entries = new MsrpcShareInfo1[ctr
|
||||
.Count];
|
||||
for (int i = 0; i < ctr.Count; i++)
|
||||
{
|
||||
entries[i] = new MsrpcShareInfo1(this, ctr.Array[i]);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
public virtual IFileEntry[] GetEntries()
|
||||
{
|
||||
Srvsvc.ShareInfoCtr1 ctr = (Srvsvc.ShareInfoCtr1)Info;
|
||||
MsrpcShareInfo1[] entries = new MsrpcShareInfo1[ctr
|
||||
.Count];
|
||||
for (int i = 0; i < ctr.Count; i++)
|
||||
{
|
||||
entries[i] = new MsrpcShareInfo1(this, ctr.Array[i]);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,26 +18,26 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class MsrpcShareGetInfo : Srvsvc.ShareGetInfo
|
||||
{
|
||||
public MsrpcShareGetInfo(string server, string sharename)
|
||||
: base(server, sharename, 502, new Srvsvc.ShareInfo502())
|
||||
{
|
||||
Ptype = 0;
|
||||
public class MsrpcShareGetInfo : Srvsvc.ShareGetInfo
|
||||
{
|
||||
public MsrpcShareGetInfo(string server, string sharename) : base(server, sharename
|
||||
, 502, new Srvsvc.ShareInfo502())
|
||||
{
|
||||
Ptype = 0;
|
||||
Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual Ace[] GetSecurity()
|
||||
{
|
||||
Srvsvc.ShareInfo502 info502 = (Srvsvc.ShareInfo502)Info;
|
||||
if (info502.SecurityDescriptor != null)
|
||||
{
|
||||
SecurityDescriptor sd;
|
||||
sd = new SecurityDescriptor(info502.SecurityDescriptor, 0, info502.SdSize);
|
||||
return sd.Aces;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual Ace[] GetSecurity()
|
||||
{
|
||||
Srvsvc.ShareInfo502 info502 = (Srvsvc.ShareInfo502)Info;
|
||||
if (info502.SecurityDescriptor != null)
|
||||
{
|
||||
SecurityDescriptor sd;
|
||||
sd = new SecurityDescriptor(info502.SecurityDescriptor, 0, info502.SdSize);
|
||||
return sd.Aces;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,25 +18,23 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class SamrAliasHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrAliasHandle(DcerpcHandle handle,
|
||||
SamrDomainHandle domainHandle,
|
||||
int access,
|
||||
int rid)
|
||||
{
|
||||
MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
public class SamrAliasHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrAliasHandle(DcerpcHandle handle, SamrDomainHandle domainHandle, int access
|
||||
, int rid)
|
||||
{
|
||||
MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,25 +18,24 @@ using SharpCifs.Smb;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class SamrDomainHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrDomainHandle(DcerpcHandle handle,
|
||||
SamrPolicyHandle policyHandle,
|
||||
int access,
|
||||
Rpc.SidT sid)
|
||||
{
|
||||
MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
public class SamrDomainHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrDomainHandle(DcerpcHandle handle, SamrPolicyHandle policyHandle, int access
|
||||
, Rpc.SidT sid)
|
||||
{
|
||||
MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this
|
||||
);
|
||||
handle.Sendrecv(rpc);
|
||||
if (rpc.Retval != 0)
|
||||
{
|
||||
throw new SmbException(rpc.Retval, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,34 +16,34 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Msrpc
|
||||
{
|
||||
public class SamrPolicyHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrPolicyHandle(DcerpcHandle handle, string server, int access)
|
||||
{
|
||||
if (server == null)
|
||||
{
|
||||
server = "\\\\";
|
||||
}
|
||||
MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this);
|
||||
try
|
||||
{
|
||||
handle.Sendrecv(rpc);
|
||||
}
|
||||
catch (DcerpcException de)
|
||||
{
|
||||
if (de.GetErrorCode() != DcerpcError.DcerpcFaultOpRngError)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this);
|
||||
handle.Sendrecv(rpc2);
|
||||
}
|
||||
}
|
||||
public class SamrPolicyHandle : Rpc.PolicyHandle
|
||||
{
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public SamrPolicyHandle(DcerpcHandle handle, string server, int access)
|
||||
{
|
||||
if (server == null)
|
||||
{
|
||||
server = "\\\\";
|
||||
}
|
||||
MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this);
|
||||
try
|
||||
{
|
||||
handle.Sendrecv(rpc);
|
||||
}
|
||||
catch (DcerpcException de)
|
||||
{
|
||||
if (de.GetErrorCode() != DcerpcError.DcerpcFaultOpRngError)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this);
|
||||
handle.Sendrecv(rpc2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <exception cref="System.IO.IOException"></exception>
|
||||
public virtual void Close()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,285 +20,286 @@ using SharpCifs.Util.Sharpen;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public class NdrBuffer
|
||||
{
|
||||
internal int Referent;
|
||||
public class NdrBuffer
|
||||
{
|
||||
internal int Referent;
|
||||
|
||||
internal Hashtable Referents;
|
||||
internal Hashtable Referents;
|
||||
|
||||
internal class Entry
|
||||
{
|
||||
internal int Referent;
|
||||
internal class Entry
|
||||
{
|
||||
internal int Referent;
|
||||
|
||||
internal object Obj;
|
||||
}
|
||||
internal object Obj;
|
||||
}
|
||||
|
||||
public byte[] Buf;
|
||||
public byte[] Buf;
|
||||
|
||||
public int Start;
|
||||
public int Start;
|
||||
|
||||
public int Index;
|
||||
public int Index;
|
||||
|
||||
public int Length;
|
||||
public int Length;
|
||||
|
||||
public NdrBuffer Deferred;
|
||||
public NdrBuffer Deferred;
|
||||
|
||||
public NdrBuffer(byte[] buf, int start)
|
||||
{
|
||||
this.Buf = buf;
|
||||
this.Start = Index = start;
|
||||
Length = 0;
|
||||
Deferred = this;
|
||||
}
|
||||
public NdrBuffer(byte[] buf, int start)
|
||||
{
|
||||
this.Buf = buf;
|
||||
this.Start = Index = start;
|
||||
Length = 0;
|
||||
Deferred = this;
|
||||
}
|
||||
|
||||
public virtual NdrBuffer Derive(int idx)
|
||||
{
|
||||
NdrBuffer nb = new NdrBuffer(Buf, Start);
|
||||
nb.Index = idx;
|
||||
nb.Deferred = Deferred;
|
||||
return nb;
|
||||
}
|
||||
public virtual NdrBuffer Derive(int idx)
|
||||
{
|
||||
NdrBuffer nb = new NdrBuffer(Buf, Start);
|
||||
nb.Index = idx;
|
||||
nb.Deferred = Deferred;
|
||||
return nb;
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
Index = Start;
|
||||
Length = 0;
|
||||
Deferred = this;
|
||||
}
|
||||
public virtual void Reset()
|
||||
{
|
||||
Index = Start;
|
||||
Length = 0;
|
||||
Deferred = this;
|
||||
}
|
||||
|
||||
public virtual int GetIndex()
|
||||
{
|
||||
return Index;
|
||||
}
|
||||
public virtual int GetIndex()
|
||||
{
|
||||
return Index;
|
||||
}
|
||||
|
||||
public virtual void SetIndex(int index)
|
||||
{
|
||||
this.Index = index;
|
||||
}
|
||||
public virtual void SetIndex(int index)
|
||||
{
|
||||
this.Index = index;
|
||||
}
|
||||
|
||||
public virtual int GetCapacity()
|
||||
{
|
||||
return Buf.Length - Start;
|
||||
}
|
||||
public virtual int GetCapacity()
|
||||
{
|
||||
return Buf.Length - Start;
|
||||
}
|
||||
|
||||
public virtual int GetTailSpace()
|
||||
{
|
||||
return Buf.Length - Index;
|
||||
}
|
||||
public virtual int GetTailSpace()
|
||||
{
|
||||
return Buf.Length - Index;
|
||||
}
|
||||
|
||||
public virtual byte[] GetBuffer()
|
||||
{
|
||||
return Buf;
|
||||
}
|
||||
public virtual byte[] GetBuffer()
|
||||
{
|
||||
return Buf;
|
||||
}
|
||||
|
||||
public virtual int Align(int boundary, byte value)
|
||||
{
|
||||
int n = Align(boundary);
|
||||
int i = n;
|
||||
while (i > 0)
|
||||
{
|
||||
Buf[Index - i] = value;
|
||||
i--;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
public virtual int Align(int boundary, byte value)
|
||||
{
|
||||
int n = Align(boundary);
|
||||
int i = n;
|
||||
while (i > 0)
|
||||
{
|
||||
Buf[Index - i] = value;
|
||||
i--;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public virtual void WriteOctetArray(byte[] b, int i, int l)
|
||||
{
|
||||
Array.Copy(b, i, Buf, Index, l);
|
||||
Advance(l);
|
||||
}
|
||||
public virtual void WriteOctetArray(byte[] b, int i, int l)
|
||||
{
|
||||
Array.Copy(b, i, Buf, Index, l);
|
||||
Advance(l);
|
||||
}
|
||||
|
||||
public virtual void ReadOctetArray(byte[] b, int i, int l)
|
||||
{
|
||||
Array.Copy(Buf, Index, b, i, l);
|
||||
Advance(l);
|
||||
}
|
||||
public virtual void ReadOctetArray(byte[] b, int i, int l)
|
||||
{
|
||||
Array.Copy(Buf, Index, b, i, l);
|
||||
Advance(l);
|
||||
}
|
||||
|
||||
public virtual int GetLength()
|
||||
{
|
||||
return Deferred.Length;
|
||||
}
|
||||
public virtual int GetLength()
|
||||
{
|
||||
return Deferred.Length;
|
||||
}
|
||||
|
||||
public virtual void SetLength(int length)
|
||||
{
|
||||
Deferred.Length = length;
|
||||
}
|
||||
public virtual void SetLength(int length)
|
||||
{
|
||||
Deferred.Length = length;
|
||||
}
|
||||
|
||||
public virtual void Advance(int n)
|
||||
{
|
||||
Index += n;
|
||||
if ((Index - Start) > Deferred.Length)
|
||||
{
|
||||
Deferred.Length = Index - Start;
|
||||
}
|
||||
}
|
||||
public virtual void Advance(int n)
|
||||
{
|
||||
Index += n;
|
||||
if ((Index - Start) > Deferred.Length)
|
||||
{
|
||||
Deferred.Length = Index - Start;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Align(int boundary)
|
||||
{
|
||||
int m = boundary - 1;
|
||||
int i = Index - Start;
|
||||
int n = ((i + m) & ~m) - i;
|
||||
Advance(n);
|
||||
return n;
|
||||
}
|
||||
public virtual int Align(int boundary)
|
||||
{
|
||||
int m = boundary - 1;
|
||||
int i = Index - Start;
|
||||
int n = ((i + m) & ~m) - i;
|
||||
Advance(n);
|
||||
return n;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_small(int s)
|
||||
{
|
||||
Buf[Index] = unchecked((byte)(s & unchecked(0xFF)));
|
||||
Advance(1);
|
||||
}
|
||||
public virtual void Enc_ndr_small(int s)
|
||||
{
|
||||
Buf[Index] = unchecked((byte)(s & unchecked(0xFF)));
|
||||
Advance(1);
|
||||
}
|
||||
|
||||
public virtual int Dec_ndr_small()
|
||||
{
|
||||
int val = Buf[Index] & unchecked(0xFF);
|
||||
Advance(1);
|
||||
return val;
|
||||
}
|
||||
public virtual int Dec_ndr_small()
|
||||
{
|
||||
int val = Buf[Index] & unchecked(0xFF);
|
||||
Advance(1);
|
||||
return val;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_short(int s)
|
||||
{
|
||||
Align(2);
|
||||
Encdec.Enc_uint16le((short)s, Buf, Index);
|
||||
Advance(2);
|
||||
}
|
||||
public virtual void Enc_ndr_short(int s)
|
||||
{
|
||||
Align(2);
|
||||
Encdec.Enc_uint16le((short)s, Buf, Index);
|
||||
Advance(2);
|
||||
}
|
||||
|
||||
public virtual int Dec_ndr_short()
|
||||
{
|
||||
Align(2);
|
||||
int val = Encdec.Dec_uint16le(Buf, Index);
|
||||
Advance(2);
|
||||
return val;
|
||||
}
|
||||
public virtual int Dec_ndr_short()
|
||||
{
|
||||
Align(2);
|
||||
int val = Encdec.Dec_uint16le(Buf, Index);
|
||||
Advance(2);
|
||||
return val;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_long(int l)
|
||||
{
|
||||
Align(4);
|
||||
Encdec.Enc_uint32le(l, Buf, Index);
|
||||
Advance(4);
|
||||
}
|
||||
public virtual void Enc_ndr_long(int l)
|
||||
{
|
||||
Align(4);
|
||||
Encdec.Enc_uint32le(l, Buf, Index);
|
||||
Advance(4);
|
||||
}
|
||||
|
||||
public virtual int Dec_ndr_long()
|
||||
{
|
||||
Align(4);
|
||||
int val = Encdec.Dec_uint32le(Buf, Index);
|
||||
Advance(4);
|
||||
return val;
|
||||
}
|
||||
public virtual int Dec_ndr_long()
|
||||
{
|
||||
Align(4);
|
||||
int val = Encdec.Dec_uint32le(Buf, Index);
|
||||
Advance(4);
|
||||
return val;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_hyper(long h)
|
||||
{
|
||||
Align(8);
|
||||
Encdec.Enc_uint64le(h, Buf, Index);
|
||||
Advance(8);
|
||||
}
|
||||
public virtual void Enc_ndr_hyper(long h)
|
||||
{
|
||||
Align(8);
|
||||
Encdec.Enc_uint64le(h, Buf, Index);
|
||||
Advance(8);
|
||||
}
|
||||
|
||||
public virtual long Dec_ndr_hyper()
|
||||
{
|
||||
Align(8);
|
||||
long val = Encdec.Dec_uint64le(Buf, Index);
|
||||
Advance(8);
|
||||
return val;
|
||||
}
|
||||
public virtual long Dec_ndr_hyper()
|
||||
{
|
||||
Align(8);
|
||||
long val = Encdec.Dec_uint64le(Buf, Index);
|
||||
Advance(8);
|
||||
return val;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_string(string s)
|
||||
{
|
||||
Align(4);
|
||||
int i = Index;
|
||||
int len = s.Length;
|
||||
Encdec.Enc_uint32le(len + 1, Buf, i);
|
||||
i += 4;
|
||||
Encdec.Enc_uint32le(0, Buf, i);
|
||||
i += 4;
|
||||
Encdec.Enc_uint32le(len + 1, Buf, i);
|
||||
i += 4;
|
||||
try
|
||||
{
|
||||
Array.Copy(Runtime.GetBytesForString(s, "UTF-16LE"), 0, Buf, i, len * 2);
|
||||
}
|
||||
catch (UnsupportedEncodingException)
|
||||
{
|
||||
}
|
||||
i += len * 2;
|
||||
Buf[i++] = unchecked((byte)('\0'));
|
||||
Buf[i++] = unchecked((byte)('\0'));
|
||||
Advance(i - Index);
|
||||
}
|
||||
public virtual void Enc_ndr_string(string s)
|
||||
{
|
||||
Align(4);
|
||||
int i = Index;
|
||||
int len = s.Length;
|
||||
Encdec.Enc_uint32le(len + 1, Buf, i);
|
||||
i += 4;
|
||||
Encdec.Enc_uint32le(0, Buf, i);
|
||||
i += 4;
|
||||
Encdec.Enc_uint32le(len + 1, Buf, i);
|
||||
i += 4;
|
||||
try
|
||||
{
|
||||
Array.Copy(Runtime.GetBytesForString(s, "UTF-16LE"), 0, Buf, i, len
|
||||
* 2);
|
||||
}
|
||||
catch (UnsupportedEncodingException)
|
||||
{
|
||||
}
|
||||
i += len * 2;
|
||||
Buf[i++] = unchecked((byte)('\0'));
|
||||
Buf[i++] = unchecked((byte)('\0'));
|
||||
Advance(i - Index);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public virtual string Dec_ndr_string()
|
||||
{
|
||||
Align(4);
|
||||
int i = Index;
|
||||
string val = null;
|
||||
int len = Encdec.Dec_uint32le(Buf, i);
|
||||
i += 12;
|
||||
if (len != 0)
|
||||
{
|
||||
len--;
|
||||
int size = len * 2;
|
||||
try
|
||||
{
|
||||
if (size < 0 || size > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
val = Runtime.GetStringForBytes(Buf, i, size, "UTF-16LE");
|
||||
i += size + 2;
|
||||
}
|
||||
catch (UnsupportedEncodingException)
|
||||
{
|
||||
}
|
||||
}
|
||||
Advance(i - Index);
|
||||
return val;
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public virtual string Dec_ndr_string()
|
||||
{
|
||||
Align(4);
|
||||
int i = Index;
|
||||
string val = null;
|
||||
int len = Encdec.Dec_uint32le(Buf, i);
|
||||
i += 12;
|
||||
if (len != 0)
|
||||
{
|
||||
len--;
|
||||
int size = len * 2;
|
||||
try
|
||||
{
|
||||
if (size < 0 || size > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
val = Runtime.GetStringForBytes(Buf, i, size, "UTF-16LE");
|
||||
i += size + 2;
|
||||
}
|
||||
catch (UnsupportedEncodingException)
|
||||
{
|
||||
}
|
||||
}
|
||||
Advance(i - Index);
|
||||
return val;
|
||||
}
|
||||
|
||||
private int GetDceReferent(object obj)
|
||||
{
|
||||
Entry e;
|
||||
if (Referents == null)
|
||||
{
|
||||
Referents = new Hashtable();
|
||||
Referent = 1;
|
||||
}
|
||||
if ((e = (Entry)Referents.Get(obj)) == null)
|
||||
{
|
||||
e = new Entry();
|
||||
e.Referent = Referent++;
|
||||
e.Obj = obj;
|
||||
Referents.Put(obj, e);
|
||||
}
|
||||
return e.Referent;
|
||||
}
|
||||
private int GetDceReferent(object obj)
|
||||
{
|
||||
Entry e;
|
||||
if (Referents == null)
|
||||
{
|
||||
Referents = new Hashtable();
|
||||
Referent = 1;
|
||||
}
|
||||
if ((e = (Entry)Referents.Get(obj)) == null)
|
||||
{
|
||||
e = new Entry();
|
||||
e.Referent = Referent++;
|
||||
e.Obj = obj;
|
||||
Referents.Put(obj, e);
|
||||
}
|
||||
return e.Referent;
|
||||
}
|
||||
|
||||
public virtual void Enc_ndr_referent(object obj, int type)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
Enc_ndr_long(0);
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
case 3:
|
||||
{
|
||||
Enc_ndr_long(Runtime.IdentityHashCode(obj));
|
||||
return;
|
||||
}
|
||||
public virtual void Enc_ndr_referent(object obj, int type)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
Enc_ndr_long(0);
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
case 3:
|
||||
{
|
||||
Enc_ndr_long(Runtime.IdentityHashCode(obj));
|
||||
return;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
Enc_ndr_long(GetDceReferent(obj));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
Enc_ndr_long(GetDceReferent(obj));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "start=" + Start + ",index=" + Index + ",length=" + GetLength();
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return "start=" + Start + ",index=" + Index + ",length=" + GetLength();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@ using System.IO;
|
||||
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
|
||||
public class NdrException : IOException
|
||||
{
|
||||
public static readonly string NoNullRef = "ref pointer cannot be null";
|
||||
|
||||
public class NdrException : IOException
|
||||
{
|
||||
public static readonly string NoNullRef = "ref pointer cannot be null";
|
||||
public static readonly string InvalidConformance = "invalid array conformance";
|
||||
|
||||
public static readonly string InvalidConformance = "invalid array conformance";
|
||||
|
||||
public NdrException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
public NdrException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public class NdrHyper : NdrObject
|
||||
{
|
||||
public long Value;
|
||||
public class NdrHyper : NdrObject
|
||||
{
|
||||
public long Value;
|
||||
|
||||
public NdrHyper(long value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
public NdrHyper(long value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_hyper(Value);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_hyper(Value);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_hyper();
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_hyper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public class NdrLong : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
public class NdrLong : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
|
||||
public NdrLong(int value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
public NdrLong(int value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_long(Value);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_long(Value);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_long();
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_long();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public abstract class NdrObject
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Encode(NdrBuffer dst);
|
||||
public abstract class NdrObject
|
||||
{
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Encode(NdrBuffer dst);
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Decode(NdrBuffer src);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public abstract void Decode(NdrBuffer src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public class NdrShort : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
public class NdrShort : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
|
||||
public NdrShort(int value)
|
||||
{
|
||||
this.Value = value & unchecked(0xFF);
|
||||
}
|
||||
public NdrShort(int value)
|
||||
{
|
||||
this.Value = value & unchecked(0xFF);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_short(Value);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_short(Value);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_short();
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_short();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,25 +16,25 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc.Ndr
|
||||
{
|
||||
public class NdrSmall : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
public class NdrSmall : NdrObject
|
||||
{
|
||||
public int Value;
|
||||
|
||||
public NdrSmall(int value)
|
||||
{
|
||||
this.Value = value & unchecked(0xFF);
|
||||
}
|
||||
public NdrSmall(int value)
|
||||
{
|
||||
this.Value = value & unchecked(0xFF);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_small(Value);
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Enc_ndr_small(Value);
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_small();
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
Value = src.Dec_ndr_small();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,268 +18,268 @@ using SharpCifs.Dcerpc.Ndr;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public class Rpc
|
||||
{
|
||||
public class UuidT : NdrObject
|
||||
{
|
||||
public int TimeLow;
|
||||
public class Rpc
|
||||
{
|
||||
public class UuidT : NdrObject
|
||||
{
|
||||
public int TimeLow;
|
||||
|
||||
public short TimeMid;
|
||||
public short TimeMid;
|
||||
|
||||
public short TimeHiAndVersion;
|
||||
public short TimeHiAndVersion;
|
||||
|
||||
public byte ClockSeqHiAndReserved;
|
||||
public byte ClockSeqHiAndReserved;
|
||||
|
||||
public byte ClockSeqLow;
|
||||
public byte ClockSeqLow;
|
||||
|
||||
public byte[] Node;
|
||||
public byte[] Node;
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_long(TimeLow);
|
||||
dst.Enc_ndr_short(TimeMid);
|
||||
dst.Enc_ndr_short(TimeHiAndVersion);
|
||||
dst.Enc_ndr_small(ClockSeqHiAndReserved);
|
||||
dst.Enc_ndr_small(ClockSeqLow);
|
||||
int nodes = 6;
|
||||
int nodei = dst.Index;
|
||||
dst.Advance(1 * nodes);
|
||||
dst = dst.Derive(nodei);
|
||||
for (int i = 0; i < nodes; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(Node[i]);
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_long(TimeLow);
|
||||
dst.Enc_ndr_short(TimeMid);
|
||||
dst.Enc_ndr_short(TimeHiAndVersion);
|
||||
dst.Enc_ndr_small(ClockSeqHiAndReserved);
|
||||
dst.Enc_ndr_small(ClockSeqLow);
|
||||
int nodes = 6;
|
||||
int nodei = dst.Index;
|
||||
dst.Advance(1 * nodes);
|
||||
dst = dst.Derive(nodei);
|
||||
for (int i = 0; i < nodes; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(Node[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
TimeLow = src.Dec_ndr_long();
|
||||
TimeMid = (short)src.Dec_ndr_short();
|
||||
TimeHiAndVersion = (short)src.Dec_ndr_short();
|
||||
ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
|
||||
ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
|
||||
int nodes = 6;
|
||||
int nodei = src.Index;
|
||||
src.Advance(1 * nodes);
|
||||
if (Node == null)
|
||||
{
|
||||
if (nodes < 0 || nodes > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Node = new byte[nodes];
|
||||
}
|
||||
src = src.Derive(nodei);
|
||||
for (int i = 0; i < nodes; i++)
|
||||
{
|
||||
Node[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
TimeLow = src.Dec_ndr_long();
|
||||
TimeMid = (short)src.Dec_ndr_short();
|
||||
TimeHiAndVersion = (short)src.Dec_ndr_short();
|
||||
ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
|
||||
ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
|
||||
int nodes = 6;
|
||||
int nodei = src.Index;
|
||||
src.Advance(1 * nodes);
|
||||
if (Node == null)
|
||||
{
|
||||
if (nodes < 0 || nodes > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Node = new byte[nodes];
|
||||
}
|
||||
src = src.Derive(nodei);
|
||||
for (int i = 0; i < nodes; i++)
|
||||
{
|
||||
Node[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PolicyHandle : NdrObject
|
||||
{
|
||||
public int Type;
|
||||
public class PolicyHandle : NdrObject
|
||||
{
|
||||
public int Type;
|
||||
|
||||
public UuidT Uuid;
|
||||
public UuidT Uuid;
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_long(Type);
|
||||
dst.Enc_ndr_long(Uuid.TimeLow);
|
||||
dst.Enc_ndr_short(Uuid.TimeMid);
|
||||
dst.Enc_ndr_short(Uuid.TimeHiAndVersion);
|
||||
dst.Enc_ndr_small(Uuid.ClockSeqHiAndReserved);
|
||||
dst.Enc_ndr_small(Uuid.ClockSeqLow);
|
||||
int uuidNodes = 6;
|
||||
int uuidNodei = dst.Index;
|
||||
dst.Advance(1 * uuidNodes);
|
||||
dst = dst.Derive(uuidNodei);
|
||||
for (int i = 0; i < uuidNodes; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(Uuid.Node[i]);
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_long(Type);
|
||||
dst.Enc_ndr_long(Uuid.TimeLow);
|
||||
dst.Enc_ndr_short(Uuid.TimeMid);
|
||||
dst.Enc_ndr_short(Uuid.TimeHiAndVersion);
|
||||
dst.Enc_ndr_small(Uuid.ClockSeqHiAndReserved);
|
||||
dst.Enc_ndr_small(Uuid.ClockSeqLow);
|
||||
int uuidNodes = 6;
|
||||
int uuidNodei = dst.Index;
|
||||
dst.Advance(1 * uuidNodes);
|
||||
dst = dst.Derive(uuidNodei);
|
||||
for (int i = 0; i < uuidNodes; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(Uuid.Node[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
Type = src.Dec_ndr_long();
|
||||
src.Align(4);
|
||||
if (Uuid == null)
|
||||
{
|
||||
Uuid = new UuidT();
|
||||
}
|
||||
Uuid.TimeLow = src.Dec_ndr_long();
|
||||
Uuid.TimeMid = (short)src.Dec_ndr_short();
|
||||
Uuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
|
||||
Uuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
|
||||
Uuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
|
||||
int uuidNodes = 6;
|
||||
int uuidNodei = src.Index;
|
||||
src.Advance(1 * uuidNodes);
|
||||
if (Uuid.Node == null)
|
||||
{
|
||||
if (uuidNodes < 0 || uuidNodes > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Uuid.Node = new byte[uuidNodes];
|
||||
}
|
||||
src = src.Derive(uuidNodei);
|
||||
for (int i = 0; i < uuidNodes; i++)
|
||||
{
|
||||
Uuid.Node[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
Type = src.Dec_ndr_long();
|
||||
src.Align(4);
|
||||
if (Uuid == null)
|
||||
{
|
||||
Uuid = new UuidT();
|
||||
}
|
||||
Uuid.TimeLow = src.Dec_ndr_long();
|
||||
Uuid.TimeMid = (short)src.Dec_ndr_short();
|
||||
Uuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
|
||||
Uuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
|
||||
Uuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
|
||||
int uuidNodes = 6;
|
||||
int uuidNodei = src.Index;
|
||||
src.Advance(1 * uuidNodes);
|
||||
if (Uuid.Node == null)
|
||||
{
|
||||
if (uuidNodes < 0 || uuidNodes > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Uuid.Node = new byte[uuidNodes];
|
||||
}
|
||||
src = src.Derive(uuidNodei);
|
||||
for (int i = 0; i < uuidNodes; i++)
|
||||
{
|
||||
Uuid.Node[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Unicode_string : NdrObject
|
||||
{
|
||||
public short Length;
|
||||
public class Unicode_string : NdrObject
|
||||
{
|
||||
public short Length;
|
||||
|
||||
public short MaximumLength;
|
||||
public short MaximumLength;
|
||||
|
||||
public short[] Buffer;
|
||||
public short[] Buffer;
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_short(Length);
|
||||
dst.Enc_ndr_short(MaximumLength);
|
||||
dst.Enc_ndr_referent(Buffer, 1);
|
||||
if (Buffer != null)
|
||||
{
|
||||
dst = dst.Deferred;
|
||||
int bufferl = Length / 2;
|
||||
int buffers = MaximumLength / 2;
|
||||
dst.Enc_ndr_long(buffers);
|
||||
dst.Enc_ndr_long(0);
|
||||
dst.Enc_ndr_long(bufferl);
|
||||
int bufferi = dst.Index;
|
||||
dst.Advance(2 * bufferl);
|
||||
dst = dst.Derive(bufferi);
|
||||
for (int i = 0; i < bufferl; i++)
|
||||
{
|
||||
dst.Enc_ndr_short(Buffer[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
dst.Enc_ndr_short(Length);
|
||||
dst.Enc_ndr_short(MaximumLength);
|
||||
dst.Enc_ndr_referent(Buffer, 1);
|
||||
if (Buffer != null)
|
||||
{
|
||||
dst = dst.Deferred;
|
||||
int bufferl = Length / 2;
|
||||
int buffers = MaximumLength / 2;
|
||||
dst.Enc_ndr_long(buffers);
|
||||
dst.Enc_ndr_long(0);
|
||||
dst.Enc_ndr_long(bufferl);
|
||||
int bufferi = dst.Index;
|
||||
dst.Advance(2 * bufferl);
|
||||
dst = dst.Derive(bufferi);
|
||||
for (int i = 0; i < bufferl; i++)
|
||||
{
|
||||
dst.Enc_ndr_short(Buffer[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
Length = (short)src.Dec_ndr_short();
|
||||
MaximumLength = (short)src.Dec_ndr_short();
|
||||
int bufferp = src.Dec_ndr_long();
|
||||
if (bufferp != 0)
|
||||
{
|
||||
src = src.Deferred;
|
||||
int buffers = src.Dec_ndr_long();
|
||||
src.Dec_ndr_long();
|
||||
int bufferl = src.Dec_ndr_long();
|
||||
int bufferi = src.Index;
|
||||
src.Advance(2 * bufferl);
|
||||
if (Buffer == null)
|
||||
{
|
||||
if (buffers < 0 || buffers > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Buffer = new short[buffers];
|
||||
}
|
||||
src = src.Derive(bufferi);
|
||||
for (int i = 0; i < bufferl; i++)
|
||||
{
|
||||
Buffer[i] = (short)src.Dec_ndr_short();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
Length = (short)src.Dec_ndr_short();
|
||||
MaximumLength = (short)src.Dec_ndr_short();
|
||||
int bufferp = src.Dec_ndr_long();
|
||||
if (bufferp != 0)
|
||||
{
|
||||
src = src.Deferred;
|
||||
int buffers = src.Dec_ndr_long();
|
||||
src.Dec_ndr_long();
|
||||
int bufferl = src.Dec_ndr_long();
|
||||
int bufferi = src.Index;
|
||||
src.Advance(2 * bufferl);
|
||||
if (Buffer == null)
|
||||
{
|
||||
if (buffers < 0 || buffers > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
Buffer = new short[buffers];
|
||||
}
|
||||
src = src.Derive(bufferi);
|
||||
for (int i = 0; i < bufferl; i++)
|
||||
{
|
||||
Buffer[i] = (short)src.Dec_ndr_short();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SidT : NdrObject
|
||||
{
|
||||
public byte Revision;
|
||||
public class SidT : NdrObject
|
||||
{
|
||||
public byte Revision;
|
||||
|
||||
public byte SubAuthorityCount;
|
||||
public byte SubAuthorityCount;
|
||||
|
||||
public byte[] IdentifierAuthority;
|
||||
public byte[] IdentifierAuthority;
|
||||
|
||||
public int[] SubAuthority;
|
||||
public int[] SubAuthority;
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
int subAuthoritys = SubAuthorityCount;
|
||||
dst.Enc_ndr_long(subAuthoritys);
|
||||
dst.Enc_ndr_small(Revision);
|
||||
dst.Enc_ndr_small(SubAuthorityCount);
|
||||
int identifierAuthoritys = 6;
|
||||
int identifierAuthorityi = dst.Index;
|
||||
dst.Advance(1 * identifierAuthoritys);
|
||||
int subAuthorityi = dst.Index;
|
||||
dst.Advance(4 * subAuthoritys);
|
||||
dst = dst.Derive(identifierAuthorityi);
|
||||
for (int i = 0; i < identifierAuthoritys; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(IdentifierAuthority[i]);
|
||||
}
|
||||
dst = dst.Derive(subAuthorityi);
|
||||
for (int i1 = 0; i1 < subAuthoritys; i1++)
|
||||
{
|
||||
dst.Enc_ndr_long(SubAuthority[i1]);
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Encode(NdrBuffer dst)
|
||||
{
|
||||
dst.Align(4);
|
||||
int subAuthoritys = SubAuthorityCount;
|
||||
dst.Enc_ndr_long(subAuthoritys);
|
||||
dst.Enc_ndr_small(Revision);
|
||||
dst.Enc_ndr_small(SubAuthorityCount);
|
||||
int identifierAuthoritys = 6;
|
||||
int identifierAuthorityi = dst.Index;
|
||||
dst.Advance(1 * identifierAuthoritys);
|
||||
int subAuthorityi = dst.Index;
|
||||
dst.Advance(4 * subAuthoritys);
|
||||
dst = dst.Derive(identifierAuthorityi);
|
||||
for (int i = 0; i < identifierAuthoritys; i++)
|
||||
{
|
||||
dst.Enc_ndr_small(IdentifierAuthority[i]);
|
||||
}
|
||||
dst = dst.Derive(subAuthorityi);
|
||||
for (int i1 = 0; i1 < subAuthoritys; i1++)
|
||||
{
|
||||
dst.Enc_ndr_long(SubAuthority[i1]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
int subAuthoritys = src.Dec_ndr_long();
|
||||
Revision = unchecked((byte)src.Dec_ndr_small());
|
||||
SubAuthorityCount = unchecked((byte)src.Dec_ndr_small());
|
||||
int identifierAuthoritys = 6;
|
||||
int identifierAuthorityi = src.Index;
|
||||
src.Advance(1 * identifierAuthoritys);
|
||||
int subAuthorityi = src.Index;
|
||||
src.Advance(4 * subAuthoritys);
|
||||
if (IdentifierAuthority == null)
|
||||
{
|
||||
if (identifierAuthoritys < 0 || identifierAuthoritys > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
IdentifierAuthority = new byte[identifierAuthoritys];
|
||||
}
|
||||
src = src.Derive(identifierAuthorityi);
|
||||
for (int i = 0; i < identifierAuthoritys; i++)
|
||||
{
|
||||
IdentifierAuthority[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
if (SubAuthority == null)
|
||||
{
|
||||
if (subAuthoritys < 0 || subAuthoritys > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
SubAuthority = new int[subAuthoritys];
|
||||
}
|
||||
src = src.Derive(subAuthorityi);
|
||||
for (int i1 = 0; i1 < subAuthoritys; i1++)
|
||||
{
|
||||
SubAuthority[i1] = src.Dec_ndr_long();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception>
|
||||
public override void Decode(NdrBuffer src)
|
||||
{
|
||||
src.Align(4);
|
||||
int subAuthoritys = src.Dec_ndr_long();
|
||||
Revision = unchecked((byte)src.Dec_ndr_small());
|
||||
SubAuthorityCount = unchecked((byte)src.Dec_ndr_small());
|
||||
int identifierAuthoritys = 6;
|
||||
int identifierAuthorityi = src.Index;
|
||||
src.Advance(1 * identifierAuthoritys);
|
||||
int subAuthorityi = src.Index;
|
||||
src.Advance(4 * subAuthoritys);
|
||||
if (IdentifierAuthority == null)
|
||||
{
|
||||
if (identifierAuthoritys < 0 || identifierAuthoritys > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
IdentifierAuthority = new byte[identifierAuthoritys];
|
||||
}
|
||||
src = src.Derive(identifierAuthorityi);
|
||||
for (int i = 0; i < identifierAuthoritys; i++)
|
||||
{
|
||||
IdentifierAuthority[i] = unchecked((byte)src.Dec_ndr_small());
|
||||
}
|
||||
if (SubAuthority == null)
|
||||
{
|
||||
if (subAuthoritys < 0 || subAuthoritys > unchecked(0xFFFF))
|
||||
{
|
||||
throw new NdrException(NdrException.InvalidConformance);
|
||||
}
|
||||
SubAuthority = new int[subAuthoritys];
|
||||
}
|
||||
src = src.Derive(subAuthorityi);
|
||||
for (int i1 = 0; i1 < subAuthoritys; i1++)
|
||||
{
|
||||
SubAuthority[i1] = src.Dec_ndr_long();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,141 +18,131 @@ using System;
|
||||
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public class Uuid : Rpc.UuidT
|
||||
{
|
||||
public static int Hex_to_bin(char[] arr, int offset, int length)
|
||||
{
|
||||
int value = 0;
|
||||
int ai;
|
||||
int count;
|
||||
count = 0;
|
||||
for (ai = offset; ai < arr.Length && count < length; ai++)
|
||||
{
|
||||
value <<= 4;
|
||||
switch (arr[ai])
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
{
|
||||
value += arr[ai] - '0';
|
||||
break;
|
||||
}
|
||||
public class Uuid : Rpc.UuidT
|
||||
{
|
||||
public static int Hex_to_bin(char[] arr, int offset, int length)
|
||||
{
|
||||
int value = 0;
|
||||
int ai;
|
||||
int count;
|
||||
count = 0;
|
||||
for (ai = offset; ai < arr.Length && count < length; ai++)
|
||||
{
|
||||
value <<= 4;
|
||||
switch (arr[ai])
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
{
|
||||
value += arr[ai] - '0';
|
||||
break;
|
||||
}
|
||||
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
{
|
||||
value += 10 + (arr[ai] - 'A');
|
||||
break;
|
||||
}
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
{
|
||||
value += 10 + (arr[ai] - 'A');
|
||||
break;
|
||||
}
|
||||
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
{
|
||||
value += 10 + (arr[ai] - 'a');
|
||||
break;
|
||||
}
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
{
|
||||
value += 10 + (arr[ai] - 'a');
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
throw new ArgumentException(new string(arr, offset, length));
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new ArgumentException(new string(arr, offset, length));
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
internal static readonly char[] Hexchars =
|
||||
{
|
||||
'0', '1', '2', '3', '4',
|
||||
'5', '6', '7', '8', '9',
|
||||
'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
internal static readonly char[] Hexchars = { '0', '1', '2', '3', '4',
|
||||
'5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||
|
||||
public static string Bin_to_hex(int value, int length)
|
||||
{
|
||||
char[] arr = new char[length];
|
||||
int ai = arr.Length;
|
||||
while (ai-- > 0)
|
||||
{
|
||||
arr[ai] = Hexchars[value & unchecked(0xF)];
|
||||
value = (int)(((uint)value) >> 4);
|
||||
}
|
||||
return new string(arr);
|
||||
}
|
||||
public static string Bin_to_hex(int value, int length)
|
||||
{
|
||||
char[] arr = new char[length];
|
||||
int ai = arr.Length;
|
||||
while (ai-- > 0)
|
||||
{
|
||||
arr[ai] = Hexchars[value & unchecked(0xF)];
|
||||
value = (int)(((uint)value) >> 4);
|
||||
}
|
||||
return new string(arr);
|
||||
}
|
||||
|
||||
private static byte B(int i)
|
||||
{
|
||||
return unchecked((byte)(i & unchecked(0xFF)));
|
||||
}
|
||||
private static byte B(int i)
|
||||
{
|
||||
return unchecked((byte)(i & unchecked(0xFF)));
|
||||
}
|
||||
|
||||
private static short S(int i)
|
||||
{
|
||||
return (short)(i & unchecked(0xFFFF));
|
||||
}
|
||||
private static short S(int i)
|
||||
{
|
||||
return (short)(i & unchecked(0xFFFF));
|
||||
}
|
||||
|
||||
public Uuid(Rpc.UuidT uuid)
|
||||
{
|
||||
TimeLow = uuid.TimeLow;
|
||||
TimeMid = uuid.TimeMid;
|
||||
TimeHiAndVersion = uuid.TimeHiAndVersion;
|
||||
ClockSeqHiAndReserved = uuid.ClockSeqHiAndReserved;
|
||||
ClockSeqLow = uuid.ClockSeqLow;
|
||||
Node = new byte[6];
|
||||
Node[0] = uuid.Node[0];
|
||||
Node[1] = uuid.Node[1];
|
||||
Node[2] = uuid.Node[2];
|
||||
Node[3] = uuid.Node[3];
|
||||
Node[4] = uuid.Node[4];
|
||||
Node[5] = uuid.Node[5];
|
||||
}
|
||||
public Uuid(Rpc.UuidT uuid)
|
||||
{
|
||||
TimeLow = uuid.TimeLow;
|
||||
TimeMid = uuid.TimeMid;
|
||||
TimeHiAndVersion = uuid.TimeHiAndVersion;
|
||||
ClockSeqHiAndReserved = uuid.ClockSeqHiAndReserved;
|
||||
ClockSeqLow = uuid.ClockSeqLow;
|
||||
Node = new byte[6];
|
||||
Node[0] = uuid.Node[0];
|
||||
Node[1] = uuid.Node[1];
|
||||
Node[2] = uuid.Node[2];
|
||||
Node[3] = uuid.Node[3];
|
||||
Node[4] = uuid.Node[4];
|
||||
Node[5] = uuid.Node[5];
|
||||
}
|
||||
|
||||
public Uuid(string str)
|
||||
{
|
||||
char[] arr = str.ToCharArray();
|
||||
TimeLow = Hex_to_bin(arr, 0, 8);
|
||||
TimeMid = S(Hex_to_bin(arr, 9, 4));
|
||||
TimeHiAndVersion = S(Hex_to_bin(arr, 14, 4));
|
||||
ClockSeqHiAndReserved = B(Hex_to_bin(arr, 19, 2));
|
||||
ClockSeqLow = B(Hex_to_bin(arr, 21, 2));
|
||||
Node = new byte[6];
|
||||
Node[0] = B(Hex_to_bin(arr, 24, 2));
|
||||
Node[1] = B(Hex_to_bin(arr, 26, 2));
|
||||
Node[2] = B(Hex_to_bin(arr, 28, 2));
|
||||
Node[3] = B(Hex_to_bin(arr, 30, 2));
|
||||
Node[4] = B(Hex_to_bin(arr, 32, 2));
|
||||
Node[5] = B(Hex_to_bin(arr, 34, 2));
|
||||
}
|
||||
public Uuid(string str)
|
||||
{
|
||||
char[] arr = str.ToCharArray();
|
||||
TimeLow = Hex_to_bin(arr, 0, 8);
|
||||
TimeMid = S(Hex_to_bin(arr, 9, 4));
|
||||
TimeHiAndVersion = S(Hex_to_bin(arr, 14, 4));
|
||||
ClockSeqHiAndReserved = B(Hex_to_bin(arr, 19, 2));
|
||||
ClockSeqLow = B(Hex_to_bin(arr, 21, 2));
|
||||
Node = new byte[6];
|
||||
Node[0] = B(Hex_to_bin(arr, 24, 2));
|
||||
Node[1] = B(Hex_to_bin(arr, 26, 2));
|
||||
Node[2] = B(Hex_to_bin(arr, 28, 2));
|
||||
Node[3] = B(Hex_to_bin(arr, 30, 2));
|
||||
Node[4] = B(Hex_to_bin(arr, 32, 2));
|
||||
Node[5] = B(Hex_to_bin(arr, 34, 2));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Bin_to_hex(TimeLow, 8)
|
||||
+ '-' + Bin_to_hex(TimeMid, 4)
|
||||
+ '-' + Bin_to_hex(TimeHiAndVersion, 4)
|
||||
+ '-' + Bin_to_hex(ClockSeqHiAndReserved, 2)
|
||||
+ Bin_to_hex(ClockSeqLow, 2)
|
||||
+ '-' + Bin_to_hex(Node[0], 2)
|
||||
+ Bin_to_hex(Node[1], 2)
|
||||
+ Bin_to_hex(Node[2], 2)
|
||||
+ Bin_to_hex(Node[3], 2)
|
||||
+ Bin_to_hex(Node[4], 2)
|
||||
+ Bin_to_hex(Node[5], 2);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return Bin_to_hex(TimeLow, 8) + '-' + Bin_to_hex(TimeMid, 4) + '-' + Bin_to_hex
|
||||
(TimeHiAndVersion, 4) + '-' + Bin_to_hex(ClockSeqHiAndReserved, 2) + Bin_to_hex
|
||||
(ClockSeqLow, 2) + '-' + Bin_to_hex(Node[0], 2) + Bin_to_hex(Node[1], 2) + Bin_to_hex
|
||||
(Node[2], 2) + Bin_to_hex(Node[3], 2) + Bin_to_hex(Node[4], 2) + Bin_to_hex(Node
|
||||
[5], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,50 +16,50 @@
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
namespace SharpCifs.Dcerpc
|
||||
{
|
||||
public class UnicodeString : Rpc.Unicode_string
|
||||
{
|
||||
internal bool Zterm;
|
||||
public class UnicodeString : Rpc.Unicode_string
|
||||
{
|
||||
internal bool Zterm;
|
||||
|
||||
public UnicodeString(bool zterm)
|
||||
{
|
||||
this.Zterm = zterm;
|
||||
}
|
||||
public UnicodeString(bool zterm)
|
||||
{
|
||||
this.Zterm = zterm;
|
||||
}
|
||||
|
||||
public UnicodeString(Rpc.Unicode_string rus, bool zterm)
|
||||
{
|
||||
Length = rus.Length;
|
||||
MaximumLength = rus.MaximumLength;
|
||||
Buffer = rus.Buffer;
|
||||
this.Zterm = zterm;
|
||||
}
|
||||
public UnicodeString(Rpc.Unicode_string rus, bool zterm)
|
||||
{
|
||||
Length = rus.Length;
|
||||
MaximumLength = rus.MaximumLength;
|
||||
Buffer = rus.Buffer;
|
||||
this.Zterm = zterm;
|
||||
}
|
||||
|
||||
public UnicodeString(string str, bool zterm)
|
||||
{
|
||||
this.Zterm = zterm;
|
||||
int len = str.Length;
|
||||
int zt = zterm ? 1 : 0;
|
||||
Length = MaximumLength = (short)((len + zt) * 2);
|
||||
Buffer = new short[len + zt];
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
Buffer[i] = (short)str[i];
|
||||
}
|
||||
if (zterm)
|
||||
{
|
||||
Buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
public UnicodeString(string str, bool zterm)
|
||||
{
|
||||
this.Zterm = zterm;
|
||||
int len = str.Length;
|
||||
int zt = zterm ? 1 : 0;
|
||||
Length = MaximumLength = (short)((len + zt) * 2);
|
||||
Buffer = new short[len + zt];
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
Buffer[i] = (short)str[i];
|
||||
}
|
||||
if (zterm)
|
||||
{
|
||||
Buffer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
int len = Length / 2 - (Zterm ? 1 : 0);
|
||||
char[] ca = new char[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
ca[i] = (char)Buffer[i];
|
||||
}
|
||||
return new string(ca, 0, len);
|
||||
}
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
int len = Length / 2 - (Zterm ? 1 : 0);
|
||||
char[] ca = new char[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
ca[i] = (char)Buffer[i];
|
||||
}
|
||||
return new string(ca, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user