diff options
Diffstat (limited to 'Emby.Server.Implementations/IO/SharpCifs/Dcerpc')
40 files changed, 0 insertions, 5780 deletions
diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs deleted file mode 100644 index 1d8d13c08..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBind.cs +++ /dev/null @@ -1,102 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; -using SharpCifs.Util; - -namespace SharpCifs.Dcerpc -{ - public class DcerpcBind : DcerpcMessage - { - internal static readonly string[] ResultMessage = { "0", "DCERPC_BIND_ERR_ABSTRACT_SYNTAX_NOT_SUPPORTED" - , "DCERPC_BIND_ERR_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED", "DCERPC_BIND_ERR_LOCAL_LIMIT_EXCEEDED" - }; - - internal static string GetResultMessage(int result) - { - return result < 4 ? ResultMessage[result] : "0x" + Hexdump.ToHexString(result, 4 - ); - } - - public override DcerpcException GetResult() - { - if (Result != 0) - { - return new DcerpcException(GetResultMessage(Result)); - } - return null; - } - - internal DcerpcBinding Binding; - - internal int MaxXmit; - - internal int MaxRecv; - - public DcerpcBind() - { - } - - internal DcerpcBind(DcerpcBinding binding, DcerpcHandle handle) - { - this.Binding = binding; - MaxXmit = handle.MaxXmit; - MaxRecv = handle.MaxRecv; - Ptype = 11; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - - public override int GetOpnum() - { - return 0; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - dst.Enc_ndr_short(MaxXmit); - dst.Enc_ndr_short(MaxRecv); - dst.Enc_ndr_long(0); - dst.Enc_ndr_small(1); - dst.Enc_ndr_small(0); - dst.Enc_ndr_short(0); - dst.Enc_ndr_short(0); - dst.Enc_ndr_small(1); - dst.Enc_ndr_small(0); - Binding.Uuid.Encode(dst); - dst.Enc_ndr_short(Binding.Major); - dst.Enc_ndr_short(Binding.Minor); - DcerpcConstants.DcerpcUuidSyntaxNdr.Encode(dst); - dst.Enc_ndr_long(2); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode_out(NdrBuffer src) - { - src.Dec_ndr_short(); - src.Dec_ndr_short(); - src.Dec_ndr_long(); - int n = src.Dec_ndr_short(); - src.Advance(n); - src.Align(4); - src.Dec_ndr_small(); - src.Align(4); - Result = src.Dec_ndr_short(); - src.Dec_ndr_short(); - src.Advance(20); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs deleted file mode 100644 index 234150664..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcBinding.cs +++ /dev/null @@ -1,122 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using SharpCifs.Dcerpc.Msrpc; -using SharpCifs.Util.Sharpen; - -namespace SharpCifs.Dcerpc -{ - 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()); - } - - public static void AddInterface(string name, string syntax) - { - _interfaces.Put(name, syntax); - } - - internal string Proto; - - internal string Server; - - internal string Endpoint; - - internal Hashtable Options; - - internal Uuid Uuid; - - internal int Major; - - internal int Minor; - - internal DcerpcBinding(string proto, string server) - { - this.Proto = proto; - this.Server = server; - } - - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - internal virtual void SetOption(string key, object val) - { - if (key.Equals("endpoint")) - { - Endpoint = val.ToString().ToLower(); - if (Endpoint.StartsWith("\\pipe\\")) - { - string iface = (string)_interfaces.Get(Runtime.Substring(Endpoint, 6)); - if (iface != null) - { - int c; - int p; - c = iface.IndexOf(':'); - p = iface.IndexOf('.', c + 1); - Uuid = new Uuid(Runtime.Substring(iface, 0, c)); - Major = Convert.ToInt32(Runtime.Substring(iface, c + 1, p)); - Minor = Convert.ToInt32(Runtime.Substring(iface, p + 1)); - return; - } - } - throw new DcerpcException("Bad endpoint: " + Endpoint); - } - if (Options == null) - { - Options = new Hashtable(); - } - Options.Put(key, val); - } - - 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; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs deleted file mode 100644 index 5b69c5c2e..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcConstants.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc -{ - public static class DcerpcConstants - { - public static Uuid DcerpcUuidSyntaxNdr = new Uuid("8a885d04-1ceb-11c9-9fe8-08002b104860" - ); - - public static int DcerpcFirstFrag = unchecked(0x01); - - public static int DcerpcLastFrag = unchecked(0x02); - - public static int DcerpcPendingCancel = unchecked(0x04); - - public static int DcerpcReserved1 = unchecked(0x08); - - public static int DcerpcConcMpx = unchecked(0x10); - - public static int DcerpcDidNotExecute = unchecked(0x20); - - public static int DcerpcMaybe = unchecked(0x40); - - public static int DcerpcObjectUuid = unchecked(0x80); - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs deleted file mode 100644 index 55c061065..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcError.cs +++ /dev/null @@ -1,48 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc -{ - public static class DcerpcError - { - public static int DcerpcFaultOther = unchecked(0x00000001); - - public static int DcerpcFaultAccessDenied = unchecked(0x00000005); - - public static int DcerpcFaultCantPerform = unchecked(0x000006D8); - - public static int DcerpcFaultNdr = unchecked(0x000006F7); - - public static int DcerpcFaultInvalidTag = unchecked(0x1C000006); - - public static int DcerpcFaultContextMismatch = unchecked(0x1C00001A); - - public static int DcerpcFaultOpRngError = unchecked(0x1C010002); - - public static int DcerpcFaultUnkIf = unchecked(0x1C010003); - - public static int DcerpcFaultProtoError = unchecked(0x1c01000b); - - 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" }; - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs deleted file mode 100644 index 13c4f0d0c..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcException.cs +++ /dev/null @@ -1,93 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.IO; -using SharpCifs.Util; -using SharpCifs.Util.Sharpen; - -namespace SharpCifs.Dcerpc -{ - - 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; - if (errcode > DcerpcError.DcerpcFaultCodes[mid]) - { - min = mid + 1; - } - else - { - if (errcode < DcerpcError.DcerpcFaultCodes[mid]) - { - max = mid - 1; - } - else - { - return DcerpcError.DcerpcFaultMessages[mid]; - } - } - } - return "0x" + Hexdump.ToHexString(errcode, 8); - } - - private int _error; - - private Exception _rootCause; - - internal DcerpcException(int error) : base(GetMessageByDcerpcError(error)) - { - this._error = error; - } - - public DcerpcException(string msg) : base(msg) - { - } - - public DcerpcException(string msg, Exception rootCause) : base(msg) - { - this._rootCause = rootCause; - } - - public virtual int GetErrorCode() - { - return _error; - } - - 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(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs deleted file mode 100644 index 786b0ac12..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcHandle.cs +++ /dev/null @@ -1,332 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.IO; -using SharpCifs.Dcerpc.Ndr; -using SharpCifs.Smb; -using SharpCifs.Util.Sharpen; - -namespace SharpCifs.Dcerpc -{ - public abstract class DcerpcHandle - { - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - protected internal static DcerpcBinding ParseBinding(string str) - { - int state; - int mark; - int si; - char[] arr = str.ToCharArray(); - string proto = null; - string key = null; - DcerpcBinding binding = null; - state = mark = si = 0; - do - { - char ch = arr[si]; - switch (state) - { - case 0: - { - if (ch == ':') - { - proto = Runtime.Substring(str, mark, si); - mark = si + 1; - state = 1; - } - break; - } - - 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 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; - } - - protected internal DcerpcBinding Binding; - - protected internal int MaxXmit = 4280; - - protected internal int MaxRecv; - - protected internal int State; - - protected internal IDcerpcSecurityProvider SecurityProvider; - - private static int _callId = 1; - - /// <exception cref="UnknownHostException"></exception> - /// <exception cref="System.UriFormatException"></exception> - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - public static DcerpcHandle GetHandle(string url, NtlmPasswordAuthentication auth) - { - if (url.StartsWith("ncacn_np:")) - { - return new DcerpcPipeHandle(url, auth); - } - throw new DcerpcException("DCERPC transport not supported: " + url); - } - - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - /// <exception cref="System.IO.IOException"></exception> - public virtual void Bind() - { - lock (this) - { - try - { - State = 1; - DcerpcMessage bind = new DcerpcBind(Binding, this); - Sendrecv(bind); - } - catch (IOException ioe) - { - State = 0; - throw; - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - /// <exception cref="System.IO.IOException"></exception> - public virtual void Sendrecv(DcerpcMessage msg) - { - byte[] stub; - byte[] frag; - NdrBuffer buf; - NdrBuffer fbuf; - bool isLast; - bool isDirect; - DcerpcException de; - if (State == 0) - { - Bind(); - } - isDirect = true; - stub = BufferCache.GetBuffer(); - try - { - int off; - int tot; - int n; - buf = new NdrBuffer(stub, 0); - 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.Flags &= ~DcerpcConstants.DcerpcLastFrag; - n = MaxXmit - 24; - } - else - { - msg.Flags |= DcerpcConstants.DcerpcLastFrag; - 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.Ptype == 2 && msg.IsFlagSet(DcerpcConstants.DcerpcLastFrag) == false) - { - 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; - } - } - - 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 Principal GetPrincipal() - { - if (this is DcerpcPipeHandle) - { - return ((DcerpcPipeHandle)this).Pipe.GetPrincipal(); - } - return null; - } - - public override string ToString() - { - return Binding.ToString(); - } - - /// <exception cref="System.IO.IOException"></exception> - protected internal abstract void DoSendFragment(byte[] buf, int off, int length, - bool isDirect); - - /// <exception cref="System.IO.IOException"></exception> - protected internal abstract void DoReceiveFragment(byte[] buf, bool isDirect); - - /// <exception cref="System.IO.IOException"></exception> - public abstract void Close(); - - public DcerpcHandle() - { - MaxRecv = MaxXmit; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs deleted file mode 100644 index 543dd72dd..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcMessage.cs +++ /dev/null @@ -1,150 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc -{ - public abstract class DcerpcMessage : NdrObject - { - protected internal int Ptype = -1; - - protected internal int Flags; - - protected internal int Length; - - protected internal int CallId; - - protected internal int AllocHint; - - protected internal int Result; - - public virtual bool IsFlagSet(int flag) - { - return (Flags & flag) == flag; - } - - public virtual void UnsetFlag(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; - } - - internal virtual void Encode_header(NdrBuffer buf) - { - buf.Enc_ndr_small(5); - buf.Enc_ndr_small(0); - buf.Enc_ndr_small(Ptype); - buf.Enc_ndr_small(Flags); - buf.Enc_ndr_long(unchecked(0x00000010)); - buf.Enc_ndr_short(Length); - buf.Enc_ndr_short(0); - buf.Enc_ndr_long(CallId); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - internal virtual void Decode_header(NdrBuffer buf) - { - if (buf.Dec_ndr_small() != 5 || buf.Dec_ndr_small() != 0) - { - throw new NdrException("DCERPC version not supported"); - } - Ptype = buf.Dec_ndr_small(); - Flags = buf.Dec_ndr_small(); - if (buf.Dec_ndr_long() != unchecked(0x00000010)) - { - throw new NdrException("Data representation not supported"); - } - Length = buf.Dec_ndr_short(); - if (buf.Dec_ndr_short() != 0) - { - throw new NdrException("DCERPC authentication not supported"); - } - CallId = buf.Dec_ndr_long(); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer buf) - { - int start = buf.GetIndex(); - int allocHintIndex = 0; - buf.Advance(16); - if (Ptype == 0) - { - allocHintIndex = buf.GetIndex(); - buf.Enc_ndr_long(0); - buf.Enc_ndr_short(0); - buf.Enc_ndr_short(GetOpnum()); - } - Encode_in(buf); - Length = buf.GetIndex() - start; - if (Ptype == 0) - { - buf.SetIndex(allocHintIndex); - AllocHint = Length - allocHintIndex; - buf.Enc_ndr_long(AllocHint); - } - buf.SetIndex(start); - Encode_header(buf); - buf.SetIndex(start + Length); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode(NdrBuffer buf) - { - Decode_header(buf); - if (Ptype != 12 && Ptype != 2 && Ptype != 3 && Ptype != 13) - { - throw new NdrException("Unexpected ptype: " + Ptype); - } - if (Ptype == 2 || Ptype == 3) - { - AllocHint = buf.Dec_ndr_long(); - buf.Dec_ndr_short(); - buf.Dec_ndr_short(); - } - if (Ptype == 3 || Ptype == 13) - { - Result = buf.Dec_ndr_long(); - } - else - { - Decode_out(buf); - } - } - - public abstract int GetOpnum(); - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public abstract void Encode_in(NdrBuffer dst); - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public abstract void Decode_out(NdrBuffer src); - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs deleted file mode 100644 index 0399578cd..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcPipeHandle.cs +++ /dev/null @@ -1,135 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using System.IO; -using SharpCifs.Smb; -using SharpCifs.Util; -using SharpCifs.Util.Sharpen; - -namespace SharpCifs.Dcerpc -{ - public class DcerpcPipeHandle : DcerpcHandle - { - internal SmbNamedPipe Pipe; - - internal SmbFileInputStream In; - - internal SmbFileOutputStream Out; - - internal bool IsStart = true; - - /// <exception cref="UnknownHostException"></exception> - /// <exception cref="System.UriFormatException"></exception> - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - public DcerpcPipeHandle(string url, NtlmPasswordAuthentication auth) - { - Binding = ParseBinding(url); - url = "smb://" + Binding.Server + "/IPC$/" + Runtime.Substring(Binding.Endpoint - , 6); - string @params = string.Empty; - string server; - string address; - server = (string)Binding.GetOption("server"); - if (server != null) - { - @params += "&server=" + server; - } - address = (string)Binding.GetOption("address"); - if (server != null) - { - @params += "&address=" + address; - } - if (@params.Length > 0) - { - url += "?" + Runtime.Substring(@params, 1); - } - Pipe = new SmbNamedPipe(url, (unchecked(0x2019F) << 16) | SmbNamedPipe.PipeTypeRdwr - | SmbNamedPipe.PipeTypeDceTransact, auth); - } - - /// <exception cref="System.IO.IOException"></exception> - protected internal override void DoSendFragment(byte[] buf, int off, int length, - bool isDirect) - { - if (Out != null && Out.IsOpen() == false) - { - throw new IOException("DCERPC pipe is no longer open"); - } - if (In == null) - { - In = (SmbFileInputStream)Pipe.GetNamedPipeInputStream(); - } - if (Out == null) - { - Out = (SmbFileOutputStream)Pipe.GetNamedPipeOutputStream(); - } - if (isDirect) - { - Out.WriteDirect(buf, off, length, 1); - return; - } - Out.Write(buf, off, length); - } - - /// <exception cref="System.IO.IOException"></exception> - protected internal override void DoReceiveFragment(byte[] buf, bool isDirect) - { - int off; - int flags; - int length; - if (buf.Length < MaxRecv) - { - throw new ArgumentException("buffer too small"); - } - if (IsStart && !isDirect) - { - // start of new frag, do trans - off = In.Read(buf, 0, 1024); - } - else - { - off = In.ReadDirect(buf, 0, buf.Length); - } - if (buf[0] != 5 && buf[1] != 0) - { - throw new IOException("Unexpected DCERPC PDU header"); - } - flags = buf[3] & unchecked(0xFF); - // next read is start of new frag - 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); - } - } - - /// <exception cref="System.IO.IOException"></exception> - public override void Close() - { - State = 0; - if (Out != null) - { - Out.Close(); - } - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs deleted file mode 100644 index cc46902f1..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/DcerpcSecurityProvider.cs +++ /dev/null @@ -1,29 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc -{ - public interface IDcerpcSecurityProvider - { - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - void Wrap(NdrBuffer outgoing); - - /// <exception cref="SharpCifs.Dcerpc.DcerpcException"></exception> - void Unwrap(NdrBuffer incoming); - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs deleted file mode 100644 index 03964fcc7..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsaPolicyHandle.cs +++ /dev/null @@ -1,43 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Smb; - -namespace SharpCifs.Dcerpc.Msrpc -{ - public class LsaPolicyHandle : Rpc.PolicyHandle - { - /// <exception cref="System.IO.IOException"></exception> - public LsaPolicyHandle(DcerpcHandle handle, string server, int access) - { - if (server == null) - { - server = "\\\\"; - } - MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this); - handle.Sendrecv(rpc); - if (rpc.Retval != 0) - { - throw new SmbException(rpc.Retval, false); - } - } - - /// <exception cref="System.IO.IOException"></exception> - public virtual void Close() - { - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs deleted file mode 100644 index ef09bb16e..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/LsarSidArrayX.cs +++ /dev/null @@ -1,34 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.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]; - } - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs deleted file mode 100644 index 1ae85c473..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Lsarpc.cs +++ /dev/null @@ -1,1161 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_referent(Sid, 1); - if (Sid != null) - { - dst = dst.Deferred; - Sid.Encode(dst); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_short(SidType); - dst.Enc_ndr_long(Rid); - dst.Enc_ndr_long(SidIndex); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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]); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - Handle.Encode(dst); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - Handle.Encode(dst); - dst.Enc_ndr_short(Level); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - Handle.Encode(dst); - dst.Enc_ndr_short(Level); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs deleted file mode 100644 index 6a9d4302a..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcDfsRootEnum.cs +++ /dev/null @@ -1,43 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; -using SharpCifs.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; - 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; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs deleted file mode 100644 index d9c0afb34..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcEnumerateAliasesInDomain.cs +++ /dev/null @@ -1,29 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -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; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs deleted file mode 100644 index 77b2ee375..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcGetMembersInAlias.cs +++ /dev/null @@ -1,29 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Msrpc -{ - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs deleted file mode 100644 index 0aaf31026..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLookupSids.cs +++ /dev/null @@ -1,34 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Smb; - -namespace SharpCifs.Dcerpc.Msrpc -{ - 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; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs deleted file mode 100644 index 9d2c2a0f4..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcLsarOpenPolicy2.cs +++ /dev/null @@ -1,35 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -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; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs deleted file mode 100644 index 820d81ab2..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcQueryInformationPolicy.cs +++ /dev/null @@ -1,30 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc.Msrpc -{ - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs deleted file mode 100644 index 80c45257c..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect2.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Msrpc -{ - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs deleted file mode 100644 index 0f2603e9c..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrConnect4.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Msrpc -{ - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs deleted file mode 100644 index e0b9b68d3..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenAlias.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -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; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs deleted file mode 100644 index 2ac6bceed..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcSamrOpenDomain.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -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) - { - Ptype = 0; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs deleted file mode 100644 index 7c7b64abf..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareEnum.cs +++ /dev/null @@ -1,55 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.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; - } - - private readonly MsrpcShareEnum _enclosing; - } - - 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; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs deleted file mode 100644 index 802ed61a3..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/MsrpcShareGetInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.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; - Flags = DcerpcConstants.DcerpcFirstFrag | DcerpcConstants.DcerpcLastFrag; - } - - /// <exception cref="System.IO.IOException"></exception> - public virtual Ace[] GetSecurity() - { - Srvsvc.ShareInfo502 info502 = (Srvsvc.ShareInfo502)Info; - if (info502.SecurityDescriptor != null) - { - SecurityDescriptor sd; - sd = new SecurityDescriptor(info502.SecurityDescriptor, 0, info502.SdSize); - return sd.Aces; - } - return null; - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs deleted file mode 100644 index a338b2885..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Netdfs.cs +++ /dev/null @@ -1,616 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc.Msrpc -{ - public class Netdfs - { - public static string GetSyntax() - { - return "4fc742e0-4a10-11cf-8273-00aa004ae673:3.0"; - } - - public const int DfsVolumeFlavorStandalone = unchecked(0x100); - - public const int DfsVolumeFlavorAdBlob = unchecked(0x200); - - public const int DfsStorageStateOffline = unchecked(0x0001); - - public const int DfsStorageStateOnline = unchecked(0x0002); - - public const int DfsStorageStateActive = unchecked(0x0004); - - public class DfsInfo1 : NdrObject - { - public string EntryPath; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 DfsInfo1[] S; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 string ServerName; - - public string ShareName; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 string Comment; - - public int State; - - public int NumStores; - - public DfsStorageInfo[] Stores; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 DfsInfo3[] S; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 DfsInfo200[] S; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 string DfsName; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 DfsInfo300[] S; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 NdrObject E; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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 int Retval; - - public string DfsName; - - public int Level; - - public int Prefmaxlen; - - public DfsEnumStruct Info; - - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs deleted file mode 100644 index bdc71695e..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Samr.cs +++ /dev/null @@ -1,579 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc.Msrpc -{ - public class Samr - { - public static string GetSyntax() - { - return "12345778-1234-abcd-ef00-0123456789ac:1.0"; - } - - public const int AcbDisabled = 1; - - public const int AcbHomdirreq = 2; - - public const int AcbPwnotreq = 4; - - public const int AcbTempdup = 8; - - public const int AcbNormal = 16; - - public const int AcbMns = 32; - - public const int AcbDomtrust = 64; - - public const int AcbWstrust = 128; - - public const int AcbSvrtrust = 256; - - public const int AcbPwnoexp = 512; - - public const int AcbAutolock = 1024; - - public const int AcbEncTxtPwdAllowed = 2048; - - public const int AcbSmartcardRequired = 4096; - - public const int AcbTrustedForDelegation = 8192; - - public const int AcbNotDelegated = 16384; - - public const int AcbUseDesKeyOnly = 32768; - - public const int AcbDontRequirePreauth = 65536; - - public class SamrCloseHandle : DcerpcMessage - { - public override int GetOpnum() - { - return unchecked(0x01); - } - - public int Retval; - - public Rpc.PolicyHandle Handle; - - public SamrCloseHandle(Rpc.PolicyHandle handle) - { - this.Handle = handle; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - Handle.Encode(dst); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode_out(NdrBuffer src) - { - Retval = src.Dec_ndr_long(); - } - } - - public class SamrConnect2 : DcerpcMessage - { - public override int GetOpnum() - { - return unchecked(0x39); - } - - public int Retval; - - public string SystemName; - - public int AccessMask; - - public Rpc.PolicyHandle Handle; - - public SamrConnect2(string systemName, int accessMask, Rpc.PolicyHandle handle - ) - { - this.SystemName = systemName; - this.AccessMask = accessMask; - this.Handle = handle; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - Handle.Encode(dst); - dst.Enc_ndr_long(AccessMask); - Sid.Encode(dst); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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]); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - DomainHandle.Encode(dst); - dst.Enc_ndr_long(ResumeHandle); - dst.Enc_ndr_long(AcctFlags); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - DomainHandle.Encode(dst); - dst.Enc_ndr_long(AccessMask); - dst.Enc_ndr_long(Rid); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - AliasHandle.Encode(dst); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_long(Rid); - dst.Enc_ndr_long(Attributes); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs deleted file mode 100644 index d4ebdacc4..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrAliasHandle.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Smb; - -namespace SharpCifs.Dcerpc.Msrpc -{ - public class SamrAliasHandle : Rpc.PolicyHandle - { - /// <exception cref="System.IO.IOException"></exception> - public SamrAliasHandle(DcerpcHandle handle, SamrDomainHandle domainHandle, int access - , int rid) - { - MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this); - handle.Sendrecv(rpc); - if (rpc.Retval != 0) - { - throw new SmbException(rpc.Retval, false); - } - } - - /// <exception cref="System.IO.IOException"></exception> - public virtual void Close() - { - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs deleted file mode 100644 index d44c79886..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrDomainHandle.cs +++ /dev/null @@ -1,41 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Smb; - -namespace SharpCifs.Dcerpc.Msrpc -{ - public class SamrDomainHandle : Rpc.PolicyHandle - { - /// <exception cref="System.IO.IOException"></exception> - public SamrDomainHandle(DcerpcHandle handle, SamrPolicyHandle policyHandle, int access - , Rpc.SidT sid) - { - MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this - ); - handle.Sendrecv(rpc); - if (rpc.Retval != 0) - { - throw new SmbException(rpc.Retval, false); - } - } - - /// <exception cref="System.IO.IOException"></exception> - public virtual void Close() - { - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs deleted file mode 100644 index 0cd3f9369..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/SamrPolicyHandle.cs +++ /dev/null @@ -1,49 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Msrpc -{ - public class SamrPolicyHandle : Rpc.PolicyHandle - { - /// <exception cref="System.IO.IOException"></exception> - public SamrPolicyHandle(DcerpcHandle handle, string server, int access) - { - if (server == null) - { - server = "\\\\"; - } - MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this); - try - { - handle.Sendrecv(rpc); - } - catch (DcerpcException de) - { - if (de.GetErrorCode() != DcerpcError.DcerpcFaultOpRngError) - { - throw; - } - MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this); - handle.Sendrecv(rpc2); - } - } - - /// <exception cref="System.IO.IOException"></exception> - public virtual void Close() - { - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs deleted file mode 100644 index f33f48327..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Msrpc/Srvsvc.cs +++ /dev/null @@ -1,734 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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]); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode_in(NdrBuffer dst) - { - dst.Enc_ndr_referent(Servername, 1); - if (Servername != null) - { - dst.Enc_ndr_string(Servername); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - 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.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs deleted file mode 100644 index 0a47de799..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrBuffer.cs +++ /dev/null @@ -1,305 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; -using SharpCifs.Util; -using SharpCifs.Util.Sharpen; - -namespace SharpCifs.Dcerpc.Ndr -{ - public class NdrBuffer - { - internal int Referent; - - internal Hashtable Referents; - - internal class Entry - { - internal int Referent; - - internal object Obj; - } - - public byte[] Buf; - - public int Start; - - public int Index; - - public int Length; - - public NdrBuffer Deferred; - - 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 void Reset() - { - Index = Start; - Length = 0; - Deferred = this; - } - - public virtual int GetIndex() - { - return Index; - } - - public virtual void SetIndex(int index) - { - this.Index = index; - } - - public virtual int GetCapacity() - { - return Buf.Length - Start; - } - - public virtual int GetTailSpace() - { - return Buf.Length - Index; - } - - 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 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 int GetLength() - { - return Deferred.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 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 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 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 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 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); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public virtual string Dec_ndr_string() - { - Align(4); - int i = Index; - string val = null; - int len = Encdec.Dec_uint32le(Buf, i); - i += 12; - if (len != 0) - { - len--; - int size = len * 2; - try - { - if (size < 0 || size > unchecked(0xFFFF)) - { - throw new NdrException(NdrException.InvalidConformance); - } - val = Runtime.GetStringForBytes(Buf, i, size, "UTF-16LE"); - i += size + 2; - } - catch (UnsupportedEncodingException) - { - } - } - Advance(i - Index); - return val; - } - - private int GetDceReferent(object obj) - { - Entry e; - if (Referents == null) - { - Referents = new Hashtable(); - Referent = 1; - } - if ((e = (Entry)Referents.Get(obj)) == null) - { - e = new Entry(); - e.Referent = Referent++; - e.Obj = obj; - Referents.Put(obj, e); - } - return e.Referent; - } - - 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; - } - } - } - - public override string ToString() - { - return "start=" + Start + ",index=" + Index + ",length=" + GetLength(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs deleted file mode 100644 index 7757735f8..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrException.cs +++ /dev/null @@ -1,32 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System.IO; - -namespace SharpCifs.Dcerpc.Ndr -{ - - public class NdrException : IOException - { - public static readonly string NoNullRef = "ref pointer cannot be null"; - - public static readonly string InvalidConformance = "invalid array conformance"; - - public NdrException(string msg) : base(msg) - { - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs deleted file mode 100644 index 9e2932337..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrHyper.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Ndr -{ - public class NdrHyper : NdrObject - { - public long Value; - - public NdrHyper(long value) - { - this.Value = value; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Enc_ndr_hyper(Value); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode(NdrBuffer src) - { - Value = src.Dec_ndr_hyper(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs deleted file mode 100644 index 74d90465e..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrLong.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Ndr -{ - public class NdrLong : NdrObject - { - public int Value; - - public NdrLong(int value) - { - this.Value = value; - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Enc_ndr_long(Value); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode(NdrBuffer src) - { - Value = src.Dec_ndr_long(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs deleted file mode 100644 index 8951fa202..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrObject.cs +++ /dev/null @@ -1,27 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Ndr -{ - public abstract class NdrObject - { - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public abstract void Encode(NdrBuffer dst); - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public abstract void Decode(NdrBuffer src); - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs deleted file mode 100644 index e2ea8c65b..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrShort.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Ndr -{ - public class NdrShort : NdrObject - { - public int Value; - - public NdrShort(int value) - { - this.Value = value & unchecked(0xFF); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Enc_ndr_short(Value); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode(NdrBuffer src) - { - Value = src.Dec_ndr_short(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs deleted file mode 100644 index 8309dea66..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Ndr/NdrSmall.cs +++ /dev/null @@ -1,40 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc.Ndr -{ - public class NdrSmall : NdrObject - { - public int Value; - - public NdrSmall(int value) - { - this.Value = value & unchecked(0xFF); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Enc_ndr_small(Value); - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Decode(NdrBuffer src) - { - Value = src.Dec_ndr_small(); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs deleted file mode 100644 index aa33d3522..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/Rpc.cs +++ /dev/null @@ -1,285 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using SharpCifs.Dcerpc.Ndr; - -namespace SharpCifs.Dcerpc -{ - public class Rpc - { - public class UuidT : NdrObject - { - public int TimeLow; - - public short TimeMid; - - public short TimeHiAndVersion; - - public byte ClockSeqHiAndReserved; - - public byte ClockSeqLow; - - public byte[] Node; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_long(TimeLow); - dst.Enc_ndr_short(TimeMid); - dst.Enc_ndr_short(TimeHiAndVersion); - dst.Enc_ndr_small(ClockSeqHiAndReserved); - dst.Enc_ndr_small(ClockSeqLow); - int nodes = 6; - int nodei = dst.Index; - dst.Advance(1 * nodes); - dst = dst.Derive(nodei); - for (int i = 0; i < nodes; i++) - { - dst.Enc_ndr_small(Node[i]); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void 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 UuidT Uuid; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_long(Type); - dst.Enc_ndr_long(Uuid.TimeLow); - dst.Enc_ndr_short(Uuid.TimeMid); - dst.Enc_ndr_short(Uuid.TimeHiAndVersion); - dst.Enc_ndr_small(Uuid.ClockSeqHiAndReserved); - dst.Enc_ndr_small(Uuid.ClockSeqLow); - int uuidNodes = 6; - int uuidNodei = dst.Index; - dst.Advance(1 * uuidNodes); - dst = dst.Derive(uuidNodei); - for (int i = 0; i < uuidNodes; i++) - { - dst.Enc_ndr_small(Uuid.Node[i]); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void 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 short MaximumLength; - - public short[] Buffer; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - dst.Enc_ndr_short(Length); - dst.Enc_ndr_short(MaximumLength); - dst.Enc_ndr_referent(Buffer, 1); - if (Buffer != null) - { - dst = dst.Deferred; - int bufferl = Length / 2; - int buffers = MaximumLength / 2; - dst.Enc_ndr_long(buffers); - dst.Enc_ndr_long(0); - dst.Enc_ndr_long(bufferl); - int bufferi = dst.Index; - dst.Advance(2 * bufferl); - dst = dst.Derive(bufferi); - for (int i = 0; i < bufferl; i++) - { - dst.Enc_ndr_short(Buffer[i]); - } - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void 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 byte SubAuthorityCount; - - public byte[] IdentifierAuthority; - - public int[] SubAuthority; - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void Encode(NdrBuffer dst) - { - dst.Align(4); - int subAuthoritys = SubAuthorityCount; - dst.Enc_ndr_long(subAuthoritys); - dst.Enc_ndr_small(Revision); - dst.Enc_ndr_small(SubAuthorityCount); - int identifierAuthoritys = 6; - int identifierAuthorityi = dst.Index; - dst.Advance(1 * identifierAuthoritys); - int subAuthorityi = dst.Index; - dst.Advance(4 * subAuthoritys); - dst = dst.Derive(identifierAuthorityi); - for (int i = 0; i < identifierAuthoritys; i++) - { - dst.Enc_ndr_small(IdentifierAuthority[i]); - } - dst = dst.Derive(subAuthorityi); - for (int i1 = 0; i1 < subAuthoritys; i1++) - { - dst.Enc_ndr_long(SubAuthority[i1]); - } - } - - /// <exception cref="SharpCifs.Dcerpc.Ndr.NdrException"></exception> - public override void 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.Server.Implementations/IO/SharpCifs/Dcerpc/UUID.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/UUID.cs deleted file mode 100644 index bef4be214..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/UUID.cs +++ /dev/null @@ -1,148 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using 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; - } - - 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; - } - - 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); - } - - private static byte B(int i) - { - return unchecked((byte)(i & unchecked(0xFF))); - } - - 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(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); - } - } -} diff --git a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs b/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs deleted file mode 100644 index b0c36898c..000000000 --- a/Emby.Server.Implementations/IO/SharpCifs/Dcerpc/UnicodeString.cs +++ /dev/null @@ -1,65 +0,0 @@ -// This code is derived from jcifs smb client library <jcifs at samba dot org> -// Ported by J. Arturo <webmaster at komodosoft dot net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -namespace SharpCifs.Dcerpc -{ - public class UnicodeString : Rpc.Unicode_string - { - internal bool 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(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); - } - } -} |
