Author: cwittich
Date: Sat May 29 19:47:03 2010
New Revision: 47420
URL:
http://svn.reactos.org/svn/reactos?rev=47420&view=rev
Log:
[SHLWAPI]
sync to wine 1.2 RC2
Modified:
trunk/reactos/dll/win32/shlwapi/ordinal.c
trunk/reactos/dll/win32/shlwapi/reg.c
trunk/reactos/dll/win32/shlwapi/shlwapi.spec
trunk/reactos/dll/win32/shlwapi/string.c
trunk/reactos/dll/win32/shlwapi/thread.c
trunk/reactos/dll/win32/shlwapi/url.c
Modified: trunk/reactos/dll/win32/shlwapi/ordinal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/ordinal.…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/ordinal.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/ordinal.c [iso-8859-1] Sat May 29 19:47:03 2010
@@ -484,7 +484,6 @@
DWORD mystrlen, mytype;
DWORD len;
HKEY mykey;
- HRESULT retval;
LCID mylcid;
WCHAR *mystr;
LONG lres;
@@ -512,7 +511,7 @@
/* Did not find a value in the registry or the user buffer is too small */
mylcid = GetUserDefaultLCID();
- retval = LcidToRfc1766W(mylcid, mystr, mystrlen);
+ LcidToRfc1766W(mylcid, mystr, mystrlen);
len = lstrlenW(mystr);
memcpy( langbuf, mystr, min(*buflen, len+1)*sizeof(WCHAR) );
Modified: trunk/reactos/dll/win32/shlwapi/reg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/reg.c?re…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/reg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/reg.c [iso-8859-1] Sat May 29 19:47:03 2010
@@ -331,8 +331,25 @@
LPDWORD pcchValueNameLen, LPDWORD pdwType, LPVOID pvData,
LPDWORD pcbData, SHREGENUM_FLAGS enumRegFlags)
{
- FIXME("(%p, 0x%08x, %s, %p, %p, %p, %p, 0x%08x) stub\n", hUSKey, dwIndex,
- debugstr_a(pszValueName), pcchValueNameLen, pdwType, pvData, pcbData,
enumRegFlags);
+ HKEY dokey;
+
+ TRACE("(%p, 0x%08x, %p, %p, %p, %p, %p, 0x%08x)\n", hUSKey, dwIndex,
+ pszValueName, pcchValueNameLen, pdwType, pvData, pcbData, enumRegFlags);
+
+ if (((enumRegFlags == SHREGENUM_HKCU) ||
+ (enumRegFlags == SHREGENUM_DEFAULT)) &&
+ (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
+ return RegEnumValueA(dokey, dwIndex, pszValueName, pcchValueNameLen,
+ NULL, pdwType, pvData, pcbData);
+ }
+
+ if (((enumRegFlags == SHREGENUM_HKLM) ||
+ (enumRegFlags == SHREGENUM_DEFAULT)) &&
+ (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
+ return RegEnumValueA(dokey, dwIndex, pszValueName, pcchValueNameLen,
+ NULL, pdwType, pvData, pcbData);
+ }
+ FIXME("no support for SHREGENUM_BOTH\n");
return ERROR_INVALID_FUNCTION;
}
@@ -345,8 +362,25 @@
LPDWORD pcchValueNameLen, LPDWORD pdwType, LPVOID pvData,
LPDWORD pcbData, SHREGENUM_FLAGS enumRegFlags)
{
- FIXME("(%p, 0x%08x, %s, %p, %p, %p, %p, 0x%08x) stub\n", hUSKey, dwIndex,
- debugstr_w(pszValueName), pcchValueNameLen, pdwType, pvData, pcbData,
enumRegFlags);
+ HKEY dokey;
+
+ TRACE("(%p, 0x%08x, %p, %p, %p, %p, %p, 0x%08x)\n", hUSKey, dwIndex,
+ pszValueName, pcchValueNameLen, pdwType, pvData, pcbData, enumRegFlags);
+
+ if (((enumRegFlags == SHREGENUM_HKCU) ||
+ (enumRegFlags == SHREGENUM_DEFAULT)) &&
+ (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKCU))) {
+ return RegEnumValueW(dokey, dwIndex, pszValueName, pcchValueNameLen,
+ NULL, pdwType, pvData, pcbData);
+ }
+
+ if (((enumRegFlags == SHREGENUM_HKLM) ||
+ (enumRegFlags == SHREGENUM_DEFAULT)) &&
+ (dokey = REG_GetHKEYFromHUSKEY(hUSKey,REG_HKLM))) {
+ return RegEnumValueW(dokey, dwIndex, pszValueName, pcchValueNameLen,
+ NULL, pdwType, pvData, pcbData);
+ }
+ FIXME("no support for SHREGENUM_BOTH\n");
return ERROR_INVALID_FUNCTION;
}
Modified: trunk/reactos/dll/win32/shlwapi/shlwapi.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/shlwapi.…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/shlwapi.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/shlwapi.spec [iso-8859-1] Sat May 29 19:47:03 2010
@@ -683,6 +683,7 @@
@ stdcall SHCreateStreamOnFileEx(wstr long long long ptr ptr)
@ stdcall SHCreateStreamOnFileW(wstr long ptr)
@ stdcall SHCreateStreamWrapper(ptr ptr long ptr)
+@ stdcall SHCreateThreadRef(ptr ptr)
@ stdcall SHDeleteEmptyKeyA(long ptr)
@ stdcall SHDeleteEmptyKeyW(long ptr)
@ stdcall SHDeleteKeyA(long str)
Modified: trunk/reactos/dll/win32/shlwapi/string.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/string.c…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/string.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/string.c [iso-8859-1] Sat May 29 19:47:03 2010
@@ -1415,7 +1415,7 @@
break;
case STRRET_CSTR:
- if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len )
&& len)
+ if (!MultiByteToWideChar( CP_ACP, 0, src->u.cStr, -1, dest, len ))
dest[len-1] = 0;
break;
@@ -1423,7 +1423,7 @@
if (pidl)
{
if (!MultiByteToWideChar( CP_ACP, 0,
((LPCSTR)&pidl->mkid)+src->u.uOffset, -1,
- dest, len ) && len)
+ dest, len ))
dest[len-1] = 0;
}
break;
Modified: trunk/reactos/dll/win32/shlwapi/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/thread.c…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/thread.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/thread.c [iso-8859-1] Sat May 29 19:47:03 2010
@@ -120,6 +120,93 @@
IUnknown *refIE; /* Reference to the IE process */
} SHLWAPI_THREAD_INFO, *LPSHLWAPI_THREAD_INFO;
+typedef struct
+{
+ const IUnknownVtbl* lpVtbl;
+ LONG *ref;
+} threadref;
+
+static HRESULT WINAPI threadref_QueryInterface(IUnknown *iface, REFIID riid, LPVOID
*ppvObj)
+{
+ threadref * This = (threadref *)iface;
+
+ TRACE("(%p, %s, %p)\n", This, debugstr_guid(riid), ppvObj);
+
+ if (ppvObj == NULL)
+ return E_POINTER;
+
+ if (IsEqualGUID(&IID_IUnknown, riid)) {
+ TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObj);
+ *ppvObj = This;
+ IUnknown_AddRef((IUnknown*)*ppvObj);
+ return S_OK;
+ }
+
+ *ppvObj = NULL;
+ FIXME("(%p, %s, %p) interface not supported\n", This, debugstr_guid(riid),
ppvObj);
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI threadref_AddRef(IUnknown *iface)
+{
+ threadref * This = (threadref *)iface;
+
+ TRACE("(%p)\n", This);
+ return InterlockedIncrement(This->ref);
+}
+
+static ULONG WINAPI threadref_Release(IUnknown *iface)
+{
+ LONG refcount;
+ threadref * This = (threadref *)iface;
+
+ TRACE("(%p)\n", This);
+
+ refcount = InterlockedDecrement(This->ref);
+ if (!refcount)
+ HeapFree(GetProcessHeap(), 0, This);
+
+ return refcount;
+}
+
+/* VTable */
+static const IUnknownVtbl threadref_vt =
+{
+ threadref_QueryInterface,
+ threadref_AddRef,
+ threadref_Release,
+};
+
+/*************************************************************************
+ * SHCreateThreadRef [SHLWAPI.@]
+ *
+ * Create a per-thread IUnknown object
+ *
+ * PARAMS
+ * lprefcount [I] Pointer to a LONG to be used as refcount
+ * lppUnknown [O] Destination to receive the created object reference
+ *
+ * RETURNS
+ * Success: S_OK. lppUnknown is set to the object reference.
+ * Failure: E_INVALIDARG, if a parameter is NULL
+ */
+HRESULT WINAPI SHCreateThreadRef(LONG *lprefcount, IUnknown **lppUnknown)
+{
+ threadref * This;
+ TRACE("(%p, %p)\n", lprefcount, lppUnknown);
+
+ if (!lprefcount || !lppUnknown)
+ return E_INVALIDARG;
+
+ This = HeapAlloc(GetProcessHeap(), 0, sizeof(threadref));
+ This->lpVtbl = &threadref_vt;
+ This->ref = lprefcount;
+
+ *lprefcount = 1;
+ *lppUnknown = (IUnknown *) This;
+ TRACE("=> returning S_OK with %p\n", This);
+ return S_OK;
+}
/*************************************************************************
* SHGetThreadRef [SHLWAPI.@]
@@ -131,13 +218,13 @@
*
* RETURNS
* Success: S_OK. lppUnknown is set to the object reference.
- * Failure: E_NOINTERFACE, if an error occurs or lppUnknown is NULL.
+ * Failure: E_NOINTERFACE, if an error occurs or no object is set
*/
HRESULT WINAPI SHGetThreadRef(IUnknown **lppUnknown)
{
TRACE("(%p)\n", lppUnknown);
- if (!lppUnknown || SHLWAPI_ThreadRef_index == TLS_OUT_OF_INDEXES)
+ if (SHLWAPI_ThreadRef_index == TLS_OUT_OF_INDEXES)
return E_NOINTERFACE;
*lppUnknown = TlsGetValue(SHLWAPI_ThreadRef_index);
@@ -159,13 +246,13 @@
*
* RETURNS
* Success: S_OK. lpUnknown is stored and can be retrieved by SHGetThreadRef()
- * Failure: E_NOINTERFACE, if an error occurs or lpUnknown is NULL.
+ * Failure: E_NOINTERFACE, if an error occurs
*/
HRESULT WINAPI SHSetThreadRef(IUnknown *lpUnknown)
{
TRACE("(%p)\n", lpUnknown);
- if (!lpUnknown || SHLWAPI_ThreadRef_index == TLS_OUT_OF_INDEXES)
+ if (SHLWAPI_ThreadRef_index == TLS_OUT_OF_INDEXES)
return E_NOINTERFACE;
TlsSetValue(SHLWAPI_ThreadRef_index, lpUnknown);
Modified: trunk/reactos/dll/win32/shlwapi/url.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shlwapi/url.c?re…
==============================================================================
--- trunk/reactos/dll/win32/shlwapi/url.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shlwapi/url.c [iso-8859-1] Sat May 29 19:47:03 2010
@@ -232,40 +232,34 @@
HRESULT WINAPI UrlCanonicalizeA(LPCSTR pszUrl, LPSTR pszCanonicalized,
LPDWORD pcchCanonicalized, DWORD dwFlags)
{
- LPWSTR base, canonical;
+ LPWSTR url, canonical;
HRESULT ret;
- DWORD len, len2;
+ DWORD len;
TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_a(pszUrl),
pszCanonicalized,
pcchCanonicalized, dwFlags, pcchCanonicalized ? *pcchCanonicalized : -1);
- if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
+ if(!pszUrl || !pszCanonicalized || !pcchCanonicalized || !*pcchCanonicalized)
return E_INVALIDARG;
- base = HeapAlloc(GetProcessHeap(), 0,
- (2*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR));
- canonical = base + INTERNET_MAX_URL_LENGTH;
-
- MultiByteToWideChar(0, 0, pszUrl, -1, base, INTERNET_MAX_URL_LENGTH);
- len = INTERNET_MAX_URL_LENGTH;
-
- ret = UrlCanonicalizeW(base, canonical, &len, dwFlags);
- if (ret != S_OK) {
- *pcchCanonicalized = len * 2;
- HeapFree(GetProcessHeap(), 0, base);
- return ret;
- }
-
- len2 = WideCharToMultiByte(0, 0, canonical, -1, 0, 0, 0, 0);
- if (len2 > *pcchCanonicalized) {
- *pcchCanonicalized = len2;
- HeapFree(GetProcessHeap(), 0, base);
- return E_POINTER;
- }
- WideCharToMultiByte(0, 0, canonical, -1, pszCanonicalized, *pcchCanonicalized, 0,
0);
- *pcchCanonicalized = len;
- HeapFree(GetProcessHeap(), 0, base);
- return S_OK;
+ len = strlen(pszUrl)+1;
+ url = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
+ canonical = HeapAlloc(GetProcessHeap(), 0, *pcchCanonicalized*sizeof(WCHAR));
+ if(!url || !canonical) {
+ HeapFree(GetProcessHeap(), 0, url);
+ HeapFree(GetProcessHeap(), 0, canonical);
+ return E_OUTOFMEMORY;
+ }
+
+ MultiByteToWideChar(0, 0, pszUrl, -1, url, len);
+
+ ret = UrlCanonicalizeW(url, canonical, pcchCanonicalized, dwFlags);
+ if(ret == S_OK)
+ WideCharToMultiByte(0, 0, canonical, -1, pszCanonicalized,
+ *pcchCanonicalized+1, 0, 0);
+
+ HeapFree(GetProcessHeap(), 0, canonical);
+ return ret;
}
/*************************************************************************
@@ -287,11 +281,12 @@
static const WCHAR wszFile[] =
{'f','i','l','e',':'};
static const WCHAR wszRes[] = {'r','e','s',':'};
static const WCHAR wszLocalhost[] =
{'l','o','c','a','l','h','o','s','t'};
+ static const WCHAR wszFilePrefix[] =
{'f','i','l','e',':','/','/','/'};
TRACE("(%s, %p, %p, 0x%08x) *pcchCanonicalized: %d\n", debugstr_w(pszUrl),
pszCanonicalized,
pcchCanonicalized, dwFlags, pcchCanonicalized ? *pcchCanonicalized : -1);
- if(!pszUrl || !pszCanonicalized || !pcchCanonicalized)
+ if(!pszUrl || !pszCanonicalized || !pcchCanonicalized || !*pcchCanonicalized)
return E_INVALIDARG;
if(!*pszUrl) {
@@ -300,8 +295,9 @@
}
nByteLen = (strlenW(pszUrl) + 1) * sizeof(WCHAR); /* length in bytes */
+ /* Allocate memory for simplified URL (before escaping) */
lpszUrlCpy = HeapAlloc(GetProcessHeap(), 0,
- INTERNET_MAX_URL_LENGTH * sizeof(WCHAR));
+ nByteLen+sizeof(wszFilePrefix)+sizeof(WCHAR));
if((dwFlags & URL_FILE_USE_PATHURL) && nByteLen >= sizeof(wszFile)
&& !memcmp(wszFile, pszUrl, sizeof(wszFile)))
@@ -328,8 +324,6 @@
state = 0;
if(pszUrl[1] == ':') { /* Assume path */
- static const WCHAR wszFilePrefix[] =
{'f','i','l','e',':','/','/','/'};
-
memcpy(wk2, wszFilePrefix, sizeof(wszFilePrefix));
wk2 += sizeof(wszFilePrefix)/sizeof(WCHAR);
if (dwFlags & URL_FILE_USE_PATHURL)
@@ -833,6 +827,8 @@
if (ret == S_OK) {
/* Reuse mrelative as temp storage as its already allocated and not needed anymore */
+ if(*pcchCombined == 0)
+ *pcchCombined = 1;
ret = UrlCanonicalizeW(preliminary, mrelative, pcchCombined, (dwFlags &
~URL_FILE_USE_PATHURL));
if(SUCCEEDED(ret) && pszCombined) {
lstrcpyW(pszCombined, mrelative);