Esempio n. 1
0
NTSTATUS
SrvShareRegOpen(
    OUT PHANDLE phRepository
    )
{
    return NtRegOpenServer(phRepository);
}
Esempio n. 2
0
NTSTATUS
NtRegOpenConfig(
    PCSTR pszConfigKey,
    PCSTR pszPolicyKey,
    PLWREG_CONFIG_REG *ppReg
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PLWREG_CONFIG_REG pReg = NULL;

    ntStatus = LW_RTL_ALLOCATE(
                   (PVOID*)&pReg, 
                   LWREG_CONFIG_REG, 
                   sizeof(LWREG_CONFIG_REG));
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = LwRtlCStringDuplicate(&pReg->pszConfigKey, pszConfigKey);
    BAIL_ON_NT_STATUS(ntStatus);

    if (pszPolicyKey)
    {
        ntStatus = LwRtlCStringDuplicate(&pReg->pszPolicyKey, pszPolicyKey);
        BAIL_ON_NT_STATUS(ntStatus);
    }

    ntStatus = NtRegOpenServer(&pReg->hConnection);
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = NtRegOpenKeyExA(
            pReg->hConnection,
            NULL,
            HKEY_THIS_MACHINE,
            0,
            KEY_READ,
            &(pReg->hKey));
    BAIL_ON_NT_STATUS(ntStatus);

cleanup:

    *ppReg = pReg;

    return ntStatus;

error:

    NtRegCloseConfig(pReg);
    pReg = NULL;

    goto cleanup;
}
Esempio n. 3
0
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;
}