VOID SrvShareRegClose( IN HANDLE hRepository ) { NtRegCloseServer(hRepository); }
VOID NtRegCloseConfig( PLWREG_CONFIG_REG pReg ) { if (pReg) { LwRtlCStringFree(&pReg->pszConfigKey); LwRtlCStringFree(&pReg->pszPolicyKey); if (pReg->hConnection) { if ( pReg->hKey ) { NtRegCloseKey(pReg->hConnection, pReg->hKey); pReg->hKey = NULL; } NtRegCloseServer(pReg->hConnection); pReg->hConnection = NULL; } RTL_FREE(&pReg); } }
NTSTATUS DfsConfigReadStandaloneRoots( VOID ) { NTSTATUS ntStatus = STATUS_SUCCESS; HANDLE hRegConnection = (HANDLE)NULL; HKEY hStandaloneKey = (HKEY)NULL; PWSTR pwszStandaloneRootKeyPath = NULL; DWORD dwIndex = 0; DWORD dwReserved = 0; DWORD dwDfsRootNameSize = MAX_KEY_LENGTH; WCHAR pwszDfsRootName[MAX_KEY_LENGTH] = {0}; BOOLEAN bFinished = FALSE; ntStatus = LwRtlWC16StringAllocateFromCString( &pwszStandaloneRootKeyPath, DFS_CONF_ROOT_STANDALONE); BAIL_ON_NT_STATUS(ntStatus); ntStatus = NtRegOpenServer(&hRegConnection); BAIL_ON_NT_STATUS(ntStatus); ntStatus = NtRegOpenKeyExW( hRegConnection, NULL, pwszStandaloneRootKeyPath, 0, KEY_READ, &hStandaloneKey); BAIL_ON_NT_STATUS(ntStatus); for (dwIndex = 0; !bFinished; dwIndex++) { ntStatus = NtRegEnumKeyExW( hRegConnection, hStandaloneKey, dwIndex, pwszDfsRootName, &dwDfsRootNameSize, &dwReserved, NULL, NULL, NULL); if (ntStatus == STATUS_NO_MORE_ENTRIES) { ntStatus = STATUS_SUCCESS; bFinished = TRUE; continue; } BAIL_ON_NT_STATUS(ntStatus); ntStatus = DfsConfigInitializeRoot( hRegConnection, hStandaloneKey, pwszDfsRootName); BAIL_ON_NT_STATUS(ntStatus); } cleanup: if (pwszStandaloneRootKeyPath) { LwRtlWC16StringFree(&pwszStandaloneRootKeyPath); } if (hStandaloneKey) { NtRegCloseKey(hRegConnection, hStandaloneKey); } if (hRegConnection) { NtRegCloseServer(hRegConnection); } return ntStatus; error: goto cleanup; }