DWORD VmAfdCreateAnonymousConnectionContext ( PVM_AFD_CONNECTION_CONTEXT *ppConnectionContext ) { DWORD dwError = 0; PVM_AFD_CONNECTION_CONTEXT pConnectionContext = NULL; if (!ppConnectionContext) { dwError = ERROR_INVALID_PARAMETER; BAIL_ON_VMAFD_ERROR (dwError); } dwError = gIPCVtable.pfnCreateAnonymousConnectionContext( &pConnectionContext ); BAIL_ON_VMAFD_ERROR (dwError); *ppConnectionContext = pConnectionContext; cleanup: return dwError; error: if (ppConnectionContext) { *ppConnectionContext = NULL; } if (pConnectionContext) { VmAfdFreeConnectionContext(pConnectionContext); } goto cleanup; }
static DWORD InitializeSystemStores( VOID ) { DWORD dwError = 0; PVECS_SRV_STORE_HANDLE pStore = NULL; WCHAR wszSystemStoreName[] = SYSTEM_CERT_STORE_NAME_W; WCHAR wszTrustedStoreName[] = TRUSTED_ROOTS_STORE_NAME_W; WCHAR wszCRLStoreName[] = CRL_STORE_NAME_W; WCHAR wszEveryone[] = GROUP_EVERYONE_W; PVM_AFD_CONNECTION_CONTEXT pRootConnectionContext = NULL; dwError = VmAfdCreateAnonymousConnectionContext( &pRootConnectionContext ); BAIL_ON_VMAFD_ERROR (dwError); dwError = VecsSrvCreateCertStoreWithAuth ( wszSystemStoreName, NULL, pRootConnectionContext, &pStore ); if (dwError == ERROR_ALREADY_EXISTS) { dwError = 0; } BAIL_ON_VMAFD_ERROR (dwError); if (pStore) { VecsSrvCloseCertStoreHandle( pStore, pRootConnectionContext ); pStore = NULL; } dwError = VecsSrvCreateCertStoreWithAuth ( wszTrustedStoreName, NULL, pRootConnectionContext, &pStore ); if (dwError == ERROR_ALREADY_EXISTS) { dwError = 0; } BAIL_ON_VMAFD_ERROR (dwError); if (pStore) { dwError = VecsSrvSetPermission( pStore, wszEveryone, READ_STORE, VMAFD_ACE_TYPE_ALLOWED, pRootConnectionContext ); BAIL_ON_VMAFD_ERROR (dwError); VecsSrvCloseCertStoreHandle( pStore, pRootConnectionContext ); pStore = NULL; } dwError = VecsSrvCreateCertStoreWithAuth ( wszCRLStoreName, NULL, pRootConnectionContext, &pStore ); if (dwError == ERROR_ALREADY_EXISTS) { dwError = 0; } BAIL_ON_VMAFD_ERROR (dwError); if (pStore) { dwError = VecsSrvSetPermission( pStore, wszEveryone, READ_STORE, VMAFD_ACE_TYPE_ALLOWED, pRootConnectionContext ); BAIL_ON_VMAFD_ERROR (dwError); } cleanup: if (pStore && pRootConnectionContext) { VecsSrvCloseCertStoreHandle( pStore, pRootConnectionContext ); } if (pRootConnectionContext) { VmAfdFreeConnectionContext (pRootConnectionContext); } return dwError; error: goto cleanup; }