New registry key adding patch

Zimler Attila hijaszu at hlfslinux.hu
Thu Jan 1 07:16:49 CST 2004


Hi,
I give it a third try :)

Dimitrie O. Paun wrote:

>On January 1, 2004 06:41 am, Zimler Attila wrote:
>  
>
>>This is working while "key name" string is not localized. 
>>After that this could introduce security bugs. 
>>Will it be localized? How to deal with situations like this?
>>    
>>
>
>Well, we would need to allocate the buffer dynamically anyway.
>  
>
I don't understand this. Probably because I don't understand how we 
translate the "key name" string, to the localized version, and because 
this I have no idea how big memory should we allocate.

>Please use uniffied diffs (diff -u) when submitting patches.
>
>  
>
cvs diff -u is ok? (This is how I did it at this time)

Hope everything is ok (except localization) at this time.
Attila

-------------- next part --------------
Index: programs/regedit/edit.c
===================================================================
RCS file: /home/wine/wine/programs/regedit/edit.c,v
retrieving revision 1.3
diff -u -u -r1.3 edit.c
--- programs/regedit/edit.c	12 Dec 2003 04:08:59 -0000	1.3
+++ programs/regedit/edit.c	1 Jan 2004 12:06:32 -0000
@@ -91,6 +91,29 @@
     return FALSE;
 }
 
+BOOL CreateKey(HKEY hKey)
+{
+    LONG lRet;
+    HKEY retKey;
+    TCHAR keyName[32] = "new key";
+    unsigned int keyNum = 1;
+         
+    /* If we have illegal parameter return with operation failure */
+    if (!hKey) return FALSE;
+    
+    /* try to find out a name for the newly create key.
+	We try it max 100 times. */
+    lRet = RegOpenKey(hKey, keyName, &retKey);
+    while (lRet == ERROR_SUCCESS && keyNum < 100) {
+	    sprintf(keyName, "new key %u", ++keyNum);
+	    lRet = RegOpenKey(hKey, keyName, &retKey);
+    }
+    if (lRet == ERROR_SUCCESS) return FALSE;
+    
+    lRet = RegCreateKey(hKey, keyName, &retKey);
+    return lRet == ERROR_SUCCESS;
+}
+
 BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName)
 {
     DWORD valueDataLen;
Index: programs/regedit/framewnd.c
===================================================================
RCS file: /home/wine/wine/programs/regedit/framewnd.c,v
retrieving revision 1.5
diff -u -u -r1.5 framewnd.c
--- programs/regedit/framewnd.c	12 Dec 2003 04:08:59 -0000	1.5
+++ programs/regedit/framewnd.c	1 Jan 2004 12:06:32 -0000
@@ -469,6 +469,9 @@
     case ID_EDIT_COPYKEYNAME:
         CopyKeyName(hWnd, _T(""));
         break;
+    case ID_EDIT_NEW_KEY:
+	CreateKey(hKey);
+	break;
     case ID_REGISTRY_PRINTERSETUP:
         /*PRINTDLG pd;*/
         /*PrintDlg(&pd);*/
Index: programs/regedit/main.h
===================================================================
RCS file: /home/wine/wine/programs/regedit/main.h,v
retrieving revision 1.8
diff -u -u -r1.8 main.h
--- programs/regedit/main.h	12 Dec 2003 04:08:59 -0000	1.8
+++ programs/regedit/main.h	1 Jan 2004 12:06:32 -0000
@@ -93,6 +93,7 @@
 extern LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey);
 
 /* edit.c */
+BOOL CreateKey(HKEY hKey);
 BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName);
 
 #endif /* __MAIN_H__ */


More information about the wine-devel mailing list