From: Jose Carlos Jesus Date: Sun, 19 Jun 2022 19:57:30 +0000 (+0100) Subject: [REGEDIT] Fix issue at Find registry key (#4341) X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=568383c9b91c2e529ae4a3609e416ec8044cfc23 [REGEDIT] Fix issue at Find registry key (#4341) - If we dont select a item as a starting point to search from, we need to set pszValueName to the first value name in current subkey. - Check pszSubKey length before calling RegFindRecurse. - Set focus to subkey when we search for it. --- diff --git a/base/applications/regedit/find.c b/base/applications/regedit/find.c index 1fb5bbe45a0..17de9b9b147 100644 --- a/base/applications/regedit/find.c +++ b/base/applications/regedit/find.c @@ -160,9 +160,6 @@ BOOL RegFindRecurse( if (lResult != ERROR_SUCCESS) return FALSE; - if (pszValueName == NULL) - pszValueName = s_empty; - lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL, &c, NULL, NULL, NULL, NULL); if (lResult != ERROR_SUCCESS) @@ -195,6 +192,9 @@ BOOL RegFindRecurse( qsort(ppszNames, c, sizeof(LPWSTR), compare); + if (pszValueName == NULL) + pszValueName = ppszNames[0]; + for(i = 0; i < c; i++) { if (DoEvents()) @@ -370,13 +370,14 @@ BOOL RegFindWalk( LPWSTR *ppszNames = NULL; hBaseKey = *phKey; + + if (wcslen(pszSubKey) >= _countof(szSubKey)) + return FALSE; + if (RegFindRecurse(hBaseKey, pszSubKey, pszValueName, ppszFoundSubKey, ppszFoundValueName)) return TRUE; - if (wcslen(pszSubKey) >= MAX_PATH) - return FALSE; - wcscpy(szSubKey, pszSubKey); while(szSubKey[0] != 0) { @@ -687,10 +688,18 @@ BOOL FindNext(HWND hWnd) { GetKeyName(szFullKey, COUNT_OF(szFullKey), hKeyRoot, pszFoundSubKey); SelectNode(g_pChildWnd->hTreeWnd, szFullKey); - SetValueName(g_pChildWnd->hListWnd, pszFoundValueName); free(pszFoundSubKey); - free(pszFoundValueName); - SetFocus(g_pChildWnd->hListWnd); + + if (pszFoundValueName != NULL) + { + SetValueName(g_pChildWnd->hListWnd, pszFoundValueName); + free(pszFoundValueName); + SetFocus(g_pChildWnd->hListWnd); + } + else + { + SetFocus(g_pChildWnd->hTreeWnd); + } } return fSuccess || s_bAbort; }