https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ed125de9f35b742e397ff591eecc829289446ce0

commit ed125de9f35b742e397ff591eecc829289446ce0
Author:     Serge Gautherie <[email protected]>
AuthorDate: Sat May 7 00:49:29 2022 +0200
Commit:     George BiČ™oc <[email protected]>
CommitDate: Sun May 8 19:42:49 2022 +0200

    [SACDRV] Add 2 OBJ_KERNEL_HANDLE
    
    Match Zw*() uses.
    
    Plus:
    - GetRegistryValueBuffer(): Add missing ZwClose(Handle), Fix a copypasta.
    - SetRegistryValue(): 1 s/NtClose/ZwClose/.
    
    CORE-10207
---
 drivers/sac/driver/util.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/sac/driver/util.c b/drivers/sac/driver/util.c
index 3eef9025377..0e0722f4794 100644
--- a/drivers/sac/driver/util.c
+++ b/drivers/sac/driver/util.c
@@ -406,7 +406,7 @@ GetRegistryValueBuffer(IN PCWSTR KeyName,
     RtlInitUnicodeString(&DestinationString, KeyName);
     InitializeObjectAttributes(&ObjectAttributes,
                                &DestinationString,
-                               OBJ_CASE_INSENSITIVE,
+                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
                                NULL,
                                NULL);
     Status = ZwOpenKey(&Handle,
@@ -427,7 +427,8 @@ GetRegistryValueBuffer(IN PCWSTR KeyName,
                              NULL,
                              0,
                              &ResultLength);
-    if (!ResultLength) return Status;
+    if (!ResultLength)
+        goto Quit;
 
     /* Allocate the buffer for the partial info structure and our integer data 
*/
     ResultLength += sizeof(ULONG);
@@ -435,7 +436,7 @@ GetRegistryValueBuffer(IN PCWSTR KeyName,
     if (!*Buffer)
     {
         SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed 
allocation\n");
-        return Status;
+        goto Quit;
     }
 
     /* Now read the data */
@@ -452,8 +453,10 @@ GetRegistryValueBuffer(IN PCWSTR KeyName,
         SacFreePool(*Buffer);
     }
 
-    /* Return the result */
-    SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
+Quit:
+    /* Close the handle and exit */
+    ZwClose(Handle);
+    SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: Exiting.\n");
     return Status;
 }
 
@@ -478,7 +481,7 @@ SetRegistryValue(IN PCWSTR KeyName,
     RtlInitUnicodeString(&DestinationString, KeyName);
     InitializeObjectAttributes(&ObjectAttributes,
                                &DestinationString,
-                               OBJ_CASE_INSENSITIVE,
+                               OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
                                NULL,
                                NULL);
     Status = ZwOpenKey(&Handle,
@@ -501,7 +504,7 @@ SetRegistryValue(IN PCWSTR KeyName,
     }
 
     /* Close the handle and exit */
-    NtClose(Handle);
+    ZwClose(Handle);
     SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
     return Status;
 }

Reply via email to