[LSASRV]
authorEric Kohl <eric.kohl@reactos.org>
Thu, 29 Nov 2012 22:02:22 +0000 (22:02 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 29 Nov 2012 22:02:22 +0000 (22:02 +0000)
- Fix object deletion.
- Add a registry wrapper function that enables us to delete registry keys which have already been opened.
- Make LsarDelete call LsarDeleteObject because otherwise object deletion would not be possible.

svn path=/trunk/; revision=57784

reactos/dll/win32/lsasrv/database.c
reactos/dll/win32/lsasrv/lsarpc.c
reactos/dll/win32/lsasrv/lsasrv.h
reactos/dll/win32/lsasrv/registry.c

index 3ca4363..1afa0a3 100644 (file)
@@ -796,7 +796,6 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
 
     NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
                                 0,
 
     NewObject = RtlAllocateHeap(RtlGetProcessHeap(),
                                 0,
-//                                sizeof(LSA_DB_OBJECT) + wcslen(ObjectName) + sizeof(WCHAR));
                                 sizeof(LSA_DB_OBJECT));
     if (NewObject == NULL)
     {
                                 sizeof(LSA_DB_OBJECT));
     if (NewObject == NULL)
     {
@@ -810,7 +809,6 @@ LsapOpenDbObject(IN PLSA_DB_OBJECT ParentObject,
     NewObject->Access = DesiredAccess;
     NewObject->KeyHandle = ObjectKeyHandle;
     NewObject->ParentObject = ParentObject;
     NewObject->Access = DesiredAccess;
     NewObject->KeyHandle = ObjectKeyHandle;
     NewObject->ParentObject = ParentObject;
-//    wcscpy(NewObject->Name, ObjectName);
 
     if (ParentObject != NULL)
         ParentObject->RefCount++;
 
     if (ParentObject != NULL)
         ParentObject->RefCount++;
@@ -901,10 +899,8 @@ NTSTATUS
 LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject)
 {
     PLSA_DB_OBJECT ParentObject = NULL;
 LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject)
 {
     PLSA_DB_OBJECT ParentObject = NULL;
-#if 0
     WCHAR KeyName[64];
     WCHAR KeyName[64];
-    ULONG EnumIndex;
-#endif
+    ULONG Index;
     NTSTATUS Status = STATUS_SUCCESS;
 
     DbObject->RefCount--;
     NTSTATUS Status = STATUS_SUCCESS;
 
     DbObject->RefCount--;
@@ -914,40 +910,36 @@ LsapDeleteDbObject(IN PLSA_DB_OBJECT DbObject)
 
     if (DbObject->KeyHandle != NULL)
     {
 
     if (DbObject->KeyHandle != NULL)
     {
-#if 0
-        EnumIndex = 0;
+        Index = 0;
 
         while (TRUE)
         {
             Status = LsapRegEnumerateSubKey(DbObject->KeyHandle,
 
         while (TRUE)
         {
             Status = LsapRegEnumerateSubKey(DbObject->KeyHandle,
-                                            EnumIndex,
+                                            Index,
                                             64 * sizeof(WCHAR),
                                             KeyName);
             if (!NT_SUCCESS(Status))
                 break;
 
                                             64 * sizeof(WCHAR),
                                             KeyName);
             if (!NT_SUCCESS(Status))
                 break;
 
-            TRACE("EnumIndex: %lu\n", EnumIndex);
+            TRACE("Index: %lu\n", Index);
             TRACE("Key name: %S\n", KeyName);
 
             TRACE("Key name: %S\n", KeyName);
 
-            Status = LsapRegDeleteKey(DbObject->KeyHandle,
-                                      KeyName);
+            Status = LsapRegDeleteSubKey(DbObject->KeyHandle,
+                                         KeyName);
             if (!NT_SUCCESS(Status))
                 break;
             if (!NT_SUCCESS(Status))
                 break;
-
-//            EnumIndex++;
         }
         }
-#endif
+
+        if (Status == STATUS_NO_MORE_ENTRIES)
+            Status = STATUS_SUCCESS;
+
+        LsapRegDeleteKey(DbObject->KeyHandle);
+
         NtClose(DbObject->KeyHandle);
     }
 
     if (DbObject->ParentObject != NULL)
         NtClose(DbObject->KeyHandle);
     }
 
     if (DbObject->ParentObject != NULL)
-    {
         ParentObject = DbObject->ParentObject;
         ParentObject = DbObject->ParentObject;
-#if 0
-        LsapRegDeleteKey(ParentObject->KeyHandle,
-                         DbObject->Name);
-#endif
-    }
 
     RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject);
 
 
     RtlFreeHeap(RtlGetProcessHeap(), 0, DbObject);
 
index 67375f0..db70223 100644 (file)
@@ -97,8 +97,7 @@ NTSTATUS WINAPI LsarClose(
 NTSTATUS WINAPI LsarDelete(
     LSAPR_HANDLE ObjectHandle)
 {
 NTSTATUS WINAPI LsarDelete(
     LSAPR_HANDLE ObjectHandle)
 {
-    /* Deprecated */
-    return STATUS_NOT_SUPPORTED;
+    return LsarDeleteObject(&ObjectHandle);
 }
 
 
 }
 
 
index 33af276..6488585 100644 (file)
@@ -48,7 +48,6 @@ typedef struct _LSA_DB_OBJECT
     ACCESS_MASK Access;
     HANDLE KeyHandle;
     struct _LSA_DB_OBJECT *ParentObject;
     ACCESS_MASK Access;
     HANDLE KeyHandle;
     struct _LSA_DB_OBJECT *ParentObject;
-    WCHAR Name[0];
 } LSA_DB_OBJECT, *PLSA_DB_OBJECT;
 
 #define LSAP_DB_SIGNATURE 0x12345678
 } LSA_DB_OBJECT, *PLSA_DB_OBJECT;
 
 #define LSAP_DB_SIGNATURE 0x12345678
@@ -282,8 +281,11 @@ LsapRegCreateKey(IN HANDLE ParentKeyHandle,
                  OUT HANDLE KeyHandle);
 
 NTSTATUS
                  OUT HANDLE KeyHandle);
 
 NTSTATUS
-LsapRegDeleteKey(IN HANDLE ParentKeyHandle,
-                 IN LPCWSTR KeyName);
+LsapRegDeleteSubKey(IN HANDLE ParentKeyHandle,
+                    IN LPCWSTR KeyName);
+
+NTSTATUS
+LsapRegDeleteKey(IN HANDLE KeyHandle);
 
 NTSTATUS
 LsapRegEnumerateSubKey(IN HANDLE KeyHandle,
 
 NTSTATUS
 LsapRegEnumerateSubKey(IN HANDLE KeyHandle,
index 80c083e..2775faa 100644 (file)
@@ -60,8 +60,8 @@ LsapRegCreateKey(IN HANDLE ParentKeyHandle,
 
 
 NTSTATUS
 
 
 NTSTATUS
-LsapRegDeleteKey(IN HANDLE ParentKeyHandle,
-                 IN LPCWSTR KeyName)
+LsapRegDeleteSubKey(IN HANDLE ParentKeyHandle,
+                    IN LPCWSTR KeyName)
 {
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING SubKeyName;
 {
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING SubKeyName;
@@ -89,6 +89,13 @@ LsapRegDeleteKey(IN HANDLE ParentKeyHandle,
 }
 
 
 }
 
 
+NTSTATUS
+LsapRegDeleteKey(IN HANDLE KeyHandle)
+{
+    return NtDeleteKey(KeyHandle);
+}
+
+
 NTSTATUS
 LsapRegEnumerateSubKey(IN HANDLE KeyHandle,
                        IN ULONG Index,
 NTSTATUS
 LsapRegEnumerateSubKey(IN HANDLE KeyHandle,
                        IN ULONG Index,