ReactOS 0.4.15-dev-5664-g3bf4ef6
find.c File Reference
#include "regedit.h"
Include dependency graph for find.c:

Go to the source code of this file.

Macros

#define RSF_WHOLESTRING   0x00000001
 
#define RSF_LOOKATKEYS   0x00000002
 
#define RSF_LOOKATVALUES   0x00000004
 
#define RSF_LOOKATDATA   0x00000008
 
#define RSF_MATCHCASE   0x00010000
 

Functions

VOID SetValueName (HWND hwndLV, LPCWSTR pszValueName)
 
BOOL DoEvents (VOID)
 
static LPWSTR lstrstri (LPCWSTR psz1, LPCWSTR psz2)
 
static BOOL CompareName (LPCWSTR pszName1, LPCWSTR pszName2)
 
static BOOL CompareData (DWORD dwType, LPCWSTR psz1, LPCWSTR psz2)
 
int compare (const void *x, const void *y)
 
BOOL RegFindRecurse (HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValueName, LPWSTR *ppszFoundSubKey, LPWSTR *ppszFoundValueName)
 
BOOL RegFindWalk (HKEY *phKey, LPCWSTR pszSubKey, LPCWSTR pszValueName, LPWSTR *ppszFoundSubKey, LPWSTR *ppszFoundValueName)
 
static DWORD GetFindFlags (void)
 
static void SetFindFlags (DWORD dwFlags)
 
static INT_PTR CALLBACK AbortFindDialogProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL FindNext (HWND hWnd)
 
static INT_PTR CALLBACK FindDialogProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void FindNextMessageBox (HWND hWnd)
 
void FindDialog (HWND hWnd)
 

Variables

static WCHAR s_szFindWhat [256]
 
static const WCHAR s_szFindFlags [] = L"FindFlags"
 
static const WCHAR s_szFindFlagsR [] = L"FindFlagsReactOS"
 
static HWND s_hwndAbortDialog
 
static BOOL s_bAbort
 
static DWORD s_dwFlags
 
static WCHAR s_szName [MAX_PATH]
 
static DWORD s_cchName
 
static const WCHAR s_empty [] = L""
 
static const WCHAR s_backslash [] = L"\\"
 

Macro Definition Documentation

◆ RSF_LOOKATDATA

#define RSF_LOOKATDATA   0x00000008

Definition at line 24 of file find.c.

◆ RSF_LOOKATKEYS

#define RSF_LOOKATKEYS   0x00000002

Definition at line 22 of file find.c.

◆ RSF_LOOKATVALUES

#define RSF_LOOKATVALUES   0x00000004

Definition at line 23 of file find.c.

◆ RSF_MATCHCASE

#define RSF_MATCHCASE   0x00010000

Definition at line 25 of file find.c.

◆ RSF_WHOLESTRING

#define RSF_WHOLESTRING   0x00000001

Definition at line 21 of file find.c.

Function Documentation

◆ AbortFindDialogProc()

static INT_PTR CALLBACK AbortFindDialogProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 604 of file find.c.

605{
608
609 switch(uMsg)
610 {
611 case WM_CLOSE:
612 s_bAbort = TRUE;
613 break;
614
615 case WM_COMMAND:
616 switch(HIWORD(wParam))
617 {
618 case BN_CLICKED:
619 switch(LOWORD(wParam))
620 {
621 case IDCANCEL:
622 s_bAbort = TRUE;
623 break;
624 }
625 break;
626 }
627 break;
628 }
629 return 0;
630}
static BOOL s_bAbort
Definition: find.c:31
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define LOWORD(l)
Definition: pedump.c:82
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_CLOSE
Definition: winuser.h:1611
#define IDCANCEL
Definition: winuser.h:825
#define WM_COMMAND
Definition: winuser.h:1730
#define BN_CLICKED
Definition: winuser.h:1915

Referenced by FindNext().

◆ compare()

int compare ( const void x,
const void y 
)

Definition at line 128 of file find.c.

129{
130 const LPCWSTR *a = (const LPCWSTR *)x;
131 const LPCWSTR *b = (const LPCWSTR *)y;
132 return _wcsicmp(*a, *b);
133}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

◆ CompareData()

static BOOL CompareData ( DWORD  dwType,
LPCWSTR  psz1,
LPCWSTR  psz2 
)
static

Definition at line 91 of file find.c.

95{
96 INT i, cch1 = wcslen(psz1), cch2 = wcslen(psz2);
97 if (dwType == REG_SZ || dwType == REG_EXPAND_SZ)
98 {
100 {
103 psz1, cch1, psz2, cch2);
104 else
106 NORM_IGNORECASE, psz1, cch1, psz2, cch2);
107 }
108
109 for(i = 0; i <= cch1 - cch2; i++)
110 {
112 {
114 psz1 + i, cch2, psz2, cch2))
115 return TRUE;
116 }
117 else
118 {
120 NORM_IGNORECASE, psz1 + i, cch2, psz2, cch2))
121 return TRUE;
122 }
123 }
124 }
125 return FALSE;
126}
#define RSF_MATCHCASE
Definition: find.c:25
#define RSF_WHOLESTRING
Definition: find.c:21
static DWORD s_dwFlags
Definition: find.c:33
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: lang.c:2279
#define REG_SZ
Definition: layer.c:22
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define LOCALE_SYSTEM_DEFAULT
int32_t INT
Definition: typedefs.h:58
#define NORM_IGNORECASE
Definition: winnls.h:176

Referenced by RegFindRecurse().

◆ CompareName()

static BOOL CompareName ( LPCWSTR  pszName1,
LPCWSTR  pszName2 
)
static

Definition at line 72 of file find.c.

73{
75 {
77 return wcscmp(pszName1, pszName2) == 0;
78 else
79 return _wcsicmp(pszName1, pszName2) == 0;
80 }
81 else
82 {
84 return wcsstr(pszName1, pszName2) != NULL;
85 else
86 return lstrstri(pszName1, pszName2) != NULL;
87 }
88}
static LPWSTR lstrstri(LPCWSTR psz1, LPCWSTR psz2)
Definition: find.c:57
#define NULL
Definition: types.h:112
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by LdrGetDllHandleEx(), LdrpCompareResourceNames_U(), RegFindRecurse(), and RegFindWalk().

◆ DoEvents()

BOOL DoEvents ( VOID  )

Definition at line 41 of file find.c.

42{
43 MSG msg;
44 if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
45 {
46 if (msg.message == WM_QUIT)
47 s_bAbort = TRUE;
49 {
52 }
53 }
54 return s_bAbort;
55}
#define msg(x)
Definition: auth_time.c:54
static HWND s_hwndAbortDialog
Definition: find.c:30
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WM_QUIT
Definition: winuser.h:1613
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI IsDialogMessageW(_In_ HWND, _In_ LPMSG)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1186
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)

Referenced by RegFindRecurse(), and RegFindWalk().

◆ FindDialog()

void FindDialog ( HWND  hWnd)

Definition at line 834 of file find.c.

835{
837 hWnd, FindDialogProc, 0) != 0)
838 {
840 }
841}
HWND hWnd
Definition: settings.c:17
void FindNextMessageBox(HWND hWnd)
Definition: find.c:822
static INT_PTR CALLBACK FindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: find.c:707
#define IDD_FIND
Definition: resource.h:48
#define GetModuleHandle
Definition: winbase.h:3698
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by _CmdWndProc(), and FindNext().

◆ FindDialogProc()

static INT_PTR CALLBACK FindDialogProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 707 of file find.c.

708{
709 INT_PTR iResult = 0;
710 HWND hControl;
711 LONG lStyle;
713 static WCHAR s_szSavedFindValue[256];
714
715 switch(uMsg)
716 {
717 case WM_INITDIALOG:
719
720 hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
721 if (hControl)
723
724 hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
725 if (hControl)
727
728 hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
729 if (hControl)
731
732 /* Match whole string */
733 hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
734 if (hControl)
736
737 /* Case sensitivity */
738 hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
739 if (hControl)
741
742 hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
743 if (hControl)
744 {
745 SetWindowTextW(hControl, s_szSavedFindValue);
746 SetFocus(hControl);
747 SendMessageW(hControl, EM_SETSEL, 0, -1);
748 }
749 break;
750
751 case WM_CLOSE:
752 EndDialog(hDlg, 0);
753 break;
754
755 case WM_COMMAND:
756 switch(HIWORD(wParam))
757 {
758 case BN_CLICKED:
759 switch(LOWORD(wParam))
760 {
761 case IDOK:
762 dwFlags = 0;
763
764 hControl = GetDlgItem(hDlg, IDC_LOOKAT_KEYS);
765 if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
767
768 hControl = GetDlgItem(hDlg, IDC_LOOKAT_VALUES);
769 if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
771
772 hControl = GetDlgItem(hDlg, IDC_LOOKAT_DATA);
773 if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
775
776 hControl = GetDlgItem(hDlg, IDC_MATCHSTRING);
777 if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
779
780 hControl = GetDlgItem(hDlg, IDC_MATCHCASE);
781 if (hControl && (SendMessageW(hControl, BM_GETCHECK, 0, 0) == BST_CHECKED))
783
785
786 hControl = GetDlgItem(hDlg, IDC_FINDWHAT);
787 if (hControl)
789 EndDialog(hDlg, 1);
790 break;
791
792 case IDCANCEL:
793 EndDialog(hDlg, 0);
794 break;
795 }
796 break;
797
798 case EN_CHANGE:
799 switch(LOWORD(wParam))
800 {
801 case IDC_FINDWHAT:
802 GetWindowTextW((HWND) lParam, s_szSavedFindValue, ARRAY_SIZE(s_szSavedFindValue));
803 hControl = GetDlgItem(hDlg, IDOK);
804 if (hControl)
805 {
806 lStyle = GetWindowLongPtr(hControl, GWL_STYLE);
807 if (s_szSavedFindValue[0])
808 lStyle &= ~WS_DISABLED;
809 else
810 lStyle |= WS_DISABLED;
811 SetWindowLongPtr(hControl, GWL_STYLE, lStyle);
813 }
814 break;
815 }
816 }
817 break;
818 }
819 return iResult;
820}
#define ARRAY_SIZE(a)
Definition: main.h:24
static void SetFindFlags(DWORD dwFlags)
Definition: find.c:586
#define RSF_LOOKATVALUES
Definition: find.c:23
#define RSF_LOOKATDATA
Definition: find.c:24
static DWORD GetFindFlags(void)
Definition: find.c:557
static WCHAR s_szFindWhat[256]
Definition: find.c:27
#define RSF_LOOKATKEYS
Definition: find.c:22
#define IDC_LOOKAT_DATA
Definition: resource.h:270
#define IDC_LOOKAT_VALUES
Definition: resource.h:269
#define IDC_FINDWHAT
Definition: resource.h:267
#define IDC_MATCHSTRING
Definition: resource.h:271
#define IDC_LOOKAT_KEYS
Definition: resource.h:268
#define IDC_MATCHCASE
Definition: resource.h:272
unsigned long DWORD
Definition: ntddk_ex.h:95
long LONG
Definition: pedump.c:60
#define WS_DISABLED
Definition: pedump.c:621
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
int32_t INT_PTR
Definition: typedefs.h:64
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define WM_INITDIALOG
Definition: winuser.h:1729
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:824
#define BM_SETCHECK
Definition: winuser.h:1911
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define EM_SETSEL
Definition: winuser.h:2008
#define GWL_STYLE
Definition: winuser.h:846
#define RDW_INVALIDATE
Definition: winuser.h:1204
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1908
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
#define EN_CHANGE
Definition: winuser.h:2012
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by FindDialog().

◆ FindNext()

BOOL FindNext ( HWND  hWnd)

Definition at line 632 of file find.c.

633{
634 HKEY hKeyRoot;
635 LPCWSTR pszKeyPath;
636 BOOL fSuccess;
637 WCHAR szFullKey[512];
638 LPCWSTR pszValueName;
639 LPWSTR pszFoundSubKey, pszFoundValueName;
640
641 if (wcslen(s_szFindWhat) == 0)
642 {
644 return TRUE;
645 }
646
648
649 pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
650 if (pszKeyPath == NULL)
651 {
652 hKeyRoot = HKEY_CLASSES_ROOT;
653 pszKeyPath = s_empty;
654 }
655
656 /* Create abort find dialog */
660 {
663 }
664 s_bAbort = FALSE;
665
666 pszValueName = GetValueName(g_pChildWnd->hListWnd, -1);
667
672
673 fSuccess = RegFindWalk(&hKeyRoot, pszKeyPath, pszValueName,
674 &pszFoundSubKey, &pszFoundValueName);
675
680
682 {
685 }
686
687 if (fSuccess)
688 {
689 GetKeyName(szFullKey, ARRAY_SIZE(szFullKey), hKeyRoot, pszFoundSubKey);
690 SelectNode(g_pChildWnd->hTreeWnd, szFullKey);
691 free(pszFoundSubKey);
692
693 if (pszFoundValueName != NULL)
694 {
695 SetValueName(g_pChildWnd->hListWnd, pszFoundValueName);
696 free(pszFoundValueName);
698 }
699 else
700 {
702 }
703 }
704 return fSuccess || s_bAbort;
705}
ChildWnd * g_pChildWnd
Definition: childwnd.c:23
BOOL GetKeyName(LPWSTR pszDest, size_t iDestLength, HKEY hRootKey, LPCWSTR lpSubKey)
Definition: edit.c:1588
VOID SetValueName(HWND hwndLV, LPCWSTR pszValueName)
Definition: listview.c:84
BOOL RegFindWalk(HKEY *phKey, LPCWSTR pszSubKey, LPCWSTR pszValueName, LPWSTR *ppszFoundSubKey, LPWSTR *ppszFoundValueName)
Definition: find.c:356
static const WCHAR s_empty[]
Definition: find.c:36
static INT_PTR CALLBACK AbortFindDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: find.c:604
void FindDialog(HWND hWnd)
Definition: find.c:834
WCHAR * GetValueName(HWND hwndLV, int iStartAt)
Definition: listview.c:55
HWND hFrameWnd
Definition: main.c:35
BOOL SelectNode(HWND hwndTV, LPCWSTR keyPath)
Definition: treeview.c:773
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
#define IDD_FINDING
Definition: resource.h:49
#define free
Definition: debug_ros.c:5
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND hTreeWnd
Definition: main.h:63
HWND hListWnd
Definition: main.h:64
HWND hAddressBarWnd
Definition: main.h:65
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4271
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI DestroyWindow(_In_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by FindNextMessageBox().

◆ FindNextMessageBox()

void FindNextMessageBox ( HWND  hWnd)

Definition at line 822 of file find.c.

823{
824 if (!FindNext(hWnd))
825 {
826 WCHAR msg[128], caption[128];
827
829 LoadStringW(hInst, IDS_APP_TITLE, caption, ARRAY_SIZE(caption));
831 }
832}
#define IDS_APP_TITLE
Definition: resource.h:10
BOOL FindNext(HWND hWnd)
Definition: find.c:632
#define IDS_FINISHEDFIND
Definition: resource.h:199
HINSTANCE hInst
Definition: dxdiag.c:13
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONINFORMATION
Definition: winuser.h:796

Referenced by _CmdWndProc(), and FindDialog().

◆ GetFindFlags()

static DWORD GetFindFlags ( void  )
static

Definition at line 557 of file find.c.

558{
559 HKEY hKey;
560 DWORD dwType, dwValue, cbData;
562
564 {
565 /* Retrieve flags from registry key */
566 cbData = sizeof(dwValue);
567 if (RegQueryValueExW(hKey, s_szFindFlags, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
568 {
569 if (dwType == REG_DWORD)
570 dwFlags = (dwFlags & ~0x0000FFFF) | ((dwValue & 0x0000FFFF) << 0);
571 }
572
573 /* Retrieve ReactOS Regedit specific flags from registry key */
574 cbData = sizeof(dwValue);
575 if (RegQueryValueExW(hKey, s_szFindFlagsR, NULL, &dwType, (LPBYTE) &dwValue, &cbData) == ERROR_SUCCESS)
576 {
577 if (dwType == REG_DWORD)
578 dwFlags = (dwFlags & ~0xFFFF0000) | ((dwValue & 0x0000FFFF) << 16);
579 }
580
582 }
583 return dwFlags;
584}
const TCHAR g_szGeneralRegKey[]
Definition: settings.c:16
static const WCHAR s_szFindFlagsR[]
Definition: find.c:29
static const WCHAR s_szFindFlags[]
Definition: find.c:28
#define RegCloseKey(hKey)
Definition: registry.h:47
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4121
FxAutoRegKey hKey
#define REG_DWORD
Definition: sdbapi.c:596
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by FindDialogProc(), and FindNext().

◆ lstrstri()

static LPWSTR lstrstri ( LPCWSTR  psz1,
LPCWSTR  psz2 
)
static

Definition at line 57 of file find.c.

58{
59 INT i, cch1, cch2;
60
61 cch1 = wcslen(psz1);
62 cch2 = wcslen(psz2);
63 for(i = 0; i <= cch1 - cch2; i++)
64 {
66 psz1 + i, cch2, psz2, cch2) == 2)
67 return (LPWSTR) (psz1 + i);
68 }
69 return NULL;
70}

Referenced by CompareName().

◆ RegFindRecurse()

BOOL RegFindRecurse ( HKEY  hKey,
LPCWSTR  pszSubKey,
LPCWSTR  pszValueName,
LPWSTR ppszFoundSubKey,
LPWSTR ppszFoundValueName 
)

Definition at line 135 of file find.c.

141{
142 HKEY hSubKey;
143 LONG lResult;
144 WCHAR szSubKey[MAX_PATH];
145 DWORD i, c, cb, type;
146 BOOL fPast = FALSE;
147 LPWSTR *ppszNames = NULL;
148 LPBYTE pb = NULL;
149
150 if (DoEvents())
151 return FALSE;
152
153 if(wcslen(pszSubKey) >= _countof(szSubKey))
154 return FALSE;
155
156 wcscpy(szSubKey, pszSubKey);
157 hSubKey = NULL;
158
159 lResult = RegOpenKeyExW(hKey, szSubKey, 0, KEY_ALL_ACCESS, &hSubKey);
160 if (lResult != ERROR_SUCCESS)
161 return FALSE;
162
163 lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL, NULL, NULL,
164 &c, NULL, NULL, NULL, NULL);
165 if (lResult != ERROR_SUCCESS)
166 goto err;
167 ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
168 if (ppszNames == NULL)
169 goto err;
170 ZeroMemory(ppszNames, c * sizeof(LPWSTR));
171
172 for(i = 0; i < c; i++)
173 {
174 if (DoEvents())
175 goto err;
176
178 lResult = RegEnumValueW(hSubKey, i, s_szName, &s_cchName, NULL, NULL,
179 NULL, &cb);
180 if (lResult == ERROR_NO_MORE_ITEMS)
181 {
182 c = i;
183 break;
184 }
185 if (lResult != ERROR_SUCCESS)
186 goto err;
188 continue;
189
190 ppszNames[i] = _wcsdup(s_szName);
191 }
192
193 qsort(ppszNames, c, sizeof(LPWSTR), compare);
194
195 if (pszValueName == NULL)
196 pszValueName = ppszNames[0];
197
198 for(i = 0; i < c; i++)
199 {
200 if (DoEvents())
201 goto err;
202
203 if (!fPast && _wcsicmp(ppszNames[i], pszValueName) == 0)
204 {
205 fPast = TRUE;
206 continue;
207 }
208 if (!fPast)
209 continue;
210
211 if ((s_dwFlags & RSF_LOOKATVALUES) &&
212 CompareName(ppszNames[i], s_szFindWhat))
213 {
214 *ppszFoundSubKey = _wcsdup(szSubKey);
215 if (ppszNames[i][0] == 0)
216 *ppszFoundValueName = NULL;
217 else
218 *ppszFoundValueName = _wcsdup(ppszNames[i]);
219 goto success;
220 }
221
222 lResult = RegQueryValueExW(hSubKey, ppszNames[i], NULL, &type,
223 NULL, &cb);
224 if (lResult != ERROR_SUCCESS)
225 goto err;
226 pb = malloc(cb);
227 if (pb == NULL)
228 goto err;
229 lResult = RegQueryValueExW(hSubKey, ppszNames[i], NULL, &type,
230 pb, &cb);
231 if (lResult != ERROR_SUCCESS)
232 goto err;
233
234 if ((s_dwFlags & RSF_LOOKATDATA) &&
236 {
237 *ppszFoundSubKey = _wcsdup(szSubKey);
238 if (ppszNames[i][0] == 0)
239 *ppszFoundValueName = NULL;
240 else
241 *ppszFoundValueName = _wcsdup(ppszNames[i]);
242 goto success;
243 }
244 free(pb);
245 pb = NULL;
246 }
247
248 if (ppszNames != NULL)
249 {
250 for(i = 0; i < c; i++)
251 free(ppszNames[i]);
252 free(ppszNames);
253 }
254 ppszNames = NULL;
255
256 lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
257 NULL, NULL, NULL, NULL, NULL);
258 if (lResult != ERROR_SUCCESS)
259 goto err;
260 ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
261 if (ppszNames == NULL)
262 goto err;
263 ZeroMemory(ppszNames, c * sizeof(LPWSTR));
264
265 for(i = 0; i < c; i++)
266 {
267 if (DoEvents())
268 goto err;
269
271 lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cchName, NULL, NULL,
272 NULL, NULL);
273 if (lResult == ERROR_NO_MORE_ITEMS)
274 {
275 c = i;
276 break;
277 }
278 if (lResult != ERROR_SUCCESS)
279 goto err;
281 continue;
282
283 ppszNames[i] = _wcsdup(s_szName);
284 }
285
286 qsort(ppszNames, c, sizeof(LPWSTR), compare);
287
288 for(i = 0; i < c; i++)
289 {
290 if (DoEvents())
291 goto err;
292
293 if ((s_dwFlags & RSF_LOOKATKEYS) &&
294 CompareName(ppszNames[i], s_szFindWhat))
295 {
296 *ppszFoundSubKey = malloc(
297 (wcslen(szSubKey) + wcslen(ppszNames[i]) + 2) *
298 sizeof(WCHAR));
299 if (*ppszFoundSubKey == NULL)
300 goto err;
301 if (szSubKey[0])
302 {
303 wcscpy(*ppszFoundSubKey, szSubKey);
304 wcscat(*ppszFoundSubKey, s_backslash);
305 }
306 else
307 **ppszFoundSubKey = 0;
308 wcscat(*ppszFoundSubKey, ppszNames[i]);
309 *ppszFoundValueName = NULL;
310 goto success;
311 }
312
313 if (RegFindRecurse(hSubKey, ppszNames[i], NULL, ppszFoundSubKey,
314 ppszFoundValueName))
315 {
316 LPWSTR psz = *ppszFoundSubKey;
317 *ppszFoundSubKey = malloc(
318 (wcslen(szSubKey) + wcslen(psz) + 2) * sizeof(WCHAR));
319 if (*ppszFoundSubKey == NULL)
320 goto err;
321 if (szSubKey[0])
322 {
323 wcscpy(*ppszFoundSubKey, szSubKey);
324 wcscat(*ppszFoundSubKey, s_backslash);
325 }
326 else
327 **ppszFoundSubKey = 0;
328 wcscat(*ppszFoundSubKey, psz);
329 free(psz);
330 goto success;
331 }
332 }
333
334err:
335 if (ppszNames != NULL)
336 {
337 for(i = 0; i < c; i++)
338 free(ppszNames[i]);
339 free(ppszNames);
340 }
341 free(pb);
342 RegCloseKey(hSubKey);
343 return FALSE;
344
345success:
346 if (ppszNames != NULL)
347 {
348 for(i = 0; i < c; i++)
349 free(ppszNames[i]);
350 free(ppszNames);
351 }
352 RegCloseKey(hSubKey);
353 return TRUE;
354}
BOOL RegFindRecurse(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValueName, LPWSTR *ppszFoundSubKey, LPWSTR *ppszFoundValueName)
Definition: find.c:135
static WCHAR s_szName[MAX_PATH]
Definition: find.c:34
static BOOL CompareName(LPCWSTR pszName1, LPCWSTR pszName2)
Definition: find.c:72
static DWORD s_cchName
Definition: find.c:35
static BOOL CompareData(DWORD dwType, LPCWSTR psz1, LPCWSTR psz2)
Definition: find.c:91
BOOL DoEvents(VOID)
Definition: find.c:41
static const WCHAR s_backslash[]
Definition: find.c:37
#define malloc
Definition: debug_ros.c:4
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3690
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define err(...)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define _countof(array)
Definition: sndvol32.h:68
Definition: bug.cpp:8
#define success(from, fromstr, to, tostr)
#define ZeroMemory
Definition: winbase.h:1670

Referenced by RegFindRecurse(), and RegFindWalk().

◆ RegFindWalk()

BOOL RegFindWalk ( HKEY phKey,
LPCWSTR  pszSubKey,
LPCWSTR  pszValueName,
LPWSTR ppszFoundSubKey,
LPWSTR ppszFoundValueName 
)

Definition at line 356 of file find.c.

362{
363 LONG lResult;
364 DWORD i, c;
365 HKEY hBaseKey, hSubKey;
366 WCHAR szKeyName[MAX_PATH];
367 WCHAR szSubKey[MAX_PATH];
368 LPWSTR pch;
369 BOOL fPast;
370 LPWSTR *ppszNames = NULL;
371
372 hBaseKey = *phKey;
373
374 if (wcslen(pszSubKey) >= _countof(szSubKey))
375 return FALSE;
376
377 if (RegFindRecurse(hBaseKey, pszSubKey, pszValueName, ppszFoundSubKey,
378 ppszFoundValueName))
379 return TRUE;
380
381 wcscpy(szSubKey, pszSubKey);
382 while(szSubKey[0] != 0)
383 {
384 if (DoEvents())
385 return FALSE;
386
387 pch = wcsrchr(szSubKey, L'\\');
388 if (pch == NULL)
389 {
390 wcscpy(szKeyName, szSubKey);
391 szSubKey[0] = 0;
392 hSubKey = hBaseKey;
393 }
394 else
395 {
396 lstrcpynW(szKeyName, pch + 1, MAX_PATH);
397 *pch = 0;
398 lResult = RegOpenKeyExW(hBaseKey, szSubKey, 0, KEY_ALL_ACCESS,
399 &hSubKey);
400 if (lResult != ERROR_SUCCESS)
401 return FALSE;
402 }
403
404 lResult = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, &c, NULL, NULL,
405 NULL, NULL, NULL, NULL, NULL);
406 if (lResult != ERROR_SUCCESS)
407 goto err;
408
409 ppszNames = (LPWSTR *) malloc(c * sizeof(LPWSTR));
410 if (ppszNames == NULL)
411 goto err;
412 ZeroMemory(ppszNames, c * sizeof(LPWSTR));
413
414 for(i = 0; i < c; i++)
415 {
416 if (DoEvents())
417 goto err;
418
420 lResult = RegEnumKeyExW(hSubKey, i, s_szName, &s_cchName,
421 NULL, NULL, NULL, NULL);
422 if (lResult == ERROR_NO_MORE_ITEMS)
423 {
424 c = i;
425 break;
426 }
427 if (lResult != ERROR_SUCCESS)
428 break;
429 ppszNames[i] = _wcsdup(s_szName);
430 }
431
432 qsort(ppszNames, c, sizeof(LPWSTR), compare);
433
434 fPast = FALSE;
435 for(i = 0; i < c; i++)
436 {
437 if (DoEvents())
438 goto err;
439
440 if (!fPast && _wcsicmp(ppszNames[i], szKeyName) == 0)
441 {
442 fPast = TRUE;
443 continue;
444 }
445 if (!fPast)
446 continue;
447
448 if ((s_dwFlags & RSF_LOOKATKEYS) &&
449 CompareName(ppszNames[i], s_szFindWhat))
450 {
451 *ppszFoundSubKey = malloc(
452 (wcslen(szSubKey) + wcslen(ppszNames[i]) + 2) *
453 sizeof(WCHAR));
454 if (*ppszFoundSubKey == NULL)
455 goto err;
456 if (szSubKey[0])
457 {
458 wcscpy(*ppszFoundSubKey, szSubKey);
459 wcscat(*ppszFoundSubKey, s_backslash);
460 }
461 else
462 **ppszFoundSubKey = 0;
463 wcscat(*ppszFoundSubKey, ppszNames[i]);
464 *ppszFoundValueName = NULL;
465 goto success;
466 }
467
468 if (RegFindRecurse(hSubKey, ppszNames[i], NULL,
469 ppszFoundSubKey, ppszFoundValueName))
470 {
471 LPWSTR psz = *ppszFoundSubKey;
472 *ppszFoundSubKey = malloc(
473 (wcslen(szSubKey) + wcslen(psz) + 2) *
474 sizeof(WCHAR));
475 if (*ppszFoundSubKey == NULL)
476 goto err;
477 if (szSubKey[0])
478 {
479 wcscpy(*ppszFoundSubKey, szSubKey);
480 wcscat(*ppszFoundSubKey, s_backslash);
481 }
482 else
483 **ppszFoundSubKey = 0;
484 wcscat(*ppszFoundSubKey, psz);
485 free(psz);
486 goto success;
487 }
488 }
489 if (ppszNames != NULL)
490 {
491 for(i = 0; i < c; i++)
492 free(ppszNames[i]);
493 free(ppszNames);
494 }
495 ppszNames = NULL;
496
497 if (hBaseKey != hSubKey)
498 RegCloseKey(hSubKey);
499 }
500
501 if (*phKey == HKEY_CLASSES_ROOT)
502 {
503 *phKey = HKEY_CURRENT_USER;
504 if (RegFindRecurse(*phKey, s_empty, NULL, ppszFoundSubKey,
505 ppszFoundValueName))
506 return TRUE;
507 }
508
509 if (*phKey == HKEY_CURRENT_USER)
510 {
511 *phKey = HKEY_LOCAL_MACHINE;
512 if (RegFindRecurse(*phKey, s_empty, NULL, ppszFoundSubKey,
513 ppszFoundValueName))
514 goto success;
515 }
516
517 if (*phKey == HKEY_LOCAL_MACHINE)
518 {
519 *phKey = HKEY_USERS;
520 if (RegFindRecurse(*phKey, s_empty, NULL, ppszFoundSubKey,
521 ppszFoundValueName))
522 goto success;
523 }
524
525 if (*phKey == HKEY_USERS)
526 {
527 *phKey = HKEY_CURRENT_CONFIG;
528 if (RegFindRecurse(*phKey, s_empty, NULL, ppszFoundSubKey,
529 ppszFoundValueName))
530 goto success;
531 }
532
533err:
534 if (ppszNames != NULL)
535 {
536 for(i = 0; i < c; i++)
537 free(ppszNames[i]);
538 free(ppszNames);
539 }
540 if (hBaseKey != hSubKey)
541 RegCloseKey(hSubKey);
542 return FALSE;
543
544success:
545 if (ppszNames != NULL)
546 {
547 for(i = 0; i < c; i++)
548 free(ppszNames[i]);
549 free(ppszNames);
550 }
551 if (hBaseKey != hSubKey)
552 RegCloseKey(hSubKey);
553 return TRUE;
554}
#define wcsrchr
Definition: compat.h:16
#define lstrcpynW
Definition: compat.h:738
#define pch(ap)
Definition: match.c:418
#define L(x)
Definition: ntvdm.h:50
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_USERS
Definition: winreg.h:13

Referenced by FindNext().

◆ SetFindFlags()

static void SetFindFlags ( DWORD  dwFlags)
static

Definition at line 586 of file find.c.

587{
588 HKEY hKey;
589 DWORD dwDisposition;
591
593 {
594 dwData = (dwFlags >> 0) & 0x0000FFFF;
595 RegSetValueExW(hKey, s_szFindFlags, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
596
597 dwData = (dwFlags >> 16) & 0x0000FFFF;
598 RegSetValueExW(hKey, s_szFindFlagsR, 0, REG_DWORD, (const BYTE *) &dwData, sizeof(dwData));
599
601 }
602}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1091
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4900
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
unsigned char BYTE
Definition: xxhash.c:193

Referenced by FindDialogProc().

◆ SetValueName()

VOID SetValueName ( HWND  hwndLV,
LPCWSTR  pszValueName 
)

Definition at line 84 of file listview.c.

85{
86 INT i, c;
87 LVFINDINFOW fi;
88
89 c = ListView_GetItemCount(hwndLV);
90 for(i = 0; i < c; i++)
91 {
93 }
94 if (pszValueName == NULL)
95 i = 0;
96 else
97 {
98 fi.flags = LVFI_STRING;
99 fi.psz = pszValueName;
100 i = ListView_FindItem(hwndLV, -1, &fi);
101 }
105}
INT iListViewSelect
Definition: listview.c:29
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2673
#define LVFI_STRING
Definition: commctrl.h:2437
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
LPCWSTR psz
Definition: commctrl.h:2457

Referenced by FindNext().

Variable Documentation

◆ s_bAbort

BOOL s_bAbort
static

Definition at line 31 of file find.c.

Referenced by AbortFindDialogProc(), DoEvents(), and FindNext().

◆ s_backslash

const WCHAR s_backslash[] = L"\\"
static

Definition at line 37 of file find.c.

Referenced by RegFindRecurse(), and RegFindWalk().

◆ s_cchName

DWORD s_cchName
static

Definition at line 35 of file find.c.

Referenced by RegFindRecurse(), and RegFindWalk().

◆ s_dwFlags

DWORD s_dwFlags
static

Definition at line 33 of file find.c.

Referenced by CompareData(), CompareName(), FindNext(), RegFindRecurse(), and RegFindWalk().

◆ s_empty

const WCHAR s_empty[] = L""
static

Definition at line 36 of file find.c.

Referenced by FindNext(), and RegFindWalk().

◆ s_hwndAbortDialog

HWND s_hwndAbortDialog
static

Definition at line 30 of file find.c.

Referenced by DoEvents(), and FindNext().

◆ s_szFindFlags

const WCHAR s_szFindFlags[] = L"FindFlags"
static

Definition at line 28 of file find.c.

Referenced by GetFindFlags(), and SetFindFlags().

◆ s_szFindFlagsR

const WCHAR s_szFindFlagsR[] = L"FindFlagsReactOS"
static

Definition at line 29 of file find.c.

Referenced by GetFindFlags(), and SetFindFlags().

◆ s_szFindWhat

WCHAR s_szFindWhat[256]
static

Definition at line 27 of file find.c.

Referenced by FindDialogProc(), FindNext(), RegFindRecurse(), and RegFindWalk().

◆ s_szName

WCHAR s_szName[MAX_PATH]
static

Definition at line 34 of file find.c.

Referenced by General_DoTest(), IME_DoTest(), RegFindRecurse(), RegFindWalk(), and START_TEST().