diff --git a/Emby.Common.Implementations/Emby.Common.Implementations.csproj b/Emby.Common.Implementations/Emby.Common.Implementations.csproj
index 5b1defccb..00c90d16e 100644
--- a/Emby.Common.Implementations/Emby.Common.Implementations.csproj
+++ b/Emby.Common.Implementations/Emby.Common.Implementations.csproj
@@ -228,7 +228,6 @@
-
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs
index 60fcc44d4..1d8d13c08 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs
@@ -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;
+ }
- ///
- 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);
+ ///
+ 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);
+ }
- ///
- 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);
- }
- }
+ ///
+ 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);
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs
index e5aef2cdc..234150664 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs
@@ -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;
+ }
- ///
- 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 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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs
index 5a7409f7c..5b69c5c2e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs
@@ -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);
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs
index f0c94bff7..55c061065 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs
@@ -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" };
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs
index 09ee17551..13c4f0d0c 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs
@@ -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();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs
index 1448f2e2e..786b0ac12 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs
@@ -22,312 +22,311 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Dcerpc
{
- public abstract class DcerpcHandle
- {
- ///
- 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
+ {
+ ///
+ 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;
- ///
- ///
- ///
- 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);
- }
+ ///
+ ///
+ ///
+ 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);
+ }
- ///
- ///
- public virtual void Bind()
- {
- lock (this)
- {
- try
- {
- State = 1;
- DcerpcMessage bind = new DcerpcBind(Binding, this);
- Sendrecv(bind);
- }
- catch (IOException ioe)
- {
- State = 0;
- throw;
- }
- }
- }
+ ///
+ ///
+ public virtual void Bind()
+ {
+ lock (this)
+ {
+ try
+ {
+ State = 1;
+ DcerpcMessage bind = new DcerpcBind(Binding, this);
+ Sendrecv(bind);
+ }
+ catch (IOException ioe)
+ {
+ State = 0;
+ throw;
+ }
+ }
+ }
- ///
- ///
- 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);
+ ///
+ ///
+ 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();
+ }
- ///
- protected internal abstract void DoSendFragment(byte[] buf, int off, int length, bool isDirect);
+ ///
+ protected internal abstract void DoSendFragment(byte[] buf, int off, int length,
+ bool isDirect);
- ///
- protected internal abstract void DoReceiveFragment(byte[] buf, bool isDirect);
+ ///
+ protected internal abstract void DoReceiveFragment(byte[] buf, bool isDirect);
- ///
- public abstract void Close();
+ ///
+ public abstract void Close();
- public DcerpcHandle()
- {
- MaxRecv = MaxXmit;
- }
- }
+ public DcerpcHandle()
+ {
+ MaxRecv = MaxXmit;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs
index a4ba1f957..543dd72dd 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs
@@ -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);
+ }
- ///
- 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();
- }
+ ///
+ 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();
+ }
- ///
- 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);
- }
+ ///
+ 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);
+ }
- ///
- 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 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();
- ///
- public abstract void Encode_in(NdrBuffer dst);
+ ///
+ public abstract void Encode_in(NdrBuffer dst);
- ///
- public abstract void Decode_out(NdrBuffer src);
- }
+ ///
+ public abstract void Decode_out(NdrBuffer src);
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs
index 583097d2a..0399578cd 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs
@@ -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;
- ///
- ///
- ///
- 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);
- }
+ ///
+ ///
+ ///
+ 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);
+ }
- ///
- 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);
- }
+ ///
+ 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);
+ }
- ///
- 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
+ ///
+ 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);
+ }
+ }
- ///
- public override void Close()
- {
- State = 0;
- if (Out != null)
- {
- Out.Close();
- }
- }
- }
+ ///
+ public override void Close()
+ {
+ State = 0;
+ if (Out != null)
+ {
+ Out.Close();
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs
index 2deadaa2c..cc46902f1 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs
@@ -18,12 +18,12 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc
{
- public interface IDcerpcSecurityProvider
- {
- ///
- void Wrap(NdrBuffer outgoing);
+ public interface IDcerpcSecurityProvider
+ {
+ ///
+ void Wrap(NdrBuffer outgoing);
- ///
- void Unwrap(NdrBuffer incoming);
- }
+ ///
+ void Unwrap(NdrBuffer incoming);
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs
index a95753749..03964fcc7 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs
@@ -18,26 +18,26 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class LsaPolicyHandle : Rpc.PolicyHandle
- {
- ///
- 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
+ {
+ ///
+ 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 virtual void Close()
- {
- }
- }
+ ///
+ public virtual void Close()
+ {
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs
index ead8de163..ef09bb16e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs
@@ -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];
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs
index 4a5623433..1ae85c473 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs
@@ -18,1144 +18,1144 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class Lsarpc
- {
- public static string GetSyntax()
- {
- return "12345778-1234-abcd-ef00-0123456789ab:0.0";
- }
-
- public class LsarQosInfo : NdrObject
- {
- public int Length;
-
- public short ImpersonationLevel;
-
- public byte ContextMode;
-
- public byte EffectiveOnly;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Length);
- dst.Enc_ndr_short(ImpersonationLevel);
- dst.Enc_ndr_small(ContextMode);
- dst.Enc_ndr_small(EffectiveOnly);
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Length = src.Dec_ndr_long();
- ImpersonationLevel = (short)src.Dec_ndr_short();
- ContextMode = unchecked((byte)src.Dec_ndr_small());
- EffectiveOnly = unchecked((byte)src.Dec_ndr_small());
- }
- }
-
- public class LsarObjectAttributes : NdrObject
- {
- public int Length;
-
- public NdrSmall RootDirectory;
-
- public Rpc.Unicode_string ObjectName;
-
- public int Attributes;
-
- public int SecurityDescriptor;
-
- public LsarQosInfo SecurityQualityOfService;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Length);
- dst.Enc_ndr_referent(RootDirectory, 1);
- dst.Enc_ndr_referent(ObjectName, 1);
- dst.Enc_ndr_long(Attributes);
- dst.Enc_ndr_long(SecurityDescriptor);
- dst.Enc_ndr_referent(SecurityQualityOfService, 1);
- if (RootDirectory != null)
- {
- dst = dst.Deferred;
- RootDirectory.Encode(dst);
- }
- if (ObjectName != null)
- {
- dst = dst.Deferred;
- ObjectName.Encode(dst);
- }
- if (SecurityQualityOfService != null)
- {
- dst = dst.Deferred;
- SecurityQualityOfService.Encode(dst);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Length = src.Dec_ndr_long();
- int rootDirectoryp = src.Dec_ndr_long();
- int objectNamep = src.Dec_ndr_long();
- Attributes = src.Dec_ndr_long();
- SecurityDescriptor = src.Dec_ndr_long();
- int securityQualityOfServicep = src.Dec_ndr_long();
- if (rootDirectoryp != 0)
- {
- src = src.Deferred;
- RootDirectory.Decode(src);
- }
- if (objectNamep != 0)
- {
- if (ObjectName == null)
- {
- ObjectName = new Rpc.Unicode_string();
- }
- src = src.Deferred;
- ObjectName.Decode(src);
- }
- if (securityQualityOfServicep != 0)
- {
- if (SecurityQualityOfService == null)
- {
- SecurityQualityOfService = new LsarQosInfo();
- }
- src = src.Deferred;
- SecurityQualityOfService.Decode(src);
- }
- }
- }
-
- public class LsarDomainInfo : NdrObject
- {
- public Rpc.Unicode_string Name;
-
- public Rpc.SidT Sid;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_short(Name.Length);
- dst.Enc_ndr_short(Name.MaximumLength);
- dst.Enc_ndr_referent(Name.Buffer, 1);
- dst.Enc_ndr_referent(Sid, 1);
- if (Name.Buffer != null)
- {
- dst = dst.Deferred;
- int nameBufferl = Name.Length / 2;
- int nameBuffers = Name.MaximumLength / 2;
- dst.Enc_ndr_long(nameBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(nameBufferl);
- int nameBufferi = dst.Index;
- dst.Advance(2 * nameBufferl);
- dst = dst.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- dst.Enc_ndr_short(Name.Buffer[i]);
- }
- }
- if (Sid != null)
- {
- dst = dst.Deferred;
- Sid.Encode(dst);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- src.Align(4);
- if (Name == null)
- {
- Name = new Rpc.Unicode_string();
- }
- Name.Length = (short)src.Dec_ndr_short();
- Name.MaximumLength = (short)src.Dec_ndr_short();
- int nameBufferp = src.Dec_ndr_long();
- int sidp = src.Dec_ndr_long();
- if (nameBufferp != 0)
- {
- src = src.Deferred;
- int nameBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int nameBufferl = src.Dec_ndr_long();
- int nameBufferi = src.Index;
- src.Advance(2 * nameBufferl);
- if (Name.Buffer == null)
- {
- if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Name.Buffer = new short[nameBuffers];
- }
- src = src.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- Name.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- if (sidp != 0)
- {
- if (Sid == null)
- {
- Sid = new Rpc.SidT();
- }
- src = src.Deferred;
- Sid.Decode(src);
- }
- }
- }
-
- public class LsarDnsDomainInfo : NdrObject
- {
- public Rpc.Unicode_string Name;
-
- public Rpc.Unicode_string DnsDomain;
-
- public Rpc.Unicode_string DnsForest;
-
- public Rpc.UuidT DomainGuid;
-
- public Rpc.SidT Sid;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_short(Name.Length);
- dst.Enc_ndr_short(Name.MaximumLength);
- dst.Enc_ndr_referent(Name.Buffer, 1);
- dst.Enc_ndr_short(DnsDomain.Length);
- dst.Enc_ndr_short(DnsDomain.MaximumLength);
- dst.Enc_ndr_referent(DnsDomain.Buffer, 1);
- dst.Enc_ndr_short(DnsForest.Length);
- dst.Enc_ndr_short(DnsForest.MaximumLength);
- dst.Enc_ndr_referent(DnsForest.Buffer, 1);
- dst.Enc_ndr_long(DomainGuid.TimeLow);
- dst.Enc_ndr_short(DomainGuid.TimeMid);
- dst.Enc_ndr_short(DomainGuid.TimeHiAndVersion);
- dst.Enc_ndr_small(DomainGuid.ClockSeqHiAndReserved);
- dst.Enc_ndr_small(DomainGuid.ClockSeqLow);
- int domainGuidNodes = 6;
- int domainGuidNodei = dst.Index;
- dst.Advance(1 * domainGuidNodes);
- dst.Enc_ndr_referent(Sid, 1);
- if (Name.Buffer != null)
- {
- dst = dst.Deferred;
- int nameBufferl = Name.Length / 2;
- int nameBuffers = Name.MaximumLength / 2;
- dst.Enc_ndr_long(nameBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(nameBufferl);
- int nameBufferi = dst.Index;
- dst.Advance(2 * nameBufferl);
- dst = dst.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- dst.Enc_ndr_short(Name.Buffer[i]);
- }
- }
- if (DnsDomain.Buffer != null)
- {
- dst = dst.Deferred;
- int dnsDomainBufferl = DnsDomain.Length / 2;
- int dnsDomainBuffers = DnsDomain.MaximumLength / 2;
- dst.Enc_ndr_long(dnsDomainBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(dnsDomainBufferl);
- int dnsDomainBufferi = dst.Index;
- dst.Advance(2 * dnsDomainBufferl);
- dst = dst.Derive(dnsDomainBufferi);
- for (int i = 0; i < dnsDomainBufferl; i++)
- {
- dst.Enc_ndr_short(DnsDomain.Buffer[i]);
- }
- }
- if (DnsForest.Buffer != null)
- {
- dst = dst.Deferred;
- int dnsForestBufferl = DnsForest.Length / 2;
- int dnsForestBuffers = DnsForest.MaximumLength / 2;
- dst.Enc_ndr_long(dnsForestBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(dnsForestBufferl);
- int dnsForestBufferi = dst.Index;
- dst.Advance(2 * dnsForestBufferl);
- dst = dst.Derive(dnsForestBufferi);
- for (int i = 0; i < dnsForestBufferl; i++)
- {
- dst.Enc_ndr_short(DnsForest.Buffer[i]);
- }
- }
- dst = dst.Derive(domainGuidNodei);
- for (int i1 = 0; i1 < domainGuidNodes; i1++)
- {
- dst.Enc_ndr_small(DomainGuid.Node[i1]);
- }
- if (Sid != null)
- {
- dst = dst.Deferred;
- Sid.Encode(dst);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- src.Align(4);
- if (Name == null)
- {
- Name = new Rpc.Unicode_string();
- }
- Name.Length = (short)src.Dec_ndr_short();
- Name.MaximumLength = (short)src.Dec_ndr_short();
- int nameBufferp = src.Dec_ndr_long();
- src.Align(4);
- if (DnsDomain == null)
- {
- DnsDomain = new Rpc.Unicode_string();
- }
- DnsDomain.Length = (short)src.Dec_ndr_short();
- DnsDomain.MaximumLength = (short)src.Dec_ndr_short();
- int dnsDomainBufferp = src.Dec_ndr_long();
- src.Align(4);
- if (DnsForest == null)
- {
- DnsForest = new Rpc.Unicode_string();
- }
- DnsForest.Length = (short)src.Dec_ndr_short();
- DnsForest.MaximumLength = (short)src.Dec_ndr_short();
- int dnsForestBufferp = src.Dec_ndr_long();
- src.Align(4);
- if (DomainGuid == null)
- {
- DomainGuid = new Rpc.UuidT();
- }
- DomainGuid.TimeLow = src.Dec_ndr_long();
- DomainGuid.TimeMid = (short)src.Dec_ndr_short();
- DomainGuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
- DomainGuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
- DomainGuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
- int domainGuidNodes = 6;
- int domainGuidNodei = src.Index;
- src.Advance(1 * domainGuidNodes);
- int sidp = src.Dec_ndr_long();
- if (nameBufferp != 0)
- {
- src = src.Deferred;
- int nameBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int nameBufferl = src.Dec_ndr_long();
- int nameBufferi = src.Index;
- src.Advance(2 * nameBufferl);
- if (Name.Buffer == null)
- {
- if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Name.Buffer = new short[nameBuffers];
- }
- src = src.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- Name.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- if (dnsDomainBufferp != 0)
- {
- src = src.Deferred;
- int dnsDomainBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int dnsDomainBufferl = src.Dec_ndr_long();
- int dnsDomainBufferi = src.Index;
- src.Advance(2 * dnsDomainBufferl);
- if (DnsDomain.Buffer == null)
- {
- if (dnsDomainBuffers < 0 || dnsDomainBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- DnsDomain.Buffer = new short[dnsDomainBuffers];
- }
- src = src.Derive(dnsDomainBufferi);
- for (int i = 0; i < dnsDomainBufferl; i++)
- {
- DnsDomain.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- if (dnsForestBufferp != 0)
- {
- src = src.Deferred;
- int dnsForestBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int dnsForestBufferl = src.Dec_ndr_long();
- int dnsForestBufferi = src.Index;
- src.Advance(2 * dnsForestBufferl);
- if (DnsForest.Buffer == null)
- {
- if (dnsForestBuffers < 0 || dnsForestBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- DnsForest.Buffer = new short[dnsForestBuffers];
- }
- src = src.Derive(dnsForestBufferi);
- for (int i = 0; i < dnsForestBufferl; i++)
- {
- DnsForest.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- if (DomainGuid.Node == null)
- {
- if (domainGuidNodes < 0 || domainGuidNodes > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- DomainGuid.Node = new byte[domainGuidNodes];
- }
- src = src.Derive(domainGuidNodei);
- for (int i1 = 0; i1 < domainGuidNodes; i1++)
- {
- DomainGuid.Node[i1] = unchecked((byte)src.Dec_ndr_small());
- }
- if (sidp != 0)
- {
- if (Sid == null)
- {
- Sid = new Rpc.SidT();
- }
- src = src.Deferred;
- Sid.Decode(src);
- }
- }
- }
-
- public const int PolicyInfoAuditEvents = 2;
-
- public const int PolicyInfoPrimaryDomain = 3;
-
- public const int PolicyInfoAccountDomain = 5;
-
- public const int PolicyInfoServerRole = 6;
-
- public const int PolicyInfoModification = 9;
-
- public const int PolicyInfoDnsDomain = 12;
-
- public class LsarSidPtr : NdrObject
- {
- public Rpc.SidT Sid;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(Sid, 1);
- if (Sid != null)
- {
- dst = dst.Deferred;
- Sid.Encode(dst);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int sidp = src.Dec_ndr_long();
- if (sidp != 0)
- {
- if (Sid == null)
- {
- Sid = new Rpc.SidT();
- }
- src = src.Deferred;
- Sid.Decode(src);
- }
- }
- }
-
- public class LsarSidArray : NdrObject
- {
- public int NumSids;
-
- public LsarSidPtr[] Sids;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(NumSids);
- dst.Enc_ndr_referent(Sids, 1);
- if (Sids != null)
- {
- dst = dst.Deferred;
- int sidss = NumSids;
- dst.Enc_ndr_long(sidss);
- int sidsi = dst.Index;
- dst.Advance(4 * sidss);
- dst = dst.Derive(sidsi);
- for (int i = 0; i < sidss; i++)
- {
- Sids[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- NumSids = src.Dec_ndr_long();
- int sidsp = src.Dec_ndr_long();
- if (sidsp != 0)
- {
- src = src.Deferred;
- int sidss = src.Dec_ndr_long();
- int sidsi = src.Index;
- src.Advance(4 * sidss);
- if (Sids == null)
- {
- if (sidss < 0 || sidss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Sids = new LsarSidPtr[sidss];
- }
- src = src.Derive(sidsi);
- for (int i = 0; i < sidss; i++)
- {
- if (Sids[i] == null)
- {
- Sids[i] = new LsarSidPtr();
- }
- Sids[i].Decode(src);
- }
- }
- }
- }
-
- public const int SidNameUseNone = 0;
-
- public const int SidNameUser = 1;
-
- public const int SidNameDomGrp = 2;
-
- public const int SidNameDomain = 3;
-
- public const int SidNameAlias = 4;
-
- public const int SidNameWknGrp = 5;
-
- public const int SidNameDeleted = 6;
-
- public const int SidNameInvalid = 7;
-
- public const int SidNameUnknown = 8;
-
- public class LsarTranslatedSid : NdrObject
- {
- public int SidType;
-
- public int Rid;
-
- public int SidIndex;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_short(SidType);
- dst.Enc_ndr_long(Rid);
- dst.Enc_ndr_long(SidIndex);
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- SidType = src.Dec_ndr_short();
- Rid = src.Dec_ndr_long();
- SidIndex = src.Dec_ndr_long();
- }
- }
-
- public class LsarTransSidArray : NdrObject
- {
- public int Count;
-
- public LsarTranslatedSid[] Sids;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Sids, 1);
- if (Sids != null)
- {
- dst = dst.Deferred;
- int sidss = Count;
- dst.Enc_ndr_long(sidss);
- int sidsi = dst.Index;
- dst.Advance(12 * sidss);
- dst = dst.Derive(sidsi);
- for (int i = 0; i < sidss; i++)
- {
- Sids[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int sidsp = src.Dec_ndr_long();
- if (sidsp != 0)
- {
- src = src.Deferred;
- int sidss = src.Dec_ndr_long();
- int sidsi = src.Index;
- src.Advance(12 * sidss);
- if (Sids == null)
- {
- if (sidss < 0 || sidss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Sids = new LsarTranslatedSid[sidss];
- }
- src = src.Derive(sidsi);
- for (int i = 0; i < sidss; i++)
- {
- if (Sids[i] == null)
- {
- Sids[i] = new LsarTranslatedSid();
- }
- Sids[i].Decode(src);
- }
- }
- }
- }
-
- public class LsarTrustInformation : NdrObject
- {
- public Rpc.Unicode_string Name;
-
- public Rpc.SidT Sid;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_short(Name.Length);
- dst.Enc_ndr_short(Name.MaximumLength);
- dst.Enc_ndr_referent(Name.Buffer, 1);
- dst.Enc_ndr_referent(Sid, 1);
- if (Name.Buffer != null)
- {
- dst = dst.Deferred;
- int nameBufferl = Name.Length / 2;
- int nameBuffers = Name.MaximumLength / 2;
- dst.Enc_ndr_long(nameBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(nameBufferl);
- int nameBufferi = dst.Index;
- dst.Advance(2 * nameBufferl);
- dst = dst.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- dst.Enc_ndr_short(Name.Buffer[i]);
- }
- }
- if (Sid != null)
- {
- dst = dst.Deferred;
- Sid.Encode(dst);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- src.Align(4);
- if (Name == null)
- {
- Name = new Rpc.Unicode_string();
- }
- Name.Length = (short)src.Dec_ndr_short();
- Name.MaximumLength = (short)src.Dec_ndr_short();
- int nameBufferp = src.Dec_ndr_long();
- int sidp = src.Dec_ndr_long();
- if (nameBufferp != 0)
- {
- src = src.Deferred;
- int nameBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int nameBufferl = src.Dec_ndr_long();
- int nameBufferi = src.Index;
- src.Advance(2 * nameBufferl);
- if (Name.Buffer == null)
- {
- if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Name.Buffer = new short[nameBuffers];
- }
- src = src.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- Name.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- if (sidp != 0)
- {
- if (Sid == null)
- {
- Sid = new Rpc.SidT();
- }
- src = src.Deferred;
- Sid.Decode(src);
- }
- }
- }
-
- public class LsarRefDomainList : NdrObject
- {
- public int Count;
-
- public LsarTrustInformation[] Domains;
-
- public int MaxCount;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Domains, 1);
- dst.Enc_ndr_long(MaxCount);
- if (Domains != null)
- {
- dst = dst.Deferred;
- int domainss = Count;
- dst.Enc_ndr_long(domainss);
- int domainsi = dst.Index;
- dst.Advance(12 * domainss);
- dst = dst.Derive(domainsi);
- for (int i = 0; i < domainss; i++)
- {
- Domains[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int domainsp = src.Dec_ndr_long();
- MaxCount = src.Dec_ndr_long();
- if (domainsp != 0)
- {
- src = src.Deferred;
- int domainss = src.Dec_ndr_long();
- int domainsi = src.Index;
- src.Advance(12 * domainss);
- if (Domains == null)
- {
- if (domainss < 0 || domainss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Domains = new LsarTrustInformation[domainss];
- }
- src = src.Derive(domainsi);
- for (int i = 0; i < domainss; i++)
- {
- if (Domains[i] == null)
- {
- Domains[i] = new LsarTrustInformation();
- }
- Domains[i].Decode(src);
- }
- }
- }
- }
-
- public class LsarTranslatedName : NdrObject
- {
- public short SidType;
-
- public Rpc.Unicode_string Name;
-
- public int SidIndex;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_short(SidType);
- dst.Enc_ndr_short(Name.Length);
- dst.Enc_ndr_short(Name.MaximumLength);
- dst.Enc_ndr_referent(Name.Buffer, 1);
- dst.Enc_ndr_long(SidIndex);
- if (Name.Buffer != null)
- {
- dst = dst.Deferred;
- int nameBufferl = Name.Length / 2;
- int nameBuffers = Name.MaximumLength / 2;
- dst.Enc_ndr_long(nameBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(nameBufferl);
- int nameBufferi = dst.Index;
- dst.Advance(2 * nameBufferl);
- dst = dst.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- dst.Enc_ndr_short(Name.Buffer[i]);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- SidType = (short)src.Dec_ndr_short();
- src.Align(4);
- if (Name == null)
- {
- Name = new Rpc.Unicode_string();
- }
- Name.Length = (short)src.Dec_ndr_short();
- Name.MaximumLength = (short)src.Dec_ndr_short();
- int nameBufferp = src.Dec_ndr_long();
- SidIndex = src.Dec_ndr_long();
- if (nameBufferp != 0)
- {
- src = src.Deferred;
- int nameBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int nameBufferl = src.Dec_ndr_long();
- int nameBufferi = src.Index;
- src.Advance(2 * nameBufferl);
- if (Name.Buffer == null)
- {
- if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Name.Buffer = new short[nameBuffers];
- }
- src = src.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- Name.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- }
- }
-
- public class LsarTransNameArray : NdrObject
- {
- public int Count;
-
- public LsarTranslatedName[] Names;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Names, 1);
- if (Names != null)
- {
- dst = dst.Deferred;
- int namess = Count;
- dst.Enc_ndr_long(namess);
- int namesi = dst.Index;
- dst.Advance(16 * namess);
- dst = dst.Derive(namesi);
- for (int i = 0; i < namess; i++)
- {
- Names[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int namesp = src.Dec_ndr_long();
- if (namesp != 0)
- {
- src = src.Deferred;
- int namess = src.Dec_ndr_long();
- int namesi = src.Index;
- src.Advance(16 * namess);
- if (Names == null)
- {
- if (namess < 0 || namess > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Names = new LsarTranslatedName[namess];
- }
- src = src.Derive(namesi);
- for (int i = 0; i < namess; i++)
- {
- if (Names[i] == null)
- {
- Names[i] = new LsarTranslatedName();
- }
- Names[i].Decode(src);
- }
- }
- }
- }
-
- public class LsarClose : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x00);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle Handle;
-
- public LsarClose(Rpc.PolicyHandle handle)
- {
- this.Handle = handle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Handle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class LsarQueryInformationPolicy : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x07);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle Handle;
-
- public short Level;
-
- public NdrObject Info;
-
- public LsarQueryInformationPolicy(Rpc.PolicyHandle handle, short level, NdrObject
- info)
- {
- this.Handle = handle;
- this.Level = level;
- this.Info = info;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- dst.Enc_ndr_short(Level);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- src.Dec_ndr_short();
- Info.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class LsarLookupSids : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x0f);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle Handle;
-
- public LsarSidArray Sids;
-
- public LsarRefDomainList Domains;
-
- public LsarTransNameArray Names;
-
- public short Level;
-
- public int Count;
-
- public LsarLookupSids(Rpc.PolicyHandle handle, LsarSidArray sids, LsarRefDomainList
- domains, LsarTransNameArray names, short level, int count)
- {
- this.Handle = handle;
- this.Sids = sids;
- this.Domains = domains;
- this.Names = names;
- this.Level = level;
- this.Count = count;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- Sids.Encode(dst);
- Names.Encode(dst);
- dst.Enc_ndr_short(Level);
- dst.Enc_ndr_long(Count);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- int domainsp = src.Dec_ndr_long();
- if (domainsp != 0)
- {
- if (Domains == null)
- {
- Domains = new LsarRefDomainList();
- }
- Domains.Decode(src);
- }
- Names.Decode(src);
- Count = src.Dec_ndr_long();
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class LsarOpenPolicy2 : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x2c);
- }
-
- public int Retval;
-
- public string SystemName;
-
- public LsarObjectAttributes ObjectAttributes;
-
- public int DesiredAccess;
-
- public Rpc.PolicyHandle PolicyHandle;
-
- public LsarOpenPolicy2(string systemName, LsarObjectAttributes objectAttributes
- , int desiredAccess, Rpc.PolicyHandle policyHandle)
- {
- this.SystemName = systemName;
- this.ObjectAttributes = objectAttributes;
- this.DesiredAccess = desiredAccess;
- this.PolicyHandle = policyHandle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(SystemName, 1);
- if (SystemName != null)
- {
- dst.Enc_ndr_string(SystemName);
- }
- ObjectAttributes.Encode(dst);
- dst.Enc_ndr_long(DesiredAccess);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- PolicyHandle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class LsarQueryInformationPolicy2 : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x2e);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle Handle;
-
- public short Level;
-
- public NdrObject Info;
-
- public LsarQueryInformationPolicy2(Rpc.PolicyHandle handle, short level, NdrObject
- info)
- {
- this.Handle = handle;
- this.Level = level;
- this.Info = info;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- dst.Enc_ndr_short(Level);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- src.Dec_ndr_short();
- Info.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
- }
+ public class Lsarpc
+ {
+ public static string GetSyntax()
+ {
+ return "12345778-1234-abcd-ef00-0123456789ab:0.0";
+ }
+
+ public class LsarQosInfo : NdrObject
+ {
+ public int Length;
+
+ public short ImpersonationLevel;
+
+ public byte ContextMode;
+
+ public byte EffectiveOnly;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Length);
+ dst.Enc_ndr_short(ImpersonationLevel);
+ dst.Enc_ndr_small(ContextMode);
+ dst.Enc_ndr_small(EffectiveOnly);
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Length = src.Dec_ndr_long();
+ ImpersonationLevel = (short)src.Dec_ndr_short();
+ ContextMode = unchecked((byte)src.Dec_ndr_small());
+ EffectiveOnly = unchecked((byte)src.Dec_ndr_small());
+ }
+ }
+
+ public class LsarObjectAttributes : NdrObject
+ {
+ public int Length;
+
+ public NdrSmall RootDirectory;
+
+ public Rpc.Unicode_string ObjectName;
+
+ public int Attributes;
+
+ public int SecurityDescriptor;
+
+ public LsarQosInfo SecurityQualityOfService;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Length);
+ dst.Enc_ndr_referent(RootDirectory, 1);
+ dst.Enc_ndr_referent(ObjectName, 1);
+ dst.Enc_ndr_long(Attributes);
+ dst.Enc_ndr_long(SecurityDescriptor);
+ dst.Enc_ndr_referent(SecurityQualityOfService, 1);
+ if (RootDirectory != null)
+ {
+ dst = dst.Deferred;
+ RootDirectory.Encode(dst);
+ }
+ if (ObjectName != null)
+ {
+ dst = dst.Deferred;
+ ObjectName.Encode(dst);
+ }
+ if (SecurityQualityOfService != null)
+ {
+ dst = dst.Deferred;
+ SecurityQualityOfService.Encode(dst);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Length = src.Dec_ndr_long();
+ int rootDirectoryp = src.Dec_ndr_long();
+ int objectNamep = src.Dec_ndr_long();
+ Attributes = src.Dec_ndr_long();
+ SecurityDescriptor = src.Dec_ndr_long();
+ int securityQualityOfServicep = src.Dec_ndr_long();
+ if (rootDirectoryp != 0)
+ {
+ src = src.Deferred;
+ RootDirectory.Decode(src);
+ }
+ if (objectNamep != 0)
+ {
+ if (ObjectName == null)
+ {
+ ObjectName = new Rpc.Unicode_string();
+ }
+ src = src.Deferred;
+ ObjectName.Decode(src);
+ }
+ if (securityQualityOfServicep != 0)
+ {
+ if (SecurityQualityOfService == null)
+ {
+ SecurityQualityOfService = new LsarQosInfo();
+ }
+ src = src.Deferred;
+ SecurityQualityOfService.Decode(src);
+ }
+ }
+ }
+
+ public class LsarDomainInfo : NdrObject
+ {
+ public Rpc.Unicode_string Name;
+
+ public Rpc.SidT Sid;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_short(Name.Length);
+ dst.Enc_ndr_short(Name.MaximumLength);
+ dst.Enc_ndr_referent(Name.Buffer, 1);
+ dst.Enc_ndr_referent(Sid, 1);
+ if (Name.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int nameBufferl = Name.Length / 2;
+ int nameBuffers = Name.MaximumLength / 2;
+ dst.Enc_ndr_long(nameBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(nameBufferl);
+ int nameBufferi = dst.Index;
+ dst.Advance(2 * nameBufferl);
+ dst = dst.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ dst.Enc_ndr_short(Name.Buffer[i]);
+ }
+ }
+ if (Sid != null)
+ {
+ dst = dst.Deferred;
+ Sid.Encode(dst);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ src.Align(4);
+ if (Name == null)
+ {
+ Name = new Rpc.Unicode_string();
+ }
+ Name.Length = (short)src.Dec_ndr_short();
+ Name.MaximumLength = (short)src.Dec_ndr_short();
+ int nameBufferp = src.Dec_ndr_long();
+ int sidp = src.Dec_ndr_long();
+ if (nameBufferp != 0)
+ {
+ src = src.Deferred;
+ int nameBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int nameBufferl = src.Dec_ndr_long();
+ int nameBufferi = src.Index;
+ src.Advance(2 * nameBufferl);
+ if (Name.Buffer == null)
+ {
+ if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Name.Buffer = new short[nameBuffers];
+ }
+ src = src.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ Name.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ if (sidp != 0)
+ {
+ if (Sid == null)
+ {
+ Sid = new Rpc.SidT();
+ }
+ src = src.Deferred;
+ Sid.Decode(src);
+ }
+ }
+ }
+
+ public class LsarDnsDomainInfo : NdrObject
+ {
+ public Rpc.Unicode_string Name;
+
+ public Rpc.Unicode_string DnsDomain;
+
+ public Rpc.Unicode_string DnsForest;
+
+ public Rpc.UuidT DomainGuid;
+
+ public Rpc.SidT Sid;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_short(Name.Length);
+ dst.Enc_ndr_short(Name.MaximumLength);
+ dst.Enc_ndr_referent(Name.Buffer, 1);
+ dst.Enc_ndr_short(DnsDomain.Length);
+ dst.Enc_ndr_short(DnsDomain.MaximumLength);
+ dst.Enc_ndr_referent(DnsDomain.Buffer, 1);
+ dst.Enc_ndr_short(DnsForest.Length);
+ dst.Enc_ndr_short(DnsForest.MaximumLength);
+ dst.Enc_ndr_referent(DnsForest.Buffer, 1);
+ dst.Enc_ndr_long(DomainGuid.TimeLow);
+ dst.Enc_ndr_short(DomainGuid.TimeMid);
+ dst.Enc_ndr_short(DomainGuid.TimeHiAndVersion);
+ dst.Enc_ndr_small(DomainGuid.ClockSeqHiAndReserved);
+ dst.Enc_ndr_small(DomainGuid.ClockSeqLow);
+ int domainGuidNodes = 6;
+ int domainGuidNodei = dst.Index;
+ dst.Advance(1 * domainGuidNodes);
+ dst.Enc_ndr_referent(Sid, 1);
+ if (Name.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int nameBufferl = Name.Length / 2;
+ int nameBuffers = Name.MaximumLength / 2;
+ dst.Enc_ndr_long(nameBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(nameBufferl);
+ int nameBufferi = dst.Index;
+ dst.Advance(2 * nameBufferl);
+ dst = dst.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ dst.Enc_ndr_short(Name.Buffer[i]);
+ }
+ }
+ if (DnsDomain.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int dnsDomainBufferl = DnsDomain.Length / 2;
+ int dnsDomainBuffers = DnsDomain.MaximumLength / 2;
+ dst.Enc_ndr_long(dnsDomainBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(dnsDomainBufferl);
+ int dnsDomainBufferi = dst.Index;
+ dst.Advance(2 * dnsDomainBufferl);
+ dst = dst.Derive(dnsDomainBufferi);
+ for (int i = 0; i < dnsDomainBufferl; i++)
+ {
+ dst.Enc_ndr_short(DnsDomain.Buffer[i]);
+ }
+ }
+ if (DnsForest.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int dnsForestBufferl = DnsForest.Length / 2;
+ int dnsForestBuffers = DnsForest.MaximumLength / 2;
+ dst.Enc_ndr_long(dnsForestBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(dnsForestBufferl);
+ int dnsForestBufferi = dst.Index;
+ dst.Advance(2 * dnsForestBufferl);
+ dst = dst.Derive(dnsForestBufferi);
+ for (int i = 0; i < dnsForestBufferl; i++)
+ {
+ dst.Enc_ndr_short(DnsForest.Buffer[i]);
+ }
+ }
+ dst = dst.Derive(domainGuidNodei);
+ for (int i1 = 0; i1 < domainGuidNodes; i1++)
+ {
+ dst.Enc_ndr_small(DomainGuid.Node[i1]);
+ }
+ if (Sid != null)
+ {
+ dst = dst.Deferred;
+ Sid.Encode(dst);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ src.Align(4);
+ if (Name == null)
+ {
+ Name = new Rpc.Unicode_string();
+ }
+ Name.Length = (short)src.Dec_ndr_short();
+ Name.MaximumLength = (short)src.Dec_ndr_short();
+ int nameBufferp = src.Dec_ndr_long();
+ src.Align(4);
+ if (DnsDomain == null)
+ {
+ DnsDomain = new Rpc.Unicode_string();
+ }
+ DnsDomain.Length = (short)src.Dec_ndr_short();
+ DnsDomain.MaximumLength = (short)src.Dec_ndr_short();
+ int dnsDomainBufferp = src.Dec_ndr_long();
+ src.Align(4);
+ if (DnsForest == null)
+ {
+ DnsForest = new Rpc.Unicode_string();
+ }
+ DnsForest.Length = (short)src.Dec_ndr_short();
+ DnsForest.MaximumLength = (short)src.Dec_ndr_short();
+ int dnsForestBufferp = src.Dec_ndr_long();
+ src.Align(4);
+ if (DomainGuid == null)
+ {
+ DomainGuid = new Rpc.UuidT();
+ }
+ DomainGuid.TimeLow = src.Dec_ndr_long();
+ DomainGuid.TimeMid = (short)src.Dec_ndr_short();
+ DomainGuid.TimeHiAndVersion = (short)src.Dec_ndr_short();
+ DomainGuid.ClockSeqHiAndReserved = unchecked((byte)src.Dec_ndr_small());
+ DomainGuid.ClockSeqLow = unchecked((byte)src.Dec_ndr_small());
+ int domainGuidNodes = 6;
+ int domainGuidNodei = src.Index;
+ src.Advance(1 * domainGuidNodes);
+ int sidp = src.Dec_ndr_long();
+ if (nameBufferp != 0)
+ {
+ src = src.Deferred;
+ int nameBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int nameBufferl = src.Dec_ndr_long();
+ int nameBufferi = src.Index;
+ src.Advance(2 * nameBufferl);
+ if (Name.Buffer == null)
+ {
+ if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Name.Buffer = new short[nameBuffers];
+ }
+ src = src.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ Name.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ if (dnsDomainBufferp != 0)
+ {
+ src = src.Deferred;
+ int dnsDomainBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int dnsDomainBufferl = src.Dec_ndr_long();
+ int dnsDomainBufferi = src.Index;
+ src.Advance(2 * dnsDomainBufferl);
+ if (DnsDomain.Buffer == null)
+ {
+ if (dnsDomainBuffers < 0 || dnsDomainBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ DnsDomain.Buffer = new short[dnsDomainBuffers];
+ }
+ src = src.Derive(dnsDomainBufferi);
+ for (int i = 0; i < dnsDomainBufferl; i++)
+ {
+ DnsDomain.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ if (dnsForestBufferp != 0)
+ {
+ src = src.Deferred;
+ int dnsForestBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int dnsForestBufferl = src.Dec_ndr_long();
+ int dnsForestBufferi = src.Index;
+ src.Advance(2 * dnsForestBufferl);
+ if (DnsForest.Buffer == null)
+ {
+ if (dnsForestBuffers < 0 || dnsForestBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ DnsForest.Buffer = new short[dnsForestBuffers];
+ }
+ src = src.Derive(dnsForestBufferi);
+ for (int i = 0; i < dnsForestBufferl; i++)
+ {
+ DnsForest.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ if (DomainGuid.Node == null)
+ {
+ if (domainGuidNodes < 0 || domainGuidNodes > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ DomainGuid.Node = new byte[domainGuidNodes];
+ }
+ src = src.Derive(domainGuidNodei);
+ for (int i1 = 0; i1 < domainGuidNodes; i1++)
+ {
+ DomainGuid.Node[i1] = unchecked((byte)src.Dec_ndr_small());
+ }
+ if (sidp != 0)
+ {
+ if (Sid == null)
+ {
+ Sid = new Rpc.SidT();
+ }
+ src = src.Deferred;
+ Sid.Decode(src);
+ }
+ }
+ }
+
+ public const int PolicyInfoAuditEvents = 2;
+
+ public const int PolicyInfoPrimaryDomain = 3;
+
+ public const int PolicyInfoAccountDomain = 5;
+
+ public const int PolicyInfoServerRole = 6;
+
+ public const int PolicyInfoModification = 9;
+
+ public const int PolicyInfoDnsDomain = 12;
+
+ public class LsarSidPtr : NdrObject
+ {
+ public Rpc.SidT Sid;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(Sid, 1);
+ if (Sid != null)
+ {
+ dst = dst.Deferred;
+ Sid.Encode(dst);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int sidp = src.Dec_ndr_long();
+ if (sidp != 0)
+ {
+ if (Sid == null)
+ {
+ Sid = new Rpc.SidT();
+ }
+ src = src.Deferred;
+ Sid.Decode(src);
+ }
+ }
+ }
+
+ public class LsarSidArray : NdrObject
+ {
+ public int NumSids;
+
+ public LsarSidPtr[] Sids;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(NumSids);
+ dst.Enc_ndr_referent(Sids, 1);
+ if (Sids != null)
+ {
+ dst = dst.Deferred;
+ int sidss = NumSids;
+ dst.Enc_ndr_long(sidss);
+ int sidsi = dst.Index;
+ dst.Advance(4 * sidss);
+ dst = dst.Derive(sidsi);
+ for (int i = 0; i < sidss; i++)
+ {
+ Sids[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ NumSids = src.Dec_ndr_long();
+ int sidsp = src.Dec_ndr_long();
+ if (sidsp != 0)
+ {
+ src = src.Deferred;
+ int sidss = src.Dec_ndr_long();
+ int sidsi = src.Index;
+ src.Advance(4 * sidss);
+ if (Sids == null)
+ {
+ if (sidss < 0 || sidss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Sids = new LsarSidPtr[sidss];
+ }
+ src = src.Derive(sidsi);
+ for (int i = 0; i < sidss; i++)
+ {
+ if (Sids[i] == null)
+ {
+ Sids[i] = new LsarSidPtr();
+ }
+ Sids[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public const int SidNameUseNone = 0;
+
+ public const int SidNameUser = 1;
+
+ public const int SidNameDomGrp = 2;
+
+ public const int SidNameDomain = 3;
+
+ public const int SidNameAlias = 4;
+
+ public const int SidNameWknGrp = 5;
+
+ public const int SidNameDeleted = 6;
+
+ public const int SidNameInvalid = 7;
+
+ public const int SidNameUnknown = 8;
+
+ public class LsarTranslatedSid : NdrObject
+ {
+ public int SidType;
+
+ public int Rid;
+
+ public int SidIndex;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_short(SidType);
+ dst.Enc_ndr_long(Rid);
+ dst.Enc_ndr_long(SidIndex);
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ SidType = src.Dec_ndr_short();
+ Rid = src.Dec_ndr_long();
+ SidIndex = src.Dec_ndr_long();
+ }
+ }
+
+ public class LsarTransSidArray : NdrObject
+ {
+ public int Count;
+
+ public LsarTranslatedSid[] Sids;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Sids, 1);
+ if (Sids != null)
+ {
+ dst = dst.Deferred;
+ int sidss = Count;
+ dst.Enc_ndr_long(sidss);
+ int sidsi = dst.Index;
+ dst.Advance(12 * sidss);
+ dst = dst.Derive(sidsi);
+ for (int i = 0; i < sidss; i++)
+ {
+ Sids[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int sidsp = src.Dec_ndr_long();
+ if (sidsp != 0)
+ {
+ src = src.Deferred;
+ int sidss = src.Dec_ndr_long();
+ int sidsi = src.Index;
+ src.Advance(12 * sidss);
+ if (Sids == null)
+ {
+ if (sidss < 0 || sidss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Sids = new LsarTranslatedSid[sidss];
+ }
+ src = src.Derive(sidsi);
+ for (int i = 0; i < sidss; i++)
+ {
+ if (Sids[i] == null)
+ {
+ Sids[i] = new LsarTranslatedSid();
+ }
+ Sids[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class LsarTrustInformation : NdrObject
+ {
+ public Rpc.Unicode_string Name;
+
+ public Rpc.SidT Sid;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_short(Name.Length);
+ dst.Enc_ndr_short(Name.MaximumLength);
+ dst.Enc_ndr_referent(Name.Buffer, 1);
+ dst.Enc_ndr_referent(Sid, 1);
+ if (Name.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int nameBufferl = Name.Length / 2;
+ int nameBuffers = Name.MaximumLength / 2;
+ dst.Enc_ndr_long(nameBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(nameBufferl);
+ int nameBufferi = dst.Index;
+ dst.Advance(2 * nameBufferl);
+ dst = dst.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ dst.Enc_ndr_short(Name.Buffer[i]);
+ }
+ }
+ if (Sid != null)
+ {
+ dst = dst.Deferred;
+ Sid.Encode(dst);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ src.Align(4);
+ if (Name == null)
+ {
+ Name = new Rpc.Unicode_string();
+ }
+ Name.Length = (short)src.Dec_ndr_short();
+ Name.MaximumLength = (short)src.Dec_ndr_short();
+ int nameBufferp = src.Dec_ndr_long();
+ int sidp = src.Dec_ndr_long();
+ if (nameBufferp != 0)
+ {
+ src = src.Deferred;
+ int nameBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int nameBufferl = src.Dec_ndr_long();
+ int nameBufferi = src.Index;
+ src.Advance(2 * nameBufferl);
+ if (Name.Buffer == null)
+ {
+ if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Name.Buffer = new short[nameBuffers];
+ }
+ src = src.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ Name.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ if (sidp != 0)
+ {
+ if (Sid == null)
+ {
+ Sid = new Rpc.SidT();
+ }
+ src = src.Deferred;
+ Sid.Decode(src);
+ }
+ }
+ }
+
+ public class LsarRefDomainList : NdrObject
+ {
+ public int Count;
+
+ public LsarTrustInformation[] Domains;
+
+ public int MaxCount;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Domains, 1);
+ dst.Enc_ndr_long(MaxCount);
+ if (Domains != null)
+ {
+ dst = dst.Deferred;
+ int domainss = Count;
+ dst.Enc_ndr_long(domainss);
+ int domainsi = dst.Index;
+ dst.Advance(12 * domainss);
+ dst = dst.Derive(domainsi);
+ for (int i = 0; i < domainss; i++)
+ {
+ Domains[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int domainsp = src.Dec_ndr_long();
+ MaxCount = src.Dec_ndr_long();
+ if (domainsp != 0)
+ {
+ src = src.Deferred;
+ int domainss = src.Dec_ndr_long();
+ int domainsi = src.Index;
+ src.Advance(12 * domainss);
+ if (Domains == null)
+ {
+ if (domainss < 0 || domainss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Domains = new LsarTrustInformation[domainss];
+ }
+ src = src.Derive(domainsi);
+ for (int i = 0; i < domainss; i++)
+ {
+ if (Domains[i] == null)
+ {
+ Domains[i] = new LsarTrustInformation();
+ }
+ Domains[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class LsarTranslatedName : NdrObject
+ {
+ public short SidType;
+
+ public Rpc.Unicode_string Name;
+
+ public int SidIndex;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_short(SidType);
+ dst.Enc_ndr_short(Name.Length);
+ dst.Enc_ndr_short(Name.MaximumLength);
+ dst.Enc_ndr_referent(Name.Buffer, 1);
+ dst.Enc_ndr_long(SidIndex);
+ if (Name.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int nameBufferl = Name.Length / 2;
+ int nameBuffers = Name.MaximumLength / 2;
+ dst.Enc_ndr_long(nameBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(nameBufferl);
+ int nameBufferi = dst.Index;
+ dst.Advance(2 * nameBufferl);
+ dst = dst.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ dst.Enc_ndr_short(Name.Buffer[i]);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ SidType = (short)src.Dec_ndr_short();
+ src.Align(4);
+ if (Name == null)
+ {
+ Name = new Rpc.Unicode_string();
+ }
+ Name.Length = (short)src.Dec_ndr_short();
+ Name.MaximumLength = (short)src.Dec_ndr_short();
+ int nameBufferp = src.Dec_ndr_long();
+ SidIndex = src.Dec_ndr_long();
+ if (nameBufferp != 0)
+ {
+ src = src.Deferred;
+ int nameBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int nameBufferl = src.Dec_ndr_long();
+ int nameBufferi = src.Index;
+ src.Advance(2 * nameBufferl);
+ if (Name.Buffer == null)
+ {
+ if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Name.Buffer = new short[nameBuffers];
+ }
+ src = src.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ Name.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ }
+ }
+
+ public class LsarTransNameArray : NdrObject
+ {
+ public int Count;
+
+ public LsarTranslatedName[] Names;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Names, 1);
+ if (Names != null)
+ {
+ dst = dst.Deferred;
+ int namess = Count;
+ dst.Enc_ndr_long(namess);
+ int namesi = dst.Index;
+ dst.Advance(16 * namess);
+ dst = dst.Derive(namesi);
+ for (int i = 0; i < namess; i++)
+ {
+ Names[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int namesp = src.Dec_ndr_long();
+ if (namesp != 0)
+ {
+ src = src.Deferred;
+ int namess = src.Dec_ndr_long();
+ int namesi = src.Index;
+ src.Advance(16 * namess);
+ if (Names == null)
+ {
+ if (namess < 0 || namess > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Names = new LsarTranslatedName[namess];
+ }
+ src = src.Derive(namesi);
+ for (int i = 0; i < namess; i++)
+ {
+ if (Names[i] == null)
+ {
+ Names[i] = new LsarTranslatedName();
+ }
+ Names[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class LsarClose : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x00);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle Handle;
+
+ public LsarClose(Rpc.PolicyHandle handle)
+ {
+ this.Handle = handle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Handle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class LsarQueryInformationPolicy : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x07);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle Handle;
+
+ public short Level;
+
+ public NdrObject Info;
+
+ public LsarQueryInformationPolicy(Rpc.PolicyHandle handle, short level, NdrObject
+ info)
+ {
+ this.Handle = handle;
+ this.Level = level;
+ this.Info = info;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ dst.Enc_ndr_short(Level);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ src.Dec_ndr_short();
+ Info.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class LsarLookupSids : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x0f);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle Handle;
+
+ public LsarSidArray Sids;
+
+ public LsarRefDomainList Domains;
+
+ public LsarTransNameArray Names;
+
+ public short Level;
+
+ public int Count;
+
+ public LsarLookupSids(Rpc.PolicyHandle handle, LsarSidArray sids, LsarRefDomainList
+ domains, LsarTransNameArray names, short level, int count)
+ {
+ this.Handle = handle;
+ this.Sids = sids;
+ this.Domains = domains;
+ this.Names = names;
+ this.Level = level;
+ this.Count = count;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ Sids.Encode(dst);
+ Names.Encode(dst);
+ dst.Enc_ndr_short(Level);
+ dst.Enc_ndr_long(Count);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ int domainsp = src.Dec_ndr_long();
+ if (domainsp != 0)
+ {
+ if (Domains == null)
+ {
+ Domains = new LsarRefDomainList();
+ }
+ Domains.Decode(src);
+ }
+ Names.Decode(src);
+ Count = src.Dec_ndr_long();
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class LsarOpenPolicy2 : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x2c);
+ }
+
+ public int Retval;
+
+ public string SystemName;
+
+ public LsarObjectAttributes ObjectAttributes;
+
+ public int DesiredAccess;
+
+ public Rpc.PolicyHandle PolicyHandle;
+
+ public LsarOpenPolicy2(string systemName, LsarObjectAttributes objectAttributes
+ , int desiredAccess, Rpc.PolicyHandle policyHandle)
+ {
+ this.SystemName = systemName;
+ this.ObjectAttributes = objectAttributes;
+ this.DesiredAccess = desiredAccess;
+ this.PolicyHandle = policyHandle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(SystemName, 1);
+ if (SystemName != null)
+ {
+ dst.Enc_ndr_string(SystemName);
+ }
+ ObjectAttributes.Encode(dst);
+ dst.Enc_ndr_long(DesiredAccess);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ PolicyHandle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class LsarQueryInformationPolicy2 : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x2e);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle Handle;
+
+ public short Level;
+
+ public NdrObject Info;
+
+ public LsarQueryInformationPolicy2(Rpc.PolicyHandle handle, short level, NdrObject
+ info)
+ {
+ this.Handle = handle;
+ this.Level = level;
+ this.Info = info;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ dst.Enc_ndr_short(Level);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ src.Dec_ndr_short();
+ Info.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs
index 6b4d70e3c..6a9d4302a 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs
@@ -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;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs
index 817a69e46..d9c0afb34 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs
index 9fcfc3488..77b2ee375 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs
index 7b507b61e..0aaf31026 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs
index 379442647..9d2c2a0f4 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs
index c66c273bd..820d81ab2 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs
index 643fe3e8e..80c45257c 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs
index b45979cf1..0f2603e9c 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs
index c84ab275f..e0b9b68d3 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs
@@ -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;
- }
- }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs
index eb311a315..2ac6bceed 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs
@@ -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;
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs
index 9947acdda..7c7b64abf 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs
@@ -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;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs
index 6b41445b7..802ed61a3 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs
@@ -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;
- }
+ }
- ///
- 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;
- }
- }
+ ///
+ 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;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs
index 902f5d675..a338b2885 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs
@@ -18,599 +18,599 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class Netdfs
- {
- public static string GetSyntax()
- {
- return "4fc742e0-4a10-11cf-8273-00aa004ae673:3.0";
- }
+ public class Netdfs
+ {
+ public static string GetSyntax()
+ {
+ return "4fc742e0-4a10-11cf-8273-00aa004ae673:3.0";
+ }
- public const int DfsVolumeFlavorStandalone = unchecked(0x100);
+ public const int DfsVolumeFlavorStandalone = unchecked(0x100);
- public const int DfsVolumeFlavorAdBlob = unchecked(0x200);
+ public const int DfsVolumeFlavorAdBlob = unchecked(0x200);
- public const int DfsStorageStateOffline = unchecked(0x0001);
+ public const int DfsStorageStateOffline = unchecked(0x0001);
- public const int DfsStorageStateOnline = unchecked(0x0002);
+ public const int DfsStorageStateOnline = unchecked(0x0002);
- public const int DfsStorageStateActive = unchecked(0x0004);
+ public const int DfsStorageStateActive = unchecked(0x0004);
- public class DfsInfo1 : NdrObject
- {
- public string EntryPath;
+ public class DfsInfo1 : NdrObject
+ {
+ public string EntryPath;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(EntryPath, 1);
- if (EntryPath != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(EntryPath);
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(EntryPath, 1);
+ if (EntryPath != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(EntryPath);
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int entryPathp = src.Dec_ndr_long();
- if (entryPathp != 0)
- {
- src = src.Deferred;
- EntryPath = src.Dec_ndr_string();
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int entryPathp = src.Dec_ndr_long();
+ if (entryPathp != 0)
+ {
+ src = src.Deferred;
+ EntryPath = src.Dec_ndr_string();
+ }
+ }
+ }
- public class DfsEnumArray1 : NdrObject
- {
- public int Count;
+ public class DfsEnumArray1 : NdrObject
+ {
+ public int Count;
- public DfsInfo1[] S;
+ public DfsInfo1[] S;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(S, 1);
- if (S != null)
- {
- dst = dst.Deferred;
- int ss = Count;
- dst.Enc_ndr_long(ss);
- int si = dst.Index;
- dst.Advance(4 * ss);
- dst = dst.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- S[i].Encode(dst);
- }
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(S, 1);
+ if (S != null)
+ {
+ dst = dst.Deferred;
+ int ss = Count;
+ dst.Enc_ndr_long(ss);
+ int si = dst.Index;
+ dst.Advance(4 * ss);
+ dst = dst.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ S[i].Encode(dst);
+ }
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int sp = src.Dec_ndr_long();
- if (sp != 0)
- {
- src = src.Deferred;
- int ss = src.Dec_ndr_long();
- int si = src.Index;
- src.Advance(4 * ss);
- if (S == null)
- {
- if (ss < 0 || ss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- S = new DfsInfo1[ss];
- }
- src = src.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- if (S[i] == null)
- {
- S[i] = new DfsInfo1();
- }
- S[i].Decode(src);
- }
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int sp = src.Dec_ndr_long();
+ if (sp != 0)
+ {
+ src = src.Deferred;
+ int ss = src.Dec_ndr_long();
+ int si = src.Index;
+ src.Advance(4 * ss);
+ if (S == null)
+ {
+ if (ss < 0 || ss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ S = new DfsInfo1[ss];
+ }
+ src = src.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ if (S[i] == null)
+ {
+ S[i] = new DfsInfo1();
+ }
+ S[i].Decode(src);
+ }
+ }
+ }
+ }
- public class DfsStorageInfo : NdrObject
- {
- public int State;
+ public class DfsStorageInfo : NdrObject
+ {
+ public int State;
- public string ServerName;
+ public string ServerName;
- public string ShareName;
+ public string ShareName;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(State);
- dst.Enc_ndr_referent(ServerName, 1);
- dst.Enc_ndr_referent(ShareName, 1);
- if (ServerName != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(ServerName);
- }
- if (ShareName != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(ShareName);
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(State);
+ dst.Enc_ndr_referent(ServerName, 1);
+ dst.Enc_ndr_referent(ShareName, 1);
+ if (ServerName != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(ServerName);
+ }
+ if (ShareName != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(ShareName);
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- State = src.Dec_ndr_long();
- int serverNamep = src.Dec_ndr_long();
- int shareNamep = src.Dec_ndr_long();
- if (serverNamep != 0)
- {
- src = src.Deferred;
- ServerName = src.Dec_ndr_string();
- }
- if (shareNamep != 0)
- {
- src = src.Deferred;
- ShareName = src.Dec_ndr_string();
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ State = src.Dec_ndr_long();
+ int serverNamep = src.Dec_ndr_long();
+ int shareNamep = src.Dec_ndr_long();
+ if (serverNamep != 0)
+ {
+ src = src.Deferred;
+ ServerName = src.Dec_ndr_string();
+ }
+ if (shareNamep != 0)
+ {
+ src = src.Deferred;
+ ShareName = src.Dec_ndr_string();
+ }
+ }
+ }
- public class DfsInfo3 : NdrObject
- {
- public string Path;
+ public class DfsInfo3 : NdrObject
+ {
+ public string Path;
- public string Comment;
+ public string Comment;
- public int State;
+ public int State;
- public int NumStores;
+ public int NumStores;
- public DfsStorageInfo[] Stores;
+ public DfsStorageInfo[] Stores;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(Path, 1);
- dst.Enc_ndr_referent(Comment, 1);
- dst.Enc_ndr_long(State);
- dst.Enc_ndr_long(NumStores);
- dst.Enc_ndr_referent(Stores, 1);
- if (Path != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Path);
- }
- if (Comment != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Comment);
- }
- if (Stores != null)
- {
- dst = dst.Deferred;
- int storess = NumStores;
- dst.Enc_ndr_long(storess);
- int storesi = dst.Index;
- dst.Advance(12 * storess);
- dst = dst.Derive(storesi);
- for (int i = 0; i < storess; i++)
- {
- Stores[i].Encode(dst);
- }
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(Path, 1);
+ dst.Enc_ndr_referent(Comment, 1);
+ dst.Enc_ndr_long(State);
+ dst.Enc_ndr_long(NumStores);
+ dst.Enc_ndr_referent(Stores, 1);
+ if (Path != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Path);
+ }
+ if (Comment != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Comment);
+ }
+ if (Stores != null)
+ {
+ dst = dst.Deferred;
+ int storess = NumStores;
+ dst.Enc_ndr_long(storess);
+ int storesi = dst.Index;
+ dst.Advance(12 * storess);
+ dst = dst.Derive(storesi);
+ for (int i = 0; i < storess; i++)
+ {
+ Stores[i].Encode(dst);
+ }
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int pathp = src.Dec_ndr_long();
- int commentp = src.Dec_ndr_long();
- State = src.Dec_ndr_long();
- NumStores = src.Dec_ndr_long();
- int storesp = src.Dec_ndr_long();
- if (pathp != 0)
- {
- src = src.Deferred;
- Path = src.Dec_ndr_string();
- }
- if (commentp != 0)
- {
- src = src.Deferred;
- Comment = src.Dec_ndr_string();
- }
- if (storesp != 0)
- {
- src = src.Deferred;
- int storess = src.Dec_ndr_long();
- int storesi = src.Index;
- src.Advance(12 * storess);
- if (Stores == null)
- {
- if (storess < 0 || storess > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Stores = new DfsStorageInfo[storess];
- }
- src = src.Derive(storesi);
- for (int i = 0; i < storess; i++)
- {
- if (Stores[i] == null)
- {
- Stores[i] = new DfsStorageInfo();
- }
- Stores[i].Decode(src);
- }
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int pathp = src.Dec_ndr_long();
+ int commentp = src.Dec_ndr_long();
+ State = src.Dec_ndr_long();
+ NumStores = src.Dec_ndr_long();
+ int storesp = src.Dec_ndr_long();
+ if (pathp != 0)
+ {
+ src = src.Deferred;
+ Path = src.Dec_ndr_string();
+ }
+ if (commentp != 0)
+ {
+ src = src.Deferred;
+ Comment = src.Dec_ndr_string();
+ }
+ if (storesp != 0)
+ {
+ src = src.Deferred;
+ int storess = src.Dec_ndr_long();
+ int storesi = src.Index;
+ src.Advance(12 * storess);
+ if (Stores == null)
+ {
+ if (storess < 0 || storess > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Stores = new DfsStorageInfo[storess];
+ }
+ src = src.Derive(storesi);
+ for (int i = 0; i < storess; i++)
+ {
+ if (Stores[i] == null)
+ {
+ Stores[i] = new DfsStorageInfo();
+ }
+ Stores[i].Decode(src);
+ }
+ }
+ }
+ }
- public class DfsEnumArray3 : NdrObject
- {
- public int Count;
+ public class DfsEnumArray3 : NdrObject
+ {
+ public int Count;
- public DfsInfo3[] S;
+ public DfsInfo3[] S;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(S, 1);
- if (S != null)
- {
- dst = dst.Deferred;
- int ss = Count;
- dst.Enc_ndr_long(ss);
- int si = dst.Index;
- dst.Advance(20 * ss);
- dst = dst.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- S[i].Encode(dst);
- }
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(S, 1);
+ if (S != null)
+ {
+ dst = dst.Deferred;
+ int ss = Count;
+ dst.Enc_ndr_long(ss);
+ int si = dst.Index;
+ dst.Advance(20 * ss);
+ dst = dst.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ S[i].Encode(dst);
+ }
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int sp = src.Dec_ndr_long();
- if (sp != 0)
- {
- src = src.Deferred;
- int ss = src.Dec_ndr_long();
- int si = src.Index;
- src.Advance(20 * ss);
- if (S == null)
- {
- if (ss < 0 || ss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- S = new DfsInfo3[ss];
- }
- src = src.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- if (S[i] == null)
- {
- S[i] = new DfsInfo3();
- }
- S[i].Decode(src);
- }
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int sp = src.Dec_ndr_long();
+ if (sp != 0)
+ {
+ src = src.Deferred;
+ int ss = src.Dec_ndr_long();
+ int si = src.Index;
+ src.Advance(20 * ss);
+ if (S == null)
+ {
+ if (ss < 0 || ss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ S = new DfsInfo3[ss];
+ }
+ src = src.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ if (S[i] == null)
+ {
+ S[i] = new DfsInfo3();
+ }
+ S[i].Decode(src);
+ }
+ }
+ }
+ }
- public class DfsInfo200 : NdrObject
- {
- public string DfsName;
+ public class DfsInfo200 : NdrObject
+ {
+ public string DfsName;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(DfsName, 1);
- if (DfsName != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(DfsName);
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(DfsName, 1);
+ if (DfsName != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(DfsName);
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int dfsNamep = src.Dec_ndr_long();
- if (dfsNamep != 0)
- {
- src = src.Deferred;
- DfsName = src.Dec_ndr_string();
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int dfsNamep = src.Dec_ndr_long();
+ if (dfsNamep != 0)
+ {
+ src = src.Deferred;
+ DfsName = src.Dec_ndr_string();
+ }
+ }
+ }
- public class DfsEnumArray200 : NdrObject
- {
- public int Count;
+ public class DfsEnumArray200 : NdrObject
+ {
+ public int Count;
- public DfsInfo200[] S;
+ public DfsInfo200[] S;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(S, 1);
- if (S != null)
- {
- dst = dst.Deferred;
- int ss = Count;
- dst.Enc_ndr_long(ss);
- int si = dst.Index;
- dst.Advance(4 * ss);
- dst = dst.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- S[i].Encode(dst);
- }
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(S, 1);
+ if (S != null)
+ {
+ dst = dst.Deferred;
+ int ss = Count;
+ dst.Enc_ndr_long(ss);
+ int si = dst.Index;
+ dst.Advance(4 * ss);
+ dst = dst.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ S[i].Encode(dst);
+ }
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int sp = src.Dec_ndr_long();
- if (sp != 0)
- {
- src = src.Deferred;
- int ss = src.Dec_ndr_long();
- int si = src.Index;
- src.Advance(4 * ss);
- if (S == null)
- {
- if (ss < 0 || ss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- S = new DfsInfo200[ss];
- }
- src = src.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- if (S[i] == null)
- {
- S[i] = new DfsInfo200();
- }
- S[i].Decode(src);
- }
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int sp = src.Dec_ndr_long();
+ if (sp != 0)
+ {
+ src = src.Deferred;
+ int ss = src.Dec_ndr_long();
+ int si = src.Index;
+ src.Advance(4 * ss);
+ if (S == null)
+ {
+ if (ss < 0 || ss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ S = new DfsInfo200[ss];
+ }
+ src = src.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ if (S[i] == null)
+ {
+ S[i] = new DfsInfo200();
+ }
+ S[i].Decode(src);
+ }
+ }
+ }
+ }
- public class DfsInfo300 : NdrObject
- {
- public int Flags;
+ public class DfsInfo300 : NdrObject
+ {
+ public int Flags;
- public string DfsName;
+ public string DfsName;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Flags);
- dst.Enc_ndr_referent(DfsName, 1);
- if (DfsName != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(DfsName);
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Flags);
+ dst.Enc_ndr_referent(DfsName, 1);
+ if (DfsName != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(DfsName);
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Flags = src.Dec_ndr_long();
- int dfsNamep = src.Dec_ndr_long();
- if (dfsNamep != 0)
- {
- src = src.Deferred;
- DfsName = src.Dec_ndr_string();
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Flags = src.Dec_ndr_long();
+ int dfsNamep = src.Dec_ndr_long();
+ if (dfsNamep != 0)
+ {
+ src = src.Deferred;
+ DfsName = src.Dec_ndr_string();
+ }
+ }
+ }
- public class DfsEnumArray300 : NdrObject
- {
- public int Count;
+ public class DfsEnumArray300 : NdrObject
+ {
+ public int Count;
- public DfsInfo300[] S;
+ public DfsInfo300[] S;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(S, 1);
- if (S != null)
- {
- dst = dst.Deferred;
- int ss = Count;
- dst.Enc_ndr_long(ss);
- int si = dst.Index;
- dst.Advance(8 * ss);
- dst = dst.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- S[i].Encode(dst);
- }
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(S, 1);
+ if (S != null)
+ {
+ dst = dst.Deferred;
+ int ss = Count;
+ dst.Enc_ndr_long(ss);
+ int si = dst.Index;
+ dst.Advance(8 * ss);
+ dst = dst.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ S[i].Encode(dst);
+ }
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int sp = src.Dec_ndr_long();
- if (sp != 0)
- {
- src = src.Deferred;
- int ss = src.Dec_ndr_long();
- int si = src.Index;
- src.Advance(8 * ss);
- if (S == null)
- {
- if (ss < 0 || ss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- S = new DfsInfo300[ss];
- }
- src = src.Derive(si);
- for (int i = 0; i < ss; i++)
- {
- if (S[i] == null)
- {
- S[i] = new DfsInfo300();
- }
- S[i].Decode(src);
- }
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int sp = src.Dec_ndr_long();
+ if (sp != 0)
+ {
+ src = src.Deferred;
+ int ss = src.Dec_ndr_long();
+ int si = src.Index;
+ src.Advance(8 * ss);
+ if (S == null)
+ {
+ if (ss < 0 || ss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ S = new DfsInfo300[ss];
+ }
+ src = src.Derive(si);
+ for (int i = 0; i < ss; i++)
+ {
+ if (S[i] == null)
+ {
+ S[i] = new DfsInfo300();
+ }
+ S[i].Decode(src);
+ }
+ }
+ }
+ }
- public class DfsEnumStruct : NdrObject
- {
- public int Level;
+ public class DfsEnumStruct : NdrObject
+ {
+ public int Level;
- public NdrObject E;
+ public NdrObject E;
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Level);
- int descr = Level;
- dst.Enc_ndr_long(descr);
- dst.Enc_ndr_referent(E, 1);
- if (E != null)
- {
- dst = dst.Deferred;
- E.Encode(dst);
- }
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Level);
+ int descr = Level;
+ dst.Enc_ndr_long(descr);
+ dst.Enc_ndr_referent(E, 1);
+ if (E != null)
+ {
+ dst = dst.Deferred;
+ E.Encode(dst);
+ }
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Level = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int ep = src.Dec_ndr_long();
- if (ep != 0)
- {
- if (E == null)
- {
- E = new DfsEnumArray1();
- }
- src = src.Deferred;
- E.Decode(src);
- }
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Level = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int ep = src.Dec_ndr_long();
+ if (ep != 0)
+ {
+ if (E == null)
+ {
+ E = new DfsEnumArray1();
+ }
+ src = src.Deferred;
+ E.Decode(src);
+ }
+ }
+ }
- public class NetrDfsEnumEx : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x15);
- }
+ public class NetrDfsEnumEx : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x15);
+ }
- public int Retval;
+ public int Retval;
- public string DfsName;
+ public string DfsName;
- public int Level;
+ public int Level;
- public int Prefmaxlen;
+ public int Prefmaxlen;
- public DfsEnumStruct Info;
+ public DfsEnumStruct Info;
- public NdrLong Totalentries;
+ public NdrLong Totalentries;
- public NetrDfsEnumEx(string dfsName, int level, int prefmaxlen, DfsEnumStruct
- info, NdrLong totalentries)
- {
- this.DfsName = dfsName;
- this.Level = level;
- this.Prefmaxlen = prefmaxlen;
- this.Info = info;
- this.Totalentries = totalentries;
- }
+ public NetrDfsEnumEx(string dfsName, int level, int prefmaxlen, DfsEnumStruct
+ info, NdrLong totalentries)
+ {
+ this.DfsName = dfsName;
+ this.Level = level;
+ this.Prefmaxlen = prefmaxlen;
+ this.Info = info;
+ this.Totalentries = totalentries;
+ }
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_string(DfsName);
- dst.Enc_ndr_long(Level);
- dst.Enc_ndr_long(Prefmaxlen);
- dst.Enc_ndr_referent(Info, 1);
- if (Info != null)
- {
- Info.Encode(dst);
- }
- dst.Enc_ndr_referent(Totalentries, 1);
- if (Totalentries != null)
- {
- Totalentries.Encode(dst);
- }
- }
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_string(DfsName);
+ dst.Enc_ndr_long(Level);
+ dst.Enc_ndr_long(Prefmaxlen);
+ dst.Enc_ndr_referent(Info, 1);
+ if (Info != null)
+ {
+ Info.Encode(dst);
+ }
+ dst.Enc_ndr_referent(Totalentries, 1);
+ if (Totalentries != null)
+ {
+ Totalentries.Encode(dst);
+ }
+ }
- ///
- public override void Decode_out(NdrBuffer src)
- {
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- if (Info == null)
- {
- Info = new DfsEnumStruct();
- }
- Info.Decode(src);
- }
- int totalentriesp = src.Dec_ndr_long();
- if (totalentriesp != 0)
- {
- Totalentries.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
- }
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ if (Info == null)
+ {
+ Info = new DfsEnumStruct();
+ }
+ Info.Decode(src);
+ }
+ int totalentriesp = src.Dec_ndr_long();
+ if (totalentriesp != 0)
+ {
+ Totalentries.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs
index 48051e40d..bdc71695e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs
@@ -18,566 +18,562 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class Samr
- {
- public static string GetSyntax()
- {
- return "12345778-1234-abcd-ef00-0123456789ac:1.0";
- }
+ public class Samr
+ {
+ public static string GetSyntax()
+ {
+ return "12345778-1234-abcd-ef00-0123456789ac:1.0";
+ }
- public const int AcbDisabled = 1;
+ public const int AcbDisabled = 1;
- public const int AcbHomdirreq = 2;
+ public const int AcbHomdirreq = 2;
- public const int AcbPwnotreq = 4;
+ public const int AcbPwnotreq = 4;
- public const int AcbTempdup = 8;
+ public const int AcbTempdup = 8;
- public const int AcbNormal = 16;
+ public const int AcbNormal = 16;
- public const int AcbMns = 32;
+ public const int AcbMns = 32;
- public const int AcbDomtrust = 64;
+ public const int AcbDomtrust = 64;
- public const int AcbWstrust = 128;
+ public const int AcbWstrust = 128;
- public const int AcbSvrtrust = 256;
+ public const int AcbSvrtrust = 256;
- public const int AcbPwnoexp = 512;
+ public const int AcbPwnoexp = 512;
- public const int AcbAutolock = 1024;
+ public const int AcbAutolock = 1024;
- public const int AcbEncTxtPwdAllowed = 2048;
+ public const int AcbEncTxtPwdAllowed = 2048;
- public const int AcbSmartcardRequired = 4096;
+ public const int AcbSmartcardRequired = 4096;
- public const int AcbTrustedForDelegation = 8192;
+ public const int AcbTrustedForDelegation = 8192;
- public const int AcbNotDelegated = 16384;
+ public const int AcbNotDelegated = 16384;
- public const int AcbUseDesKeyOnly = 32768;
+ public const int AcbUseDesKeyOnly = 32768;
- public const int AcbDontRequirePreauth = 65536;
+ public const int AcbDontRequirePreauth = 65536;
- public class SamrCloseHandle : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x01);
- }
+ public class SamrCloseHandle : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x01);
+ }
- public int Retval;
+ public int Retval;
- public Rpc.PolicyHandle Handle;
+ public Rpc.PolicyHandle Handle;
- public SamrCloseHandle(Rpc.PolicyHandle handle)
- {
- this.Handle = handle;
- }
+ public SamrCloseHandle(Rpc.PolicyHandle handle)
+ {
+ this.Handle = handle;
+ }
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- }
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ }
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Retval = src.Dec_ndr_long();
- }
- }
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Retval = src.Dec_ndr_long();
+ }
+ }
- public class SamrConnect2 : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x39);
- }
+ public class SamrConnect2 : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x39);
+ }
- public int Retval;
+ public int Retval;
- public string SystemName;
+ public string SystemName;
- public int AccessMask;
+ public int AccessMask;
- public Rpc.PolicyHandle Handle;
+ public Rpc.PolicyHandle Handle;
- public SamrConnect2(string systemName, int accessMask, Rpc.PolicyHandle handle)
- {
- this.SystemName = systemName;
- this.AccessMask = accessMask;
- this.Handle = handle;
- }
+ public SamrConnect2(string systemName, int accessMask, Rpc.PolicyHandle handle
+ )
+ {
+ this.SystemName = systemName;
+ this.AccessMask = accessMask;
+ this.Handle = handle;
+ }
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(SystemName, 1);
- if (SystemName != null)
- {
- dst.Enc_ndr_string(SystemName);
- }
- dst.Enc_ndr_long(AccessMask);
- }
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(SystemName, 1);
+ if (SystemName != null)
+ {
+ dst.Enc_ndr_string(SystemName);
+ }
+ dst.Enc_ndr_long(AccessMask);
+ }
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Handle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class SamrConnect4 : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x3e);
- }
-
- public int Retval;
-
- public string SystemName;
-
- public int Unknown;
-
- public int AccessMask;
-
- public Rpc.PolicyHandle Handle;
-
- public SamrConnect4(string systemName, int unknown, int accessMask, Rpc.PolicyHandle handle)
- {
- this.SystemName = systemName;
- this.Unknown = unknown;
- this.AccessMask = accessMask;
- this.Handle = handle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(SystemName, 1);
- if (SystemName != null)
- {
- dst.Enc_ndr_string(SystemName);
- }
- dst.Enc_ndr_long(Unknown);
- dst.Enc_ndr_long(AccessMask);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Handle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class SamrOpenDomain : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x07);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle Handle;
-
- public int AccessMask;
-
- public Rpc.SidT Sid;
-
- public Rpc.PolicyHandle DomainHandle;
-
- public SamrOpenDomain(Rpc.PolicyHandle handle,
- int accessMask,
- Rpc.SidT sid,
- Rpc.PolicyHandle domainHandle)
- {
- this.Handle = handle;
- this.AccessMask = accessMask;
- this.Sid = sid;
- this.DomainHandle = domainHandle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- Handle.Encode(dst);
- dst.Enc_ndr_long(AccessMask);
- Sid.Encode(dst);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- DomainHandle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class SamrSamEntry : NdrObject
- {
- public int Idx;
-
- public Rpc.Unicode_string Name;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Idx);
- dst.Enc_ndr_short(Name.Length);
- dst.Enc_ndr_short(Name.MaximumLength);
- dst.Enc_ndr_referent(Name.Buffer, 1);
- if (Name.Buffer != null)
- {
- dst = dst.Deferred;
- int nameBufferl = Name.Length / 2;
- int nameBuffers = Name.MaximumLength / 2;
- dst.Enc_ndr_long(nameBuffers);
- dst.Enc_ndr_long(0);
- dst.Enc_ndr_long(nameBufferl);
- int nameBufferi = dst.Index;
- dst.Advance(2 * nameBufferl);
- dst = dst.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- dst.Enc_ndr_short(Name.Buffer[i]);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Idx = src.Dec_ndr_long();
- src.Align(4);
- if (Name == null)
- {
- Name = new Rpc.Unicode_string();
- }
- Name.Length = (short)src.Dec_ndr_short();
- Name.MaximumLength = (short)src.Dec_ndr_short();
- int nameBufferp = src.Dec_ndr_long();
- if (nameBufferp != 0)
- {
- src = src.Deferred;
- int nameBuffers = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int nameBufferl = src.Dec_ndr_long();
- int nameBufferi = src.Index;
- src.Advance(2 * nameBufferl);
- if (Name.Buffer == null)
- {
- if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Name.Buffer = new short[nameBuffers];
- }
- src = src.Derive(nameBufferi);
- for (int i = 0; i < nameBufferl; i++)
- {
- Name.Buffer[i] = (short)src.Dec_ndr_short();
- }
- }
- }
- }
-
- public class SamrSamArray : NdrObject
- {
- public int Count;
-
- public SamrSamEntry[] Entries;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Entries, 1);
- if (Entries != null)
- {
- dst = dst.Deferred;
- int entriess = Count;
- dst.Enc_ndr_long(entriess);
- int entriesi = dst.Index;
- dst.Advance(12 * entriess);
- dst = dst.Derive(entriesi);
- for (int i = 0; i < entriess; i++)
- {
- Entries[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int entriesp = src.Dec_ndr_long();
- if (entriesp != 0)
- {
- src = src.Deferred;
- int entriess = src.Dec_ndr_long();
- int entriesi = src.Index;
- src.Advance(12 * entriess);
- if (Entries == null)
- {
- if (entriess < 0 || entriess > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Entries = new SamrSamEntry[entriess];
- }
- src = src.Derive(entriesi);
- for (int i = 0; i < entriess; i++)
- {
- if (Entries[i] == null)
- {
- Entries[i] = new SamrSamEntry();
- }
- Entries[i].Decode(src);
- }
- }
- }
- }
-
- public class SamrEnumerateAliasesInDomain : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x0f);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle DomainHandle;
-
- public int ResumeHandle;
-
- public int AcctFlags;
-
- public SamrSamArray Sam;
-
- public int NumEntries;
-
- public SamrEnumerateAliasesInDomain(Rpc.PolicyHandle domainHandle,
- int resumeHandle,
- int acctFlags,
- SamrSamArray sam,
- int numEntries)
- {
- this.DomainHandle = domainHandle;
- this.ResumeHandle = resumeHandle;
- this.AcctFlags = acctFlags;
- this.Sam = sam;
- this.NumEntries = numEntries;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- DomainHandle.Encode(dst);
- dst.Enc_ndr_long(ResumeHandle);
- dst.Enc_ndr_long(AcctFlags);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- ResumeHandle = src.Dec_ndr_long();
- int samp = src.Dec_ndr_long();
- if (samp != 0)
- {
- if (Sam == null)
- {
- Sam = new SamrSamArray();
- }
- Sam.Decode(src);
- }
- NumEntries = src.Dec_ndr_long();
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class SamrOpenAlias : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x1b);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle DomainHandle;
-
- public int AccessMask;
-
- public int Rid;
-
- public Rpc.PolicyHandle AliasHandle;
-
- public SamrOpenAlias(Rpc.PolicyHandle domainHandle,
- int accessMask,
- int rid,
- Rpc.PolicyHandle aliasHandle)
- {
- this.DomainHandle = domainHandle;
- this.AccessMask = accessMask;
- this.Rid = rid;
- this.AliasHandle = aliasHandle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- DomainHandle.Encode(dst);
- dst.Enc_ndr_long(AccessMask);
- dst.Enc_ndr_long(Rid);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- AliasHandle.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class SamrGetMembersInAlias : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x21);
- }
-
- public int Retval;
-
- public Rpc.PolicyHandle AliasHandle;
-
- public Lsarpc.LsarSidArray Sids;
-
- public SamrGetMembersInAlias(Rpc.PolicyHandle aliasHandle, Lsarpc.LsarSidArray sids)
- {
- this.AliasHandle = aliasHandle;
- this.Sids = sids;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- AliasHandle.Encode(dst);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Sids.Decode(src);
- Retval = src.Dec_ndr_long();
- }
- }
-
- public const int SeGroupMandatory = 1;
-
- public const int SeGroupEnabledByDefault = 2;
-
- public const int SeGroupEnabled = 4;
-
- public const int SeGroupOwner = 8;
-
- public const int SeGroupUseForDenyOnly = 16;
-
- public const int SeGroupResource = 536870912;
-
- public const int SeGroupLogonId = -1073741824;
-
- public class SamrRidWithAttribute : NdrObject
- {
- public int Rid;
-
- public int Attributes;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Rid);
- dst.Enc_ndr_long(Attributes);
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Rid = src.Dec_ndr_long();
- Attributes = src.Dec_ndr_long();
- }
- }
-
- public class SamrRidWithAttributeArray : NdrObject
- {
- public int Count;
-
- public SamrRidWithAttribute[] Rids;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Rids, 1);
- if (Rids != null)
- {
- dst = dst.Deferred;
- int ridss = Count;
- dst.Enc_ndr_long(ridss);
- int ridsi = dst.Index;
- dst.Advance(8 * ridss);
- dst = dst.Derive(ridsi);
- for (int i = 0; i < ridss; i++)
- {
- Rids[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int ridsp = src.Dec_ndr_long();
- if (ridsp != 0)
- {
- src = src.Deferred;
- int ridss = src.Dec_ndr_long();
- int ridsi = src.Index;
- src.Advance(8 * ridss);
- if (Rids == null)
- {
- if (ridss < 0 || ridss > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Rids = new SamrRidWithAttribute[ridss];
- }
- src = src.Derive(ridsi);
- for (int i = 0; i < ridss; i++)
- {
- if (Rids[i] == null)
- {
- Rids[i] = new SamrRidWithAttribute();
- }
- Rids[i].Decode(src);
- }
- }
- }
- }
- }
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Handle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrConnect4 : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x3e);
+ }
+
+ public int Retval;
+
+ public string SystemName;
+
+ public int Unknown;
+
+ public int AccessMask;
+
+ public Rpc.PolicyHandle Handle;
+
+ public SamrConnect4(string systemName, int unknown, int accessMask, Rpc.PolicyHandle
+ handle)
+ {
+ this.SystemName = systemName;
+ this.Unknown = unknown;
+ this.AccessMask = accessMask;
+ this.Handle = handle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(SystemName, 1);
+ if (SystemName != null)
+ {
+ dst.Enc_ndr_string(SystemName);
+ }
+ dst.Enc_ndr_long(Unknown);
+ dst.Enc_ndr_long(AccessMask);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Handle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrOpenDomain : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x07);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle Handle;
+
+ public int AccessMask;
+
+ public Rpc.SidT Sid;
+
+ public Rpc.PolicyHandle DomainHandle;
+
+ public SamrOpenDomain(Rpc.PolicyHandle handle, int accessMask, Rpc.SidT sid, Rpc.PolicyHandle
+ domainHandle)
+ {
+ this.Handle = handle;
+ this.AccessMask = accessMask;
+ this.Sid = sid;
+ this.DomainHandle = domainHandle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ Handle.Encode(dst);
+ dst.Enc_ndr_long(AccessMask);
+ Sid.Encode(dst);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ DomainHandle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrSamEntry : NdrObject
+ {
+ public int Idx;
+
+ public Rpc.Unicode_string Name;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Idx);
+ dst.Enc_ndr_short(Name.Length);
+ dst.Enc_ndr_short(Name.MaximumLength);
+ dst.Enc_ndr_referent(Name.Buffer, 1);
+ if (Name.Buffer != null)
+ {
+ dst = dst.Deferred;
+ int nameBufferl = Name.Length / 2;
+ int nameBuffers = Name.MaximumLength / 2;
+ dst.Enc_ndr_long(nameBuffers);
+ dst.Enc_ndr_long(0);
+ dst.Enc_ndr_long(nameBufferl);
+ int nameBufferi = dst.Index;
+ dst.Advance(2 * nameBufferl);
+ dst = dst.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ dst.Enc_ndr_short(Name.Buffer[i]);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Idx = src.Dec_ndr_long();
+ src.Align(4);
+ if (Name == null)
+ {
+ Name = new Rpc.Unicode_string();
+ }
+ Name.Length = (short)src.Dec_ndr_short();
+ Name.MaximumLength = (short)src.Dec_ndr_short();
+ int nameBufferp = src.Dec_ndr_long();
+ if (nameBufferp != 0)
+ {
+ src = src.Deferred;
+ int nameBuffers = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int nameBufferl = src.Dec_ndr_long();
+ int nameBufferi = src.Index;
+ src.Advance(2 * nameBufferl);
+ if (Name.Buffer == null)
+ {
+ if (nameBuffers < 0 || nameBuffers > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Name.Buffer = new short[nameBuffers];
+ }
+ src = src.Derive(nameBufferi);
+ for (int i = 0; i < nameBufferl; i++)
+ {
+ Name.Buffer[i] = (short)src.Dec_ndr_short();
+ }
+ }
+ }
+ }
+
+ public class SamrSamArray : NdrObject
+ {
+ public int Count;
+
+ public SamrSamEntry[] Entries;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Entries, 1);
+ if (Entries != null)
+ {
+ dst = dst.Deferred;
+ int entriess = Count;
+ dst.Enc_ndr_long(entriess);
+ int entriesi = dst.Index;
+ dst.Advance(12 * entriess);
+ dst = dst.Derive(entriesi);
+ for (int i = 0; i < entriess; i++)
+ {
+ Entries[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int entriesp = src.Dec_ndr_long();
+ if (entriesp != 0)
+ {
+ src = src.Deferred;
+ int entriess = src.Dec_ndr_long();
+ int entriesi = src.Index;
+ src.Advance(12 * entriess);
+ if (Entries == null)
+ {
+ if (entriess < 0 || entriess > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Entries = new SamrSamEntry[entriess];
+ }
+ src = src.Derive(entriesi);
+ for (int i = 0; i < entriess; i++)
+ {
+ if (Entries[i] == null)
+ {
+ Entries[i] = new SamrSamEntry();
+ }
+ Entries[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class SamrEnumerateAliasesInDomain : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x0f);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle DomainHandle;
+
+ public int ResumeHandle;
+
+ public int AcctFlags;
+
+ public SamrSamArray Sam;
+
+ public int NumEntries;
+
+ public SamrEnumerateAliasesInDomain(Rpc.PolicyHandle domainHandle, int resumeHandle
+ , int acctFlags, SamrSamArray sam, int numEntries)
+ {
+ this.DomainHandle = domainHandle;
+ this.ResumeHandle = resumeHandle;
+ this.AcctFlags = acctFlags;
+ this.Sam = sam;
+ this.NumEntries = numEntries;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ DomainHandle.Encode(dst);
+ dst.Enc_ndr_long(ResumeHandle);
+ dst.Enc_ndr_long(AcctFlags);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ ResumeHandle = src.Dec_ndr_long();
+ int samp = src.Dec_ndr_long();
+ if (samp != 0)
+ {
+ if (Sam == null)
+ {
+ Sam = new SamrSamArray();
+ }
+ Sam.Decode(src);
+ }
+ NumEntries = src.Dec_ndr_long();
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrOpenAlias : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x1b);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle DomainHandle;
+
+ public int AccessMask;
+
+ public int Rid;
+
+ public Rpc.PolicyHandle AliasHandle;
+
+ public SamrOpenAlias(Rpc.PolicyHandle domainHandle, int accessMask, int rid, Rpc.PolicyHandle
+ aliasHandle)
+ {
+ this.DomainHandle = domainHandle;
+ this.AccessMask = accessMask;
+ this.Rid = rid;
+ this.AliasHandle = aliasHandle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ DomainHandle.Encode(dst);
+ dst.Enc_ndr_long(AccessMask);
+ dst.Enc_ndr_long(Rid);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ AliasHandle.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrGetMembersInAlias : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x21);
+ }
+
+ public int Retval;
+
+ public Rpc.PolicyHandle AliasHandle;
+
+ public Lsarpc.LsarSidArray Sids;
+
+ public SamrGetMembersInAlias(Rpc.PolicyHandle aliasHandle, Lsarpc.LsarSidArray
+ sids)
+ {
+ this.AliasHandle = aliasHandle;
+ this.Sids = sids;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ AliasHandle.Encode(dst);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Sids.Decode(src);
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public const int SeGroupMandatory = 1;
+
+ public const int SeGroupEnabledByDefault = 2;
+
+ public const int SeGroupEnabled = 4;
+
+ public const int SeGroupOwner = 8;
+
+ public const int SeGroupUseForDenyOnly = 16;
+
+ public const int SeGroupResource = 536870912;
+
+ public const int SeGroupLogonId = -1073741824;
+
+ public class SamrRidWithAttribute : NdrObject
+ {
+ public int Rid;
+
+ public int Attributes;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Rid);
+ dst.Enc_ndr_long(Attributes);
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Rid = src.Dec_ndr_long();
+ Attributes = src.Dec_ndr_long();
+ }
+ }
+
+ public class SamrRidWithAttributeArray : NdrObject
+ {
+ public int Count;
+
+ public SamrRidWithAttribute[] Rids;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Rids, 1);
+ if (Rids != null)
+ {
+ dst = dst.Deferred;
+ int ridss = Count;
+ dst.Enc_ndr_long(ridss);
+ int ridsi = dst.Index;
+ dst.Advance(8 * ridss);
+ dst = dst.Derive(ridsi);
+ for (int i = 0; i < ridss; i++)
+ {
+ Rids[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int ridsp = src.Dec_ndr_long();
+ if (ridsp != 0)
+ {
+ src = src.Deferred;
+ int ridss = src.Dec_ndr_long();
+ int ridsi = src.Index;
+ src.Advance(8 * ridss);
+ if (Rids == null)
+ {
+ if (ridss < 0 || ridss > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Rids = new SamrRidWithAttribute[ridss];
+ }
+ src = src.Derive(ridsi);
+ for (int i = 0; i < ridss; i++)
+ {
+ if (Rids[i] == null)
+ {
+ Rids[i] = new SamrRidWithAttribute();
+ }
+ Rids[i].Decode(src);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs
index 37c9de97f..d4ebdacc4 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs
@@ -18,25 +18,23 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class SamrAliasHandle : Rpc.PolicyHandle
- {
- ///
- 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
+ {
+ ///
+ 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 virtual void Close()
- {
- }
- }
+ ///
+ public virtual void Close()
+ {
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs
index f50aeade2..d44c79886 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs
@@ -18,25 +18,24 @@ using SharpCifs.Smb;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class SamrDomainHandle : Rpc.PolicyHandle
- {
- ///
- 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
+ {
+ ///
+ 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 virtual void Close()
- {
- }
- }
+ ///
+ public virtual void Close()
+ {
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs
index 7aa06559f..0cd3f9369 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs
@@ -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
- {
- ///
- 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
+ {
+ ///
+ 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 virtual void Close()
- {
- }
- }
+ ///
+ public virtual void Close()
+ {
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs
index 4a1493506..f33f48327 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs
@@ -18,720 +18,717 @@ using SharpCifs.Dcerpc.Ndr;
namespace SharpCifs.Dcerpc.Msrpc
{
- public class Srvsvc
- {
- public static string GetSyntax()
- {
- return "4b324fc8-1670-01d3-1278-5a47bf6ee188:3.0";
- }
-
- public class ShareInfo0 : NdrObject
- {
- public string Netname;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(Netname, 1);
- if (Netname != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Netname);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int netnamep = src.Dec_ndr_long();
- if (netnamep != 0)
- {
- src = src.Deferred;
- Netname = src.Dec_ndr_string();
- }
- }
- }
-
- public class ShareInfoCtr0 : NdrObject
- {
- public int Count;
-
- public ShareInfo0[] Array;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Array, 1);
- if (Array != null)
- {
- dst = dst.Deferred;
- int arrays = Count;
- dst.Enc_ndr_long(arrays);
- int arrayi = dst.Index;
- dst.Advance(4 * arrays);
- dst = dst.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- Array[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int arrayp = src.Dec_ndr_long();
- if (arrayp != 0)
- {
- src = src.Deferred;
- int arrays = src.Dec_ndr_long();
- int arrayi = src.Index;
- src.Advance(4 * arrays);
- if (Array == null)
- {
- if (arrays < 0 || arrays > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Array = new ShareInfo0[arrays];
- }
- src = src.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- if (Array[i] == null)
- {
- Array[i] = new ShareInfo0();
- }
- Array[i].Decode(src);
- }
- }
- }
- }
-
- public class ShareInfo1 : NdrObject
- {
- public string Netname;
-
- public int Type;
-
- public string Remark;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(Netname, 1);
- dst.Enc_ndr_long(Type);
- dst.Enc_ndr_referent(Remark, 1);
- if (Netname != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Netname);
- }
- if (Remark != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Remark);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int netnamep = src.Dec_ndr_long();
- Type = src.Dec_ndr_long();
- int remarkp = src.Dec_ndr_long();
- if (netnamep != 0)
- {
- src = src.Deferred;
- Netname = src.Dec_ndr_string();
- }
- if (remarkp != 0)
- {
- src = src.Deferred;
- Remark = src.Dec_ndr_string();
- }
- }
- }
-
- public class ShareInfoCtr1 : NdrObject
- {
- public int Count;
-
- public ShareInfo1[] Array;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Array, 1);
- if (Array != null)
- {
- dst = dst.Deferred;
- int arrays = Count;
- dst.Enc_ndr_long(arrays);
- int arrayi = dst.Index;
- dst.Advance(12 * arrays);
- dst = dst.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- Array[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int arrayp = src.Dec_ndr_long();
- if (arrayp != 0)
- {
- src = src.Deferred;
- int arrays = src.Dec_ndr_long();
- int arrayi = src.Index;
- src.Advance(12 * arrays);
- if (Array == null)
- {
- if (arrays < 0 || arrays > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Array = new ShareInfo1[arrays];
- }
- src = src.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- if (Array[i] == null)
- {
- Array[i] = new ShareInfo1();
- }
- Array[i].Decode(src);
- }
- }
- }
- }
-
- public class ShareInfo502 : NdrObject
- {
- public string Netname;
-
- public int Type;
-
- public string Remark;
-
- public int Permissions;
-
- public int MaxUses;
-
- public int CurrentUses;
-
- public string Path;
-
- public string Password;
-
- public int SdSize;
-
- public byte[] SecurityDescriptor;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_referent(Netname, 1);
- dst.Enc_ndr_long(Type);
- dst.Enc_ndr_referent(Remark, 1);
- dst.Enc_ndr_long(Permissions);
- dst.Enc_ndr_long(MaxUses);
- dst.Enc_ndr_long(CurrentUses);
- dst.Enc_ndr_referent(Path, 1);
- dst.Enc_ndr_referent(Password, 1);
- dst.Enc_ndr_long(SdSize);
- dst.Enc_ndr_referent(SecurityDescriptor, 1);
- if (Netname != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Netname);
- }
- if (Remark != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Remark);
- }
- if (Path != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Path);
- }
- if (Password != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Password);
- }
- if (SecurityDescriptor != null)
- {
- dst = dst.Deferred;
- int securityDescriptors = SdSize;
- dst.Enc_ndr_long(securityDescriptors);
- int securityDescriptori = dst.Index;
- dst.Advance(1 * securityDescriptors);
- dst = dst.Derive(securityDescriptori);
- for (int i = 0; i < securityDescriptors; i++)
- {
- dst.Enc_ndr_small(SecurityDescriptor[i]);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- int netnamep = src.Dec_ndr_long();
- Type = src.Dec_ndr_long();
- int remarkp = src.Dec_ndr_long();
- Permissions = src.Dec_ndr_long();
- MaxUses = src.Dec_ndr_long();
- CurrentUses = src.Dec_ndr_long();
- int pathp = src.Dec_ndr_long();
- int passwordp = src.Dec_ndr_long();
- SdSize = src.Dec_ndr_long();
- int securityDescriptorp = src.Dec_ndr_long();
- if (netnamep != 0)
- {
- src = src.Deferred;
- Netname = src.Dec_ndr_string();
- }
- if (remarkp != 0)
- {
- src = src.Deferred;
- Remark = src.Dec_ndr_string();
- }
- if (pathp != 0)
- {
- src = src.Deferred;
- Path = src.Dec_ndr_string();
- }
- if (passwordp != 0)
- {
- src = src.Deferred;
- Password = src.Dec_ndr_string();
- }
- if (securityDescriptorp != 0)
- {
- src = src.Deferred;
- int securityDescriptors = src.Dec_ndr_long();
- int securityDescriptori = src.Index;
- src.Advance(1 * securityDescriptors);
- if (SecurityDescriptor == null)
- {
- if (securityDescriptors < 0 || securityDescriptors > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- SecurityDescriptor = new byte[securityDescriptors];
- }
- src = src.Derive(securityDescriptori);
- for (int i = 0; i < securityDescriptors; i++)
- {
- SecurityDescriptor[i] = unchecked((byte)src.Dec_ndr_small());
- }
- }
- }
- }
-
- public class ShareInfoCtr502 : NdrObject
- {
- public int Count;
-
- public ShareInfo502[] Array;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Count);
- dst.Enc_ndr_referent(Array, 1);
- if (Array != null)
- {
- dst = dst.Deferred;
- int arrays = Count;
- dst.Enc_ndr_long(arrays);
- int arrayi = dst.Index;
- dst.Advance(40 * arrays);
- dst = dst.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- Array[i].Encode(dst);
- }
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Count = src.Dec_ndr_long();
- int arrayp = src.Dec_ndr_long();
- if (arrayp != 0)
- {
- src = src.Deferred;
- int arrays = src.Dec_ndr_long();
- int arrayi = src.Index;
- src.Advance(40 * arrays);
- if (Array == null)
- {
- if (arrays < 0 || arrays > unchecked(0xFFFF))
- {
- throw new NdrException(NdrException.InvalidConformance);
- }
- Array = new ShareInfo502[arrays];
- }
- src = src.Derive(arrayi);
- for (int i = 0; i < arrays; i++)
- {
- if (Array[i] == null)
- {
- Array[i] = new ShareInfo502();
- }
- Array[i].Decode(src);
- }
- }
- }
- }
-
- public class ShareEnumAll : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x0f);
- }
-
- public int Retval;
-
- public string Servername;
-
- public int Level;
-
- public NdrObject Info;
-
- public int Prefmaxlen;
-
- public int Totalentries;
-
- public int ResumeHandle;
-
- public ShareEnumAll(string servername,
- int level,
- NdrObject info,
- int prefmaxlen,
- int totalentries,
- int resumeHandle)
- {
- this.Servername = servername;
- this.Level = level;
- this.Info = info;
- this.Prefmaxlen = prefmaxlen;
- this.Totalentries = totalentries;
- this.ResumeHandle = resumeHandle;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(Servername, 1);
- if (Servername != null)
- {
- dst.Enc_ndr_string(Servername);
- }
- dst.Enc_ndr_long(Level);
- int descr = Level;
- dst.Enc_ndr_long(descr);
- dst.Enc_ndr_referent(Info, 1);
- if (Info != null)
- {
- dst = dst.Deferred;
- Info.Encode(dst);
- }
- dst.Enc_ndr_long(Prefmaxlen);
- dst.Enc_ndr_long(ResumeHandle);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- Level = src.Dec_ndr_long();
- src.Dec_ndr_long();
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- if (Info == null)
- {
- Info = new ShareInfoCtr0();
- }
- src = src.Deferred;
- Info.Decode(src);
- }
- Totalentries = src.Dec_ndr_long();
- ResumeHandle = src.Dec_ndr_long();
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class ShareGetInfo : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x10);
- }
-
- public int Retval;
-
- public string Servername;
-
- public string Sharename;
-
- public int Level;
-
- public NdrObject Info;
-
- public ShareGetInfo(string servername, string sharename, int level, NdrObject info)
- {
- this.Servername = servername;
- this.Sharename = sharename;
- this.Level = level;
- this.Info = info;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(Servername, 1);
- if (Servername != null)
- {
- dst.Enc_ndr_string(Servername);
- }
- dst.Enc_ndr_string(Sharename);
- dst.Enc_ndr_long(Level);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- src.Dec_ndr_long();
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- if (Info == null)
- {
- Info = new ShareInfo0();
- }
- src = src.Deferred;
- Info.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class ServerInfo100 : NdrObject
- {
- public int PlatformId;
-
- public string Name;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(PlatformId);
- dst.Enc_ndr_referent(Name, 1);
- if (Name != null)
- {
- dst = dst.Deferred;
- dst.Enc_ndr_string(Name);
- }
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- PlatformId = src.Dec_ndr_long();
- int namep = src.Dec_ndr_long();
- if (namep != 0)
- {
- src = src.Deferred;
- Name = src.Dec_ndr_string();
- }
- }
- }
-
- public class ServerGetInfo : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x15);
- }
-
- public int Retval;
-
- public string Servername;
-
- public int Level;
-
- public NdrObject Info;
-
- public ServerGetInfo(string servername, int level, NdrObject info)
- {
- this.Servername = servername;
- this.Level = level;
- this.Info = info;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(Servername, 1);
- if (Servername != null)
- {
- dst.Enc_ndr_string(Servername);
- }
- dst.Enc_ndr_long(Level);
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- src.Dec_ndr_long();
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- if (Info == null)
- {
- Info = new ServerInfo100();
- }
- src = src.Deferred;
- Info.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
-
- public class TimeOfDayInfo : NdrObject
- {
- public int Elapsedt;
-
- public int Msecs;
-
- public int Hours;
-
- public int Mins;
-
- public int Secs;
-
- public int Hunds;
-
- public int Timezone;
-
- public int Tinterval;
-
- public int Day;
-
- public int Month;
-
- public int Year;
-
- public int Weekday;
-
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Align(4);
- dst.Enc_ndr_long(Elapsedt);
- dst.Enc_ndr_long(Msecs);
- dst.Enc_ndr_long(Hours);
- dst.Enc_ndr_long(Mins);
- dst.Enc_ndr_long(Secs);
- dst.Enc_ndr_long(Hunds);
- dst.Enc_ndr_long(Timezone);
- dst.Enc_ndr_long(Tinterval);
- dst.Enc_ndr_long(Day);
- dst.Enc_ndr_long(Month);
- dst.Enc_ndr_long(Year);
- dst.Enc_ndr_long(Weekday);
- }
-
- ///
- public override void Decode(NdrBuffer src)
- {
- src.Align(4);
- Elapsedt = src.Dec_ndr_long();
- Msecs = src.Dec_ndr_long();
- Hours = src.Dec_ndr_long();
- Mins = src.Dec_ndr_long();
- Secs = src.Dec_ndr_long();
- Hunds = src.Dec_ndr_long();
- Timezone = src.Dec_ndr_long();
- Tinterval = src.Dec_ndr_long();
- Day = src.Dec_ndr_long();
- Month = src.Dec_ndr_long();
- Year = src.Dec_ndr_long();
- Weekday = src.Dec_ndr_long();
- }
- }
-
- public class RemoteTod : DcerpcMessage
- {
- public override int GetOpnum()
- {
- return unchecked(0x1c);
- }
-
- public int Retval;
-
- public string Servername;
-
- public TimeOfDayInfo Info;
-
- public RemoteTod(string servername, TimeOfDayInfo info)
- {
- this.Servername = servername;
- this.Info = info;
- }
-
- ///
- public override void Encode_in(NdrBuffer dst)
- {
- dst.Enc_ndr_referent(Servername, 1);
- if (Servername != null)
- {
- dst.Enc_ndr_string(Servername);
- }
- }
-
- ///
- public override void Decode_out(NdrBuffer src)
- {
- int infop = src.Dec_ndr_long();
- if (infop != 0)
- {
- if (Info == null)
- {
- Info = new TimeOfDayInfo();
- }
- Info.Decode(src);
- }
- Retval = src.Dec_ndr_long();
- }
- }
- }
+ public class Srvsvc
+ {
+ public static string GetSyntax()
+ {
+ return "4b324fc8-1670-01d3-1278-5a47bf6ee188:3.0";
+ }
+
+ public class ShareInfo0 : NdrObject
+ {
+ public string Netname;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(Netname, 1);
+ if (Netname != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Netname);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int netnamep = src.Dec_ndr_long();
+ if (netnamep != 0)
+ {
+ src = src.Deferred;
+ Netname = src.Dec_ndr_string();
+ }
+ }
+ }
+
+ public class ShareInfoCtr0 : NdrObject
+ {
+ public int Count;
+
+ public ShareInfo0[] Array;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Array, 1);
+ if (Array != null)
+ {
+ dst = dst.Deferred;
+ int arrays = Count;
+ dst.Enc_ndr_long(arrays);
+ int arrayi = dst.Index;
+ dst.Advance(4 * arrays);
+ dst = dst.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ Array[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int arrayp = src.Dec_ndr_long();
+ if (arrayp != 0)
+ {
+ src = src.Deferred;
+ int arrays = src.Dec_ndr_long();
+ int arrayi = src.Index;
+ src.Advance(4 * arrays);
+ if (Array == null)
+ {
+ if (arrays < 0 || arrays > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Array = new ShareInfo0[arrays];
+ }
+ src = src.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ if (Array[i] == null)
+ {
+ Array[i] = new ShareInfo0();
+ }
+ Array[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class ShareInfo1 : NdrObject
+ {
+ public string Netname;
+
+ public int Type;
+
+ public string Remark;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(Netname, 1);
+ dst.Enc_ndr_long(Type);
+ dst.Enc_ndr_referent(Remark, 1);
+ if (Netname != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Netname);
+ }
+ if (Remark != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Remark);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int netnamep = src.Dec_ndr_long();
+ Type = src.Dec_ndr_long();
+ int remarkp = src.Dec_ndr_long();
+ if (netnamep != 0)
+ {
+ src = src.Deferred;
+ Netname = src.Dec_ndr_string();
+ }
+ if (remarkp != 0)
+ {
+ src = src.Deferred;
+ Remark = src.Dec_ndr_string();
+ }
+ }
+ }
+
+ public class ShareInfoCtr1 : NdrObject
+ {
+ public int Count;
+
+ public ShareInfo1[] Array;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Array, 1);
+ if (Array != null)
+ {
+ dst = dst.Deferred;
+ int arrays = Count;
+ dst.Enc_ndr_long(arrays);
+ int arrayi = dst.Index;
+ dst.Advance(12 * arrays);
+ dst = dst.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ Array[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int arrayp = src.Dec_ndr_long();
+ if (arrayp != 0)
+ {
+ src = src.Deferred;
+ int arrays = src.Dec_ndr_long();
+ int arrayi = src.Index;
+ src.Advance(12 * arrays);
+ if (Array == null)
+ {
+ if (arrays < 0 || arrays > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Array = new ShareInfo1[arrays];
+ }
+ src = src.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ if (Array[i] == null)
+ {
+ Array[i] = new ShareInfo1();
+ }
+ Array[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class ShareInfo502 : NdrObject
+ {
+ public string Netname;
+
+ public int Type;
+
+ public string Remark;
+
+ public int Permissions;
+
+ public int MaxUses;
+
+ public int CurrentUses;
+
+ public string Path;
+
+ public string Password;
+
+ public int SdSize;
+
+ public byte[] SecurityDescriptor;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_referent(Netname, 1);
+ dst.Enc_ndr_long(Type);
+ dst.Enc_ndr_referent(Remark, 1);
+ dst.Enc_ndr_long(Permissions);
+ dst.Enc_ndr_long(MaxUses);
+ dst.Enc_ndr_long(CurrentUses);
+ dst.Enc_ndr_referent(Path, 1);
+ dst.Enc_ndr_referent(Password, 1);
+ dst.Enc_ndr_long(SdSize);
+ dst.Enc_ndr_referent(SecurityDescriptor, 1);
+ if (Netname != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Netname);
+ }
+ if (Remark != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Remark);
+ }
+ if (Path != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Path);
+ }
+ if (Password != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Password);
+ }
+ if (SecurityDescriptor != null)
+ {
+ dst = dst.Deferred;
+ int securityDescriptors = SdSize;
+ dst.Enc_ndr_long(securityDescriptors);
+ int securityDescriptori = dst.Index;
+ dst.Advance(1 * securityDescriptors);
+ dst = dst.Derive(securityDescriptori);
+ for (int i = 0; i < securityDescriptors; i++)
+ {
+ dst.Enc_ndr_small(SecurityDescriptor[i]);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ int netnamep = src.Dec_ndr_long();
+ Type = src.Dec_ndr_long();
+ int remarkp = src.Dec_ndr_long();
+ Permissions = src.Dec_ndr_long();
+ MaxUses = src.Dec_ndr_long();
+ CurrentUses = src.Dec_ndr_long();
+ int pathp = src.Dec_ndr_long();
+ int passwordp = src.Dec_ndr_long();
+ SdSize = src.Dec_ndr_long();
+ int securityDescriptorp = src.Dec_ndr_long();
+ if (netnamep != 0)
+ {
+ src = src.Deferred;
+ Netname = src.Dec_ndr_string();
+ }
+ if (remarkp != 0)
+ {
+ src = src.Deferred;
+ Remark = src.Dec_ndr_string();
+ }
+ if (pathp != 0)
+ {
+ src = src.Deferred;
+ Path = src.Dec_ndr_string();
+ }
+ if (passwordp != 0)
+ {
+ src = src.Deferred;
+ Password = src.Dec_ndr_string();
+ }
+ if (securityDescriptorp != 0)
+ {
+ src = src.Deferred;
+ int securityDescriptors = src.Dec_ndr_long();
+ int securityDescriptori = src.Index;
+ src.Advance(1 * securityDescriptors);
+ if (SecurityDescriptor == null)
+ {
+ if (securityDescriptors < 0 || securityDescriptors > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ SecurityDescriptor = new byte[securityDescriptors];
+ }
+ src = src.Derive(securityDescriptori);
+ for (int i = 0; i < securityDescriptors; i++)
+ {
+ SecurityDescriptor[i] = unchecked((byte)src.Dec_ndr_small());
+ }
+ }
+ }
+ }
+
+ public class ShareInfoCtr502 : NdrObject
+ {
+ public int Count;
+
+ public ShareInfo502[] Array;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Count);
+ dst.Enc_ndr_referent(Array, 1);
+ if (Array != null)
+ {
+ dst = dst.Deferred;
+ int arrays = Count;
+ dst.Enc_ndr_long(arrays);
+ int arrayi = dst.Index;
+ dst.Advance(40 * arrays);
+ dst = dst.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ Array[i].Encode(dst);
+ }
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Count = src.Dec_ndr_long();
+ int arrayp = src.Dec_ndr_long();
+ if (arrayp != 0)
+ {
+ src = src.Deferred;
+ int arrays = src.Dec_ndr_long();
+ int arrayi = src.Index;
+ src.Advance(40 * arrays);
+ if (Array == null)
+ {
+ if (arrays < 0 || arrays > unchecked(0xFFFF))
+ {
+ throw new NdrException(NdrException.InvalidConformance);
+ }
+ Array = new ShareInfo502[arrays];
+ }
+ src = src.Derive(arrayi);
+ for (int i = 0; i < arrays; i++)
+ {
+ if (Array[i] == null)
+ {
+ Array[i] = new ShareInfo502();
+ }
+ Array[i].Decode(src);
+ }
+ }
+ }
+ }
+
+ public class ShareEnumAll : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x0f);
+ }
+
+ public int Retval;
+
+ public string Servername;
+
+ public int Level;
+
+ public NdrObject Info;
+
+ public int Prefmaxlen;
+
+ public int Totalentries;
+
+ public int ResumeHandle;
+
+ public ShareEnumAll(string servername, int level, NdrObject info, int prefmaxlen,
+ int totalentries, int resumeHandle)
+ {
+ this.Servername = servername;
+ this.Level = level;
+ this.Info = info;
+ this.Prefmaxlen = prefmaxlen;
+ this.Totalentries = totalentries;
+ this.ResumeHandle = resumeHandle;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(Servername, 1);
+ if (Servername != null)
+ {
+ dst.Enc_ndr_string(Servername);
+ }
+ dst.Enc_ndr_long(Level);
+ int descr = Level;
+ dst.Enc_ndr_long(descr);
+ dst.Enc_ndr_referent(Info, 1);
+ if (Info != null)
+ {
+ dst = dst.Deferred;
+ Info.Encode(dst);
+ }
+ dst.Enc_ndr_long(Prefmaxlen);
+ dst.Enc_ndr_long(ResumeHandle);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ Level = src.Dec_ndr_long();
+ src.Dec_ndr_long();
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ if (Info == null)
+ {
+ Info = new ShareInfoCtr0();
+ }
+ src = src.Deferred;
+ Info.Decode(src);
+ }
+ Totalentries = src.Dec_ndr_long();
+ ResumeHandle = src.Dec_ndr_long();
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class ShareGetInfo : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x10);
+ }
+
+ public int Retval;
+
+ public string Servername;
+
+ public string Sharename;
+
+ public int Level;
+
+ public NdrObject Info;
+
+ public ShareGetInfo(string servername, string sharename, int level, NdrObject info
+ )
+ {
+ this.Servername = servername;
+ this.Sharename = sharename;
+ this.Level = level;
+ this.Info = info;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(Servername, 1);
+ if (Servername != null)
+ {
+ dst.Enc_ndr_string(Servername);
+ }
+ dst.Enc_ndr_string(Sharename);
+ dst.Enc_ndr_long(Level);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ src.Dec_ndr_long();
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ if (Info == null)
+ {
+ Info = new ShareInfo0();
+ }
+ src = src.Deferred;
+ Info.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class ServerInfo100 : NdrObject
+ {
+ public int PlatformId;
+
+ public string Name;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(PlatformId);
+ dst.Enc_ndr_referent(Name, 1);
+ if (Name != null)
+ {
+ dst = dst.Deferred;
+ dst.Enc_ndr_string(Name);
+ }
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ PlatformId = src.Dec_ndr_long();
+ int namep = src.Dec_ndr_long();
+ if (namep != 0)
+ {
+ src = src.Deferred;
+ Name = src.Dec_ndr_string();
+ }
+ }
+ }
+
+ public class ServerGetInfo : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x15);
+ }
+
+ public int Retval;
+
+ public string Servername;
+
+ public int Level;
+
+ public NdrObject Info;
+
+ public ServerGetInfo(string servername, int level, NdrObject info)
+ {
+ this.Servername = servername;
+ this.Level = level;
+ this.Info = info;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(Servername, 1);
+ if (Servername != null)
+ {
+ dst.Enc_ndr_string(Servername);
+ }
+ dst.Enc_ndr_long(Level);
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ src.Dec_ndr_long();
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ if (Info == null)
+ {
+ Info = new ServerInfo100();
+ }
+ src = src.Deferred;
+ Info.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+
+ public class TimeOfDayInfo : NdrObject
+ {
+ public int Elapsedt;
+
+ public int Msecs;
+
+ public int Hours;
+
+ public int Mins;
+
+ public int Secs;
+
+ public int Hunds;
+
+ public int Timezone;
+
+ public int Tinterval;
+
+ public int Day;
+
+ public int Month;
+
+ public int Year;
+
+ public int Weekday;
+
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Align(4);
+ dst.Enc_ndr_long(Elapsedt);
+ dst.Enc_ndr_long(Msecs);
+ dst.Enc_ndr_long(Hours);
+ dst.Enc_ndr_long(Mins);
+ dst.Enc_ndr_long(Secs);
+ dst.Enc_ndr_long(Hunds);
+ dst.Enc_ndr_long(Timezone);
+ dst.Enc_ndr_long(Tinterval);
+ dst.Enc_ndr_long(Day);
+ dst.Enc_ndr_long(Month);
+ dst.Enc_ndr_long(Year);
+ dst.Enc_ndr_long(Weekday);
+ }
+
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ src.Align(4);
+ Elapsedt = src.Dec_ndr_long();
+ Msecs = src.Dec_ndr_long();
+ Hours = src.Dec_ndr_long();
+ Mins = src.Dec_ndr_long();
+ Secs = src.Dec_ndr_long();
+ Hunds = src.Dec_ndr_long();
+ Timezone = src.Dec_ndr_long();
+ Tinterval = src.Dec_ndr_long();
+ Day = src.Dec_ndr_long();
+ Month = src.Dec_ndr_long();
+ Year = src.Dec_ndr_long();
+ Weekday = src.Dec_ndr_long();
+ }
+ }
+
+ public class RemoteTod : DcerpcMessage
+ {
+ public override int GetOpnum()
+ {
+ return unchecked(0x1c);
+ }
+
+ public int Retval;
+
+ public string Servername;
+
+ public TimeOfDayInfo Info;
+
+ public RemoteTod(string servername, TimeOfDayInfo info)
+ {
+ this.Servername = servername;
+ this.Info = info;
+ }
+
+ ///
+ public override void Encode_in(NdrBuffer dst)
+ {
+ dst.Enc_ndr_referent(Servername, 1);
+ if (Servername != null)
+ {
+ dst.Enc_ndr_string(Servername);
+ }
+ }
+
+ ///
+ public override void Decode_out(NdrBuffer src)
+ {
+ int infop = src.Dec_ndr_long();
+ if (infop != 0)
+ {
+ if (Info == null)
+ {
+ Info = new TimeOfDayInfo();
+ }
+ Info.Decode(src);
+ }
+ Retval = src.Dec_ndr_long();
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs
index 9ce6360a2..0a47de799 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs
@@ -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);
+ }
- ///
- 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;
- }
+ ///
+ 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();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs
index 2c1e341d5..7757735f8 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs
@@ -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)
+ {
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs
index 57c9ad6e0..9e2932337 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs
@@ -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;
+ }
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Enc_ndr_hyper(Value);
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Enc_ndr_hyper(Value);
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- Value = src.Dec_ndr_hyper();
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ Value = src.Dec_ndr_hyper();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs
index 8a3ef1ae5..74d90465e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs
@@ -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;
+ }
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Enc_ndr_long(Value);
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Enc_ndr_long(Value);
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- Value = src.Dec_ndr_long();
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ Value = src.Dec_ndr_long();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs
index 84cc54251..8951fa202 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs
@@ -16,12 +16,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Dcerpc.Ndr
{
- public abstract class NdrObject
- {
- ///
- public abstract void Encode(NdrBuffer dst);
+ public abstract class NdrObject
+ {
+ ///
+ public abstract void Encode(NdrBuffer dst);
- ///
- public abstract void Decode(NdrBuffer src);
- }
+ ///
+ public abstract void Decode(NdrBuffer src);
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs
index db50de2dd..e2ea8c65b 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs
@@ -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);
+ }
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Enc_ndr_short(Value);
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Enc_ndr_short(Value);
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- Value = src.Dec_ndr_short();
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ Value = src.Dec_ndr_short();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs
index 121f7e5d8..8309dea66 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs
@@ -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);
+ }
- ///
- public override void Encode(NdrBuffer dst)
- {
- dst.Enc_ndr_small(Value);
- }
+ ///
+ public override void Encode(NdrBuffer dst)
+ {
+ dst.Enc_ndr_small(Value);
+ }
- ///
- public override void Decode(NdrBuffer src)
- {
- Value = src.Dec_ndr_small();
- }
- }
+ ///
+ public override void Decode(NdrBuffer src)
+ {
+ Value = src.Dec_ndr_small();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs
index 51d3bf2ae..aa33d3522 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs
@@ -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;
- ///
- 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]);
- }
- }
+ ///
+ 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]);
+ }
+ }
- ///
- 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 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;
- ///
- 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]);
- }
- }
+ ///
+ 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]);
+ }
+ }
- ///
- 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 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;
- ///
- 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]);
- }
- }
- }
+ ///
+ 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]);
+ }
+ }
+ }
- ///
- 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 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;
- ///
- 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]);
- }
- }
+ ///
+ 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]);
+ }
+ }
- ///
- 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();
- }
- }
- }
- }
+ ///
+ 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();
+ }
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UUID.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UUID.cs
index b9965711b..bef4be214 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UUID.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UUID.cs
@@ -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);
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs
index 4eddce21d..b0c36898c 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs
@@ -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);
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/Lmhosts.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/Lmhosts.cs
index 7d8dd8bbf..c94d0a260 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/Lmhosts.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/Lmhosts.cs
@@ -21,181 +21,182 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- public class Lmhosts
- {
- private static readonly string Filename = Config.GetProperty("jcifs.netbios.lmhosts");
+ public class Lmhosts
+ {
+ private static readonly string Filename = Config.GetProperty("jcifs.netbios.lmhosts"
+ );
- private static readonly Hashtable Tab = new Hashtable();
+ private static readonly Hashtable Tab = new Hashtable();
- private static long _lastModified = 1L;
+ private static long _lastModified = 1L;
- private static int _alt;
+ private static int _alt;
- private static LogStream _log = LogStream.GetInstance();
+ private static LogStream _log = LogStream.GetInstance();
- ///
- /// This is really just for
- /// Jcifs.UniAddress
- /// . It does
- /// not throw an
- /// Sharpen.UnknownHostException
- /// because this
- /// is queried frequently and exceptions would be rather costly to
- /// throw on a regular basis here.
- ///
- public static NbtAddress GetByName(string host)
- {
- lock (typeof(Lmhosts))
- {
- return GetByName(new Name(host, 0x20, null));
- }
- }
+ ///
+ /// This is really just for
+ /// Jcifs.UniAddress
+ /// . It does
+ /// not throw an
+ /// Sharpen.UnknownHostException
+ /// because this
+ /// is queried frequently and exceptions would be rather costly to
+ /// throw on a regular basis here.
+ ///
+ public static NbtAddress GetByName(string host)
+ {
+ lock (typeof(Lmhosts))
+ {
+ return GetByName(new Name(host, 0x20, null));
+ }
+ }
- internal static NbtAddress GetByName(Name name)
- {
- lock (typeof(Lmhosts))
- {
- NbtAddress result = null;
- try
- {
- if (Filename != null)
- {
- FilePath f = new FilePath(Filename);
- long lm;
- if ((lm = f.LastModified()) > _lastModified)
- {
- _lastModified = lm;
- Tab.Clear();
- _alt = 0;
-
- //path -> fileStream
- //Populate(new FileReader(f));
+ internal static NbtAddress GetByName(Name name)
+ {
+ lock (typeof(Lmhosts))
+ {
+ NbtAddress result = null;
+ try
+ {
+ if (Filename != null)
+ {
+ FilePath f = new FilePath(Filename);
+ long lm;
+ if ((lm = f.LastModified()) > _lastModified)
+ {
+ _lastModified = lm;
+ Tab.Clear();
+ _alt = 0;
+
+ //path -> fileStream
+ //Populate(new FileReader(f));
Populate(new FileReader(new FileStream(f, FileMode.Open)));
- }
- result = (NbtAddress)Tab[name];
- }
- }
- catch (FileNotFoundException fnfe)
- {
- if (_log.Level > 1)
- {
- _log.WriteLine("lmhosts file: " + Filename);
- Runtime.PrintStackTrace(fnfe, _log);
- }
- }
- catch (IOException ioe)
- {
- if (_log.Level > 0)
- {
- Runtime.PrintStackTrace(ioe, _log);
- }
- }
- return result;
- }
- }
+ }
+ result = (NbtAddress)Tab[name];
+ }
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ if (_log.Level > 1)
+ {
+ _log.WriteLine("lmhosts file: " + Filename);
+ Runtime.PrintStackTrace(fnfe, _log);
+ }
+ }
+ catch (IOException ioe)
+ {
+ if (_log.Level > 0)
+ {
+ Runtime.PrintStackTrace(ioe, _log);
+ }
+ }
+ return result;
+ }
+ }
- ///
- internal static void Populate(StreamReader r)
- {
- string line;
+ ///
+ internal static void Populate(StreamReader r)
+ {
+ string line;
BufferedReader br = new BufferedReader((InputStreamReader)r);
- while ((line = br.ReadLine()) != null)
- {
- line = line.ToUpper().Trim();
- if (line.Length == 0)
- {
- }
- else
- {
- if (line[0] == '#')
- {
- if (line.StartsWith("#INCLUDE "))
- {
- line = Runtime.Substring(line, line.IndexOf('\\'));
- string url = "smb:" + line.Replace('\\', '/');
- if (_alt > 0)
- {
- try
- {
- Populate(new InputStreamReader(new SmbFileInputStream(url)));
- }
- catch (IOException ioe)
- {
- _log.WriteLine("lmhosts URL: " + url);
- Runtime.PrintStackTrace(ioe, _log);
- continue;
- }
- _alt--;
- while ((line = br.ReadLine()) != null)
- {
- line = line.ToUpper().Trim();
- if (line.StartsWith("#END_ALTERNATE"))
- {
- break;
- }
- }
- }
- else
- {
- Populate(new InputStreamReader(new SmbFileInputStream(url)));
- }
- }
- else
- {
- if (line.StartsWith("#BEGIN_ALTERNATE"))
- {
- _alt++;
- }
- else
- {
- if (line.StartsWith("#END_ALTERNATE") && _alt > 0)
- {
- _alt--;
- throw new IOException("no lmhosts alternate includes loaded");
- }
- }
- }
- }
- else
- {
- if (char.IsDigit(line[0]))
- {
- char[] data = line.ToCharArray();
- int ip;
- int i;
- int j;
- Name name;
- NbtAddress addr;
- char c;
- c = '.';
- ip = i = 0;
- for (; i < data.Length && c == '.'; i++)
- {
- int b = unchecked(0x00);
- for (; i < data.Length && (c = data[i]) >= 48 && c <= 57; i++)
- {
- b = b * 10 + c - '0';
- }
- ip = (ip << 8) + b;
- }
- while (i < data.Length && char.IsWhiteSpace(data[i]))
- {
- i++;
- }
- j = i;
- while (j < data.Length && char.IsWhiteSpace(data[j]) == false)
- {
- j++;
- }
- name = new Name(Runtime.Substring(line, i, j), unchecked(0x20), null
- );
- addr = new NbtAddress(name, ip, false, NbtAddress.BNode, false, false, true, true
- , NbtAddress.UnknownMacAddress);
- Tab.Put(name, addr);
- }
- }
- }
- }
- }
- }
+ while ((line = br.ReadLine()) != null)
+ {
+ line = line.ToUpper().Trim();
+ if (line.Length == 0)
+ {
+ }
+ else
+ {
+ if (line[0] == '#')
+ {
+ if (line.StartsWith("#INCLUDE "))
+ {
+ line = Runtime.Substring(line, line.IndexOf('\\'));
+ string url = "smb:" + line.Replace('\\', '/');
+ if (_alt > 0)
+ {
+ try
+ {
+ Populate(new InputStreamReader(new SmbFileInputStream(url)));
+ }
+ catch (IOException ioe)
+ {
+ _log.WriteLine("lmhosts URL: " + url);
+ Runtime.PrintStackTrace(ioe, _log);
+ continue;
+ }
+ _alt--;
+ while ((line = br.ReadLine()) != null)
+ {
+ line = line.ToUpper().Trim();
+ if (line.StartsWith("#END_ALTERNATE"))
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ Populate(new InputStreamReader(new SmbFileInputStream(url)));
+ }
+ }
+ else
+ {
+ if (line.StartsWith("#BEGIN_ALTERNATE"))
+ {
+ _alt++;
+ }
+ else
+ {
+ if (line.StartsWith("#END_ALTERNATE") && _alt > 0)
+ {
+ _alt--;
+ throw new IOException("no lmhosts alternate includes loaded");
+ }
+ }
+ }
+ }
+ else
+ {
+ if (char.IsDigit(line[0]))
+ {
+ char[] data = line.ToCharArray();
+ int ip;
+ int i;
+ int j;
+ Name name;
+ NbtAddress addr;
+ char c;
+ c = '.';
+ ip = i = 0;
+ for (; i < data.Length && c == '.'; i++)
+ {
+ int b = unchecked(0x00);
+ for (; i < data.Length && (c = data[i]) >= 48 && c <= 57; i++)
+ {
+ b = b * 10 + c - '0';
+ }
+ ip = (ip << 8) + b;
+ }
+ while (i < data.Length && char.IsWhiteSpace(data[i]))
+ {
+ i++;
+ }
+ j = i;
+ while (j < data.Length && char.IsWhiteSpace(data[j]) == false)
+ {
+ j++;
+ }
+ name = new Name(Runtime.Substring(line, i, j), unchecked(0x20), null
+ );
+ addr = new NbtAddress(name, ip, false, NbtAddress.BNode, false, false, true, true
+ , NbtAddress.UnknownMacAddress);
+ Tab.Put(name, addr);
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/Name.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/Name.cs
index 4166e1af8..6c37d57a4 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/Name.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/Name.cs
@@ -21,110 +21,102 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- public class Name
- {
- private const int TypeOffset = 31;
+ public class Name
+ {
+ private const int TypeOffset = 31;
- private const int ScopeOffset = 33;
+ private const int ScopeOffset = 33;
- private static readonly string DefaultScope
- = Config.GetProperty("jcifs.netbios.scope");
+ private static readonly string DefaultScope = Config.GetProperty("jcifs.netbios.scope"
+ );
- internal static readonly string OemEncoding
- = Config.GetProperty("jcifs.encoding", Runtime.GetProperty("file.encoding"));
+ internal static readonly string OemEncoding = Config.GetProperty("jcifs.encoding"
+ , Runtime.GetProperty("file.encoding"));
- public string name;
+ public string name;
- public string Scope;
+ public string Scope;
- public int HexCode;
+ public int HexCode;
- internal int SrcHashCode;
+ internal int SrcHashCode;
- public Name()
- {
- }
+ public Name()
+ {
+ }
- public Name(string name, int hexCode, string scope)
- {
- if (name.Length > 15)
- {
- name = Runtime.Substring(name, 0, 15);
- }
- this.name = name.ToUpper();
- this.HexCode = hexCode;
- this.Scope = !string.IsNullOrEmpty(scope) ? scope : DefaultScope;
- SrcHashCode = 0;
- }
+ public Name(string name, int hexCode, string scope)
+ {
+ if (name.Length > 15)
+ {
+ name = Runtime.Substring(name, 0, 15);
+ }
+ this.name = name.ToUpper();
+ this.HexCode = hexCode;
+ this.Scope = !string.IsNullOrEmpty(scope) ? scope : DefaultScope;
+ SrcHashCode = 0;
+ }
- internal virtual int WriteWireFormat(byte[] dst, int dstIndex)
- {
- // write 0x20 in first byte
- dst[dstIndex] = unchecked(0x20);
- // write name
- try
- {
- byte[] tmp = Runtime.GetBytesForString(name, OemEncoding
- );
- int i;
- for (i = 0; i < tmp.Length; i++)
- {
- dst[dstIndex + (2 * i + 1)]
- = unchecked((byte)(((tmp[i] & unchecked(0xF0)) >> 4) + unchecked(0x41)));
- dst[dstIndex + (2 * i + 2)]
- = unchecked((byte)((tmp[i] & unchecked(0x0F)) + unchecked(0x41)));
- }
- for (; i < 15; i++)
- {
- dst[dstIndex + (2 * i + 1)] = unchecked(unchecked(0x43));
- dst[dstIndex + (2 * i + 2)] = unchecked(unchecked(0x41));
- }
- dst[dstIndex + TypeOffset]
- = unchecked((byte)(((HexCode & unchecked(0xF0)) >> 4) + unchecked(0x41)));
- dst[dstIndex + TypeOffset + 1]
- = unchecked((byte)((HexCode & unchecked(0x0F)) + unchecked(0x41)));
- }
- catch (UnsupportedEncodingException)
- {
- }
- return ScopeOffset + WriteScopeWireFormat(dst, dstIndex + ScopeOffset);
- }
+ internal virtual int WriteWireFormat(byte[] dst, int dstIndex)
+ {
+ // write 0x20 in first byte
+ dst[dstIndex] = unchecked(0x20);
+ // write name
+ try
+ {
+ byte[] tmp = Runtime.GetBytesForString(name, OemEncoding
+ );
+ int i;
+ for (i = 0; i < tmp.Length; i++)
+ {
+ dst[dstIndex + (2 * i + 1)] = unchecked((byte)(((tmp[i] & unchecked(0xF0))
+ >> 4) + unchecked(0x41)));
+ dst[dstIndex + (2 * i + 2)] = unchecked((byte)((tmp[i] & unchecked(0x0F))
+ + unchecked(0x41)));
+ }
+ for (; i < 15; i++)
+ {
+ dst[dstIndex + (2 * i + 1)] = unchecked(unchecked(0x43));
+ dst[dstIndex + (2 * i + 2)] = unchecked(unchecked(0x41));
+ }
+ dst[dstIndex + TypeOffset] = unchecked((byte)(((HexCode & unchecked(0xF0)
+ ) >> 4) + unchecked(0x41)));
+ dst[dstIndex + TypeOffset + 1] = unchecked((byte)((HexCode & unchecked(0x0F)) + unchecked(0x41)));
+ }
+ catch (UnsupportedEncodingException)
+ {
+ }
+ return ScopeOffset + WriteScopeWireFormat(dst, dstIndex + ScopeOffset);
+ }
- internal virtual int ReadWireFormat(byte[] src, int srcIndex)
- {
- byte[] tmp = new byte[ScopeOffset];
- int length = 15;
- for (int i = 0; i < 15; i++)
- {
- tmp[i] = unchecked(
- (byte)(
- ((src[srcIndex + (2 * i + 1)] & unchecked(0xFF)) - unchecked(0x41)) << 4
- )
- );
- tmp[i] |= unchecked(
- (byte)(
- ((src[srcIndex + (2 * i + 2)] & unchecked(0xFF)) - unchecked(0x41))
- & unchecked(0x0F)
- )
- );
- if (tmp[i] != unchecked((byte)' '))
- {
- length = i + 1;
- }
- }
- try
- {
- name = Runtime.GetStringForBytes(tmp, 0, length, OemEncoding
- );
- }
- catch (UnsupportedEncodingException)
- {
- }
- HexCode = ((src[srcIndex + TypeOffset] & unchecked(0xFF)) - unchecked(0x41)) << 4;
- HexCode |= ((src[srcIndex + TypeOffset + 1] & unchecked(0xFF)) - unchecked(0x41))
- & unchecked(0x0F);
- return ScopeOffset + ReadScopeWireFormat(src, srcIndex + ScopeOffset);
- }
+ internal virtual int ReadWireFormat(byte[] src, int srcIndex)
+ {
+ byte[] tmp = new byte[ScopeOffset];
+ int length = 15;
+ for (int i = 0; i < 15; i++)
+ {
+ tmp[i] = unchecked((byte)(((src[srcIndex + (2 * i + 1)] & unchecked(0xFF))
+ - unchecked(0x41)) << 4));
+ tmp[i] |= unchecked((byte)(((src[srcIndex + (2 * i + 2)] & unchecked(0xFF)
+ ) - unchecked(0x41)) & unchecked(0x0F)));
+ if (tmp[i] != unchecked((byte)' '))
+ {
+ length = i + 1;
+ }
+ }
+ try
+ {
+ name = Runtime.GetStringForBytes(tmp, 0, length, OemEncoding
+ );
+ }
+ catch (UnsupportedEncodingException)
+ {
+ }
+ HexCode = ((src[srcIndex + TypeOffset] & unchecked(0xFF)) - unchecked(0x41)) << 4;
+ HexCode |= ((src[srcIndex + TypeOffset + 1] & unchecked(0xFF)) - unchecked(
+ 0x41)) & unchecked(0x0F);
+ return ScopeOffset + ReadScopeWireFormat(src, srcIndex + ScopeOffset);
+ }
internal int ReadWireFormatDos(byte[] src, int srcIndex)
{
@@ -138,8 +130,9 @@ namespace SharpCifs.Netbios
{
name = Runtime.GetStringForBytes(tmp, 0, length).Trim();
}
- catch (Exception)
+ catch (Exception ex)
{
+
}
HexCode = src[srcIndex + length];
@@ -148,129 +141,129 @@ namespace SharpCifs.Netbios
}
- internal virtual int WriteScopeWireFormat(byte[] dst, int dstIndex)
- {
- if (Scope == null)
- {
- dst[dstIndex] = unchecked(unchecked(0x00));
- return 1;
- }
- // copy new scope in
- dst[dstIndex++] = unchecked((byte)('.'));
- try
- {
- Array.Copy(Runtime.GetBytesForString(Scope, OemEncoding),
- 0, dst, dstIndex, Scope.Length);
- }
- catch (UnsupportedEncodingException)
- {
- }
- dstIndex += Scope.Length;
- dst[dstIndex++] = unchecked(unchecked(0x00));
- // now go over scope backwards converting '.' to label length
- int i = dstIndex - 2;
- int e = i - Scope.Length;
- int c = 0;
- do
- {
- if (dst[i] == '.')
- {
- dst[i] = unchecked((byte)c);
- c = 0;
- }
- else
- {
- c++;
- }
- }
- while (i-- > e);
- return Scope.Length + 2;
- }
+ internal virtual int WriteScopeWireFormat(byte[] dst, int dstIndex)
+ {
+ if (Scope == null)
+ {
+ dst[dstIndex] = unchecked(unchecked(0x00));
+ return 1;
+ }
+ // copy new scope in
+ dst[dstIndex++] = unchecked((byte)('.'));
+ try
+ {
+ Array.Copy(Runtime.GetBytesForString(Scope, OemEncoding
+ ), 0, dst, dstIndex, Scope.Length);
+ }
+ catch (UnsupportedEncodingException)
+ {
+ }
+ dstIndex += Scope.Length;
+ dst[dstIndex++] = unchecked(unchecked(0x00));
+ // now go over scope backwards converting '.' to label length
+ int i = dstIndex - 2;
+ int e = i - Scope.Length;
+ int c = 0;
+ do
+ {
+ if (dst[i] == '.')
+ {
+ dst[i] = unchecked((byte)c);
+ c = 0;
+ }
+ else
+ {
+ c++;
+ }
+ }
+ while (i-- > e);
+ return Scope.Length + 2;
+ }
- internal virtual int ReadScopeWireFormat(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- int n;
- StringBuilder sb;
- if ((n = src[srcIndex++] & unchecked(0xFF)) == 0)
- {
- Scope = null;
- return 1;
- }
- try
- {
- sb = new StringBuilder(Runtime.GetStringForBytes(src, srcIndex, n, OemEncoding));
- srcIndex += n;
- while ((n = src[srcIndex++] & unchecked(0xFF)) != 0)
- {
- sb.Append('.').Append(Runtime.GetStringForBytes(src, srcIndex, n, OemEncoding));
- srcIndex += n;
- }
- Scope = sb.ToString();
- }
- catch (UnsupportedEncodingException)
- {
- }
- return srcIndex - start;
- }
+ internal virtual int ReadScopeWireFormat(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ int n;
+ StringBuilder sb;
+ if ((n = src[srcIndex++] & unchecked(0xFF)) == 0)
+ {
+ Scope = null;
+ return 1;
+ }
+ try
+ {
+ sb = new StringBuilder(Runtime.GetStringForBytes(src, srcIndex, n, OemEncoding));
+ srcIndex += n;
+ while ((n = src[srcIndex++] & unchecked(0xFF)) != 0)
+ {
+ sb.Append('.').Append(Runtime.GetStringForBytes(src, srcIndex, n, OemEncoding));
+ srcIndex += n;
+ }
+ Scope = sb.ToString();
+ }
+ catch (UnsupportedEncodingException)
+ {
+ }
+ return srcIndex - start;
+ }
- public override int GetHashCode()
- {
- int result;
- result = name.GetHashCode();
- result += 65599 * HexCode;
- result += 65599 * SrcHashCode;
- if (Scope != null && Scope.Length != 0)
- {
- result += Scope.GetHashCode();
- }
- return result;
- }
+ public override int GetHashCode()
+ {
+ int result;
+ result = name.GetHashCode();
+ result += 65599 * HexCode;
+ result += 65599 * SrcHashCode;
+ if (Scope != null && Scope.Length != 0)
+ {
+ result += Scope.GetHashCode();
+ }
+ return result;
+ }
- public override bool Equals(object obj)
- {
- Name n;
- if (!(obj is Name))
- {
- return false;
- }
- n = (Name)obj;
- if (Scope == null && n.Scope == null)
- {
- return name.Equals(n.name) && HexCode == n.HexCode;
- }
- return name.Equals(n.name) && HexCode == n.HexCode && Scope.Equals(n.Scope);
- }
+ public override bool Equals(object obj)
+ {
+ Name n;
+ if (!(obj is Name))
+ {
+ return false;
+ }
+ n = (Name)obj;
+ if (Scope == null && n.Scope == null)
+ {
+ return name.Equals(n.name) && HexCode == n.HexCode;
+ }
+ return name.Equals(n.name) && HexCode == n.HexCode && Scope.Equals(n.Scope);
+ }
- public override string ToString()
- {
- StringBuilder sb = new StringBuilder();
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
- //return "";
+ //return "";
- string n = name;
- // fix MSBROWSE name
- if (n == null)
- {
- n = "null";
- }
- else
- {
- if (n[0] == unchecked(0x01))
- {
- char[] c = n.ToCharArray();
- c[0] = '.';
- c[1] = '.';
- c[14] = '.';
- n = new string(c);
- }
- }
- sb.Append(n).Append("<").Append(Hexdump.ToHexString(HexCode, 2)).Append(">");
- if (Scope != null)
- {
- sb.Append(".").Append(Scope);
- }
- return sb.ToString();
- }
- }
+ string n = name;
+ // fix MSBROWSE name
+ if (n == null)
+ {
+ n = "null";
+ }
+ else
+ {
+ if (n[0] == unchecked(0x01))
+ {
+ char[] c = n.ToCharArray();
+ c[0] = '.';
+ c[1] = '.';
+ c[14] = '.';
+ n = new string(c);
+ }
+ }
+ sb.Append(n).Append("<").Append(Hexdump.ToHexString(HexCode, 2)).Append(">");
+ if (Scope != null)
+ {
+ sb.Append(".").Append(Scope);
+ }
+ return sb.ToString();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryRequest.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryRequest.cs
index 1e9419638..646e65bf8 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryRequest.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryRequest.cs
@@ -16,37 +16,37 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Netbios
{
- internal class NameQueryRequest : NameServicePacket
- {
- internal NameQueryRequest(Name name)
- {
- QuestionName = name;
- QuestionType = Nb;
- }
+ internal class NameQueryRequest : NameServicePacket
+ {
+ internal NameQueryRequest(Name name)
+ {
+ QuestionName = name;
+ QuestionType = Nb;
+ }
- internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
- {
- return WriteQuestionSectionWireFormat(dst, dstIndex);
- }
+ internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
+ {
+ return WriteQuestionSectionWireFormat(dst, dstIndex);
+ }
- internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
- {
- return ReadQuestionSectionWireFormat(src, srcIndex);
- }
+ internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
+ {
+ return ReadQuestionSectionWireFormat(src, srcIndex);
+ }
- internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
- {
- return 0;
- }
+ internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
+ {
+ return 0;
+ }
- public override string ToString()
- {
- return "NameQueryRequest[" + base.ToString() + "]";
- }
- }
+ public override string ToString()
+ {
+ return "NameQueryRequest[" + base.ToString() + "]";
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryResponse.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryResponse.cs
index 2285c6e7b..c7fac8e93 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryResponse.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameQueryResponse.cs
@@ -16,52 +16,53 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Netbios
{
- internal class NameQueryResponse : NameServicePacket
- {
- public NameQueryResponse()
- {
- RecordName = new Name();
- }
+ internal class NameQueryResponse : NameServicePacket
+ {
+ public NameQueryResponse()
+ {
+ RecordName = new Name();
+ }
- internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
- {
- return ReadResourceRecordWireFormat(src, srcIndex);
- }
+ internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
+ {
+ return ReadResourceRecordWireFormat(src, srcIndex);
+ }
- internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
- {
- if (ResultCode != 0 || OpCode != Query)
- {
- return 0;
- }
- bool groupName = ((src[srcIndex] & unchecked(0x80)) == unchecked(0x80)) ? true : false;
- int nodeType = (src[srcIndex] & unchecked(0x60)) >> 5;
- srcIndex += 2;
- int address = ReadInt4(src, srcIndex);
- if (address != 0)
- {
- AddrEntry[AddrIndex] = new NbtAddress(RecordName, address, groupName, nodeType);
- }
- else
- {
- AddrEntry[AddrIndex] = null;
- }
- return 6;
- }
+ internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
+ {
+ if (ResultCode != 0 || OpCode != Query)
+ {
+ return 0;
+ }
+ bool groupName = ((src[srcIndex] & unchecked(0x80)) == unchecked(0x80)) ? true : false;
+ int nodeType = (src[srcIndex] & unchecked(0x60)) >> 5;
+ srcIndex += 2;
+ int address = ReadInt4(src, srcIndex);
+ if (address != 0)
+ {
+ AddrEntry[AddrIndex] = new NbtAddress(RecordName, address, groupName, nodeType);
+ }
+ else
+ {
+ AddrEntry[AddrIndex] = null;
+ }
+ return 6;
+ }
- public override string ToString()
- {
- return "NameQueryResponse[" + base.ToString() + ",addrEntry=" + AddrEntry + "]";
- }
- }
+ public override string ToString()
+ {
+ return "NameQueryResponse[" + base.ToString() + ",addrEntry=" + AddrEntry
+ + "]";
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs
index fb74c691b..01700e64a 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServiceClient.cs
@@ -21,13 +21,10 @@ using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Threading;
-using SharpCifs.Smb;
using SharpCifs.Util;
-using SharpCifs.Util.DbsHelper;
using SharpCifs.Util.Sharpen;
using Thread = SharpCifs.Util.Sharpen.Thread;
-using System.Threading.Tasks;
namespace SharpCifs.Netbios
{
@@ -51,29 +48,27 @@ namespace SharpCifs.Netbios
internal const int ResolverWins = 3;
- private static readonly int SndBufSize
- = Config.GetInt("jcifs.netbios.snd_buf_size", DefaultSndBufSize);
+ private static readonly int SndBufSize = Config.GetInt("jcifs.netbios.snd_buf_size"
+ , DefaultSndBufSize);
- private static readonly int RcvBufSize
- = Config.GetInt("jcifs.netbios.rcv_buf_size", DefaultRcvBufSize);
+ private static readonly int RcvBufSize = Config.GetInt("jcifs.netbios.rcv_buf_size"
+ , DefaultRcvBufSize);
- private static readonly int SoTimeout
- = Config.GetInt("jcifs.netbios.soTimeout", DefaultSoTimeout);
+ private static readonly int SoTimeout = Config.GetInt("jcifs.netbios.soTimeout",
+ DefaultSoTimeout);
- private static readonly int RetryCount
- = Config.GetInt("jcifs.netbios.retryCount", DefaultRetryCount);
+ private static readonly int RetryCount = Config.GetInt("jcifs.netbios.retryCount"
+ , DefaultRetryCount);
- private static readonly int RetryTimeout
- = Config.GetInt("jcifs.netbios.retryTimeout", DefaultRetryTimeout);
+ private static readonly int RetryTimeout = Config.GetInt("jcifs.netbios.retryTimeout"
+ , DefaultRetryTimeout);
- private static readonly int Lport
- = Config.GetInt("jcifs.netbios.lport", 137);
+ private static readonly int Lport = Config.GetInt("jcifs.netbios.lport", 137);
- private static readonly IPAddress Laddr
- = Config.GetInetAddress("jcifs.netbios.laddr", null);
+ private static readonly IPAddress Laddr = Config.GetInetAddress("jcifs.netbios.laddr"
+ , null);
- private static readonly string Ro
- = Config.GetProperty("jcifs.resolveOrder");
+ private static readonly string Ro = Config.GetProperty("jcifs.resolveOrder");
private static LogStream _log = LogStream.GetInstance();
@@ -87,20 +82,18 @@ namespace SharpCifs.Netbios
private byte[] _rcvBuf;
- private SocketEx _socketSender;
+ private SocketEx _socket;
private Hashtable _responseTable = new Hashtable();
private Thread _thread;
-
+
private int _nextNameTrnId;
private int[] _resolveOrder;
private bool _waitResponse = true;
- private bool _isActive = false;
-
private AutoResetEvent _autoResetWaitReceive;
internal IPAddress laddr;
@@ -116,17 +109,13 @@ namespace SharpCifs.Netbios
{
this._lport = lport;
- this.laddr = laddr
- ?? Config.GetLocalHost()
- ?? Extensions.GetLocalAddresses()?.FirstOrDefault();
-
- if (this.laddr == null)
- throw new ArgumentNullException("IPAddress NOT found. if exec on localhost, set vallue to [jcifs.smb.client.laddr]");
+ this.laddr = laddr
+ ?? Config.GetLocalHost()
+ ?? Extensions.GetAddressesByName(Dns.GetHostName()).FirstOrDefault();
try
{
- Baddr = Config.GetInetAddress("jcifs.netbios.baddr",
- Extensions.GetAddressByName("255.255.255.255"));
+ Baddr = Config.GetInetAddress("jcifs.netbios.baddr", Extensions.GetAddressByName("255.255.255.255"));
}
catch (Exception ex)
{
@@ -172,8 +161,8 @@ namespace SharpCifs.Netbios
{
if (_log.Level > 1)
{
- _log.WriteLine("NetBIOS resolveOrder specifies WINS however the "
- + "jcifs.netbios.wins property has not been set");
+ _log.WriteLine("NetBIOS resolveOrder specifies WINS however the " + "jcifs.netbios.wins property has not been set"
+ );
}
continue;
}
@@ -219,93 +208,53 @@ namespace SharpCifs.Netbios
///
internal virtual void EnsureOpen(int timeout)
{
- //Log.Out($"NameServiceClient.EnsureOpen");
-
_closeTimeout = 0;
if (SoTimeout != 0)
{
_closeTimeout = Math.Max(SoTimeout, timeout);
}
-
- var localPort = (SmbConstants.Lport == 0) ? _lport : SmbConstants.Lport;
-
// If socket is still good, the new closeTimeout will
// be ignored; see tryClose comment.
- if (
- _socketSender == null
- || _socketSender.LocalEndPoint == null
- || _socketSender.GetLocalPort() != localPort
- || !IPAddress.Any.Equals(_socketSender.GetLocalInetAddress())
- )
+ if (_socket == null)
{
- if (_socketSender != null)
- {
- _socketSender.Dispose();
- _socketSender = null;
- }
-
- _socketSender = new SocketEx(AddressFamily.InterNetwork,
- SocketType.Dgram,
- ProtocolType.Udp);
-
- _socketSender.Bind(new IPEndPoint(IPAddress.Any, localPort));
-
+ _socket = new SocketEx(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
+
+ //IPAddress.`Address` property deleted
+ //_socket.Bind(new IPEndPoint(laddr.Address, _lport));
+ _socket.Bind(new IPEndPoint(laddr, _lport));
if (_waitResponse)
{
- if (_thread != null)
- {
- _thread.Cancel(true);
- _thread.Dispose();
- }
-
- _thread = new Thread(this);
+ _thread = new Thread(this); //new Sharpen.Thread(this, "JCIFS-NameServiceClient");
_thread.SetDaemon(true);
- _thread.Start(true);
+ _thread.Start();
}
}
}
internal virtual void TryClose()
{
- //Log.Out("NameSerciceClient.TryClose");
-
- if (this._isActive)
- {
- //Log.Out("NameSerciceClient.TryClose - Now in Processing... Exit.");
- return;
- }
-
lock (_lock)
{
- if (_socketSender != null)
+ if (_socket != null)
{
- _socketSender.Dispose();
- _socketSender = null;
- //Log.Out("NameSerciceClient.TryClose - _socketSender.Disposed");
- }
-
- if (_thread != null)
- {
- _thread.Cancel(true);
- _thread.Dispose();
- _thread = null;
- //Log.Out("NameSerciceClient.TryClose - _thread.Aborted");
+ //Socket.`Close` method deleted
+ //_socket.Close();
+ _socket.Dispose();
+ _socket = null;
}
+ _thread = null;
if (_waitResponse)
{
_responseTable.Clear();
- }
- else
+ } else
{
_autoResetWaitReceive.Set();
}
}
}
-
- private int _recievedLength = -1;
public virtual void Run()
{
int nameTrnId;
@@ -313,38 +262,12 @@ namespace SharpCifs.Netbios
try
{
- while (Thread.CurrentThread().Equals(_thread))
+
+ while (_thread == Thread.CurrentThread())
{
- if (_thread.IsCanceled)
- break;
+ _socket.SoTimeOut = _closeTimeout;
- var localPort = (SmbConstants.Lport == 0) ? _lport : SmbConstants.Lport;
-
- var sockEvArg = new SocketAsyncEventArgs();
- sockEvArg.RemoteEndPoint = new IPEndPoint(IPAddress.Any, localPort);
- sockEvArg.SetBuffer(_rcvBuf, 0, RcvBufSize);
- sockEvArg.Completed += this.OnReceiveCompleted;
-
- _socketSender.SoTimeOut = _closeTimeout;
-
- this._recievedLength = -1;
-
- //Log.Out($"NameServiceClient.Run - Wait Recieve: {IPAddress.Any}: {localPort}");
- _socketSender.ReceiveFromAsync(sockEvArg);
-
- while (this._recievedLength == -1)
- {
- if (_thread.IsCanceled)
- break;
-
- Task.Delay(300).GetAwaiter().GetResult();
- }
-
- sockEvArg?.Dispose();
-
-
- if (_thread.IsCanceled)
- break;
+ int len = _socket.Receive(_rcvBuf, 0, RcvBufSize);
if (_log.Level > 3)
{
@@ -361,15 +284,12 @@ namespace SharpCifs.Netbios
lock (response)
{
- if (_thread.IsCanceled)
- break;
-
response.ReadWireFormat(_rcvBuf, 0);
if (_log.Level > 3)
{
_log.WriteLine(response);
- Hexdump.ToHexdump(_log, _rcvBuf, 0, this._recievedLength);
+ Hexdump.ToHexdump(_log, _rcvBuf, 0, len);
}
if (response.IsResponse)
@@ -380,6 +300,7 @@ namespace SharpCifs.Netbios
}
}
}
+
}
catch (TimeoutException) { }
catch (Exception ex)
@@ -395,21 +316,10 @@ namespace SharpCifs.Netbios
}
}
-
- private void OnReceiveCompleted(object sender, SocketAsyncEventArgs e)
- {
- //Log.Out("NameServiceClient.OnReceiveCompleted");
- this._recievedLength = e.BytesTransferred;
- }
-
-
///
- internal virtual void Send(NameServicePacket request,
- NameServicePacket response,
- int timeout)
+ internal virtual void Send(NameServicePacket request, NameServicePacket response,
+ int timeout)
{
- //Log.Out("NameSerciceClient.Send - Start");
-
int nid = 0;
int max = NbtAddress.Nbns.Length;
if (max == 0)
@@ -419,7 +329,6 @@ namespace SharpCifs.Netbios
lock (response)
{
- this._isActive = true;
while (max-- > 0)
{
@@ -429,75 +338,45 @@ namespace SharpCifs.Netbios
{
request.NameTrnId = GetNextNameTrnId();
nid = request.NameTrnId;
-
response.Received = false;
_responseTable.Put(nid, response);
-
- //Log.Out($"NameSerciceClient.Send - timeout = {timeout}");
EnsureOpen(timeout + 1000);
-
int requestLenght = request.WriteWireFormat(_sndBuf, 0);
- byte[] msg = new byte[requestLenght];
- Array.Copy(_sndBuf, msg, requestLenght);
-
- _socketSender.SetSocketOption(SocketOptionLevel.Socket,
- SocketOptionName.Broadcast,
- request.IsBroadcast
- ? 1
- : 0);
-
- _socketSender.SendTo(msg, new IPEndPoint(request.Addr, _lport));
- //Log.Out("NameSerciceClient.Send - Sended");
-
+ _socket.Send(_sndBuf, 0, requestLenght, new IPEndPoint(request.Addr, _lport));
if (_log.Level > 3)
{
_log.WriteLine(request);
Hexdump.ToHexdump(_log, _sndBuf, 0, requestLenght);
}
- }
+ }
if (_waitResponse)
{
long start = Runtime.CurrentTimeMillis();
- var isRecieved = false;
- var startTime = DateTime.Now;
while (timeout > 0)
{
Runtime.Wait(response, timeout);
if (response.Received && request.QuestionType == response.RecordType)
{
- //return;
- isRecieved = true;
- break;
+ return;
}
response.Received = false;
timeout -= (int)(Runtime.CurrentTimeMillis() - start);
-
- //if (timeout <= 0)
- //{
- // Log.Out($"NameSerciceClient.Send Timeout! - {(DateTime.Now - startTime).TotalMilliseconds} msec");
- //}
}
-
- if (isRecieved)
- break;
}
}
catch (Exception ie)
{
- if (_waitResponse)
- _responseTable.Remove(nid);
-
- //Log.Out("NameSerciceClient.Send - IOException");
-
throw new IOException(ie.Message);
}
finally
{
+ //Sharpen.Collections.Remove(responseTable, nid);
if (_waitResponse)
+ {
_responseTable.Remove(nid);
+ }
}
-
if (_waitResponse)
{
lock (_lock)
@@ -514,24 +393,17 @@ namespace SharpCifs.Netbios
}
}
}
-
- this._isActive = false;
- //Log.Out("NameSerciceClient.Send - Normaly Ended.");
}
}
///
internal virtual NbtAddress[] GetAllByName(Name name, IPAddress addr)
{
- //Log.Out("NameSerciceClient.GetAllByName");
-
int n;
NameQueryRequest request = new NameQueryRequest(name);
NameQueryResponse response = new NameQueryResponse();
request.Addr = addr ?? NbtAddress.GetWinsAddress();
- request.IsBroadcast = (request.Addr == null
- || request.Addr.ToString() == Baddr.ToString());
-
+ request.IsBroadcast = request.Addr == null;
if (request.IsBroadcast)
{
request.Addr = Baddr;
@@ -568,12 +440,10 @@ namespace SharpCifs.Netbios
///
internal virtual NbtAddress GetByName(Name name, IPAddress addr)
{
- //Log.Out("NameSerciceClient.GetByName");
-
int n;
+
NameQueryRequest request = new NameQueryRequest(name);
NameQueryResponse response = new NameQueryResponse();
-
if (addr != null)
{
request.Addr = addr;
@@ -593,9 +463,7 @@ namespace SharpCifs.Netbios
}
throw new UnknownHostException(ioe);
}
-
- if (response.Received
- && response.ResultCode == 0
+ if (response.Received && response.ResultCode == 0
&& response.IsResponse)
{
int last = response.AddrEntry.Length - 1;
@@ -603,11 +471,9 @@ namespace SharpCifs.Netbios
return response.AddrEntry[last];
}
}
-
while (--n > 0 && request.IsBroadcast);
throw new UnknownHostException();
}
-
for (int i = 0; i < _resolveOrder.Length; i++)
{
try
@@ -630,9 +496,8 @@ namespace SharpCifs.Netbios
case ResolverWins:
case ResolverBcast:
{
- if (_resolveOrder[i] == ResolverWins
- && name.name != NbtAddress.MasterBrowserName
- && name.HexCode != unchecked(0x1d))
+ if (_resolveOrder[i] == ResolverWins && name.name != NbtAddress.MasterBrowserName
+ && name.HexCode != unchecked(0x1d))
{
request.Addr = NbtAddress.GetWinsAddress();
request.IsBroadcast = false;
@@ -657,12 +522,11 @@ namespace SharpCifs.Netbios
}
throw new UnknownHostException(ioe);
}
- if (response.Received
- && response.ResultCode == 0
+ if (response.Received && response.ResultCode == 0
&& response.IsResponse)
{
- response.AddrEntry[0].HostName.SrcHashCode
- = request.Addr.GetHashCode();
+
+ response.AddrEntry[0].HostName.SrcHashCode = request.Addr.GetHashCode();
return response.AddrEntry[0];
}
if (_resolveOrder[i] == ResolverWins)
@@ -678,15 +542,12 @@ namespace SharpCifs.Netbios
{
}
}
-
throw new UnknownHostException();
}
///
internal virtual NbtAddress[] GetNodeStatus(NbtAddress addr)
{
- //Log.Out("NameSerciceClient.GetNodeStatus");
-
int n;
int srcHashCode;
NodeStatusRequest request;
@@ -695,7 +556,6 @@ namespace SharpCifs.Netbios
request = new NodeStatusRequest(new Name(NbtAddress.AnyHostsName, unchecked(0x00), null));
request.Addr = addr.GetInetAddress();
n = RetryCount;
-
while (n-- > 0)
{
try
@@ -725,8 +585,6 @@ namespace SharpCifs.Netbios
internal virtual NbtAddress[] GetHosts()
{
- //Log.Out("NbtServiceClient.GetHosts");
-
try
{
_waitResponse = false;
@@ -735,8 +593,6 @@ namespace SharpCifs.Netbios
for (int i = 1; i <= 254; i++)
{
- //Log.Out($"NbtServiceClient.GetHosts - {i}");
-
NodeStatusRequest request;
NodeStatusResponse response;
@@ -749,59 +605,49 @@ namespace SharpCifs.Netbios
IPAddress addr = new IPAddress(addrBytes);
- response = new NodeStatusResponse(
- new NbtAddress(NbtAddress.UnknownName,
- BitConverter.ToInt32(addr.GetAddressBytes(), 0),
- false,
- 0x20)
- );
-
- request = new NodeStatusRequest(new Name(NbtAddress.AnyHostsName,
- unchecked(0x20),
- null))
- {
- Addr = addr
- };
+ //response = new NodeStatusResponse(new NbtAddress(NbtAddress.UnknownName,
+ // (int)addr.Address, false, 0x20));
+ response = new NodeStatusResponse(new NbtAddress(NbtAddress.UnknownName,
+ BitConverter.ToInt32(addr.GetAddressBytes(), 0) , false, 0x20));
+ request = new NodeStatusRequest(new Name(NbtAddress.AnyHostsName, unchecked(0x20), null));
+ request.Addr = addr;
Send(request, response, 0);
}
+
}
catch (IOException ioe)
{
- //Log.Out(ioe);
-
if (_log.Level > 1)
{
Runtime.PrintStackTrace(ioe, _log);
}
throw new UnknownHostException(ioe);
}
-
+
_autoResetWaitReceive = new AutoResetEvent(false);
-
- if (_thread != null)
- {
- _thread.Cancel(true);
- _thread.Dispose();
- }
-
- _thread = new Thread(this);
+ _thread = new Thread(this);
_thread.SetDaemon(true);
- _thread.Start(true);
+ _thread.Start();
- _autoResetWaitReceive.WaitOne();
+ _autoResetWaitReceive.WaitOne();
- var result = new List();
+ List result = new List();
foreach (var key in _responseTable.Keys)
{
- var resp = (NodeStatusResponse)_responseTable[key];
+ NodeStatusResponse resp = (NodeStatusResponse)_responseTable[key];
- if (!resp.Received || resp.ResultCode != 0)
- continue;
-
- result.AddRange(resp.AddressArray
- .Where(entry => entry.HostName.HexCode == 0x20));
+ if (resp.Received && resp.ResultCode == 0)
+ {
+ foreach (var entry in resp.AddressArray)
+ {
+ if (entry.HostName.HexCode == 0x20)
+ {
+ result.Add(entry);
+ }
+ }
+ }
}
_responseTable.Clear();
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServicePacket.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServicePacket.cs
index 1ac258a4e..28e98406e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServicePacket.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NameServicePacket.cs
@@ -20,474 +20,429 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- internal abstract class NameServicePacket
- {
- internal const int Query = 0;
+ internal abstract class NameServicePacket
+ {
+ internal const int Query = 0;
- internal const int Wack = 7;
+ internal const int Wack = 7;
- internal const int FmtErr = 0x1;
+ internal const int FmtErr = 0x1;
- internal const int SrvErr = 0x2;
+ internal const int SrvErr = 0x2;
- internal const int ImpErr = 0x4;
+ internal const int ImpErr = 0x4;
- internal const int RfsErr = 0x5;
+ internal const int RfsErr = 0x5;
- internal const int ActErr = 0x6;
+ internal const int ActErr = 0x6;
- internal const int CftErr = 0x7;
+ internal const int CftErr = 0x7;
- internal const int NbIn = 0x00200001;
+ internal const int NbIn = 0x00200001;
- internal const int NbstatIn = 0x00210001;
+ internal const int NbstatIn = 0x00210001;
- internal const int Nb = 0x0020;
+ internal const int Nb = 0x0020;
- internal const int Nbstat = 0x0021;
+ internal const int Nbstat = 0x0021;
- internal const int In = 0x0001;
+ internal const int In = 0x0001;
- internal const int A = 0x0001;
+ internal const int A = 0x0001;
- internal const int Ns = 0x0002;
+ internal const int Ns = 0x0002;
- internal const int Null = 0x000a;
+ internal const int Null = 0x000a;
- internal const int HeaderLength = 12;
+ internal const int HeaderLength = 12;
- internal const int OpcodeOffset = 2;
+ internal const int OpcodeOffset = 2;
- internal const int QuestionOffset = 4;
+ internal const int QuestionOffset = 4;
- internal const int AnswerOffset = 6;
+ internal const int AnswerOffset = 6;
- internal const int AuthorityOffset = 8;
+ internal const int AuthorityOffset = 8;
- internal const int AdditionalOffset = 10;
+ internal const int AdditionalOffset = 10;
- // opcode
- // rcode
- // type/class
- // header field offsets
- internal static void WriteInt2(int val, byte[] dst, int dstIndex)
- {
- dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
- dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
- }
+ // opcode
+ // rcode
+ // type/class
+ // header field offsets
+ internal static void WriteInt2(int val, byte[] dst, int dstIndex)
+ {
+ dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
+ dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
+ }
- internal static void WriteInt4(int val, byte[] dst, int dstIndex)
- {
- dst[dstIndex++] = unchecked((byte)((val >> 24) & unchecked(0xFF)));
- dst[dstIndex++] = unchecked((byte)((val >> 16) & unchecked(0xFF)));
- dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
- dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
- }
+ internal static void WriteInt4(int val, byte[] dst, int dstIndex)
+ {
+ dst[dstIndex++] = unchecked((byte)((val >> 24) & unchecked(0xFF)));
+ dst[dstIndex++] = unchecked((byte)((val >> 16) & unchecked(0xFF)));
+ dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
+ dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
+ }
- internal static int ReadInt2(byte[] src, int srcIndex)
- {
- return ((src[srcIndex] & unchecked(0xFF)) << 8) + (src[srcIndex + 1] & unchecked(
- 0xFF));
- }
+ internal static int ReadInt2(byte[] src, int srcIndex)
+ {
+ return ((src[srcIndex] & unchecked(0xFF)) << 8) + (src[srcIndex + 1] & unchecked(
+ 0xFF));
+ }
- internal static int ReadInt4(byte[] src, int srcIndex)
- {
- return ((src[srcIndex] & unchecked(0xFF)) << 24)
- + ((src[srcIndex + 1] & unchecked(0xFF)) << 16)
- + ((src[srcIndex + 2] & unchecked(0xFF)) << 8)
- + (src[srcIndex + 3] & unchecked(0xFF));
- }
+ internal static int ReadInt4(byte[] src, int srcIndex)
+ {
+ return ((src[srcIndex] & unchecked(0xFF)) << 24) + ((src[srcIndex + 1] & unchecked(
+ 0xFF)) << 16) + ((src[srcIndex + 2] & unchecked(0xFF)) << 8) + (src
+ [srcIndex + 3] & unchecked(0xFF));
+ }
- internal static int ReadNameTrnId(byte[] src, int srcIndex)
- {
- return ReadInt2(src, srcIndex);
- }
+ internal static int ReadNameTrnId(byte[] src, int srcIndex)
+ {
+ return ReadInt2(src, srcIndex);
+ }
- internal int AddrIndex;
+ internal int AddrIndex;
- internal NbtAddress[] AddrEntry;
+ internal NbtAddress[] AddrEntry;
- internal int NameTrnId;
+ internal int NameTrnId;
- internal int OpCode;
+ internal int OpCode;
- internal int ResultCode;
+ internal int ResultCode;
- internal int QuestionCount;
+ internal int QuestionCount;
- internal int AnswerCount;
+ internal int AnswerCount;
- internal int AuthorityCount;
+ internal int AuthorityCount;
- internal int AdditionalCount;
+ internal int AdditionalCount;
- internal bool Received;
+ internal bool Received;
- internal bool IsResponse;
+ internal bool IsResponse;
- internal bool IsAuthAnswer;
+ internal bool IsAuthAnswer;
- internal bool IsTruncated;
+ internal bool IsTruncated;
- internal bool IsRecurDesired;
+ internal bool IsRecurDesired;
- internal bool IsRecurAvailable;
+ internal bool IsRecurAvailable;
- internal bool IsBroadcast;
+ internal bool IsBroadcast;
- internal Name QuestionName;
+ internal Name QuestionName;
- internal Name RecordName;
-
- internal int QuestionType;
-
- internal int QuestionClass;
-
- internal int RecordType;
-
- internal int RecordClass;
-
- internal int Ttl;
-
- internal int RDataLength;
-
- internal IPAddress Addr;
-
- public NameServicePacket()
- {
- IsRecurDesired = true;
- IsBroadcast = true;
- QuestionCount = 1;
- QuestionClass = In;
- }
-
- internal virtual int WriteWireFormat(byte[] dst, int dstIndex)
- {
- int start = dstIndex;
- dstIndex += WriteHeaderWireFormat(dst, dstIndex);
- dstIndex += WriteBodyWireFormat(dst, dstIndex);
- return dstIndex - start;
- }
-
- internal virtual int ReadWireFormat(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- srcIndex += ReadHeaderWireFormat(src, srcIndex);
- srcIndex += ReadBodyWireFormat(src, srcIndex);
- return srcIndex - start;
- }
-
- internal virtual int WriteHeaderWireFormat(byte[] dst, int dstIndex)
- {
- int start = dstIndex;
- WriteInt2(NameTrnId, dst, dstIndex);
- dst[dstIndex + OpcodeOffset] = unchecked(
- (byte)(
- (IsResponse
- ? unchecked(0x80)
- : unchecked(0x00))
- + ((OpCode << 3) & unchecked(0x78))
- + (IsAuthAnswer
- ? unchecked(0x04)
- : unchecked(0x00))
- + (IsTruncated
- ? unchecked(0x02)
- : unchecked(0x00))
- + (IsRecurDesired
- ? unchecked(0x01)
- : unchecked(0x00))
- )
- );
- dst[dstIndex + OpcodeOffset + 1] = unchecked(
- (byte)(
- (IsRecurAvailable
- ? unchecked(0x80)
- : unchecked(0x00))
- + (IsBroadcast
- ? unchecked(0x10)
- : unchecked(0x00))
- + (ResultCode & unchecked(0x0F))
- )
- );
- WriteInt2(QuestionCount, dst, start + QuestionOffset);
- WriteInt2(AnswerCount, dst, start + AnswerOffset);
- WriteInt2(AuthorityCount, dst, start + AuthorityOffset);
- WriteInt2(AdditionalCount, dst, start + AdditionalOffset);
- return HeaderLength;
- }
-
- internal virtual int ReadHeaderWireFormat(byte[] src, int srcIndex)
- {
- NameTrnId = ReadInt2(src, srcIndex);
-
- IsResponse = ((src[srcIndex + OpcodeOffset] & unchecked(0x80)) == 0)
- ? false
- : true;
- OpCode = (src[srcIndex + OpcodeOffset] & unchecked(0x78)) >> 3;
- IsAuthAnswer = ((src[srcIndex + OpcodeOffset] & unchecked(0x04)) == 0)
- ? false
- : true;
- IsTruncated = ((src[srcIndex + OpcodeOffset] & unchecked(0x02)) == 0)
- ? false
- : true;
- IsRecurDesired = ((src[srcIndex + OpcodeOffset] & unchecked(0x01)) == 0)
- ? false
- : true;
- IsRecurAvailable = ((src[srcIndex + OpcodeOffset + 1] & unchecked(0x80)) == 0)
- ? false
- : true;
- IsBroadcast = ((src[srcIndex + OpcodeOffset + 1] & unchecked(0x10)) == 0)
- ? false
- : true;
- ResultCode = src[srcIndex + OpcodeOffset + 1] & unchecked(0x0F);
- QuestionCount = ReadInt2(src, srcIndex + QuestionOffset);
- AnswerCount = ReadInt2(src, srcIndex + AnswerOffset);
- AuthorityCount = ReadInt2(src, srcIndex + AuthorityOffset);
- AdditionalCount = ReadInt2(src, srcIndex + AdditionalOffset);
- return HeaderLength;
- }
-
- internal virtual int WriteQuestionSectionWireFormat(byte[] dst, int dstIndex)
- {
- int start = dstIndex;
- dstIndex += QuestionName.WriteWireFormat(dst, dstIndex);
- WriteInt2(QuestionType, dst, dstIndex);
- dstIndex += 2;
- WriteInt2(QuestionClass, dst, dstIndex);
- dstIndex += 2;
- return dstIndex - start;
- }
-
- internal virtual int ReadQuestionSectionWireFormat(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- srcIndex += QuestionName.ReadWireFormat(src, srcIndex);
- QuestionType = ReadInt2(src, srcIndex);
- srcIndex += 2;
- QuestionClass = ReadInt2(src, srcIndex);
- srcIndex += 2;
- return srcIndex - start;
- }
-
- internal virtual int WriteResourceRecordWireFormat(byte[] dst, int dstIndex)
- {
- int start = dstIndex;
- if (RecordName == QuestionName)
- {
- dst[dstIndex++] = unchecked(unchecked(0xC0));
- // label string pointer to
- dst[dstIndex++] = unchecked(unchecked(0x0C));
- }
- else
- {
- // questionName (offset 12)
- dstIndex += RecordName.WriteWireFormat(dst, dstIndex);
- }
- WriteInt2(RecordType, dst, dstIndex);
- dstIndex += 2;
- WriteInt2(RecordClass, dst, dstIndex);
- dstIndex += 2;
- WriteInt4(Ttl, dst, dstIndex);
- dstIndex += 4;
- RDataLength = WriteRDataWireFormat(dst, dstIndex + 2);
- WriteInt2(RDataLength, dst, dstIndex);
- dstIndex += 2 + RDataLength;
- return dstIndex - start;
- }
-
- internal virtual int ReadResourceRecordWireFormat(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- int end;
- if ((src[srcIndex] & unchecked(0xC0)) == unchecked(0xC0))
- {
- RecordName = QuestionName;
- // label string pointer to questionName
- srcIndex += 2;
- }
- else
- {
- srcIndex += RecordName.ReadWireFormat(src, srcIndex);
- }
- RecordType = ReadInt2(src, srcIndex);
- srcIndex += 2;
- RecordClass = ReadInt2(src, srcIndex);
- srcIndex += 2;
- Ttl = ReadInt4(src, srcIndex);
- srcIndex += 4;
- RDataLength = ReadInt2(src, srcIndex);
- srcIndex += 2;
- AddrEntry = new NbtAddress[RDataLength / 6];
- end = srcIndex + RDataLength;
- for (AddrIndex = 0; srcIndex < end; AddrIndex++)
- {
- srcIndex += ReadRDataWireFormat(src, srcIndex);
- }
- return srcIndex - start;
- }
-
- internal abstract int WriteBodyWireFormat(byte[] dst, int dstIndex);
-
- internal abstract int ReadBodyWireFormat(byte[] src, int srcIndex);
-
- internal abstract int WriteRDataWireFormat(byte[] dst, int dstIndex);
-
- internal abstract int ReadRDataWireFormat(byte[] src, int srcIndex);
-
- public override string ToString()
- {
- string opCodeString;
- string resultCodeString;
- string questionTypeString;
- string recordTypeString;
-
- switch (OpCode)
- {
- case Query:
- {
- opCodeString = "QUERY";
- break;
- }
-
- case Wack:
- {
- opCodeString = "WACK";
- break;
- }
-
- default:
- {
- opCodeString = Extensions.ToString(OpCode);
- break;
- }
- }
- switch (ResultCode)
- {
- case FmtErr:
- {
- resultCodeString = "FMT_ERR";
- break;
- }
-
- case SrvErr:
- {
- resultCodeString = "SRV_ERR";
- break;
- }
-
- case ImpErr:
- {
- resultCodeString = "IMP_ERR";
- break;
- }
-
- case RfsErr:
- {
- resultCodeString = "RFS_ERR";
- break;
- }
-
- case ActErr:
- {
- resultCodeString = "ACT_ERR";
- break;
- }
-
- case CftErr:
- {
- resultCodeString = "CFT_ERR";
- break;
- }
-
- default:
- {
- resultCodeString = "0x" + Hexdump.ToHexString(ResultCode, 1);
- break;
- }
- }
- switch (QuestionType)
- {
- case Nb:
- {
- questionTypeString = "NB";
- break;
- }
-
- case Nbstat:
- {
- questionTypeString = "NBSTAT";
- break;
- }
-
- default:
- {
- questionTypeString = "0x" + Hexdump.ToHexString(QuestionType, 4);
- break;
- }
- }
- switch (RecordType)
- {
- case A:
- {
- recordTypeString = "A";
- break;
- }
-
- case Ns:
- {
- recordTypeString = "NS";
- break;
- }
-
- case Null:
- {
- recordTypeString = "NULL";
- break;
- }
-
- case Nb:
- {
- recordTypeString = "NB";
- break;
- }
-
- case Nbstat:
- {
- recordTypeString = "NBSTAT";
- break;
- }
-
- default:
- {
- recordTypeString = "0x" + Hexdump.ToHexString(RecordType, 4);
- break;
- }
- }
- return "nameTrnId=" + NameTrnId
- + ",isResponse=" + IsResponse
- + ",opCode=" + opCodeString
- + ",isAuthAnswer=" + IsAuthAnswer
- + ",isTruncated=" + IsTruncated
- + ",isRecurAvailable=" + IsRecurAvailable
- + ",isRecurDesired=" + IsRecurDesired
- + ",isBroadcast=" + IsBroadcast
- + ",resultCode=" + ResultCode
- + ",questionCount=" + QuestionCount
- + ",answerCount=" + AnswerCount
- + ",authorityCount=" + AuthorityCount
- + ",additionalCount=" + AdditionalCount
- + ",questionName=" + QuestionName
- + ",questionType=" + questionTypeString
- + ",questionClass=" + (QuestionClass == In
- ? "IN"
- : "0x" + Hexdump.ToHexString(QuestionClass, 4))
- + ",recordName=" + RecordName
- + ",recordType=" + recordTypeString
- + ",recordClass=" + (RecordClass == In
- ? "IN"
- : "0x" + Hexdump.ToHexString(RecordClass, 4))
- + ",ttl=" + Ttl
- + ",rDataLength=" + RDataLength;
- }
- }
+ internal Name RecordName;
+
+ internal int QuestionType;
+
+ internal int QuestionClass;
+
+ internal int RecordType;
+
+ internal int RecordClass;
+
+ internal int Ttl;
+
+ internal int RDataLength;
+
+ internal IPAddress Addr;
+
+ public NameServicePacket()
+ {
+ IsRecurDesired = true;
+ IsBroadcast = true;
+ QuestionCount = 1;
+ QuestionClass = In;
+ }
+
+ internal virtual int WriteWireFormat(byte[] dst, int dstIndex)
+ {
+ int start = dstIndex;
+ dstIndex += WriteHeaderWireFormat(dst, dstIndex);
+ dstIndex += WriteBodyWireFormat(dst, dstIndex);
+ return dstIndex - start;
+ }
+
+ internal virtual int ReadWireFormat(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ srcIndex += ReadHeaderWireFormat(src, srcIndex);
+ srcIndex += ReadBodyWireFormat(src, srcIndex);
+ return srcIndex - start;
+ }
+
+ internal virtual int WriteHeaderWireFormat(byte[] dst, int dstIndex)
+ {
+ int start = dstIndex;
+ WriteInt2(NameTrnId, dst, dstIndex);
+ dst[dstIndex + OpcodeOffset] = unchecked((byte)((IsResponse ? unchecked(0x80) : unchecked(0x00)) + ((OpCode << 3) & unchecked(0x78)) + (IsAuthAnswer
+ ? unchecked(0x04) : unchecked(0x00)) + (IsTruncated ? unchecked(0x02) : unchecked(0x00)) + (IsRecurDesired ? unchecked(0x01)
+ : unchecked(0x00))));
+ dst[dstIndex + OpcodeOffset + 1] = unchecked((byte)((IsRecurAvailable ? unchecked(
+ 0x80) : unchecked(0x00)) + (IsBroadcast ? unchecked(0x10) :
+ unchecked(0x00)) + (ResultCode & unchecked(0x0F))));
+ WriteInt2(QuestionCount, dst, start + QuestionOffset);
+ WriteInt2(AnswerCount, dst, start + AnswerOffset);
+ WriteInt2(AuthorityCount, dst, start + AuthorityOffset);
+ WriteInt2(AdditionalCount, dst, start + AdditionalOffset);
+ return HeaderLength;
+ }
+
+ internal virtual int ReadHeaderWireFormat(byte[] src, int srcIndex)
+ {
+ NameTrnId = ReadInt2(src, srcIndex);
+ IsResponse = ((src[srcIndex + OpcodeOffset] & unchecked(0x80)) == 0) ? false
+ : true;
+ OpCode = (src[srcIndex + OpcodeOffset] & unchecked(0x78)) >> 3;
+ IsAuthAnswer = ((src[srcIndex + OpcodeOffset] & unchecked(0x04)) == 0) ?
+ false : true;
+ IsTruncated = ((src[srcIndex + OpcodeOffset] & unchecked(0x02)) == 0) ? false
+ : true;
+ IsRecurDesired = ((src[srcIndex + OpcodeOffset] & unchecked(0x01)) == 0) ?
+ false : true;
+ IsRecurAvailable = ((src[srcIndex + OpcodeOffset + 1] & unchecked(0x80))
+ == 0) ? false : true;
+ IsBroadcast = ((src[srcIndex + OpcodeOffset + 1] & unchecked(0x10)) == 0)
+ ? false : true;
+ ResultCode = src[srcIndex + OpcodeOffset + 1] & unchecked(0x0F);
+ QuestionCount = ReadInt2(src, srcIndex + QuestionOffset);
+ AnswerCount = ReadInt2(src, srcIndex + AnswerOffset);
+ AuthorityCount = ReadInt2(src, srcIndex + AuthorityOffset);
+ AdditionalCount = ReadInt2(src, srcIndex + AdditionalOffset);
+ return HeaderLength;
+ }
+
+ internal virtual int WriteQuestionSectionWireFormat(byte[] dst, int dstIndex)
+ {
+ int start = dstIndex;
+ dstIndex += QuestionName.WriteWireFormat(dst, dstIndex);
+ WriteInt2(QuestionType, dst, dstIndex);
+ dstIndex += 2;
+ WriteInt2(QuestionClass, dst, dstIndex);
+ dstIndex += 2;
+ return dstIndex - start;
+ }
+
+ internal virtual int ReadQuestionSectionWireFormat(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ srcIndex += QuestionName.ReadWireFormat(src, srcIndex);
+ QuestionType = ReadInt2(src, srcIndex);
+ srcIndex += 2;
+ QuestionClass = ReadInt2(src, srcIndex);
+ srcIndex += 2;
+ return srcIndex - start;
+ }
+
+ internal virtual int WriteResourceRecordWireFormat(byte[] dst, int dstIndex)
+ {
+ int start = dstIndex;
+ if (RecordName == QuestionName)
+ {
+ dst[dstIndex++] = unchecked(unchecked(0xC0));
+ // label string pointer to
+ dst[dstIndex++] = unchecked(unchecked(0x0C));
+ }
+ else
+ {
+ // questionName (offset 12)
+ dstIndex += RecordName.WriteWireFormat(dst, dstIndex);
+ }
+ WriteInt2(RecordType, dst, dstIndex);
+ dstIndex += 2;
+ WriteInt2(RecordClass, dst, dstIndex);
+ dstIndex += 2;
+ WriteInt4(Ttl, dst, dstIndex);
+ dstIndex += 4;
+ RDataLength = WriteRDataWireFormat(dst, dstIndex + 2);
+ WriteInt2(RDataLength, dst, dstIndex);
+ dstIndex += 2 + RDataLength;
+ return dstIndex - start;
+ }
+
+ internal virtual int ReadResourceRecordWireFormat(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ int end;
+ if ((src[srcIndex] & unchecked(0xC0)) == unchecked(0xC0))
+ {
+ RecordName = QuestionName;
+ // label string pointer to questionName
+ srcIndex += 2;
+ }
+ else
+ {
+ srcIndex += RecordName.ReadWireFormat(src, srcIndex);
+ }
+ RecordType = ReadInt2(src, srcIndex);
+ srcIndex += 2;
+ RecordClass = ReadInt2(src, srcIndex);
+ srcIndex += 2;
+ Ttl = ReadInt4(src, srcIndex);
+ srcIndex += 4;
+ RDataLength = ReadInt2(src, srcIndex);
+ srcIndex += 2;
+ AddrEntry = new NbtAddress[RDataLength / 6];
+ end = srcIndex + RDataLength;
+ for (AddrIndex = 0; srcIndex < end; AddrIndex++)
+ {
+ srcIndex += ReadRDataWireFormat(src, srcIndex);
+ }
+ return srcIndex - start;
+ }
+
+ internal abstract int WriteBodyWireFormat(byte[] dst, int dstIndex);
+
+ internal abstract int ReadBodyWireFormat(byte[] src, int srcIndex);
+
+ internal abstract int WriteRDataWireFormat(byte[] dst, int dstIndex);
+
+ internal abstract int ReadRDataWireFormat(byte[] src, int srcIndex);
+
+ public override string ToString()
+ {
+ string opCodeString;
+ string resultCodeString;
+ string questionTypeString;
+ string recordTypeString;
+
+ switch (OpCode)
+ {
+ case Query:
+ {
+ opCodeString = "QUERY";
+ break;
+ }
+
+ case Wack:
+ {
+ opCodeString = "WACK";
+ break;
+ }
+
+ default:
+ {
+ opCodeString = Extensions.ToString(OpCode);
+ break;
+ }
+ }
+ switch (ResultCode)
+ {
+ case FmtErr:
+ {
+ resultCodeString = "FMT_ERR";
+ break;
+ }
+
+ case SrvErr:
+ {
+ resultCodeString = "SRV_ERR";
+ break;
+ }
+
+ case ImpErr:
+ {
+ resultCodeString = "IMP_ERR";
+ break;
+ }
+
+ case RfsErr:
+ {
+ resultCodeString = "RFS_ERR";
+ break;
+ }
+
+ case ActErr:
+ {
+ resultCodeString = "ACT_ERR";
+ break;
+ }
+
+ case CftErr:
+ {
+ resultCodeString = "CFT_ERR";
+ break;
+ }
+
+ default:
+ {
+ resultCodeString = "0x" + Hexdump.ToHexString(ResultCode, 1);
+ break;
+ }
+ }
+ switch (QuestionType)
+ {
+ case Nb:
+ {
+ questionTypeString = "NB";
+ break;
+ }
+
+ case Nbstat:
+ {
+ questionTypeString = "NBSTAT";
+ break;
+ }
+
+ default:
+ {
+ questionTypeString = "0x" + Hexdump.ToHexString(QuestionType, 4);
+ break;
+ }
+ }
+ switch (RecordType)
+ {
+ case A:
+ {
+ recordTypeString = "A";
+ break;
+ }
+
+ case Ns:
+ {
+ recordTypeString = "NS";
+ break;
+ }
+
+ case Null:
+ {
+ recordTypeString = "NULL";
+ break;
+ }
+
+ case Nb:
+ {
+ recordTypeString = "NB";
+ break;
+ }
+
+ case Nbstat:
+ {
+ recordTypeString = "NBSTAT";
+ break;
+ }
+
+ default:
+ {
+ recordTypeString = "0x" + Hexdump.ToHexString(RecordType, 4);
+ break;
+ }
+ }
+ return "nameTrnId=" + NameTrnId + ",isResponse=" + IsResponse + ",opCode="
+ + opCodeString + ",isAuthAnswer=" + IsAuthAnswer + ",isTruncated=" + IsTruncated
+ + ",isRecurAvailable=" + IsRecurAvailable + ",isRecurDesired=" + IsRecurDesired
+ + ",isBroadcast=" + IsBroadcast + ",resultCode=" + ResultCode + ",questionCount="
+ + QuestionCount + ",answerCount=" + AnswerCount + ",authorityCount=" + AuthorityCount
+ + ",additionalCount=" + AdditionalCount + ",questionName=" + QuestionName + ",questionType="
+ + questionTypeString + ",questionClass=" + (QuestionClass == In ? "IN" : "0x" +
+ Hexdump.ToHexString(QuestionClass, 4)) + ",recordName=" + RecordName + ",recordType="
+ + recordTypeString + ",recordClass=" + (RecordClass == In ? "IN" : "0x" + Hexdump
+ .ToHexString(RecordClass, 4)) + ",ttl=" + Ttl + ",rDataLength=" + RDataLength;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtAddress.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtAddress.cs
index 34f70d27b..c64d385f1 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtAddress.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtAddress.cs
@@ -18,949 +18,903 @@ using System;
using System.Linq;
using System.Net;
using SharpCifs.Util;
-using SharpCifs.Util.DbsHelper;
using SharpCifs.Util.Sharpen;
using Extensions = SharpCifs.Util.Sharpen.Extensions;
namespace SharpCifs.Netbios
{
- /// This class represents a NetBIOS over TCP/IP address.
- ///
- /// This class represents a NetBIOS over TCP/IP address. Under normal
- /// conditions, users of jCIFS need not be concerned with this class as
- /// name resolution and session services are handled internally by the smb package.
- ///
Applications can use the methods getLocalHost,
- /// getByName, and
- /// getAllByAddress to create a new NbtAddress instance. This
- /// class is symmetric with
- /// System.Net.IPAddress
- /// .
- ///
About NetBIOS: The NetBIOS name
- /// service is a dynamic distributed service that allows hosts to resolve
- /// names by broadcasting a query, directing queries to a server such as
- /// Samba or WINS. NetBIOS is currently the primary networking layer for
- /// providing name service, datagram service, and session service to the
- /// Microsoft Windows platform. A NetBIOS name can be 15 characters long
- /// and hosts usually registers several names on the network. From a
- /// Windows command prompt you can see
- /// what names a host registers with the nbtstat command.
- ///
- /// C:\>nbtstat -a 192.168.1.15
- /// NetBIOS Remote Machine Name Table
- /// Name Type Status
- /// ---------------------------------------------
- /// JMORRIS2 <00> UNIQUE Registered
- /// BILLING-NY <00> GROUP Registered
- /// JMORRIS2 <03> UNIQUE Registered
- /// JMORRIS2 <20> UNIQUE Registered
- /// BILLING-NY <1E> GROUP Registered
- /// JMORRIS <03> UNIQUE Registered
- /// MAC Address = 00-B0-34-21-FA-3B
- ///
- ///
The hostname of this machine is JMORRIS2. It is
- /// a member of the group(a.k.a workgroup and domain) BILLING-NY. To
- /// obtain an
- /// System.Net.IPAddress
- /// for a host one might do:
- ///
From a UNIX platform with Samba installed you can perform similar
- /// diagnostics using the nmblookup utility.
- ///
- /// Michael B. Allen
- /// System.Net.IPAddress
- /// jcifs-0.1
- public sealed class NbtAddress
- {
- internal static readonly string AnyHostsName
- = "*\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000";
+ /// This class represents a NetBIOS over TCP/IP address.
+ ///
+ /// This class represents a NetBIOS over TCP/IP address. Under normal
+ /// conditions, users of jCIFS need not be concerned with this class as
+ /// name resolution and session services are handled internally by the smb package.
+ ///
Applications can use the methods getLocalHost,
+ /// getByName, and
+ /// getAllByAddress to create a new NbtAddress instance. This
+ /// class is symmetric with
+ /// System.Net.IPAddress
+ /// .
+ ///
About NetBIOS: The NetBIOS name
+ /// service is a dynamic distributed service that allows hosts to resolve
+ /// names by broadcasting a query, directing queries to a server such as
+ /// Samba or WINS. NetBIOS is currently the primary networking layer for
+ /// providing name service, datagram service, and session service to the
+ /// Microsoft Windows platform. A NetBIOS name can be 15 characters long
+ /// and hosts usually registers several names on the network. From a
+ /// Windows command prompt you can see
+ /// what names a host registers with the nbtstat command.
+ ///
+ /// C:\>nbtstat -a 192.168.1.15
+ /// NetBIOS Remote Machine Name Table
+ /// Name Type Status
+ /// ---------------------------------------------
+ /// JMORRIS2 <00> UNIQUE Registered
+ /// BILLING-NY <00> GROUP Registered
+ /// JMORRIS2 <03> UNIQUE Registered
+ /// JMORRIS2 <20> UNIQUE Registered
+ /// BILLING-NY <1E> GROUP Registered
+ /// JMORRIS <03> UNIQUE Registered
+ /// MAC Address = 00-B0-34-21-FA-3B
+ ///
+ ///
The hostname of this machine is JMORRIS2. It is
+ /// a member of the group(a.k.a workgroup and domain) BILLING-NY. To
+ /// obtain an
+ /// System.Net.IPAddress
+ /// for a host one might do:
+ ///
From a UNIX platform with Samba installed you can perform similar
+ /// diagnostics using the nmblookup utility.
+ ///
+ /// Michael B. Allen
+ /// System.Net.IPAddress
+ /// jcifs-0.1
+ public sealed class NbtAddress
+ {
+ internal static readonly string AnyHostsName = "*\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000";
- ///
- /// This is a special name for querying the master browser that serves the
- /// list of hosts found in "Network Neighborhood".
- ///
- ///
- /// This is a special name for querying the master browser that serves the
- /// list of hosts found in "Network Neighborhood".
- ///
- public static readonly string MasterBrowserName = "\u0001\u0002__MSBROWSE__\u0002";
+ ///
+ /// This is a special name for querying the master browser that serves the
+ /// list of hosts found in "Network Neighborhood".
+ ///
+ ///
+ /// This is a special name for querying the master browser that serves the
+ /// list of hosts found in "Network Neighborhood".
+ ///
+ public static readonly string MasterBrowserName = "\u0001\u0002__MSBROWSE__\u0002";
- ///
- /// A special generic name specified when connecting to a host for which
- /// a name is not known.
- ///
- ///
- /// A special generic name specified when connecting to a host for which
- /// a name is not known. Not all servers respond to this name.
- ///
- public static readonly string SmbserverName = "*SMBSERVER ";
+ ///
+ /// A special generic name specified when connecting to a host for which
+ /// a name is not known.
+ ///
+ ///
+ /// A special generic name specified when connecting to a host for which
+ /// a name is not known. Not all servers respond to this name.
+ ///
+ public static readonly string SmbserverName = "*SMBSERVER ";
- /// A B node only broadcasts name queries.
- ///
- /// A B node only broadcasts name queries. This is the default if a
- /// nameserver such as WINS or Samba is not specified.
- ///
- public const int BNode = 0;
+ /// A B node only broadcasts name queries.
+ ///
+ /// A B node only broadcasts name queries. This is the default if a
+ /// nameserver such as WINS or Samba is not specified.
+ ///
+ public const int BNode = 0;
- ///
- /// A Point-to-Point node, or P node, unicasts queries to a nameserver
- /// only.
- ///
- ///
- /// A Point-to-Point node, or P node, unicasts queries to a nameserver
- /// only. Natrually the jcifs.netbios.nameserver property must
- /// be set.
- ///
- public const int PNode = 1;
+ ///
+ /// A Point-to-Point node, or P node, unicasts queries to a nameserver
+ /// only.
+ ///
+ ///
+ /// A Point-to-Point node, or P node, unicasts queries to a nameserver
+ /// only. Natrually the jcifs.netbios.nameserver property must
+ /// be set.
+ ///
+ public const int PNode = 1;
- ///
- /// Try Broadcast queries first, then try to resolve the name using the
- /// nameserver.
- ///
- ///
- /// Try Broadcast queries first, then try to resolve the name using the
- /// nameserver.
- ///
- public const int MNode = 2;
+ ///
+ /// Try Broadcast queries first, then try to resolve the name using the
+ /// nameserver.
+ ///
+ ///
+ /// Try Broadcast queries first, then try to resolve the name using the
+ /// nameserver.
+ ///
+ public const int MNode = 2;
- /// A Hybrid node tries to resolve a name using the nameserver first.
- ///
- /// A Hybrid node tries to resolve a name using the nameserver first. If
- /// that fails use the broadcast address. This is the default if a nameserver
- /// is provided. This is the behavior of Microsoft Windows machines.
- ///
- public const int HNode = 3;
+ /// A Hybrid node tries to resolve a name using the nameserver first.
+ ///
+ /// A Hybrid node tries to resolve a name using the nameserver first. If
+ /// that fails use the broadcast address. This is the default if a nameserver
+ /// is provided. This is the behavior of Microsoft Windows machines.
+ ///
+ public const int HNode = 3;
- internal static readonly IPAddress[] Nbns
- = Config.GetInetAddressArray("jcifs.netbios.wins", ",", new IPAddress[0]);
+ internal static readonly IPAddress[] Nbns = Config.GetInetAddressArray("jcifs.netbios.wins"
+ , ",", new IPAddress[0]);
- private static readonly NameServiceClient Client = new NameServiceClient();
+ private static readonly NameServiceClient Client = new NameServiceClient();
- private const int DefaultCachePolicy = 30;
+ private const int DefaultCachePolicy = 30;
- private static readonly int CachePolicy
- = Config.GetInt("jcifs.netbios.cachePolicy", DefaultCachePolicy);
+ private static readonly int CachePolicy = Config.GetInt("jcifs.netbios.cachePolicy"
+ , DefaultCachePolicy);
- private const int Forever = -1;
+ private const int Forever = -1;
- private static int _nbnsIndex;
+ private static int _nbnsIndex;
- private static readonly Hashtable AddressCache = new Hashtable();
+ private static readonly Hashtable AddressCache = new Hashtable();
- private static readonly Hashtable LookupTable = new Hashtable();
+ private static readonly Hashtable LookupTable = new Hashtable();
- internal static readonly Name UnknownName = new Name("0.0.0.0", unchecked(0x00), null);
+ internal static readonly Name UnknownName = new Name("0.0.0.0", unchecked(0x00), null);
- internal static readonly NbtAddress UnknownAddress
- = new NbtAddress(UnknownName, 0, false, BNode);
+ internal static readonly NbtAddress UnknownAddress = new NbtAddress
+ (UnknownName, 0, false, BNode);
- internal static readonly byte[] UnknownMacAddress =
- {
- unchecked(unchecked(0x00)),
- unchecked(unchecked(0x00)),
- unchecked(unchecked(0x00)),
- unchecked(unchecked(0x00)),
- unchecked(unchecked(0x00)),
- unchecked(unchecked(0x00))
- };
+ internal static readonly byte[] UnknownMacAddress = { unchecked(unchecked(0x00)), unchecked(unchecked(0x00)), unchecked(unchecked(0x00)), unchecked(unchecked(0x00)), unchecked(unchecked(0x00)), unchecked(unchecked(0x00)) };
- private sealed class CacheEntry
- {
- internal Name HostName;
+ internal sealed class CacheEntry
+ {
+ internal Name HostName;
- internal NbtAddress Address;
+ internal NbtAddress Address;
- internal long Expiration;
+ internal long Expiration;
- internal CacheEntry(Name hostName, NbtAddress address, long expiration)
- {
- this.HostName = hostName;
- this.Address = address;
- this.Expiration = expiration;
- }
- }
+ internal CacheEntry(Name hostName, NbtAddress address, long expiration)
+ {
+ this.HostName = hostName;
+ this.Address = address;
+ this.Expiration = expiration;
+ }
+ }
- private static NbtAddress Localhost;
+ internal static NbtAddress Localhost;
- static NbtAddress()
- {
- IPAddress localInetAddress;
- string localHostname;
- Name localName;
- AddressCache.Put(UnknownName, new CacheEntry(UnknownName,
- UnknownAddress,
- Forever));
- localInetAddress = Client.laddr;
- if (localInetAddress == null)
- {
- try
- {
+ static NbtAddress()
+ {
+ IPAddress localInetAddress;
+ string localHostname;
+ Name localName;
+ AddressCache.Put(UnknownName, new CacheEntry(UnknownName, UnknownAddress
+ , Forever));
+ localInetAddress = Client.laddr;
+ if (localInetAddress == null)
+ {
+ try
+ {
localInetAddress = Extensions.GetAddressByName("127.0.0.1");
- }
- catch (UnknownHostException)
- {
- }
- }
- localHostname = Config.GetProperty("jcifs.netbios.hostname", null);
- if (string.IsNullOrEmpty(localHostname))
- {
- /*
- byte[] addr = localInetAddress.GetAddressBytes();
+ }
+ catch (UnknownHostException)
+ {
- localHostname = "JCIFS"
- + (addr[2] & unchecked((int)(0xFF)))
- + "_" + (addr[3] & unchecked((int)(0xFF)))
- + "_" + Hexdump.ToHexString(
- (int)(new Random().NextDouble()
- * (double)unchecked((int)(0xFF))),
- 2
- );
- */
- try
- {
- localHostname = Dns.GetHostName();
- }
- catch (Exception)
- {
- localHostname = "JCIFS_127_0_0_1";
- }
- }
- localName = new Name(localHostname,
- unchecked(0x00),
- Config.GetProperty("jcifs.netbios.scope", null));
- Localhost = new NbtAddress(localName,
- localInetAddress.GetHashCode(),
- false,
- BNode,
- false,
- false,
- true,
- false,
- UnknownMacAddress);
- CacheAddress(localName, Localhost, Forever);
- }
+ }
+ }
+ localHostname = Config.GetProperty("jcifs.netbios.hostname", null);
+ if (string.IsNullOrEmpty(localHostname))
+ {
+ byte[] addr = localInetAddress.GetAddressBytes();
+
+ /*localHostname = "JCIFS" + (addr[2] & unchecked((int)(0xFF))) + "_" + (addr[3] & unchecked(
+ (int)(0xFF))) + "_" + Hexdump.ToHexString((int)(new Random().NextDouble() * (double)unchecked(
+ (int)(0xFF))), 2);*/
+ localHostname = "JCIFS_127_0_0_1";
+ }
+ localName = new Name(localHostname, unchecked(0x00), Config.GetProperty("jcifs.netbios.scope"
+ , null));
+ Localhost = new NbtAddress(localName, localInetAddress.GetHashCode(), false, BNode
+ , false, false, true, false, UnknownMacAddress);
+ CacheAddress(localName, Localhost, Forever);
+ }
- private static void CacheAddress(Name hostName, NbtAddress addr)
- {
- if (CachePolicy == 0)
- {
- return;
- }
- long expiration = -1;
- if (CachePolicy != Forever)
- {
- expiration = Runtime.CurrentTimeMillis() + CachePolicy * 1000;
- }
- CacheAddress(hostName, addr, expiration);
- }
+ internal static void CacheAddress(Name hostName, NbtAddress addr)
+ {
+ if (CachePolicy == 0)
+ {
+ return;
+ }
+ long expiration = -1;
+ if (CachePolicy != Forever)
+ {
+ expiration = Runtime.CurrentTimeMillis() + CachePolicy * 1000;
+ }
+ CacheAddress(hostName, addr, expiration);
+ }
- private static void CacheAddress(Name hostName, NbtAddress addr, long expiration)
- {
- if (CachePolicy == 0)
- {
- return;
- }
- lock (AddressCache)
- {
+ internal static void CacheAddress(Name hostName, NbtAddress addr, long expiration
+ )
+ {
+ if (CachePolicy == 0)
+ {
+ return;
+ }
+ lock (AddressCache)
+ {
+ CacheEntry entry = (CacheEntry)AddressCache.Get(hostName);
+ if (entry == null)
+ {
+ entry = new CacheEntry(hostName, addr, expiration);
+ AddressCache.Put(hostName, entry);
+ }
+ else
+ {
+ entry.Address = addr;
+ entry.Expiration = expiration;
+ }
+ }
+ }
+
+ internal static void CacheAddressArray(NbtAddress[] addrs)
+ {
+ if (CachePolicy == 0)
+ {
+ return;
+ }
+ long expiration = -1;
+ if (CachePolicy != Forever)
+ {
+ expiration = Runtime.CurrentTimeMillis() + CachePolicy * 1000;
+ }
+ lock (AddressCache)
+ {
+ for (int i = 0; i < addrs.Length; i++)
+ {
+ CacheEntry entry = (CacheEntry)AddressCache.Get(addrs[i].HostName
+ );
+ if (entry == null)
+ {
+ entry = new CacheEntry(addrs[i].HostName, addrs[i], expiration);
+ AddressCache.Put(addrs[i].HostName, entry);
+ }
+ else
+ {
+ entry.Address = addrs[i];
+ entry.Expiration = expiration;
+ }
+ }
+ }
+ }
+
+ internal static NbtAddress GetCachedAddress(Name hostName)
+ {
+ if (CachePolicy == 0)
+ {
+ return null;
+ }
+ lock (AddressCache)
+ {
CacheEntry entry = (CacheEntry)AddressCache.Get(hostName);
- if (entry == null)
- {
- entry = new CacheEntry(hostName, addr, expiration);
- AddressCache.Put(hostName, entry);
- }
- else
- {
- entry.Address = addr;
- entry.Expiration = expiration;
- }
- }
- }
+ if (entry != null && entry.Expiration < Runtime.CurrentTimeMillis() && entry.Expiration
+ >= 0)
+ {
+ entry = null;
+ }
+ return entry != null ? entry.Address : null;
+ }
+ }
- private static void CacheAddressArray(NbtAddress[] addrs)
- {
- if (CachePolicy == 0)
- {
- return;
- }
- long expiration = -1;
- if (CachePolicy != Forever)
- {
- expiration = Runtime.CurrentTimeMillis() + CachePolicy * 1000;
- }
- lock (AddressCache)
- {
- for (int i = 0; i < addrs.Length; i++)
- {
- CacheEntry entry = (CacheEntry)AddressCache.Get(addrs[i].HostName);
- if (entry == null)
- {
- entry = new CacheEntry(addrs[i].HostName, addrs[i], expiration);
- AddressCache.Put(addrs[i].HostName, entry);
- }
- else
- {
- entry.Address = addrs[i];
- entry.Expiration = expiration;
- }
- }
- }
- }
+ ///
+ internal static NbtAddress DoNameQuery(Name name, IPAddress svr)
+ {
+ NbtAddress addr;
+ if (name.HexCode == unchecked(0x1d) && svr == null)
+ {
+ svr = Client.Baddr;
+ }
+ // bit of a hack but saves a lookup
+ name.SrcHashCode = svr != null ? svr.GetHashCode() : 0;
+ addr = GetCachedAddress(name);
+ if (addr == null)
+ {
+ if ((addr = (NbtAddress)CheckLookupTable(name)) == null)
+ {
+ try
+ {
+ addr = Client.GetByName(name, svr);
+ }
+ catch (UnknownHostException)
+ {
+ addr = UnknownAddress;
+ }
+ finally
+ {
+ CacheAddress(name, addr);
+ UpdateLookupTable(name);
+ }
+ }
+ }
+ if (addr == UnknownAddress)
+ {
+ throw new UnknownHostException(name.ToString());
+ }
+ return addr;
+ }
- private static NbtAddress GetCachedAddress(Name hostName)
- {
- if (CachePolicy == 0)
- {
- return null;
- }
- lock (AddressCache)
- {
- CacheEntry entry = (CacheEntry)AddressCache.Get(hostName);
- if (entry != null
- && entry.Expiration < Runtime.CurrentTimeMillis()
- && entry.Expiration>= 0)
- {
- entry = null;
- }
- return entry != null
- ? entry.Address
- : null;
- }
- }
+ private static object CheckLookupTable(Name name)
+ {
+ object obj;
+ lock (LookupTable)
+ {
+ if (LookupTable.ContainsKey(name) == false)
+ {
+ LookupTable.Put(name, name);
+ return null;
+ }
+ while (LookupTable.ContainsKey(name))
+ {
+ try
+ {
+ Runtime.Wait(LookupTable);
+ }
+ catch (Exception)
+ {
+ }
+ }
+ }
+ obj = GetCachedAddress(name);
+ if (obj == null)
+ {
+ lock (LookupTable)
+ {
+ LookupTable.Put(name, name);
+ }
+ }
+ return obj;
+ }
- ///
- private static NbtAddress DoNameQuery(Name name, IPAddress svr)
- {
- NbtAddress addr;
- if (name.HexCode == unchecked(0x1d) && svr == null)
- {
- svr = Client.Baddr;
- }
- // bit of a hack but saves a lookup
- name.SrcHashCode = svr != null
- ? svr.GetHashCode()
- : 0;
- addr = GetCachedAddress(name);
- if (addr == null)
- {
- if ((addr = (NbtAddress)CheckLookupTable(name)) == null)
- {
- try
- {
- addr = Client.GetByName(name, svr);
- }
- catch (UnknownHostException)
- {
- addr = UnknownAddress;
- }
- finally
- {
- CacheAddress(name, addr);
- UpdateLookupTable(name);
- }
- }
- }
- if (addr == UnknownAddress)
- {
- throw new UnknownHostException(name.ToString());
- }
- return addr;
- }
-
- private static object CheckLookupTable(Name name)
- {
- object obj;
- lock (LookupTable)
- {
- if (LookupTable.ContainsKey(name) == false)
- {
- LookupTable.Put(name, name);
- return null;
- }
- while (LookupTable.ContainsKey(name))
- {
- try
- {
- Runtime.Wait(LookupTable);
- }
- catch (Exception)
- {
- }
- }
- }
- obj = GetCachedAddress(name);
- if (obj == null)
- {
- lock (LookupTable)
- {
- LookupTable.Put(name, name);
- }
- }
- return obj;
- }
-
- private static void UpdateLookupTable(Name name)
- {
- lock (LookupTable)
- {
- //Sharpen.Collections.Remove(LOOKUP_TABLE, name);
+ private static void UpdateLookupTable(Name name)
+ {
+ lock (LookupTable)
+ {
+ //Sharpen.Collections.Remove(LOOKUP_TABLE, name);
LookupTable.Remove(name);
- Runtime.NotifyAll(LookupTable);
- }
- }
+ Runtime.NotifyAll(LookupTable);
+ }
+ }
+ /// Retrieves the local host address.
+ /// Retrieves the local host address.
+ ///
+ /// This is not likely as the IP returned
+ /// by InetAddress should be available
+ ///
+ public static NbtAddress GetLocalHost()
+ {
+ return Localhost;
+ }
+ public static NbtAddress[] GetHosts()
+ {
+ return new NameServiceClient().GetHosts();
+ }
- /// Retrieves the local host address.
- /// Retrieves the local host address.
- ///
- /// This is not likely as the IP returned
- /// by InetAddress should be available
- ///
- public static NbtAddress GetLocalHost()
- {
- return Localhost;
- }
+ public static Name GetLocalName()
+ {
+ return Localhost.HostName;
+ }
- public static NbtAddress[] GetHosts()
- {
- //Log.Out("NbtAddress.GetHosts");
- return new NameServiceClient().GetHosts();
- }
+ /// Determines the address of a host given it's host name.
+ ///
+ /// Determines the address of a host given it's host name. The name can be a NetBIOS name like
+ /// "freto" or an IP address like "192.168.1.15". It cannot be a DNS name;
+ /// the analygous
+ /// Jcifs.UniAddress
+ /// or
+ /// System.Net.IPAddress
+ /// getByName methods can be used for that.
+ ///
+ /// hostname to resolve
+ /// if there is an error resolving the name
+ ///
+ public static NbtAddress GetByName(string host)
+ {
+ return GetByName(host, unchecked(0x00), null);
+ }
- public static Name GetLocalName()
- {
- return Localhost.HostName;
- }
+ /// Determines the address of a host given it's host name.
+ ///
+ /// Determines the address of a host given it's host name. NetBIOS
+ /// names also have a type. Types(aka Hex Codes)
+ /// are used to distiquish the various services on a host. <a
+ /// href="../../../nbtcodes.html">Here is
+ /// a fairly complete list of NetBIOS hex codes. Scope is not used but is
+ /// still functional in other NetBIOS products and so for completeness it has been
+ /// implemented. A scope of null or ""
+ /// signifies no scope.
+ ///
+ /// the name to resolve
+ /// the hex code of the name
+ /// the scope of the name
+ /// if there is an error resolving the name
+ ///
+ public static NbtAddress GetByName(string host, int type, string scope)
+ {
+ return GetByName(host, type, scope, null);
+ }
- /// Determines the address of a host given it's host name.
- ///
- /// Determines the address of a host given it's host name. The name can be a NetBIOS name like
- /// "freto" or an IP address like "192.168.1.15". It cannot be a DNS name;
- /// the analygous
- /// Jcifs.UniAddress
- /// or
- /// System.Net.IPAddress
- /// getByName methods can be used for that.
- ///
- /// hostname to resolve
- /// if there is an error resolving the name
- ///
- public static NbtAddress GetByName(string host)
- {
- return GetByName(host, unchecked(0x00), null);
- }
+ ///
+ public static NbtAddress GetByName(string host, int type, string scope, IPAddress
+ svr)
+ {
+ if (string.IsNullOrEmpty(host))
+ {
+ return GetLocalHost();
+ }
+ if (!char.IsDigit(host[0]))
+ {
+ return DoNameQuery(new Name(host, type, scope), svr);
+ }
+ int ip = unchecked(0x00);
+ int hitDots = 0;
+ char[] data = host.ToCharArray();
+ for (int i = 0; i < data.Length; i++)
+ {
+ char c = data[i];
+ if (c < 48 || c > 57)
+ {
+ return DoNameQuery(new Name(host, type, scope), svr);
+ }
+ int b = unchecked(0x00);
+ while (c != '.')
+ {
+ if (c < 48 || c > 57)
+ {
+ return DoNameQuery(new Name(host, type, scope), svr);
+ }
+ b = b * 10 + c - '0';
+ if (++i >= data.Length)
+ {
+ break;
+ }
+ c = data[i];
+ }
+ if (b > unchecked(0xFF))
+ {
+ return DoNameQuery(new Name(host, type, scope), svr);
+ }
+ ip = (ip << 8) + b;
+ hitDots++;
+ }
+ if (hitDots != 4 || host.EndsWith("."))
+ {
+ return DoNameQuery(new Name(host, type, scope), svr);
+ }
+ return new NbtAddress(UnknownName, ip, false, BNode);
+ }
- /// Determines the address of a host given it's host name.
- ///
- /// Determines the address of a host given it's host name. NetBIOS
- /// names also have a type. Types(aka Hex Codes)
- /// are used to distiquish the various services on a host. <a
- /// href="../../../nbtcodes.html">Here is
- /// a fairly complete list of NetBIOS hex codes. Scope is not used but is
- /// still functional in other NetBIOS products and so for completeness it has been
- /// implemented. A scope of null or ""
- /// signifies no scope.
- ///
- /// the name to resolve
- /// the hex code of the name
- /// the scope of the name
- /// if there is an error resolving the name
- ///
- public static NbtAddress GetByName(string host, int type, string scope)
- {
- return GetByName(host, type, scope, null);
- }
+ ///
+ public static NbtAddress[] GetAllByName(string host, int type, string scope, IPAddress
+ svr)
+ {
+ return Client.GetAllByName(new Name(host, type, scope), svr);
+ }
- ///
- public static NbtAddress GetByName(string host, int type, string scope, IPAddress svr)
- {
- if (string.IsNullOrEmpty(host))
- {
- return GetLocalHost();
- }
- if (!char.IsDigit(host[0]))
- {
- return DoNameQuery(new Name(host, type, scope), svr);
- }
- int ip = unchecked(0x00);
- int hitDots = 0;
- char[] data = host.ToCharArray();
- for (int i = 0; i < data.Length; i++)
- {
- char c = data[i];
- if (c < 48 || c > 57)
- {
- return DoNameQuery(new Name(host, type, scope), svr);
- }
- int b = unchecked(0x00);
- while (c != '.')
- {
- if (c < 48 || c > 57)
- {
- return DoNameQuery(new Name(host, type, scope), svr);
- }
- b = b * 10 + c - '0';
- if (++i >= data.Length)
- {
- break;
- }
- c = data[i];
- }
- if (b > unchecked(0xFF))
- {
- return DoNameQuery(new Name(host, type, scope), svr);
- }
- ip = (ip << 8) + b;
- hitDots++;
- }
- if (hitDots != 4 || host.EndsWith("."))
- {
- return DoNameQuery(new Name(host, type, scope), svr);
- }
- return new NbtAddress(UnknownName, ip, false, BNode);
- }
+ /// Retrieve all addresses of a host by it's address.
+ ///
+ /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
+ /// have many names for a given IP address. The name and IP address make the
+ /// NetBIOS address. This provides a way to retrieve the other names for a
+ /// host with the same IP address.
+ ///
+ /// hostname to lookup all addresses for
+ /// if there is an error resolving the name
+ ///
+ public static NbtAddress[] GetAllByAddress(string host)
+ {
+ return GetAllByAddress(GetByName(host, unchecked(0x00), null));
+ }
- ///
- public static NbtAddress[] GetAllByName(string host,
- int type,
- string scope,
- IPAddress svr)
- {
- return Client.GetAllByName(new Name(host, type, scope), svr);
- }
+ /// Retrieve all addresses of a host by it's address.
+ ///
+ /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
+ /// have many names for a given IP address. The name and IP address make
+ /// the NetBIOS address. This provides a way to retrieve the other names
+ /// for a host with the same IP address. See
+ /// GetByName(string)
+ /// for a description of type
+ /// and scope.
+ ///
+ /// hostname to lookup all addresses for
+ /// the hexcode of the name
+ /// the scope of the name
+ /// if there is an error resolving the name
+ ///
+ public static NbtAddress[] GetAllByAddress(string host, int type, string scope)
+ {
+ return GetAllByAddress(GetByName(host, type, scope));
+ }
- /// Retrieve all addresses of a host by it's address.
- ///
- /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
- /// have many names for a given IP address. The name and IP address make the
- /// NetBIOS address. This provides a way to retrieve the other names for a
- /// host with the same IP address.
- ///
- /// hostname to lookup all addresses for
- /// if there is an error resolving the name
- ///
- public static NbtAddress[] GetAllByAddress(string host)
- {
- return GetAllByAddress(GetByName(host, unchecked(0x00), null));
- }
+ /// Retrieve all addresses of a host by it's address.
+ ///
+ /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
+ /// have many names for a given IP address. The name and IP address make the
+ /// NetBIOS address. This provides a way to retrieve the other names for a
+ /// host with the same IP address.
+ ///
+ /// the address to query
+ /// if address cannot be resolved
+ public static NbtAddress[] GetAllByAddress(NbtAddress addr)
+ {
+ try
+ {
+ NbtAddress[] addrs = Client.GetNodeStatus(addr);
+ CacheAddressArray(addrs);
+ return addrs;
+ }
+ catch (UnknownHostException)
+ {
+ throw new UnknownHostException("no name with type 0x" + Hexdump.ToHexString(addr.
+ HostName.HexCode, 2) + (((addr.HostName.Scope == null) || (addr.HostName.Scope.Length
+ == 0)) ? " with no scope" : " with scope " + addr.HostName.Scope) + " for host "
+ + addr.GetHostAddress());
+ }
+ }
- /// Retrieve all addresses of a host by it's address.
- ///
- /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
- /// have many names for a given IP address. The name and IP address make
- /// the NetBIOS address. This provides a way to retrieve the other names
- /// for a host with the same IP address. See
- /// GetByName(string)
- /// for a description of type
- /// and scope.
- ///
- /// hostname to lookup all addresses for
- /// the hexcode of the name
- /// the scope of the name
- /// if there is an error resolving the name
- ///
- public static NbtAddress[] GetAllByAddress(string host, int type, string scope)
- {
- return GetAllByAddress(GetByName(host, type, scope));
- }
+ public static IPAddress GetWinsAddress()
+ {
+ return Nbns.Length == 0 ? null : Nbns[_nbnsIndex];
+ }
- /// Retrieve all addresses of a host by it's address.
- ///
- /// Retrieve all addresses of a host by it's address. NetBIOS hosts can
- /// have many names for a given IP address. The name and IP address make the
- /// NetBIOS address. This provides a way to retrieve the other names for a
- /// host with the same IP address.
- ///
- /// the address to query
- /// if address cannot be resolved
- public static NbtAddress[] GetAllByAddress(NbtAddress addr)
- {
- try
- {
- NbtAddress[] addrs = Client.GetNodeStatus(addr);
- CacheAddressArray(addrs);
- return addrs;
- }
- catch (UnknownHostException)
- {
- throw new UnknownHostException(
- "no name with type 0x" + Hexdump.ToHexString(addr.HostName.HexCode, 2)
- + (((addr.HostName.Scope == null) || (addr.HostName.Scope.Length == 0))
- ? " with no scope"
- : " with scope " + addr.HostName.Scope)
- + " for host " + addr.GetHostAddress()
- );
- }
- }
+ public static bool IsWins(IPAddress svr)
+ {
+ for (int i = 0; svr != null && i < Nbns.Length; i++)
+ {
+ if (svr.GetHashCode() == Nbns[i].GetHashCode())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- public static IPAddress GetWinsAddress()
- {
- return Nbns.Length == 0 ? null : Nbns[_nbnsIndex];
- }
+ internal static IPAddress SwitchWins()
+ {
+ _nbnsIndex = (_nbnsIndex + 1) < Nbns.Length ? _nbnsIndex + 1 : 0;
+ return Nbns.Length == 0 ? null : Nbns[_nbnsIndex];
+ }
- public static bool IsWins(IPAddress svr)
- {
- for (int i = 0; svr != null && i < Nbns.Length; i++)
- {
- if (svr.GetHashCode() == Nbns[i].GetHashCode())
- {
- return true;
- }
- }
- return false;
- }
+ internal Name HostName;
- internal static IPAddress SwitchWins()
- {
- _nbnsIndex = (_nbnsIndex + 1) < Nbns.Length ? _nbnsIndex + 1 : 0;
- return Nbns.Length == 0 ? null : Nbns[_nbnsIndex];
- }
+ internal int Address;
- internal Name HostName;
+ internal int NodeType;
- internal int Address;
+ internal bool GroupName;
- internal int NodeType;
+ internal bool isBeingDeleted;
- internal bool GroupName;
+ internal bool isInConflict;
- internal bool isBeingDeleted;
+ internal bool isActive;
- internal bool isInConflict;
+ internal bool isPermanent;
- internal bool isActive;
+ internal bool IsDataFromNodeStatus;
- internal bool isPermanent;
+ internal byte[] MacAddress;
- internal bool IsDataFromNodeStatus;
+ internal string CalledName;
- internal byte[] MacAddress;
+ internal NbtAddress(Name hostName, int address, bool groupName, int nodeType)
+ {
+ this.HostName = hostName;
+ this.Address = address;
+ this.GroupName = groupName;
+ this.NodeType = nodeType;
+ }
- internal string CalledName;
+ internal NbtAddress(Name hostName, int address, bool groupName, int nodeType, bool
+ isBeingDeleted, bool isInConflict, bool isActive, bool isPermanent, byte[] macAddress
+ )
+ {
+ this.HostName = hostName;
+ this.Address = address;
+ this.GroupName = groupName;
+ this.NodeType = nodeType;
+ this.isBeingDeleted = isBeingDeleted;
+ this.isInConflict = isInConflict;
+ this.isActive = isActive;
+ this.isPermanent = isPermanent;
+ this.MacAddress = macAddress;
+ IsDataFromNodeStatus = true;
+ }
- internal NbtAddress(Name hostName, int address, bool groupName, int nodeType)
- {
- this.HostName = hostName;
- this.Address = address;
- this.GroupName = groupName;
- this.NodeType = nodeType;
- }
+ public string FirstCalledName()
+ {
+ CalledName = HostName.name;
+ if (char.IsDigit(CalledName[0]))
+ {
+ int i;
+ int len;
+ int dots;
+ char[] data;
+ i = dots = 0;
+ len = CalledName.Length;
+ data = CalledName.ToCharArray();
+ while (i < len && char.IsDigit(data[i++]))
+ {
+ if (i == len && dots == 3)
+ {
+ // probably an IP address
+ CalledName = SmbserverName;
+ break;
+ }
+ if (i < len && data[i] == '.')
+ {
+ dots++;
+ i++;
+ }
+ }
+ }
+ else
+ {
+ switch (HostName.HexCode)
+ {
+ case unchecked(0x1B):
+ case unchecked(0x1C):
+ case unchecked(0x1D):
+ {
+ CalledName = SmbserverName;
+ break;
+ }
+ }
+ }
+ return CalledName;
+ }
- internal NbtAddress(Name hostName,
- int address,
- bool groupName,
- int nodeType,
- bool isBeingDeleted,
- bool isInConflict,
- bool isActive,
- bool isPermanent,
- byte[] macAddress)
- {
- this.HostName = hostName;
- this.Address = address;
- this.GroupName = groupName;
- this.NodeType = nodeType;
- this.isBeingDeleted = isBeingDeleted;
- this.isInConflict = isInConflict;
- this.isActive = isActive;
- this.isPermanent = isPermanent;
- this.MacAddress = macAddress;
- IsDataFromNodeStatus = true;
- }
+ public string NextCalledName()
+ {
+ if (CalledName == HostName.name)
+ {
+ CalledName = SmbserverName;
+ }
+ else
+ {
+ if (CalledName == SmbserverName)
+ {
+ NbtAddress[] addrs;
+ try
+ {
+ addrs = Client.GetNodeStatus(this);
+ if (HostName.HexCode == unchecked(0x1D))
+ {
+ for (int i = 0; i < addrs.Length; i++)
+ {
+ if (addrs[i].HostName.HexCode == unchecked(0x20))
+ {
+ return addrs[i].HostName.name;
+ }
+ }
+ return null;
+ }
+ if (IsDataFromNodeStatus)
+ {
+ CalledName = null;
+ return HostName.name;
+ }
+ }
+ catch (UnknownHostException)
+ {
+ CalledName = null;
+ }
+ }
+ else
+ {
+ CalledName = null;
+ }
+ }
+ return CalledName;
+ }
- public string FirstCalledName()
- {
- CalledName = HostName.name;
- if (char.IsDigit(CalledName[0]))
- {
- int i;
- int len;
- int dots;
- char[] data;
- i = dots = 0;
- len = CalledName.Length;
- data = CalledName.ToCharArray();
- while (i < len && char.IsDigit(data[i++]))
- {
- if (i == len && dots == 3)
- {
- // probably an IP address
- CalledName = SmbserverName;
- break;
- }
- if (i < len && data[i] == '.')
- {
- dots++;
- i++;
- }
- }
- }
- else
- {
- switch (HostName.HexCode)
- {
- case unchecked(0x1B):
- case unchecked(0x1C):
- case unchecked(0x1D):
- {
- CalledName = SmbserverName;
- break;
- }
- }
- }
- return CalledName;
- }
+ ///
+ internal void CheckData()
+ {
+ if (HostName == UnknownName)
+ {
+ GetAllByAddress(this);
+ }
+ }
- public string NextCalledName()
- {
- if (CalledName == HostName.name)
- {
- CalledName = SmbserverName;
- }
- else
- {
- if (CalledName == SmbserverName)
- {
- NbtAddress[] addrs;
- try
- {
- addrs = Client.GetNodeStatus(this);
- if (HostName.HexCode == unchecked(0x1D))
- {
- for (int i = 0; i < addrs.Length; i++)
- {
- if (addrs[i].HostName.HexCode == unchecked(0x20))
- {
- return addrs[i].HostName.name;
- }
- }
- return null;
- }
- if (IsDataFromNodeStatus)
- {
- CalledName = null;
- return HostName.name;
- }
- }
- catch (UnknownHostException)
- {
- CalledName = null;
- }
- }
- else
- {
- CalledName = null;
- }
- }
- return CalledName;
- }
+ ///
+ internal void CheckNodeStatusData()
+ {
+ if (IsDataFromNodeStatus == false)
+ {
+ GetAllByAddress(this);
+ }
+ }
- ///
- internal void CheckData()
- {
- if (HostName == UnknownName)
- {
- GetAllByAddress(this);
- }
- }
+ /// Determines if the address is a group address.
+ ///
+ /// Determines if the address is a group address. This is also
+ /// known as a workgroup name or group name.
+ ///
+ /// if the host cannot be resolved to find out.
+ ///
+ public bool IsGroupAddress()
+ {
+ CheckData();
+ return GroupName;
+ }
- ///
- internal void CheckNodeStatusData()
- {
- if (IsDataFromNodeStatus == false)
- {
- GetAllByAddress(this);
- }
- }
+ /// Checks the node type of this address.
+ /// Checks the node type of this address.
+ ///
+ ///
+ /// B_NODE
+ /// ,
+ /// P_NODE
+ /// ,
+ /// M_NODE
+ /// ,
+ /// H_NODE
+ ///
+ /// if the host cannot be resolved to find out.
+ ///
+ public int GetNodeType()
+ {
+ CheckData();
+ return NodeType;
+ }
- /// Determines if the address is a group address.
- ///
- /// Determines if the address is a group address. This is also
- /// known as a workgroup name or group name.
- ///
- /// if the host cannot be resolved to find out.
- ///
- public bool IsGroupAddress()
- {
- CheckData();
- return GroupName;
- }
+ /// Determines if this address in the process of being deleted.
+ /// Determines if this address in the process of being deleted.
+ /// if the host cannot be resolved to find out.
+ ///
+ public bool IsBeingDeleted()
+ {
+ CheckNodeStatusData();
+ return isBeingDeleted;
+ }
- /// Checks the node type of this address.
- /// Checks the node type of this address.
- ///
- ///
- /// B_NODE
- /// ,
- /// P_NODE
- /// ,
- /// M_NODE
- /// ,
- /// H_NODE
- ///
- /// if the host cannot be resolved to find out.
- ///
- public int GetNodeType()
- {
- CheckData();
- return NodeType;
- }
+ /// Determines if this address in conflict with another address.
+ /// Determines if this address in conflict with another address.
+ /// if the host cannot be resolved to find out.
+ ///
+ public bool IsInConflict()
+ {
+ CheckNodeStatusData();
+ return isInConflict;
+ }
- /// Determines if this address in the process of being deleted.
- /// Determines if this address in the process of being deleted.
- /// if the host cannot be resolved to find out.
- ///
- public bool IsBeingDeleted()
- {
- CheckNodeStatusData();
- return isBeingDeleted;
- }
+ /// Determines if this address is active.
+ /// Determines if this address is active.
+ /// if the host cannot be resolved to find out.
+ ///
+ public bool IsActive()
+ {
+ CheckNodeStatusData();
+ return isActive;
+ }
- /// Determines if this address in conflict with another address.
- /// Determines if this address in conflict with another address.
- /// if the host cannot be resolved to find out.
- ///
- public bool IsInConflict()
- {
- CheckNodeStatusData();
- return isInConflict;
- }
+ /// Determines if this address is set to be permanent.
+ /// Determines if this address is set to be permanent.
+ /// if the host cannot be resolved to find out.
+ ///
+ public bool IsPermanent()
+ {
+ CheckNodeStatusData();
+ return isPermanent;
+ }
- /// Determines if this address is active.
- /// Determines if this address is active.
- /// if the host cannot be resolved to find out.
- ///
- public bool IsActive()
- {
- CheckNodeStatusData();
- return isActive;
- }
+ /// Retrieves the MAC address of the remote network interface.
+ /// Retrieves the MAC address of the remote network interface. Samba returns all zeros.
+ ///
+ /// the MAC address as an array of six bytes
+ ///
+ /// if the host cannot be resolved to
+ /// determine the MAC address.
+ ///
+ public byte[] GetMacAddress()
+ {
+ CheckNodeStatusData();
+ return MacAddress;
+ }
- /// Determines if this address is set to be permanent.
- /// Determines if this address is set to be permanent.
- /// if the host cannot be resolved to find out.
- ///
- public bool IsPermanent()
- {
- CheckNodeStatusData();
- return isPermanent;
- }
+ /// The hostname of this address.
+ ///
+ /// The hostname of this address. If the hostname is null the local machines
+ /// IP address is returned.
+ ///
+ /// the text representation of the hostname associated with this address
+ public string GetHostName()
+ {
+ if (HostName == UnknownName)
+ {
+ return GetHostAddress();
+ }
+ return HostName.name;
+ }
- /// Retrieves the MAC address of the remote network interface.
- /// Retrieves the MAC address of the remote network interface. Samba returns all zeros.
- ///
- /// the MAC address as an array of six bytes
- ///
- /// if the host cannot be resolved to
- /// determine the MAC address.
- ///
- public byte[] GetMacAddress()
- {
- CheckNodeStatusData();
- return MacAddress;
- }
+ /// Returns the raw IP address of this NbtAddress.
+ ///
+ /// Returns the raw IP address of this NbtAddress. The result is in network
+ /// byte order: the highest order byte of the address is in getAddress()[0].
+ ///
+ /// a four byte array
+ public byte[] GetAddress()
+ {
+ byte[] addr = new byte[4];
+ addr[0] = unchecked((byte)(((int)(((uint)Address) >> 24)) & unchecked(0xFF
+ )));
+ addr[1] = unchecked((byte)(((int)(((uint)Address) >> 16)) & unchecked(0xFF
+ )));
+ addr[2] = unchecked((byte)(((int)(((uint)Address) >> 8)) & unchecked(0xFF)
+ ));
+ addr[3] = unchecked((byte)(Address & unchecked(0xFF)));
+ return addr;
+ }
- /// The hostname of this address.
- ///
- /// The hostname of this address. If the hostname is null the local machines
- /// IP address is returned.
- ///
- /// the text representation of the hostname associated with this address
- public string GetHostName()
- {
- if (HostName == UnknownName)
- {
- return GetHostAddress();
- }
- return HostName.name;
- }
+ /// To convert this address to an InetAddress.
+ /// To convert this address to an InetAddress.
+ ///
+ /// the
+ /// System.Net.IPAddress
+ /// representation of this address.
+ ///
+ ///
+ public IPAddress GetInetAddress()
+ {
+ return Extensions.GetAddressByName(GetHostAddress());
+ }
- /// Returns the raw IP address of this NbtAddress.
- ///
- /// Returns the raw IP address of this NbtAddress. The result is in network
- /// byte order: the highest order byte of the address is in getAddress()[0].
- ///
- /// a four byte array
- public byte[] GetAddress()
- {
- byte[] addr = new byte[4];
- addr[0] = unchecked((byte)(((int)(((uint)Address) >> 24)) & unchecked(0xFF)));
- addr[1] = unchecked((byte)(((int)(((uint)Address) >> 16)) & unchecked(0xFF)));
- addr[2] = unchecked((byte)(((int)(((uint)Address) >> 8)) & unchecked(0xFF)));
- addr[3] = unchecked((byte)(Address & unchecked(0xFF)));
- return addr;
- }
+ ///
+ /// Returns this IP adress as a
+ /// string
+ /// in the form "%d.%d.%d.%d".
+ ///
+ public string GetHostAddress()
+ {
+ return (((int)(((uint)Address) >> 24)) & unchecked(0xFF)) + "." + (((int)(
+ ((uint)Address) >> 16)) & unchecked(0xFF)) + "." + (((int)(((uint)Address
+ ) >> 8)) & unchecked(0xFF)) + "." + (((int)(((uint)Address) >> 0)) & unchecked(
+ 0xFF));
+ }
- /// To convert this address to an InetAddress.
- /// To convert this address to an InetAddress.
- ///
- /// the
- /// System.Net.IPAddress
- /// representation of this address.
- ///
- ///
- public IPAddress GetInetAddress()
- {
- return Extensions.GetAddressByName(GetHostAddress());
- }
+ /// Returned the hex code associated with this name(e.g.
+ /// Returned the hex code associated with this name(e.g. 0x20 is for the file service)
+ ///
+ public int GetNameType()
+ {
+ return HostName.HexCode;
+ }
- ///
- /// Returns this IP adress as a
- /// string
- /// in the form "%d.%d.%d.%d".
- ///
- public string GetHostAddress()
- {
- return (((int)(((uint)Address) >> 24)) & unchecked(0xFF))
- + "." + (((int)(((uint)Address) >> 16)) & unchecked(0xFF))
- + "." + (((int)(((uint)Address) >> 8)) & unchecked(0xFF))
- + "." + (((int)(((uint)Address) >> 0)) & unchecked(0xFF));
- }
+ /// Returns a hashcode for this IP address.
+ ///
+ /// Returns a hashcode for this IP address. The hashcode comes from the IP address
+ /// and is not generated from the string representation. So because NetBIOS nodes
+ /// can have many names, all names associated with an IP will have the same
+ /// hashcode.
+ ///
+ public override int GetHashCode()
+ {
+ return Address;
+ }
- /// Returned the hex code associated with this name(e.g.
- /// Returned the hex code associated with this name(e.g. 0x20 is for the file service)
- ///
- public int GetNameType()
- {
- return HostName.HexCode;
- }
+ /// Determines if this address is equal two another.
+ ///
+ /// Determines if this address is equal two another. Only the IP Addresses
+ /// are compared. Similar to the
+ /// GetHashCode()
+ /// method, the comparison
+ /// is based on the integer IP address and not the string representation.
+ ///
+ public override bool Equals(object obj)
+ {
+ return (obj != null) && (obj is NbtAddress) && (((NbtAddress)obj).Address == Address
+ );
+ }
- /// Returns a hashcode for this IP address.
- ///
- /// Returns a hashcode for this IP address. The hashcode comes from the IP address
- /// and is not generated from the string representation. So because NetBIOS nodes
- /// can have many names, all names associated with an IP will have the same
- /// hashcode.
- ///
- public override int GetHashCode()
- {
- return Address;
- }
-
- /// Determines if this address is equal two another.
- ///
- /// Determines if this address is equal two another. Only the IP Addresses
- /// are compared. Similar to the
- /// GetHashCode()
- /// method, the comparison
- /// is based on the integer IP address and not the string representation.
- ///
- public override bool Equals(object obj)
- {
- return (obj != null)
- && (obj is NbtAddress)
- && (((NbtAddress)obj).Address == Address);
- }
-
- ///
- /// Returns the
- /// string
- /// representaion of this address.
- ///
- public override string ToString()
- {
- return HostName + "/" + GetHostAddress();
- }
- }
+ ///
+ /// Returns the
+ /// string
+ /// representaion of this address.
+ ///
+ public override string ToString()
+ {
+ return HostName + "/" + GetHostAddress();
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtException.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtException.cs
index 9ade0e67c..e785c9943 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtException.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NbtException.cs
@@ -19,147 +19,146 @@ using System.IO;
namespace SharpCifs.Netbios
{
- public class NbtException : IOException
- {
- public const int Success = 0;
+ public class NbtException : IOException
+ {
+ public const int Success = 0;
- public const int ErrNamSrvc = unchecked(0x01);
+ public const int ErrNamSrvc = unchecked(0x01);
- public const int ErrSsnSrvc = unchecked(0x02);
+ public const int ErrSsnSrvc = unchecked(0x02);
- public const int FmtErr = unchecked(0x1);
+ public const int FmtErr = unchecked(0x1);
- public const int SrvErr = unchecked(0x2);
+ public const int SrvErr = unchecked(0x2);
- public const int ImpErr = unchecked(0x4);
+ public const int ImpErr = unchecked(0x4);
- public const int RfsErr = unchecked(0x5);
+ public const int RfsErr = unchecked(0x5);
- public const int ActErr = unchecked(0x6);
+ public const int ActErr = unchecked(0x6);
- public const int CftErr = unchecked(0x7);
+ public const int CftErr = unchecked(0x7);
- public const int ConnectionRefused = -1;
+ public const int ConnectionRefused = -1;
- public const int NotListeningCalled = unchecked(0x80);
+ public const int NotListeningCalled = unchecked(0x80);
- public const int NotListeningCalling = unchecked(0x81);
+ public const int NotListeningCalling = unchecked(0x81);
- public const int CalledNotPresent = unchecked(0x82);
+ public const int CalledNotPresent = unchecked(0x82);
- public const int NoResources = unchecked(0x83);
+ public const int NoResources = unchecked(0x83);
- public const int Unspecified = unchecked(0x8F);
+ public const int Unspecified = unchecked(0x8F);
- public int ErrorClass;
+ public int ErrorClass;
- public int ErrorCode;
+ public int ErrorCode;
- // error classes
- // name service error codes
- // session service error codes
- public static string GetErrorString(int errorClass, int errorCode)
- {
- string result = string.Empty;
- switch (errorClass)
- {
- case Success:
- {
- result += "SUCCESS";
- break;
- }
+ // error classes
+ // name service error codes
+ // session service error codes
+ public static string GetErrorString(int errorClass, int errorCode)
+ {
+ string result = string.Empty;
+ switch (errorClass)
+ {
+ case Success:
+ {
+ result += "SUCCESS";
+ break;
+ }
- case ErrNamSrvc:
- {
- result += "ERR_NAM_SRVC/";
- switch (errorCode)
- {
- case FmtErr:
- {
- result += "FMT_ERR: Format Error";
- goto default;
- }
+ case ErrNamSrvc:
+ {
+ result += "ERR_NAM_SRVC/";
+ switch (errorCode)
+ {
+ case FmtErr:
+ {
+ result += "FMT_ERR: Format Error";
+ goto default;
+ }
- default:
- {
- result += "Unknown error code: " + errorCode;
- break;
- }
- }
- break;
- }
+ default:
+ {
+ result += "Unknown error code: " + errorCode;
+ break;
+ }
+ }
+ break;
+ }
- case ErrSsnSrvc:
- {
- result += "ERR_SSN_SRVC/";
- switch (errorCode)
- {
- case ConnectionRefused:
- {
- result += "Connection refused";
- break;
- }
+ case ErrSsnSrvc:
+ {
+ result += "ERR_SSN_SRVC/";
+ switch (errorCode)
+ {
+ case ConnectionRefused:
+ {
+ result += "Connection refused";
+ break;
+ }
- case NotListeningCalled:
- {
- result += "Not listening on called name";
- break;
- }
+ case NotListeningCalled:
+ {
+ result += "Not listening on called name";
+ break;
+ }
- case NotListeningCalling:
- {
- result += "Not listening for calling name";
- break;
- }
+ case NotListeningCalling:
+ {
+ result += "Not listening for calling name";
+ break;
+ }
- case CalledNotPresent:
- {
- result += "Called name not present";
- break;
- }
+ case CalledNotPresent:
+ {
+ result += "Called name not present";
+ break;
+ }
- case NoResources:
- {
- result += "Called name present, but insufficient resources";
- break;
- }
+ case NoResources:
+ {
+ result += "Called name present, but insufficient resources";
+ break;
+ }
- case Unspecified:
- {
- result += "Unspecified error";
- break;
- }
+ case Unspecified:
+ {
+ result += "Unspecified error";
+ break;
+ }
- default:
- {
- result += "Unknown error code: " + errorCode;
- break;
- }
- }
- break;
- }
+ default:
+ {
+ result += "Unknown error code: " + errorCode;
+ break;
+ }
+ }
+ break;
+ }
- default:
- {
- result += "unknown error class: " + errorClass;
- break;
- }
- }
- return result;
- }
+ default:
+ {
+ result += "unknown error class: " + errorClass;
+ break;
+ }
+ }
+ return result;
+ }
- public NbtException(int errorClass, int errorCode) : base(GetErrorString(errorClass
- , errorCode))
- {
- this.ErrorClass = errorClass;
- this.ErrorCode = errorCode;
- }
+ public NbtException(int errorClass, int errorCode) : base(GetErrorString(errorClass
+ , errorCode))
+ {
+ this.ErrorClass = errorClass;
+ this.ErrorCode = errorCode;
+ }
- public override string ToString()
- {
- return "errorClass=" + ErrorClass
- + ",errorCode=" + ErrorCode
- + ",errorString=" + GetErrorString(ErrorClass, ErrorCode);
- }
- }
+ public override string ToString()
+ {
+ return "errorClass=" + ErrorClass + ",errorCode=" + ErrorCode + ",errorString="
+ + GetErrorString(ErrorClass, ErrorCode);
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusRequest.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusRequest.cs
index b7922eb84..66d3bb3e5 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusRequest.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusRequest.cs
@@ -16,44 +16,44 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Netbios
{
- internal class NodeStatusRequest : NameServicePacket
- {
- internal NodeStatusRequest(Name name)
- {
- QuestionName = name;
- QuestionType = Nbstat;
- IsRecurDesired = false;
- IsBroadcast = false;
- }
+ internal class NodeStatusRequest : NameServicePacket
+ {
+ internal NodeStatusRequest(Name name)
+ {
+ QuestionName = name;
+ QuestionType = Nbstat;
+ IsRecurDesired = false;
+ IsBroadcast = false;
+ }
- internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
- {
- int tmp = QuestionName.HexCode;
- QuestionName.HexCode = unchecked(0x00);
- // type has to be 0x00 for node status
- int result = WriteQuestionSectionWireFormat(dst, dstIndex);
- QuestionName.HexCode = tmp;
- return result;
- }
+ internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
+ {
+ int tmp = QuestionName.HexCode;
+ QuestionName.HexCode = unchecked(0x00);
+ // type has to be 0x00 for node status
+ int result = WriteQuestionSectionWireFormat(dst, dstIndex);
+ QuestionName.HexCode = tmp;
+ return result;
+ }
- internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
- {
- return 0;
- }
+ internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
+ {
+ return 0;
+ }
- internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
- {
- return 0;
- }
+ internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
+ {
+ return 0;
+ }
- public override string ToString()
- {
- return "NodeStatusRequest[" + base.ToString() + "]";
- }
- }
+ public override string ToString()
+ {
+ return "NodeStatusRequest[" + base.ToString() + "]";
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusResponse.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusResponse.cs
index ac0210217..aa3214419 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusResponse.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/NodeStatusResponse.cs
@@ -19,140 +19,122 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- internal class NodeStatusResponse : NameServicePacket
- {
- private NbtAddress _queryAddress;
+ internal class NodeStatusResponse : NameServicePacket
+ {
+ private NbtAddress _queryAddress;
- private int _numberOfNames;
+ private int _numberOfNames;
- private byte[] _macAddress;
+ private byte[] _macAddress;
- private byte[] _stats;
+ private byte[] _stats;
- internal NbtAddress[] AddressArray;
+ internal NbtAddress[] AddressArray;
- internal NodeStatusResponse(NbtAddress queryAddress)
- {
- this._queryAddress = queryAddress;
- RecordName = new Name();
- _macAddress = new byte[6];
- }
+ internal NodeStatusResponse(NbtAddress queryAddress)
+ {
+ this._queryAddress = queryAddress;
+ RecordName = new Name();
+ _macAddress = new byte[6];
+ }
- internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteBodyWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
- {
- return ReadResourceRecordWireFormat(src, srcIndex);
- }
+ internal override int ReadBodyWireFormat(byte[] src, int srcIndex)
+ {
+ return ReadResourceRecordWireFormat(src, srcIndex);
+ }
- internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteRDataWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- _numberOfNames = src[srcIndex] & unchecked(0xFF);
- int namesLength = _numberOfNames * 18;
- int statsLength = RDataLength - namesLength - 1;
- _numberOfNames = src[srcIndex++] & unchecked(0xFF);
- // gotta read the mac first so we can populate addressArray with it
- Array.Copy(src, srcIndex + namesLength, _macAddress, 0, 6);
- srcIndex += ReadNodeNameArray(src, srcIndex);
- _stats = new byte[statsLength];
- Array.Copy(src, srcIndex, _stats, 0, statsLength);
- srcIndex += statsLength;
- return srcIndex - start;
- }
+ internal override int ReadRDataWireFormat(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ _numberOfNames = src[srcIndex] & unchecked(0xFF);
+ int namesLength = _numberOfNames * 18;
+ int statsLength = RDataLength - namesLength - 1;
+ _numberOfNames = src[srcIndex++] & unchecked(0xFF);
+ // gotta read the mac first so we can populate addressArray with it
+ Array.Copy(src, srcIndex + namesLength, _macAddress, 0, 6);
+ srcIndex += ReadNodeNameArray(src, srcIndex);
+ _stats = new byte[statsLength];
+ Array.Copy(src, srcIndex, _stats, 0, statsLength);
+ srcIndex += statsLength;
+ return srcIndex - start;
+ }
- private int ReadNodeNameArray(byte[] src, int srcIndex)
- {
- int start = srcIndex;
- AddressArray = new NbtAddress[_numberOfNames];
- string n;
- int hexCode;
- string scope = _queryAddress.HostName.Scope;
- bool groupName;
- int ownerNodeType;
- bool isBeingDeleted;
- bool isInConflict;
- bool isActive;
- bool isPermanent;
- int j;
- bool addrFound = false;
- try
- {
- for (int i = 0; i < _numberOfNames; srcIndex += 18, i++)
- {
- for (j = srcIndex + 14; src[j] == unchecked(0x20); j--)
- {
- }
- n = Runtime.GetStringForBytes(src, srcIndex, j - srcIndex + 1, Name.OemEncoding
- );
- hexCode = src[srcIndex + 15] & unchecked(0xFF);
- groupName = ((src[srcIndex + 16] & unchecked(0x80)) == unchecked(0x80))
- ? true
- : false;
- ownerNodeType = (src[srcIndex + 16] & unchecked(0x60)) >> 5;
- isBeingDeleted = ((src[srcIndex + 16] & unchecked(0x10)) == unchecked(0x10))
- ? true
- : false;
- isInConflict = ((src[srcIndex + 16] & unchecked(0x08)) == unchecked(0x08))
- ? true
- : false;
- isActive = ((src[srcIndex + 16] & unchecked(0x04)) == unchecked(0x04))
- ? true
- : false;
- isPermanent = ((src[srcIndex + 16] & unchecked(0x02)) == unchecked(0x02))
- ? true
- : false;
- if (!addrFound
- && _queryAddress.HostName.HexCode == hexCode
- && (_queryAddress.HostName == NbtAddress.UnknownName
- || _queryAddress.HostName.name.Equals(n)))
- {
- if (_queryAddress.HostName == NbtAddress.UnknownName)
- {
- _queryAddress.HostName = new Name(n, hexCode, scope);
- }
- _queryAddress.GroupName = groupName;
- _queryAddress.NodeType = ownerNodeType;
- _queryAddress.isBeingDeleted = isBeingDeleted;
- _queryAddress.isInConflict = isInConflict;
- _queryAddress.isActive = isActive;
- _queryAddress.isPermanent = isPermanent;
- _queryAddress.MacAddress = _macAddress;
- _queryAddress.IsDataFromNodeStatus = true;
- addrFound = true;
- AddressArray[i] = _queryAddress;
- }
- else
- {
- AddressArray[i] = new NbtAddress(new Name(n, hexCode, scope),
- _queryAddress.Address,
- groupName,
- ownerNodeType,
- isBeingDeleted,
- isInConflict,
- isActive,
- isPermanent,
- _macAddress);
- }
- }
- }
- catch (UnsupportedEncodingException)
- {
- }
- return srcIndex - start;
- }
+ private int ReadNodeNameArray(byte[] src, int srcIndex)
+ {
+ int start = srcIndex;
+ AddressArray = new NbtAddress[_numberOfNames];
+ string n;
+ int hexCode;
+ string scope = _queryAddress.HostName.Scope;
+ bool groupName;
+ int ownerNodeType;
+ bool isBeingDeleted;
+ bool isInConflict;
+ bool isActive;
+ bool isPermanent;
+ int j;
+ bool addrFound = false;
+ try
+ {
+ for (int i = 0; i < _numberOfNames; srcIndex += 18, i++)
+ {
+ for (j = srcIndex + 14; src[j] == unchecked(0x20); j--)
+ {
+ }
+ n = Runtime.GetStringForBytes(src, srcIndex, j - srcIndex + 1, Name.OemEncoding
+ );
+ hexCode = src[srcIndex + 15] & unchecked(0xFF);
+ groupName = ((src[srcIndex + 16] & unchecked(0x80)) == unchecked(0x80)) ? true : false;
+ ownerNodeType = (src[srcIndex + 16] & unchecked(0x60)) >> 5;
+ isBeingDeleted = ((src[srcIndex + 16] & unchecked(0x10)) == unchecked(0x10)) ? true : false;
+ isInConflict = ((src[srcIndex + 16] & unchecked(0x08)) == unchecked(0x08)) ? true : false;
+ isActive = ((src[srcIndex + 16] & unchecked(0x04)) == unchecked(0x04)) ? true : false;
+ isPermanent = ((src[srcIndex + 16] & unchecked(0x02)) == unchecked(0x02)) ? true : false;
+ if (!addrFound && _queryAddress.HostName.HexCode == hexCode && (_queryAddress.HostName
+ == NbtAddress.UnknownName || _queryAddress.HostName.name.Equals(n)))
+ {
+ if (_queryAddress.HostName == NbtAddress.UnknownName)
+ {
+ _queryAddress.HostName = new Name(n, hexCode, scope);
+ }
+ _queryAddress.GroupName = groupName;
+ _queryAddress.NodeType = ownerNodeType;
+ _queryAddress.isBeingDeleted = isBeingDeleted;
+ _queryAddress.isInConflict = isInConflict;
+ _queryAddress.isActive = isActive;
+ _queryAddress.isPermanent = isPermanent;
+ _queryAddress.MacAddress = _macAddress;
+ _queryAddress.IsDataFromNodeStatus = true;
+ addrFound = true;
+ AddressArray[i] = _queryAddress;
+ }
+ else
+ {
+ AddressArray[i] = new NbtAddress(new Name(n, hexCode, scope), _queryAddress.Address
+ , groupName, ownerNodeType, isBeingDeleted, isInConflict, isActive, isPermanent,
+ _macAddress);
+ }
+ }
+ }
+ catch (UnsupportedEncodingException)
+ {
+ }
+ return srcIndex - start;
+ }
- public override string ToString()
- {
- return "NodeStatusResponse[" + base.ToString() + "]";
- }
- }
+ public override string ToString()
+ {
+ return "NodeStatusResponse[" + base.ToString() + "]";
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRequestPacket.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRequestPacket.cs
index 0f4d7e5e2..a5243f7aa 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRequestPacket.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRequestPacket.cs
@@ -19,44 +19,45 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- public class SessionRequestPacket : SessionServicePacket
- {
- private Name _calledName;
+ public class SessionRequestPacket : SessionServicePacket
+ {
+ private Name _calledName;
- private Name _callingName;
+ private Name _callingName;
- public SessionRequestPacket()
- {
- _calledName = new Name();
- _callingName = new Name();
- }
+ public SessionRequestPacket()
+ {
+ _calledName = new Name();
+ _callingName = new Name();
+ }
- public SessionRequestPacket(Name calledName, Name callingName)
- {
- Type = SessionRequest;
- this._calledName = calledName;
- this._callingName = callingName;
- }
+ public SessionRequestPacket(Name calledName, Name callingName)
+ {
+ Type = SessionRequest;
+ this._calledName = calledName;
+ this._callingName = callingName;
+ }
- internal override int WriteTrailerWireFormat(byte[] dst, int dstIndex)
- {
- int start = dstIndex;
- dstIndex += _calledName.WriteWireFormat(dst, dstIndex);
- dstIndex += _callingName.WriteWireFormat(dst, dstIndex);
- return dstIndex - start;
- }
+ internal override int WriteTrailerWireFormat(byte[] dst, int dstIndex)
+ {
+ int start = dstIndex;
+ dstIndex += _calledName.WriteWireFormat(dst, dstIndex);
+ dstIndex += _callingName.WriteWireFormat(dst, dstIndex);
+ return dstIndex - start;
+ }
- ///
- internal override int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex)
- {
- int start = bufferIndex;
- if (@in.Read(buffer, bufferIndex, Length) != Length)
- {
- throw new IOException("invalid session request wire format");
- }
- bufferIndex += _calledName.ReadWireFormat(buffer, bufferIndex);
- bufferIndex += _callingName.ReadWireFormat(buffer, bufferIndex);
- return bufferIndex - start;
- }
- }
+ ///
+ internal override int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex
+ )
+ {
+ int start = bufferIndex;
+ if (@in.Read(buffer, bufferIndex, Length) != Length)
+ {
+ throw new IOException("invalid session request wire format");
+ }
+ bufferIndex += _calledName.ReadWireFormat(buffer, bufferIndex);
+ bufferIndex += _callingName.ReadWireFormat(buffer, bufferIndex);
+ return bufferIndex - start;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRetargetResponsePacket.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRetargetResponsePacket.cs
index 48c772bae..c901c6e26 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRetargetResponsePacket.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionRetargetResponsePacket.cs
@@ -19,35 +19,36 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- internal class SessionRetargetResponsePacket : SessionServicePacket
- {
- private NbtAddress _retargetAddress;
+ internal class SessionRetargetResponsePacket : SessionServicePacket
+ {
+ private NbtAddress _retargetAddress;
- private int _retargetPort;
+ private int _retargetPort;
- public SessionRetargetResponsePacket()
- {
- Type = SessionRetargetResponse;
- Length = 6;
- }
+ public SessionRetargetResponsePacket()
+ {
+ Type = SessionRetargetResponse;
+ Length = 6;
+ }
- internal override int WriteTrailerWireFormat(byte[] dst, int dstIndex)
- {
- return 0;
- }
+ internal override int WriteTrailerWireFormat(byte[] dst, int dstIndex)
+ {
+ return 0;
+ }
- ///
- internal override int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex)
- {
- if (@in.Read(buffer, bufferIndex, Length) != Length)
- {
- throw new IOException("unexpected EOF reading netbios retarget session response");
- }
- int addr = ReadInt4(buffer, bufferIndex);
- bufferIndex += 4;
- _retargetAddress = new NbtAddress(null, addr, false, NbtAddress.BNode);
- _retargetPort = ReadInt2(buffer, bufferIndex);
- return Length;
- }
- }
+ ///
+ internal override int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex
+ )
+ {
+ if (@in.Read(buffer, bufferIndex, Length) != Length)
+ {
+ throw new IOException("unexpected EOF reading netbios retarget session response");
+ }
+ int addr = ReadInt4(buffer, bufferIndex);
+ bufferIndex += 4;
+ _retargetAddress = new NbtAddress(null, addr, false, NbtAddress.BNode);
+ _retargetPort = ReadInt2(buffer, bufferIndex);
+ return Length;
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionServicePacket.cs b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionServicePacket.cs
index 795dff9bd..c8d194222 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionServicePacket.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Netbios/SessionServicePacket.cs
@@ -19,136 +19,138 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Netbios
{
- public abstract class SessionServicePacket
- {
- internal const int SessionMessage = unchecked(0x00);
+ public abstract class SessionServicePacket
+ {
+ internal const int SessionMessage = unchecked(0x00);
- internal const int SessionRequest = unchecked(0x81);
+ internal const int SessionRequest = unchecked(0x81);
- public const int PositiveSessionResponse = unchecked(0x82);
+ public const int PositiveSessionResponse = unchecked(0x82);
- public const int NegativeSessionResponse = unchecked(0x83);
+ public const int NegativeSessionResponse = unchecked(0x83);
- internal const int SessionRetargetResponse = unchecked(0x84);
+ internal const int SessionRetargetResponse = unchecked(0x84);
- internal const int SessionKeepAlive = unchecked(0x85);
+ internal const int SessionKeepAlive = unchecked(0x85);
- internal const int MaxMessageSize = unchecked(0x0001FFFF);
+ internal const int MaxMessageSize = unchecked(0x0001FFFF);
- internal const int HeaderLength = 4;
+ internal const int HeaderLength = 4;
- // session service packet types
- internal static void WriteInt2(int val, byte[] dst, int dstIndex)
- {
- dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
- dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
- }
+ // session service packet types
+ internal static void WriteInt2(int val, byte[] dst, int dstIndex)
+ {
+ dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
+ dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
+ }
- internal static void WriteInt4(int val, byte[] dst, int dstIndex)
- {
- dst[dstIndex++] = unchecked((byte)((val >> 24) & unchecked(0xFF)));
- dst[dstIndex++] = unchecked((byte)((val >> 16) & unchecked(0xFF)));
- dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
- dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
- }
+ internal static void WriteInt4(int val, byte[] dst, int dstIndex)
+ {
+ dst[dstIndex++] = unchecked((byte)((val >> 24) & unchecked(0xFF)));
+ dst[dstIndex++] = unchecked((byte)((val >> 16) & unchecked(0xFF)));
+ dst[dstIndex++] = unchecked((byte)((val >> 8) & unchecked(0xFF)));
+ dst[dstIndex] = unchecked((byte)(val & unchecked(0xFF)));
+ }
- internal static int ReadInt2(byte[] src, int srcIndex)
- {
- return ((src[srcIndex] & unchecked(0xFF)) << 8)
- + (src[srcIndex + 1] & unchecked(0xFF));
- }
+ internal static int ReadInt2(byte[] src, int srcIndex)
+ {
+ return ((src[srcIndex] & unchecked(0xFF)) << 8) + (src[srcIndex + 1] & unchecked(
+ 0xFF));
+ }
- internal static int ReadInt4(byte[] src, int srcIndex)
- {
- return ((src[srcIndex] & unchecked(0xFF)) << 24)
- + ((src[srcIndex + 1] & unchecked(0xFF)) << 16)
- + ((src[srcIndex + 2] & unchecked(0xFF)) << 8)
- + (src[srcIndex + 3] & unchecked(0xFF));
- }
+ internal static int ReadInt4(byte[] src, int srcIndex)
+ {
+ return ((src[srcIndex] & unchecked(0xFF)) << 24) + ((src[srcIndex + 1] & unchecked(
+ 0xFF)) << 16) + ((src[srcIndex + 2] & unchecked(0xFF)) << 8) + (src
+ [srcIndex + 3] & unchecked(0xFF));
+ }
- internal static int ReadLength(byte[] src, int srcIndex)
- {
- srcIndex++;
- return ((src[srcIndex++] & unchecked(0x01)) << 16)
- + ((src[srcIndex++] & unchecked(0xFF)) << 8)
- + (src[srcIndex++] & unchecked(0xFF));
- }
+ internal static int ReadLength(byte[] src, int srcIndex)
+ {
+ srcIndex++;
+ return ((src[srcIndex++] & unchecked(0x01)) << 16) + ((src[srcIndex++] & unchecked(
+ 0xFF)) << 8) + (src[srcIndex++] & unchecked(0xFF));
+ }
- ///
- internal static int Readn(InputStream @in, byte[] b, int off, int len)
- {
- int i = 0;
- int n;
- while (i < len)
- {
- n = @in.Read(b, off + i, len - i);
- if (n <= 0)
- {
- break;
- }
- i += n;
- }
- return i;
- }
+ ///
+ internal static int Readn(InputStream @in, byte[] b, int off, int len)
+ {
+ int i = 0;
+ int n;
+ while (i < len)
+ {
+ n = @in.Read(b, off + i, len - i);
+ if (n <= 0)
+ {
+ break;
+ }
+ i += n;
+ }
+ return i;
+ }
- ///
- internal static int ReadPacketType(InputStream @in, byte[] buffer, int bufferIndex)
- {
- int n;
- if ((n = Readn(@in, buffer, bufferIndex, HeaderLength)) != HeaderLength)
- {
- if (n == -1)
- {
- return -1;
- }
- throw new IOException("unexpected EOF reading netbios session header");
- }
- int t = buffer[bufferIndex] & unchecked(0xFF);
- return t;
- }
+ ///
+ internal static int ReadPacketType(InputStream @in, byte[] buffer, int bufferIndex
+ )
+ {
+ int n;
+ if ((n = Readn(@in, buffer, bufferIndex, HeaderLength)) != HeaderLength)
+ {
+ if (n == -1)
+ {
+ return -1;
+ }
+ throw new IOException("unexpected EOF reading netbios session header");
+ }
+ int t = buffer[bufferIndex] & unchecked(0xFF);
+ return t;
+ }
- internal int Type;
+ internal int Type;
- internal int Length;
+ internal int Length;
- public virtual int WriteWireFormat(byte[] dst, int dstIndex)
- {
- Length = WriteTrailerWireFormat(dst, dstIndex + HeaderLength);
- WriteHeaderWireFormat(dst, dstIndex);
- return HeaderLength + Length;
- }
+ public virtual int WriteWireFormat(byte[] dst, int dstIndex)
+ {
+ Length = WriteTrailerWireFormat(dst, dstIndex + HeaderLength);
+ WriteHeaderWireFormat(dst, dstIndex);
+ return HeaderLength + Length;
+ }
- ///
- internal virtual int ReadWireFormat(InputStream @in, byte[] buffer, int bufferIndex)
- {
- ReadHeaderWireFormat(@in, buffer, bufferIndex);
- return HeaderLength + ReadTrailerWireFormat(@in, buffer, bufferIndex);
- }
+ ///
+ internal virtual int ReadWireFormat(InputStream @in, byte[] buffer, int bufferIndex
+ )
+ {
+ ReadHeaderWireFormat(@in, buffer, bufferIndex);
+ return HeaderLength + ReadTrailerWireFormat(@in, buffer, bufferIndex);
+ }
- internal virtual int WriteHeaderWireFormat(byte[] dst, int dstIndex)
- {
- dst[dstIndex++] = unchecked((byte)Type);
- if (Length > unchecked(0x0000FFFF))
- {
- dst[dstIndex] = unchecked(unchecked(0x01));
- }
- dstIndex++;
- WriteInt2(Length, dst, dstIndex);
- return HeaderLength;
- }
+ internal virtual int WriteHeaderWireFormat(byte[] dst, int dstIndex)
+ {
+ dst[dstIndex++] = unchecked((byte)Type);
+ if (Length > unchecked(0x0000FFFF))
+ {
+ dst[dstIndex] = unchecked(unchecked(0x01));
+ }
+ dstIndex++;
+ WriteInt2(Length, dst, dstIndex);
+ return HeaderLength;
+ }
- ///
- internal virtual int ReadHeaderWireFormat(InputStream @in, byte[] buffer, int bufferIndex)
- {
- Type = buffer[bufferIndex++] & unchecked(0xFF);
- Length = ((buffer[bufferIndex] & unchecked(0x01)) << 16)
- + ReadInt2(buffer, bufferIndex + 1);
- return HeaderLength;
- }
+ ///
+ internal virtual int ReadHeaderWireFormat(InputStream @in, byte[] buffer, int bufferIndex
+ )
+ {
+ Type = buffer[bufferIndex++] & unchecked(0xFF);
+ Length = ((buffer[bufferIndex] & unchecked(0x01)) << 16) + ReadInt2(buffer
+ , bufferIndex + 1);
+ return HeaderLength;
+ }
- internal abstract int WriteTrailerWireFormat(byte[] dst, int dstIndex);
+ internal abstract int WriteTrailerWireFormat(byte[] dst, int dstIndex);
- ///
- internal abstract int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex);
- }
+ ///
+ internal abstract int ReadTrailerWireFormat(InputStream @in, byte[] buffer, int bufferIndex
+ );
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmFlags.cs b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmFlags.cs
index 0c5ce261e..116f71b75 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmFlags.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmFlags.cs
@@ -16,181 +16,182 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
namespace SharpCifs.Ntlmssp
{
- /// Flags used during negotiation of NTLMSSP authentication.
- /// Flags used during negotiation of NTLMSSP authentication.
- public abstract class NtlmFlags
- {
- /// Indicates whether Unicode strings are supported or used.
- /// Indicates whether Unicode strings are supported or used.
- public const int NtlmsspNegotiateUnicode = unchecked(0x00000001);
+ /// Flags used during negotiation of NTLMSSP authentication.
+ /// Flags used during negotiation of NTLMSSP authentication.
+ public abstract class NtlmFlags
+ {
+ /// Indicates whether Unicode strings are supported or used.
+ /// Indicates whether Unicode strings are supported or used.
+ public const int NtlmsspNegotiateUnicode = unchecked(0x00000001);
- /// Indicates whether OEM strings are supported or used.
- /// Indicates whether OEM strings are supported or used.
- public const int NtlmsspNegotiateOem = unchecked(0x00000002);
+ /// Indicates whether OEM strings are supported or used.
+ /// Indicates whether OEM strings are supported or used.
+ public const int NtlmsspNegotiateOem = unchecked(0x00000002);
- ///
- /// Indicates whether the authentication target is requested from
- /// the server.
- ///
- ///
- /// Indicates whether the authentication target is requested from
- /// the server.
- ///
- public const int NtlmsspRequestTarget = unchecked(0x00000004);
+ ///
+ /// Indicates whether the authentication target is requested from
+ /// the server.
+ ///
+ ///
+ /// Indicates whether the authentication target is requested from
+ /// the server.
+ ///
+ public const int NtlmsspRequestTarget = unchecked(0x00000004);
- ///
- /// Specifies that communication across the authenticated channel
- /// should carry a digital signature (message integrity).
- ///
- ///
- /// Specifies that communication across the authenticated channel
- /// should carry a digital signature (message integrity).
- ///
- public const int NtlmsspNegotiateSign = unchecked(0x00000010);
+ ///
+ /// Specifies that communication across the authenticated channel
+ /// should carry a digital signature (message integrity).
+ ///
+ ///
+ /// Specifies that communication across the authenticated channel
+ /// should carry a digital signature (message integrity).
+ ///
+ public const int NtlmsspNegotiateSign = unchecked(0x00000010);
- ///
- /// Specifies that communication across the authenticated channel
- /// should be encrypted (message confidentiality).
- ///
- ///
- /// Specifies that communication across the authenticated channel
- /// should be encrypted (message confidentiality).
- ///
- public const int NtlmsspNegotiateSeal = unchecked(0x00000020);
+ ///
+ /// Specifies that communication across the authenticated channel
+ /// should be encrypted (message confidentiality).
+ ///
+ ///
+ /// Specifies that communication across the authenticated channel
+ /// should be encrypted (message confidentiality).
+ ///
+ public const int NtlmsspNegotiateSeal = unchecked(0x00000020);
- /// Indicates datagram authentication.
- /// Indicates datagram authentication.
- public const int NtlmsspNegotiateDatagramStyle = unchecked(0x00000040);
+ /// Indicates datagram authentication.
+ /// Indicates datagram authentication.
+ public const int NtlmsspNegotiateDatagramStyle = unchecked(0x00000040);
- ///
- /// Indicates that the LAN Manager session key should be used for
- /// signing and sealing authenticated communication.
- ///
- ///
- /// Indicates that the LAN Manager session key should be used for
- /// signing and sealing authenticated communication.
- ///
- public const int NtlmsspNegotiateLmKey = unchecked(0x00000080);
+ ///
+ /// Indicates that the LAN Manager session key should be used for
+ /// signing and sealing authenticated communication.
+ ///
+ ///
+ /// Indicates that the LAN Manager session key should be used for
+ /// signing and sealing authenticated communication.
+ ///
+ public const int NtlmsspNegotiateLmKey = unchecked(0x00000080);
- public const int NtlmsspNegotiateNetware = unchecked(0x00000100);
+ public const int NtlmsspNegotiateNetware = unchecked(0x00000100);
- /// Indicates support for NTLM authentication.
- /// Indicates support for NTLM authentication.
- public const int NtlmsspNegotiateNtlm = unchecked(0x00000200);
+ /// Indicates support for NTLM authentication.
+ /// Indicates support for NTLM authentication.
+ public const int NtlmsspNegotiateNtlm = unchecked(0x00000200);
- ///
- /// Indicates whether the OEM-formatted domain name in which the
- /// client workstation has membership is supplied in the Type-1 message.
- ///
- ///
- /// Indicates whether the OEM-formatted domain name in which the
- /// client workstation has membership is supplied in the Type-1 message.
- /// This is used in the negotation of local authentication.
- ///
- public const int NtlmsspNegotiateOemDomainSupplied = unchecked(0x00001000);
+ ///
+ /// Indicates whether the OEM-formatted domain name in which the
+ /// client workstation has membership is supplied in the Type-1 message.
+ ///
+ ///
+ /// Indicates whether the OEM-formatted domain name in which the
+ /// client workstation has membership is supplied in the Type-1 message.
+ /// This is used in the negotation of local authentication.
+ ///
+ public const int NtlmsspNegotiateOemDomainSupplied = unchecked(0x00001000);
- ///
- /// Indicates whether the OEM-formatted workstation name is supplied
- /// in the Type-1 message.
- ///
- ///
- /// Indicates whether the OEM-formatted workstation name is supplied
- /// in the Type-1 message. This is used in the negotiation of local
- /// authentication.
- ///
- public const int NtlmsspNegotiateOemWorkstationSupplied = unchecked(0x00002000);
+ ///
+ /// Indicates whether the OEM-formatted workstation name is supplied
+ /// in the Type-1 message.
+ ///
+ ///
+ /// Indicates whether the OEM-formatted workstation name is supplied
+ /// in the Type-1 message. This is used in the negotiation of local
+ /// authentication.
+ ///
+ public const int NtlmsspNegotiateOemWorkstationSupplied = unchecked(0x00002000);
- ///
- /// Sent by the server to indicate that the server and client are
- /// on the same machine.
- ///
- ///
- /// Sent by the server to indicate that the server and client are
- /// on the same machine. This implies that the server will include
- /// a local security context handle in the Type 2 message, for
- /// use in local authentication.
- ///
- public const int NtlmsspNegotiateLocalCall = unchecked(0x00004000);
+ ///
+ /// Sent by the server to indicate that the server and client are
+ /// on the same machine.
+ ///
+ ///
+ /// Sent by the server to indicate that the server and client are
+ /// on the same machine. This implies that the server will include
+ /// a local security context handle in the Type 2 message, for
+ /// use in local authentication.
+ ///
+ public const int NtlmsspNegotiateLocalCall = unchecked(0x00004000);
- ///
- /// Indicates that authenticated communication between the client
- /// and server should carry a "dummy" digital signature.
- ///
- ///
- /// Indicates that authenticated communication between the client
- /// and server should carry a "dummy" digital signature.
- ///
- public const int NtlmsspNegotiateAlwaysSign = unchecked(0x00008000);
+ ///
+ /// Indicates that authenticated communication between the client
+ /// and server should carry a "dummy" digital signature.
+ ///
+ ///
+ /// Indicates that authenticated communication between the client
+ /// and server should carry a "dummy" digital signature.
+ ///
+ public const int NtlmsspNegotiateAlwaysSign = unchecked(0x00008000);
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a domain.
- ///
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a domain.
- ///
- public const int NtlmsspTargetTypeDomain = unchecked(0x00010000);
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a domain.
+ ///
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a domain.
+ ///
+ public const int NtlmsspTargetTypeDomain = unchecked(0x00010000);
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a server.
- ///
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a server.
- ///
- public const int NtlmsspTargetTypeServer = unchecked(0x00020000);
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a server.
+ ///
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a server.
+ ///
+ public const int NtlmsspTargetTypeServer = unchecked(0x00020000);
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a share (presumably for share-level
- /// authentication).
- ///
- ///
- /// Sent by the server in the Type 2 message to indicate that the
- /// target authentication realm is a share (presumably for share-level
- /// authentication).
- ///
- public const int NtlmsspTargetTypeShare = unchecked(0x00040000);
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a share (presumably for share-level
+ /// authentication).
+ ///
+ ///
+ /// Sent by the server in the Type 2 message to indicate that the
+ /// target authentication realm is a share (presumably for share-level
+ /// authentication).
+ ///
+ public const int NtlmsspTargetTypeShare = unchecked(0x00040000);
- ///
- /// Indicates that the NTLM2 signing and sealing scheme should be used
- /// for protecting authenticated communications.
- ///
- ///
- /// Indicates that the NTLM2 signing and sealing scheme should be used
- /// for protecting authenticated communications. This refers to a
- /// particular session security scheme, and is not related to the use
- /// of NTLMv2 authentication.
- ///
- public const int NtlmsspNegotiateNtlm2 = unchecked(0x00080000);
+ ///
+ /// Indicates that the NTLM2 signing and sealing scheme should be used
+ /// for protecting authenticated communications.
+ ///
+ ///
+ /// Indicates that the NTLM2 signing and sealing scheme should be used
+ /// for protecting authenticated communications. This refers to a
+ /// particular session security scheme, and is not related to the use
+ /// of NTLMv2 authentication.
+ ///
+ public const int NtlmsspNegotiateNtlm2 = unchecked(0x00080000);
- public const int NtlmsspRequestInitResponse = unchecked(0x00100000);
+ public const int NtlmsspRequestInitResponse = unchecked(0x00100000);
- public const int NtlmsspRequestAcceptResponse = unchecked(0x00200000);
+ public const int NtlmsspRequestAcceptResponse = unchecked(0x00200000);
- public const int NtlmsspRequestNonNtSessionKey = unchecked(0x00400000);
+ public const int NtlmsspRequestNonNtSessionKey = unchecked(0x00400000
+ );
- ///
- /// Sent by the server in the Type 2 message to indicate that it is
- /// including a Target Information block in the message.
- ///
- ///
- /// Sent by the server in the Type 2 message to indicate that it is
- /// including a Target Information block in the message. The Target
- /// Information block is used in the calculation of the NTLMv2 response.
- ///
- public const int NtlmsspNegotiateTargetInfo = unchecked(0x00800000);
+ ///
+ /// Sent by the server in the Type 2 message to indicate that it is
+ /// including a Target Information block in the message.
+ ///
+ ///
+ /// Sent by the server in the Type 2 message to indicate that it is
+ /// including a Target Information block in the message. The Target
+ /// Information block is used in the calculation of the NTLMv2 response.
+ ///
+ public const int NtlmsspNegotiateTargetInfo = unchecked(0x00800000);
- /// Indicates that 128-bit encryption is supported.
- /// Indicates that 128-bit encryption is supported.
- public const int NtlmsspNegotiate128 = unchecked(0x20000000);
+ /// Indicates that 128-bit encryption is supported.
+ /// Indicates that 128-bit encryption is supported.
+ public const int NtlmsspNegotiate128 = unchecked(0x20000000);
- public const int NtlmsspNegotiateKeyExch = unchecked(0x40000000);
+ public const int NtlmsspNegotiateKeyExch = unchecked(0x40000000);
- /// Indicates that 56-bit encryption is supported.
- /// Indicates that 56-bit encryption is supported.
- public const int NtlmsspNegotiate56 = unchecked((int)(0x80000000));
- }
+ /// Indicates that 56-bit encryption is supported.
+ /// Indicates that 56-bit encryption is supported.
+ public const int NtlmsspNegotiate56 = unchecked((int)(0x80000000));
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmMessage.cs b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmMessage.cs
index d72a434af..02827d2d0 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmMessage.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/NtlmMessage.cs
@@ -18,137 +18,123 @@ using System;
namespace SharpCifs.Ntlmssp
{
- /// Abstract superclass for all NTLMSSP messages.
- /// Abstract superclass for all NTLMSSP messages.
- public abstract class NtlmMessage : NtlmFlags
- {
- /// The NTLMSSP "preamble".
- /// The NTLMSSP "preamble".
- protected internal static readonly byte[] NtlmsspSignature =
- {
- unchecked((byte)('N')),
- unchecked((byte)('T')),
- unchecked((byte)('L')),
- unchecked((byte)('M')),
- unchecked((byte)('S')),
- unchecked((byte)('S')),
- unchecked((byte)('P')),
- unchecked(0)
- };
+ /// Abstract superclass for all NTLMSSP messages.
+ /// Abstract superclass for all NTLMSSP messages.
+ public abstract class NtlmMessage : NtlmFlags
+ {
+ /// The NTLMSSP "preamble".
+ /// The NTLMSSP "preamble".
+ protected internal static readonly byte[] NtlmsspSignature = { unchecked(
+ (byte)('N')), unchecked((byte)('T')), unchecked((byte)('L')),
+ unchecked((byte)('M')), unchecked((byte)('S')), unchecked((byte
+ )('S')), unchecked((byte)('P')), unchecked(0) };
- private static readonly string OemEncoding = Config.DefaultOemEncoding;
+ private static readonly string OemEncoding = Config.DefaultOemEncoding;
- protected internal static readonly string UniEncoding = "UTF-16LE";
+ protected internal static readonly string UniEncoding = "UTF-16LE";
- private int _flags;
+ private int _flags;
- /// Returns the flags currently in use for this message.
- /// Returns the flags currently in use for this message.
- ///
- /// An int containing the flags in use for this
- /// message.
- ///
- public virtual int GetFlags()
- {
- return _flags;
- }
+ /// Returns the flags currently in use for this message.
+ /// Returns the flags currently in use for this message.
+ ///
+ /// An int containing the flags in use for this
+ /// message.
+ ///
+ public virtual int GetFlags()
+ {
+ return _flags;
+ }
- /// Sets the flags for this message.
- /// Sets the flags for this message.
- /// The flags for this message.
- public virtual void SetFlags(int flags)
- {
- this._flags = flags;
- }
+ /// Sets the flags for this message.
+ /// Sets the flags for this message.
+ /// The flags for this message.
+ public virtual void SetFlags(int flags)
+ {
+ this._flags = flags;
+ }
- /// Returns the status of the specified flag.
- /// Returns the status of the specified flag.
- /// The flag to test (i.e., NTLMSSP_NEGOTIATE_OEM).
- /// A boolean indicating whether the flag is set.
- public virtual bool GetFlag(int flag)
- {
- return (GetFlags() & flag) != 0;
- }
+ /// Returns the status of the specified flag.
+ /// Returns the status of the specified flag.
+ /// The flag to test (i.e., NTLMSSP_NEGOTIATE_OEM).
+ /// A boolean indicating whether the flag is set.
+ public virtual bool GetFlag(int flag)
+ {
+ return (GetFlags() & flag) != 0;
+ }
- /// Sets or clears the specified flag.
- /// Sets or clears the specified flag.
- ///
- /// The flag to set/clear (i.e.,
- /// NTLMSSP_NEGOTIATE_OEM).
- ///
- ///
- /// Indicates whether to set (true) or
- /// clear (false) the specified flag.
- ///
- public virtual void SetFlag(int flag, bool value)
- {
- SetFlags(value
- ? (GetFlags() | flag)
- : (GetFlags() & (unchecked((int)(0xffffffff)) ^ flag)));
- }
+ /// Sets or clears the specified flag.
+ /// Sets or clears the specified flag.
+ ///
+ /// The flag to set/clear (i.e.,
+ /// NTLMSSP_NEGOTIATE_OEM).
+ ///
+ ///
+ /// Indicates whether to set (true) or
+ /// clear (false) the specified flag.
+ ///
+ public virtual void SetFlag(int flag, bool value)
+ {
+ SetFlags(value ? (GetFlags() | flag) : (GetFlags() & (unchecked((int)(0xffffffff)
+ ) ^ flag)));
+ }
- internal static int ReadULong(byte[] src, int index)
- {
- return (src[index] & unchecked(0xff))
- | ((src[index + 1] & unchecked(0xff)) << 8)
- | ((src[index + 2] & unchecked(0xff)) << 16)
- | ((src[index + 3] & unchecked(0xff)) << 24);
- }
+ internal static int ReadULong(byte[] src, int index)
+ {
+ return (src[index] & unchecked(0xff)) | ((src[index + 1] & unchecked(0xff)) << 8) | ((src[index + 2] & unchecked(0xff)) << 16) | ((src[index
+ + 3] & unchecked(0xff)) << 24);
+ }
- internal static int ReadUShort(byte[] src, int index)
- {
- return (src[index] & unchecked(0xff)) | ((src[index + 1] & unchecked(0xff)) << 8);
- }
+ internal static int ReadUShort(byte[] src, int index)
+ {
+ return (src[index] & unchecked(0xff)) | ((src[index + 1] & unchecked(0xff)) << 8);
+ }
- internal static byte[] ReadSecurityBuffer(byte[] src, int index)
- {
- int length = ReadUShort(src, index);
- int offset = ReadULong(src, index + 4);
- byte[] buffer = new byte[length];
- Array.Copy(src, offset, buffer, 0, length);
- return buffer;
- }
+ internal static byte[] ReadSecurityBuffer(byte[] src, int index)
+ {
+ int length = ReadUShort(src, index);
+ int offset = ReadULong(src, index + 4);
+ byte[] buffer = new byte[length];
+ Array.Copy(src, offset, buffer, 0, length);
+ return buffer;
+ }
- internal static void WriteULong(byte[] dest, int offset, int value)
- {
- dest[offset] = unchecked((byte)(value & unchecked(0xff)));
+ internal static void WriteULong(byte[] dest, int offset, int value)
+ {
+ dest[offset] = unchecked((byte)(value & unchecked(0xff)));
+ dest[offset + 1] = unchecked((byte)(value >> 8 & unchecked(0xff)));
+ dest[offset + 2] = unchecked((byte)(value >> 16 & unchecked(0xff)));
+ dest[offset + 3] = unchecked((byte)(value >> 24 & unchecked(0xff)));
+ }
+
+ internal static void WriteUShort(byte[] dest, int offset, int value)
+ {
+ dest[offset] = unchecked((byte)(value & unchecked(0xff)));
dest[offset + 1] = unchecked((byte)(value >> 8 & unchecked(0xff)));
- dest[offset + 2] = unchecked((byte)(value >> 16 & unchecked(0xff)));
- dest[offset + 3] = unchecked((byte)(value >> 24 & unchecked(0xff)));
- }
+ }
- internal static void WriteUShort(byte[] dest, int offset, int value)
- {
- dest[offset] = unchecked((byte)(value & unchecked(0xff)));
- dest[offset + 1] = unchecked((byte)(value >> 8 & unchecked(0xff)));
- }
+ internal static void WriteSecurityBuffer(byte[] dest, int offset, int bodyOffset,
+ byte[] src)
+ {
+ int length = (src != null) ? src.Length : 0;
+ if (length == 0)
+ {
+ return;
+ }
+ WriteUShort(dest, offset, length);
+ WriteUShort(dest, offset + 2, length);
+ WriteULong(dest, offset + 4, bodyOffset);
+ Array.Copy(src, 0, dest, bodyOffset, length);
+ }
- internal static void WriteSecurityBuffer(byte[] dest,
- int offset,
- int bodyOffset,
- byte[] src)
- {
- int length = (src != null)
- ? src.Length
- : 0;
- if (length == 0)
- {
- return;
- }
- WriteUShort(dest, offset, length);
- WriteUShort(dest, offset + 2, length);
- WriteULong(dest, offset + 4, bodyOffset);
- Array.Copy(src, 0, dest, bodyOffset, length);
- }
+ internal static string GetOemEncoding()
+ {
+ return OemEncoding;
+ }
- internal static string GetOemEncoding()
- {
- return OemEncoding;
- }
-
- /// Returns the raw byte representation of this message.
- /// Returns the raw byte representation of this message.
- /// A byte[] containing the raw message material.
- public abstract byte[] ToByteArray();
- }
+ /// Returns the raw byte representation of this message.
+ /// Returns the raw byte representation of this message.
+ /// A byte[] containing the raw message material.
+ public abstract byte[] ToByteArray();
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type1Message.cs b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type1Message.cs
index 7a98ed4a8..afcf5ec7e 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type1Message.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type1Message.cs
@@ -22,230 +22,228 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Ntlmssp
{
- /// Represents an NTLMSSP Type-1 message.
- /// Represents an NTLMSSP Type-1 message.
- public class Type1Message : NtlmMessage
- {
- private static readonly int DefaultFlags;
+ /// Represents an NTLMSSP Type-1 message.
+ /// Represents an NTLMSSP Type-1 message.
+ public class Type1Message : NtlmMessage
+ {
+ private static readonly int DefaultFlags;
- private static readonly string DefaultDomain;
+ private static readonly string DefaultDomain;
- private static readonly string DefaultWorkstation;
+ private static readonly string DefaultWorkstation;
- private string _suppliedDomain;
+ private string _suppliedDomain;
- private string _suppliedWorkstation;
+ private string _suppliedWorkstation;
- static Type1Message()
- {
- DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode", true)
- ? NtlmsspNegotiateUnicode
- : NtlmsspNegotiateOem);
- DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
- string defaultWorkstation = null;
- try
- {
- defaultWorkstation = NbtAddress.GetLocalHost().GetHostName();
- }
- catch (UnknownHostException)
- {
- }
- DefaultWorkstation = defaultWorkstation;
- }
+ static Type1Message()
+ {
+ DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode"
+ , true) ? NtlmsspNegotiateUnicode : NtlmsspNegotiateOem);
+ DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
+ string defaultWorkstation = null;
+ try
+ {
+ defaultWorkstation = NbtAddress.GetLocalHost().GetHostName();
+ }
+ catch (UnknownHostException)
+ {
+ }
+ DefaultWorkstation = defaultWorkstation;
+ }
- ///
- /// Creates a Type-1 message using default values from the current
- /// environment.
- ///
- ///
- /// Creates a Type-1 message using default values from the current
- /// environment.
- ///
- public Type1Message() : this(GetDefaultFlags(),
- GetDefaultDomain(),
- GetDefaultWorkstation())
- {
- }
+ ///
+ /// Creates a Type-1 message using default values from the current
+ /// environment.
+ ///
+ ///
+ /// Creates a Type-1 message using default values from the current
+ /// environment.
+ ///
+ public Type1Message() : this(GetDefaultFlags(), GetDefaultDomain(), GetDefaultWorkstation
+ ())
+ {
+ }
- /// Creates a Type-1 message with the specified parameters.
- /// Creates a Type-1 message with the specified parameters.
- /// The flags to apply to this message.
- /// The supplied authentication domain.
- /// The supplied workstation name.
- public Type1Message(int flags, string suppliedDomain, string suppliedWorkstation)
- {
- SetFlags(GetDefaultFlags() | flags);
- SetSuppliedDomain(suppliedDomain);
- if (suppliedWorkstation == null)
- {
- suppliedWorkstation = GetDefaultWorkstation();
- }
- SetSuppliedWorkstation(suppliedWorkstation);
- }
+ /// Creates a Type-1 message with the specified parameters.
+ /// Creates a Type-1 message with the specified parameters.
+ /// The flags to apply to this message.
+ /// The supplied authentication domain.
+ /// The supplied workstation name.
+ public Type1Message(int flags, string suppliedDomain, string suppliedWorkstation)
+ {
+ SetFlags(GetDefaultFlags() | flags);
+ SetSuppliedDomain(suppliedDomain);
+ if (suppliedWorkstation == null)
+ {
+ suppliedWorkstation = GetDefaultWorkstation();
+ }
+ SetSuppliedWorkstation(suppliedWorkstation);
+ }
- /// Creates a Type-1 message using the given raw Type-1 material.
- /// Creates a Type-1 message using the given raw Type-1 material.
- /// The raw Type-1 material used to construct this message.
- ///
- /// If an error occurs while parsing the material.
- ///
- public Type1Message(byte[] material)
- {
- Parse(material);
- }
+ /// Creates a Type-1 message using the given raw Type-1 material.
+ /// Creates a Type-1 message using the given raw Type-1 material.
+ /// The raw Type-1 material used to construct this message.
+ /// If an error occurs while parsing the material.
+ ///
+ public Type1Message(byte[] material)
+ {
+ Parse(material);
+ }
- /// Returns the supplied authentication domain.
- /// Returns the supplied authentication domain.
- /// A String containing the supplied domain.
- public virtual string GetSuppliedDomain()
- {
- return _suppliedDomain;
- }
+ /// Returns the supplied authentication domain.
+ /// Returns the supplied authentication domain.
+ /// A String containing the supplied domain.
+ public virtual string GetSuppliedDomain()
+ {
+ return _suppliedDomain;
+ }
- /// Sets the supplied authentication domain for this message.
- /// Sets the supplied authentication domain for this message.
- /// The supplied domain for this message.
- public virtual void SetSuppliedDomain(string suppliedDomain)
- {
- this._suppliedDomain = suppliedDomain;
- }
+ /// Sets the supplied authentication domain for this message.
+ /// Sets the supplied authentication domain for this message.
+ /// The supplied domain for this message.
+ public virtual void SetSuppliedDomain(string suppliedDomain)
+ {
+ this._suppliedDomain = suppliedDomain;
+ }
- /// Returns the supplied workstation name.
- /// Returns the supplied workstation name.
- /// A String containing the supplied workstation name.
- public virtual string GetSuppliedWorkstation()
- {
- return _suppliedWorkstation;
- }
+ /// Returns the supplied workstation name.
+ /// Returns the supplied workstation name.
+ /// A String containing the supplied workstation name.
+ public virtual string GetSuppliedWorkstation()
+ {
+ return _suppliedWorkstation;
+ }
- /// Sets the supplied workstation name for this message.
- /// Sets the supplied workstation name for this message.
- /// The supplied workstation for this message.
- public virtual void SetSuppliedWorkstation(string suppliedWorkstation)
- {
- this._suppliedWorkstation = suppliedWorkstation;
- }
+ /// Sets the supplied workstation name for this message.
+ /// Sets the supplied workstation name for this message.
+ /// The supplied workstation for this message.
+ public virtual void SetSuppliedWorkstation(string suppliedWorkstation)
+ {
+ this._suppliedWorkstation = suppliedWorkstation;
+ }
- public override byte[] ToByteArray()
- {
- try
- {
- string suppliedDomain = GetSuppliedDomain();
- string suppliedWorkstation = GetSuppliedWorkstation();
- int flags = GetFlags();
- bool hostInfo = false;
- byte[] domain = new byte[0];
- if (!string.IsNullOrEmpty(suppliedDomain))
- {
- hostInfo = true;
- flags |= NtlmsspNegotiateOemDomainSupplied;
- domain = Runtime.GetBytesForString(suppliedDomain.ToUpper(),
- GetOemEncoding());
- }
- else
- {
- flags &= (NtlmsspNegotiateOemDomainSupplied ^ unchecked((int)(0xffffffff)));
- }
- byte[] workstation = new byte[0];
- if (!string.IsNullOrEmpty(suppliedWorkstation))
- {
- hostInfo = true;
- flags |= NtlmsspNegotiateOemWorkstationSupplied;
- workstation = Runtime.GetBytesForString(suppliedWorkstation.ToUpper(),
- GetOemEncoding());
- }
- else
- {
- flags &= (NtlmsspNegotiateOemWorkstationSupplied ^ unchecked((int)(0xffffffff)));
- }
- byte[] type1 = new byte[hostInfo
- ? (32 + domain.Length + workstation.Length)
- : 16];
- Array.Copy(NtlmsspSignature, 0, type1, 0, 8);
- WriteULong(type1, 8, 1);
- WriteULong(type1, 12, flags);
- if (hostInfo)
- {
- WriteSecurityBuffer(type1, 16, 32, domain);
- WriteSecurityBuffer(type1, 24, 32 + domain.Length, workstation);
- }
- return type1;
- }
- catch (IOException ex)
- {
- throw new InvalidOperationException(ex.Message);
- }
- }
+ public override byte[] ToByteArray()
+ {
+ try
+ {
+ string suppliedDomain = GetSuppliedDomain();
+ string suppliedWorkstation = GetSuppliedWorkstation();
+ int flags = GetFlags();
+ bool hostInfo = false;
+ byte[] domain = new byte[0];
+ if (!string.IsNullOrEmpty(suppliedDomain))
+ {
+ hostInfo = true;
+ flags |= NtlmsspNegotiateOemDomainSupplied;
+ domain = Runtime.GetBytesForString(suppliedDomain.ToUpper(), GetOemEncoding
+ ());
+ }
+ else
+ {
+ flags &= (NtlmsspNegotiateOemDomainSupplied ^ unchecked((int)(0xffffffff)));
+ }
+ byte[] workstation = new byte[0];
+ if (!string.IsNullOrEmpty(suppliedWorkstation))
+ {
+ hostInfo = true;
+ flags |= NtlmsspNegotiateOemWorkstationSupplied;
+ workstation = Runtime.GetBytesForString(suppliedWorkstation.ToUpper(), GetOemEncoding
+ ());
+ }
+ else
+ {
+ flags &= (NtlmsspNegotiateOemWorkstationSupplied ^ unchecked((int)(0xffffffff
+ )));
+ }
+ byte[] type1 = new byte[hostInfo ? (32 + domain.Length + workstation.Length) : 16
+ ];
+ Array.Copy(NtlmsspSignature, 0, type1, 0, 8);
+ WriteULong(type1, 8, 1);
+ WriteULong(type1, 12, flags);
+ if (hostInfo)
+ {
+ WriteSecurityBuffer(type1, 16, 32, domain);
+ WriteSecurityBuffer(type1, 24, 32 + domain.Length, workstation);
+ }
+ return type1;
+ }
+ catch (IOException ex)
+ {
+ throw new InvalidOperationException(ex.Message);
+ }
+ }
- public override string ToString()
- {
- string suppliedDomain = GetSuppliedDomain();
- string suppliedWorkstation = GetSuppliedWorkstation();
- return "Type1Message[suppliedDomain=" + (suppliedDomain ?? "null")
- + ",suppliedWorkstation=" + (suppliedWorkstation ?? "null")
- + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]";
- }
+ public override string ToString()
+ {
+ string suppliedDomain = GetSuppliedDomain();
+ string suppliedWorkstation = GetSuppliedWorkstation();
+ return "Type1Message[suppliedDomain=" + (suppliedDomain ?? "null"
+ ) + ",suppliedWorkstation=" + (suppliedWorkstation ?? "null"
+ ) + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]";
+ }
- ///
- /// Returns the default flags for a generic Type-1 message in the
- /// current environment.
- ///
- ///
- /// Returns the default flags for a generic Type-1 message in the
- /// current environment.
- ///
- /// An int containing the default flags.
- public static int GetDefaultFlags()
- {
- return DefaultFlags;
- }
+ ///
+ /// Returns the default flags for a generic Type-1 message in the
+ /// current environment.
+ ///
+ ///
+ /// Returns the default flags for a generic Type-1 message in the
+ /// current environment.
+ ///
+ /// An int containing the default flags.
+ public static int GetDefaultFlags()
+ {
+ return DefaultFlags;
+ }
- /// Returns the default domain from the current environment.
- /// Returns the default domain from the current environment.
- /// A String containing the default domain.
- public static string GetDefaultDomain()
- {
- return DefaultDomain;
- }
+ /// Returns the default domain from the current environment.
+ /// Returns the default domain from the current environment.
+ /// A String containing the default domain.
+ public static string GetDefaultDomain()
+ {
+ return DefaultDomain;
+ }
- /// Returns the default workstation from the current environment.
- /// Returns the default workstation from the current environment.
- /// A String containing the default workstation.
- public static string GetDefaultWorkstation()
- {
- return DefaultWorkstation;
- }
+ /// Returns the default workstation from the current environment.
+ /// Returns the default workstation from the current environment.
+ /// A String containing the default workstation.
+ public static string GetDefaultWorkstation()
+ {
+ return DefaultWorkstation;
+ }
- ///
- private void Parse(byte[] material)
- {
- for (int i = 0; i < 8; i++)
- {
- if (material[i] != NtlmsspSignature[i])
- {
- throw new IOException("Not an NTLMSSP message.");
- }
- }
- if (ReadULong(material, 8) != 1)
- {
- throw new IOException("Not a Type 1 message.");
- }
- int flags = ReadULong(material, 12);
- string suppliedDomain = null;
- if ((flags & NtlmsspNegotiateOemDomainSupplied) != 0)
- {
- byte[] domain = ReadSecurityBuffer(material, 16);
- suppliedDomain = Runtime.GetStringForBytes(domain, GetOemEncoding());
- }
- string suppliedWorkstation = null;
- if ((flags & NtlmsspNegotiateOemWorkstationSupplied) != 0)
- {
- byte[] workstation = ReadSecurityBuffer(material, 24);
- suppliedWorkstation = Runtime.GetStringForBytes(workstation, GetOemEncoding());
- }
- SetFlags(flags);
- SetSuppliedDomain(suppliedDomain);
- SetSuppliedWorkstation(suppliedWorkstation);
- }
- }
+ ///
+ private void Parse(byte[] material)
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ if (material[i] != NtlmsspSignature[i])
+ {
+ throw new IOException("Not an NTLMSSP message.");
+ }
+ }
+ if (ReadULong(material, 8) != 1)
+ {
+ throw new IOException("Not a Type 1 message.");
+ }
+ int flags = ReadULong(material, 12);
+ string suppliedDomain = null;
+ if ((flags & NtlmsspNegotiateOemDomainSupplied) != 0)
+ {
+ byte[] domain = ReadSecurityBuffer(material, 16);
+ suppliedDomain = Runtime.GetStringForBytes(domain, GetOemEncoding());
+ }
+ string suppliedWorkstation = null;
+ if ((flags & NtlmsspNegotiateOemWorkstationSupplied) != 0)
+ {
+ byte[] workstation = ReadSecurityBuffer(material, 24);
+ suppliedWorkstation = Runtime.GetStringForBytes(workstation, GetOemEncoding
+ ());
+ }
+ SetFlags(flags);
+ SetSuppliedDomain(suppliedDomain);
+ SetSuppliedWorkstation(suppliedWorkstation);
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type2Message.cs b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type2Message.cs
index 368591dd2..104e5b0fd 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type2Message.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type2Message.cs
@@ -22,440 +22,417 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Ntlmssp
{
- /// Represents an NTLMSSP Type-2 message.
- /// Represents an NTLMSSP Type-2 message.
- public class Type2Message : NtlmMessage
- {
- private static readonly int DefaultFlags;
+ /// Represents an NTLMSSP Type-2 message.
+ /// Represents an NTLMSSP Type-2 message.
+ public class Type2Message : NtlmMessage
+ {
+ private static readonly int DefaultFlags;
- private static readonly string DefaultDomain;
+ private static readonly string DefaultDomain;
- private static readonly byte[] DefaultTargetInformation;
+ private static readonly byte[] DefaultTargetInformation;
- private byte[] _challenge;
+ private byte[] _challenge;
- private string _target;
+ private string _target;
- private byte[] _context;
+ private byte[] _context;
- private byte[] _targetInformation;
+ private byte[] _targetInformation;
- static Type2Message()
- {
- DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode", true)
- ? NtlmsspNegotiateUnicode
- : NtlmsspNegotiateOem);
- DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
- byte[] domain = new byte[0];
- if (DefaultDomain != null)
- {
- try
- {
- domain = Runtime.GetBytesForString(DefaultDomain, UniEncoding);
- }
- catch (IOException)
- {
- }
- }
- int domainLength = domain.Length;
- byte[] server = new byte[0];
- try
- {
- string host = NbtAddress.GetLocalHost().GetHostName();
- if (host != null)
- {
- try
- {
- server = Runtime.GetBytesForString(host, UniEncoding);
- }
- catch (IOException)
- {
- }
- }
- }
- catch (UnknownHostException)
- {
- }
- int serverLength = server.Length;
- byte[] targetInfo = new byte[(domainLength > 0
- ? domainLength + 4
- : 0)
- + (serverLength > 0
- ? serverLength + 4
- : 0)
- + 4];
- int offset = 0;
- if (domainLength > 0)
- {
- WriteUShort(targetInfo, offset, 2);
- offset += 2;
- WriteUShort(targetInfo, offset, domainLength);
- offset += 2;
- Array.Copy(domain, 0, targetInfo, offset, domainLength);
- offset += domainLength;
- }
- if (serverLength > 0)
- {
- WriteUShort(targetInfo, offset, 1);
- offset += 2;
- WriteUShort(targetInfo, offset, serverLength);
- offset += 2;
- Array.Copy(server, 0, targetInfo, offset, serverLength);
- }
- DefaultTargetInformation = targetInfo;
- }
+ static Type2Message()
+ {
+ DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode"
+ , true) ? NtlmsspNegotiateUnicode : NtlmsspNegotiateOem);
+ DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
+ byte[] domain = new byte[0];
+ if (DefaultDomain != null)
+ {
+ try
+ {
+ domain = Runtime.GetBytesForString(DefaultDomain, UniEncoding);
+ }
+ catch (IOException)
+ {
+ }
+ }
+ int domainLength = domain.Length;
+ byte[] server = new byte[0];
+ try
+ {
+ string host = NbtAddress.GetLocalHost().GetHostName();
+ if (host != null)
+ {
+ try
+ {
+ server = Runtime.GetBytesForString(host, UniEncoding);
+ }
+ catch (IOException)
+ {
+ }
+ }
+ }
+ catch (UnknownHostException)
+ {
+ }
+ int serverLength = server.Length;
+ byte[] targetInfo = new byte[(domainLength > 0 ? domainLength + 4 : 0) + (serverLength
+ > 0 ? serverLength + 4 : 0) + 4];
+ int offset = 0;
+ if (domainLength > 0)
+ {
+ WriteUShort(targetInfo, offset, 2);
+ offset += 2;
+ WriteUShort(targetInfo, offset, domainLength);
+ offset += 2;
+ Array.Copy(domain, 0, targetInfo, offset, domainLength);
+ offset += domainLength;
+ }
+ if (serverLength > 0)
+ {
+ WriteUShort(targetInfo, offset, 1);
+ offset += 2;
+ WriteUShort(targetInfo, offset, serverLength);
+ offset += 2;
+ Array.Copy(server, 0, targetInfo, offset, serverLength);
+ }
+ DefaultTargetInformation = targetInfo;
+ }
- ///
- /// Creates a Type-2 message using default values from the current
- /// environment.
- ///
- ///
- /// Creates a Type-2 message using default values from the current
- /// environment.
- ///
- public Type2Message() : this(GetDefaultFlags(), null, null)
- {
- }
+ ///
+ /// Creates a Type-2 message using default values from the current
+ /// environment.
+ ///
+ ///
+ /// Creates a Type-2 message using default values from the current
+ /// environment.
+ ///
+ public Type2Message() : this(GetDefaultFlags(), null, null)
+ {
+ }
- ///
- /// Creates a Type-2 message in response to the given Type-1 message
- /// using default values from the current environment.
- ///
- ///
- /// Creates a Type-2 message in response to the given Type-1 message
- /// using default values from the current environment.
- ///
- /// The Type-1 message which this represents a response to.
- public Type2Message(Type1Message type1) : this(type1, null, null)
- {
- }
+ ///
+ /// Creates a Type-2 message in response to the given Type-1 message
+ /// using default values from the current environment.
+ ///
+ ///
+ /// Creates a Type-2 message in response to the given Type-1 message
+ /// using default values from the current environment.
+ ///
+ /// The Type-1 message which this represents a response to.
+ public Type2Message(Type1Message type1) : this(type1, null, null)
+ {
+ }
- /// Creates a Type-2 message in response to the given Type-1 message.
- /// Creates a Type-2 message in response to the given Type-1 message.
- /// The Type-1 message which this represents a response to.
- /// The challenge from the domain controller/server.
- /// The authentication target.
- public Type2Message(Type1Message type1,
- byte[] challenge,
- string target)
- : this(GetDefaultFlags(type1),
- challenge,
- (type1 != null && target == null && type1.GetFlag(NtlmsspRequestTarget))
- ? GetDefaultDomain()
- : target)
- {
- }
+ /// Creates a Type-2 message in response to the given Type-1 message.
+ /// Creates a Type-2 message in response to the given Type-1 message.
+ /// The Type-1 message which this represents a response to.
+ /// The challenge from the domain controller/server.
+ /// The authentication target.
+ public Type2Message(Type1Message type1, byte[] challenge, string target) : this(GetDefaultFlags
+ (type1), challenge, (type1 != null && target == null && type1.GetFlag(NtlmsspRequestTarget
+ )) ? GetDefaultDomain() : target)
+ {
+ }
- /// Creates a Type-2 message with the specified parameters.
- /// Creates a Type-2 message with the specified parameters.
- /// The flags to apply to this message.
- /// The challenge from the domain controller/server.
- /// The authentication target.
- public Type2Message(int flags, byte[] challenge, string target)
- {
- SetFlags(flags);
- SetChallenge(challenge);
- SetTarget(target);
- if (target != null)
- {
- SetTargetInformation(GetDefaultTargetInformation());
- }
- }
+ /// Creates a Type-2 message with the specified parameters.
+ /// Creates a Type-2 message with the specified parameters.
+ /// The flags to apply to this message.
+ /// The challenge from the domain controller/server.
+ /// The authentication target.
+ public Type2Message(int flags, byte[] challenge, string target)
+ {
+ SetFlags(flags);
+ SetChallenge(challenge);
+ SetTarget(target);
+ if (target != null)
+ {
+ SetTargetInformation(GetDefaultTargetInformation());
+ }
+ }
- /// Creates a Type-2 message using the given raw Type-2 material.
- /// Creates a Type-2 message using the given raw Type-2 material.
- /// The raw Type-2 material used to construct this message.
- /// If an error occurs while parsing the material.
- ///
- public Type2Message(byte[] material)
- {
- Parse(material);
- }
+ /// Creates a Type-2 message using the given raw Type-2 material.
+ /// Creates a Type-2 message using the given raw Type-2 material.
+ /// The raw Type-2 material used to construct this message.
+ /// If an error occurs while parsing the material.
+ ///
+ public Type2Message(byte[] material)
+ {
+ Parse(material);
+ }
- /// Returns the challenge for this message.
- /// Returns the challenge for this message.
- /// A byte[] containing the challenge.
- public virtual byte[] GetChallenge()
- {
- return _challenge;
- }
+ /// Returns the challenge for this message.
+ /// Returns the challenge for this message.
+ /// A byte[] containing the challenge.
+ public virtual byte[] GetChallenge()
+ {
+ return _challenge;
+ }
- /// Sets the challenge for this message.
- /// Sets the challenge for this message.
- /// The challenge from the domain controller/server.
- public virtual void SetChallenge(byte[] challenge)
- {
- this._challenge = challenge;
- }
+ /// Sets the challenge for this message.
+ /// Sets the challenge for this message.
+ /// The challenge from the domain controller/server.
+ public virtual void SetChallenge(byte[] challenge)
+ {
+ this._challenge = challenge;
+ }
- /// Returns the authentication target.
- /// Returns the authentication target.
- /// A String containing the authentication target.
- public virtual string GetTarget()
- {
- return _target;
- }
+ /// Returns the authentication target.
+ /// Returns the authentication target.
+ /// A String containing the authentication target.
+ public virtual string GetTarget()
+ {
+ return _target;
+ }
- /// Sets the authentication target.
- /// Sets the authentication target.
- /// The authentication target.
- public virtual void SetTarget(string target)
- {
- this._target = target;
- }
+ /// Sets the authentication target.
+ /// Sets the authentication target.
+ /// The authentication target.
+ public virtual void SetTarget(string target)
+ {
+ this._target = target;
+ }
- /// Returns the target information block.
- /// Returns the target information block.
- ///
- /// A byte[] containing the target information block.
- /// The target information block is used by the client to create an
- /// NTLMv2 response.
- ///
- public virtual byte[] GetTargetInformation()
- {
- return _targetInformation;
- }
+ /// Returns the target information block.
+ /// Returns the target information block.
+ ///
+ /// A byte[] containing the target information block.
+ /// The target information block is used by the client to create an
+ /// NTLMv2 response.
+ ///
+ public virtual byte[] GetTargetInformation()
+ {
+ return _targetInformation;
+ }
- /// Sets the target information block.
- ///
- /// Sets the target information block.
- /// The target information block is used by the client to create
- /// an NTLMv2 response.
- ///
- /// The target information block.
- public virtual void SetTargetInformation(byte[] targetInformation)
- {
- this._targetInformation = targetInformation;
- }
+ /// Sets the target information block.
+ ///
+ /// Sets the target information block.
+ /// The target information block is used by the client to create
+ /// an NTLMv2 response.
+ ///
+ /// The target information block.
+ public virtual void SetTargetInformation(byte[] targetInformation)
+ {
+ this._targetInformation = targetInformation;
+ }
- /// Returns the local security context.
- /// Returns the local security context.
- ///
- /// A byte[] containing the local security
- /// context. This is used by the client to negotiate local
- /// authentication.
- ///
- public virtual byte[] GetContext()
- {
- return _context;
- }
+ /// Returns the local security context.
+ /// Returns the local security context.
+ ///
+ /// A byte[] containing the local security
+ /// context. This is used by the client to negotiate local
+ /// authentication.
+ ///
+ public virtual byte[] GetContext()
+ {
+ return _context;
+ }
- /// Sets the local security context.
- ///
- /// Sets the local security context. This is used by the client
- /// to negotiate local authentication.
- ///
- /// The local security context.
- public virtual void SetContext(byte[] context)
- {
- this._context = context;
- }
+ /// Sets the local security context.
+ ///
+ /// Sets the local security context. This is used by the client
+ /// to negotiate local authentication.
+ ///
+ /// The local security context.
+ public virtual void SetContext(byte[] context)
+ {
+ this._context = context;
+ }
- public override byte[] ToByteArray()
- {
- try
- {
- string targetName = GetTarget();
- byte[] challenge = GetChallenge();
- byte[] context = GetContext();
- byte[] targetInformation = GetTargetInformation();
- int flags = GetFlags();
- byte[] target = new byte[0];
- if ((flags & NtlmsspRequestTarget) != 0)
- {
- if (!string.IsNullOrEmpty(targetName))
- {
- target = (flags & NtlmsspNegotiateUnicode) != 0
- ? Runtime.GetBytesForString(targetName, UniEncoding)
- : Runtime.GetBytesForString(targetName.ToUpper(), GetOemEncoding());
- }
- else
- {
- flags &= (unchecked((int)(0xffffffff)) ^ NtlmsspRequestTarget);
- }
- }
- if (targetInformation != null)
- {
- flags |= NtlmsspNegotiateTargetInfo;
- // empty context is needed for padding when t.i. is supplied.
- if (context == null)
- {
- context = new byte[8];
- }
- }
- int data = 32;
- if (context != null)
- {
- data += 8;
- }
- if (targetInformation != null)
- {
- data += 8;
- }
- byte[] type2 = new byte[data
- + target.Length
- + (targetInformation != null
- ? targetInformation.Length
- : 0)];
- Array.Copy(NtlmsspSignature, 0, type2, 0, 8);
- WriteULong(type2, 8, 2);
- WriteSecurityBuffer(type2, 12, data, target);
- WriteULong(type2, 20, flags);
- Array.Copy(challenge ?? new byte[8], 0, type2, 24, 8);
- if (context != null)
- {
- Array.Copy(context, 0, type2, 32, 8);
- }
- if (targetInformation != null)
- {
- WriteSecurityBuffer(type2, 40, data + target.Length, targetInformation);
- }
- return type2;
- }
- catch (IOException ex)
- {
- throw new InvalidOperationException(ex.Message);
- }
- }
+ public override byte[] ToByteArray()
+ {
+ try
+ {
+ string targetName = GetTarget();
+ byte[] challenge = GetChallenge();
+ byte[] context = GetContext();
+ byte[] targetInformation = GetTargetInformation();
+ int flags = GetFlags();
+ byte[] target = new byte[0];
+ if ((flags & NtlmsspRequestTarget) != 0)
+ {
+ if (!string.IsNullOrEmpty(targetName))
+ {
+ target = (flags & NtlmsspNegotiateUnicode) != 0 ? Runtime.GetBytesForString
+ (targetName, UniEncoding) : Runtime.GetBytesForString(targetName.ToUpper
+ (), GetOemEncoding());
+ }
+ else
+ {
+ flags &= (unchecked((int)(0xffffffff)) ^ NtlmsspRequestTarget);
+ }
+ }
+ if (targetInformation != null)
+ {
+ flags |= NtlmsspNegotiateTargetInfo;
+ // empty context is needed for padding when t.i. is supplied.
+ if (context == null)
+ {
+ context = new byte[8];
+ }
+ }
+ int data = 32;
+ if (context != null)
+ {
+ data += 8;
+ }
+ if (targetInformation != null)
+ {
+ data += 8;
+ }
+ byte[] type2 = new byte[data + target.Length + (targetInformation != null ? targetInformation
+ .Length : 0)];
+ Array.Copy(NtlmsspSignature, 0, type2, 0, 8);
+ WriteULong(type2, 8, 2);
+ WriteSecurityBuffer(type2, 12, data, target);
+ WriteULong(type2, 20, flags);
+ Array.Copy(challenge ?? new byte[8], 0, type2, 24, 8);
+ if (context != null)
+ {
+ Array.Copy(context, 0, type2, 32, 8);
+ }
+ if (targetInformation != null)
+ {
+ WriteSecurityBuffer(type2, 40, data + target.Length, targetInformation);
+ }
+ return type2;
+ }
+ catch (IOException ex)
+ {
+ throw new InvalidOperationException(ex.Message);
+ }
+ }
- public override string ToString()
- {
- string target = GetTarget();
- byte[] challenge = GetChallenge();
- byte[] context = GetContext();
- byte[] targetInformation = GetTargetInformation();
- return "Type2Message[target=" + target
- + ",challenge=" + (challenge == null
- ? "null"
- : "<" + challenge.Length + " bytes>")
- + ",context=" + (context == null
- ? "null"
- : "<" + context.Length + " bytes>")
- + ",targetInformation=" + (targetInformation == null
- ? "null"
- : "<" + targetInformation.Length + " bytes>")
- + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]";
- }
+ public override string ToString()
+ {
+ string target = GetTarget();
+ byte[] challenge = GetChallenge();
+ byte[] context = GetContext();
+ byte[] targetInformation = GetTargetInformation();
+ return "Type2Message[target=" + target + ",challenge=" + (challenge == null ? "null"
+ : "<" + challenge.Length + " bytes>") + ",context=" + (context == null ? "null"
+ : "<" + context.Length + " bytes>") + ",targetInformation=" + (targetInformation
+ == null ? "null" : "<" + targetInformation.Length + " bytes>") + ",flags=0x" +
+ Hexdump.ToHexString(GetFlags(), 8) + "]";
+ }
- ///
- /// Returns the default flags for a generic Type-2 message in the
- /// current environment.
- ///
- ///
- /// Returns the default flags for a generic Type-2 message in the
- /// current environment.
- ///
- /// An int containing the default flags.
- public static int GetDefaultFlags()
- {
- return DefaultFlags;
- }
+ ///
+ /// Returns the default flags for a generic Type-2 message in the
+ /// current environment.
+ ///
+ ///
+ /// Returns the default flags for a generic Type-2 message in the
+ /// current environment.
+ ///
+ /// An int containing the default flags.
+ public static int GetDefaultFlags()
+ {
+ return DefaultFlags;
+ }
- ///
- /// Returns the default flags for a Type-2 message created in response
- /// to the given Type-1 message in the current environment.
- ///
- ///
- /// Returns the default flags for a Type-2 message created in response
- /// to the given Type-1 message in the current environment.
- ///
- /// An int containing the default flags.
- public static int GetDefaultFlags(Type1Message type1)
- {
- if (type1 == null)
- {
- return DefaultFlags;
- }
- int flags = NtlmsspNegotiateNtlm;
- int type1Flags = type1.GetFlags();
- flags |= ((type1Flags & NtlmsspNegotiateUnicode) != 0)
- ? NtlmsspNegotiateUnicode
- : NtlmsspNegotiateOem;
- if ((type1Flags & NtlmsspRequestTarget) != 0)
- {
- string domain = GetDefaultDomain();
- if (domain != null)
- {
- flags |= NtlmsspRequestTarget | NtlmsspTargetTypeDomain;
- }
- }
- return flags;
- }
+ ///
+ /// Returns the default flags for a Type-2 message created in response
+ /// to the given Type-1 message in the current environment.
+ ///
+ ///
+ /// Returns the default flags for a Type-2 message created in response
+ /// to the given Type-1 message in the current environment.
+ ///
+ /// An int containing the default flags.
+ public static int GetDefaultFlags(Type1Message type1)
+ {
+ if (type1 == null)
+ {
+ return DefaultFlags;
+ }
+ int flags = NtlmsspNegotiateNtlm;
+ int type1Flags = type1.GetFlags();
+ flags |= ((type1Flags & NtlmsspNegotiateUnicode) != 0) ? NtlmsspNegotiateUnicode
+ : NtlmsspNegotiateOem;
+ if ((type1Flags & NtlmsspRequestTarget) != 0)
+ {
+ string domain = GetDefaultDomain();
+ if (domain != null)
+ {
+ flags |= NtlmsspRequestTarget | NtlmsspTargetTypeDomain;
+ }
+ }
+ return flags;
+ }
- /// Returns the default domain from the current environment.
- /// Returns the default domain from the current environment.
- /// A String containing the domain.
- public static string GetDefaultDomain()
- {
- return DefaultDomain;
- }
+ /// Returns the default domain from the current environment.
+ /// Returns the default domain from the current environment.
+ /// A String containing the domain.
+ public static string GetDefaultDomain()
+ {
+ return DefaultDomain;
+ }
- public static byte[] GetDefaultTargetInformation()
- {
- return DefaultTargetInformation;
- }
+ public static byte[] GetDefaultTargetInformation()
+ {
+ return DefaultTargetInformation;
+ }
- ///
- private void Parse(byte[] material)
- {
- for (int i = 0; i < 8; i++)
- {
- if (material[i] != NtlmsspSignature[i])
- {
- throw new IOException("Not an NTLMSSP message.");
- }
- }
- if (ReadULong(material, 8) != 2)
- {
- throw new IOException("Not a Type 2 message.");
- }
- int flags = ReadULong(material, 20);
- SetFlags(flags);
- string target = null;
- byte[] bytes = ReadSecurityBuffer(material, 12);
- if (bytes.Length != 0)
- {
- target = Runtime.GetStringForBytes(bytes,
- ((flags & NtlmsspNegotiateUnicode) != 0)
- ? UniEncoding
- : GetOemEncoding());
- }
- SetTarget(target);
- for (int i1 = 24; i1 < 32; i1++)
- {
- if (material[i1] != 0)
- {
- byte[] challenge = new byte[8];
- Array.Copy(material, 24, challenge, 0, 8);
- SetChallenge(challenge);
- break;
- }
- }
- int offset = ReadULong(material, 16);
- // offset of targetname start
- if (offset == 32 || material.Length == 32)
- {
- return;
- }
- for (int i2 = 32; i2 < 40; i2++)
- {
- if (material[i2] != 0)
- {
- byte[] context = new byte[8];
- Array.Copy(material, 32, context, 0, 8);
- SetContext(context);
- break;
- }
- }
- if (offset == 40 || material.Length == 40)
- {
- return;
- }
- bytes = ReadSecurityBuffer(material, 40);
- if (bytes.Length != 0)
- {
- SetTargetInformation(bytes);
- }
- }
- }
+ ///
+ private void Parse(byte[] material)
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ if (material[i] != NtlmsspSignature[i])
+ {
+ throw new IOException("Not an NTLMSSP message.");
+ }
+ }
+ if (ReadULong(material, 8) != 2)
+ {
+ throw new IOException("Not a Type 2 message.");
+ }
+ int flags = ReadULong(material, 20);
+ SetFlags(flags);
+ string target = null;
+ byte[] bytes = ReadSecurityBuffer(material, 12);
+ if (bytes.Length != 0)
+ {
+ target = Runtime.GetStringForBytes(bytes, ((flags & NtlmsspNegotiateUnicode
+ ) != 0) ? UniEncoding : GetOemEncoding());
+ }
+ SetTarget(target);
+ for (int i1 = 24; i1 < 32; i1++)
+ {
+ if (material[i1] != 0)
+ {
+ byte[] challenge = new byte[8];
+ Array.Copy(material, 24, challenge, 0, 8);
+ SetChallenge(challenge);
+ break;
+ }
+ }
+ int offset = ReadULong(material, 16);
+ // offset of targetname start
+ if (offset == 32 || material.Length == 32)
+ {
+ return;
+ }
+ for (int i2 = 32; i2 < 40; i2++)
+ {
+ if (material[i2] != 0)
+ {
+ byte[] context = new byte[8];
+ Array.Copy(material, 32, context, 0, 8);
+ SetContext(context);
+ break;
+ }
+ }
+ if (offset == 40 || material.Length == 40)
+ {
+ return;
+ }
+ bytes = ReadSecurityBuffer(material, 40);
+ if (bytes.Length != 0)
+ {
+ SetTargetInformation(bytes);
+ }
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type3Message.cs b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type3Message.cs
index 6d8425573..9a2a37f3c 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type3Message.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Ntlmssp/Type3Message.cs
@@ -23,716 +23,655 @@ using SharpCifs.Util.Sharpen;
namespace SharpCifs.Ntlmssp
{
- /// Represents an NTLMSSP Type-3 message.
- /// Represents an NTLMSSP Type-3 message.
- public class Type3Message : NtlmMessage
- {
- internal const long MillisecondsBetween1970And1601 = 11644473600000L;
+ /// Represents an NTLMSSP Type-3 message.
+ /// Represents an NTLMSSP Type-3 message.
+ public class Type3Message : NtlmMessage
+ {
+ internal const long MillisecondsBetween1970And1601 = 11644473600000L;
- private static readonly int DefaultFlags;
+ private static readonly int DefaultFlags;
- private static readonly string DefaultDomain;
+ private static readonly string DefaultDomain;
- private static readonly string DefaultUser;
+ private static readonly string DefaultUser;
- private static readonly string DefaultPassword;
+ private static readonly string DefaultPassword;
- private static readonly string DefaultWorkstation;
+ private static readonly string DefaultWorkstation;
- private static readonly int LmCompatibility;
+ private static readonly int LmCompatibility;
- //private static readonly SecureRandom RANDOM = new SecureRandom();
+ //private static readonly SecureRandom RANDOM = new SecureRandom();
- private byte[] _lmResponse;
+ private byte[] _lmResponse;
- private byte[] _ntResponse;
+ private byte[] _ntResponse;
- private string _domain;
+ private string _domain;
- private string _user;
+ private string _user;
- private string _workstation;
+ private string _workstation;
- private byte[] _masterKey;
+ private byte[] _masterKey;
- private byte[] _sessionKey;
+ private byte[] _sessionKey;
- static Type3Message()
- {
- DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode", true)
- ? NtlmsspNegotiateUnicode
- : NtlmsspNegotiateOem);
- DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
- DefaultUser = Config.GetProperty("jcifs.smb.client.username", null);
- DefaultPassword = Config.GetProperty("jcifs.smb.client.password", null);
- string defaultWorkstation = null;
- try
- {
- defaultWorkstation = NbtAddress.GetLocalHost().GetHostName();
- }
- catch (UnknownHostException)
- {
- }
- DefaultWorkstation = defaultWorkstation;
- LmCompatibility = Config.GetInt("jcifs.smb.lmCompatibility", 3);
- }
+ static Type3Message()
+ {
+ DefaultFlags = NtlmsspNegotiateNtlm | (Config.GetBoolean("jcifs.smb.client.useUnicode"
+ , true) ? NtlmsspNegotiateUnicode : NtlmsspNegotiateOem);
+ DefaultDomain = Config.GetProperty("jcifs.smb.client.domain", null);
+ DefaultUser = Config.GetProperty("jcifs.smb.client.username", null);
+ DefaultPassword = Config.GetProperty("jcifs.smb.client.password", null);
+ string defaultWorkstation = null;
+ try
+ {
+ defaultWorkstation = NbtAddress.GetLocalHost().GetHostName();
+ }
+ catch (UnknownHostException)
+ {
+ }
+ DefaultWorkstation = defaultWorkstation;
+ LmCompatibility = Config.GetInt("jcifs.smb.lmCompatibility", 3);
+ }
- ///
- /// Creates a Type-3 message using default values from the current
- /// environment.
- ///
- ///
- /// Creates a Type-3 message using default values from the current
- /// environment.
- ///
- public Type3Message()
- {
- SetFlags(GetDefaultFlags());
- SetDomain(GetDefaultDomain());
- SetUser(GetDefaultUser());
- SetWorkstation(GetDefaultWorkstation());
- }
+ ///
+ /// Creates a Type-3 message using default values from the current
+ /// environment.
+ ///
+ ///
+ /// Creates a Type-3 message using default values from the current
+ /// environment.
+ ///
+ public Type3Message()
+ {
+ SetFlags(GetDefaultFlags());
+ SetDomain(GetDefaultDomain());
+ SetUser(GetDefaultUser());
+ SetWorkstation(GetDefaultWorkstation());
+ }
- ///
- /// Creates a Type-3 message in response to the given Type-2 message
- /// using default values from the current environment.
- ///
- ///
- /// Creates a Type-3 message in response to the given Type-2 message
- /// using default values from the current environment.
- ///
- /// The Type-2 message which this represents a response to.
- public Type3Message(Type2Message type2)
- {
- SetFlags(GetDefaultFlags(type2));
- SetWorkstation(GetDefaultWorkstation());
- string domain = GetDefaultDomain();
- SetDomain(domain);
- string user = GetDefaultUser();
- SetUser(user);
- string password = GetDefaultPassword();
- switch (LmCompatibility)
- {
- case 0:
- case 1:
- {
- SetLmResponse(GetLMResponse(type2, password));
- SetNtResponse(GetNTResponse(type2, password));
- break;
- }
+ ///
+ /// Creates a Type-3 message in response to the given Type-2 message
+ /// using default values from the current environment.
+ ///
+ ///
+ /// Creates a Type-3 message in response to the given Type-2 message
+ /// using default values from the current environment.
+ ///
+ /// The Type-2 message which this represents a response to.
+ public Type3Message(Type2Message type2)
+ {
+ SetFlags(GetDefaultFlags(type2));
+ SetWorkstation(GetDefaultWorkstation());
+ string domain = GetDefaultDomain();
+ SetDomain(domain);
+ string user = GetDefaultUser();
+ SetUser(user);
+ string password = GetDefaultPassword();
+ switch (LmCompatibility)
+ {
+ case 0:
+ case 1:
+ {
+ SetLmResponse(GetLMResponse(type2, password));
+ SetNtResponse(GetNTResponse(type2, password));
+ break;
+ }
- case 2:
- {
- byte[] nt = GetNTResponse(type2, password);
- SetLmResponse(nt);
- SetNtResponse(nt);
- break;
- }
+ case 2:
+ {
+ byte[] nt = GetNTResponse(type2, password);
+ SetLmResponse(nt);
+ SetNtResponse(nt);
+ break;
+ }
- case 3:
- case 4:
- case 5:
- {
- byte[] clientChallenge = new byte[8];
- //RANDOM.NextBytes(clientChallenge);
- SetLmResponse(GetLMv2Response(type2, domain, user, password, clientChallenge));
- break;
- }
+ case 3:
+ case 4:
+ case 5:
+ {
+ byte[] clientChallenge = new byte[8];
+ //RANDOM.NextBytes(clientChallenge);
+ SetLmResponse(GetLMv2Response(type2, domain, user, password, clientChallenge));
+ break;
+ }
- default:
- {
- SetLmResponse(GetLMResponse(type2, password));
- SetNtResponse(GetNTResponse(type2, password));
- break;
- }
- }
- }
+ default:
+ {
+ SetLmResponse(GetLMResponse(type2, password));
+ SetNtResponse(GetNTResponse(type2, password));
+ break;
+ }
+ }
+ }
- /// Creates a Type-3 message in response to the given Type-2 message.
- /// Creates a Type-3 message in response to the given Type-2 message.
- /// The Type-2 message which this represents a response to.
- /// The password to use when constructing the response.
- /// The domain in which the user has an account.
- /// The username for the authenticating user.
- ///
- /// The workstation from which authentication is
- /// taking place.
- ///
- public Type3Message(Type2Message type2,
- string password,
- string domain,
- string user,
- string workstation,
- int flags)
- {
- SetFlags(flags | GetDefaultFlags(type2));
- if (workstation == null)
- {
- workstation = GetDefaultWorkstation();
- }
- SetWorkstation(workstation);
- SetDomain(domain);
- SetUser(user);
- switch (LmCompatibility)
- {
- case 0:
- case 1:
- {
- if ((GetFlags() & NtlmsspNegotiateNtlm2) == 0)
- {
- SetLmResponse(GetLMResponse(type2, password));
- SetNtResponse(GetNTResponse(type2, password));
- }
- else
- {
- // NTLM2 Session Response
- byte[] clientChallenge = new byte[24];
- //RANDOM.NextBytes(clientChallenge);
- Arrays.Fill(clientChallenge, 8, 24, unchecked((byte)unchecked(0x00)));
- // NTLMv1 w/ NTLM2 session sec and key exch all been verified with a debug build of smbclient
- byte[] responseKeyNt
- = NtlmPasswordAuthentication.NtowFv1(password);
- byte[] ntlm2Response
- = NtlmPasswordAuthentication.GetNtlm2Response(responseKeyNt,
- type2.GetChallenge(),
- clientChallenge);
- SetLmResponse(clientChallenge);
- SetNtResponse(ntlm2Response);
- if ((GetFlags() & NtlmsspNegotiateSign) == NtlmsspNegotiateSign)
- {
- byte[] sessionNonce = new byte[16];
- Array.Copy(type2.GetChallenge(), 0, sessionNonce, 0, 8);
- Array.Copy(clientChallenge, 0, sessionNonce, 8, 8);
- Md4 md4 = new Md4();
- md4.Update(responseKeyNt);
- byte[] userSessionKey = md4.Digest();
- Hmact64 hmac = new Hmact64(userSessionKey);
- hmac.Update(sessionNonce);
- byte[] ntlm2SessionKey = hmac.Digest();
- if ((GetFlags() & NtlmsspNegotiateKeyExch) != 0)
- {
- _masterKey = new byte[16];
- //RANDOM.NextBytes(masterKey);
- byte[] exchangedKey = new byte[16];
- Rc4 rc4 = new Rc4(ntlm2SessionKey);
- rc4.Update(_masterKey, 0, 16, exchangedKey, 0);
- SetSessionKey(exchangedKey);
- }
- else
- {
- _masterKey = ntlm2SessionKey;
- SetSessionKey(_masterKey);
- }
- }
- }
- break;
- }
+ /// Creates a Type-3 message in response to the given Type-2 message.
+ /// Creates a Type-3 message in response to the given Type-2 message.
+ /// The Type-2 message which this represents a response to.
+ /// The password to use when constructing the response.
+ /// The domain in which the user has an account.
+ /// The username for the authenticating user.
+ ///
+ /// The workstation from which authentication is
+ /// taking place.
+ ///
+ public Type3Message(Type2Message type2, string password, string domain, string user
+ , string workstation, int flags)
+ {
+ SetFlags(flags | GetDefaultFlags(type2));
+ if (workstation == null)
+ {
+ workstation = GetDefaultWorkstation();
+ }
+ SetWorkstation(workstation);
+ SetDomain(domain);
+ SetUser(user);
+ switch (LmCompatibility)
+ {
+ case 0:
+ case 1:
+ {
+ if ((GetFlags() & NtlmsspNegotiateNtlm2) == 0)
+ {
+ SetLmResponse(GetLMResponse(type2, password));
+ SetNtResponse(GetNTResponse(type2, password));
+ }
+ else
+ {
+ // NTLM2 Session Response
+ byte[] clientChallenge = new byte[24];
+ //RANDOM.NextBytes(clientChallenge);
+ Arrays.Fill(clientChallenge, 8, 24, unchecked((byte)unchecked(0x00)));
+ // NTLMv1 w/ NTLM2 session sec and key exch all been verified with a debug build of smbclient
+ byte[] responseKeyNt = NtlmPasswordAuthentication.NtowFv1(password);
+ byte[] ntlm2Response = NtlmPasswordAuthentication.GetNtlm2Response(responseKeyNt,
+ type2.GetChallenge(), clientChallenge);
+ SetLmResponse(clientChallenge);
+ SetNtResponse(ntlm2Response);
+ if ((GetFlags() & NtlmsspNegotiateSign) == NtlmsspNegotiateSign)
+ {
+ byte[] sessionNonce = new byte[16];
+ Array.Copy(type2.GetChallenge(), 0, sessionNonce, 0, 8);
+ Array.Copy(clientChallenge, 0, sessionNonce, 8, 8);
+ Md4 md4 = new Md4();
+ md4.Update(responseKeyNt);
+ byte[] userSessionKey = md4.Digest();
+ Hmact64 hmac = new Hmact64(userSessionKey);
+ hmac.Update(sessionNonce);
+ byte[] ntlm2SessionKey = hmac.Digest();
+ if ((GetFlags() & NtlmsspNegotiateKeyExch) != 0)
+ {
+ _masterKey = new byte[16];
+ //RANDOM.NextBytes(masterKey);
+ byte[] exchangedKey = new byte[16];
+ Rc4 rc4 = new Rc4(ntlm2SessionKey);
+ rc4.Update(_masterKey, 0, 16, exchangedKey, 0);
+ SetSessionKey(exchangedKey);
+ }
+ else
+ {
+ _masterKey = ntlm2SessionKey;
+ SetSessionKey(_masterKey);
+ }
+ }
+ }
+ break;
+ }
- case 2:
- {
- byte[] nt = GetNTResponse(type2, password);
- SetLmResponse(nt);
- SetNtResponse(nt);
- break;
- }
+ case 2:
+ {
+ byte[] nt = GetNTResponse(type2, password);
+ SetLmResponse(nt);
+ SetNtResponse(nt);
+ break;
+ }
- case 3:
- case 4:
- case 5:
- {
- byte[] responseKeyNt1
- = NtlmPasswordAuthentication.NtowFv2(domain, user, password);
- byte[] clientChallenge1 = new byte[8];
- //RANDOM.NextBytes(clientChallenge_1);
- SetLmResponse(GetLMv2Response(type2, domain, user, password, clientChallenge1));
- byte[] clientChallenge2 = new byte[8];
- //RANDOM.NextBytes(clientChallenge2);
- SetNtResponse(GetNtlMv2Response(type2, responseKeyNt1, clientChallenge2));
- if ((GetFlags() & NtlmsspNegotiateSign) == NtlmsspNegotiateSign)
- {
- Hmact64 hmac = new Hmact64(responseKeyNt1);
- hmac.Update(_ntResponse, 0, 16);
- // only first 16 bytes of ntResponse
- byte[] userSessionKey = hmac.Digest();
- if ((GetFlags() & NtlmsspNegotiateKeyExch) != 0)
- {
- _masterKey = new byte[16];
- //RANDOM.NextBytes(masterKey);
- byte[] exchangedKey = new byte[16];
- Rc4 rc4 = new Rc4(userSessionKey);
- rc4.Update(_masterKey, 0, 16, exchangedKey, 0);
- SetSessionKey(exchangedKey);
- }
- else
- {
- _masterKey = userSessionKey;
- SetSessionKey(_masterKey);
- }
- }
- break;
- }
+ case 3:
+ case 4:
+ case 5:
+ {
+ byte[] responseKeyNt1 = NtlmPasswordAuthentication.NtowFv2(domain, user, password
+ );
+ byte[] clientChallenge1 = new byte[8];
+ //RANDOM.NextBytes(clientChallenge_1);
+ SetLmResponse(GetLMv2Response(type2, domain, user, password, clientChallenge1));
+ byte[] clientChallenge2 = new byte[8];
+ //RANDOM.NextBytes(clientChallenge2);
+ SetNtResponse(GetNtlMv2Response(type2, responseKeyNt1, clientChallenge2));
+ if ((GetFlags() & NtlmsspNegotiateSign) == NtlmsspNegotiateSign)
+ {
+ Hmact64 hmac = new Hmact64(responseKeyNt1);
+ hmac.Update(_ntResponse, 0, 16);
+ // only first 16 bytes of ntResponse
+ byte[] userSessionKey = hmac.Digest();
+ if ((GetFlags() & NtlmsspNegotiateKeyExch) != 0)
+ {
+ _masterKey = new byte[16];
+ //RANDOM.NextBytes(masterKey);
+ byte[] exchangedKey = new byte[16];
+ Rc4 rc4 = new Rc4(userSessionKey);
+ rc4.Update(_masterKey, 0, 16, exchangedKey, 0);
+ SetSessionKey(exchangedKey);
+ }
+ else
+ {
+ _masterKey = userSessionKey;
+ SetSessionKey(_masterKey);
+ }
+ }
+ break;
+ }
- default:
- {
- SetLmResponse(GetLMResponse(type2, password));
- SetNtResponse(GetNTResponse(type2, password));
- break;
- }
- }
- }
+ default:
+ {
+ SetLmResponse(GetLMResponse(type2, password));
+ SetNtResponse(GetNTResponse(type2, password));
+ break;
+ }
+ }
+ }
- /// Creates a Type-3 message with the specified parameters.
- /// Creates a Type-3 message with the specified parameters.
- /// The flags to apply to this message.
- /// The LanManager/LMv2 response.
- /// The NT/NTLMv2 response.
- /// The domain in which the user has an account.
- /// The username for the authenticating user.
- ///
- /// The workstation from which authentication is
- /// taking place.
- ///
- public Type3Message(int flags,
- byte[] lmResponse,
- byte[] ntResponse,
- string domain,
- string user,
- string workstation)
- {
- SetFlags(flags);
- SetLmResponse(lmResponse);
- SetNtResponse(ntResponse);
- SetDomain(domain);
- SetUser(user);
- SetWorkstation(workstation);
- }
+ /// Creates a Type-3 message with the specified parameters.
+ /// Creates a Type-3 message with the specified parameters.
+ /// The flags to apply to this message.
+ /// The LanManager/LMv2 response.
+ /// The NT/NTLMv2 response.
+ /// The domain in which the user has an account.
+ /// The username for the authenticating user.
+ ///
+ /// The workstation from which authentication is
+ /// taking place.
+ ///
+ public Type3Message(int flags, byte[] lmResponse, byte[] ntResponse, string domain
+ , string user, string workstation)
+ {
+ SetFlags(flags);
+ SetLmResponse(lmResponse);
+ SetNtResponse(ntResponse);
+ SetDomain(domain);
+ SetUser(user);
+ SetWorkstation(workstation);
+ }
- /// Creates a Type-3 message using the given raw Type-3 material.
- /// Creates a Type-3 message using the given raw Type-3 material.
- /// The raw Type-3 material used to construct this message.
- /// If an error occurs while parsing the material.
- ///
- public Type3Message(byte[] material)
- {
- Parse(material);
- }
+ /// Creates a Type-3 message using the given raw Type-3 material.
+ /// Creates a Type-3 message using the given raw Type-3 material.
+ /// The raw Type-3 material used to construct this message.
+ /// If an error occurs while parsing the material.
+ ///
+ public Type3Message(byte[] material)
+ {
+ Parse(material);
+ }
- /// Returns the LanManager/LMv2 response.
- /// Returns the LanManager/LMv2 response.
- /// A byte[] containing the LanManager response.
- public virtual byte[] GetLMResponse()
- {
- return _lmResponse;
- }
+ /// Returns the LanManager/LMv2 response.
+ /// Returns the LanManager/LMv2 response.
+ /// A byte[] containing the LanManager response.
+ public virtual byte[] GetLMResponse()
+ {
+ return _lmResponse;
+ }
- /// Sets the LanManager/LMv2 response for this message.
- /// Sets the LanManager/LMv2 response for this message.
- /// The LanManager response.
- public virtual void SetLmResponse(byte[] lmResponse)
- {
- this._lmResponse = lmResponse;
- }
+ /// Sets the LanManager/LMv2 response for this message.
+ /// Sets the LanManager/LMv2 response for this message.
+ /// The LanManager response.
+ public virtual void SetLmResponse(byte[] lmResponse)
+ {
+ this._lmResponse = lmResponse;
+ }
- /// Returns the NT/NTLMv2 response.
- /// Returns the NT/NTLMv2 response.
- /// A byte[] containing the NT/NTLMv2 response.
- public virtual byte[] GetNTResponse()
- {
- return _ntResponse;
- }
+ /// Returns the NT/NTLMv2 response.
+ /// Returns the NT/NTLMv2 response.
+ /// A byte[] containing the NT/NTLMv2 response.
+ public virtual byte[] GetNTResponse()
+ {
+ return _ntResponse;
+ }
- /// Sets the NT/NTLMv2 response for this message.
- /// Sets the NT/NTLMv2 response for this message.
- /// The NT/NTLMv2 response.
- public virtual void SetNtResponse(byte[] ntResponse)
- {
- this._ntResponse = ntResponse;
- }
+ /// Sets the NT/NTLMv2 response for this message.
+ /// Sets the NT/NTLMv2 response for this message.
+ /// The NT/NTLMv2 response.
+ public virtual void SetNtResponse(byte[] ntResponse)
+ {
+ this._ntResponse = ntResponse;
+ }
- /// Returns the domain in which the user has an account.
- /// Returns the domain in which the user has an account.
- /// A String containing the domain for the user.
- public virtual string GetDomain()
- {
- return _domain;
- }
+ /// Returns the domain in which the user has an account.
+ /// Returns the domain in which the user has an account.
+ /// A String containing the domain for the user.
+ public virtual string GetDomain()
+ {
+ return _domain;
+ }
- /// Sets the domain for this message.
- /// Sets the domain for this message.
- /// The domain.
- public virtual void SetDomain(string domain)
- {
- this._domain = domain;
- }
+ /// Sets the domain for this message.
+ /// Sets the domain for this message.
+ /// The domain.
+ public virtual void SetDomain(string domain)
+ {
+ this._domain = domain;
+ }
- /// Returns the username for the authenticating user.
- /// Returns the username for the authenticating user.
- /// A String containing the user for this message.
- public virtual string GetUser()
- {
- return _user;
- }
+ /// Returns the username for the authenticating user.
+ /// Returns the username for the authenticating user.
+ /// A String containing the user for this message.
+ public virtual string GetUser()
+ {
+ return _user;
+ }
- /// Sets the user for this message.
- /// Sets the user for this message.
- /// The user.
- public virtual void SetUser(string user)
- {
- this._user = user;
- }
+ /// Sets the user for this message.
+ /// Sets the user for this message.
+ /// The user.
+ public virtual void SetUser(string user)
+ {
+ this._user = user;
+ }
- /// Returns the workstation from which authentication is being performed.
- /// Returns the workstation from which authentication is being performed.
- /// A String containing the workstation.
- public virtual string GetWorkstation()
- {
- return _workstation;
- }
+ /// Returns the workstation from which authentication is being performed.
+ /// Returns the workstation from which authentication is being performed.
+ /// A String containing the workstation.
+ public virtual string GetWorkstation()
+ {
+ return _workstation;
+ }
- /// Sets the workstation for this message.
- /// Sets the workstation for this message.
- /// The workstation.
- public virtual void SetWorkstation(string workstation)
- {
- this._workstation = workstation;
- }
+ /// Sets the workstation for this message.
+ /// Sets the workstation for this message.
+ /// The workstation.
+ public virtual void SetWorkstation(string workstation)
+ {
+ this._workstation = workstation;
+ }
- ///
- /// The real session key if the regular session key is actually
- /// the encrypted version used for key exchange.
- ///
- ///
- /// The real session key if the regular session key is actually
- /// the encrypted version used for key exchange.
- ///
- /// A byte[] containing the session key.
- public virtual byte[] GetMasterKey()
- {
- return _masterKey;
- }
+ ///
+ /// The real session key if the regular session key is actually
+ /// the encrypted version used for key exchange.
+ ///
+ ///
+ /// The real session key if the regular session key is actually
+ /// the encrypted version used for key exchange.
+ ///
+ /// A byte[] containing the session key.
+ public virtual byte[] GetMasterKey()
+ {
+ return _masterKey;
+ }
- /// Returns the session key.
- /// Returns the session key.
- /// A byte[] containing the session key.
- public virtual byte[] GetSessionKey()
- {
- return _sessionKey;
- }
+ /// Returns the session key.
+ /// Returns the session key.
+ /// A byte[] containing the session key.
+ public virtual byte[] GetSessionKey()
+ {
+ return _sessionKey;
+ }
- /// Sets the session key.
- /// Sets the session key.
- /// The session key.
- public virtual void SetSessionKey(byte[] sessionKey)
- {
- this._sessionKey = sessionKey;
- }
+ /// Sets the session key.
+ /// Sets the session key.
+ /// The session key.
+ public virtual void SetSessionKey(byte[] sessionKey)
+ {
+ this._sessionKey = sessionKey;
+ }
- public override byte[] ToByteArray()
- {
- try
- {
- int flags = GetFlags();
- bool unicode = (flags & NtlmsspNegotiateUnicode) != 0;
- string oem = unicode
- ? null
- : GetOemEncoding();
- string domainName = GetDomain();
- byte[] domain = null;
- if (!string.IsNullOrEmpty(domainName))
- {
- domain = unicode
- ? Runtime.GetBytesForString(domainName, UniEncoding)
- : Runtime.GetBytesForString(domainName, oem);
- }
- int domainLength = (domain != null)
- ? domain.Length
- : 0;
- string userName = GetUser();
- byte[] user = null;
- if (!string.IsNullOrEmpty(userName))
- {
- user = unicode
- ? Runtime.GetBytesForString(userName, UniEncoding)
- : Runtime.GetBytesForString(userName.ToUpper(), oem);
- }
- int userLength = (user != null)
- ? user.Length
- : 0;
- string workstationName = GetWorkstation();
- byte[] workstation = null;
- if (!string.IsNullOrEmpty(workstationName))
- {
- workstation = unicode
- ? Runtime.GetBytesForString(workstationName, UniEncoding)
- : Runtime.GetBytesForString(workstationName.ToUpper(), oem);
- }
- int workstationLength = (workstation != null)
- ? workstation.Length
- : 0;
- byte[] lmResponse = GetLMResponse();
- int lmLength = (lmResponse != null)
- ? lmResponse.Length
- : 0;
- byte[] ntResponse = GetNTResponse();
- int ntLength = (ntResponse != null)
- ? ntResponse.Length
- : 0;
- byte[] sessionKey = GetSessionKey();
- int keyLength = (sessionKey != null)
- ? sessionKey.Length
- : 0;
- byte[] type3 = new byte[64
- + domainLength
- + userLength
- + workstationLength
- + lmLength
- + ntLength
- + keyLength];
- Array.Copy(NtlmsspSignature, 0, type3, 0, 8);
- WriteULong(type3, 8, 3);
- int offset = 64;
- WriteSecurityBuffer(type3, 12, offset, lmResponse);
- offset += lmLength;
- WriteSecurityBuffer(type3, 20, offset, ntResponse);
- offset += ntLength;
- WriteSecurityBuffer(type3, 28, offset, domain);
- offset += domainLength;
- WriteSecurityBuffer(type3, 36, offset, user);
- offset += userLength;
- WriteSecurityBuffer(type3, 44, offset, workstation);
- offset += workstationLength;
- WriteSecurityBuffer(type3, 52, offset, sessionKey);
- WriteULong(type3, 60, flags);
- return type3;
- }
- catch (IOException ex)
- {
- throw new InvalidOperationException(ex.Message);
- }
- }
+ public override byte[] ToByteArray()
+ {
+ try
+ {
+ int flags = GetFlags();
+ bool unicode = (flags & NtlmsspNegotiateUnicode) != 0;
+ string oem = unicode ? null : GetOemEncoding();
+ string domainName = GetDomain();
+ byte[] domain = null;
+ if (!string.IsNullOrEmpty(domainName))
+ {
+ domain = unicode ? Runtime.GetBytesForString(domainName, UniEncoding) :
+ Runtime.GetBytesForString(domainName, oem);
+ }
+ int domainLength = (domain != null) ? domain.Length : 0;
+ string userName = GetUser();
+ byte[] user = null;
+ if (!string.IsNullOrEmpty(userName))
+ {
+ user = unicode ? Runtime.GetBytesForString(userName, UniEncoding) : Runtime.GetBytesForString
+ (userName.ToUpper(), oem);
+ }
+ int userLength = (user != null) ? user.Length : 0;
+ string workstationName = GetWorkstation();
+ byte[] workstation = null;
+ if (!string.IsNullOrEmpty(workstationName))
+ {
+ workstation = unicode ? Runtime.GetBytesForString(workstationName, UniEncoding
+ ) : Runtime.GetBytesForString(workstationName.ToUpper(), oem);
+ }
+ int workstationLength = (workstation != null) ? workstation.Length : 0;
+ byte[] lmResponse = GetLMResponse();
+ int lmLength = (lmResponse != null) ? lmResponse.Length : 0;
+ byte[] ntResponse = GetNTResponse();
+ int ntLength = (ntResponse != null) ? ntResponse.Length : 0;
+ byte[] sessionKey = GetSessionKey();
+ int keyLength = (sessionKey != null) ? sessionKey.Length : 0;
+ byte[] type3 = new byte[64 + domainLength + userLength + workstationLength + lmLength
+ + ntLength + keyLength];
+ Array.Copy(NtlmsspSignature, 0, type3, 0, 8);
+ WriteULong(type3, 8, 3);
+ int offset = 64;
+ WriteSecurityBuffer(type3, 12, offset, lmResponse);
+ offset += lmLength;
+ WriteSecurityBuffer(type3, 20, offset, ntResponse);
+ offset += ntLength;
+ WriteSecurityBuffer(type3, 28, offset, domain);
+ offset += domainLength;
+ WriteSecurityBuffer(type3, 36, offset, user);
+ offset += userLength;
+ WriteSecurityBuffer(type3, 44, offset, workstation);
+ offset += workstationLength;
+ WriteSecurityBuffer(type3, 52, offset, sessionKey);
+ WriteULong(type3, 60, flags);
+ return type3;
+ }
+ catch (IOException ex)
+ {
+ throw new InvalidOperationException(ex.Message);
+ }
+ }
- public override string ToString()
- {
- string user = GetUser();
- string domain = GetDomain();
- string workstation = GetWorkstation();
- byte[] lmResponse = GetLMResponse();
- byte[] ntResponse = GetNTResponse();
- byte[] sessionKey = GetSessionKey();
- return "Type3Message[domain=" + domain
- + ",user=" + user
- + ",workstation=" + workstation
- + ",lmResponse=" + (lmResponse == null
- ? "null"
- : "<" + lmResponse.Length + " bytes>")
- + ",ntResponse=" + (ntResponse == null
- ? "null"
- : "<" + ntResponse.Length + " bytes>")
- + ",sessionKey=" + (sessionKey == null
- ? "null"
- : "<" + sessionKey.Length + " bytes>")
- + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]";
- }
+ public override string ToString()
+ {
+ string user = GetUser();
+ string domain = GetDomain();
+ string workstation = GetWorkstation();
+ byte[] lmResponse = GetLMResponse();
+ byte[] ntResponse = GetNTResponse();
+ byte[] sessionKey = GetSessionKey();
+ return "Type3Message[domain=" + domain + ",user=" + user + ",workstation=" + workstation
+ + ",lmResponse=" + (lmResponse == null ? "null" : "<" + lmResponse.Length + " bytes>"
+ ) + ",ntResponse=" + (ntResponse == null ? "null" : "<" + ntResponse.Length + " bytes>"
+ ) + ",sessionKey=" + (sessionKey == null ? "null" : "<" + sessionKey.Length + " bytes>"
+ ) + ",flags=0x" + Hexdump.ToHexString(GetFlags(), 8) + "]";
+ }
- ///
- /// Returns the default flags for a generic Type-3 message in the
- /// current environment.
- ///
- ///
- /// Returns the default flags for a generic Type-3 message in the
- /// current environment.
- ///
- /// An int containing the default flags.
- public static int GetDefaultFlags()
- {
- return DefaultFlags;
- }
+ ///
+ /// Returns the default flags for a generic Type-3 message in the
+ /// current environment.
+ ///
+ ///
+ /// Returns the default flags for a generic Type-3 message in the
+ /// current environment.
+ ///
+ /// An int containing the default flags.
+ public static int GetDefaultFlags()
+ {
+ return DefaultFlags;
+ }
- ///
- /// Returns the default flags for a Type-3 message created in response
- /// to the given Type-2 message in the current environment.
- ///
- ///
- /// Returns the default flags for a Type-3 message created in response
- /// to the given Type-2 message in the current environment.
- ///
- /// An int containing the default flags.
- public static int GetDefaultFlags(Type2Message type2)
- {
- if (type2 == null)
- {
- return DefaultFlags;
- }
- int flags = NtlmsspNegotiateNtlm;
- flags |= ((type2.GetFlags() & NtlmsspNegotiateUnicode) != 0)
- ? NtlmsspNegotiateUnicode
- : NtlmsspNegotiateOem;
- return flags;
- }
+ ///
+ /// Returns the default flags for a Type-3 message created in response
+ /// to the given Type-2 message in the current environment.
+ ///
+ ///
+ /// Returns the default flags for a Type-3 message created in response
+ /// to the given Type-2 message in the current environment.
+ ///
+ /// An int containing the default flags.
+ public static int GetDefaultFlags(Type2Message type2)
+ {
+ if (type2 == null)
+ {
+ return DefaultFlags;
+ }
+ int flags = NtlmsspNegotiateNtlm;
+ flags |= ((type2.GetFlags() & NtlmsspNegotiateUnicode) != 0) ? NtlmsspNegotiateUnicode
+ : NtlmsspNegotiateOem;
+ return flags;
+ }
- ///
- /// Constructs the LanManager response to the given Type-2 message using
- /// the supplied password.
- ///
- ///
- /// Constructs the LanManager response to the given Type-2 message using
- /// the supplied password.
- ///
- /// The Type-2 message.
- /// The password.
- /// A byte[] containing the LanManager response.
- public static byte[] GetLMResponse(Type2Message type2, string password)
- {
- if (type2 == null || password == null)
- {
- return null;
- }
- return NtlmPasswordAuthentication.GetPreNtlmResponse(password,
- type2.GetChallenge());
- }
+ ///
+ /// Constructs the LanManager response to the given Type-2 message using
+ /// the supplied password.
+ ///
+ ///
+ /// Constructs the LanManager response to the given Type-2 message using
+ /// the supplied password.
+ ///
+ /// The Type-2 message.
+ /// The password.
+ /// A byte[] containing the LanManager response.
+ public static byte[] GetLMResponse(Type2Message type2, string password)
+ {
+ if (type2 == null || password == null)
+ {
+ return null;
+ }
+ return NtlmPasswordAuthentication.GetPreNtlmResponse(password, type2.GetChallenge
+ ());
+ }
- public static byte[] GetLMv2Response(Type2Message type2,
- string domain,
- string user,
- string password,
- byte[] clientChallenge)
- {
- if (type2 == null
- || domain == null
- || user == null
- || password == null
- || clientChallenge == null)
- {
- return null;
- }
- return NtlmPasswordAuthentication.GetLMv2Response(domain,
- user,
- password,
- type2.GetChallenge(),
- clientChallenge);
- }
+ public static byte[] GetLMv2Response(Type2Message type2, string domain, string user
+ , string password, byte[] clientChallenge)
+ {
+ if (type2 == null || domain == null || user == null || password == null || clientChallenge
+ == null)
+ {
+ return null;
+ }
+ return NtlmPasswordAuthentication.GetLMv2Response(domain, user, password, type2.GetChallenge
+ (), clientChallenge);
+ }
- public static byte[] GetNtlMv2Response(Type2Message type2,
- byte[] responseKeyNt,
- byte[] clientChallenge)
- {
- if (type2 == null || responseKeyNt == null || clientChallenge == null)
- {
- return null;
- }
- long nanos1601 = (Runtime.CurrentTimeMillis()
- + MillisecondsBetween1970And1601)
- * 10000L;
- return NtlmPasswordAuthentication.GetNtlMv2Response(responseKeyNt,
- type2.GetChallenge(),
- clientChallenge,
- nanos1601,
- type2.GetTargetInformation());
- }
+ public static byte[] GetNtlMv2Response(Type2Message type2, byte[] responseKeyNt,
+ byte[] clientChallenge)
+ {
+ if (type2 == null || responseKeyNt == null || clientChallenge == null)
+ {
+ return null;
+ }
+ long nanos1601 = (Runtime.CurrentTimeMillis() + MillisecondsBetween1970And1601
+ ) * 10000L;
+ return NtlmPasswordAuthentication.GetNtlMv2Response(responseKeyNt, type2.GetChallenge
+ (), clientChallenge, nanos1601, type2.GetTargetInformation());
+ }
- ///
- /// Constructs the NT response to the given Type-2 message using
- /// the supplied password.
- ///
- ///
- /// Constructs the NT response to the given Type-2 message using
- /// the supplied password.
- ///
- /// The Type-2 message.
- /// The password.
- /// A byte[] containing the NT response.
- public static byte[] GetNTResponse(Type2Message type2, string password)
- {
- if (type2 == null || password == null)
- {
- return null;
- }
- return NtlmPasswordAuthentication.GetNtlmResponse(password, type2.GetChallenge());
- }
+ ///
+ /// Constructs the NT response to the given Type-2 message using
+ /// the supplied password.
+ ///
+ ///
+ /// Constructs the NT response to the given Type-2 message using
+ /// the supplied password.
+ ///
+ /// The Type-2 message.
+ /// The password.
+ /// A byte[] containing the NT response.
+ public static byte[] GetNTResponse(Type2Message type2, string password)
+ {
+ if (type2 == null || password == null)
+ {
+ return null;
+ }
+ return NtlmPasswordAuthentication.GetNtlmResponse(password, type2.GetChallenge());
+ }
- /// Returns the default domain from the current environment.
- /// Returns the default domain from the current environment.
- /// The default domain.
- public static string GetDefaultDomain()
- {
- return DefaultDomain;
- }
+ /// Returns the default domain from the current environment.
+ /// Returns the default domain from the current environment.
+ /// The default domain.
+ public static string GetDefaultDomain()
+ {
+ return DefaultDomain;
+ }
- /// Returns the default user from the current environment.
- /// Returns the default user from the current environment.
- /// The default user.
- public static string GetDefaultUser()
- {
- return DefaultUser;
- }
+ /// Returns the default user from the current environment.
+ /// Returns the default user from the current environment.
+ /// The default user.
+ public static string GetDefaultUser()
+ {
+ return DefaultUser;
+ }
- /// Returns the default password from the current environment.
- /// Returns the default password from the current environment.
- /// The default password.
- public static string GetDefaultPassword()
- {
- return DefaultPassword;
- }
+ /// Returns the default password from the current environment.
+ /// Returns the default password from the current environment.
+ /// The default password.
+ public static string GetDefaultPassword()
+ {
+ return DefaultPassword;
+ }
- /// Returns the default workstation from the current environment.
- /// Returns the default workstation from the current environment.
- /// The default workstation.
- public static string GetDefaultWorkstation()
- {
- return DefaultWorkstation;
- }
+ /// Returns the default workstation from the current environment.
+ /// Returns the default workstation from the current environment.
+ /// The default workstation.
+ public static string GetDefaultWorkstation()
+ {
+ return DefaultWorkstation;
+ }
- ///
- private void Parse(byte[] material)
- {
- for (int i = 0; i < 8; i++)
- {
- if (material[i] != NtlmsspSignature[i])
- {
- throw new IOException("Not an NTLMSSP message.");
- }
- }
- if (ReadULong(material, 8) != 3)
- {
- throw new IOException("Not a Type 3 message.");
- }
- byte[] lmResponse = ReadSecurityBuffer(material, 12);
- int lmResponseOffset = ReadULong(material, 16);
- byte[] ntResponse = ReadSecurityBuffer(material, 20);
- int ntResponseOffset = ReadULong(material, 24);
- byte[] domain = ReadSecurityBuffer(material, 28);
- int domainOffset = ReadULong(material, 32);
- byte[] user = ReadSecurityBuffer(material, 36);
- int userOffset = ReadULong(material, 40);
- byte[] workstation = ReadSecurityBuffer(material, 44);
- int workstationOffset = ReadULong(material, 48);
- int flags;
- string charset;
- byte[] _sessionKey = null;
- if (lmResponseOffset == 52
- || ntResponseOffset == 52
- || domainOffset == 52
- || userOffset == 52
- || workstationOffset == 52)
- {
- flags = NtlmsspNegotiateNtlm | NtlmsspNegotiateOem;
- charset = GetOemEncoding();
- }
- else
- {
- _sessionKey = ReadSecurityBuffer(material, 52);
- flags = ReadULong(material, 60);
- charset = ((flags & NtlmsspNegotiateUnicode) != 0)
- ? UniEncoding
- : GetOemEncoding();
- }
- SetSessionKey(_sessionKey);
- SetFlags(flags);
- SetLmResponse(lmResponse);
- SetNtResponse(ntResponse);
- SetDomain(Runtime.GetStringForBytes(domain, charset));
- SetUser(Runtime.GetStringForBytes(user, charset));
- SetWorkstation(Runtime.GetStringForBytes(workstation, charset));
- }
- }
+ ///
+ private void Parse(byte[] material)
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ if (material[i] != NtlmsspSignature[i])
+ {
+ throw new IOException("Not an NTLMSSP message.");
+ }
+ }
+ if (ReadULong(material, 8) != 3)
+ {
+ throw new IOException("Not a Type 3 message.");
+ }
+ byte[] lmResponse = ReadSecurityBuffer(material, 12);
+ int lmResponseOffset = ReadULong(material, 16);
+ byte[] ntResponse = ReadSecurityBuffer(material, 20);
+ int ntResponseOffset = ReadULong(material, 24);
+ byte[] domain = ReadSecurityBuffer(material, 28);
+ int domainOffset = ReadULong(material, 32);
+ byte[] user = ReadSecurityBuffer(material, 36);
+ int userOffset = ReadULong(material, 40);
+ byte[] workstation = ReadSecurityBuffer(material, 44);
+ int workstationOffset = ReadULong(material, 48);
+ int flags;
+ string charset;
+ byte[] _sessionKey = null;
+ if (lmResponseOffset == 52 || ntResponseOffset == 52 || domainOffset == 52 || userOffset
+ == 52 || workstationOffset == 52)
+ {
+ flags = NtlmsspNegotiateNtlm | NtlmsspNegotiateOem;
+ charset = GetOemEncoding();
+ }
+ else
+ {
+ _sessionKey = ReadSecurityBuffer(material, 52);
+ flags = ReadULong(material, 60);
+ charset = ((flags & NtlmsspNegotiateUnicode) != 0) ? UniEncoding : GetOemEncoding
+ ();
+ }
+ SetSessionKey(_sessionKey);
+ SetFlags(flags);
+ SetLmResponse(lmResponse);
+ SetNtResponse(ntResponse);
+ SetDomain(Runtime.GetStringForBytes(domain, charset));
+ SetUser(Runtime.GetStringForBytes(user, charset));
+ SetWorkstation(Runtime.GetStringForBytes(workstation, charset));
+ }
+ }
}
diff --git a/Emby.Common.Implementations/IO/SharpCifs/Smb/ACE.cs b/Emby.Common.Implementations/IO/SharpCifs/Smb/ACE.cs
index 5f1f90070..73b742cfb 100644
--- a/Emby.Common.Implementations/IO/SharpCifs/Smb/ACE.cs
+++ b/Emby.Common.Implementations/IO/SharpCifs/Smb/ACE.cs
@@ -19,272 +19,269 @@ using SharpCifs.Util;
namespace SharpCifs.Smb
{
- ///
- /// An Access Control Entry (ACE) is an element in a security descriptor
- /// such as those associated with files and directories.
- ///
- ///
- /// An Access Control Entry (ACE) is an element in a security descriptor
- /// such as those associated with files and directories. The Windows OS
- /// determines which users have the necessary permissions to access objects
- /// based on these entries.
- ///
- /// To fully understand the information exposed by this class a description
- /// of the access check algorithm used by Windows is required. The following
- /// is a basic description of the algorithm. For a more complete description
- /// we recommend reading the section on Access Control in Keith Brown's
- /// "The .NET Developer's Guide to Windows Security" (which is also
- /// available online).
- ///
- /// Direct ACEs are evaluated first in order. The SID of the user performing
- /// the operation and the desired access bits are compared to the SID
- /// and access mask of each ACE. If the SID matches, the allow/deny flags
- /// and access mask are considered. If the ACE is a "deny"
- /// ACE and any of the desired access bits match bits in the access
- /// mask of the ACE, the whole access check fails. If the ACE is an "allow"
- /// ACE and all of the bits in the desired access bits match bits in
- /// the access mask of the ACE, the access check is successful. Otherwise,
- /// more ACEs are evaluated until all desired access bits (combined)
- /// are "allowed". If all of the desired access bits are not "allowed"
- /// the then same process is repeated for inherited ACEs.
- ///
- /// For example, if user WNET\alice tries to open a file
- /// with desired access bits 0x00000003 (FILE_READ_DATA |
- /// FILE_WRITE_DATA) and the target file has the following security
- /// descriptor ACEs:
- ///
- /// Allow WNET\alice 0x001200A9 Direct
- /// Allow Administrators 0x001F01FF Inherited
- /// Allow SYSTEM 0x001F01FF Inherited
- ///
- /// the access check would fail because the direct ACE has an access mask
- /// of 0x001200A9 which doesn't have the
- /// FILE_WRITE_DATA bit on (bit 0x00000002). Actually, this isn't quite correct. If
- /// WNET\alice is in the local Administrators group the access check
- /// will succeed because the inherited ACE allows local Administrators
- /// both FILE_READ_DATA and FILE_WRITE_DATA access.
- ///
- public class Ace
- {
- public const int FileReadData = unchecked(0x00000001);
+ ///
+ /// An Access Control Entry (ACE) is an element in a security descriptor
+ /// such as those associated with files and directories.
+ ///
+ ///
+ /// An Access Control Entry (ACE) is an element in a security descriptor
+ /// such as those associated with files and directories. The Windows OS
+ /// determines which users have the necessary permissions to access objects
+ /// based on these entries.
+ ///
+ /// To fully understand the information exposed by this class a description
+ /// of the access check algorithm used by Windows is required. The following
+ /// is a basic description of the algorithm. For a more complete description
+ /// we recommend reading the section on Access Control in Keith Brown's
+ /// "The .NET Developer's Guide to Windows Security" (which is also
+ /// available online).
+ ///
+ /// Direct ACEs are evaluated first in order. The SID of the user performing
+ /// the operation and the desired access bits are compared to the SID
+ /// and access mask of each ACE. If the SID matches, the allow/deny flags
+ /// and access mask are considered. If the ACE is a "deny"
+ /// ACE and any of the desired access bits match bits in the access
+ /// mask of the ACE, the whole access check fails. If the ACE is an "allow"
+ /// ACE and all of the bits in the desired access bits match bits in
+ /// the access mask of the ACE, the access check is successful. Otherwise,
+ /// more ACEs are evaluated until all desired access bits (combined)
+ /// are "allowed". If all of the desired access bits are not "allowed"
+ /// the then same process is repeated for inherited ACEs.
+ ///
+ /// For example, if user WNET\alice tries to open a file
+ /// with desired access bits 0x00000003 (FILE_READ_DATA |
+ /// FILE_WRITE_DATA) and the target file has the following security
+ /// descriptor ACEs:
+ ///
+ /// Allow WNET\alice 0x001200A9 Direct
+ /// Allow Administrators 0x001F01FF Inherited
+ /// Allow SYSTEM 0x001F01FF Inherited
+ ///
+ /// the access check would fail because the direct ACE has an access mask
+ /// of 0x001200A9 which doesn't have the
+ /// FILE_WRITE_DATA bit on (bit 0x00000002). Actually, this isn't quite correct. If
+ /// WNET\alice is in the local Administrators group the access check
+ /// will succeed because the inherited ACE allows local Administrators
+ /// both FILE_READ_DATA and FILE_WRITE_DATA access.
+ ///
+ public class Ace
+ {
+ public const int FileReadData = unchecked(0x00000001);
- public const int FileWriteData = unchecked(0x00000002);
+ public const int FileWriteData = unchecked(0x00000002);
- public const int FileAppendData = unchecked(0x00000004);
+ public const int FileAppendData = unchecked(0x00000004);
- public const int FileReadEa = unchecked(0x00000008);
+ public const int FileReadEa = unchecked(0x00000008);
- public const int FileWriteEa = unchecked(0x00000010);
+ public const int FileWriteEa = unchecked(0x00000010);
- public const int FileExecute = unchecked(0x00000020);
+ public const int FileExecute = unchecked(0x00000020);
- public const int FileDelete = unchecked(0x00000040);
+ public const int FileDelete = unchecked(0x00000040);
- public const int FileReadAttributes = unchecked(0x00000080);
+ public const int FileReadAttributes = unchecked(0x00000080);
- public const int FileWriteAttributes = unchecked(0x00000100);
+ public const int FileWriteAttributes = unchecked(0x00000100);
- public const int Delete = unchecked(0x00010000);
+ public const int Delete = unchecked(0x00010000);
- public const int ReadControl = unchecked(0x00020000);
+ public const int ReadControl = unchecked(0x00020000);
- public const int WriteDac = unchecked(0x00040000);
+ public const int WriteDac = unchecked(0x00040000);
- public const int WriteOwner = unchecked(0x00080000);
+ public const int WriteOwner = unchecked(0x00080000);
- public const int Synchronize = unchecked(0x00100000);
+ public const int Synchronize = unchecked(0x00100000);
- public const int GenericAll = unchecked(0x10000000);
+ public const int GenericAll = unchecked(0x10000000);
- public const int GenericExecute = unchecked(0x20000000);
+ public const int GenericExecute = unchecked(0x20000000);
- public const int GenericWrite = unchecked(0x40000000);
+ public const int GenericWrite = unchecked(0x40000000);
- public const int GenericRead = unchecked((int)(0x80000000));
+ public const int GenericRead = unchecked((int)(0x80000000));
- public const int FlagsObjectInherit = unchecked(0x01);
+ public const int FlagsObjectInherit = unchecked(0x01);
- public const int FlagsContainerInherit = unchecked(0x02);
+ public const int FlagsContainerInherit = unchecked(0x02);
- public const int FlagsNoPropagate = unchecked(0x04);
+ public const int FlagsNoPropagate = unchecked(0x04);
- public const int FlagsInheritOnly = unchecked(0x08);
+ public const int FlagsInheritOnly = unchecked(0x08);
- public const int FlagsInherited = unchecked(0x10);
+ public const int FlagsInherited = unchecked(0x10);
- internal bool Allow;
+ internal bool Allow;
- internal int Flags;
+ internal int Flags;
- internal int Access;
+ internal int Access;
- internal Sid Sid;
+ internal Sid Sid;
- // 1
- // 2
- // 3
- // 4
- // 5
- // 6
- // 7
- // 8
- // 9
- // 16
- // 17
- // 18
- // 19
- // 20
- // 28
- // 29
- // 30
- // 31
- /// Returns true if this ACE is an allow ACE and false if it is a deny ACE.
- /// Returns true if this ACE is an allow ACE and false if it is a deny ACE.
- public virtual bool IsAllow()
- {
- return Allow;
- }
+ // 1
+ // 2
+ // 3
+ // 4
+ // 5
+ // 6
+ // 7
+ // 8
+ // 9
+ // 16
+ // 17
+ // 18
+ // 19
+ // 20
+ // 28
+ // 29
+ // 30
+ // 31
+ /// Returns true if this ACE is an allow ACE and false if it is a deny ACE.
+ /// Returns true if this ACE is an allow ACE and false if it is a deny ACE.
+ public virtual bool IsAllow()
+ {
+ return Allow;
+ }
- /// Returns true if this ACE is an inherited ACE and false if it is a direct ACE.
- ///
- ///
- /// Returns true if this ACE is an inherited ACE and false if it is a direct ACE.
- ///
- /// Note: For reasons not fully understood, FLAGS_INHERITED may
- /// not be set within all security descriptors even though the ACE was in
- /// face inherited. If an inherited ACE is added to a parent the Windows
- /// ACL editor will rebuild all children ACEs and set this flag accordingly.
- ///
- public virtual bool IsInherited()
- {
- return (Flags & FlagsInherited) != 0;
- }
+ /// Returns true if this ACE is an inherited ACE and false if it is a direct ACE.
+ ///
+ ///
+ /// Returns true if this ACE is an inherited ACE and false if it is a direct ACE.
+ ///
+ /// Note: For reasons not fully understood, FLAGS_INHERITED may
+ /// not be set within all security descriptors even though the ACE was in
+ /// face inherited. If an inherited ACE is added to a parent the Windows
+ /// ACL editor will rebuild all children ACEs and set this flag accordingly.
+ ///
+ public virtual bool IsInherited()
+ {
+ return (Flags & FlagsInherited) != 0;
+ }
- /// Returns the flags for this ACE.
- ///
- /// Returns the flags for this ACE. The isInherited()
- /// method checks the FLAGS_INHERITED bit in these flags.
- ///
- public virtual int GetFlags()
- {
- return Flags;
- }
+ /// Returns the flags for this ACE.
+ ///
+ /// Returns the flags for this ACE. The isInherited()
+ /// method checks the FLAGS_INHERITED bit in these flags.
+ ///
+ public virtual int GetFlags()
+ {
+ return Flags;
+ }
- ///
- /// Returns the 'Apply To' text for inheritance of ACEs on
- /// directories such as 'This folder, subfolder and files'.
- ///
- ///
- /// Returns the 'Apply To' text for inheritance of ACEs on
- /// directories such as 'This folder, subfolder and files'. For
- /// files the text is always 'This object only'.
- ///
- public virtual string GetApplyToText()
- {
- switch (Flags & (FlagsObjectInherit | FlagsContainerInherit | FlagsInheritOnly))
- {
- case unchecked(0x00):
- {
- return "This folder only";
- }
+ ///
+ /// Returns the 'Apply To' text for inheritance of ACEs on
+ /// directories such as 'This folder, subfolder and files'.
+ ///
+ ///
+ /// Returns the 'Apply To' text for inheritance of ACEs on
+ /// directories such as 'This folder, subfolder and files'. For
+ /// files the text is always 'This object only'.
+ ///
+ public virtual string GetApplyToText()
+ {
+ switch (Flags & (FlagsObjectInherit | FlagsContainerInherit | FlagsInheritOnly
+ ))
+ {
+ case unchecked(0x00):
+ {
+ return "This folder only";
+ }
- case unchecked(0x03):
- {
- return "This folder, subfolders and files";
- }
+ case unchecked(0x03):
+ {
+ return "This folder, subfolders and files";
+ }
- case unchecked(0x0B):
- {
- return "Subfolders and files only";
- }
+ case unchecked(0x0B):
+ {
+ return "Subfolders and files only";
+ }
- case unchecked(0x02):
- {
- return "This folder and subfolders";
- }
+ case unchecked(0x02):
+ {
+ return "This folder and subfolders";
+ }
- case unchecked(0x0A):
- {
- return "Subfolders only";
- }
+ case unchecked(0x0A):
+ {
+ return "Subfolders only";
+ }
- case unchecked(0x01):
- {
- return "This folder and files";
- }
+ case unchecked(0x01):
+ {
+ return "This folder and files";
+ }
- case unchecked(0x09):
- {
- return "Files only";
- }
- }
- return "Invalid";
- }
+ case unchecked(0x09):
+ {
+ return "Files only";
+ }
+ }
+ return "Invalid";
+ }
- /// Returns the access mask accociated with this ACE.
- ///
- /// Returns the access mask accociated with this ACE. Use the
- /// constants for FILE_READ_DATA, FILE_WRITE_DATA,
- /// READ_CONTROL, GENERIC_ALL, etc with bitwise
- /// operators to determine which bits of the mask are on or off.
- ///
- public virtual int GetAccessMask()
- {
- return Access;
- }
+ /// Returns the access mask accociated with this ACE.
+ ///
+ /// Returns the access mask accociated with this ACE. Use the
+ /// constants for FILE_READ_DATA, FILE_WRITE_DATA,
+ /// READ_CONTROL, GENERIC_ALL, etc with bitwise
+ /// operators to determine which bits of the mask are on or off.
+ ///
+ public virtual int GetAccessMask()
+ {
+ return Access;
+ }
- /// Return the SID associated with this ACE.
- /// Return the SID associated with this ACE.
- public virtual Sid GetSid()
- {
- return Sid;
- }
+ /// Return the SID associated with this ACE.
+ /// Return the SID associated with this ACE.
+ public virtual Sid GetSid()
+ {
+ return Sid;
+ }
- internal virtual int Decode(byte[] buf, int bi)
- {
- Allow = buf[bi++] == unchecked(unchecked(0x00));
- Flags = buf[bi++] & unchecked(0xFF);
- int size = ServerMessageBlock.ReadInt2(buf, bi);
- bi += 2;
- Access = ServerMessageBlock.ReadInt4(buf, bi);
- bi += 4;
- Sid = new Sid(buf, bi);
- return size;
- }
+ internal virtual int Decode(byte[] buf, int bi)
+ {
+ Allow = buf[bi++] == unchecked(unchecked(0x00));
+ Flags = buf[bi++] & unchecked(0xFF);
+ int size = ServerMessageBlock.ReadInt2(buf, bi);
+ bi += 2;
+ Access = ServerMessageBlock.ReadInt4(buf, bi);
+ bi += 4;
+ Sid = new Sid(buf, bi);
+ return size;
+ }
- internal virtual void AppendCol(StringBuilder sb, string str, int width)
- {
- sb.Append(str);
- int count = width - str.Length;
- for (int i = 0; i < count; i++)
- {
- sb.Append(' ');
- }
- }
+ internal virtual void AppendCol(StringBuilder sb, string str, int width)
+ {
+ sb.Append(str);
+ int count = width - str.Length;
+ for (int i = 0; i < count; i++)
+ {
+ sb.Append(' ');
+ }
+ }
- /// Return a string represeting this ACE.
- ///
- /// Return a string represeting this ACE.
- ///
- /// Note: This function should probably be changed to return SDDL
- /// fragments but currently it does not.
- ///