|
@@ -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(byte[] buffer, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
|
|
+ public FindInformation(bool returnResumeKeys)
|
|
|
{
|
|
|
- int offset = 0;
|
|
|
- while (offset < buffer.Length)
|
|
|
- {
|
|
|
- FindInformationEntry entry = FindInformationEntry.ReadEntry(buffer, ref offset, informationLevel, isUnicode, returnResumeKeys);
|
|
|
- this.Add(entry);
|
|
|
- }
|
|
|
+ m_returnResumeKeys = returnResumeKeys;
|
|
|
}
|
|
|
|
|
|
- public byte[] GetBytes(bool isUnicode)
|
|
|
+ public abstract void WriteBytes(byte[] buffer, ref int offset, bool isUnicode);
|
|
|
+
|
|
|
+ public abstract int GetLength(bool isUnicode);
|
|
|
+
|
|
|
+ public bool ReturnResumeKeys
|
|
|
{
|
|
|
- for(int index = 0; index < this.Count; index++)
|
|
|
- {
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- int length = GetLength(isUnicode);
|
|
|
- byte[] buffer = new byte[length];
|
|
|
- int offset = 0;
|
|
|
- foreach (FindInformationEntry entry in this)
|
|
|
+ get
|
|
|
{
|
|
|
- entry.WriteBytes(buffer, ref offset, isUnicode);
|
|
|
+ return m_returnResumeKeys;
|
|
|
}
|
|
|
- return buffer;
|
|
|
}
|
|
|
|
|
|
- public int GetLength(bool isUnicode)
|
|
|
+ public static FindInformation ReadEntry(byte[] buffer, ref int offset, FindInformationLevel informationLevel, bool isUnicode, bool returnResumeKeys)
|
|
|
{
|
|
|
- int length = 0;
|
|
|
- for (int index = 0; index < this.Count; index++)
|
|
|
+ switch (informationLevel)
|
|
|
{
|
|
|
- FindInformationEntry entry = this[index];
|
|
|
- int entryLength = entry.GetLength(isUnicode);
|
|
|
- length += 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();;
|
|
|
}
|
|
|
- return length;
|
|
|
}
|
|
|
}
|
|
|
}
|