' ########################################################################################
' Microsoft Windows
' File: p2p.inc
' Contents: Win32 APIs and structures for the Microsoft Peer To Peer infrastructure.
' 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_p2p_PBI)
#DEFINE PBX_p2p_PBI
%EQUATE `P2P_INC = 1
'//----------------------------------------------------------------------------
'//
'// If defined, the following flags inhibit definition of the indicated items.
'//
'// NO_P2P_GROUP - no Peer-to-Peer Grouping
'// NO_P2P_GRAPH - no Peer-to-Peer Graphing
'// NO_P2P_IDENTITY - no Peer-to-Peer Identity manager
'// NO_P2P_PNRP - no Peer-to-Peer Peer Name Resolution Protocol
'// NO_P2P_COLLABORATION - no Peer-to-Peer Collaboration Infrastructure
'//
'//----------------------------------------------------------------------------
'#include <specstrings.h>
'#include <winsock2.h>
'#include <pnrpns.h>
'#include <ws2tcpip.h> // for sockaddrin_6
#INCLUDE ONCE "Legacy/Platform/WinSock2.inc"
#INCLUDE ONCE "Legacy/System/pnrpns.inc"
#INCLUDE ONCE "Legacy/System/WS2tcpip.inc" ' // for sockaddrin_6
'#if NTDDI_VERSION < NTDDI_VISTA
'#ifndef NO_P2P_PNRP
'#define NO_P2P_PNRP //P2P PNRP is not available prior to NTDDI_VISTA
'#endif // NO_P2P_PNRP
'#ifndef NO_P2P_COLLABORATION
'#define NO_P2P_COLLABORATION //P2P COLLABORATION is not available prior to NTDDI_VISTA
'#endif // NO_P2P_COLLABORATION
'#endif // NTDDI_VERSION < NTDDI_VISTA
'//////////////////////////////////////////////////////////////////////////////
'// Constants
' enum PEER_RECORD_CHANGE_TYPE
%EQUATE `PEER_RECORD_ADDED = 1
%EQUATE `PEER_RECORD_UPDATED = 2
%EQUATE `PEER_RECORD_DELETED = 3
%EQUATE `PEER_RECORD_EXPIRED = 4
' enum PEER_CONNECTION_STATUS
%EQUATE `PEER_CONNECTED = 1
%EQUATE `PEER_DISCONNECTED = 2
%EQUATE `PEER_CONNECTION_FAILED = 3
' enum PEER_CONNECTION_FLAGS
%EQUATE `PEER_CONNECTION_NEIGHBOR = &H0001
%EQUATE `PEER_CONNECTION_DIRECT = &H0002
' enum PEER_RECORD_FLAGS
%EQUATE `PEER_RECORD_FLAG_AUTOREFRESH = &H0001
%EQUATE `PEER_RECORD_FLAG_DELETED = &H0002
'////////////////////////////////////////////////////////////////////////////////////
'// Types
'typedef
'void *HPEEREVENT;
'typedef HPEEREVENT * PHPEEREVENT;
'typedef
'void *HPEERENUM;
'typedef HPEERENUM * PHPEERENUM;
' // Size = 4 bytes
TYPE PEER_VERSION_DATA WORD
 wVersion AS WORD ' WORD
 wHighestVersion AS WORD ' WORD
END TYPE
' // Size = 8 bytes
TYPE PEER_DATA
 cbData AS DWORD ' ULONG
 pbData AS BYTE PTR
END TYPE
' // Size = 96 bytes
TYPE PEER_RECORD DWORD
 dwSize AS DWORD
 type AS GUID ' GUID
 id AS GUID ' GUID
 dwVersion AS DWORD
 dwFlags AS DWORD
 pwzCreatorId AS WSTRINGZ PTR
 pwzModifiedById AS WSTRINGZ PTR
 pwzAttributes AS WSTRINGZ PTR
 ftCreation AS FILETIME ' FILETIME
 ftExpiration AS FILETIME ' FILETIME
 ftLastModified AS FILETIME ' FILETIME
 securityData AS PEER_DATA ' PEER_DATA
 data AS PEER_DATA ' PEER_DATA
END TYPE
' // Size = 32 bytes
TYPE PEER_ADDRESS DWORD
 dwSize AS DWORD
 sin6 AS SOCKADDR_IN6 ' SOCKADDR_IN6
END TYPE
' // Size = 64 bytes
TYPE PEER_CONNECTION_INFO QWORD FILL ' Must be 8 byte aligned
 dwSize AS DWORD
 dwFlags AS DWORD
 ullConnectionId AS QUAD ' ULONGLONG
 ullNodeId AS QUAD ' ULONGLONG
 pwzPeerId AS WSTRINGZ PTR
 address AS PEER_ADDRESS ' PEER_ADDRESS
END TYPE
' // Size = 40 bytes
TYPE PEER_EVENT_INCOMING_DATA QWORD FILL ' Must be 8 byte aligned
 dwSize AS DWORD
 ullConnectionId AS QUAD ' ULONGLONG
 type AS GUID ' GUID
 data AS PEER_DATA ' PEER_DATA
END TYPE
' // Size = 40 bytes
TYPE PEER_EVENT_RECORD_CHANGE_DATA DWORD
 dwSize AS DWORD
 changeType AS LONG ' PEER_RECORD_CHANGE_TYPE enum
 recordId AS GUID ' GUID
 recordType AS GUID ' GUID
END TYPE
' // Size = 40 bytes
TYPE PEER_EVENT_CONNECTION_CHANGE_DATA ' Must be 8 byte aligned
 dwSize AS DWORD
 status AS LONG ' PEER_CONNECTION_STATUS
 ullConnectionId AS QUAD ' ULONGLONG
 ullNodeId AS QUAD ' ULONGLONG
'#if NTDDI_VERSION >= NTDDI_VISTA
#IF %WINVER >= &H0600
 ullNextConnectionId AS QUAD ' ULONGLONG
 hrConnectionFailedReason AS LONG
 alignment__ AS DWORD ' // To keep 8 byte alignment
#ENDIF
'#endif
END TYPE
' // Size = 20 bytes
TYPE PEER_EVENT_SYNCHRONIZED_DATA DWORD
 dwSize AS DWORD
 recordType AS GUID ' GUID
END TYPE
'#ifndef NO_P2P_GRAPH
'/////////////////////////////////////////////////////////////////////////////
'//
'// G R A P H I N G
'//
'/////////////////////////////////////////////////////////////////////////////
'typedef PVOID HGRAPH, *PHGRAPH;
'/////////////////////////////////////////////////////////////////////////////
'// Constants
'#define PEER_GRAPH_VERSION MAKEWORD(1,0)
%EQUATE `PEER_GRAPH_VERSION = 1
' enum PEER_GRAPH_EVENT_TYPE
%EQUATE `PEER_GRAPH_EVENT_STATUS_CHANGED = 1
%EQUATE `PEER_GRAPH_EVENT_PROPERTY_CHANGED = 2
%EQUATE `PEER_GRAPH_EVENT_RECORD_CHANGED = 3
%EQUATE `PEER_GRAPH_EVENT_DIRECT_CONNECTION = 4
%EQUATE `PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION = 5
%EQUATE `PEER_GRAPH_EVENT_INCOMING_DATA = 6
%EQUATE `PEER_GRAPH_EVENT_CONNECTION_REQUIRED = 7
%EQUATE `PEER_GRAPH_EVENT_NODE_CHANGED = 8
%EQUATE `PEER_GRAPH_EVENT_SYNCHRONIZED = 9
' enum PEER_NODE_CHANGE_TYPE
%EQUATE `PEER_NODE_CHANGE_CONNECTED = 1
%EQUATE `PEER_NODE_CHANGE_DISCONNECTED = 2
%EQUATE `PEER_NODE_CHANGE_UPDATED = 3
' enum PEER_GRAPH_STATUS_FLAGS
%EQUATE `PEER_GRAPH_STATUS_LISTENING = &H0001
%EQUATE `PEER_GRAPH_STATUS_HAS_CONNECTIONS = &H0002
%EQUATE `PEER_GRAPH_STATUS_SYNCHRONIZED = &H0004
' enum PEER_GRAPH_PROPERTY_FLAGS
%EQUATE `PEER_GRAPH_PROPERTY_HEARTBEATS = &H0001
%EQUATE `PEER_GRAPH_PROPERTY_DEFER_EXPIRATION = &H0002
' enum PEER_GRAPH_SCOPE
%EQUATE `PEER_GRAPH_SCOPE_ANY = 0
%EQUATE `PEER_GRAPH_SCOPE_GLOBAL = 1
%EQUATE `PEER_GRAPH_SCOPE_SITELOCAL = 2
%EQUATE `PEER_GRAPH_SCOPE_LINKLOCAL = 3
%EQUATE `PEER_GRAPH_SCOPE_LOOPBACK = 4
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 40 bytes
TYPE PEER_GRAPH_PROPERTIES DWORD
 dwSize AS DWORD
 dwFlags AS DWORD ' DWORD // %PEER_GRAPH_PROPERTY_FLAGS
 dwScope AS DWORD
 dwMaxRecordSize AS DWORD
 pwzGraphId AS WSTRINGZ PTR
 pwzCreatorId AS WSTRINGZ PTR
 pwzFriendlyName AS WSTRINGZ PTR
 pwzComment AS WSTRINGZ PTR
 ulPresenceLifetime AS DWORD ' ULONG
 cPresenceMax AS DWORD ' ULONG
END TYPE
' // Size = 32 bytes
TYPE PEER_NODE_INFO QWORD FILL ' Must be 8 byte aligned
 dwSize AS DWORD
 ullNodeId AS QUAD ' ULONGLONG
 pwzPeerId AS WSTRINGZ PTR
 cAddresses AS DWORD ' ULONG
 pAddresses AS PEER_ADDRESS PTR ' PEER_ADDRESS
 pwzAttributes AS WSTRINGZ PTR
END TYPE
' // Size = 24 bytes
TYPE PEER_EVENT_NODE_CHANGE_DATA ' Must be 8 byte aligned
 dwSize AS DWORD
 changeType AS LONG ' PEER_NODE_CHANGE_TYPE
 ullNodeId AS QUAD ' ULONGLONG
 pwzPeerId AS WSTRINGZ PTR
 alignment__ AS DWORD ' // To keep 8 byte alignment
END TYPE
' // Size = 8 bytes
TYPE PEER_GRAPH_EVENT_REGISTRATION DWORD
 eventType AS LONG ' PEER_GRAPH_EVENT_TYPE
 pType AS GUID PTR ' GUID*
END TYPE
' // Size = 40 bytes
UNION PEER_GRAPH_EVENT_DATA_UNION QWORD FILL ' Must be 8 byte aligned
 dwStatus AS DWORD ' PEER_GRAPH_STATUS_FLAGS
 incomingData AS PEER_EVENT_INCOMING_DATA ' PEER_EVENT_INCOMING_DATA
 recordChangeData AS PEER_EVENT_RECORD_CHANGE_DATA ' PEER_EVENT_RECORD_CHANGE_DATA
 connectionChangeData AS PEER_EVENT_CONNECTION_CHANGE_DATA ' PEER_EVENT_CONNECTION_CHANGE_DATA
 nodeChangeData AS PEER_EVENT_NODE_CHANGE_DATA ' PEER_EVENT_NODE_CHANGE_DATA
 synchronizedData AS PEER_EVENT_SYNCHRONIZED_DATA ' PEER_EVENT_SYNCHRONIZED_DATA
END UNION
' // Size = 48 bytes
TYPE PEER_GRAPH_EVENT_DATA QWORD FILL ' Must be 8 byte aligned
 eventType AS LONG ' PEER_GRAPH_EVENT_TYPE
 PEER_GRAPH_EVENT_DATA_UNION
END TYPE
'typedef HRESULT (CALLBACK * PFNPEER_VALIDATE_RECORD)(
'FUNCTION PEER_VALIDATE_RECORD ( ' BYVAL hGraph AS DWORD
' , BYVAL pvContext AS DWORD
' , BYREF pRecord AS PEER_RECORD
' , BYVAL changeType AS LONG
' ) AS LONG
'typedef HRESULT (CALLBACK * PFNPEER_SECURE_RECORD)(
'FUNCTION PEER_SECURE_RECORD ( ' BYVAL hGraph AS DWORD
' , BYVAL pvContext AS DWORD
' , BYREF pRecord AS PEER_RECORD
' , BYVAL changeType AS LONG
' , BYREF ppSecurityData AS PEER_DATA
' ) AS LONG
'typedef HRESULT (CALLBACK * PFNPEER_FREE_SECURITY_DATA)(
'FUNCTION PEER_FREE_SECURITY_DATA ( ' BYVAL hGraph AS DWORD
' , BYVAL pvContext AS DWORD
' , BYREF pSecurityData AS PEER_DATA
' ) AS LONG
'typedef HRESULT (CALLBACK * PFNPEER_ON_PASSWORD_AUTH_FAILED)(
'FUNCTION PEER_ON_PASSWORD_AUTH_FAILED ( ' BYVAL hGraph AS DWORD
' , BYVAL pvContext AS DWORD
' ) AS LONG
' // Size = 40 bytes
TYPE PEER_SECURITY_INTERFACE DWORD
 dwSize AS DWORD
 pwzSspFilename AS WSTRINGZ PTR
 pwzPackageName AS WSTRINGZ PTR
 cbSecurityInfo AS DWORD ' ULONG
 pbSecurityInfo AS BYTE PTR
 pvContext AS DWORD
 pfnValidateRecord AS DWORD ' PFNPEER_VALIDATE_RECORD
 pfnSecureRecord AS DWORD ' PFNPEER_SECURE_RECORD
 pfnFreeSecurityData AS DWORD ' PFNPEER_FREE_SECURITY_DATA
 pfnAuthFailed AS DWORD ' PFNPEER_ON_PASSWORD_AUTH_FAILED
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// API Definitions
DECLARE FUNCTION PeerGraphStartup LIB "p2pgraph.dll" ALIAS "PeerGraphStartup" ( BYVAL wVersionRequested AS WORD , BYREF pVersionData AS PEER_VERSION_DATA ) AS LONG
DECLARE FUNCTION PeerGraphShutdown LIB "p2pgraph.dll" ALIAS "PeerGraphShutdown" ( ) AS LONG
DECLARE SUB PeerGraphFreeData LIB "p2pgraph.dll" ALIAS "PeerGraphFreeData" ( BYVAL pvData AS QUAD
 )
DECLARE FUNCTION PeerGraphGetItemCount LIB "p2pgraph.dll" ALIAS "PeerGraphGetItemCount" ( BYVAL hPeerEnum AS DWORD
 , BYREF pCount AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphGetNextItem LIB "p2pgraph.dll" ALIAS "PeerGraphGetNextItem" ( BYVAL hPeerEnum AS DWORD
 , BYREF pCount AS DWORD
 , BYREF pppvItems AS ANY
 ) AS LONG
DECLARE FUNCTION PeerGraphEndEnumeration LIB "p2pgraph.dll" ALIAS "PeerGraphEndEnumeration" ( BYVAL hPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphCreate LIB "p2pgraph.dll" ALIAS "PeerGraphCreate" ( BYREF pGraphProperties AS PEER_GRAPH_PROPERTIES
 , BYREF pwzDatabaseName AS WSTRINGZ
 , BYREF pSecurityInterface AS PEER_SECURITY_INTERFACE
 , BYREF phGraph AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphOpen LIB "p2pgraph.dll" ALIAS "PeerGraphOpen" ( BYREF pwzGraphId AS WSTRINGZ
 , BYREF pwzPeerId AS WSTRINGZ
 , BYREF pwzDatabaseName AS WSTRINGZ
 , BYREF pSecurityInterface AS PEER_SECURITY_INTERFACE
 , BYVAL cRecordTypeSyncPrecedence AS DWORD
 , BYREF pRecordTypeSyncPrecedence AS GUID
 , BYREF phGraph AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphListen LIB "p2pgraph.dll" ALIAS "PeerGraphListen" ( BYVAL hGraph AS DWORD
 , OPTIONAL BYVAL dwScope AS DWORD
 , OPTIONAL BYVAL dwScopeId AS DWORD
 , OPTIONAL BYVAL wPort AS WORD
 ) AS LONG
DECLARE FUNCTION PeerGraphConnect LIB "p2pgraph.dll" ALIAS "PeerGraphConnect" ( BYVAL hGraph AS DWORD
 , BYREF pwzPeerId AS WSTRINGZ
 , BYREF pAddress AS PEER_ADDRESS
 , BYREF pullConnectionId AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGraphClose LIB "p2pgraph.dll" ALIAS "PeerGraphClose" ( BYVAL hGraph AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphDelete LIB "p2pgraph.dll" ALIAS "PeerGraphDelete" ( BYREF pwzGraphId AS WSTRINGZ
 , BYREF pwzPeerId AS WSTRINGZ
 , BYREF pwzDatabaseName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGraphGetStatus LIB "p2pgraph.dll" ALIAS "PeerGraphGetStatus" ( BYVAL hGraph AS DWORD
 , BYREF pdwStatus AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphGetProperties LIB "p2pgraph.dll" ALIAS "PeerGraphGetProperties" ( BYVAL hGraph AS DWORD
 , BYREF ppGraphProperties AS PEER_GRAPH_PROPERTIES
 ) AS LONG
DECLARE FUNCTION PeerGraphSetProperties LIB "p2pgraph.dll" ALIAS "PeerGraphSetProperties" ( BYVAL hGraph AS DWORD
 , BYREF pGraphProperties AS PEER_GRAPH_PROPERTIES
 ) AS LONG
'// Eventing interfaces
DECLARE FUNCTION PeerGraphRegisterEvent LIB "p2pgraph.dll" ALIAS "PeerGraphRegisterEvent" ( BYVAL hGraph AS QUAD , BYVAL hEvent AS QUAD , BYVAL cEventRegistrations AS QUAD , BYREF pEventRegistrations AS PEER_GRAPH_EVENT_REGISTRATION , BYREF phPeerEvent AS QUAD ) AS LONG
DECLARE FUNCTION PeerGraphUnregisterEvent LIB "p2pgraph.dll" ALIAS "PeerGraphUnregisterEvent" ( BYVAL hPeerEvent AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGraphGetEventData LIB "p2pgraph.dll" ALIAS "PeerGraphGetEventData" ( BYVAL hPeerEvent AS DWORD
 , BYREF ppEventData AS PEER_GRAPH_EVENT_DATA
 ) AS LONG
'// Data Storage
DECLARE FUNCTION PeerGraphGetRecord LIB "p2pgraph.dll" ALIAS "PeerGraphGetRecord" ( BYVAL hGraph AS QUAD , BYREF pRecordId AS GUID , BYREF ppRecord AS PEER_RECORD ) AS LONG
DECLARE FUNCTION PeerGraphAddRecord LIB "p2pgraph.dll" ALIAS "PeerGraphAddRecord" ( BYVAL hGraph AS QUAD
 , BYREF pRecord AS PEER_RECORD
 , BYREF pRecordId AS GUID
 ) AS LONG
DECLARE FUNCTION PeerGraphUpdateRecord LIB "p2pgraph.dll" ALIAS "PeerGraphUpdateRecord" ( BYVAL hGraph AS DWORD
 , BYREF pRecord AS PEER_RECORD
 ) AS LONG
DECLARE FUNCTION PeerGraphDeleteRecord LIB "p2pgraph.dll" ALIAS "PeerGraphDeleteRecord" ( BYVAL hGraph AS DWORD
 , BYREF pRecordId AS GUID
 , BYVAL fLocal AS LONG
 ) AS LONG
DECLARE FUNCTION PeerGraphEnumRecords LIB "p2pgraph.dll" ALIAS "PeerGraphEnumRecords" ( BYVAL hGraph AS DWORD
 , BYREF pRecordType AS GUID
 , BYREF pwzPeerId AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphSearchRecords LIB "p2pgraph.dll" ALIAS "PeerGraphSearchRecords" ( BYVAL hGraph AS DWORD
 , BYREF pwzCriteria AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphExportDatabase LIB "p2pgraph.dll" ALIAS "PeerGraphExportDatabase" ( BYVAL hGraph AS DWORD
 , BYREF pwzFilePath AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGraphImportDatabase LIB "p2pgraph.dll" ALIAS "PeerGraphImportDatabase" ( BYVAL hGraph AS DWORD
 , BYREF pwzFilePath AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGraphValidateDeferredRecords LIB "p2pgraph.dll" ALIAS "PeerGraphValidateDeferredRecords" ( BYVAL hGraph AS DWORD
 , BYVAL cRecordIds AS DWORD
 , BYREF pRecordIds AS GUID
 ) AS LONG
'// Node/Connection interfaces
DECLARE FUNCTION PeerGraphOpenDirectConnection LIB "p2pgraph.dll" ALIAS "PeerGraphOpenDirectConnection" ( BYVAL hGraph AS QUAD , BYREF pwzPeerId AS WSTRINGZ , BYREF pAddress AS PEER_ADDRESS , BYREF pullConnectionId AS QUAD ) AS LONG
DECLARE FUNCTION PeerGraphSendData LIB "p2pgraph.dll" ALIAS "PeerGraphSendData" ( BYVAL hGraph AS QUAD
 , BYVAL ullConnectionId AS QUAD
 , BYREF pType AS GUID
 , BYVAL cbData AS DWORD
 , BYREF pvData AS ANY
 ) AS LONG
DECLARE FUNCTION PeerGraphCloseDirectConnection LIB "p2pgraph.dll" ALIAS "PeerGraphCloseDirectConnection" ( BYVAL hGraph AS DWORD
 , BYVAL ullConnectionId AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGraphEnumConnections LIB "p2pgraph.dll" ALIAS "PeerGraphEnumConnections" ( BYVAL hGraph AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphEnumNodes LIB "p2pgraph.dll" ALIAS "PeerGraphEnumNodes" ( BYVAL hGraph AS DWORD
 , BYREF pwzPeerId AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGraphSetPresence LIB "p2pgraph.dll" ALIAS "PeerGraphSetPresence" ( BYVAL hGraph AS DWORD
 , BYVAL fPresent AS LONG
 ) AS LONG
DECLARE FUNCTION PeerGraphGetNodeInfo LIB "p2pgraph.dll" ALIAS "PeerGraphGetNodeInfo" ( BYVAL hGraph AS DWORD
 , BYVAL ullNodeId AS QUAD
 , BYREF ppNodeInfo AS PEER_NODE_INFO
 ) AS LONG
DECLARE FUNCTION PeerGraphSetNodeAttributes LIB "p2pgraph.dll" ALIAS "PeerGraphSetNodeAttributes" ( BYVAL hGraph AS DWORD
 , BYREF pwzAttributes AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGraphPeerTimeToUniversalTime LIB "p2pgraph.dll" ALIAS "PeerGraphPeerTimeToUniversalTime" ( BYVAL hGraph AS DWORD
 , BYREF pftPeerTime AS FILETIME
 , BYREF pftUniversalTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION PeerGraphUniversalTimeToPeerTime LIB "p2pgraph.dll" ALIAS "PeerGraphUniversalTimeToPeerTime" ( BYVAL hGraph AS DWORD
 , BYREF pftUniversalTime AS FILETIME
 , BYREF pftPeerTime AS FILETIME
 ) AS LONG
'#endif // NO_P2P_GRAPH
'#if (!(defined (NO_P2P_GROUP)) || (!defined (NO_P2P_IDENTITY)))
'//////////////////////////////////////////////////////////////////////////////
'//
'// Common APIs used by Grouping and the Identity Manager
'//
'//////////////////////////////////////////////////////////////////////////////
#INCLUDE ONCE "Legacy/Platform/WinCrypt.inc"
DECLARE SUB PeerFreeData LIB "p2pgraph.dll" ALIAS "PeerFreeData" ( BYVAL pvData AS QUAD )
DECLARE FUNCTION PeerGetItemCount LIB "p2pgraph.dll" ALIAS "PeerGetItemCount" ( BYVAL hPeerEnum AS QUAD , BYREF pCount AS QUAD ) AS LONG
DECLARE FUNCTION PeerGetNextItem LIB "p2pgraph.dll" ALIAS "PeerGetNextItem" ( BYVAL hPeerEnum AS QUAD
 , BYREF pCount AS DWORD
 , BYREF pppvItems AS ANY
 ) AS LONG
DECLARE FUNCTION PeerEndEnumeration LIB "p2pgraph.dll" ALIAS "PeerEndEnumeration" ( BYVAL hPeerEnum AS DWORD
 ) AS LONG
'#endif
'#ifndef NO_P2P_GROUP
'/////////////////////////////////////////////////////////////////////////////
'//
'// G R O U P I N G
'//
'/////////////////////////////////////////////////////////////////////////////
'typedef PVOID HGROUP, *PHGROUP;
'typedef GUID PEER_ROLE_ID;
'/////////////////////////////////////////////////////////////////////////////
'// Constants
'#if NTDDI_VERSION >= NTDDI_VISTA
' #define PEER_GROUP_VERSION MAKEWORD(1,1)
'#else
' #define PEER_GROUP_VERSION MAKEWORD(1,0)
'#endif
#IF %WINVER >= &H0600
 %PEER_GROUP_VERSION = &H101
#ELSE
 %PEER_GROUP_VERSION = 1
#ENDIF
' enum PEER_GROUP_EVENT_TYPE
%EQUATE `PEER_GROUP_EVENT_STATUS_CHANGED = 1
%EQUATE `PEER_GROUP_EVENT_PROPERTY_CHANGED = 2
%EQUATE `PEER_GROUP_EVENT_RECORD_CHANGED = 3
%EQUATE `PEER_GROUP_EVENT_DIRECT_CONNECTION = 4
%EQUATE `PEER_GROUP_EVENT_NEIGHBOR_CONNECTION = 5
%EQUATE `PEER_GROUP_EVENT_INCOMING_DATA = 6
%EQUATE `PEER_GROUP_EVENT_MEMBER_CHANGED = 8
%EQUATE `PEER_GROUP_EVENT_CONNECTION_FAILED = 10
%EQUATE `PEER_GROUP_EVENT_AUTHENTICATION_FAILED = 11
' enum PEER_GROUP_STATUS
%EQUATE `PEER_GROUP_STATUS_LISTENING = &H0001
%EQUATE `PEER_GROUP_STATUS_HAS_CONNECTIONS = &H0002
' enum PEER_GROUP_PROPERTY_FLAGS
%EQUATE `PEER_MEMBER_DATA_OPTIONAL = &H0001
%EQUATE `PEER_DISABLE_PRESENCE = &H0002
%EQUATE `PEER_DEFER_EXPIRATION = &H0004
'#if NTDDI_VERSION >= NTDDI_VISTA
' enum PEER_GROUP_AUTHENTICATION_SCHEME
%EQUATE `PEER_GROUP_GMC_AUTHENTICATION = &H00000001
%EQUATE `PEER_GROUP_PASSWORD_AUTHENTICATION = &H00000002
'#endif
' enum PEER_MEMBER_FLAGS
%EQUATE `PEER_MEMBER_PRESENT = &H0001
' enum PEER_MEMBER_CHANGE_TYPE
%EQUATE `PEER_MEMBER_CONNECTED = 1
%EQUATE `PEER_MEMBER_DISCONNECTED = 2
%EQUATE `PEER_MEMBER_UPDATED = 3
%EQUATE `PEER_MEMBER_JOINED = 4
%EQUATE `PEER_MEMBER_LEFT = 5
' enum PEER_GROUP_ISSUE_CREDENTIAL_FLAGS
%EQUATE `PEER_GROUP_STORE_CREDENTIALS = &H0001
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 48 bytes
TYPE PEER_CREDENTIAL_INFO DWORD
 dwSize AS DWORD
 dwFlags AS DWORD
 pwzFriendlyName AS WSTRINGZ PTR
 pPublicKey AS CERT_PUBLIC_KEY_INFO PTR ' CERT_PUBLIC_KEY_INFO *
 pwzIssuerPeerName AS WSTRINGZ PTR
 pwzIssuerFriendlyName AS WSTRINGZ PTR
 ftValidityStart AS FILETIME ' FILETIME
 ftValidityEnd AS FILETIME ' FILETIME
 cRoles AS DWORD ' ULONG
 pRoles AS GUID PTR
END TYPE
' // Size = 40 bytes
TYPE PEER_MEMBER ' Must be 8 byte aligned
 dwSize AS DWORD
 dwFlags AS DWORD ' DWORD // PEER_MEMBER_FLAGS
 pwzIdentity AS WSTRINGZ PTR
 pwzAttributes AS WSTRINGZ PTR
 ullNodeId AS QUAD ' ULONGLONG
 cAddresses AS DWORD ' ULONG
 pAddresses AS PEER_ADDRESS PTR
 pCredentialInfo AS PEER_CREDENTIAL_INFO PTR ' PEER_CREDENTIAL_INFO *
 alignment__ AS DWORD ' // To keep 8 byte alignment
END TYPE
' // Size = 84 bytes
TYPE PEER_INVITATION_INFO DWORD
 dwSize AS DWORD
 dwFlags AS DWORD
 pwzCloudName AS WSTRINGZ PTR
 dwScope AS DWORD
 dwCloudFlags AS DWORD
 pwzGroupPeerName AS WSTRINGZ PTR
 pwzIssuerPeerName AS WSTRINGZ PTR
 pwzSubjectPeerName AS WSTRINGZ PTR
 pwzGroupFriendlyName AS WSTRINGZ PTR
 pwzIssuerFriendlyName AS WSTRINGZ PTR
 pwzSubjectFriendlyName AS WSTRINGZ PTR
 ftValidityStart AS FILETIME ' FILETIME
 ftValidityEnd AS FILETIME ' FILETIME
 cRoles AS DWORD ' ULONG
 pRoles AS GUID PTR ' PEER_ROLE_ID *
 cClassifiers AS DWORD ' ULONG
 ppwzClassifiers AS WSTRINGZ PTR ' PWSTR*
 pSubjectPublicKey AS CERT_PUBLIC_KEY_INFO PTR ' CERT_PUBLIC_KEY_INFO *
'#if NTDDI_VERSION >= NTDDI_VISTA
#IF %WINVER >= &H0600
 authScheme AS DWORD ' PEER_GROUP_AUTHENTICATION_SCHEME
#ENDIF
'#endif
END TYPE
'//start
' // Size = 64 bytes
TYPE PEER_GROUP_PROPERTIES DWORD
 dwSize AS DWORD
 dwFlags AS DWORD ' DWORD // PEER_GROUP_PROPERTY_FLAGS
 pwzCloud AS WSTRINGZ PTR
 pwzClassifier AS WSTRINGZ PTR
 pwzGroupPeerName AS WSTRINGZ PTR
 pwzCreatorPeerName AS WSTRINGZ PTR
 pwzFriendlyName AS WSTRINGZ PTR
 pwzComment AS WSTRINGZ PTR
 ulMemberDataLifetime AS DWORD ' ULONG
 ulPresenceLifetime AS DWORD ' ULONG
'#if NTDDI_VERSION >= NTDDI_VISTA
#IF %WINVER >= %WINVER
 dwAuthenticationSchemes AS DWORD ' DWORD // PEER_GROUP_AUTHENTICATION_SCHEME
 ' // group password authentication data
 pwzGroupPassword AS WSTRINGZ PTR
 groupPasswordRole AS GUID ' PEER_ROLE_ID
#ENDIF
'#endif
END TYPE
' // Size = 12 bytes
TYPE PEER_EVENT_MEMBER_CHANGE_DATA DWORD
 dwSize AS DWORD
 changeType AS LONG ' PEER_MEMBER_CHANGE_TYPE
 pwzIdentity AS WSTRINGZ PTR
END TYPE
' // Size = 8 bytes
TYPE PEER_GROUP_EVENT_REGISTRATION DWORD
 eventType AS LONG ' PEER_GROUP_EVENT_TYPE
 pType AS GUID PTR ' GUID *
END TYPE
' // Size = 40 bytes
UNION PEER_GROUP_EVENT_DATA_UNION QWORD FILL ' Must be 8 byte aligned
 dwStatus AS DWORD ' PEER_GROUP_STATUS
 incomingData AS PEER_EVENT_INCOMING_DATA ' PEER_EVENT_INCOMING_DATA
 recordChangeData AS PEER_EVENT_RECORD_CHANGE_DATA ' PEER_EVENT_RECORD_CHANGE_DATA
 connectionChangeData AS PEER_EVENT_CONNECTION_CHANGE_DATA ' PEER_EVENT_CONNECTION_CHANGE_DATA
 memberChangeData AS PEER_EVENT_MEMBER_CHANGE_DATA ' PEER_EVENT_MEMBER_CHANGE_DATA
 hrConnectionFailedReason AS LONG
END UNION
' // Size = 48 bytes
TYPE PEER_GROUP_EVENT_DATA QWORD FILL ' Must be 8 byte aligned
 eventType AS LONG ' PEER_GROUP_EVENT_TYPE
 PEER_GROUP_EVENT_DATA_UNION
END TYPE
'//end
' // Size = 12 bytes
TYPE PEER_NAME_PAIR DWORD
 dwSize AS DWORD
 pwzPeerName AS WSTRINGZ PTR
 pwzFriendlyName AS WSTRINGZ PTR
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// API Definitions
DECLARE FUNCTION PeerGroupStartup LIB "p2pgraph.dll" ALIAS "PeerGroupStartup" ( BYVAL wVersionRequested AS WORD , BYREF pVersionData AS PEER_VERSION_DATA ) AS LONG
DECLARE FUNCTION PeerGroupShutdown LIB "p2pgraph.dll" ALIAS "PeerGroupShutdown" ( ) AS LONG
DECLARE FUNCTION PeerGroupCreate LIB "p2pgraph.dll" ALIAS "PeerGroupCreate" ( BYREF pProperties AS PEER_GROUP_PROPERTIES
 , BYREF phGroup AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupOpen LIB "p2pgraph.dll" ALIAS "PeerGroupOpen" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF pwzGroupPeerName AS WSTRINGZ
 , BYREF pwzCloud AS WSTRINGZ
 , BYREF phGroup AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupJoin LIB "p2pgraph.dll" ALIAS "PeerGroupJoin" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF pwzInvitation AS WSTRINGZ
 , BYREF pwzCloud AS WSTRINGZ
 , BYREF phGroup AS DWORD
 ) AS LONG
'#if NTDDI_VERSION >= NTDDI_VISTA
DECLARE FUNCTION PeerGroupPasswordJoin LIB "p2pgraph.dll" ALIAS "PeerGroupPasswordJoin" ( BYREF pwzIdentity AS WSTRINGZ , BYREF pwzInvitation AS WSTRINGZ , BYREF pwzPassword AS WSTRINGZ , BYREF pwzCloud AS WSTRINGZ , BYREF phGroup AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION PeerGroupConnect LIB "p2pgraph.dll" ALIAS "PeerGroupConnect" ( BYVAL hGroup AS QUAD ) AS LONG
'#if NTDDI_VERSION >= NTDDI_VISTA
DECLARE FUNCTION PeerGroupConnectByAddress LIB "p2pgraph.dll" ALIAS "PeerGroupConnectByAddress" ( BYVAL hGroup AS QUAD , BYVAL cAddresses AS QUAD , BYREF pAddresses AS PEER_ADDRESS ) AS LONG
'#endif
DECLARE FUNCTION PeerGroupClose LIB "p2pgraph.dll" ALIAS "PeerGroupClose" ( BYVAL hGroup AS QUAD ) AS LONG
DECLARE FUNCTION PeerGroupDelete LIB "p2pgraph.dll" ALIAS "PeerGroupDelete" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF pwzGroupPeerName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGroupCreateInvitation LIB "p2pgraph.dll" ALIAS "PeerGroupCreateInvitation" ( BYVAL hGroup AS DWORD
 , BYREF pwzIdentityInfo AS WSTRINGZ
 , BYREF pftExpiration AS FILETIME
 , BYVAL cRoles AS DWORD
 , BYREF pRoles AS GUID
 , BYREF ppwzInvitation AS DWORD
 ) AS LONG
'#if NTDDI_VERSION >= NTDDI_VISTA
DECLARE FUNCTION PeerGroupCreatePasswordInvitation LIB "p2pgraph.dll" ALIAS "PeerGroupCreatePasswordInvitation" ( BYVAL hGroup AS QUAD , BYREF ppwzInvitation AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION PeerGroupParseInvitation LIB "p2pgraph.dll" ALIAS "PeerGroupParseInvitation" ( BYREF pwzInvitation AS WSTRINGZ , BYREF ppInvitationInfo AS PEER_INVITATION_INFO ) AS LONG
DECLARE FUNCTION PeerGroupGetStatus LIB "p2pgraph.dll" ALIAS "PeerGroupGetStatus" ( BYVAL hGroup AS QUAD
 , BYREF pdwStatus AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupGetProperties LIB "p2pgraph.dll" ALIAS "PeerGroupGetProperties" ( BYVAL hGroup AS DWORD
 , BYREF ppProperties AS PEER_GROUP_PROPERTIES
 ) AS LONG
DECLARE FUNCTION PeerGroupSetProperties LIB "p2pgraph.dll" ALIAS "PeerGroupSetProperties" ( BYVAL hGroup AS DWORD
 , BYREF pProperties AS PEER_GROUP_PROPERTIES
 ) AS LONG
DECLARE FUNCTION PeerGroupEnumMembers LIB "p2pgraph.dll" ALIAS "PeerGroupEnumMembers" ( BYVAL hGroup AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF pwzIdentity AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupOpenDirectConnection LIB "p2pgraph.dll" ALIAS "PeerGroupOpenDirectConnection" ( BYVAL hGroup AS DWORD
 , BYREF pwzIdentity AS WSTRINGZ
 , BYREF pAddress AS PEER_ADDRESS
 , BYREF pullConnectionId AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGroupCloseDirectConnection LIB "p2pgraph.dll" ALIAS "PeerGroupCloseDirectConnection" ( BYVAL hGroup AS DWORD
 , BYVAL ullConnectionId AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGroupEnumConnections LIB "p2pgraph.dll" ALIAS "PeerGroupEnumConnections" ( BYVAL hGroup AS DWORD
 , BYVAL dwFlags AS DWORD
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupSendData LIB "p2pgraph.dll" ALIAS "PeerGroupSendData" ( BYVAL hGroup AS DWORD
 , BYVAL ullConnectionId AS QUAD
 , BYREF pType AS GUID
 , BYVAL cbData AS DWORD
 , BYREF pvData AS ANY
 ) AS LONG
'// Eventing interfaces
DECLARE FUNCTION PeerGroupRegisterEvent LIB "p2pgraph.dll" ALIAS "PeerGroupRegisterEvent" ( BYVAL hGroup AS QUAD , BYVAL hEvent AS QUAD , BYVAL cEventRegistration AS QUAD , BYREF pEventRegistrations AS PEER_GROUP_EVENT_REGISTRATION , BYREF phPeerEvent AS QUAD ) AS LONG
DECLARE FUNCTION PeerGroupUnregisterEvent LIB "p2pgraph.dll" ALIAS "PeerGroupUnregisterEvent" ( BYVAL hPeerEvent AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerGroupGetEventData LIB "p2pgraph.dll" ALIAS "PeerGroupGetEventData" ( BYVAL hPeerEvent AS DWORD
 , BYREF ppEventData AS PEER_GROUP_EVENT_DATA
 ) AS LONG
'// Data Storage
DECLARE FUNCTION PeerGroupGetRecord LIB "p2pgraph.dll" ALIAS "PeerGroupGetRecord" ( BYVAL hGroup AS QUAD , BYREF pRecordId AS GUID , BYREF ppRecord AS PEER_RECORD ) AS LONG
DECLARE FUNCTION PeerGroupAddRecord LIB "p2pgraph.dll" ALIAS "PeerGroupAddRecord" ( BYVAL hGroup AS QUAD
 , BYREF pRecord AS PEER_RECORD
 , BYREF pRecordId AS GUID
 ) AS LONG
DECLARE FUNCTION PeerGroupUpdateRecord LIB "p2pgraph.dll" ALIAS "PeerGroupUpdateRecord" ( BYVAL hGroup AS DWORD
 , BYREF pRecord AS PEER_RECORD
 ) AS LONG
DECLARE FUNCTION PeerGroupDeleteRecord LIB "p2pgraph.dll" ALIAS "PeerGroupDeleteRecord" ( BYVAL hGroup AS DWORD
 , BYREF pRecordId AS GUID
 ) AS LONG
DECLARE FUNCTION PeerGroupEnumRecords LIB "p2pgraph.dll" ALIAS "PeerGroupEnumRecords" ( BYVAL hGroup AS DWORD
 , BYREF pRecordType AS GUID
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupSearchRecords LIB "p2pgraph.dll" ALIAS "PeerGroupSearchRecords" ( BYVAL hGroup AS DWORD
 , BYREF pwzCriteria AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupExportDatabase LIB "p2pgraph.dll" ALIAS "PeerGroupExportDatabase" ( BYVAL hGroup AS DWORD
 , BYREF pwzFilePath AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGroupImportDatabase LIB "p2pgraph.dll" ALIAS "PeerGroupImportDatabase" ( BYVAL hGroup AS DWORD
 , BYREF pwzFilePath AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerGroupIssueCredentials LIB "p2pgraph.dll" ALIAS "PeerGroupIssueCredentials" ( BYVAL hGroup AS DWORD
 , BYREF pwzSubjectIdentity AS WSTRINGZ
 , BYREF pCredentialInfo AS PEER_CREDENTIAL_INFO
 , BYVAL dwFlags AS DWORD
 , OPTIONAL BYREF ppwzInvitation AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupExportConfig LIB "p2pgraph.dll" ALIAS "PeerGroupExportConfig" ( BYVAL hGroup AS DWORD
 , BYREF pwzPassword AS WSTRINGZ
 , BYREF ppwzXML AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupImportConfig LIB "p2pgraph.dll" ALIAS "PeerGroupImportConfig" ( BYREF pwzXML AS WSTRINGZ
 , BYREF pwzPassword AS WSTRINGZ
 , BYVAL fOverwrite AS LONG
 , BYREF ppwzIdentity AS DWORD
 , BYREF ppwzGroup AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerGroupPeerTimeToUniversalTime LIB "p2pgraph.dll" ALIAS "PeerGroupPeerTimeToUniversalTime" ( BYVAL hGroup AS DWORD
 , BYREF pftPeerTime AS FILETIME
 , BYREF pftUniversalTime AS FILETIME
 ) AS LONG
DECLARE FUNCTION PeerGroupUniversalTimeToPeerTime LIB "p2pgraph.dll" ALIAS "PeerGroupUniversalTimeToPeerTime" ( BYVAL hGroup AS DWORD
 , BYREF pftUniversalTime AS FILETIME
 , BYREF pftPeerTime AS FILETIME
 ) AS LONG
'#if NTDDI_VERSION >= NTDDI_WIN7
DECLARE FUNCTION PeerGroupResumePasswordAuthentication LIB "p2pgraph.dll" ALIAS "PeerGroupResumePasswordAuthentication" ( BYVAL hGroup AS QUAD , BYVAL hPeerEventHandle AS QUAD ) AS LONG
'#endif
'#endif // NO_P2P_GROUP
'#ifndef NO_P2P_IDENTITY
'/////////////////////////////////////////////////////////////////////////////
'//
'// I D E N T I T Y
'//
'/////////////////////////////////////////////////////////////////////////////
'// API Definitions
DECLARE FUNCTION PeerIdentityCreate LIB "p2pgraph.dll" ALIAS "PeerIdentityCreate" ( BYREF pwzClassifier AS WSTRINGZ , BYREF pwzFriendlyName AS WSTRINGZ , BYVAL hCryptProv AS QUAD , BYREF ppwzIdentity AS QUAD ) AS LONG
DECLARE FUNCTION PeerIdentityGetFriendlyName LIB "p2pgraph.dll" ALIAS "PeerIdentityGetFriendlyName" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF ppwzFriendlyName AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentitySetFriendlyName LIB "p2pgraph.dll" ALIAS "PeerIdentitySetFriendlyName" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF ppwzFriendlyName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerIdentityGetCryptKey LIB "p2pgraph.dll" ALIAS "PeerIdentityGetCryptKey" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF phCryptProv AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentityDelete LIB "p2pgraph.dll" ALIAS "PeerIdentityDelete" ( BYREF pwzIdentity AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerEnumIdentities LIB "p2pgraph.dll" ALIAS "PeerEnumIdentities" ( BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerEnumGroups LIB "p2pgraph.dll" ALIAS "PeerEnumGroups" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCreatePeerName LIB "p2pgraph.dll" ALIAS "PeerCreatePeerName" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF pwzClassifier AS WSTRINGZ
 , BYREF ppwzPeerName AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentityGetXML LIB "p2pgraph.dll" ALIAS "PeerIdentityGetXML" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF ppwzIdentityXML AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentityExport LIB "p2pgraph.dll" ALIAS "PeerIdentityExport" ( BYREF pwzIdentity AS WSTRINGZ
 , BYREF pwzPassword AS WSTRINGZ
 , BYREF ppwzExportXML AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentityImport LIB "p2pgraph.dll" ALIAS "PeerIdentityImport" ( BYREF pwzImportXML AS WSTRINGZ
 , BYREF pwzPassword AS WSTRINGZ
 , BYREF ppwzIdentity AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerIdentityGetDefault LIB "p2pgraph.dll" ALIAS "PeerIdentityGetDefault" ( BYREF ppwzPeerName AS DWORD
 ) AS LONG
'#endif // NO_P2P_IDENTITY
'#ifndef NO_P2P_COLLABORATION
'/////////////////////////////////////////////////////////////////////////////
'//
'// C O L L A B O R A T I O N
'//
'/////////////////////////////////////////////////////////////////////////////
'#define PEER_COLLAB_VERSION MAKEWORD(1,0)
%EQUATE `PEER_COLLAB_VERSION = 1
'//////////////////////////////////////////////////////////////////////////////
'//
'// Common used by AppInvite, Contact API's and Serverless Presence
'//
'//////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// Constants
' enum PEER_SIGNIN_FLAGS
%EQUATE `PEER_SIGNIN_NONE = &H0
%EQUATE `PEER_SIGNIN_NEAR_ME = &H1
%EQUATE `PEER_SIGNIN_INTERNET = &H2
%EQUATE `PEER_SIGNIN_ALL = %PEER_SIGNIN_INTERNET OR %PEER_SIGNIN_NEAR_ME
' enum PEER_WATCH_PERMISSION
%EQUATE `PEER_WATCH_BLOCKED = 0
%EQUATE `PEER_WATCH_ALLOWED = 1
' enum PEER_PUBLICATION_SCOPE
%EQUATE `PEER_PUBLICATION_SCOPE_NONE = &H0
%EQUATE `PEER_PUBLICATION_SCOPE_NEAR_ME = &H1
%EQUATE `PEER_PUBLICATION_SCOPE_INTERNET = &H2
%EQUATE `PEER_PUBLICATION_SCOPE_ALL = %PEER_PUBLICATION_SCOPE_NEAR_ME OR %PEER_PUBLICATION_SCOPE_INTERNET
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 28 bytes
TYPE PEER_APPLICATION DWORD
 id AS GUID ' GUID
 data AS PEER_DATA ' PEER_DATA
 pwzDescription AS WSTRINGZ PTR
END TYPE
' // Size = 28 bytes
TYPE PEER_OBJECT DWORD
 id AS GUID ' GUID
 data AS PEER_DATA ' PEER_DATA
 dwPublicationScope AS DWORD
END TYPE
' // Size = 32 bytes
TYPE PEER_CONTACT DWORD
 pwzPeerName AS WSTRINGZ PTR
 pwzNickName AS WSTRINGZ PTR
 pwzDisplayName AS WSTRINGZ PTR
 pwzEmailAddress AS WSTRINGZ PTR
 fWatch AS LONG
 WatcherPermissions AS LONG ' PEER_WATCH_PERMISSION
 credentials AS PEER_DATA ' PEER_DATA
END TYPE
' // Size = 36 bytes
TYPE PEER_ENDPOINT DWORD
 address AS PEER_ADDRESS ' PEER_ADDRESS
 pwzEndpointName AS WSTRINGZ PTR
END TYPE
' // Size = 56 bytes
TYPE PEER_PEOPLE_NEAR_ME DWORD
 pwzNickName AS WSTRINGZ PTR
 endpoint AS PEER_ENDPOINT ' PEER_ENDPOINT
 id AS GUID ' GUID
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// APIs
DECLARE FUNCTION PeerCollabStartup LIB "p2pgraph.dll" ALIAS "PeerCollabStartup" ( BYVAL wVersionRequested AS WORD ) AS LONG
DECLARE FUNCTION PeerCollabShutdown LIB "p2pgraph.dll" ALIAS "PeerCollabShutdown" ( ) AS LONG
DECLARE FUNCTION PeerCollabSignin LIB "p2pgraph.dll" ALIAS "PeerCollabSignin" ( BYVAL hwndParent AS QUAD
 , BYVAL dwSigninOptions AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabSignout LIB "p2pgraph.dll" ALIAS "PeerCollabSignout" ( BYVAL dwSigninOptions AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabGetSigninOptions LIB "p2pgraph.dll" ALIAS "PeerCollabGetSigninOptions" ( BYREF pdwSigninOptions AS DWORD
 ) AS LONG
'/////////////////////////////////////////////////////////////////////////////
'//
'// A P P I N V I T E
'//
'/////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// constants
' enum PEER_INVITATION_RESPONSE_TYPE
%EQUATE `PEER_INVITATION_RESPONSE_DECLINED = 0
%EQUATE `PEER_INVITATION_RESPONSE_ACCEPTED = 1
%EQUATE `PEER_INVITATION_RESPONSE_EXPIRED = 2
%EQUATE `PEER_INVITATION_RESPONSE_ERROR = 3
' enum PEER_APPLICATION_REGISTRATION_TYPE
%EQUATE `PEER_APPLICATION_CURRENT_USER = 0
%EQUATE `PEER_APPLICATION_ALL_USERS = 1
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 28 bytes
TYPE PEER_INVITATION DWORD
 applicationId AS GUID ' GUID
 applicationData AS PEER_DATA ' PEER_DATA
 pwzMessage AS WSTRINGZ PTR
END TYPE
' // Size = 12 bytes
TYPE PEER_INVITATION_RESPONSE DWORD
 action AS LONG ' PEER_INVITATION_RESPONSE_TYPE
 pwzMessage AS WSTRINGZ PTR
 hrExtendedInfo AS LONG
END TYPE
' // Size = 12 bytes
TYPE PEER_APP_LAUNCH_INFO DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
 pInvitation AS PEER_INVITATION PTR ' PPEER_INVITATION
END TYPE
' // Size = 40 bytes
TYPE PEER_APPLICATION_REGISTRATION_INFO DWORD
 application AS PEER_APPLICATION ' PEER_APPLICATION
 pwzApplicationToLaunch AS WSTRINGZ PTR
 pwzApplicationArguments AS WSTRINGZ PTR
 dwPublicationScope AS DWORD
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// API's
'// AppInvite sender side API's
DECLARE FUNCTION PeerCollabAsyncInviteContact LIB "p2pgraph.dll" ALIAS "PeerCollabAsyncInviteContact" ( BYREF pcContact AS PEER_CONTACT , BYREF pcEndpoint AS PEER_ENDPOINT , BYREF pcInvitation AS PEER_INVITATION , OPTIONAL BYVAL hEvent AS QUAD , OPTIONAL BYREF phInvitation AS QUAD ) AS LONG
DECLARE FUNCTION PeerCollabGetInvitationResponse LIB "p2pgraph.dll" ALIAS "PeerCollabGetInvitationResponse" ( BYVAL hInvitation AS QUAD
 , BYREF ppInvitationResponse AS PEER_INVITATION_RESPONSE
 ) AS LONG
DECLARE FUNCTION PeerCollabCancelInvitation LIB "p2pgraph.dll" ALIAS "PeerCollabCancelInvitation" ( BYVAL hInvitation AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabCloseHandle LIB "p2pgraph.dll" ALIAS "PeerCollabCloseHandle" ( BYVAL hInvitation AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabInviteContact LIB "p2pgraph.dll" ALIAS "PeerCollabInviteContact" ( BYREF pcContact AS PEER_CONTACT
 , BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF pcInvitation AS PEER_INVITATION
 , BYREF ppResponse AS PEER_INVITATION_RESPONSE
 ) AS LONG
DECLARE FUNCTION PeerCollabAsyncInviteEndpoint LIB "p2pgraph.dll" ALIAS "PeerCollabAsyncInviteEndpoint" ( BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF pcInvitation AS PEER_INVITATION
 , OPTIONAL BYVAL hEvent AS DWORD
 , OPTIONAL BYREF phInvitation AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabInviteEndpoint LIB "p2pgraph.dll" ALIAS "PeerCollabInviteEndpoint" ( BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF pcInvitation AS PEER_INVITATION
 , BYREF ppResponse AS PEER_INVITATION_RESPONSE
 ) AS LONG
'// AppInvite receiver side API's
DECLARE FUNCTION PeerCollabGetAppLaunchInfo LIB "p2pgraph.dll" ALIAS "PeerCollabGetAppLaunchInfo" ( BYREF ppLaunchInfo AS PEER_APP_LAUNCH_INFO ) AS LONG
'// Applications registration API's
DECLARE FUNCTION PeerCollabRegisterApplication LIB "p2pgraph.dll" ALIAS "PeerCollabRegisterApplication" ( BYREF pcApplication AS PEER_APPLICATION_REGISTRATION_INFO , BYVAL registrationType AS LONG ) AS LONG
DECLARE FUNCTION PeerCollabUnregisterApplication LIB "p2pgraph.dll" ALIAS "PeerCollabUnregisterApplication" ( BYVAL pApplicationId AS GUID
 , BYVAL registrationType AS LONG
 ) AS LONG
DECLARE FUNCTION PeerCollabGetApplicationRegistrationInfo LIB "p2pgraph.dll" ALIAS "PeerCollabGetApplicationRegistrationInfo" ( BYVAL pApplicationId AS GUID
 , BYVAL registrationType AS LONG
 , BYREF ppApplication AS PEER_APPLICATION_REGISTRATION_INFO
 ) AS LONG
DECLARE FUNCTION PeerCollabEnumApplicationRegistrationInfo LIB "p2pgraph.dll" ALIAS "PeerCollabEnumApplicationRegistrationInfo" ( BYVAL registrationType AS LONG
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
'/////////////////////////////////////////////////////////////////////////////
'//
'// S E R V E R L E S S P R E S E N C E
'//
'/////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// constants
' enum PEER_PRESENCE_STATUS
%EQUATE `PEER_PRESENCE_OFFLINE = 0
%EQUATE `PEER_PRESENCE_OUT_TO_LUNCH = 1
%EQUATE `PEER_PRESENCE_AWAY = 2
%EQUATE `PEER_PRESENCE_BE_RIGHT_BACK = 3
%EQUATE `PEER_PRESENCE_IDLE = 4
%EQUATE `PEER_PRESENCE_BUSY = 5
%EQUATE `PEER_PRESENCE_ON_THE_PHONE = 6
%EQUATE `PEER_PRESENCE_ONLINE = 7
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 8 bytes
TYPE PEER_PRESENCE_INFO DWORD
 status AS LONG ' PEER_PRESENCE_STATUS
 pwzDescriptiveText AS WSTRINGZ PTR
END TYPE
'//////////////////////////////////////////////////////////////////////////////
'// API's
'// Subscriber
DECLARE FUNCTION PeerCollabGetPresenceInfo LIB "p2pgraph.dll" ALIAS "PeerCollabGetPresenceInfo" ( BYREF pcEndpoint AS PEER_ENDPOINT , BYREF ppPresenceInfo AS PEER_PRESENCE_INFO ) AS LONG
DECLARE FUNCTION PeerCollabEnumApplications LIB "p2pgraph.dll" ALIAS "PeerCollabEnumApplications" ( BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF pApplicationId AS GUID
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabEnumObjects LIB "p2pgraph.dll" ALIAS "PeerCollabEnumObjects" ( BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF pApplicationId AS GUID
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabEnumEndpoints LIB "p2pgraph.dll" ALIAS "PeerCollabEnumEndpoints" ( BYREF pcContact AS PEER_CONTACT
 , BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabRefreshEndpointData LIB "p2pgraph.dll" ALIAS "PeerCollabRefreshEndpointData" ( BYREF pcEndpoint AS PEER_ENDPOINT
 ) AS LONG
DECLARE FUNCTION PeerCollabDeleteEndpointData LIB "p2pgraph.dll" ALIAS "PeerCollabDeleteEndpointData" ( BYREF pcEndpoint AS PEER_ENDPOINT
 ) AS LONG
DECLARE FUNCTION PeerCollabQueryContactData LIB "p2pgraph.dll" ALIAS "PeerCollabQueryContactData" ( BYREF pcEndpoint AS PEER_ENDPOINT
 , BYREF ppwzContactData AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabSubscribeEndpointData LIB "p2pgraph.dll" ALIAS "PeerCollabSubscribeEndpointData" ( BYREF pcEndpoint AS PEER_ENDPOINT
 ) AS LONG
DECLARE FUNCTION PeerCollabUnsubscribeEndpointData LIB "p2pgraph.dll" ALIAS "PeerCollabUnsubscribeEndpointData" ( BYREF pcEndpoint AS PEER_ENDPOINT
 ) AS LONG
'// Publisher
DECLARE FUNCTION PeerCollabSetPresenceInfo LIB "p2pgraph.dll" ALIAS "PeerCollabSetPresenceInfo" ( BYREF pcPresenceInfo AS PEER_PRESENCE_INFO ) AS LONG
DECLARE FUNCTION PeerCollabGetEndpointName LIB "p2pgraph.dll" ALIAS "PeerCollabGetEndpointName" ( BYREF ppwzEndpointName AS QUAD
 ) AS LONG
DECLARE FUNCTION PeerCollabSetEndpointName LIB "p2pgraph.dll" ALIAS "PeerCollabSetEndpointName" ( BYREF pwzEndpointName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerCollabSetObject LIB "p2pgraph.dll" ALIAS "PeerCollabSetObject" ( BYREF pcObject AS PEER_OBJECT
 ) AS LONG
DECLARE FUNCTION PeerCollabDeleteObject LIB "p2pgraph.dll" ALIAS "PeerCollabDeleteObject" ( BYREF pObjectId AS GUID
 ) AS LONG
'#endif
'/////////////////////////////////////////////////////////////////////////////
'//
'// R E G I S T R A T I O N
'//
'/////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// constants
' enum PEER_CHANGE_TYPE
%EQUATE `PEER_CHANGE_ADDED = 0
%EQUATE `PEER_CHANGE_DELETED = 1
%EQUATE `PEER_CHANGE_UPDATED = 2
' enum PEER_COLLAB_EVENT_TYPE
%EQUATE `PEER_EVENT_WATCHLIST_CHANGED = 1
%EQUATE `PEER_EVENT_ENDPOINT_CHANGED = 2
%EQUATE `PEER_EVENT_ENDPOINT_PRESENCE_CHANGED = 3
%EQUATE `PEER_EVENT_ENDPOINT_APPLICATION_CHANGED = 4
%EQUATE `PEER_EVENT_ENDPOINT_OBJECT_CHANGED = 5
%EQUATE `PEER_EVENT_MY_ENDPOINT_CHANGED = 6
%EQUATE `PEER_EVENT_MY_PRESENCE_CHANGED = 7
%EQUATE `PEER_EVENT_MY_APPLICATION_CHANGED = 8
%EQUATE `PEER_EVENT_MY_OBJECT_CHANGED = 9
%EQUATE `PEER_EVENT_PEOPLE_NEAR_ME_CHANGED = 10
%EQUATE `PEER_EVENT_REQUEST_STATUS_CHANGED = 11
'/////////////////////////////////////////////////////////////////////////////
'// Structures
' // Size = 8 bytes
TYPE PEER_COLLAB_EVENT_REGISTRATION DWORD
 eventType AS LONG ' PEER_COLLAB_EVENT_TYPE
 pInstance AS GUID PTR ' GUID *
END TYPE
' // Size = 8 bytes
TYPE PEER_EVENT_WATCHLIST_CHANGED_DATA DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 changeType AS LONG ' PEER_CHANGE_TYPE
END TYPE
' // Size = 16 bytes
TYPE PEER_EVENT_PRESENCE_CHANGED_DATA DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
 changeType AS LONG ' PEER_CHANGE_TYPE
 pPresenceInfo AS PEER_PRESENCE_INFO PTR ' PPEER_PRESENCE_INFO
END TYPE
' // Size = 16 bytes
TYPE PEER_EVENT_APPLICATION_CHANGED_DATA DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
 changeType AS LONG ' PEER_CHANGE_TYPE
 pApplication AS PEER_APPLICATION PTR ' PPEER_APPLICATION
END TYPE
' // Size = 16 bytes
TYPE PEER_EVENT_OBJECT_CHANGED_DATA DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
 changeType AS LONG ' PEER_CHANGE_TYPE
 pObject AS PEER_OBJECT PTR ' PEER_OBJECT
END TYPE
' // Size = 8 bytes
TYPE PEER_EVENT_ENDPOINT_CHANGED_DATA DWORD
 pContact AS PEER_CONTACT PTR ' PPEER_CONTACT
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
END TYPE
' // Size = 8 bytes
TYPE PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA DWORD
 changeType AS LONG ' PEER_CHANGE_TYPE
 pPeopleNearMe AS PEER_PEOPLE_NEAR_ME PTR ' PPEER_PEOPLE_NEAR_ME
END TYPE
' // Size = 8 bytes
TYPE PEER_EVENT_REQUEST_STATUS_CHANGED_DATA DWORD
 pEndpoint AS PEER_ENDPOINT PTR ' PPEER_ENDPOINT
 hrChange AS LONG
END TYPE
' // Size = 16 bytes
UNION PEER_COLLAB_EVENT_DATA_UNION DWORD
 watchListChangedData AS PEER_EVENT_WATCHLIST_CHANGED_DATA
 presenceChangedData AS PEER_EVENT_PRESENCE_CHANGED_DATA
 applicationChangedData AS PEER_EVENT_APPLICATION_CHANGED_DATA
 objectChangedData AS PEER_EVENT_OBJECT_CHANGED_DATA
 endpointChangedData AS PEER_EVENT_ENDPOINT_CHANGED_DATA
 peopleNearMeChangedData AS PEER_EVENT_PEOPLE_NEAR_ME_CHANGED_DATA
 requestStatusChangedData AS PEER_EVENT_REQUEST_STATUS_CHANGED_DATA
END UNION
' // Size = 20 bytes
TYPE PEER_COLLAB_EVENT_DATA DWORD
 eventType AS LONG ' PEER_COLLAB_EVENT_TYPE
 PEER_COLLAB_EVENT_DATA_UNION
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// API's
DECLARE FUNCTION PeerCollabRegisterEvent LIB "p2pgraph.dll" ALIAS "PeerCollabRegisterEvent" ( BYVAL hEvent AS QUAD , BYVAL cEventRegistration AS QUAD , BYREF pEventRegistrations AS PEER_COLLAB_EVENT_REGISTRATION , BYREF phPeerEvent AS QUAD ) AS LONG
DECLARE FUNCTION PeerCollabGetEventData LIB "p2pgraph.dll" ALIAS "PeerCollabGetEventData" ( BYVAL hPeerEvent AS QUAD
 , BYREF ppEventData AS PEER_COLLAB_EVENT_DATA
 ) AS LONG
DECLARE FUNCTION PeerCollabUnregisterEvent LIB "p2pgraph.dll" ALIAS "PeerCollabUnregisterEvent" ( BYVAL hPeerEvent AS DWORD
 ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'//
'// P N M
'//
'//////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// API's
DECLARE FUNCTION PeerCollabEnumPeopleNearMe LIB "p2pgraph.dll" ALIAS "PeerCollabEnumPeopleNearMe" ( BYREF phPeerEnum AS QUAD ) AS LONG
'//////////////////////////////////////////////////////////////////////////////
'//
'// C O N T A C T
'//
'//////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////
'// API's
DECLARE FUNCTION PeerCollabAddContact LIB "p2pgraph.dll" ALIAS "PeerCollabAddContact" ( BYREF pwzContactData AS WSTRINGZ , OPTIONAL BYREF ppContact AS PEER_CONTACT ) AS LONG
DECLARE FUNCTION PeerCollabDeleteContact LIB "p2pgraph.dll" ALIAS "PeerCollabDeleteContact" ( BYREF pwzPeerName AS WSTRINGZ
 ) AS LONG
DECLARE FUNCTION PeerCollabGetContact LIB "p2pgraph.dll" ALIAS "PeerCollabGetContact" ( BYREF pwzPeerName AS WSTRINGZ
 , BYREF ppContact AS PEER_CONTACT
 ) AS LONG
DECLARE FUNCTION PeerCollabUpdateContact LIB "p2pgraph.dll" ALIAS "PeerCollabUpdateContact" ( BYREF pContact AS PEER_CONTACT
 ) AS LONG
DECLARE FUNCTION PeerCollabEnumContacts LIB "p2pgraph.dll" ALIAS "PeerCollabEnumContacts" ( BYREF phPeerEnum AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabExportContact LIB "p2pgraph.dll" ALIAS "PeerCollabExportContact" ( BYREF pwzPeerName AS WSTRINGZ
 , BYREF ppwzContactData AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerCollabParseContact LIB "p2pgraph.dll" ALIAS "PeerCollabParseContact" ( BYREF pwzContactData AS WSTRINGZ
 , BYREF ppContact AS PEER_CONTACT
 ) AS LONG
'#endif // NO_P2P_COLLABORATION
'/////////////////////////////////////////////////////////////////////////////
'//
'// PNRP APIs
'//
'/////////////////////////////////////////////////////////////////////////////
'#ifndef NO_P2P_PNRP
'#define PNRP_VERSION MAKEWORD(2,0)
%EQUATE `PNRP_VERSION = 2
'#define PEER_PNRP_ALL_LINK_CLOUDS L"PEER_PNRP_ALL_LINKS"
'#define PEER_PNRP_AUTO_ADDRESSES ((ULONG)(-1))
$PEER_PNRP_ALL_LINK_CLOUDS = "PEER_PNRP_ALL_LINKS"
%EQUATE `PEER_PNRP_AUTO_ADDRESSES = &HFFFFFF
'/////////////////////////////////////////////////////////////////////////////
'// Structures
'typedef PVOID HRESOLUTION, HREGISTRATION;
' // Size = 24 bytes
TYPE PEER_PNRP_ENDPOINT_INFO DWORD
 pwzPeerName AS WSTRINGZ PTR
 cAddresses AS DWORD ' ULONG
 ppAddresses AS SOCKADDR PTR
 pwzComment AS WSTRINGZ PTR
 payload AS PEER_DATA ' PEER_DATA
END TYPE
' // Size = 12 bytes
TYPE PEER_PNRP_CLOUD_INFO DWORD
 pwzCloudName AS WSTRINGZ PTR
 dwScope AS LONG ' PNRP_SCOPE
 dwScopeId AS DWORD
END TYPE
' // Size = 32 bytes
TYPE PEER_PNRP_REGISTRATION_INFO DWORD
 pwzCloudName AS WSTRINGZ PTR
 pwzPublishingIdentity AS WSTRINGZ PTR
 cAddresses AS DWORD ' ULONG
 ppAddresses AS SOCKADDR PTR
 wPort AS WORD ' WORD
 pwzComment AS WSTRINGZ PTR
 payload AS PEER_DATA ' PEER_DATA
END TYPE
'/////////////////////////////////////////////////////////////////////////////
'// API's
DECLARE FUNCTION PeerNameToPeerHostName LIB "p2pgraph.dll" ALIAS "PeerNameToPeerHostName" ( BYREF pwzPeerName AS WSTRINGZ , BYREF ppwzHostName AS QUAD ) AS LONG
DECLARE FUNCTION PeerHostNameToPeerName LIB "p2pgraph.dll" ALIAS "PeerHostNameToPeerName" ( BYREF pwzHostName AS WSTRINGZ
 , BYREF ppwzPeerName AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerPnrpStartup LIB "p2pgraph.dll" ALIAS "PeerPnrpStartup" ( BYVAL wVersionRequested AS WORD
 ) AS LONG
DECLARE FUNCTION PeerPnrpShutdown LIB "p2pgraph.dll" ALIAS "PeerPnrpShutdown" ( ) AS LONG
DECLARE FUNCTION PeerPnrpRegister LIB "p2pgraph.dll" ALIAS "PeerPnrpRegister" ( BYREF pcwzPeerName AS WSTRINGZ
 , BYREF pRegistrationInfo AS PEER_PNRP_REGISTRATION_INFO
 , BYREF phRegistration AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerPnrpUpdateRegistration LIB "p2pgraph.dll" ALIAS "PeerPnrpUpdateRegistration" ( BYVAL hRegistration AS DWORD
 , BYREF pRegistrationInfo AS PEER_PNRP_REGISTRATION_INFO
 ) AS LONG
DECLARE FUNCTION PeerPnrpUnregister LIB "p2pgraph.dll" ALIAS "PeerPnrpUnregister" ( BYVAL hRegistration AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerPnrpResolve LIB "p2pgraph.dll" ALIAS "PeerPnrpResolve" ( BYREF pcwzPeerName AS WSTRINGZ
 , BYREF pcwzCloudName AS WSTRINGZ
 , BYREF pcEndpoints AS DWORD
 , BYREF ppEndpoints AS PEER_PNRP_ENDPOINT_INFO
 ) AS LONG
DECLARE FUNCTION PeerPnrpStartResolve LIB "p2pgraph.dll" ALIAS "PeerPnrpStartResolve" ( BYREF pcwzPeerName AS WSTRINGZ
 , BYREF pcwzCloudName AS WSTRINGZ
 , BYVAL cMaxEndpoints AS DWORD
 , BYVAL hEvent AS DWORD _?
 , BYREF phResolve AS DWORD
 ) AS LONG
DECLARE FUNCTION PeerPnrpGetCloudInfo LIB "p2pgraph.dll" ALIAS "PeerPnrpGetCloudInfo" ( BYREF pcNumClouds AS DWORD
 , BYREF ppCloudInfo AS PEER_PNRP_CLOUD_INFO
 ) AS LONG
DECLARE FUNCTION PeerPnrpGetEndpoint LIB "p2pgraph.dll" ALIAS "PeerPnrpGetEndpoint" ( BYVAL hResolve AS DWORD
 , BYREF ppEndpoint AS PEER_PNRP_ENDPOINT_INFO
 ) AS LONG
DECLARE FUNCTION PeerPnrpEndResolve LIB "p2pgraph.dll" ALIAS "PeerPnrpEndResolve" ( BYVAL hResolve AS DWORD
 ) AS LONG
'#endif // NO_P2P_PNRP
'/////////////////////////////////////////////////////////////////////////////
'//
'// Error codes
'//
'/////////////////////////////////////////////////////////////////////////////
#IF NOT %DEF(%FACILITY_P2P)
%EQUATE `FACILITY_P2P = 99
#ENDIF
'#define PEER_E_IPV6_NOT_INSTALLED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0001)
'#define PEER_E_NOT_INITIALIZED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0002)
'#define PEER_E_CANNOT_START_SERVICE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0003)
'#define PEER_E_NOT_LICENSED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0004)
'#define PEER_E_INVALID_GRAPH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0010)
'#define PEER_E_DBNAME_CHANGED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0011)
'#define PEER_E_DUPLICATE_GRAPH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0012)
'#define PEER_E_GRAPH_NOT_READY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0013)
'#define PEER_E_GRAPH_SHUTTING_DOWN MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0014)
'#define PEER_E_GRAPH_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0015)
'#define PEER_E_INVALID_DATABASE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0016)
'#define PEER_E_TOO_MANY_ATTRIBUTES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0017)
%EQUATE `PEER_E_IPV6_NOT_INSTALLED = &H80630001&
%EQUATE `PEER_E_NOT_INITIALIZED = &H80630002&
%EQUATE `PEER_E_CANNOT_START_SERVICE = &H80630003&
%EQUATE `PEER_E_NOT_LICENSED = &H80630004&
%EQUATE `PEER_E_INVALID_GRAPH = &H80630010&
%EQUATE `PEER_E_DBNAME_CHANGED = &H80630011&
%EQUATE `PEER_E_DUPLICATE_GRAPH = &H80630012&
%EQUATE `PEER_E_GRAPH_NOT_READY = &H80630013&
%EQUATE `PEER_E_GRAPH_SHUTTING_DOWN = &H80630014&
%EQUATE `PEER_E_GRAPH_IN_USE = &H80630015&
%EQUATE `PEER_E_INVALID_DATABASE = &H80630016&
%EQUATE `PEER_E_TOO_MANY_ATTRIBUTES = &H80630017&
'#define PEER_E_CONNECTION_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0103)
'#define PEER_E_CONNECT_SELF MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0106)
'#define PEER_E_ALREADY_LISTENING MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0107)
'#define PEER_E_NODE_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0108)
'#define PEER_E_CONNECTION_FAILED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0109)
'#define PEER_E_CONNECTION_NOT_AUTHENTICATED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x010A)
'#define PEER_E_CONNECTION_REFUSED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x010B)
%EQUATE `PEER_E_CONNECTION_NOT_FOUND = &H80630103&
%EQUATE `PEER_E_CONNECT_SELF = &H80630106&
%EQUATE `PEER_E_ALREADY_LISTENING = &H80630107&
%EQUATE `PEER_E_NODE_NOT_FOUND = &H80630108&
%EQUATE `PEER_E_CONNECTION_FAILED = &H80630109&
%EQUATE `PEER_E_CONNECTION_NOT_AUTHENTICATED = &H8063010A&
%EQUATE `PEER_E_CONNECTION_REFUSED = &H8063010B&
'#define PEER_E_CLASSIFIER_TOO_LONG MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0201)
'#define PEER_E_TOO_MANY_IDENTITIES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0202)
'#define PEER_E_NO_KEY_ACCESS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0203)
'#define PEER_E_GROUPS_EXIST MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0204)
%EQUATE `PEER_E_CLASSIFIER_TOO_LONG = &H80630201&
%EQUATE `PEER_E_TOO_MANY_IDENTITIES = &H80630202&
%EQUATE `PEER_E_NO_KEY_ACCESS = &H80630203&
%EQUATE `PEER_E_GROUPS_EXIST = &H80630204&
'// record error codes
'#define PEER_E_RECORD_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0301)
'#define PEER_E_DATABASE_ACCESSDENIED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0302)
'#define PEER_E_DBINITIALIZATION_FAILED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0303)
'#define PEER_E_MAX_RECORD_SIZE_EXCEEDED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0304)
'#define PEER_E_DATABASE_ALREADY_PRESENT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0305)
'#define PEER_E_DATABASE_NOT_PRESENT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0306)
%EQUATE `PEER_E_RECORD_NOT_FOUND = &H80630301&
%EQUATE `PEER_E_DATABASE_ACCESSDENIED = &H80630302&
%EQUATE `PEER_E_DBINITIALIZATION_FAILED = &H80630303&
%EQUATE `PEER_E_MAX_RECORD_SIZE_EXCEEDED = &H80630304&
%EQUATE `PEER_E_DATABASE_ALREADY_PRESENT = &H80630305&
%EQUATE `PEER_E_DATABASE_NOT_PRESENT = &H80630306&
'#define PEER_E_IDENTITY_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0401)
%EQUATE `PEER_E_IDENTITY_NOT_FOUND = &H80630401&
'// eventing error
'#define PEER_E_EVENT_HANDLE_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0501)
%EQUATE `PEER_E_EVENT_HANDLE_NOT_FOUND = &H80630501&
'// searching error
'#define PEER_E_INVALID_SEARCH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0601)
'#define PEER_E_INVALID_ATTRIBUTES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0602)
%EQUATE `PEER_E_INVALID_SEARCH = &H80630601&
%EQUATE `PEER_E_INVALID_ATTRIBUTES = &H80630602&
'// certificate verification error codes
'#define PEER_E_INVITATION_NOT_TRUSTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0701)
'#define PEER_E_CHAIN_TOO_LONG MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0703)
'#define PEER_E_INVALID_TIME_PERIOD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0705)
'#define PEER_E_CIRCULAR_CHAIN_DETECTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0706)
%EQUATE `PEER_E_INVITATION_NOT_TRUSTED = &H80630701&
%EQUATE `PEER_E_CHAIN_TOO_LONG = &H80630703&
%EQUATE `PEER_E_INVALID_TIME_PERIOD = &H80630705&
%EQUATE `PEER_E_CIRCULAR_CHAIN_DETECTED = &H80630706&
'#define PEER_E_CERT_STORE_CORRUPTED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x0801)
%EQUATE `PEER_E_CERT_STORE_CORRUPTED = &H80630801&
'#define PEER_E_NO_CLOUD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x1001)
'#define PEER_E_CLOUD_NAME_AMBIGUOUS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x1005)
%EQUATE `PEER_E_NO_CLOUD = &H80631001&
%EQUATE `PEER_E_CLOUD_NAME_AMBIGUOUS = &H80631005&
'#define PEER_E_INVALID_RECORD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2010)
'#define PEER_E_NOT_AUTHORIZED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2020)
'#define PEER_E_PASSWORD_DOES_NOT_MEET_POLICY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2021)
'#define PEER_E_DEFERRED_VALIDATION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2030)
'#define PEER_E_INVALID_GROUP_PROPERTIES MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2040)
'#define PEER_E_INVALID_PEER_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2050)
'#define PEER_E_INVALID_CLASSIFIER MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2060)
'#define PEER_E_INVALID_FRIENDLY_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2070)
'#define PEER_E_INVALID_ROLE_PROPERTY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2071)
'#define PEER_E_INVALID_CLASSIFIER_PROPERTY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2072)
'#define PEER_E_INVALID_RECORD_EXPIRATION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2080)
'#define PEER_E_INVALID_CREDENTIAL_INFO MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2081)
'#define PEER_E_INVALID_CREDENTIAL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2082)
'#define PEER_E_INVALID_RECORD_SIZE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2083)
'#define PEER_E_UNSUPPORTED_VERSION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2090)
'#define PEER_E_GROUP_NOT_READY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2091)
'#define PEER_E_GROUP_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2092)
'#define PEER_E_INVALID_GROUP MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2093)
'#define PEER_E_NO_MEMBERS_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2094)
'#define PEER_E_NO_MEMBER_CONNECTIONS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2095)
'#define PEER_E_UNABLE_TO_LISTEN MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2096)
'#define PEER_E_IDENTITY_DELETED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x20A0)
'#define PEER_E_SERVICE_NOT_AVAILABLE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x20A1)
%EQUATE `PEER_E_INVALID_RECORD = &H80632010&
%EQUATE `PEER_E_NOT_AUTHORIZED = &H80632020&
%EQUATE `PEER_E_PASSWORD_DOES_NOT_MEET_POLICY = &H80632021&
%EQUATE `PEER_E_DEFERRED_VALIDATION = &H80632030&
%EQUATE `PEER_E_INVALID_GROUP_PROPERTIES = &H80632040&
%EQUATE `PEER_E_INVALID_PEER_NAME = &H80632050&
%EQUATE `PEER_E_INVALID_CLASSIFIER = &H80632060&
%EQUATE `PEER_E_INVALID_FRIENDLY_NAME = &H80632070&
%EQUATE `PEER_E_INVALID_ROLE_PROPERTY = &H80632071&
%EQUATE `PEER_E_INVALID_CLASSIFIER_PROPERTY = &H80632072&
%EQUATE `PEER_E_INVALID_RECORD_EXPIRATION = &H80632080&
%EQUATE `PEER_E_INVALID_CREDENTIAL_INFO = &H80632081&
%EQUATE `PEER_E_INVALID_CREDENTIAL = &H80632082&
%EQUATE `PEER_E_INVALID_RECORD_SIZE = &H80632083&
%EQUATE `PEER_E_UNSUPPORTED_VERSION = &H80632090&
%EQUATE `PEER_E_GROUP_NOT_READY = &H80632091&
%EQUATE `PEER_E_GROUP_IN_USE = &H80632092&
%EQUATE `PEER_E_INVALID_GROUP = &H80632093&
%EQUATE `PEER_E_NO_MEMBERS_FOUND = &H80632094&
%EQUATE `PEER_E_NO_MEMBER_CONNECTIONS = &H80632095&
%EQUATE `PEER_E_UNABLE_TO_LISTEN = &H80632097&
%EQUATE `PEER_E_IDENTITY_DELETED = &H806320A0&
%EQUATE `PEER_E_SERVICE_NOT_AVAILABLE = &H806320A1&
'// Contacts APIs error code
'#define PEER_E_CONTACT_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x6001)
%EQUATE `PEER_E_CONTACT_NOT_FOUND = &H80636001&
'// Special success codes
'#define PEER_S_GRAPH_DATA_CREATED MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x0001)
'#define PEER_S_NO_EVENT_DATA MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x0002)
'#define PEER_S_ALREADY_CONNECTED MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x2000)
'#define PEER_S_SUBSCRIPTION_EXISTS MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x6000)
'#define PEER_S_NO_CONNECTIVITY MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x0005)
'#define PEER_S_ALREADY_A_MEMBER MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_P2P, 0x0006)
%EQUATE `PEER_S_GRAPH_DATA_CREATED = &H80630001&
%EQUATE `PEER_S_NO_EVENT_DATA = &H80630002&
%EQUATE `PEER_S_ALREADY_CONNECTED = &H80632000&
%EQUATE `PEER_S_SUBSCRIPTION_EXISTS = &H80636000&
%EQUATE `PEER_S_NO_CONNECTIVITY = &H80630005&
%EQUATE `PEER_S_ALREADY_A_MEMBER = &H80630006&
'// Pnrp helpers errors
'#define PEER_E_CANNOT_CONVERT_PEER_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x4001)
'#define PEER_E_INVALID_PEER_HOST_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x4002)
'#define PEER_E_NO_MORE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x4003)
'#define PEER_E_PNRP_DUPLICATE_PEER_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x4005)
%EQUATE `PEER_E_CANNOT_CONVERT_PEER_NAME = &H80634001&
%EQUATE `PEER_E_INVALID_PEER_HOST_NAME = &H80634002&
%EQUATE `PEER_E_NO_MORE = &H80634003&
%EQUATE `PEER_E_PNRP_DUPLICATE_PEER_NAME = &H80634005&
'// AppInvite APIs error code
'#define PEER_E_INVITE_CANCELLED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x7000)
'#define PEER_E_INVITE_RESPONSE_NOT_AVAILABLE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x7001)
%EQUATE `PEER_E_INVITE_CANCELLED = &H80637000&
%EQUATE `PEER_E_INVITE_RESPONSE_NOT_AVAILABLE = &H80637001&
'// Serverless presence error codes
'#define PEER_E_NOT_SIGNED_IN MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x7003)
'#define PEER_E_PRIVACY_DECLINED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x7004)
'#define PEER_E_TIMEOUT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x7005)
'#define PEER_E_INVALID_ADDRESS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0X7007)
'#define PEER_E_FW_EXCEPTION_DISABLED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0X7008)
'#define PEER_E_FW_BLOCKED_BY_POLICY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0X7009)
'#define PEER_E_FW_BLOCKED_BY_SHIELDS_UP MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0X700A)
'#define PEER_E_FW_DECLINED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x700B)
%EQUATE `PEER_E_NOT_SIGNED_IN = &H80637003&
%EQUATE `PEER_E_PRIVACY_DECLINED = &H80637004&
%EQUATE `PEER_E_TIMEOUT = &H80637005&
%EQUATE `PEER_E_INVALID_ADDRESS = &H80637007&
%EQUATE `PEER_E_FW_EXCEPTION_DISABLED = &H80637008&
%EQUATE `PEER_E_FW_BLOCKED_BY_POLICY = &H80637009&
%EQUATE `PEER_E_FW_BLOCKED_BY_SHIELDS_UP = &H8063700A&
%EQUATE `PEER_E_FW_DECLINED = &H8063700B&
'//
'// WSA_PNRP_* error codes returned by the NSP
'//
'// These errors are only used by PNRP NSP and applications using the NSP.
'// Any usage from other system/apps not related to PNRP (for example PNRP based getaddrinfo
'// implementations) would require these errors be moved to winerror.h
'#define WSA_PNRP_ERROR_BASE 11500
'#define WSA_PNRP_CLOUD_NOT_FOUND (WSA_PNRP_ERROR_BASE + 1)
'#define WSA_PNRP_CLOUD_DISABLED (WSA_PNRP_ERROR_BASE + 2)
'#define WSA_PNRP_INVALID_IDENTITY (WSA_PNRP_ERROR_BASE + 3)
'#define WSA_PNRP_TOO_MUCH_LOAD (WSA_PNRP_ERROR_BASE + 4)
'#define WSA_PNRP_CLOUD_IS_SEARCH_ONLY (WSA_PNRP_ERROR_BASE + 5)
'#define WSA_PNRP_CLIENT_INVALID_COMPARTMENT_ID (WSA_PNRP_ERROR_BASE + 6)
'#define WSA_PNRP_DUPLICATE_PEER_NAME (WSA_PNRP_ERROR_BASE + 8)
'#define WSA_PNRP_CLOUD_IS_DEAD (WSA_PNRP_ERROR_BASE + 9)
%EQUATE `WSA_PNRP_ERROR_BASE = 11500&
%EQUATE `WSA_PNRP_CLOUD_NOT_FOUND = %WSA_PNRP_ERROR_BASE + 1
%EQUATE `WSA_PNRP_CLOUD_DISABLED = %WSA_PNRP_ERROR_BASE + 2
%EQUATE `WSA_PNRP_INVALID_IDENTITY = %WSA_PNRP_ERROR_BASE + 3
%EQUATE `WSA_PNRP_TOO_MUCH_LOAD = %WSA_PNRP_ERROR_BASE + 4
%EQUATE `WSA_PNRP_CLOUD_IS_SEARCH_ONLY = %WSA_PNRP_ERROR_BASE + 5
%EQUATE `WSA_PNRP_CLIENT_INVALID_COMPARTMENT_ID = %WSA_PNRP_ERROR_BASE + 6
%EQUATE `WSA_PNRP_DUPLICATE_PEER_NAME = %WSA_PNRP_ERROR_BASE + 8
%EQUATE `WSA_PNRP_CLOUD_IS_DEAD = %WSA_PNRP_ERROR_BASE + 9
'//
'// these are the HRESULTs corresponding to the WSA error codes above and returned by Grouping and Simple API
'//
'#define PEER_E_CLOUD_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_CLOUD_NOT_FOUND)
'#define PEER_E_CLOUD_DISABLED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_CLOUD_DISABLED)
'#define PEER_E_INVALID_IDENTITY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_INVALID_IDENTITY)
'#define PEER_E_TOO_MUCH_LOAD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_TOO_MUCH_LOAD)
'#define PEER_E_CLOUD_IS_SEARCH_ONLY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_CLOUD_IS_SEARCH_ONLY)
'#define PEER_E_CLIENT_INVALID_COMPARTMENT_ID MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_CLIENT_INVALID_COMPARTMENT_ID)
'#define PEER_E_DUPLICATE_PEER_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_DUPLICATE_PEER_NAME)
'#define PEER_E_CLOUD_IS_DEAD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, WSA_PNRP_CLOUD_IS_DEAD)
%EQUATE `PEER_E_CLOUD_NOT_FOUND = &H80072CED&
%EQUATE `PEER_E_CLOUD_DISABLED = &H80072CEE&
%EQUATE `PEER_E_INVALID_IDENTITY = &H80072CEF&
%EQUATE `PEER_E_TOO_MUCH_LOAD = &H80072CF0&
%EQUATE `PEER_E_CLOUD_IS_SEARCH_ONLY = &H80072CF1&
%EQUATE `PEER_E_CLIENT_INVALID_COMPARTMENT_ID = &H80072CF2&
%EQUATE `PEER_E_DUPLICATE_PEER_NAME = &H80072CF4&
%EQUATE `PEER_E_CLOUD_IS_DEAD = &H80072CF5&
'//
'// these are the error codes that are not defined by winerror.h, so we define them as our own
'//
'#define PEER_E_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_FOUND)
'#define PEER_E_DISK_FULL MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_DISK_FULL)
'#define PEER_E_ALREADY_EXISTS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_EXISTS)
%EQUATE `PEER_E_NOT_FOUND = &H80070490&
%EQUATE `PEER_E_DISK_FULL = &H80070070&
%EQUATE `PEER_E_ALREADY_EXISTS = &H80070087&
'#pragma warning(pop)
'/////////////////////////////////////////////////////////////////////////////
'//
'// These GUIDs are outside conditional includes so you can
'// #include <p2p.h> in precompiled header
'// then
'// #include <initguid.h> in a single source file
'// #include <p2p.h> in that source file a second time to instantiate the GUIDs
'#ifdef DEFINE_GUID
'#ifndef NO_P2P_GROUP
'DEFINE_GUID(PEER_GROUP_ROLE_ADMIN, /* 04387127-aa56-450a-8ce5-4f565c6790f4 */
' 0x04387127, 0xaa56, 0x450a, 0x8c, 0xe5, 0x4f, 0x56, 0x5c, 0x67, 0x90, 0xf4);
$PEER_GROUP_ROLE_ADMIN = GUID$("{04387127-aa56-450a-8ce5-4f565c6790f4}")
'DEFINE_GUID(PEER_GROUP_ROLE_MEMBER, /* f12dc4c7-0857-4ca0-93fc-b1bb19a3d8c2 */
' 0xf12dc4c7, 0x0857, 0x4ca0, 0x93, 0xfc, 0xb1, 0xbb, 0x19, 0xa3, 0xd8, 0xc2);
$PEER_GROUP_ROLE_MEMBER = GUID$("{f12dc4c7-0857-4ca0-93fc-b1bb19a3d8c2}")
'#if NTDDI_VERSION >= NTDDI_VISTA
'DEFINE_GUID(PEER_GROUP_ROLE_INVITING_MEMBER, /* 4370fd89-dc18-4cfb-8dbf-9853a8a9f905 */
' 0x4370fd89, 0xdc18, 0x4cfb, 0x8d, 0xbf, 0x98, 0x53, 0xa8, 0xa9, 0xf9, 0x05);
$PEER_GROUP_ROLE_INVITING_MEMBER = GUID$("{4370fd89-dc18-4cfb-8dbf-9853a8a9f905}")
'#endif
'#endif // NO_P2P_GROUP
'#ifndef NO_P2P_COLLABORATION
'DEFINE_GUID(PEER_COLLAB_OBJECTID_USER_PICTURE, /* dd15f41f-fc4e-4922-b035-4c06a754d01d */
' 0xdd15f41f, 0xfc4e, 0x4922, 0xb0, 0x35, 0x4c, 0x06, 0xa7, 0x54, 0xd0, 0x1d);
$PEER_COLLAB_OBJECTID_USER_PICTURE = GUID$("{dd15f41f-fc4e-4922-b035-4c06a754d01d}")
'#endif
'#endif // DEFINE_GUID
#ENDIF
