Skip to content

Commit

Permalink
[REGEDIT] Fix issue at Find registry key (#4341)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
zecarlos1957 committed Jun 19, 2022
1 parent 65d7fb1 commit 568383c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions base/applications/regedit/find.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 568383c

Please sign in to comment.