shlwapi: add two new exported APIs and fix a possible 0 reference bug in SHLWAPI_436

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Sun Apr 6 09:38:18 CDT 2003


Changelog:
  * dlls/shlwapi/shlwapi.spec
    Add new export SHLWAPI_269 and SHLWAPI_270
  * dlls/shlwapi/ordinal.h
    Declare SHLWAPI_436 for use in the other functions
  * dlls/shlwapi/ordinal.c
    Implement SHLWAPI_269 and SHLWAPI_270
    Fix a 0 reference bug in SHLWAPI_436 and change its return value
    to what at least W2K does as well.    

License: X11/LGPL

Rolf Kalbermatter
 
Index: dlls/shlwapi/shlwapi.spec
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/shlwapi.spec,v
retrieving revision 1.72
diff -u -r1.72 shlwapi.spec
--- dlls/shlwapi/shlwapi.spec	27 Mar 2003 18:34:34 -0000	1.72
+++ dlls/shlwapi/shlwapi.spec	6 Apr 2003 10:34:41 -0000
@@ -266,8 +266,8 @@
 266 stdcall @(long wstr ptr ptr) SHLWAPI_266
 267 stdcall @(long long long long) SHLWAPI_267
 268 stdcall @(long long) SHLWAPI_268
-269 stub @
-270 stub @
+269 stdcall @(str ptr) SHLWAPI_269
+270 stdcall @(wstr ptr) SHLWAPI_270
 271 stdcall @(wstr wstr wstr) SHLWAPI_271
 272 stub @
 273 stub @

Index: dlls/shlwapi/ordinal.h
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/ordinal.h,v
retrieving revision 1.6
diff -u -r1.6 ordinal.h
--- dlls/shlwapi/ordinal.h	27 Mar 2003 18:34:34 -0000	1.6
+++ dlls/shlwapi/ordinal.h	6 Apr 2003 10:35:25 -0000
@@ -42,6 +42,8 @@
 } UNKNOWN_SHLWAPI_2;
 
 DWORD WINAPI SHLWAPI_2(LPCWSTR x, UNKNOWN_SHLWAPI_2 *y);
+
+HRESULT WINAPI SHLWAPI_436(LPCWSTR idstr, CLSID *id);
 
 /* Macro to get function pointer for a module*/
 #define GET_FUNC(func, module, name, fail) \

Index: dlls/shlwapi/ordinal.c
===================================================================
RCS file: /home/wine/wine/dlls/shlwapi/ordinal.c,v
retrieving revision 1.65
diff -u -r1.65 ordinal.c
--- dlls/shlwapi/ordinal.c	27 Mar 2003 18:34:34 -0000	1.65
+++ dlls/shlwapi/ordinal.c	6 Apr 2003 10:48:02 -0000
@@ -2705,45 +2705,78 @@
 }
 
 /*************************************************************************
+ *      @	[SHLWAPI.269]
+ *
+ * Convert an ASCII string CLSID into a CLSID.
+ */
+BOOL WINAPI SHLWAPI_269(LPCSTR idstr, CLSID *id)
+{
+	WCHAR wClsid[40];
+	MultiByteToWideChar(CP_ACP, 0, idstr, -1, wClsid, sizeof(wClsid)/sizeof(WCHAR));
+	return SUCCEEDED(SHLWAPI_436(wClsid, id));
+}
+
+/*************************************************************************
+ *      @	[SHLWAPI.270]
+ *
+ * Convert an Unicode string CLSID into a CLSID.
+ */
+BOOL WINAPI SHLWAPI_270(LPCWSTR idstr, CLSID *id)
+{
+	return SUCCEEDED(SHLWAPI_436(idstr, id));
+}
+
+/*************************************************************************
  *      @	[SHLWAPI.436]
  *
+ * Convert an Unicode string CLSID into a CLSID.
+ *
+ * PARAMS
+ *  idstr      [I]   string containing a CLSID in text form
+ *  id         [O]   CLSID extracted from the string
+ *
+ * RETURNS
+ *  S_OK on success or E_INVALIDARG on failure
+ *
+ * NOTES
  *  This is really CLSIDFromString which is exported by ole32.dll,
  *  however the native shlwapi.dll does *not* import ole32. Nor does
  *  ole32.dll import this ordinal from shlwapi. Therefore we must conclude
- *  that MS duplicated the code for CLSIDFromString.
- *
+ *  that MS duplicated the code for CLSIDFromString, and yes they did, only
+ *  it returns an E_INVALIDARG error code on failure.
  *  This is a duplicate (with changes for UNICODE) of CLSIDFromString16
  *  in dlls/ole32/compobj.c
  */
-DWORD WINAPI SHLWAPI_436 (LPWSTR idstr, CLSID *id)
+HRESULT WINAPI SHLWAPI_436(LPCWSTR idstr, CLSID *id)
 {
-    LPWSTR s = idstr;
-    BYTE *p;
-    INT i;
-    WCHAR table[256];
-
-    if (!s) {
-	memset(s, 0, sizeof(CLSID));
-	return S_OK;
-    }
-    else {  /* validate the CLSID string */
+	LPCWSTR s = idstr;
+	BYTE *p;
+	INT i;
+	WCHAR table[256];
+
+	if (!s) {
+	  memset(id, 0, sizeof(CLSID));
+	  return S_OK;
+	}
+	else {  /* validate the CLSID string */
 
-	if (strlenW(s) != 38)
-	    return CO_E_CLASSSTRING;
+	  if (strlenW(s) != 38)
+	    return E_INVALIDARG;
 
-	if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
-	    return CO_E_CLASSSTRING;
+	  if ((s[0]!=L'{') || (s[9]!=L'-') || (s[14]!=L'-') || (s[19]!=L'-') || (s[24]!=L'-') || (s[37]!=L'}'))
+	    return E_INVALIDARG;
 
-	for (i=1; i<37; i++)
-	    {
-		if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
-		if (!(((s[i] >= L'0') && (s[i] <= L'9'))  ||
-		      ((s[i] >= L'a') && (s[i] <= L'f'))  ||
-		      ((s[i] >= L'A') && (s[i] <= L'F')))
-		    )
-		    return CO_E_CLASSSTRING;
-	    }
-    }
+	  for (i=1; i<37; i++)
+	  {
+	    if ((i == 9)||(i == 14)||(i == 19)||(i == 24))
+	      continue;
+	    if (!(((s[i] >= L'0') && (s[i] <= L'9'))  ||
+	        ((s[i] >= L'a') && (s[i] <= L'f'))  ||
+	        ((s[i] >= L'A') && (s[i] <= L'F')))
+	       )
+	      return E_INVALIDARG;
+	  }
+	}
 
     TRACE("%s -> %p\n", debugstr_w(s), id);
 




More information about the wine-patches mailing list