[PATCH] Fix 16 bit StringFromGUID2 to not use wide characters (try 2)

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Tue May 20 16:48:41 CDT 2008


Compared to try 1, this fixes the type of the count parameter.
It is must be INT16 instead of INT (which is 32 bits in wine) because
there is no sign expansion. Maybe s_word in
the spec file would also do.
---
 dlls/ole32/compobj.c    |    1 -
 dlls/ole32/compobj.spec |    2 +-
 dlls/ole32/ole16.c      |   31 +++++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index 7280150..c4eec23 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -1399,7 +1399,6 @@ HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr)
 
 /******************************************************************************
  *		StringFromGUID2	[OLE32.@]
- *		StringFromGUID2	[COMPOBJ.76]
  *
  * Modified version of StringFromCLSID that allows you to specify max
  * buffer size.
diff --git a/dlls/ole32/compobj.spec b/dlls/ole32/compobj.spec
index 3ac8568..390a212 100644
--- a/dlls/ole32/compobj.spec
+++ b/dlls/ole32/compobj.spec
@@ -72,7 +72,7 @@
 72 stub _IID_IEXTERNALCONNECTION
 73 pascal CoCreateGuid(ptr) CoCreateGuid
 75 stub FNASSERT
-76 pascal StringFromGUID2(ptr ptr word) StringFromGUID2
+76 pascal StringFromGUID2(ptr ptr word) StringFromGUID2_16
 77 stub COGETCLASSEXT
 78 stub OLE1CLASSFROMCLSID2
 79 stub CLSIDFROMOLE1CLASS
diff --git a/dlls/ole32/ole16.c b/dlls/ole32/ole16.c
index d19a817..f2897cd 100644
--- a/dlls/ole32/ole16.c
+++ b/dlls/ole32/ole16.c
@@ -399,6 +399,37 @@ HRESULT WINAPI StringFromCLSID16(
 }
 
 /******************************************************************************
+ *		StringFromGUID2_16	[COMPOBJ.76]
+ *
+ * Modified version of StringFromCLSID that allows you to specify max
+ * buffer size.
+ *
+ * PARAMS
+ *  id   [I] GUID to convert to string.
+ *  str  [O] Buffer where the result will be stored.
+ *  cmax [I] Size of the buffer in characters.
+ *
+ * RETURNS
+ *	Success: The length of the resulting string in characters.
+ *  Failure: 0.
+ */
+INT WINAPI StringFromGUID2_16(REFGUID id, LPSTR str, INT16 cmax)
+{
+  char		xguid[80];
+  int           len;
+
+  if (WINE_StringFromCLSID( id, xguid ))
+  	return 0;
+  	
+  len = strlen( xguid ) + 1; /* The terminating zero counts */
+  if (len > cmax)
+        return 0;
+        
+  strcpy( str, xguid );
+  return len;
+}
+
+/******************************************************************************
  * ProgIDFromCLSID [COMPOBJ.62]
  *
  * Converts a class id into the respective Program ID. (By using a registry lookup)
-- 
1.5.5.1




More information about the wine-patches mailing list