ifndef __COMBASEAPI_INC
define __COMBASEAPI_INC

include apiset.inc
include apisetcconv.inc

include rpc.inc
include rpcndr.inc

if (NTDDI_VERSION ge NTDDI_VISTA and not defined(_WIN32_WINNT))
define _WIN32_WINNT 0x0600
endif

if (NTDDI_VERSION ge NTDDI_WS03 and not defined(_WIN32_WINNT))
define _WIN32_WINNT 0x0502
endif

if (NTDDI_VERSION ge NTDDI_WINXP and not defined(_WIN32_WINNT))
define _WIN32_WINNT 0x0501
endif

if (NTDDI_VERSION ge NTDDI_WIN2K and not defined(_WIN32_WINNT))
define _WIN32_WINNT 0x0500
endif

ifndef _COMBASEAPI_H_
define _COMBASEAPI_H_

.pragma pack(push, size_t)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

include stdlib.inc

define CLSCTX_INPROC	       (CLSCTX_INPROC_SERVER or CLSCTX_INPROC_HANDLER)
if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)
define CLSCTX_ALL	       (CLSCTX_INPROC_SERVER or CLSCTX_INPROC_HANDLER or CLSCTX_LOCAL_SERVER or CLSCTX_REMOTE_SERVER)
define CLSCTX_SERVER	       (CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER or CLSCTX_REMOTE_SERVER)
else
define CLSCTX_ALL	       (CLSCTX_INPROC_SERVER or CLSCTX_INPROC_HANDLER or CLSCTX_LOCAL_SERVER )
define CLSCTX_SERVER	       (CLSCTX_INPROC_SERVER or CLSCTX_LOCAL_SERVER)
endif

.enum REGCLS {
    REGCLS_SINGLEUSE = 0,
    REGCLS_MULTIPLEUSE = 1,
    REGCLS_MULTI_SEPARATE = 2,
    REGCLS_SUSPENDED	  = 4,
    REGCLS_SURROGATE	  = 8,
if (NTDDI_VERSION ge NTDDI_WINTHRESHOLD)
    REGCLS_AGILE = 0x10,
endif
}

.enum COINITBASE {
if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)
  COINITBASE_MULTITHREADED	= 0x0,
endif
}

include wtypesbase.inc
include unknwnbase.inc
include objidlbase.inc
include guiddef.inc
ifndef INITGUID
include cguid.inc
endif

endif

.pragma comment(lib, ole32)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetMalloc proto WINAPI :DWORD, :ptr
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

CreateStreamOnHGlobal proto WINAPI :HGLOBAL, :BOOL, :ptr
GetHGlobalFromStream proto WINAPI :LPSTREAM, :ptr
CoUninitialize proto WINAPI

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetCurrentProcess proto WINAPI
endif

if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoInitializeEx proto WINAPI :LPVOID, :DWORD
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetCallerTID proto WINAPI :LPDWORD
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoGetCurrentLogicalThreadId proto WINAPI :ptr
endif

endif

if (_WIN32_WINNT ge 0x0501)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoGetContextToken proto WINAPI :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetDefaultContext proto WINAPI :APTTYPE, :REFIID, :ptr ptr
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

if (NTDDI_VERSION ge NTDDI_WIN7)
CoGetApartmentType proto WINAPI :ptr, :ptr
endif

endif

if (NTDDI_VERSION ge NTDDI_WIN8)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)

tagServerInformation	struct
dwServerPid		DWORD ?
dwServerTid		DWORD ?
ui64ServerAddress	UINT64 ?
tagServerInformation	ends
ServerInformation	typedef tagServerInformation
PServerInformation	typedef ptr tagServerInformation

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoDecodeProxy proto WINAPI :DWORD, :UINT64, :PServerInformation
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

DECLARE_HANDLE(CO_MTA_USAGE_COOKIE)

CoIncrementMTAUsage proto WINAPI :ptr
CoDecrementMTAUsage proto WINAPI :CO_MTA_USAGE_COOKIE

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

CoAllowUnmarshalerCLSID proto WINAPI :REFCLSID

ifndef RC_INVOKED
ifdef _M_IX86
define _CRT_INTERNAL_COMBASE_SYMBOL_PREFIX <"_">
elseif defined(_M_X64) or defined(_M_ARM) or defined(_M_ARM64)
define _CRT_INTERNAL_COMBASE_SYMBOL_PREFIX <"">
endif

if defined(_EXE_INITIALIZE_MTA) and not defined(_M_CEE)
;.pragma comment(lib, "exe_initialize_mta")
;.pragma comment(linker, "/include:" _CRT_INTERNAL_COMBASE_SYMBOL_PREFIX "__PLEASE_LINK_WITH_exe_initialize_mta.lib")
endif
endif

endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoGetObjectContext proto WINAPI :REFIID, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoGetClassObject proto WINAPI :REFCLSID, :DWORD, :LPVOID, :REFIID, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoRegisterClassObject proto WINAPI :REFCLSID, :LPUNKNOWN, :DWORD, :DWORD, :LPDWORD
CoRevokeClassObject proto WINAPI :DWORD
CoResumeClassObjects proto WINAPI
CoSuspendClassObjects proto WINAPI
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoAddRefServerProcess proto WINAPI
CoReleaseServerProcess proto WINAPI
CoGetPSClsid proto WINAPI :REFIID, :ptr
CoRegisterPSClsid proto WINAPI :REFIID, :REFCLSID
CoRegisterSurrogate proto WINAPI :LPSURROGATE
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoGetMarshalSizeMax proto WINAPI :ptr, :REFIID, :LPUNKNOWN, :DWORD, :LPVOID, :DWORD
CoMarshalInterface proto WINAPI :LPSTREAM, :REFIID, :LPUNKNOWN, :DWORD, :LPVOID, :DWORD
CoUnmarshalInterface proto WINAPI :LPSTREAM, :REFIID, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoMarshalHresult proto WINAPI :LPSTREAM, :HRESULT
CoUnmarshalHresult proto WINAPI :LPSTREAM, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoReleaseMarshalData proto WINAPI :LPSTREAM
CoDisconnectObject proto WINAPI :LPUNKNOWN, :DWORD
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoLockObjectExternal proto WINAPI :LPUNKNOWN, :BOOL, :BOOL
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoGetStandardMarshal proto WINAPI :REFIID, :LPUNKNOWN, :DWORD, :LPVOID, :DWORD, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetStdMarshalEx proto WINAPI :LPUNKNOWN, :DWORD, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)

.enum STDMSHLFLAGS {
    SMEXF_SERVER     = 0x01,
    SMEXF_HANDLER    = 0x02
    }

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoIsHandlerConnected proto WINAPI :LPUNKNOWN
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoMarshalInterThreadInterfaceInStream proto WINAPI :REFIID, :LPUNKNOWN, :ptr
CoGetInterfaceAndReleaseStream proto WINAPI :LPSTREAM, :REFIID, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoCreateFreeThreadedMarshaler proto WINAPI :LPUNKNOWN, :ptr
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)
CoFreeUnusedLibraries proto WINAPI
if (_WIN32_WINNT ge 0x0501)
CoFreeUnusedLibrariesEx proto WINAPI :DWORD, :DWORD
endif

endif

if (_WIN32_WINNT ge 0x0600)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoDisconnectContext proto WINAPI :DWORD
endif

endif

if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
CoInitializeSecurity proto WINAPI :PSECURITY_DESCRIPTOR, :LONG, :ptr, :ptr, :DWORD, :DWORD, :ptr, :DWORD, :ptr
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetCallContext proto WINAPI :REFIID, :ptr ptr
CoQueryProxyBlanket proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr
CoSetProxyBlanket proto WINAPI :ptr, :DWORD, :DWORD, :ptr, :DWORD, :DWORD, :RPC_AUTH_IDENTITY_HANDLE, :DWORD
CoCopyProxy proto WINAPI :ptr, :ptr ptr
CoQueryClientBlanket proto WINAPI :ptr, :ptr, :ptr, :ptr, :ptr, :ptr, :ptr
CoImpersonateClient proto WINAPI
CoRevertToSelf proto WINAPI
CoQueryAuthenticationServices proto WINAPI :ptr, :ptr ptr
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)

CoSwitchCallContext proto WINAPI :ptr, :ptr ptr

define COM_RIGHTS_EXECUTE 1
define COM_RIGHTS_EXECUTE_LOCAL 2
define COM_RIGHTS_EXECUTE_REMOTE 4
define COM_RIGHTS_ACTIVATE_LOCAL 8
define COM_RIGHTS_ACTIVATE_REMOTE 16
define COM_RIGHTS_RESERVED1 32
define COM_RIGHTS_RESERVED2 64

endif

endif

if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES))
CoCreateInstance proto WINAPI :REFCLSID, :LPUNKNOWN, :DWORD, :REFIID, :ptr
endif

if (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM))

if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)
CoCreateInstanceEx proto WINAPI :REFCLSID, :ptr, :DWORD, :ptr, :DWORD, :ptr
endif

if (_WIN32_WINNT ge 0x0602)
CoCreateInstanceFromApp proto WINAPI :REFCLSID, :ptr, :DWORD, :PVOID, :DWORD, :ptr
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoRegisterActivationFilter proto WINAPI :ptr
endif

if (_WIN32_WINNT ge 0x0500) or defined(_WIN32_DCOM)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetCancelObject proto WINAPI :DWORD, :REFIID, :ptr ptr
CoSetCancelObject proto WINAPI :ptr
CoCancelCall proto WINAPI :DWORD, :ULONG
CoTestCancel proto WINAPI
CoEnableCallCancellation proto WINAPI :LPVOID
CoDisableCallCancellation proto WINAPI :LPVOID
endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
StringFromCLSID proto WINAPI :REFCLSID, :ptr
CLSIDFromString proto WINAPI :LPCOLESTR, :LPCLSID
StringFromIID proto WINAPI :REFIID, :ptr
IIDFromString proto WINAPI :LPCOLESTR, :LPIID
endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)
ProgIDFromCLSID proto WINAPI :REFCLSID, :ptr
CLSIDFromProgID proto WINAPI :LPCOLESTR, :LPCLSID
endif
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

StringFromGUID2 proto WINAPI :REFGUID, :LPOLESTR, :sdword
CoCreateGuid proto WINAPI :ptr

;PROPVARIANT typedef tagPROPVARIANT

PropVariantCopy proto WINAPI :ptr, :ptr
PropVariantClear proto WINAPI :ptr
FreePropVariantArray proto WINAPI :ULONG, :ptr

endif

if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
endif
endif

if (_WIN32_WINNT ge 0x0400) or defined(_WIN32_DCOM)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)

CoWaitForMultipleHandles proto WINAPI :DWORD, :DWORD, :ULONG, :LPHANDLE, :LPDWORD

.enum COWAIT_FLAGS {
  COWAIT_DEFAULT = 0,
  COWAIT_WAITALL = 1,
  COWAIT_ALERTABLE = 2,
  COWAIT_INPUTAVAILABLE = 4,
  COWAIT_DISPATCH_CALLS = 8,
  COWAIT_DISPATCH_WINDOW_MESSAGES = 0x10,
}

if (NTDDI_VERSION ge NTDDI_WIN8)

.enum CWMO_FLAGS {
  CWMO_DEFAULT = 0,
  CWMO_DISPATCH_CALLS = 1,
  CWMO_DISPATCH_WINDOW_MESSAGES = 2,
}

CoWaitForMultipleObjects proto WINAPI :DWORD, :DWORD, :ULONG, :ptr, :LPDWORD

endif

define CWMO_MAX_HANDLES 56

endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoGetTreatAsClass proto WINAPI :REFCLSID, :LPCLSID
endif

if (_WIN32_WINNT ge 0x0501)
if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)
CoInvalidateRemoteMachineBindings proto WINAPI :LPOLESTR
endif
endif

if (NTDDI_VERSION ge NTDDI_WINBLUE)

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM)

.enum AgileReferenceOptions {
    AGILEREFERENCE_DEFAULT	  = 0,
    AGILEREFERENCE_DELAYEDMARSHAL = 1,
    }

RoGetAgileReference proto WINAPI :AgileReferenceOptions, :REFIID, :ptr, :ptr ptr

endif

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP or WINAPI_PARTITION_SYSTEM or WINAPI_PARTITION_GAMES)

CALLBACK(LPFNGETCLASSOBJECT, :REFCLSID, :REFIID, :ptr)
CALLBACK(LPFNCANUNLOADNOW,)

DllGetClassObject proto WINAPI :REFCLSID, :REFIID, :ptr
DllCanUnloadNow proto WINAPI
CoTaskMemAlloc proto WINAPI :SIZE_T
CoTaskMemRealloc proto WINAPI :LPVOID, :SIZE_T
CoTaskMemFree proto WINAPI :LPVOID

endif

if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP or WINAPI_PARTITION_SYSTEM)

CoFileTimeNow proto WINAPI :ptr
CLSIDFromProgIDEx proto WINAPI :LPCOLESTR, :LPCLSID

if (NTDDI_VERSION ge NTDDI_WIN10_VB)

ifndef _CO_DEVICE_CATALOG_
define _CO_DEVICE_CATALOG_
endif

DECLARE_HANDLE(CO_DEVICE_CATALOG_COOKIE)

CoRegisterDeviceCatalog proto WINAPI :PCWSTR, :ptr
CoRevokeDeviceCatalog proto WINAPI :CO_DEVICE_CATALOG_COOKIE

endif

endif

ifndef RC_INVOKED
.pragma pack(pop)
endif

endif
endif
