From c60ee93dd92bcad8cc043b560eb92a6bd42cf95c Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Wed, 15 Feb 2017 13:11:14 +0200 Subject: [PATCH] Renamed SMBLibrary.Authentication.Win32 to SMBLibrary.Win32.Security --- SMBLibrary/SMBLibrary.csproj | 9 ++-- .../{Authentication => Security}/LoginAPI.cs | 3 +- .../NetworkAPI.cs | 3 +- .../SSPIHelper.cs | 3 +- .../Structures/SecBuffer.cs} | 38 +-------------- .../Security/Structures/SecBufferDesc.cs | 47 +++++++++++++++++++ SMBLibrary/Win32/Win32UserCollection.cs | 2 +- 7 files changed, 57 insertions(+), 48 deletions(-) rename SMBLibrary/Win32/{Authentication => Security}/LoginAPI.cs (95%) rename SMBLibrary/Win32/{Authentication => Security}/NetworkAPI.cs (96%) rename SMBLibrary/Win32/{Authentication => Security}/SSPIHelper.cs (97%) rename SMBLibrary/Win32/{Authentication/SecBufferDesc.cs => Security/Structures/SecBuffer.cs} (61%) create mode 100644 SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs diff --git a/SMBLibrary/SMBLibrary.csproj b/SMBLibrary/SMBLibrary.csproj index 6956ffc..622ac4c 100644 --- a/SMBLibrary/SMBLibrary.csproj +++ b/SMBLibrary/SMBLibrary.csproj @@ -532,10 +532,11 @@ - - - - + + + + + diff --git a/SMBLibrary/Win32/Authentication/LoginAPI.cs b/SMBLibrary/Win32/Security/LoginAPI.cs similarity index 95% rename from SMBLibrary/Win32/Authentication/LoginAPI.cs rename to SMBLibrary/Win32/Security/LoginAPI.cs index 8f68691..096e87b 100644 --- a/SMBLibrary/Win32/Authentication/LoginAPI.cs +++ b/SMBLibrary/Win32/Security/LoginAPI.cs @@ -7,10 +7,9 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; using Utilities; -namespace SMBLibrary.Authentication.Win32 +namespace SMBLibrary.Win32.Security { public enum LogonType { diff --git a/SMBLibrary/Win32/Authentication/NetworkAPI.cs b/SMBLibrary/Win32/Security/NetworkAPI.cs similarity index 96% rename from SMBLibrary/Win32/Authentication/NetworkAPI.cs rename to SMBLibrary/Win32/Security/NetworkAPI.cs index f55772c..6f86322 100644 --- a/SMBLibrary/Win32/Authentication/NetworkAPI.cs +++ b/SMBLibrary/Win32/Security/NetworkAPI.cs @@ -7,10 +7,9 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; using Utilities; -namespace SMBLibrary.Authentication.Win32 +namespace SMBLibrary.Win32.Security { public class NetworkAPI { diff --git a/SMBLibrary/Win32/Authentication/SSPIHelper.cs b/SMBLibrary/Win32/Security/SSPIHelper.cs similarity index 97% rename from SMBLibrary/Win32/Authentication/SSPIHelper.cs rename to SMBLibrary/Win32/Security/SSPIHelper.cs index 0c0ccca..312af5d 100644 --- a/SMBLibrary/Win32/Authentication/SSPIHelper.cs +++ b/SMBLibrary/Win32/Security/SSPIHelper.cs @@ -7,9 +7,8 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; -namespace SMBLibrary.Authentication.Win32 +namespace SMBLibrary.Win32.Security { [StructLayout(LayoutKind.Sequential)] public struct SecHandle diff --git a/SMBLibrary/Win32/Authentication/SecBufferDesc.cs b/SMBLibrary/Win32/Security/Structures/SecBuffer.cs similarity index 61% rename from SMBLibrary/Win32/Authentication/SecBufferDesc.cs rename to SMBLibrary/Win32/Security/Structures/SecBuffer.cs index e6bdfb4..e11de8f 100644 --- a/SMBLibrary/Win32/Authentication/SecBufferDesc.cs +++ b/SMBLibrary/Win32/Security/Structures/SecBuffer.cs @@ -7,9 +7,8 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; -namespace SMBLibrary.Authentication.Win32 +namespace SMBLibrary.Win32.Security { public enum SecBufferType : uint { @@ -69,39 +68,4 @@ namespace SMBLibrary.Authentication.Win32 return buffer; } } - - [StructLayout(LayoutKind.Sequential)] - public struct SecBufferDesc : IDisposable - { - public uint ulVersion; - public uint cBuffers; // Indicates the number of SecBuffer structures in the pBuffers array. - public IntPtr pBuffers; // Pointer to an array of SecBuffer structures. - - public SecBufferDesc(SecBuffer buffer) : this(new SecBuffer[] { buffer }) - { - } - - public SecBufferDesc(SecBuffer[] buffers) - { - int secBufferSize = Marshal.SizeOf(typeof(SecBuffer)); - ulVersion = (uint)SecBufferType.SECBUFFER_VERSION; - cBuffers = (uint)buffers.Length; - pBuffers = Marshal.AllocHGlobal(buffers.Length * secBufferSize); - IntPtr currentBuffer = pBuffers; - for (int index = 0; index < buffers.Length; index++) - { - Marshal.StructureToPtr(buffers[index], currentBuffer, false); - currentBuffer = new IntPtr(currentBuffer.ToInt64() + secBufferSize); - } - } - - public void Dispose() - { - if (pBuffers != IntPtr.Zero) - { - Marshal.FreeHGlobal(pBuffers); - pBuffers = IntPtr.Zero; - } - } - } } diff --git a/SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs b/SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs new file mode 100644 index 0000000..e1b755e --- /dev/null +++ b/SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs @@ -0,0 +1,47 @@ +/* Copyright (C) 2014-2017 Tal Aloni . All rights reserved. + * + * You can redistribute this program and/or modify it under the terms of + * the GNU Lesser Public License as published by the Free Software Foundation, + * either version 3 of the License, or (at your option) any later version. + */ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace SMBLibrary.Win32.Security +{ + [StructLayout(LayoutKind.Sequential)] + public struct SecBufferDesc : IDisposable + { + public uint ulVersion; + public uint cBuffers; // Indicates the number of SecBuffer structures in the pBuffers array. + public IntPtr pBuffers; // Pointer to an array of SecBuffer structures. + + public SecBufferDesc(SecBuffer buffer) : this(new SecBuffer[] { buffer }) + { + } + + public SecBufferDesc(SecBuffer[] buffers) + { + int secBufferSize = Marshal.SizeOf(typeof(SecBuffer)); + ulVersion = (uint)SecBufferType.SECBUFFER_VERSION; + cBuffers = (uint)buffers.Length; + pBuffers = Marshal.AllocHGlobal(buffers.Length * secBufferSize); + IntPtr currentBuffer = pBuffers; + for (int index = 0; index < buffers.Length; index++) + { + Marshal.StructureToPtr(buffers[index], currentBuffer, false); + currentBuffer = new IntPtr(currentBuffer.ToInt64() + secBufferSize); + } + } + + public void Dispose() + { + if (pBuffers != IntPtr.Zero) + { + Marshal.FreeHGlobal(pBuffers); + pBuffers = IntPtr.Zero; + } + } + } +} diff --git a/SMBLibrary/Win32/Win32UserCollection.cs b/SMBLibrary/Win32/Win32UserCollection.cs index c57fff1..fa70d1d 100644 --- a/SMBLibrary/Win32/Win32UserCollection.cs +++ b/SMBLibrary/Win32/Win32UserCollection.cs @@ -10,7 +10,7 @@ using System.Net; using System.Text; using Utilities; using SMBLibrary.Authentication; -using SMBLibrary.Authentication.Win32; +using SMBLibrary.Win32.Security; using Microsoft.Win32; namespace SMBLibrary.Server.Win32