desk.cpl, Control Panel patch

Andreas Mohr andi at rhlx01.fht-esslingen.de
Sun Dec 23 16:48:58 CST 2001


Hi all,

- update programs/control/ to not rely on rundll32.exe any more
  (why would you use it in the first place ?), thus making it usable
  for no-windows installs, too

- fixed, added or implemented stubs:
  DrawMenuBarTemp(): corrected parameter count. GRRRRR !!!
  CallCPLEntry16(): stub
  SetSysColorsTemp(): corrected parameter count. See above. Fully implemented
  (hopefully) this undocumented function. Now desk.cpl actually works
  without having this particular crash (there are others remaining, though...)

About that parameter count thingy again:
If you're absolutely sure that you have to add some particular stub,
then make *dead* sure that you get the parameters right !
Yep, in this case I had a FIXME message from this stub that made me suspect it
rather soon, but I'm just about sure I'll lose 5 hours next time on a
similar crash case...

Hmpf :(

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: controls/menu.c
===================================================================
RCS file: /home/wine/wine/controls/menu.c,v
retrieving revision 1.133
diff -u -r1.133 menu.c
--- controls/menu.c	6 Nov 2001 20:57:13 -0000	1.133
+++ controls/menu.c	23 Dec 2001 20:31:02 -0000
@@ -3978,10 +3978,16 @@
 
 /***********************************************************************
  *           DrawMenuBarTemp   (USER32.@)
+ *
+ * UNDOCUMENTED !!
+ * 
+ * called by W98SE desk.cpl Control Panel Applet
+ *
+ * Not 100% sure about the param names, but close.
  */
-DWORD WINAPI DrawMenuBarTemp(DWORD p1, DWORD p2)
+DWORD WINAPI DrawMenuBarTemp(HWND someHWND, HDC someHDC, LPRECT someRECT, HMENU someHMENU, HFONT someFONT)
 {
-    FIXME("(%08lx %08lx): stub\n", p1, p2);
+    FIXME("(0x%08x, 0x%08x, %p, 0x%08x, 0x%08x): stub\n", someHWND, someHDC, someRECT, someHMENU, someFONT);
     return 0;
 }
 
Index: dlls/shell32/control.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/control.c,v
retrieving revision 1.2
diff -u -r1.2 control.c
--- dlls/shell32/control.c	19 Jun 2001 18:20:50 -0000	1.2
+++ dlls/shell32/control.c	23 Dec 2001 20:31:02 -0000
@@ -377,10 +377,21 @@
 
 /*************************************************************************
  * RunDLL_CallEntry16				[SHELL32.122]
- * the name is propably wrong
+ * the name is probably wrong
  */
 HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z)
 {
     FIXME("0x%04lx 0x%04lx 0x%04lx 0x%04lx 0x%04lx stub\n",v,w,x,y,z);
     return 0;
+}
+
+/*
+ * called by desk.cpl on "Advanced" with:
+ * hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0
+ *
+ */
+DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6)
+{
+    FIXME("(%04x, %p, %08lx, %08lx, %08lx, %08lx): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6);
+    return 0x0deadbee;
 }
Index: dlls/shell32/shell32.spec
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32.spec,v
retrieving revision 1.44
diff -u -r1.44 shell32.spec
--- dlls/shell32/shell32.spec	2 Oct 2001 17:25:36 -0000	1.44
+++ dlls/shell32/shell32.spec	23 Dec 2001 20:31:02 -0000
@@ -171,7 +171,7 @@
  163 stdcall StrToOleStr (wstr str) StrToOleStrAW
  164 stdcall Win32DeleteFile(str) Win32DeleteFile
  165 stdcall SHCreateDirectory(long long) SHCreateDirectory
- 166 stub CallCPLEntry16
+ 166 stdcall CallCPLEntry16(long long long long long long) CallCPLEntry16
  167 stdcall SHAddFromPropSheetExtArray(long long long) SHAddFromPropSheetExtArray
  168 stdcall SHCreatePropSheetExtArray(long str long) SHCreatePropSheetExtArray
  169 stdcall SHDestroyPropSheetExtArray(long) SHDestroyPropSheetExtArray
Index: dlls/user/user32.spec
===================================================================
RCS file: /home/wine/wine/dlls/user/user32.spec,v
retrieving revision 1.37
diff -u -r1.37 user32.spec
--- dlls/user/user32.spec	17 Dec 2001 21:40:56 -0000	1.37
+++ dlls/user/user32.spec	23 Dec 2001 20:31:02 -0000
@@ -520,7 +520,7 @@
 @ stdcall SetScrollRange(long long long long long) SetScrollRange
 @ stdcall SetShellWindow(long) SetShellWindow
 @ stdcall SetSysColors(long ptr ptr) SetSysColors
-@ stdcall SetSysColorsTemp(long ptr ptr) SetSysColorsTemp
+@ stdcall SetSysColorsTemp(ptr ptr long) SetSysColorsTemp
 @ stdcall SetSystemCursor(long long) SetSystemCursor
 @ stdcall SetSystemMenu(long long) SetSystemMenu
 @ stdcall SetSystemTimer(long long long ptr) SetSystemTimer
@@ -650,13 +650,14 @@
 @ stdcall SetProcessDefaultLayout(long) SetProcessDefaultLayout
 @ stdcall RegisterDeviceNotificationA(long ptr long) RegisterDeviceNotificationA
 @ stub    RegisterDeviceNotificationW
+@ stub    TrackMouseEvent
 @ stub    UnregisterDeviceNotification
 
 # win98/win2k
 @ stdcall AllowSetForegroundWindow (long) AllowSetForegroundWindow
 @ stdcall AnimateWindow(long long long) AnimateWindow
 @ stdcall GetAncestor(long long) GetAncestor
-@ stdcall DrawMenuBarTemp(long long) DrawMenuBarTemp
+@ stdcall DrawMenuBarTemp(long long long long long) DrawMenuBarTemp
 @ stdcall EnumDisplaySettingsExA(str long ptr long) EnumDisplaySettingsExA
 @ stdcall EnumDisplaySettingsExW(wstr long ptr long) EnumDisplaySettingsExW
 @ stdcall GetClipboardSequenceNumber () GetClipboardSequenceNumber
Index: programs/control/control.c
===================================================================
RCS file: /home/wine/wine/programs/control/control.c,v
retrieving revision 1.2
diff -u -r1.2 control.c
--- programs/control/control.c	3 Apr 1999 11:23:15 -0000	1.2
+++ programs/control/control.c	23 Dec 2001 20:31:03 -0000
@@ -12,13 +12,13 @@
 
 void launch(char what[255])
 { 
-  HINSTANCE hChild;
-  char szArgs[255];
+  HMODULE hMod;
+  FARPROC pControl_RunDLL;
 
-  lstrcpy(szArgs, szEXEC_ARGS);
-  strcat(szArgs, what);
-
-  hChild = ShellExecute((HWND)0, 0, szEXEC_PREFIX, szArgs, "", SW_SHOWNORMAL);
+  hMod = LoadLibrary("shell32.dll");
+  pControl_RunDLL = GetProcAddress(hMod, "Control_RunDLL");
+  pControl_RunDLL(GetDesktopWindow(), 0, what, SW_SHOW);
+  FreeLibrary(hMod);
   exit(0);
 }
 
@@ -35,18 +35,27 @@
              break;
 
     case 1:  /* check for optional parameter */
-             if (strcmp(szParams,szP_DESKTOP)      ==0) launch(szC_DESKTOP);
-             if (strcmp(szParams,szP_COLOR)        ==0) launch(szC_COLOR);
-             if (strcmp(szParams,szP_DATETIME)     ==0) launch(szC_DATETIME);
-             if (strcmp(szParams,szP_DESKTOP)      ==0) launch(szC_DESKTOP);
-             if (strcmp(szParams,szP_INTERNATIONAL)==0) launch(szC_INTERNATIONAL);
-             if (strcmp(szParams,szP_KEYBOARD)     ==0) launch(szC_KEYBOARD);
-             if (strcmp(szParams,szP_MOUSE)        ==0) launch(szC_MOUSE);
-             if (strcmp(szParams,szP_PORTS)        ==0) launch(szC_PORTS);
-             if (strcmp(szParams,szP_PRINTERS)     ==0) launch(szC_PRINTERS);
+             if (!strcmp(szParams,szP_DESKTOP))
+		 launch(szC_DESKTOP);
+             if (!strcmp(szParams,szP_COLOR))
+		 launch(szC_COLOR);
+             if (!strcmp(szParams,szP_DATETIME))
+		 launch(szC_DATETIME);
+             if (!strcmp(szParams,szP_DESKTOP))
+		 launch(szC_DESKTOP);
+             if (!strcmp(szParams,szP_INTERNATIONAL))
+		 launch(szC_INTERNATIONAL);
+             if (!strcmp(szParams,szP_KEYBOARD))
+		 launch(szC_KEYBOARD);
+             if (!strcmp(szParams,szP_MOUSE))
+		 launch(szC_MOUSE);
+             if (!strcmp(szParams,szP_PORTS))
+		 launch(szC_PORTS);
+             if (!strcmp(szParams,szP_PRINTERS))
+		 launch(szC_PRINTERS);
 
-             /* couldn't recognize desired panel, going default mode */
-             launch("");
+	     /* try to launch if a .cpl file is given directly */
+	     launch(szParams);
              break;
 
     default: printf("Syntax error.");
Index: windows/syscolor.c
===================================================================
RCS file: /home/wine/wine/windows/syscolor.c,v
retrieving revision 1.28
diff -u -r1.28 syscolor.c
--- windows/syscolor.c	17 Aug 2001 00:07:14 -0000	1.28
+++ windows/syscolor.c	23 Dec 2001 20:31:03 -0000
@@ -148,11 +148,11 @@
 
     if (SysColorPens[index])
     {
-	SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], FALSE);
+        SYSCOLOR_MakeObjectSystem(SysColorPens[index], FALSE);
 	DeleteObject( SysColorPens[index] ); 
     }
     SysColorPens[index] = CreatePen( PS_SOLID, 1, color );
-    SYSCOLOR_MakeObjectSystem(SysColorBrushes[index], TRUE);
+    SYSCOLOR_MakeObjectSystem(SysColorPens[index], TRUE);
 }
 
 
@@ -275,11 +275,80 @@
 
 /*************************************************************************
  *		SetSysColorsTemp (USER32.@)
- */
-BOOL	WINAPI	SetSysColorsTemp( int n, const int* p, const COLORREF* ptr)
-{
-	FIXME("(%d,%p,%p): stub!\n", n, p, ptr);
-	return 0;
+ *
+ * UNDOCUMENTED !!
+ * 
+ * Called by W98SE desk.cpl Control Panel Applet:
+ * handle = SetSysColorsTemp(ptr, ptr, nCount);     ("set" call)
+ * result = SetSysColorsTemp(NULL, NULL, handle);   ("restore" call)
+ *
+ * pPens is an array of COLORREF values, which seems to be used
+ * to indicate the color values to create new pens with.
+ *
+ * pBrushes is an array of solid brush handles (returned by a previous
+ * CreateSolidBrush), which seems to contain the brush handles to set
+ * for the system colors.
+ *
+ * n seems to be used for
+ *   a) indicating the number of entries to operate on (length of pPens,
+ *      pBrushes)
+ *   b) passing the handle that points to the previously used color settings.
+ *      I couldn't figure out in hell what kind of handle this is on
+ *      Windows. I just use a heap handle instead. Shouldn't matter anyway.
+ *
+ * RETURNS
+ *     heap handle of our own copy of the current syscolors in case of
+ *                 "set" call, i.e. pPens, pBrushes != NULL.
+ *     TRUE (unconditionally !) in case of "restore" call,
+ *          i.e. pPens, pBrushes == NULL.
+ *     FALSE in case of either pPens != NULL and pBrushes == NULL
+ *          or pPens == NULL and pBrushes != NULL.
+ *
+ * I'm not sure whether this implementation is 100% correct. [AM]
+ */
+DWORD WINAPI SetSysColorsTemp( const COLORREF *pPens, const HBRUSH *pBrushes, DWORD n)
+{
+	int i;
+
+	if (pPens && pBrushes) /* "set" call */
+	{
+	    /* allocate our structure to remember old colors */
+	    LPVOID pOldCol = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)+n*sizeof(HPEN)+n*sizeof(HBRUSH));
+	    LPVOID p = pOldCol;
+	    *(DWORD *)p = n; p += sizeof(DWORD);
+	    memcpy(p, SysColorPens, n*sizeof(HPEN)); p += n*sizeof(HPEN);
+	    memcpy(p, SysColorBrushes, n*sizeof(HBRUSH)); p += n*sizeof(HBRUSH);
+
+	    for (i=0; i < n; i++)
+	    {
+		SysColorPens[i] = CreatePen( PS_SOLID, 1, pPens[i] );
+		SysColorBrushes[i] = pBrushes[i];
+	    }
+
+	    return (DWORD)pOldCol;
+	}
+	if ((!pPens) && (!pBrushes)) /* "restore" call */
+	{
+	    LPVOID pOldCol = (LPVOID)n;
+	    LPVOID p = pOldCol;
+	    DWORD nCount = *(DWORD *)p;
+	    p += sizeof(DWORD);
+
+	    for (i=0; i < nCount; i++)
+	    {
+		DeleteObject(SysColorPens[i]);
+		SysColorPens[i] = *(HPEN *)p; p += sizeof(HPEN);
+	    }
+	    for (i=0; i < nCount; i++)
+	    {
+		SysColorBrushes[i] = *(HBRUSH *)p; p += sizeof(HBRUSH);
+	    }
+	    /* get rid of storage structure */
+	    HeapFree(GetProcessHeap(), 0, pOldCol);
+
+	    return TRUE;
+	}
+	return FALSE;
 }
 
 /***********************************************************************


More information about the wine-patches mailing list