' ########################################################################################
' Microsoft Windows
' File: Transact.inc
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_transact_PBI)
#DEFINE PBX_transact_PBI
%EQUATE `TRANSACT_INC = 1
#INCLUDE ONCE "Legacy/COM/Unknwn.inc"
#INCLUDE ONCE "Legacy/Platform/WinError.inc"
#IF NOT %DEF(%BasicTransactionTypes_INTERFACE_DEFINED)
%EQUATE `BasicTransactionTypes_INTERFACE_DEFINED = 1
' // Size = 16 bytes
TYPE BOID BYTE
 rgb(15) AS BYTE ' byte rgb[ 16 ]
END TYPE
'#define BOID_NULL (*((BOID*)(&IID_NULL)))
$BOID_NULL = $IID_NULL
#IF NOT %DEF(%MAX_TRAN_DESC_DEFINED)
%EQUATE `MAX_TRAN_DESC_DEFINED = 1
' enum TX_MISC_CONSTANTS
%EQUATE `MAX_TRAN_DESC = 40
#ENDIF
'typedef BOID XACTUOW;
'typedef LONG ISOLEVEL;
' enum ISOLATIONLEVEL
%EQUATE `ISOLATIONLEVEL_UNSPECIFIED = &Hffffffff&
%EQUATE `ISOLATIONLEVEL_CHAOS = &H10&
%EQUATE `ISOLATIONLEVEL_READUNCOMMITTED = &H100&
%EQUATE `ISOLATIONLEVEL_BROWSE = &H100&
%EQUATE `ISOLATIONLEVEL_CURSORSTABILITY = &H1000&
%EQUATE `ISOLATIONLEVEL_READCOMMITTED = &H1000&
%EQUATE `ISOLATIONLEVEL_REPEATABLEREAD = &H10000&
%EQUATE `ISOLATIONLEVEL_SERIALIZABLE = &H100000&
%EQUATE `ISOLATIONLEVEL_ISOLATED = &H100000&
' // Size = 40 bytes
TYPE XACTTRANSINFO DWORD
 uow AS GUID ' XACTUOW
 isoLevel AS LONG ' ISOLEVEL
 isoFlags AS DWORD ' ULONG
 grfTCSupported AS DWORD
 grfRMSupported AS DWORD
 grfTCSupportedRetaining AS DWORD
 grfRMSupportedRetaining AS DWORD
END TYPE
' // Size = 36 bytes
TYPE XACTSTATS DWORD
 cOpen AS DWORD ' ULONG
 cCommitting AS DWORD ' ULONG
 cCommitted AS DWORD ' ULONG
 cAborting AS DWORD ' ULONG
 cAborted AS DWORD ' ULONG
 cInDoubt AS DWORD ' ULONG
 cHeuristicDecision AS DWORD ' ULONG
 timeTransactionsUp AS FILETIME ' FILETIME
END TYPE
' enum ISOFLAG
%EQUATE `ISOFLAG_RETAIN_COMMIT_DC = 1
%EQUATE `ISOFLAG_RETAIN_COMMIT = 2
%EQUATE `ISOFLAG_RETAIN_COMMIT_NO = 3
%EQUATE `ISOFLAG_RETAIN_ABORT_DC = 4
%EQUATE `ISOFLAG_RETAIN_ABORT = 8
%EQUATE `ISOFLAG_RETAIN_ABORT_NO = 12
%EQUATE `ISOFLAG_RETAIN_DONTCARE = %ISOFLAG_RETAIN_COMMIT_DC OR %ISOFLAG_RETAIN_ABORT_DC
%EQUATE `ISOFLAG_RETAIN_BOTH = %ISOFLAG_RETAIN_COMMIT OR %ISOFLAG_RETAIN_ABORT
%EQUATE `ISOFLAG_RETAIN_NONE = %ISOFLAG_RETAIN_COMMIT_NO OR %ISOFLAG_RETAIN_ABORT_NO
%EQUATE `ISOFLAG_OPTIMISTIC = 16
%EQUATE `ISOFLAG_READONLY = 32
' enum XACTTC
%EQUATE `XACTTC_NONE = 0
%EQUATE `XACTTC_SYNC_PHASEONE = 1
%EQUATE `XACTTC_SYNC_PHASETWO = 2
%EQUATE `XACTTC_SYNC = 2
%EQUATE `XACTTC_ASYNC_PHASEONE = 4
%EQUATE `XACTTC_ASYNC = 4
' enum XACTRM
%EQUATE `XACTRM_OPTIMISTICLASTWINS = 1
%EQUATE `XACTRM_NOREADONLYPREPARES = 2
' enum XACTCONST
%EQUATE `XACTCONST_TIMEOUTINFINITE = 0
' enum XACTHEURISTIC
%EQUATE `XACTHEURISTIC_ABORT = 1
%EQUATE `XACTHEURISTIC_COMMIT = 2
%EQUATE `XACTHEURISTIC_DAMAGE = 3
%EQUATE `XACTHEURISTIC_DANGER = 4
' enum XACTSTAT
%EQUATE `XACTSTAT_NONE = 0
%EQUATE `XACTSTAT_OPENNORMAL = &H1
%EQUATE `XACTSTAT_OPENREFUSED = &H2
%EQUATE `XACTSTAT_PREPARING = &H4
%EQUATE `XACTSTAT_PREPARED = &H8
%EQUATE `XACTSTAT_PREPARERETAINING = &H10
%EQUATE `XACTSTAT_PREPARERETAINED = &H20
%EQUATE `XACTSTAT_COMMITTING = &H40
%EQUATE `XACTSTAT_COMMITRETAINING = &H80
%EQUATE `XACTSTAT_ABORTING = &H100
%EQUATE `XACTSTAT_ABORTED = &H200
%EQUATE `XACTSTAT_COMMITTED = &H400
%EQUATE `XACTSTAT_HEURISTIC_ABORT = &H800
%EQUATE `XACTSTAT_HEURISTIC_COMMIT = &H1000
%EQUATE `XACTSTAT_HEURISTIC_DAMAGE = &H2000
%EQUATE `XACTSTAT_HEURISTIC_DANGER = &H4000
%EQUATE `XACTSTAT_FORCED_ABORT = &H8000
%EQUATE `XACTSTAT_FORCED_COMMIT = &H10000
%EQUATE `XACTSTAT_INDOUBT = &H20000
%EQUATE `XACTSTAT_CLOSED = &H40000
%EQUATE `XACTSTAT_OPEN = &H3
%EQUATE `XACTSTAT_NOTPREPARED = &H7ffc3
%EQUATE `XACTSTAT_ALL = &H7ffff
' // Size = 44 bytes
TYPE XACTOPT DWORD
 ulTimeout AS DWORD
 szDescription AS ASCIIZ * 40
END TYPE
#ENDIF ' /* __BasicTransactionTypes_INTERFACE_DEFINED__ */
$IID_ITransaction = GUID$("{0FB15084-AF41-11CE-BD2B-204C4F4F5020}")
$IID_ITransactionCloner = GUID$("{02656950-2152-11d0-944C-00A0C905416E}")
$IID_ITransaction2 = GUID$("{34021548-0065-11d3-bac1-00c04f797be2}")
$IID_ITransactionDispenser = GUID$("{3A6AD9E1-23B9-11cf-AD60-00AA00A74CCD}")
$IID_ITransactionOptions = GUID$("{3A6AD9E0-23B9-11CF-AD60-00AA00A74CCD}")
$IID_ITransactionOutcomeEvents = GUID$("{3A6AD9E2-23B9-11cf-AD60-00AA00A74CCD}")
$IID_ITmNodeName = GUID$("{30274F88-6EE4-474e-9B95-7807BC9EF8CF}")
$IID_IKernelTransaction = GUID$("{79427A2B-F895-40E0-BE79-B57DC82ED231}")
' ########################################################################################
' ITransaction interface
' IID = 0FB15084-AF41-11CE-BD2B-204C4F4F5020
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ITransaction_INTERFACE_DEFINED)
 %ITransaction_INTERFACE_DEFINED = 1
INTERFACE ITransaction $IID_ITransaction
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Commit ( ' VTable offset = 12
 BYVAL fRetaining AS LONG
 , BYVAL grfTC AS DWORD
 , BYVAL grfRM AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Abort ( ' VTable offset = 16
 BYVAL pboidReason AS DWORD
 , BYVAL fRetaining AS LONG
 , BYVAL fAsync AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetTransactionInfo ( ' VTable offset = 20
 BYREF pinfo AS XACTTRANSINFO
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransaction_INTERFACE_DEFINED__ */
' ########################################################################################
' ITransactionCloner interface
' IID = 02656950-2152-11d0-944C-00A0C905416E
' Inherited interface = ITransaction
' ########################################################################################
#IF NOT %DEF(%ITransactionCloner_INTERFACE_DEFINED)
 %ITransactionCloner_INTERFACE_DEFINED = 1
INTERFACE ITransactionCloner $IID_ITransactionCloner
 INHERIT IUnknown
 ' =====================================================================================
 ' ITransaction methods
 ' =====================================================================================
 METHOD Commit ( ' VTable offset = 12
 BYVAL fRetaining AS LONG
 , BYVAL grfTC AS DWORD
 , BYVAL grfRM AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Abort ( ' VTable offset = 16
 BYVAL pboidReason AS DWORD
 , BYVAL fRetaining AS LONG
 , BYVAL fAsync AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetTransactionInfo ( ' VTable offset = 20
 BYREF pinfo AS XACTTRANSINFO
 ) AS LONG
 ' =====================================================================================
 ' =====================================================================================
 ' ITransactionCloner methods
 ' =====================================================================================
 METHOD CloneWithCommitDisabled ( ' VTable offset = 24
 BYREF ppITransaction AS ITransaction
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransactionCloner_INTERFACE_DEFINED__ */
' ########################################################################################
' ITransaction2 interface
' IID = 34021548-0065-11d3-bac1-00c04f797be2
' Inherited interface = ITransaction
' ########################################################################################
#IF NOT %DEF(%ITransaction2_INTERFACE_DEFINED)
 %ITransaction2_INTERFACE_DEFINED = 1
INTERFACE ITransaction2 $IID_ITransaction2
 INHERIT IUnknown
 ' =====================================================================================
 ' ITransaction methods
 ' =====================================================================================
 METHOD Commit ( ' VTable offset = 12
 BYVAL fRetaining AS LONG
 , BYVAL grfTC AS DWORD
 , BYVAL grfRM AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Abort ( ' VTable offset = 16
 BYVAL pboidReason AS DWORD
 , BYVAL fRetaining AS LONG
 , BYVAL fAsync AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD GetTransactionInfo ( ' VTable offset = 20
 BYREF pinfo AS XACTTRANSINFO
 ) AS LONG
 ' =====================================================================================
 ' =====================================================================================
 ' ITransaction2 methods
 ' =====================================================================================
 METHOD GetTransactionInfo2 ( ' VTable offset = 24
 BYREF pinfo AS XACTTRANSINFO
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransaction2_INTERFACE_DEFINED__ */
' ########################################################################################
' ITransactionDispenser interface
' IID = 3A6AD9E1-23B9-11cf-AD60-00AA00A74CCD
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ITransactionDispenser_INTERFACE_DEFINED)
 %ITransactionDispenser_INTERFACE_DEFINED = 1
INTERFACE ITransactionDispenser $IID_ITransactionDispenser
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetOptionsObject ( ' VTable offset = 12
 BYREF ppOptions AS ITransactionOptions
 ) AS LONG
 ' =====================================================================================
 METHOD BeginTransaction ( ' VTable offset = 16
 BYVAL punkOuter AS IUnknown
 , BYVAL isoLevel AS LONG
 , BYVAL isoFlags AS DWORD
 , BYVAL pOptions AS ITransactionOptions
 , BYREF ppTransaction AS ITransaction
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransactionDispenser_INTERFACE_DEFINED__ */
' ########################################################################################
' ITransactionOptions interface
' IID = 3A6AD9E0-23B9-11cf-AD60-00AA00A74CCD
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ITransactionOptions_INTERFACE_DEFINED)
 %ITransactionOptions_INTERFACE_DEFINED = 1
INTERFACE ITransactionOptions $IID_ITransactionOptions
 INHERIT IUnknown
 ' =====================================================================================
 METHOD SetOptions ( ' VTable offset = 12
 BYREF pOptions AS XACTOPT
 ) AS LONG
 ' =====================================================================================
 METHOD GetOptions ( ' VTable offset = 16
 BYREF pOptions AS XACTOPT
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransactionOptions_INTERFACE_DEFINED__ */
' ########################################################################################
' ITransactionOutcomeEvents interface
' IID = 3A6AD9E2-23B9-11cf-AD60-00AA00A74CCD
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ITransactionOutcomeEvents_INTERFACE_DEFINED)
 %ITransactionOutcomeEvents_INTERFACE_DEFINED = 1
INTERFACE ITransactionOutcomeEvents $IID_ITransactionOutcomeEvents
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Committed ( ' VTable offset = 12
 BYVAL fRetaining AS LONG
 , BYREF pNewUOW AS GUID
 , BYVAL hr AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Aborted ( ' VTable offset = 16
 BYREF pboidReason AS GUID
 , BYVAL fRetaining AS LONG
 , BYREF pNewUOW AS GUID
 , BYVAL hr AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD HeuristicDecision ( ' VTable offset = 20
 BYVAL dwDecision AS DWORD
 , BYREF pboidReason AS GUID
 , BYVAL hr AS LONG
 ) AS LONG
 ' =====================================================================================
 METHOD Indoubt ( ' VTable offset = 24
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITransactionOutcomeEvents_INTERFACE_DEFINED__ */
' ########################################################################################
' ITmNodeName interface
' IID = 30274F88-6EE4-474e-9B95-7807BC9EF8CF
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ITmNodeName_INTERFACE_DEFINED)
 %ITmNodeName_INTERFACE_DEFINED = 1
INTERFACE ITmNodeName $IID_ITmNodeName
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetNodeNameSize ( ' VTable offset = 12
 BYREF pcbNodeNameSize AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNodeName ( ' VTable offset = 16
 BYVAL cbNodeNameBufferSize AS DWORD
 , BYREF pNodeNameBuffer AS WSTRINGZ
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ITmNodeName_INTERFACE_DEFINED__ */
' ########################################################################################
' IKernelTransaction interface
' IID = 79427A2B-F895-40E0-BE79-B57DC82ED231
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%IKernelTransaction_INTERFACE_DEFINED)
 %IKernelTransaction_INTERFACE_DEFINED = 1
INTERFACE IKernelTransaction $IID_IKernelTransaction
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetHandle ( ' VTable offset = 12
 BYREF pHandle AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IKernelTransaction_INTERFACE_DEFINED__ */
#ENDIF
