' ########################################################################################
' Microsoft Windows
' File: callobj.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_callobj_PBI)
#DEFINE PBX_callobj_PBI
%EQUATE `CALLOBJ_INC = 1
'/* header files for imported files */
#INCLUDE ONCE "Legacy/COM/OAIdl.inc"
#IF NOT %DEF(%ICallFrame_INTERFACE_DEFINED)
 %ICallFrame_INTERFACE_DEFINED = 1
' // Size = 60 bytes
TYPE CALLFRAMEINFO DWORD
 iMethod AS DWORD ' ULONG iMethod
 fHasInValues AS LONG ' BOOL fHasInValues
 fHasInOutValues AS LONG ' BOOL fHasInOutValues
 fHasOutValues AS LONG ' BOOL fHasOutValues
 fDerivesFromIDispatch AS LONG ' BOOL fDerivesFromIDispatch
 cInInterfacesMax AS LONG ' LONG cInInterfacesMax
 cInOutInterfacesMax AS LONG ' LONG cInOutInterfacesMax
 cOutInterfacesMax AS LONG ' LONG cOutInterfacesMax
 cTopLevelInInterfaces AS LONG ' LONG cTopLevelInInterfaces
 iid AS GUID ' IID iid
 cMethod AS DWORD ' ULONG cMethod
 cParams AS DWORD ' ULONG cParams
END TYPE
' // Size = 12 bytes
TYPE CALLFRAMEPARAMINFO WORD
 fIn AS BYTE ' BOOLEAN fIn
 fOut AS BYTE ' BOOLEAN fOut
 stackOffset AS DWORD ' ULONG stackOffset
 cbParam AS DWORD ' ULONG cbParam
END TYPE
MACRO CALLFRAME_COPY_ENUM = LONG
' CALLFRAME_COPY enum
%EQUATE `CALLFRAME_COPY_NESTED = 1
%EQUATE `CALLFRAME_COPY_INDEPENDENT = 2
MACRO CALLFRAME_FREE_ENUM = LONG
' CALLFRAME_FREE enum
%EQUATE `CALLFRAME_FREE_NONE = 0
%EQUATE `CALLFRAME_FREE_IN = 1
%EQUATE `CALLFRAME_FREE_INOUT = 2
%EQUATE `CALLFRAME_FREE_OUT = 4
%EQUATE `CALLFRAME_FREE_TOP_INOUT = 8
%EQUATE `CALLFRAME_FREE_TOP_OUT = 16
%EQUATE `CALLFRAME_FREE_ALL = 31
MACRO CALLFRAME_NULL_ENUM = LONG
' CALLFRAME_NULL enum
%EQUATE `CALLFRAME_NULL_NONE = 0
%EQUATE `CALLFRAME_NULL_INOUT = 2
%EQUATE `CALLFRAME_NULL_OUT = 4
%EQUATE `CALLFRAME_NULL_ALL = 6
MACRO CALLFRAME_WALK_ENUM = LONG
' CALLFRAME_WALK enum
%EQUATE `CALLFRAME_WALK_IN = 1
%EQUATE `CALLFRAME_WALK_INOUT = 2
%EQUATE `CALLFRAME_WALK_OUT = 4
' // Size = 32 bytes
TYPE CALLFRAME_MARSHALCONTEXT DWORD
 fIn AS BYTE ' BOOLEAN fIn
 dwDestContext AS DWORD ' DWORD dwDestContext
 pvDestContext AS DWORD ' LPVOID pvDestContext
 mshlmgr AS DWORD ' IUnknown *punkReserved
 guidTransferSyntax AS GUID ' GUID guidTransferSyntax
END TYPE
' ########################################################################################
' ICallFrame interface
' IID = D573B4B0-894E-11D2-B8B6-00C04FB9618A
' Inherited interface = IUnknown
' ########################################################################################
$IID_ICallFrame = GUID$("{D573B4B0-894E-11D2-B8B6-00C04FB9618A}")
INTERFACE ICallFrame $IID_ICallFrame
 INHERIT IUnknown
 ' =====================================================================================
 METHOD GetInfo ( ' VTable offset = 12
 BYREF pInfo AS CALLFRAMEINFO
 ) AS LONG
 ' =====================================================================================
 METHOD GetIIDAndMethod ( ' VTable offset = 16
 BYREF pIID AS GUID
 , BYREF piMethod AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetNames ( ' VTable offset = 20
 BYREF pwszInterface AS DWORD
 , BYREF pwszMethod AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetStackLocation ( ' VTable offset = 24
 ) AS DWORD
 ' =====================================================================================
 METHOD SetStackLocation ( ' VTable offset = 28
 BYVAL pvStack AS DWORD
 ) ' void
 ' =====================================================================================
 METHOD SetReturnValue ( ' VTable offset = 32
 BYVAL hr AS LONG
 ) ' void
 ' =====================================================================================
 METHOD GetReturnValue ( ' VTable offset = 36
 ) AS LONG
 ' =====================================================================================
 METHOD GetParamInfo ( ' VTable offset = 40
 BYVAL iparam AS DWORD
 , BYREF pInfo AS CALLFRAMEPARAMINFO
 ) AS LONG
 ' =====================================================================================
 METHOD SetParam ( ' VTable offset = 44
 BYVAL iparam AS DWORD
 , BYREF pvar AS VARIANT
 ) AS LONG
 ' =====================================================================================
 METHOD GetParam ( ' VTable offset = 48
 BYVAL iparam AS DWORD
 , BYREF pvar AS VARIANT
 ) AS LONG
 ' =====================================================================================
 METHOD Copy ( ' VTable offset = 52
 BYVAL copyControl AS CALLFRAME_COPY_ENUM
 , BYVAL pWalker AS ICallFrameWalker
 , BYREF ppFrame AS ICallFrame
 ) AS LONG
 ' =====================================================================================
 METHOD Free ( ' VTable offset = 56
 BYVAL pframeArgsDest AS ICallFrame
 , BYVAL pWalkerDestFree AS ICallFrameWalker
 , BYVAL pWalkerCopy AS ICallFrameWalker
 , BYVAL freeFlags AS DWORD
 , BYVAL pWalkerFree AS ICallFrameWalker
 , BYVAL nullFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD FreeParam ( ' VTable offset = 60
 BYVAL iparam AS DWORD
 , BYVAL freeFlags AS DWORD
 , BYVAL pWalkerFree AS ICallFrameWalker
 , BYVAL nullFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD WalkFrame ( ' VTable offset = 64
 BYVAL walkWhat AS DWORD
 , BYVAL pWalker AS ICallFrameWalker
 ) AS LONG
 ' =====================================================================================
 METHOD GetMarshalSizeMax ( ' VTable offset = 68
 BYREF pmshlContext AS CALLFRAME_MARSHALCONTEXT
 , BYVAL mshlflags AS DWORD
 , BYREF pcbBufferNeeded AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Marshal ( ' VTable offset = 72
 BYREF pmshlContext AS CALLFRAME_MARSHALCONTEXT
 , BYVAL mshlflags AS DWORD
 , BYVAL pBuffer AS DWORD
 , BYVAL cbBuffer AS DWORD
 , BYREF pcbBufferUsed AS DWORD
 , BYREF pdataRep AS DWORD
 , BYREF prpcFlags AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD Unmarshal ( ' VTable offset = 76
 BYVAL pBuffer AS DWORD
 , BYVAL cbBuffer AS DWORD
 , BYVAL dataRep AS DWORD
 , BYREF pcontext AS CALLFRAME_MARSHALCONTEXT
 , BYREF pcbUnmarshalled AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD ReleaseMarshalData ( ' VTable offset = 80
 BYVAL pBuffer AS DWORD
 , BYVAL cbBuffer AS DWORD
 , BYVAL ibFirstRelease AS DWORD
 , BYVAL dataRep AS DWORD
 , BYREF pcontext AS CALLFRAME_MARSHALCONTEXT
 ) AS LONG
 ' =====================================================================================
 METHOD Invoke ( ' VTable offset = 84
 BYVAL pvReceiver AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallFrame_INTERFACE_DEFINED__ */
' ########################################################################################
' ICallIndirect interface
' IID = D573B4B1-894E-11D2-B8B6-00C04FB9618A
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ICallIndirect_INTERFACE_DEFINED)
 %ICallIndirect_INTERFACE_DEFINED = 1
$IID_ICallIndirect = GUID$("{D573B4B1-894E-11D2-B8B6-00C04FB9618A}")
INTERFACE ICallIndirect $IID_ICallIndirect
 INHERIT IUnknown
 ' =====================================================================================
 METHOD CallIndirect ( ' VTable offset = 12
 BYREF phrReturn AS LONG
 , BYVAL iMethod AS DWORD
 , BYVAL pvArgs AS DWORD
 , BYREF cbArgs AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMethodInfo ( ' VTable offset = 16
 BYVAL iMethod AS DWORD
 , BYREF pInfo AS CALLFRAMEINFO
 , BYREF pwszMethod AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetStackSize ( ' VTable offset = 20
 BYVAL iMethod AS DWORD
 , BYREF cbArgs AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetIID ( ' VTable offset = 24
 BYREF piid AS GUID
 , BYREF pfDerivesFromIDispatch AS LONG
 , BYREF pcMethod AS DWORD
 , BYREF pwszInterface AS DWORD
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallIndirect_INTERFACE_DEFINED__ */
' ########################################################################################
' ICallInterceptor interface
' IID = 60C7CA75-896D-11Dd2-B8B6-00C04FB9618A
' Inherited interface = ICallIndirect
' ########################################################################################
#IF NOT %DEF(%ICallInterceptor_INTERFACE_DEFINED)
 %ICallInterceptor_INTERFACE_DEFINED = 1
$IID_ICallInterceptor = GUID$("{60C7CA75-896D-11D2-B8B6-00C04FB9618A}")
INTERFACE ICallInterceptor $IID_ICallInterceptor
 INHERIT IUnknown
 ' =====================================================================================
 METHOD CallIndirect ( ' VTable offset = 12
 BYREF phrReturn AS LONG
 , BYVAL iMethod AS DWORD
 , BYVAL pvArgs AS DWORD
 , BYREF cbArgs AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetMethodInfo ( ' VTable offset = 16
 BYVAL iMethod AS DWORD
 , BYREF pInfo AS CALLFRAMEINFO
 , BYREF pwszMethod AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetStackSize ( ' VTable offset = 20
 BYVAL iMethod AS DWORD
 , BYREF cbArgs AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD GetIID ( ' VTable offset = 24
 BYREF piid AS GUID
 , BYREF pfDerivesFromIDispatch AS LONG
 , BYREF pcMethod AS DWORD
 , BYREF pwszInterface AS DWORD
 ) AS LONG
 ' =====================================================================================
 METHOD RegisterSink ( ' VTable offset = 28
 BYVAL psink AS ICallFrameEvents
 ) AS LONG
 ' =====================================================================================
 METHOD GetRegisteredSink ( ' VTable offset = 32
 BYREF ppsink AS ICallFrameEvents
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallInterceptor_INTERFACE_DEFINED__ */
' ########################################################################################
' ICallFrameEvents interface
' IID = FD5E0843-FC91-11d0-97D7-00C04FB9618A
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ICallFrameEvents_INTERFACE_DEFINED)
 %ICallFrameEvents_INTERFACE_DEFINED = 1
$IID_ICallFrameEvents = GUID$("{FD5E0843-FC91-11D0-97D7-00C04FB9618A}")
INTERFACE ICallFrameEvents $IID_ICallFrameEvents
 INHERIT IUnknown
 ' =====================================================================================
 METHOD OnCall ( ' VTable offset = 12
 BYVAL pFrame AS ICallFrame
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallFrameEvents_INTERFACE_DEFINED__ */
' ########################################################################################
' ICallUnmarshal interface
' IID = 5333B003-2E42-11D2-B89D-00C04FB9618A
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ICallUnmarshal_INTERFACE_DEFINED)
 %ICallUnmarshal_INTERFACE_DEFINED = 1
$IID_ICallUnmarshal = GUID$("{5333B003-2E42-11D2-B89D-00C04FB9618A}")
INTERFACE ICallUnmarshal $IID_ICallUnmarshal
 INHERIT IUnknown
 ' =====================================================================================
 METHOD Unmarshal ( ' VTable offset = 12
 BYVAL iMethod AS DWORD
 , BYVAL pBuffer AS DWORD
 , BYVAL cbBuffer AS DWORD
 , BYVAL fForceBufferCopy AS LONG
 , BYVAL dataRep AS DWORD
 , BYREF pcontext AS CALLFRAME_MARSHALCONTEXT
 , BYREF pcbUnmarshalled AS DWORD
 , BYREF ppFrame AS ICallFrame
 ) AS LONG
 ' =====================================================================================
 METHOD ReleaseMarshalData ( ' VTable offset = 16
 BYVAL iMethod AS DWORD
 , BYVAL pBuffer AS DWORD
 , BYVAL cbBuffer AS DWORD
 , BYVAL ibFirstRelease AS DWORD
 , BYVAL dataRep AS DWORD
 , BYREF pcontext AS CALLFRAME_MARSHALCONTEXT
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallUnmarshal_INTERFACE_DEFINED__ */
' ########################################################################################
' ICallFrameWalker interface
' IID = 08B23919-392D-11d2-B8A4-00C04FB9618A
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%ICallFrameWalker_INTERFACE_DEFINED)
 %ICallFrameWalker_INTERFACE_DEFINED = 1
$IID_ICallFrameWalker = GUID$("{08B23919-392D-11D2-B8A4-00C04FB9618A}")
INTERFACE ICallFrameWalker $IID_ICallFrameWalker
 INHERIT IUnknown
 ' =====================================================================================
 METHOD OnWalkInterface ( ' VTable offset = 12
 BYREF iid AS GUID
 , BYVAL ppvInterface AS DWORD
 , BYVAL fIn AS LONG
 , BYVAL fOut AS LONG
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __ICallFrameWalker_INTERFACE_DEFINED__ */
' ########################################################################################
' IInterfaceRelated interface
' IID = D1FB5A79-7706-11d1-ADBA-00C04FC2ADC0
' Inherited interface = IUnknown
' ########################################################################################
#IF NOT %DEF(%IInterfaceRelated_INTERFACE_DEFINED)
 %IInterfaceRelated_INTERFACE_DEFINED = 1
$IID_IInterfaceRelated = GUID$("{D1FB5A79-7706-11d1-ADBA-00C04FC2ADC0}")
INTERFACE IInterfaceRelated $IID_IInterfaceRelated
 INHERIT IUnknown
 ' =====================================================================================
 METHOD SetIID ( ' VTable offset = 12
 BYREF iid AS GUID
 ) AS LONG
 ' =====================================================================================
 METHOD GetIID ( ' VTable offset = 16
 BYREF piid AS GUID
 ) AS LONG
 ' =====================================================================================
END INTERFACE
#ENDIF ' /* __IInterfaceRelated_INTERFACE_DEFINED__ */
'#define CALLFRAME_E_ALREADYINVOKED _HRESULT_TYPEDEF_( 0x8004d090 )
'#define CALLFRAME_E_COULDNTMAKECALL _HRESULT_TYPEDEF_( 0x8004d091 )
%EQUATE `CALLFRAME_E_ALREADYINVOKED = &H8004d090
%EQUATE `CALLFRAME_E_COULDNTMAKECALL = &H8004d091
#IF NOT %DEF(%ICallFrameAPIs_INTERFACE_DEFINED)
 %ICallFrameAPIs_INTERFACE_DEFINED = 1
DECLARE FUNCTION CoGetInterceptor LIB "ole32.dll" ALIAS "CoGetInterceptor" ( BYREF iidIntercepted AS GUID , BYVAL punkOuter AS IUnknown , BYREF iid AS GUID , BYREF ppv AS ANY ) AS LONG
DECLARE FUNCTION CoGetInterceptorFromTypeInfo LIB "ole32.dll" ALIAS "CoGetInterceptorFromTypeInfo" ( BYREF iidIntercepted AS GUID
 , BYVAL punkOuter AS IUnknown
 , BYVAL typeInfo AS ITypeInfo
 , BYREF iid AS GUID
 , BYREF ppv AS ANY
 ) AS LONG
#ENDIF ' /* __ICallFrameAPIs_INTERFACE_DEFINED__ */
#ENDIF
