Renamed SMBLibrary.Authentication.Win32 to SMBLibrary.Win32.Security

This commit is contained in:
Tal Aloni 2017-02-15 13:11:14 +02:00
parent d7e33e465d
commit c60ee93dd9
7 changed files with 57 additions and 48 deletions

View file

@ -532,10 +532,11 @@
<Compile Include="Utilities\LogEntry.cs" />
<Compile Include="Utilities\PrefetchedStream.cs" />
<Compile Include="Utilities\SocketUtils.cs" />
<Compile Include="Win32\Authentication\LoginAPI.cs" />
<Compile Include="Win32\Authentication\NetworkAPI.cs" />
<Compile Include="Win32\Authentication\SecBufferDesc.cs" />
<Compile Include="Win32\Authentication\SSPIHelper.cs" />
<Compile Include="Win32\Security\LoginAPI.cs" />
<Compile Include="Win32\Security\NetworkAPI.cs" />
<Compile Include="Win32\Security\SSPIHelper.cs" />
<Compile Include="Win32\Security\Structures\SecBuffer.cs" />
<Compile Include="Win32\Security\Structures\SecBufferDesc.cs" />
<Compile Include="Win32\Win32UserCollection.cs" />
</ItemGroup>
<ItemGroup>

View file

@ -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
{

View file

@ -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
{

View file

@ -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

View file

@ -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;
}
}
}
}

View file

@ -0,0 +1,47 @@
/* Copyright (C) 2014-2017 Tal Aloni <tal.aloni.il@gmail.com>. 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;
}
}
}
}

View file

@ -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