| 1585 | } |
| 1586 | |
| 1587 | LONG WINAPI DetourTransactionBegin() |
| 1588 | { |
| 1589 | // Only one transaction is allowed at a time. |
| 1590 | _Benign_race_begin_ |
| 1591 | if (s_nPendingThreadId != 0) { |
| 1592 | return ERROR_INVALID_OPERATION; |
| 1593 | } |
| 1594 | _Benign_race_end_ |
| 1595 | |
| 1596 | // Make sure only one thread can start a transaction. |
| 1597 | if (InterlockedCompareExchange(&s_nPendingThreadId, (LONG)GetCurrentThreadId(), 0) != 0) { |
| 1598 | return ERROR_INVALID_OPERATION; |
| 1599 | } |
| 1600 | |
| 1601 | s_pPendingOperations = NULL; |
| 1602 | s_pPendingThreads = NULL; |
| 1603 | s_ppPendingError = NULL; |
| 1604 | |
| 1605 | // Make sure the trampoline pages are writable. |
| 1606 | s_nPendingError = detour_writable_trampoline_regions(); |
| 1607 | |
| 1608 | return s_nPendingError; |
| 1609 | } |
| 1610 | |
| 1611 | LONG WINAPI DetourTransactionAbort() |
| 1612 | { |
no test coverage detected
searching dependent graphs…