https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4293704ecb004a673d591…
commit 4293704ecb004a673d5910322d0d132165940251
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Dec 26 15:21:39 2023 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Dec 26 15:21:39 2023 +0900
[CTFMON] Unlink RegNotifyChangeKeyValue (#6232)
Dynamic load advapi32!RegNotifyChangeKeyValue function.
Output log if RegNotifyChangeKeyValue failed.
CORE-19362
---
base/applications/ctfmon/CRegWatcher.cpp | 39 ++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/base/applications/ctfmon/CRegWatcher.cpp
b/base/applications/ctfmon/CRegWatcher.cpp
index 1905956cb91..264d4f22d65 100644
--- a/base/applications/ctfmon/CRegWatcher.cpp
+++ b/base/applications/ctfmon/CRegWatcher.cpp
@@ -83,6 +83,31 @@ CRegWatcher::Uninit()
}
}
+// advapi32!RegNotifyChangeKeyValue
+typedef LONG (WINAPI *FN_RegNotifyChangeKeyValue)(HKEY, BOOL, DWORD, HANDLE, BOOL);
+
+LONG WINAPI
+DelayedRegNotifyChangeKeyValue(
+ HKEY hKey,
+ BOOL bWatchSubtree,
+ DWORD dwNotifyFilter,
+ HANDLE hEvent,
+ BOOL fAsynchronous)
+{
+ static FN_RegNotifyChangeKeyValue s_fnRegNotifyChangeKeyValue = NULL;
+
+ if (!s_fnRegNotifyChangeKeyValue)
+ {
+ HINSTANCE hAdvApi32 = cicGetSystemModuleHandle(TEXT("advapi32.dll"),
FALSE);
+ s_fnRegNotifyChangeKeyValue =
+ (FN_RegNotifyChangeKeyValue)GetProcAddress(hAdvApi32,
"RegNotifyChangeKeyValue");
+ if (!s_fnRegNotifyChangeKeyValue)
+ return ERROR_CALL_NOT_IMPLEMENTED;
+ }
+
+ return s_fnRegNotifyChangeKeyValue(hKey, bWatchSubtree, dwNotifyFilter, hEvent,
fAsynchronous);
+}
+
BOOL
CRegWatcher::InitEvent(
_In_ SIZE_T iEvent,
@@ -112,11 +137,15 @@ CRegWatcher::InitEvent(
}
// Start registry watching
- error = ::RegNotifyChangeKeyValue(entry.hKey,
- TRUE,
- REG_NOTIFY_CHANGE_LAST_SET |
REG_NOTIFY_CHANGE_NAME,
- s_ahWatchEvents[iEvent],
- TRUE);
+ error = DelayedRegNotifyChangeKeyValue(entry.hKey,
+ TRUE,
+ REG_NOTIFY_CHANGE_LAST_SET |
REG_NOTIFY_CHANGE_NAME,
+ s_ahWatchEvents[iEvent],
+ TRUE);
+#ifndef NDEBUG
+ if (error != ERROR_SUCCESS)
+ OutputDebugStringA("RegNotifyChangeKeyValue failed\n");
+#endif
return error == ERROR_SUCCESS;
}