mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-04-30 02:37:49 +02:00
FindInformation was renamed to FindInformationList, FindInformationEntry was renamed to FindInformation
This commit is contained in:
parent
e0c0bc6ae6
commit
b892bd9018
15 changed files with 125 additions and 125 deletions
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_FIND_FILE_BOTH_DIRECTORY_INFO
|
||||
/// </summary>
|
||||
public class FindFileBothDirectoryInfo : FindInformationEntry
|
||||
public class FindFileBothDirectoryInfo : FindInformation
|
||||
{
|
||||
public const int FixedLength = 94;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_FIND_FILE_DIRECTORY_INFO
|
||||
/// </summary>
|
||||
public class FindFileDirectoryInfo : FindInformationEntry
|
||||
public class FindFileDirectoryInfo : FindInformation
|
||||
{
|
||||
public const int FixedLength = 64;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_FIND_FILE_FULL_DIRECTORY_INFO
|
||||
/// </summary>
|
||||
public class FindFileFullDirectoryInfo : FindInformationEntry
|
||||
public class FindFileFullDirectoryInfo : FindInformation
|
||||
{
|
||||
public const int FixedLength = 68;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_FIND_FILE_NAMES_INFO
|
||||
/// </summary>
|
||||
public class FindFileNamesInfo : FindInformationEntry
|
||||
public class FindFileNamesInfo : FindInformation
|
||||
{
|
||||
public const int FixedLength = 12;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_INFO_QUERY_EA_SIZE
|
||||
/// </summary>
|
||||
public class FindInfoQueryEASize : FindInformationEntry
|
||||
public class FindInfoQueryEASize : FindInformation
|
||||
{
|
||||
public uint ResumeKey; // Optional
|
||||
public DateTime CreationDateTime;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_INFO_QUERY_EAS_FROM_LIST
|
||||
/// </summary>
|
||||
public class FindInfoQueryExtendedAttributesFromList : FindInformationEntry
|
||||
public class FindInfoQueryExtendedAttributesFromList : FindInformation
|
||||
{
|
||||
public uint ResumeKey; // Optional
|
||||
public DateTime CreationDateTime;
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace SMBLibrary.SMB1
|
|||
/// <summary>
|
||||
/// SMB_INFO_STANDARD
|
||||
/// </summary>
|
||||
public class FindInfoStandard : FindInformationEntry
|
||||
public class FindInfoStandard : FindInformation
|
||||
{
|
||||
public const int FixedLength = 23;
|
||||
|
||||
|
|
|
@ -7,72 +7,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
{
|
||||
public class FindInformation : List<FindInformationEntry>
|
||||
public abstract class FindInformation
|
||||
{
|
||||
public FindInformation()
|
||||
private bool m_returnResumeKeys;
|
||||
|
||||
public FindInformation(bool returnResumeKeys)
|
||||
{
|
||||
m_returnResumeKeys = returnResumeKeys;
|
||||
}
|
||||
|
||||
public FindInformation(byte[] buffer, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
public abstract void WriteBytes(byte[] buffer, ref int offset, bool isUnicode);
|
||||
|
||||
public abstract int GetLength(bool isUnicode);
|
||||
|
||||
public bool ReturnResumeKeys
|
||||
{
|
||||
int offset = 0;
|
||||
while (offset < buffer.Length)
|
||||
get
|
||||
{
|
||||
FindInformationEntry entry = FindInformationEntry.ReadEntry(buffer, ref offset, informationLevel, isUnicode, returnResumeKeys);
|
||||
this.Add(entry);
|
||||
return m_returnResumeKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetBytes(bool isUnicode)
|
||||
public static FindInformation ReadEntry(byte[] buffer, ref int offset, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
{
|
||||
for(int index = 0; index < this.Count; index++)
|
||||
switch (informationLevel)
|
||||
{
|
||||
if (index < this.Count - 1)
|
||||
{
|
||||
FindInformationEntry entry = this[index];
|
||||
int entryLength = entry.GetLength(isUnicode);
|
||||
if (entry is FindFileBothDirectoryInfo)
|
||||
{
|
||||
((FindFileBothDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileDirectoryInfo)
|
||||
{
|
||||
((FindFileDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileFullDirectoryInfo)
|
||||
{
|
||||
((FindFileFullDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileNamesInfo)
|
||||
{
|
||||
((FindFileNamesInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
}
|
||||
case FindInformationLevel.SMB_INFO_STANDARD:
|
||||
return new FindInfoStandard(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_INFO_QUERY_EA_SIZE:
|
||||
return new FindInfoQueryEASize(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
|
||||
return new FindInfoQueryExtendedAttributesFromList(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
|
||||
return new FindFileDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
|
||||
return new FindFileFullDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
|
||||
return new FindFileNamesInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
|
||||
return new FindFileBothDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
default:
|
||||
throw new InvalidRequestException();;
|
||||
}
|
||||
int length = GetLength(isUnicode);
|
||||
byte[] buffer = new byte[length];
|
||||
int offset = 0;
|
||||
foreach (FindInformationEntry entry in this)
|
||||
{
|
||||
entry.WriteBytes(buffer, ref offset, isUnicode);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public int GetLength(bool isUnicode)
|
||||
{
|
||||
int length = 0;
|
||||
for (int index = 0; index < this.Count; index++)
|
||||
{
|
||||
FindInformationEntry entry = this[index];
|
||||
int entryLength = entry.GetLength(isUnicode);
|
||||
length += entryLength;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
/* Copyright (C) 2014 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.Text;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
{
|
||||
public abstract class FindInformationEntry
|
||||
{
|
||||
private bool m_returnResumeKeys;
|
||||
|
||||
public FindInformationEntry(bool returnResumeKeys)
|
||||
{
|
||||
m_returnResumeKeys = returnResumeKeys;
|
||||
}
|
||||
|
||||
public abstract void WriteBytes(byte[] buffer, ref int offset, bool isUnicode);
|
||||
|
||||
public abstract int GetLength(bool isUnicode);
|
||||
|
||||
public bool ReturnResumeKeys
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_returnResumeKeys;
|
||||
}
|
||||
}
|
||||
|
||||
public static FindInformationEntry ReadEntry(byte[] buffer, ref int offset, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
{
|
||||
switch (informationLevel)
|
||||
{
|
||||
case FindInformationLevel.SMB_INFO_STANDARD:
|
||||
return new FindInfoStandard(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_INFO_QUERY_EA_SIZE:
|
||||
return new FindInfoQueryEASize(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_INFO_QUERY_EAS_FROM_LIST:
|
||||
return new FindInfoQueryExtendedAttributesFromList(buffer, ref offset, isUnicode, returnResumeKeys);
|
||||
case FindInformationLevel.SMB_FIND_FILE_DIRECTORY_INFO:
|
||||
return new FindFileDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_FULL_DIRECTORY_INFO:
|
||||
return new FindFileFullDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_NAMES_INFO:
|
||||
return new FindFileNamesInfo(buffer, ref offset, isUnicode);
|
||||
case FindInformationLevel.SMB_FIND_FILE_BOTH_DIRECTORY_INFO:
|
||||
return new FindFileBothDirectoryInfo(buffer, ref offset, isUnicode);
|
||||
default:
|
||||
throw new InvalidRequestException();;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* Copyright (C) 2014 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.Text;
|
||||
using Utilities;
|
||||
|
||||
namespace SMBLibrary.SMB1
|
||||
{
|
||||
public class FindInformationList : List<FindInformation>
|
||||
{
|
||||
public FindInformationList()
|
||||
{
|
||||
}
|
||||
|
||||
public FindInformationList(byte[] buffer, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
{
|
||||
int offset = 0;
|
||||
while (offset < buffer.Length)
|
||||
{
|
||||
FindInformation entry = FindInformation.ReadEntry(buffer, ref offset, informationLevel, isUnicode, returnResumeKeys);
|
||||
this.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] GetBytes(bool isUnicode)
|
||||
{
|
||||
for(int index = 0; index < this.Count; index++)
|
||||
{
|
||||
if (index < this.Count - 1)
|
||||
{
|
||||
FindInformation entry = this[index];
|
||||
int entryLength = entry.GetLength(isUnicode);
|
||||
if (entry is FindFileBothDirectoryInfo)
|
||||
{
|
||||
((FindFileBothDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileDirectoryInfo)
|
||||
{
|
||||
((FindFileDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileFullDirectoryInfo)
|
||||
{
|
||||
((FindFileFullDirectoryInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
else if (entry is FindFileNamesInfo)
|
||||
{
|
||||
((FindFileNamesInfo)entry).NextEntryOffset = (uint)entryLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
int length = GetLength(isUnicode);
|
||||
byte[] buffer = new byte[length];
|
||||
int offset = 0;
|
||||
foreach (FindInformation entry in this)
|
||||
{
|
||||
entry.WriteBytes(buffer, ref offset, isUnicode);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public int GetLength(bool isUnicode)
|
||||
{
|
||||
int length = 0;
|
||||
for (int index = 0; index < this.Count; index++)
|
||||
{
|
||||
FindInformation entry = this[index];
|
||||
int entryLength = entry.GetLength(isUnicode);
|
||||
length += entryLength;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,11 +24,11 @@ namespace SMBLibrary.SMB1
|
|||
public ushort EaErrorOffset;
|
||||
public ushort LastNameOffset;
|
||||
// Data:
|
||||
public FindInformation FindInfoList;
|
||||
public FindInformationList FindInfoList;
|
||||
|
||||
public Transaction2FindFirst2Response() : base()
|
||||
{
|
||||
FindInfoList = new FindInformation();
|
||||
FindInfoList = new FindInformationList();
|
||||
}
|
||||
|
||||
public Transaction2FindFirst2Response(byte[] parameters, byte[] data, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys) : base()
|
||||
|
@ -39,7 +39,7 @@ namespace SMBLibrary.SMB1
|
|||
EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 6);
|
||||
LastNameOffset = LittleEndianConverter.ToUInt16(parameters, 8);
|
||||
|
||||
FindInfoList = new FindInformation(data, informationLevel, isUnicode, returnResumeKeys);
|
||||
FindInfoList = new FindInformationList(data, informationLevel, isUnicode, returnResumeKeys);
|
||||
}
|
||||
|
||||
public override byte[] GetParameters(bool isUnicode)
|
||||
|
|
|
@ -23,11 +23,11 @@ namespace SMBLibrary.SMB1
|
|||
public ushort EaErrorOffset;
|
||||
public ushort LastNameOffset;
|
||||
// Data:
|
||||
public FindInformation FindInfoList;
|
||||
public FindInformationList FindInfoList;
|
||||
|
||||
public Transaction2FindNext2Response() : base()
|
||||
{
|
||||
FindInfoList = new FindInformation();
|
||||
FindInfoList = new FindInformationList();
|
||||
}
|
||||
|
||||
public Transaction2FindNext2Response(byte[] parameters, byte[] data, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys) : base()
|
||||
|
@ -37,7 +37,7 @@ namespace SMBLibrary.SMB1
|
|||
EaErrorOffset = LittleEndianConverter.ToUInt16(parameters, 4);
|
||||
LastNameOffset = LittleEndianConverter.ToUInt16(parameters, 6);
|
||||
|
||||
FindInfoList = new FindInformation(data, informationLevel, isUnicode, returnResumeKeys);
|
||||
FindInfoList = new FindInformationList(data, informationLevel, isUnicode, returnResumeKeys);
|
||||
}
|
||||
|
||||
public override byte[] GetParameters(bool isUnicode)
|
||||
|
|
|
@ -296,7 +296,7 @@
|
|||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoQueryEASize.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoQueryExtendedAttributesFromList.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInformation.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInformationEntry.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInformationList.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FindInformation\FindInfoStandard.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FullExtendedAttribute.cs" />
|
||||
<Compile Include="SMB1\Transaction2Subcommands\Structures\FullExtendedAttributeList.cs" />
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace SMBLibrary.Server
|
|||
public const int BytesPerSector = 512;
|
||||
public const int ClusterSize = 4096;
|
||||
|
||||
internal static FindInformationEntry FromFileSystemEntry(FileSystemEntry entry, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
internal static FindInformation FromFileSystemEntry(FileSystemEntry entry, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
||||
{
|
||||
switch (informationLevel)
|
||||
{
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace SMBLibrary.Server
|
|||
Transaction2FindFirst2Response response = new Transaction2FindFirst2Response();
|
||||
for (int index = 0; index < entriesToReturn; index++)
|
||||
{
|
||||
FindInformationEntry infoEntry = InfoHelper.FromFileSystemEntry(entries[index], subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys);
|
||||
FindInformation infoEntry = InfoHelper.FromFileSystemEntry(entries[index], subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys);
|
||||
response.FindInfoList.Add(infoEntry);
|
||||
if (response.FindInfoList.GetLength(header.UnicodeFlag) > state.GetMaxDataCount(header.PID))
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ namespace SMBLibrary.Server
|
|||
List<FileSystemEntry> entries = state.OpenSearches[subcommand.SID];
|
||||
for (int index = 0; index < entries.Count; index++)
|
||||
{
|
||||
FindInformationEntry infoEntry = InfoHelper.FromFileSystemEntry(entries[index], subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys);
|
||||
FindInformation infoEntry = InfoHelper.FromFileSystemEntry(entries[index], subcommand.InformationLevel, header.UnicodeFlag, returnResumeKeys);
|
||||
response.FindInfoList.Add(infoEntry);
|
||||
if (response.FindInfoList.GetLength(header.UnicodeFlag) > state.GetMaxDataCount(header.PID))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue