#ifndef _NTTMAPI_H
/**
* Initiates commit of a KTM transaction. This is distinct from the registry-only NtCommitRegistryTransaction
* API and its reserved Flags parameter.
*
* \param TransactionHandle KTM transaction handle with TRANSACTION_COMMIT (0x8). The native entry
* additionally requires SYNCHRONIZE (0x100000) when Wait is nonzero: the synchronous access mask is 0x100008.
* A commit-only handle can request asynchronous commit but is denied for synchronous commit.
* \param Wait TRUE waits for outcome completion; FALSE permits asynchronous completion. Empty transactions
* can complete immediately even with FALSE.
* \return STATUS_SUCCESS, STATUS_PENDING for an operation still in progress, or an error. STATUS_PENDING
* satisfies NT_SUCCESS but is not completed commit. Terminal paths return
* STATUS_TRANSACTION_ALREADY_COMMITTED after commit and STATUS_TRANSACTION_ALREADY_ABORTED after rollback.
* \remarks For asynchronous calls, wait/query outcome using appropriately authorized handles before treating
* changes as committed. Registry-only handles are rejected with STATUS_OBJECT_TYPE_MISMATCH. Close every
* handle independently; completion does not close it. Superior, coordinator, resource-manager, and recovery
* paths can return additional failures.
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-zwcommittransaction
*/
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
NtCommitTransaction(
_In_ HANDLE TransactionHandle,
_In_ BOOLEAN Wait
);
View code on GitHub#ifndef _NTZWAPI_H
_Kernel_entry_
NTSYSCALLAPI
NTSTATUS
NTAPI
ZwCommitTransaction(
_In_ HANDLE TransactionHandle,
_In_ BOOLEAN Wait
);
View code on GitHub// wdm.h
__kernel_entry NTSYSCALLAPI NTSTATUS NtCommitTransaction(
[in] HANDLE TransactionHandle,
[in] BOOLEAN Wait
);
View the official Windows Driver Kit DDI reference// wdm.h
NTSYSCALLAPI NTSTATUS ZwCommitTransaction(
[in] HANDLE TransactionHandle,
[in] BOOLEAN Wait
);
View the official Windows Driver Kit DDI referenceThe ZwCommitTransaction routine initiates a commit operation for a specified transaction.
TransactionHandle [in]A handle to a transaction object. Your component receives this handle from ZwCreateTransaction or ZwOpenTransaction. The handle must have TRANSACTION_COMMIT access to the object.
Wait [in]A Boolean value that the caller sets to TRUE for synchronous operation or FALSE for asynchronous operation. If this parameter is TRUE, the call returns after the commit operation is complete.
ZwCommitTransaction returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:
| Return code | Description |
|---|---|
| STATUS_OBJECT_TYPE_MISMATCH | The handle that was specified for the TransactionHandle parameter is not a handle to a transaction object. |
| STATUS_INVALID_HANDLE | The specified transaction object handle is invalid. |
| STATUS_ACCESS_DENIED | The caller does not have appropriate access to the transaction object. |
| STATUS_TRANSACTION_SUPERIOR_EXISTS | The caller cannot commit the transaction because a superior transaction manager exists. |
| STATUS_TRANSACTION_ALREADY_ABORTED | The transaction cannot be committed because it has been rolled back. |
| STATUS_TRANSACTION_ALREADY_COMMITTED | The transaction is already committed. |
| STATUS_TRANSACTION_REQUEST_NOT_VALID | The commit operation for this transaction has already been started. |
| STATUS_PENDING | Commit notifications have been queued to resource managers, and the caller specified FALSE for the Wait parameter. |
The routine might return other NTSTATUS values.
For more information about how transaction clients should use the ZwCommitTransaction routine, see Creating a Transactional Client.
For more information about commit operations, see Handling Commit Operations.
For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Using Nt and Zw Versions of the Native System Services Routines
The ZwCommitTransaction routine initiates a commit operation for a specified transaction.
TransactionHandle [in]A handle to a transaction object. Your component receives this handle from ZwCreateTransaction or ZwOpenTransaction. The handle must have TRANSACTION_COMMIT access to the object.
Wait [in]A Boolean value that the caller sets to TRUE for synchronous operation or FALSE for asynchronous operation. If this parameter is TRUE, the call returns after the commit operation is complete.
ZwCommitTransaction returns STATUS_SUCCESS if the operation succeeds. Otherwise, this routine might return one of the following values:
| Return code | Description |
|---|---|
| STATUS_OBJECT_TYPE_MISMATCH | The handle that was specified for the TransactionHandle parameter is not a handle to a transaction object. |
| STATUS_INVALID_HANDLE | The specified transaction object handle is invalid. |
| STATUS_ACCESS_DENIED | The caller does not have appropriate access to the transaction object. |
| STATUS_TRANSACTION_SUPERIOR_EXISTS | The caller cannot commit the transaction because a superior transaction manager exists. |
| STATUS_TRANSACTION_ALREADY_ABORTED | The transaction cannot be committed because it has been rolled back. |
| STATUS_TRANSACTION_ALREADY_COMMITTED | The transaction is already committed. |
| STATUS_TRANSACTION_REQUEST_NOT_VALID | The commit operation for this transaction has already been started. |
| STATUS_PENDING | Commit notifications have been queued to resource managers, and the caller specified FALSE for the Wait parameter. |
The routine might return other NTSTATUS values.
For more information about how transaction clients should use the ZwCommitTransaction routine, see Creating a Transactional Client.
For more information about commit operations, see Handling Commit Operations.
For calls from kernel-mode drivers, the NtXxx and ZwXxx versions of a Windows Native System Services routine can behave differently in the way that they handle and interpret input parameters. For more information about the relationship between the NtXxx and ZwXxx versions of a routine, see Using Nt and Zw Versions of the Native System Services Routines.
Using Nt and Zw Versions of the Native System Services Routines