mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 05:00:27 +00:00
[SAMSRV]
- Support container objects in SampCreateDbObject. - Implement SampGetObjectAttribute and SampSetObjectAttribute. svn path=/trunk/; revision=56669
This commit is contained in:
parent
7803f2678f
commit
f07bb17c73
2 changed files with 126 additions and 101 deletions
|
@ -309,6 +309,7 @@ SampCreateDbObject(IN PSAM_DB_OBJECT ParentObject,
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING KeyName;
|
UNICODE_STRING KeyName;
|
||||||
HANDLE ParentKeyHandle;
|
HANDLE ParentKeyHandle;
|
||||||
|
HANDLE ContainerKeyHandle = NULL;
|
||||||
HANDLE ObjectKeyHandle;
|
HANDLE ObjectKeyHandle;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -320,25 +321,73 @@ SampCreateDbObject(IN PSAM_DB_OBJECT ParentObject,
|
||||||
else
|
else
|
||||||
ParentKeyHandle = ParentObject->KeyHandle;
|
ParentKeyHandle = ParentObject->KeyHandle;
|
||||||
|
|
||||||
RtlInitUnicodeString(&KeyName,
|
if (ContainerName != NULL)
|
||||||
ObjectName);
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&KeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
ParentKeyHandle,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtCreateKey(&ObjectKeyHandle,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
&ObjectAttributes,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
return Status;
|
/* Open the container key */
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
ContainerName);
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
ParentKeyHandle,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtOpenKey(&ContainerKeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Open the object key */
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
ObjectName);
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
ContainerKeyHandle,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtCreateKey(&ObjectKeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&ObjectAttributes,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
NtClose(ContainerKeyHandle);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&KeyName,
|
||||||
|
ObjectName);
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
ParentKeyHandle,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Status = NtCreateKey(&ObjectKeyHandle,
|
||||||
|
KEY_ALL_ACCESS,
|
||||||
|
&ObjectAttributes,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
|
NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||||
|
@ -553,120 +602,82 @@ SampCloseDbObject(PSAM_DB_OBJECT DbObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsapSetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
SampSetObjectAttribute(PSAM_DB_OBJECT DbObject,
|
||||||
LPWSTR AttributeName,
|
LPWSTR AttributeName,
|
||||||
|
ULONG AttributeType,
|
||||||
LPVOID AttributeData,
|
LPVOID AttributeData,
|
||||||
ULONG AttributeSize)
|
ULONG AttributeSize)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
UNICODE_STRING ValueName;
|
||||||
UNICODE_STRING KeyName;
|
|
||||||
HANDLE AttributeKey;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&ValueName,
|
||||||
AttributeName);
|
AttributeName);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
return ZwSetValueKey(DbObject->KeyHandle,
|
||||||
&KeyName,
|
&ValueName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
DbObject->KeyHandle,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtCreateKey(&AttributeKey,
|
|
||||||
KEY_SET_VALUE,
|
|
||||||
&ObjectAttributes,
|
|
||||||
0,
|
0,
|
||||||
NULL,
|
AttributeType,
|
||||||
REG_OPTION_NON_VOLATILE,
|
AttributeData,
|
||||||
NULL);
|
AttributeSize);
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = RtlpNtSetValueKey(AttributeKey,
|
|
||||||
REG_NONE,
|
|
||||||
AttributeData,
|
|
||||||
AttributeSize);
|
|
||||||
|
|
||||||
NtClose(AttributeKey);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
LsapGetObjectAttribute(PLSA_DB_OBJECT DbObject,
|
SampGetObjectAttribute(PSAM_DB_OBJECT DbObject,
|
||||||
LPWSTR AttributeName,
|
LPWSTR AttributeName,
|
||||||
|
PULONG AttributeType,
|
||||||
LPVOID AttributeData,
|
LPVOID AttributeData,
|
||||||
PULONG AttributeSize)
|
PULONG AttributeSize)
|
||||||
{
|
{
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
|
||||||
UNICODE_STRING KeyName;
|
UNICODE_STRING ValueName;
|
||||||
HANDLE AttributeKey;
|
ULONG BufferLength = 0;
|
||||||
ULONG ValueSize;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
RtlInitUnicodeString(&KeyName,
|
RtlInitUnicodeString(&ValueName,
|
||||||
AttributeName);
|
AttributeName);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
if (AttributeSize != NULL)
|
||||||
&KeyName,
|
BufferLength = *AttributeSize;
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
DbObject->KeyHandle,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
Status = NtOpenKey(&AttributeKey,
|
BufferLength += FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data);
|
||||||
KEY_QUERY_VALUE,
|
|
||||||
&ObjectAttributes);
|
/* Allocate memory for the value */
|
||||||
if (!NT_SUCCESS(Status))
|
ValueInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferLength);
|
||||||
|
if (ValueInfo == NULL)
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
|
/* Query the value */
|
||||||
|
Status = ZwQueryValueKey(DbObject->KeyHandle,
|
||||||
|
&ValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
ValueInfo,
|
||||||
|
BufferLength,
|
||||||
|
&BufferLength);
|
||||||
|
if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW))
|
||||||
{
|
{
|
||||||
return Status;
|
if (AttributeType != NULL)
|
||||||
|
*AttributeType = ValueInfo->Type;
|
||||||
|
|
||||||
|
if (AttributeSize != NULL)
|
||||||
|
*AttributeSize = ValueInfo->DataLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueSize = *AttributeSize;
|
/* Check if the caller wanted data back, and we got it */
|
||||||
Status = RtlpNtQueryValueKey(AttributeKey,
|
if ((NT_SUCCESS(Status)) && (AttributeData != NULL))
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&ValueSize,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status) && Status != STATUS_BUFFER_OVERFLOW)
|
|
||||||
{
|
{
|
||||||
goto Done;
|
/* Copy it */
|
||||||
|
RtlMoveMemory(AttributeData,
|
||||||
|
ValueInfo->Data,
|
||||||
|
ValueInfo->DataLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AttributeData == NULL || *AttributeSize == 0)
|
/* Free the memory and return status */
|
||||||
{
|
RtlFreeHeap(RtlGetProcessHeap(), 0, ValueInfo);
|
||||||
*AttributeSize = ValueSize;
|
|
||||||
Status = STATUS_SUCCESS;
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
else if (*AttributeSize < ValueSize)
|
|
||||||
{
|
|
||||||
*AttributeSize = ValueSize;
|
|
||||||
Status = STATUS_BUFFER_OVERFLOW;
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = RtlpNtQueryValueKey(AttributeKey,
|
|
||||||
NULL,
|
|
||||||
AttributeData,
|
|
||||||
&ValueSize,
|
|
||||||
0);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
*AttributeSize = ValueSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
Done:
|
|
||||||
NtClose(AttributeKey);
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,20 @@ SampValidateDbObject(SAMPR_HANDLE Handle,
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
SampCloseDbObject(PSAM_DB_OBJECT DbObject);
|
SampCloseDbObject(PSAM_DB_OBJECT DbObject);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
SampSetObjectAttribute(PSAM_DB_OBJECT DbObject,
|
||||||
|
LPWSTR AttributeName,
|
||||||
|
ULONG AttributeType,
|
||||||
|
LPVOID AttributeData,
|
||||||
|
ULONG AttributeSize);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
SampGetObjectAttribute(PSAM_DB_OBJECT DbObject,
|
||||||
|
LPWSTR AttributeName,
|
||||||
|
PULONG AttributeType,
|
||||||
|
LPVOID AttributeData,
|
||||||
|
PULONG AttributeSize);
|
||||||
|
|
||||||
/* samspc.c */
|
/* samspc.c */
|
||||||
VOID SampStartRpcServer(VOID);
|
VOID SampStartRpcServer(VOID);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue