Details
-
Bug
-
Resolution: Incomplete
-
Major
-
None
-
None
-
None
-
Operating System: ReactOS
Platform: x86 Hardware
Description
This is a full implementation of the regedit search function.
English and German language available, with other languages the "Find" and "Find
next" menu points are still disabled.
PATCH:
diff -urN regedit/De.rc regeditnew/De.rc
— regedit/De.rc 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/De.rc 2005-03-09 13:58:35.000000000 +0100
@@ -76,7 +76,7 @@
MENUITEM SEPARATOR
MENUITEM "Schlüsselname &kopieren", ID_EDIT_COPYKEYNAME
MENUITEM SEPARATOR
- MENUITEM "&Suchen\tStrg+F", ID_EDIT_FIND, GRAYED
+ MENUITEM "&Suchen\tStrg+F", ID_EDIT_FIND
MENUITEM "&Nächstes finden\tF3", ID_EDIT_FINDNEXT, GRAYED
END
POPUP "&Ansicht"
@@ -190,12 +190,47 @@
PUSHBUTTON "Abbrechen",IDCANCEL,196,82,50,14
END
+IDD_FINDDIALOG DIALOG DISCARDABLE 0, 0, 260, 90
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Suchen"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "Suchen nach:",IDC_FINDTEXT,0,6,80,14,SS_NOPREFIX
+ EDITTEXT IDC_FINDEDIT,49,3,149,14,ES_AUTOHSCROLL
+ DEFPUSHBUTTON "&Weitersuchen",IDOK,208,3,49,14
+ PUSHBUTTON "Abbrechen",IDCANCEL,208,20,49,14
+ GROUPBOX "Suchoptionen",IDC_FIND_GROUPBOX, 5, 25, 194, 46, BS_GROUPBOX
+ CHECKBOX "Schlüssel", IDC_CHECKBOX_KEYS, 10, 36, 60, 10
+ CHECKBOX "Werte", IDC_CHECKBOX_VALUES, 10, 47, 60, 10
+ CHECKBOX "Daten", IDC_CHECKBOX_DATA, 10, 58, 80, 10
+ CHECKBOX "Ganze Zeichenfole vergleichen", IDC_CHECKBOX_MATCHSTRING, 5,
75, 200, 10
+END
+
+IDD_SEARCHINGDIALOG DIALOG DISCARDABLE 0, 0, 170, 60
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Suchen"
+FONT 8, "MS Sans Serif"
+BEGIN
+ ICON IDI_REGEDIT,IDI_REGEDIT,8,11,16,16
+ LTEXT "Registrierung wird durchsucht...",IDC_FINDTEXT,35,15,200,14,SS_NOPREFIX
+ PUSHBUTTON "Abbrechen",IDCANCEL,58,40,49,13
+END
+
/*
- String Table
*/
STRINGTABLE DISCARDABLE
BEGIN
+ IDS_RESULTBOX_TITLE "Ich habe etwas gefunden..."
+ IDS_FOUND_NOTHING_TITLE "Information"
+ IDS_FOUND_NOTHING "Keine Ergebnisse."
+ IDS_NO_MORE_RESULTS_TITLE "Information"
+ IDS_NO_MORE_RESULTS "Keine weiteren Ergebnisse."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
IDS_LIST_COLUMN_NAME "Name"
IDS_LIST_COLUMN_TYPE "Typ"
IDS_LIST_COLUMN_DATA "Daten"
diff -urN regedit/edit.c regeditnew/edit.c
— regedit/edit.c 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/edit.c 2005-03-09 13:58:35.000000000 +0100
@@ -50,6 +50,394 @@
static DWORD valueDataLen;
static EDIT_MODE dwordEditMode = EDIT_MODE_HEX;
+static BOOL searchForKeys = TRUE;
+static BOOL searchForValues = TRUE;
+static BOOL searchForData = TRUE;
+static BOOL searchMatchWholeString = FALSE;
+LPTSTR searchString = NULL; // extern keyword in main.c - so no static-keyword here
+static int searchStringLen = 0;
+static HWND hFindEdit,hFindButton;
+static LONG_PTR prevWndProcEdit;
+
+static BOOL killSearchThread = FALSE;
+extern HWND hFrameWnd;
+
+#define TYPE_KEY 0
+#define TYPE_VALUE 1
+#define TYPE_DATA 2
+
+typedef struct findKeyStruct
findKeyStruct;
+
+static findKeyStruct *foundKeys = NULL;
+static DWORD numFoundKeys,currentOfFoundKeys;
+
+//FreeFoundKeys() - Frees the search results in nemory ( used by the "Find
next" command )
+void FreeFoundKeys() {
+DWORD z = 0;
+
+while(z < numFoundKeys)
+
+if(foundKeys)
+
+numFoundKeys = 0;
+}
+
+//findedit_proc() - Checks the user input in the find dialog
+LRESULT CALLBACK findedit_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam) {
+if(uMsg Unable to render embedded object: File (= 193) { // if uMsg == 193, tmpLen is always 0) not found.
+
+DWORD tmpLen = SendMessage(hWnd, EM_LINELENGTH, 0, 0);
+
+if(tmpLen != searchStringLen)
+
+}
+return CallWindowProc ((WNDPROC) prevWndProcEdit, hWnd, uMsg, wParam, lParam);
+}
+
+//AddSearchResult() - Adds a search result to global struct
+void AddSearchResult(const LPTSTR key,HKEY baseKey,DWORD type)
+
+//SearchRegistryRecrusively() - Main searching function
+void SearchRegistryRecrusively(const LPTSTR startKey,const HKEY baseKey,BOOL
isRootKey) {
+HKEY hkey;
+DWORD largestSubkeySize, largestValueSize, largestDataSize, nextSubkeySize;
+DWORD valueSize,dataSize,index = 0;
+LPTSTR subkeyName,nextSubkey,valueName,valueData, fullValuePath,fullData;
+
+if(killSearchThread)return; //User clicked "Cancel" while searching - so abort
operation
+
+if (RegOpenKeyA( baseKey, startKey, &hkey ) == ERROR_SUCCESS) {
+
+ //Get size of largest subkey, value and data
+
if(RegQueryInfoKey(hkey,NULL,NULL,NULL,NULL,&largestSubkeySize,NULL,NULL,&largestValueSize,
+ &largestDataSize,NULL,NULL) == ERROR_SUCCESS) {
+
+ if(searchForValues || searchForData) {
+
+ largestValueSize++; //Add 1 for terminating /0
+ largestDataSize++; //Same
+
+ valueName = (LPTSTR)HeapAlloc(GetProcessHeap(),0,largestValueSize);
+ valueData = (LPTSTR)HeapAlloc(GetProcessHeap(),0,largestDataSize);
+
+ while(RegEnumValue(hkey,index,valueName,&valueSize,NULL,NULL,
+ valueData,&dataSize) == ERROR_SUCCESS) {
+
+if(searchForValues) {
+ if(searchStringLen <= valueSize) {
+ //Normal mode or "match whole string" - mode?
+ if(!searchMatchWholeString || searchStringLen == valueSize) {
+ if(strstr (CharLower(valueName), searchString))
+ }
+ }
+}
+
+if(searchForData) {
+ if(searchStringLen <= dataSize) {
+ //Normal mode or "match whole string" - mode?
+ if(!searchMatchWholeString || searchStringLen == dataSize) {
+ if(strstr (CharLower(valueData), searchString))
+ }
+ }
+}
+
+
+ index++;
+ }
+
+ HeapFree(GetProcessHeap(),0,valueData);
+ HeapFree(GetProcessHeap(),0,valueName);
+
+ }
+
+ largestSubkeySize++; //Add 1 for terminating \0
+ nextSubkeySize = largestSubkeySize + strlen(startKey) + 1; // + 1 is for the "\"
+
+ subkeyName = (LPTSTR)HeapAlloc(GetProcessHeap(),0,largestSubkeySize);
+ nextSubkey = (LPTSTR)HeapAlloc(GetProcessHeap(),0,nextSubkeySize);
+
+ index = 0;
+
+ //Loop thru all subkeys
+ while(RegEnumKey(hkey,index,subkeyName,largestSubkeySize) == ERROR_SUCCESS) {
+
+ //First level keys ( root keys ) structure is "bla" and not "\bla"
+ if(isRootKey) sprintf(nextSubkey,"%s",subkeyName);
+ else sprintf(nextSubkey,"%s
%s",startKey,subkeyName);
+
+if(searchForKeys) { //Are we searching for subkeys?
+
+ if(searchStringLen <= strlen(subkeyName)) {
+ //Normal mode or "match whole string" - mode?
+ if(!searchMatchWholeString || searchStringLen == strlen(subkeyName))
+ }
+}
+
+
+
+ SearchRegistryRecrusively(nextSubkey,baseKey,FALSE); //Go to next level
+
+ index++;
+ }
+
+ HeapFree(GetProcessHeap(),0,subkeyName);
+ HeapFree(GetProcessHeap(),0,nextSubkey);
+ }
+
+RegCloseKey(hkey);
+}
+
+}
+
+//Thread running while the "Searching"-dialog is displayed
+DWORD WINAPI search_regkey_thread( LPVOID l ) {
+killSearchThread = FALSE; //No user cancel...
+printf("Searching for \"%s\"...\n",searchString);
+HKEY baseKey = HKEY_CLASSES_ROOT;
+while(!killSearchThread)
+printf("%u results.\n",numFoundKeys);
+
+if(numFoundKeys > 1)
+
+EndDialog((HWND)l, 0); //Close the "Searching"-dialog, were finished!
+return 0;
+}
+
+INT_PTR CALLBACK searchingdlg_proc(HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM
lParam) {
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ CreateThread(NULL,0,search_regkey_thread,(LPVOID)hWnd,0,NULL);
+ return (TRUE);
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam))
+ break;
+ }
+
+return(FALSE);
+}
+
+//Output helper strings
+static const char HK_CLASSES_ROOT[] = "HKEY_CLASSES_ROOT";
+static const char HK_CURRENT_USER[] = "HKEY_CURRENT_USER";
+static const char HK_LOCAL_MACHINE[] = "HKEY_LOCAL_MACHINE";
+static const char HK_USERS[] = "HKEY_USERS";
+static const char HK_CURRENT_CONFIG[] = "HKEY_CURRENT_CONFIG";
+static const char HK_DYN_DATA[] = "HKEY_DYN_DATA";
+
+//Displays a MessageBox showing the result
+BOOL DisplayFoundKey() {
+TCHAR title[256],errstr[1024];
+
+if(currentOfFoundKeys < numFoundKeys)
+else {
+if(!numFoundKeys)
+else
{ +FreeFoundKeys(); //Clean up memory + + if (!LoadString(hInst, IDS_NO_MORE_RESULTS_TITLE, title, COUNT_OF(title))) + lstrcpy(title,"Information"); + if (!LoadString(hInst, IDS_NO_MORE_RESULTS, errstr, COUNT_OF(errstr))) + lstrcpy(title,"No more results."); + +MessageBox(hFrameWnd,errstr,title,MB_OK | MB_ICONINFORMATION); + +}+
+HMENU hMenu = GetMenu( hFrameWnd );
+EnableMenuItem(hMenu, ID_EDIT_FINDNEXT, MF_BYCOMMAND | MF_GRAYED); //Disable
"Find next" menu
+
+return FALSE;
+}
+}
+
+INT_PTR CALLBACK finddlg_proc(HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM lParam) {
+
+ switch(uMsg) {
+ case WM_INITDIALOG:
+ hFindEdit = GetDlgItem(hWnd, IDC_FINDEDIT);
+ hFindButton = GetDlgItem(hWnd, IDOK);
+
+ //Watches over changes of the editbox
+ prevWndProcEdit = SetWindowLongPtr (hFindEdit, GWLP_WNDPROC, (LONG_PTR)
findedit_proc);
+
+ EnableWindow(hFindButton, FALSE);
+
+ CheckDlgButton( hWnd, IDC_CHECKBOX_KEYS, BST_CHECKED );
+ CheckDlgButton( hWnd, IDC_CHECKBOX_VALUES, BST_CHECKED );
+ CheckDlgButton( hWnd, IDC_CHECKBOX_DATA, BST_CHECKED );
+ return(TRUE);
+ break;
+
+ case WM_COMMAND:
+
+ switch(LOWORD(wParam))
+ break;
+ }
+
+return(FALSE);
+}
void error(HWND hwnd, INT resId, ...)
{ diff -urN regedit/En.rc regeditnew/En.rc --- regedit/En.rc 2005-03-09 14:00:56.000000000 +0100 +++ regeditnew/En.rc 2005-03-09 13:58:35.000000000 +0100 @@ -76,7 +76,7 @@ MENUITEM SEPARATOR MENUITEM "&Copy Key Name", ID_EDIT_COPYKEYNAME MENUITEM SEPARATOR - MENUITEM "&Find\tCtrl+F", ID_EDIT_FIND, GRAYED + MENUITEM "&Find\tCtrl+F", ID_EDIT_FIND MENUITEM "Find Ne&xt\tF3", ID_EDIT_FINDNEXT, GRAYED END POPUP "&View" @@ -190,12 +190,48 @@ PUSHBUTTON "Cancel",IDCANCEL,196,82,50,14 END +IDD_FINDDIALOG DIALOG DISCARDABLE 0, 0, 260, 90 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Find" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Find what:",IDC_FINDTEXT,5,6,40,14,SS_NOPREFIX + EDITTEXT IDC_FINDEDIT,49,3,149,14,ES_AUTOHSCROLL + DEFPUSHBUTTON "&Find next",IDOK,208,3,49,14 + PUSHBUTTON "Cancel",IDCANCEL,208,20,49,14 + GROUPBOX "Look at",IDC_FIND_GROUPBOX, 5, 25, 194, 46, BS_GROUPBOX + CHECKBOX "Keys", IDC_CHECKBOX_KEYS, 10, 36, 60, 10 + CHECKBOX "Values", IDC_CHECKBOX_VALUES, 10, 47, 60, 10 + CHECKBOX "Data", IDC_CHECKBOX_DATA, 10, 58, 60, 10 + CHECKBOX "Match whole string only", IDC_CHECKBOX_MATCHSTRING, 5, 75, 100, 10 +END + +IDD_SEARCHINGDIALOG DIALOG DISCARDABLE 0, 0, 170, 60 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Search" +FONT 8, "MS Sans Serif" +BEGIN + ICON IDI_REGEDIT,IDI_REGEDIT,8,11,16,16 + LTEXT "Registry is being searched...",IDC_FINDTEXT,35,15,200,14,SS_NOPREFIX + PUSHBUTTON "Cancel",IDCANCEL,58,40,49,13 +END + + /* * String Table */ STRINGTABLE DISCARDABLE BEGIN + IDS_RESULTBOX_TITLE "Found something..." + IDS_FOUND_NOTHING_TITLE "Information" + IDS_FOUND_NOTHING "No results." + IDS_NO_MORE_RESULTS_TITLE "Information" + IDS_NO_MORE_RESULTS "No more results." +END + +STRINGTABLE DISCARDABLE +BEGIN IDS_LIST_COLUMN_NAME "Name" IDS_LIST_COLUMN_TYPE "Type" IDS_LIST_COLUMN_DATA "Data" diff -urN regedit/framewnd.c regeditnew/framewnd.c --- regedit/framewnd.c 2005-03-09 14:00:56.000000000 +0100 +++ regeditnew/framewnd.c 2005-03-09 13:58:35.000000000 +0100 @@ -531,6 +531,12 @@ case ID_EDIT_DELETE: regsam |= KEY_WRITE; break; + case ID_EDIT_FIND: + DialogBox(hInst, MAKEINTRESOURCE(IDD_FINDDIALOG), NULL, finddlg_proc); + break; + case ID_EDIT_FINDNEXT: + DisplayFoundKey(); + break; } keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
diff -urN regedit/main.c regeditnew/main.c
— regedit/main.c 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/main.c 2005-03-09 13:58:35.000000000 +0100
@@ -46,6 +46,7 @@
UINT nClipboardFormat;
LPCTSTR strClipboardFormat = _T("TODO: SET CORRECT FORMAT");
+extern LPTSTR searchString;
#define MAX_LOADSTRING 100
TCHAR szTitle[MAX_LOADSTRING];
@@ -222,6 +223,10 @@
DispatchMessage(&msg);
}
}
+
+ FreeFoundKeys();
+ if(searchString)HeapFree(GetProcessHeap(),0,searchString);
+
ExitInstance(hInstance);
return msg.wParam;
}
diff -urN regedit/main.h regeditnew/main.h
— regedit/main.h 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/main.h 2005-03-09 13:58:35.000000000 +0100
@@ -102,4 +102,8 @@
/* edit.c */
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin);
+extern INT_PTR CALLBACK finddlg_proc(HWND hWnd, UINT uMsg, WPARAM wParam,LPARAM
lParam);
+extern BOOL DisplayFoundKey();
+extern void FreeFoundKeys();
+
#endif /* _MAIN_H_ */
diff -urN regedit/res/.svn/entries regeditnew/res/.svn/entries
— regedit/res/.svn/entries 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/res/.svn/entries 2005-03-09 13:58:35.000000000 +0100
@@ -13,55 +13,55 @@
<entry
committed-rev="7376"
name="string.ico"
- text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-01-01T15:12:11.000000Z"
checksum="78d0080b67b7fd3557a63d40041c5cce"
last-author="weiden"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
<entry
committed-rev="7376"
name="bin.ico" - text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-01-01T15:12:11.000000Z"
checksum="9f180cae21806d680da5edbb4ed3c191"
last-author="weiden"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
<entry
committed-rev="7376"
name="folder.ico" - text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-01-01T15:12:11.000000Z"
checksum="0ce4dffe9b3c05b8263fb7293914c941"
last-author="weiden"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
<entry
committed-rev="7376"
name="folderopen.ico" - text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-01-01T15:12:11.000000Z"
checksum="2b4324598ddaa1f304a321d07eeb1f88"
last-author="weiden"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
<entry
committed-rev="7376"
name="computer.ico" - text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-01-01T15:12:11.000000Z"
checksum="338732cef0ef743ba5a36845847bf347"
last-author="weiden"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
<entry
committed-rev="9798"
name="regedit.ico" - text-time="2005-03-09T12:40:42.000000Z"
+ text-time="2005-03-09T11:01:43.000000Z"
committed-date="2004-06-21T17:11:00.000000Z"
checksum="3e87b480d2239021dcd9cf3107f8116b"
last-author="ekohl"
kind="file" - prop-time="2005-03-09T12:40:42.000000Z"/>
+ prop-time="2005-03-09T11:01:43.000000Z"/>
</wc-entries>
diff -urN regedit/resource.h regeditnew/resource.h-
- regedit/resource.h 2005-03-09 14:00:56.000000000 +0100
+++ regeditnew/resource.h 2005-03-09 13:58:35.000000000 +0100
@@ -129,6 +129,22 @@
#define ID_SWITCH_PANELS 32871
#define ID_EDIT_PERMISSIONS 32872
- regedit/resource.h 2005-03-09 14:00:56.000000000 +0100
-
+#define IDD_FINDDIALOG 32880
+#define IDC_FINDTEXT 32881
+#define IDC_FINDEDIT 32882
+#define IDC_FIND_GROUPBOX 32883
+#define IDC_CHECKBOX_KEYS 32884
+#define IDC_CHECKBOX_VALUES 32885
+#define IDC_CHECKBOX_DATA 32886
+#define IDC_CHECKBOX_MATCHSTRING 32887
+#define IDD_SEARCHINGDIALOG 32900
+#define IDC_SEARCHINGTEXT 32901
+#define IDS_RESULTBOX_TITLE 33910
+#define IDS_FOUND_NOTHING_TITLE 33911
+#define IDS_FOUND_NOTHING 33912
+#define IDS_NO_MORE_RESULTS_TITLE 33913
+#define IDS_NO_MORE_RESULTS 33914
+
#define IDS_FLT_REGFILES 31001
#define IDS_FLT_REGFILES_FLT 31002
#define IDS_FLT_REGEDIT4 31003