INTFileStore.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* Copyright (C) 2017 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using Utilities;
  11. namespace SMBLibrary
  12. {
  13. public delegate void OnNotifyChangeCompleted(NTStatus status, byte[] buffer, object context);
  14. /// <summary>
  15. /// A file store (a.k.a. object store) interface to allow access to a file system or a named pipe in an NT-like manner dictated by the SMB protocol.
  16. /// </summary>
  17. public interface INTFileStore
  18. {
  19. NTStatus CreateFile(out object handle, out FileStatus fileStatus, string path, AccessMask desiredAccess, FileAttributes fileAttributes, ShareAccess shareAccess, CreateDisposition createDisposition, CreateOptions createOptions, SecurityContext securityContext);
  20. NTStatus CloseFile(object handle);
  21. NTStatus ReadFile(out byte[] data, object handle, long offset, int maxCount);
  22. NTStatus WriteFile(out int numberOfBytesWritten, object handle, long offset, byte[] data);
  23. NTStatus FlushFileBuffers(object handle);
  24. NTStatus LockFile(object handle, long byteOffset, long length, bool exclusiveLock);
  25. NTStatus UnlockFile(object handle, long byteOffset, long length);
  26. NTStatus QueryDirectory(out List<QueryDirectoryFileInformation> result, object handle, string fileName, FileInformationClass informationClass);
  27. NTStatus GetFileInformation(out FileInformation result, object handle, FileInformationClass informationClass);
  28. NTStatus SetFileInformation(object handle, FileInformation information);
  29. NTStatus GetFileSystemInformation(out FileSystemInformation result, FileSystemInformationClass informationClass);
  30. NTStatus SetFileSystemInformation(FileSystemInformation information);
  31. NTStatus GetSecurityInformation(out SecurityDescriptor result, object handle, SecurityInformation securityInformation);
  32. NTStatus SetSecurityInformation(object handle, SecurityInformation securityInformation, SecurityDescriptor securityDescriptor);
  33. /// <summary>
  34. /// Monitor the contents of a directory (and its subdirectories) by using change notifications.
  35. /// When something changes within the directory being watched this operation is completed.
  36. /// </summary>
  37. /// <returns>
  38. /// STATUS_PENDING - The directory is being watched, change notification will be provided using callback method.
  39. /// STATUS_NOT_SUPPORTED - The underlying object store does not support change notifications.
  40. /// STATUS_INVALID_HANDLE - The handle supplied is invalid.
  41. /// </returns>
  42. NTStatus NotifyChange(out object ioRequest, object handle, NotifyChangeFilter completionFilter, bool watchTree, int outputBufferSize, OnNotifyChangeCompleted onNotifyChangeCompleted, object context);
  43. NTStatus Cancel(object ioRequest);
  44. NTStatus DeviceIOControl(object handle, uint ctlCode, byte[] input, out byte[] output, int maxOutputLength);
  45. }
  46. }