' ########################################################################################
' Microsoft Windows
' File: slpublic.inc
' Contents: Software Licensing and Geniune Advantage Client public API
' 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_slpublic_PBI)
#DEFINE PBX_slpublic_PBI
%EQUATE `SLPUBLIC_INC = 1
#INCLUDE ONCE "Core/Windows.inc"
'#define SLFreeMemory(p) LocalFree(p)
DECLARE FUNCTION SLFreeMemory LIB "kernel32.dll" ALIAS "LocalFree" ( BYVAL hMem AS QUAD ) AS QUAD ' HLOCAL
'#define SLWGAFreeMemory(p) LocalFree(p)
DECLARE FUNCTION SLWGAFreeMemory LIB "kernel32.dll" ALIAS "LocalFree" ( BYVAL hMem AS QUAD ) AS QUAD ' HLOCAL
'typedef GUID SLID;
' enum SLDATATYPE
%EQUATE `SL_DATA_NONE = %REG_NONE
%EQUATE `SL_DATA_SZ = %REG_SZ
%EQUATE `SL_DATA_DWORD = %REG_DWORD
%EQUATE `SL_DATA_BINARY = %REG_BINARY
%EQUATE `SL_DATA_MULTI_SZ = %REG_MULTI_SZ
%EQUATE `SL_DATA_SUM = 100
' enum SL_GENUINE_STATE
%EQUATE `SL_GEN_STATE_IS_GENUINE = 0
%EQUATE `SL_GEN_STATE_INVALID_LICENSE = 1
%EQUATE `SL_GEN_STATE_TAMPERED = 2
%EQUATE `SL_GEN_STATE_LAST = 3
' // Size = 12 bytes
TYPE SL_NONGENUINE_UI_OPTIONS
 cbSize AS DWORD
 pComponentId AS GUID PTR ' CONST SLID*
 hResultUI AS LONG
END TYPE
$$SL_PROP_BRT_DATA = "SL_BRT_DATA"$$
$$SL_PROP_BRT_COMMIT = "SL_BRT_COMMIT"$$
$$SL_PROP_GENUINE_RESULT = "SL_GENUINE_RESULT"$$
$$SL_PROP_NONGENUINE_GRACE_FLAG = "SL_NONGENUINE_GRACE_FLAG"$$
$$SL_POLICY_EVALUATION_MODE_ENABLED = "Security-SPP-EvaluationModeEnabled"$$
DECLARE FUNCTION SLGetWindowsInformation LIB "slc.dll" ALIAS "SLGetWindowsInformation" ( BYREF pwszValueName AS WSTRINGZ , BYREF peDataType AS LONG , BYREF pcbValue AS QUAD , BYREF ppbValue AS QUAD ) AS LONG
'/*++
'Routine Description:
' This function is used to for Windows components to get
' component policy value.
'Arguments:
' pwszValueName
' The name of the requested value.
' peDataType
' Data type. Following types are supported:
' SL_DATA_SZ - UNICODE string
' SL_DATA_DWORD - DWORD
' SL_DATA_BINARY - Binary blob
' pcbValue
' Size of the allocated buffer.
' ppbValue
' The value. If successful, the data is returned in the buffer
' allocated by SLC.
' The caller has to call SLFreeMemory to free the memory.
'Return Error:
' E_INVALIDARG
' SL_E_VALUE_NOT_FOUND
' SL_E_RIGHT_NOT_GRANTED
'--*/
DECLARE FUNCTION SLGetWindowsInformationDWORD LIB "slc.dll" ALIAS "SLGetWindowsInformationDWORD" ( BYREF pwszValueName AS WSTRINGZ , BYREF pdwValue AS QUAD ) AS LONG
'/*++
'Routine Description:
' This function is used to for Windows components to get
' component policy DWORD value.
'Arguments:
' pwszValueName
' The name of the requested value.
' pdwValue
' The buffer to receive DWORD value
'Return Error:
' E_INVALIDARG
' SL_E_VALUE_NOT_FOUND
' SL_E_RIGHT_NOT_GRANTED
' SL_E_DATATYPE_MISMATCHED
'--*/
DECLARE FUNCTION SLIsGenuineLocal LIB "slwga.dll" ALIAS "SLIsGenuineLocal" ( BYREF pAppId AS GUID , BYREF pGenuineState AS LONG , BYREF pUIOptions AS SL_NONGENUINE_UI_OPTIONS ) AS LONG
'/*++
'Routine Description:
' Determines if an installation is a Genuine installation.
' It interrogates the license for pAppId and inspects the "Tampered"
' flag. If either the license for pAppId is invalid or the "Tampered"
' flag is set, the installation is assumed to be invalid.
' pGenuineState is ONLY modified if the result is S_OK. Otherwise, it is
' left in the state in which it was found on function entry.
'Arguments:
' pAppId
' Application identifier.
' pbGenuineState
' Output state value - one of the SL_GENUINE_STATE values
' pUIOptions
' Non genuine UI options. If NULL, no UI is displayed if
' state is non-genuine.
'Return Error:
' S_OK
' Operation completed successfully.
' E_INVALIDARG
' pGenuineState is NULL.
'--*/
DECLARE FUNCTION SLIsGenuineLocalEx LIB "slwga.dll" ALIAS "SLIsGenuineLocalEx" ( BYREF pAppId AS GUID , BYREF pSkuId AS GUID , BYREF pGenuineState AS LONG ) AS LONG
'/*++
'Routine Description:
' Determines if an installation is a Genuine installation.
' If the SkuId is provided, it is used for the primary check. If the Sku license
' contains a ProductUniquenessGroupId value, that is also used. Finally, the AppId is used.
' If the AppId, ProductUniquenessGroupId, or SkuId contains a "Tampered" flag or if the license
' state is invalid or "Tampered", the installation is assumed to be invalid.
' pGenuineState is ONLY modified if the result is S_OK. Otherwise, it is
' left in the state in which it was found on function entry.
'Arguments:
' pAppId
' Application identifier.
' pSkuId
' Sku identifier, optional. If specified and the Sku license contains a
' ProductUniquenessGroupId then that is also checked.
' pbGenuineState
' Output state value - one of the SL_GENUINE_STATE values
'Return Error:
' S_OK
' Operation completed successfully.
' E_INVALIDARG
' pGenuineState is NULL.
'--*/
DECLARE FUNCTION SLAcquireGenuineTicket LIB "slcext.dll" ALIAS "SLAcquireGenuineTicket" ( BYREF ppTicketBlob AS QUAD , BYREF pcbTicketBlob AS QUAD , BYREF pwszTemplateId AS WSTRINGZ , BYREF pwszServerUrl AS WSTRINGZ , OPTIONAL BYREF pwszClientToken AS WSTRINGZ ) AS LONG
'/*++
'Routine Description:
' Returns genuine ticket acquired from Software Licensing Server based
' on SLWGA template blob.
' The client is responsible for freeing the buffer returned in ppGenuineBlob.
' SLWGAFreeMemory should be used to free the memory.
' The output parameters are only set if the function returns S_OK. Otherwise,
' they are left as they were when the function was entered.
'Arguments:
' ppTicketBlob
' Pointer to output pointer to be returned (XrML genuine ticket).
' pcbTicketBlob
' An output pointer that will contain the size, in bytes, of the region
' returned in ppTicketBlob.
' pwszTemplateId
' Id of genuine blob template kept on the server side.
' pwszServerUrl
' Ticket acquisition server url.
' pwszClientToken
' Client custom token.
'Return Error:
' S_OK
' Operation completed successfully.
'--*/
' // *** Removed in Windows 7 SDK ***
'DECLARE FUNCTION SLGetInstalledSAMLicenseApplications LIB "slc.dll" ALIAS "SLGetInstalledSAMLicenseApplications" ( ' BYREF pnReturnedAppIds AS DWORD
' , BYREF ppReturnedAppIds AS DWORD
' ) AS LONG
'/*++
'Routine Description:
' Obtains an array of Application Ids representing applications whose SAM
' licenses have been installed with SLInstallSAMLicense.
'Arguments:
' pnReturnedAppIds
' Number of elements in ppReturnedAppIds array
' ppReturnedAppIds
' Array containing all installed Application Ids.
' The caller has to call SLFreeMemory to free the memory.
'Return Errors:
' S_OK
' Operation completed successfully
' E_INVALIDARG
' One or more arguments are invalid
'--*/
' // *** Removed in Windows 7 SDK ***
'DECLARE FUNCTION SLGetSAMLicense LIB "slc.dll" ALIAS "SLGetSAMLicense" ( ' BYREF pApplicationId AS GUID
' , BYREF pcbXmlLicenseData AS DWORD
' , BYREF ppbXmlLicenseData AS DWORD
' ) AS LONG
'/*++
'Routine Description:
' Obtain information about an installed SAM application.
'Arguments:
' pApplicationId
' Id of Application for which to obtain its SAM License
' pcbXmlLicenseData
' Size of ppbXmlLicenseData in bytes
' ppbXmlLicenseData
' License file data for (SAM) application with Application Id pApplicationId.
' The caller has to call SLFreeMemory to free the memory.
'Return Errors:
' S_OK
' Operation completed successfully
' SL_E_LICENSE_FILE_NOT_INSTALLED
' License not installed
' E_INVALIDARG
' One or more arguments are invalid
'--*/
' // *** Removed in Windows 7 SDK ***
'DECLARE FUNCTION SLInstallSAMLicense LIB "slc.dll" ALIAS "SLInstallSAMLicense" ( ' BYREF pApplicationId AS GUID
' , BYVAL cbXmlLicenseData AS DWORD
' , BYVAL pbXmlLicenseData AS DWORD
' ) AS LONG
'/*++
'Routine Description:
' Install SAM License
'Arguments:
' pApplicationId
' Id of Application for which to install SAM License.
' cbXmlLicenseData
' Size of pbXmlLicenseData in bytes
' pbXmlLicenseData
' License file data
'Return Errors:
' S_OK
' Operation completed successfully
' SL_E_LUA_ACCESSDENIED
' The Software Licensing Service reported that the action requires administrator privilege
' E_INVALIDARG
' One or more arguments are invalid
'--*/
' // *** Removed in Windows 7 SDK ***
'DECLARE FUNCTION SLUninstallSAMLicense LIB "slc.dll" ALIAS "SLUninstallSAMLicense" ( ' BYREF pApplicationId AS GUID
' ) AS LONG
'/*++
'Routine Description:
' UnInstall SAM License
'Arguments:
' pApplicationId
' Id of Application for which to uninstall SAM License.
'Return Errors:
' S_OK
' Operation completed successfully
' SL_E_LICENSE_FILE_NOT_INSTALLED
' License not installed
' SL_E_LUA_ACCESSDENIED
' The Software Licensing Service reported that the action requires administrator privilege
' E_INVALIDARG
' One or more arguments are invalid
'--*/
DECLARE FUNCTION SLSetGenuineInformation LIB "slc.dll" ALIAS "SLSetGenuineInformation" ( BYREF pAppId AS GUID , BYREF pwszValueName AS WSTRINGZ , BYVAL eDataType AS LONG , BYVAL cbValue AS QUAD , BYVAL pbValue AS QUAD ) AS LONG
'/*++
'Routine Description:
' This function sets genuine information.
'Arguments:
' hSLC
' Handle to current SLC session.
' pAppId
' Application ID. E.g. Windows AppId
' pwszValueName
' The name of value.
' TBD
' eType
' See SLDATATYPE
' cbValue
' Size of value
' pbValue
' Value.
' Some properties allows NULL pointer, which can be used to delete
' the property but some properties can't.
'Return Value:
' HRESULT_FROM_WIN32(ERROR_BUFFER_OVERFLOW)
' The size of value is over expected size
' E_ACCESSDENIED
' Admin privilege required
' E_INVALIDAGR
' Some property does not allow NULL value
' SL_E_NOT_SUPPORTED
' The name of value is not supported
' SL_E_DEPENDENT_PROPERTY_NOT_SET
' If entry has been set
' SL_E_DATATYPE_MISMATCHED
' The type of data is mismatched with the expected type
' of specified value name
'--*/
DECLARE FUNCTION SLGetGenuineInformation LIB "slc.dll" ALIAS "SLGetGenuineInformation" ( BYREF pAppId AS GUID , BYREF pwszValueName AS WSTRINGZ , BYREF peDataType AS LONG , BYREF pcbValue AS QUAD , BYREF ppbValue AS QUAD ) AS LONG
'/*++
'Routine Description:
' This function gets genuine information.
'Arguments:
' hSLC
' Handle to current SLC session.
' pAppId
' Application ID. E.g. Windows AppId
' pwszValueName
' See SLSetOfflineGenuineInformation
' eType
' See SLDATATYPE
' cbValue
' Size of value
' pbValue
' Value
'Return Value:
' SL_E_NOT_SUPPORTED
' The name of value is not supported
' SL_E_VALUE_NOT_FOUND
' The specified value can not be found
'--*/
#ENDIF
