From 81d435a181db3d7d0b93149dd61c971f5a0147ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 14 Oct 2018 00:29:04 +0200 Subject: [PATCH] [MKHIVE] Implement and use RegCloseKey(). --- sdk/tools/mkhive/mkhive.h | 4 ++++ sdk/tools/mkhive/reginf.c | 3 +++ sdk/tools/mkhive/registry.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/sdk/tools/mkhive/mkhive.h b/sdk/tools/mkhive/mkhive.h index 517925a6b63..82c8ecc2c33 100644 --- a/sdk/tools/mkhive/mkhive.h +++ b/sdk/tools/mkhive/mkhive.h @@ -89,6 +89,10 @@ RegSetValueExW( IN const UCHAR* lpData, IN ULONG cbData); +LONG WINAPI +RegCloseKey( + IN HKEY hKey); + LONG WINAPI RegDeleteKeyW( IN HKEY hKey, diff --git a/sdk/tools/mkhive/reginf.c b/sdk/tools/mkhive/reginf.c index c6087a96ba2..47f0d8525b7 100644 --- a/sdk/tools/mkhive/reginf.c +++ b/sdk/tools/mkhive/reginf.c @@ -463,8 +463,11 @@ registry_callback(HINF hInf, PWCHAR Section, BOOL Delete) /* and now do it */ if (!do_reg_operation(KeyHandle, ValuePtr, Context, Flags)) { + RegCloseKey(KeyHandle); return FALSE; } + + RegCloseKey(KeyHandle); } InfHostFreeContext(Context); diff --git a/sdk/tools/mkhive/registry.c b/sdk/tools/mkhive/registry.c index 1686fca08da..cd238dcd95e 100644 --- a/sdk/tools/mkhive/registry.c +++ b/sdk/tools/mkhive/registry.c @@ -485,6 +485,18 @@ RegpCreateOrOpenKey( return ERROR_SUCCESS; } +LONG WINAPI +RegCloseKey( + IN HKEY hKey) +{ + PMEMKEY Key = HKEY_TO_MEMKEY(hKey); // ParentKey + + /* Free the object */ + free(Key); + + return ERROR_SUCCESS; +} + LONG WINAPI RegCreateKeyW( IN HKEY hKey, @@ -942,6 +954,8 @@ RegInitializeRegistry( CreateSymLink(L"Registry\\Machine\\SYSTEM\\CurrentControlSet", NULL, ControlSetKey); + RegCloseKey(ControlSetKey); + #if 0 /* Link SECURITY to SAM */ CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM", L"\\Registry\\Machine\\SAM\\SAM"); -- 2.17.1