Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

36 linhas
1.5 KiB

  1. using System;
  2. using System.Security;
  3. using Microsoft.Win32.SafeHandles;
  4. namespace Alphaleonis.Win32.Filesystem
  5. {
  6. /// <summary>Represents a wrapper class for a handle used by the FindFirstFile/FindNextFile Win32 API functions.</summary>
  7. [SecurityCritical]
  8. internal sealed class SafeEncryptedFileRawHandle : SafeHandleZeroOrMinusOneIsInvalid
  9. {
  10. /// <summary>Constructor that prevents a default instance of this class from being created.</summary>
  11. private SafeEncryptedFileRawHandle()
  12. : base(true)
  13. {
  14. }
  15. /// <summary>Constructor that prevents a default instance of this class from being created.</summary>
  16. /// <param name="handle">The handle.</param>
  17. /// <param name="ownsHandle">true to reliably release the handle during the finalization phase; false to prevent
  18. /// reliable release (not recommended).</param>
  19. public SafeEncryptedFileRawHandle(IntPtr handle, bool ownsHandle)
  20. : base(ownsHandle)
  21. {
  22. SetHandle(handle);
  23. }
  24. /// <summary>When overridden in a derived class, executes the code required to free the handle.</summary>
  25. /// <returns><see langword="true"/> if the handle is released successfully; otherwise, in the event of a catastrophic failure, <see langword="false"/>. In this case, it generates a ReleaseHandleFailed Managed Debugging Assistant.</returns>
  26. protected override bool ReleaseHandle()
  27. {
  28. NativeMethods.CloseEncryptedFileRaw(handle);
  29. return true;
  30. }
  31. }
  32. }