Implementing SceSvcAttachmentConfig
The SceSvcAttachmentConfig function must retrieve information from the security database and then use that information to configure the service.
When implementing SceSvcAttachmentConfig, you can either retrieve all of the information and then configure the service, or retrieve and configure the service in steps. The following algorithm retrieves all of the information and then configures the service.
To implement SceSvcAttachmentConfig
- Define the variables needed to retrieve information and return codes.
- Call the pfQueryInfo callback function in the callback structure to retrieve configuration information from the security database.
- Configure the system with the returned information.
- Call the pfFreeInfo callback function in the callback structure to free memory used for returned information.
- If there is any message that the extension wants to add to the analysis log file, call the pfLogInfo callback function in the callback structure.
- Return the appropriate SCESTATUS codes.
The following example shows one possible implementation of SceSvcAttachmentConfig. Note that in this example, the function ProcessConfigurationLine sets the service configuration. The implementation of this function is not shown.
SCESTATUS WINAPI SceSvcAttachmentConfig (
IN PSCESVC_CALLBACK_INFO pSceCbInfo
)
{
////////////////////////////////////////////////////
// Define variables.
////////////////////////////////////////////////////
PSCESVC_CONFIGURATION_INFO pConfigInfo = NULL;
SCESTATUS retCode;
SCE_ENUMERATION_CONTEXT EnumContext = 0;
if ( pSceCbInfo == NULL ||
pSceCbInfo->sceHandle == NULL ||
pSceCbInfo->pfQueryInfo == NULL ||
pSceCbInfo->pfSetInfo == NULL ||
pSceCbInfo->pfFreeInfo == NULL )
{
return(SCESTATUS_INVALID_PARAMETER);
}
////////////////////////////////////////////////////
// Retrieve configuration information and configure
// system.
////////////////////////////////////////////////////
do
{
retCode = (*(pSceCbInfo->pfQueryInfo))( pSceCbInfo->sceHandle,
SceSvcConfigurationInfo,
NULL,
FALSE,
(PVOID *)&pConfigInfo,
&EnumContext
);
if (retCode == SCESTATUS_SUCCESS && pConfigInfo != NULL)
{
ULONG i:
//////////////////////////////////////////////////
// Configure system.
/////////////////////////////////////////////////
for(i = 0; < pConfigInfo->Count; i++)
{
if(pConfigInfo->Line[i].Key == NULL)
continue;
ProcessConfigurationLine(pConfigInfo->Line[i]);
}
//////////////////////////////////////////////////
// Free data returned.
/////////////////////////////////////////////////
(*(pSceCbInfo->pfFreeInfo)) ((PVOPID)pConfigInfo);
pConfigInfo = NULL;
}
} while (retCode == SCESTATUS_SUCCESS && CountReturned > 0);
////////////////////////////////////////////////////
// Add code for other return codes if retCode is
// not SCESTATUS_SUCCESS.
///////////////////////////////////////////////////
return retCode;
}