aboutsummaryrefslogtreecommitdiffstats
path: root/api/registry.c
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2020-10-23 22:04:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2020-10-30 16:51:01 +0100
commit84c066fa798a4d669f9fa3145a29ed9d46db47d5 (patch)
tree51ddf7fae7fe213e1130daf7f0c306892792a8c7 /api/registry.c
parentapi: connect rundll32 child with parent using stdout and stderr (diff)
downloadwintun-84c066fa798a4d669f9fa3145a29ed9d46db47d5.tar.xz
wintun-84c066fa798a4d669f9fa3145a29ed9d46db47d5.zip
api: revise logging
RegistryQueryString() may produce one or more "File not found" errors when called from RegistryQueryStringWait() - which is expected while waiting. Those errors were annoying and awkward to read in the log. Furthermore, should RegistryQueryString() fail, it already displays detailed Windows error message and the parent's logging was simplified to prevent repetitions in the log. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'api/registry.c')
-rw-r--r--api/registry.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/api/registry.c b/api/registry.c
index a36b27e..f1e2372 100644
--- a/api/registry.c
+++ b/api/registry.c
@@ -180,7 +180,8 @@ RegistryQuery(
_In_opt_z_ const WCHAR *Name,
_Out_opt_ DWORD *ValueType,
_Out_ void **Buf,
- _Inout_ DWORD *BufLen)
+ _Inout_ DWORD *BufLen,
+ _In_ BOOL Log)
{
HANDLE Heap = GetProcessHeap();
for (;;)
@@ -193,15 +194,15 @@ RegistryQuery(
return ERROR_SUCCESS;
HeapFree(Heap, 0, *Buf);
if (Result != ERROR_MORE_DATA)
- return LOG_ERROR(L"Querying value failed", Result);
+ return Log ? LOG_ERROR(L"Querying value failed", Result) : Result;
}
}
WINTUN_STATUS
-RegistryQueryString(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _Out_ WCHAR **Value)
+RegistryQueryString(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _Out_ WCHAR **Value, _In_ BOOL Log)
{
DWORD ValueType, Size = 256 * sizeof(WCHAR);
- DWORD Result = RegistryQuery(Key, Name, &ValueType, Value, &Size);
+ DWORD Result = RegistryQuery(Key, Name, &ValueType, Value, &Size, Log);
if (Result != ERROR_SUCCESS)
return Result;
switch (ValueType)
@@ -236,7 +237,7 @@ RegistryQueryStringWait(_In_ HKEY Key, _In_opt_z_ const WCHAR *Name, _In_ DWORD
LOG_ERROR(L"Failed to setup notification", Result);
break;
}
- Result = RegistryQueryString(Key, Name, Value);
+ Result = RegistryQueryString(Key, Name, Value, FALSE);
if (Result != ERROR_FILE_NOT_FOUND && Result != ERROR_PATH_NOT_FOUND)
break;
LONGLONG TimeLeft = Deadline - GetTickCount64();