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

  1. Define the variables needed to retrieve information and return codes.
  2. Call the pfQueryInfo callback function in the callback structure to retrieve configuration information from the security database.
  3. Configure the system with the returned information.
  4. Call the pfFreeInfo callback function in the callback structure to free memory used for returned information.
  5. 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.
  6. 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;
}