mirror of
https://github.com/reactos/reactos.git
synced 2024-12-30 19:14:31 +00:00
[LSASRV]
- LsapRegQueryKeyInfo: Return the maximum sub key name length too. - LsarEnumerateAccounts: User the maximum sub key name length to allocate a large enough buffer instead of using a fixed size one. - LsarAddAccountRights: Use the proper value size to retrieve the system access attribute. svn path=/trunk/; revision=72215
This commit is contained in:
parent
caa5c5b12d
commit
3890a9cf57
3 changed files with 36 additions and 10 deletions
|
@ -654,10 +654,11 @@ NTSTATUS WINAPI LsarEnumerateAccounts(
|
|||
{
|
||||
LSAPR_ACCOUNT_ENUM_BUFFER EnumBuffer = {0, NULL};
|
||||
PLSA_DB_OBJECT PolicyObject = NULL;
|
||||
WCHAR AccountKeyName[64];
|
||||
PWSTR AccountKeyBuffer = NULL;
|
||||
HANDLE AccountsKeyHandle = NULL;
|
||||
HANDLE AccountKeyHandle;
|
||||
HANDLE SidKeyHandle;
|
||||
ULONG AccountKeyBufferSize;
|
||||
ULONG EnumIndex;
|
||||
ULONG EnumCount;
|
||||
ULONG RequiredLength;
|
||||
|
@ -693,6 +694,23 @@ NTSTATUS WINAPI LsarEnumerateAccounts(
|
|||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
Status = LsapRegQueryKeyInfo(AccountsKeyHandle,
|
||||
NULL,
|
||||
&AccountKeyBufferSize,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ERR("LsapRegQueryKeyInfo returned 0x%08lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
AccountKeyBufferSize += sizeof(WCHAR);
|
||||
AccountKeyBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AccountKeyBufferSize);
|
||||
if (AccountKeyBuffer == NULL)
|
||||
{
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
EnumIndex = *EnumerationContext;
|
||||
EnumCount = 0;
|
||||
RequiredLength = 0;
|
||||
|
@ -701,16 +719,16 @@ NTSTATUS WINAPI LsarEnumerateAccounts(
|
|||
{
|
||||
Status = LsapRegEnumerateSubKey(AccountsKeyHandle,
|
||||
EnumIndex,
|
||||
64 * sizeof(WCHAR),
|
||||
AccountKeyName);
|
||||
AccountKeyBufferSize,
|
||||
AccountKeyBuffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
break;
|
||||
|
||||
TRACE("EnumIndex: %lu\n", EnumIndex);
|
||||
TRACE("Account key name: %S\n", AccountKeyName);
|
||||
TRACE("Account key name: %S\n", AccountKeyBuffer);
|
||||
|
||||
Status = LsapRegOpenKey(AccountsKeyHandle,
|
||||
AccountKeyName,
|
||||
AccountKeyBuffer,
|
||||
KEY_READ,
|
||||
&AccountKeyHandle);
|
||||
TRACE("LsapRegOpenKey returned %08lX\n", Status);
|
||||
|
@ -766,16 +784,16 @@ NTSTATUS WINAPI LsarEnumerateAccounts(
|
|||
{
|
||||
Status = LsapRegEnumerateSubKey(AccountsKeyHandle,
|
||||
EnumIndex,
|
||||
64 * sizeof(WCHAR),
|
||||
AccountKeyName);
|
||||
AccountKeyBufferSize,
|
||||
AccountKeyBuffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
break;
|
||||
|
||||
TRACE("EnumIndex: %lu\n", EnumIndex);
|
||||
TRACE("Account key name: %S\n", AccountKeyName);
|
||||
TRACE("Account key name: %S\n", AccountKeyBuffer);
|
||||
|
||||
Status = LsapRegOpenKey(AccountsKeyHandle,
|
||||
AccountKeyName,
|
||||
AccountKeyBuffer,
|
||||
KEY_READ,
|
||||
&AccountKeyHandle);
|
||||
TRACE("LsapRegOpenKey returned %08lX\n", Status);
|
||||
|
@ -845,6 +863,9 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
if (AccountKeyBuffer != NULL)
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, AccountKeyBuffer);
|
||||
|
||||
if (AccountsKeyHandle != NULL)
|
||||
LsapRegCloseKey(AccountsKeyHandle);
|
||||
|
||||
|
@ -2520,7 +2541,7 @@ NTSTATUS WINAPI LsarAddAccountRights(
|
|||
|
||||
if (ulNewRights > 0)
|
||||
{
|
||||
Size = 0;
|
||||
Size = sizeof(ACCESS_MASK);
|
||||
|
||||
/* Get the system access flags, if the attribute exists */
|
||||
Status = LsapGetObjectAttribute(AccountObject,
|
||||
|
|
|
@ -364,6 +364,7 @@ LsapRegOpenKey(IN HANDLE ParentKeyHandle,
|
|||
NTSTATUS
|
||||
LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
|
||||
OUT PULONG SubKeyCount,
|
||||
OUT PULONG MaxSubKeyNameLength,
|
||||
OUT PULONG ValueCount);
|
||||
|
||||
NTSTATUS
|
||||
|
|
|
@ -175,6 +175,7 @@ LsapRegOpenKey(IN HANDLE ParentKeyHandle,
|
|||
NTSTATUS
|
||||
LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
|
||||
OUT PULONG SubKeyCount,
|
||||
OUT PULONG MaxSubKeyNameLength,
|
||||
OUT PULONG ValueCount)
|
||||
{
|
||||
KEY_FULL_INFORMATION FullInfoBuffer;
|
||||
|
@ -196,6 +197,9 @@ LsapRegQueryKeyInfo(IN HANDLE KeyHandle,
|
|||
if (SubKeyCount != NULL)
|
||||
*SubKeyCount = FullInfoBuffer.SubKeys;
|
||||
|
||||
if (MaxSubKeyNameLength != NULL)
|
||||
*MaxSubKeyNameLength = FullInfoBuffer.MaxNameLen;
|
||||
|
||||
if (ValueCount != NULL)
|
||||
*ValueCount = FullInfoBuffer.Values;
|
||||
|
||||
|
|
Loading…
Reference in a new issue