mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
Renamed SMBLibrary.Authentication.Win32 to SMBLibrary.Win32.Security
This commit is contained in:
parent
d7e33e465d
commit
c60ee93dd9
7 changed files with 57 additions and 48 deletions
|
@ -532,10 +532,11 @@
|
||||||
<Compile Include="Utilities\LogEntry.cs" />
|
<Compile Include="Utilities\LogEntry.cs" />
|
||||||
<Compile Include="Utilities\PrefetchedStream.cs" />
|
<Compile Include="Utilities\PrefetchedStream.cs" />
|
||||||
<Compile Include="Utilities\SocketUtils.cs" />
|
<Compile Include="Utilities\SocketUtils.cs" />
|
||||||
<Compile Include="Win32\Authentication\LoginAPI.cs" />
|
<Compile Include="Win32\Security\LoginAPI.cs" />
|
||||||
<Compile Include="Win32\Authentication\NetworkAPI.cs" />
|
<Compile Include="Win32\Security\NetworkAPI.cs" />
|
||||||
<Compile Include="Win32\Authentication\SecBufferDesc.cs" />
|
<Compile Include="Win32\Security\SSPIHelper.cs" />
|
||||||
<Compile Include="Win32\Authentication\SSPIHelper.cs" />
|
<Compile Include="Win32\Security\Structures\SecBuffer.cs" />
|
||||||
|
<Compile Include="Win32\Security\Structures\SecBufferDesc.cs" />
|
||||||
<Compile Include="Win32\Win32UserCollection.cs" />
|
<Compile Include="Win32\Win32UserCollection.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using Utilities;
|
using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Authentication.Win32
|
namespace SMBLibrary.Win32.Security
|
||||||
{
|
{
|
||||||
public enum LogonType
|
public enum LogonType
|
||||||
{
|
{
|
|
@ -7,10 +7,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
using Utilities;
|
using Utilities;
|
||||||
|
|
||||||
namespace SMBLibrary.Authentication.Win32
|
namespace SMBLibrary.Win32.Security
|
||||||
{
|
{
|
||||||
public class NetworkAPI
|
public class NetworkAPI
|
||||||
{
|
{
|
|
@ -7,9 +7,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SMBLibrary.Authentication.Win32
|
namespace SMBLibrary.Win32.Security
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SecHandle
|
public struct SecHandle
|
|
@ -7,9 +7,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace SMBLibrary.Authentication.Win32
|
namespace SMBLibrary.Win32.Security
|
||||||
{
|
{
|
||||||
public enum SecBufferType : uint
|
public enum SecBufferType : uint
|
||||||
{
|
{
|
||||||
|
@ -69,39 +68,4 @@ namespace SMBLibrary.Authentication.Win32
|
||||||
return buffer;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
47
SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs
Normal file
47
SMBLibrary/Win32/Security/Structures/SecBufferDesc.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Utilities;
|
using Utilities;
|
||||||
using SMBLibrary.Authentication;
|
using SMBLibrary.Authentication;
|
||||||
using SMBLibrary.Authentication.Win32;
|
using SMBLibrary.Win32.Security;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace SMBLibrary.Server.Win32
|
namespace SMBLibrary.Server.Win32
|
||||||
|
|
Loading…
Add table
Reference in a new issue