Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

78 Zeilen
4.7 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System;
  22. using System.Diagnostics.CodeAnalysis;
  23. using System.Runtime.InteropServices;
  24. using System.Security;
  25. namespace Alphaleonis.Win32.Filesystem
  26. {
  27. internal static partial class NativeMethods
  28. {
  29. /// <summary>
  30. /// Creates a new transaction object.
  31. /// </summary>
  32. /// <remarks>
  33. /// <para>Use the <see cref="CloseHandle"/> function to close the transaction handle. If the last transaction handle is closed
  34. /// beforea client calls the CommitTransaction function with the transaction handle, then KTM rolls back the transaction.</para>
  35. /// <para>Minimum supported client: Windows Vista</para>
  36. /// <para>Minimum supported server:Windows Server 2008</para>
  37. /// </remarks>
  38. /// <returns>
  39. /// <para>If the function succeeds, the return value is a handle to the transaction.</para>
  40. /// <para>If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call the GetLastError
  41. /// function.</para>
  42. /// </returns>
  43. [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
  44. [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
  45. internal static extern SafeKernelTransactionHandle CreateTransaction([MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpTransactionAttributes, IntPtr uow, [MarshalAs(UnmanagedType.U4)] uint createOptions, [MarshalAs(UnmanagedType.U4)] uint isolationLevel, [MarshalAs(UnmanagedType.U4)] uint isolationFlags, [MarshalAs(UnmanagedType.U4)] int timeout, [MarshalAs(UnmanagedType.LPWStr)] string description);
  46. /// <summary>Requests that the specified transaction be committed.</summary>
  47. /// <remarks>
  48. /// <para>You can commit any transaction handle that has been opened or created using the TRANSACTION_COMMIT permission; any
  49. /// application can commit a transaction, not just the creator.</para>
  50. /// <para>This function can only be called if the transaction is still active, not prepared, pre-prepared, or rolled back.</para>
  51. /// <para>Minimum supported client: Windows Vista</para>
  52. /// <para>Minimum supported server:Windows Server 2008</para>
  53. /// </remarks>
  54. /// <returns>
  55. /// <para>If the function succeeds, the return value is nonzero.</para>
  56. /// <para>If the function fails, the return value is 0 (zero). To get extended error information, call the GetLastError function.</para>
  57. /// </returns>
  58. [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
  59. [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
  60. [return: MarshalAs(UnmanagedType.Bool)]
  61. internal static extern bool CommitTransaction(SafeHandle hTrans);
  62. /// <summary>
  63. /// Requests that the specified transaction be rolled back. This function is synchronous.
  64. /// </summary>
  65. /// <returns>
  66. /// <para>If the function succeeds, the return value is nonzero.</para>
  67. /// <para>If the function fails, the return value is zero. To get extended error information, call the GetLastError function. </para>
  68. /// </returns>
  69. [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")]
  70. [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity]
  71. [return: MarshalAs(UnmanagedType.Bool)]
  72. internal static extern bool RollbackTransaction(SafeHandle hTrans);
  73. }
  74. }