[SHLWAPI_WINETEST] Sync with Wine Staging 2.9. CORE-13362
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:40:14 +0000 (22:40 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 3 Jun 2017 22:40:14 +0000 (22:40 +0000)
svn path=/trunk/; revision=74848

rostests/winetests/shlwapi/istream.c
rostests/winetests/shlwapi/string.c

index e40545c..9aefb1f 100644 (file)
 #include <winnls.h>
 #include <winreg.h>
 #include <objbase.h>
-//#include "shlwapi.h"
-
-
-/* Function pointers for the SHCreateStreamOnFile functions */
-static HMODULE hShlwapi;
-static HRESULT (WINAPI *pSHCreateStreamOnFileA)(LPCSTR file, DWORD mode, IStream **stream);
-static HRESULT (WINAPI *pSHCreateStreamOnFileW)(LPCWSTR file, DWORD mode, IStream **stream);
-static HRESULT (WINAPI *pSHCreateStreamOnFileEx)(LPCWSTR file, DWORD mode, DWORD attributes, BOOL create, IStream *template, IStream **stream);
-
-static BOOL is_win2000_IE5 = FALSE;
+#include <shlwapi.h>
 
 static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
 {
@@ -86,21 +77,10 @@ static void test_IStream_invalid_operations(IStream * stream, DWORD mode)
     {
         ok(ret == STG_E_ACCESSDENIED /* XP */ || broken(ret == S_OK) /* Win2000 + IE5 */,
            "expected STG_E_ACCESSDENIED, got 0x%08x\n", ret);
-        if (ret == S_OK)
-            is_win2000_IE5 = TRUE;
     }
     else
         ok(ret == S_OK, "expected S_OK, got 0x%08x\n", ret);
 
-    /* IStream::Write calls below hang under Win2000 + IE5, Win2000 + IE6 SP1
-     * and newer Windows versions pass these tests.
-     */
-    if (is_win2000_IE5)
-    {
-        win_skip("broken IStream::Write implementation (win2000)\n");
-        return;
-    }
-
     strcpy(data, "Hello");
     ret = stream->lpVtbl->Write(stream, data, 5, NULL);
     if (mode == STGM_READ)
@@ -290,7 +270,7 @@ static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
     /* invalid arguments */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(NULL, mode | stgm, &stream);
+    ret = SHCreateStreamOnFileA(NULL, mode | stgm, &stream);
     if (ret == E_INVALIDARG) /* Win98 SE */ {
         win_skip("Not supported\n");
         return;
@@ -304,34 +284,34 @@ static void test_SHCreateStreamOnFileA(DWORD mode, DWORD stgm)
 
 if (0) /* This test crashes on WinXP SP2 */
 {
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | stgm, NULL);
+    ret = SHCreateStreamOnFileA(test_file, mode | stgm, NULL);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret);
 }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CONVERT | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_CONVERT | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_TRANSACTED | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_TRANSACTED | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileA: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
 
     /* file does not exist */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
     ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "SHCreateStreamOnFileA: expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileA: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_CREATE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n");
 
@@ -347,7 +327,7 @@ if (0) /* This test crashes on WinXP SP2 */
     /* file exists */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n");
 
@@ -359,7 +339,7 @@ if (0) /* This test crashes on WinXP SP2 */
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileA)(test_file, mode | STGM_CREATE | stgm, &stream);
+    ret = SHCreateStreamOnFileA(test_file, mode | STGM_CREATE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileA: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileA: expected a valid IStream object, got NULL\n");
 
@@ -401,7 +381,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
     {
         /* Crashes on NT4 */
         stream = NULL;
-        ret = (*pSHCreateStreamOnFileW)(NULL, mode | stgm, &stream);
+        ret = SHCreateStreamOnFileW(NULL, mode | stgm, &stream);
         ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* XP */
            ret == E_INVALIDARG /* Vista */,
           "SHCreateStreamOnFileW: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) or E_INVALIDARG, got 0x%08x\n", ret);
@@ -411,29 +391,29 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
     if (0)
     {
         /* This test crashes on WinXP SP2 */
-            ret = (*pSHCreateStreamOnFileW)(test_file, mode | stgm, NULL);
+            ret = SHCreateStreamOnFileW(test_file, mode | stgm, NULL);
             ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret);
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CONVERT | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_CONVERT | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_DELETEONRELEASE | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_TRANSACTED | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_TRANSACTED | stgm, &stream);
     ok(ret == E_INVALIDARG, "SHCreateStreamOnFileW: expected E_INVALIDARG, got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream);
 
     /* file does not exist */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
     if (ret == E_INVALIDARG) /* Win98 SE */ {
         win_skip("Not supported\n");
         return;
@@ -443,7 +423,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
     ok(stream == NULL, "SHCreateStreamOnFileW: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_CREATE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n");
 
@@ -459,7 +439,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
     /* file exists */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_FAILIFTHERE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n");
 
@@ -471,7 +451,7 @@ static void test_SHCreateStreamOnFileW(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileW)(test_file, mode | STGM_CREATE | stgm, &stream);
+    ret = SHCreateStreamOnFileW(test_file, mode | STGM_CREATE | stgm, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileW: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileW: expected a valid IStream object, got NULL\n");
 
@@ -516,7 +496,7 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     {
         /* Crashes on NT4 */
         stream = NULL;
-        ret = (*pSHCreateStreamOnFileEx)(NULL, mode, 0, FALSE, NULL, &stream);
+        ret = SHCreateStreamOnFileEx(NULL, mode, 0, FALSE, NULL, &stream);
         ok(ret == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* XP */
            ret == E_INVALIDARG /* Vista */,
           "SHCreateStreamOnFileEx: expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) or E_INVALIDARG, got 0x%08x\n", ret);
@@ -524,11 +504,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode, 0, FALSE, template, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode, 0, FALSE, template, &stream);
     if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
         win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
         Sleep(1000);
-        ret = (*pSHCreateStreamOnFileEx)(test_file, mode, 0, FALSE, template, &stream);
+        ret = SHCreateStreamOnFileEx(test_file, mode, 0, FALSE, template, &stream);
     }
     ok( ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) ||
         ret == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER),
@@ -540,14 +520,14 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     if (0)
     {
         /* This test crashes on WinXP SP2 */
-        ret = (*pSHCreateStreamOnFileEx)(test_file, mode, 0, FALSE, NULL, NULL);
+        ret = SHCreateStreamOnFileEx(test_file, mode, 0, FALSE, NULL, NULL);
         ok(ret == E_INVALIDARG, "SHCreateStreamOnFileEx: expected E_INVALIDARG, got 0x%08x\n", ret);
     }
 
     /* file does not exist */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_FAILIFTHERE | stgm, 0, FALSE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_FAILIFTHERE | stgm, 0, FALSE, NULL, &stream);
     if ((stgm & STGM_TRANSACTED) == STGM_TRANSACTED && mode == STGM_READ) {
         ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) /* XP */ || ret == E_INVALIDARG /* Vista */,
           "SHCreateStreamOnFileEx: expected E_INVALIDARG or HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got 0x%08x\n", ret);
@@ -565,7 +545,7 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     ok(stream == NULL, "SHCreateStreamOnFileEx: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_FAILIFTHERE | stgm, 0, TRUE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_FAILIFTHERE | stgm, 0, TRUE, NULL, &stream);
     /* not supported on win9x */
     if (broken(ret == HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER) && stream == NULL)) {
         skip("Not supported\n");
@@ -588,11 +568,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
     if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
         win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
         Sleep(1000);
-        ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
+        ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
     }
     ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
@@ -609,11 +589,11 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
     if (ret == HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED)) {
         win_skip("File probably locked by Anti-Virus/Spam software, trying again\n");
         Sleep(1000);
-        ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
+        ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
     }
     ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
@@ -630,7 +610,7 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     /* file exists */
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_FAILIFTHERE | stgm, 0, FALSE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_FAILIFTHERE | stgm, 0, FALSE, NULL, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
 
@@ -642,12 +622,12 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_FAILIFTHERE | stgm, 0, TRUE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_FAILIFTHERE | stgm, 0, TRUE, NULL, &stream);
     ok(ret == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "SHCreateStreamOnFileEx: expected HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), got 0x%08x\n", ret);
     ok(stream == NULL, "SHCreateStreamOnFileEx: expected a NULL IStream object, got %p\n", stream);
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, FALSE, NULL, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
 
@@ -659,7 +639,7 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
     }
 
     stream = NULL;
-    ret = (*pSHCreateStreamOnFileEx)(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
+    ret = SHCreateStreamOnFileEx(test_file, mode | STGM_CREATE | stgm, 0, TRUE, NULL, &stream);
     ok(ret == S_OK, "SHCreateStreamOnFileEx: expected S_OK, got 0x%08x\n", ret);
     ok(stream != NULL, "SHCreateStreamOnFileEx: expected a valid IStream object, got NULL\n");
 
@@ -692,7 +672,7 @@ static void test_SHCreateStreamOnFileEx_CopyTo(void)
     GetTempFileNameW(tmpPath, prefix, 0, srcFileName);
     GetTempFileNameW(tmpPath, prefix, 0, dstFileName);
 
-    ret = pSHCreateStreamOnFileEx(srcFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &src);
+    ret = SHCreateStreamOnFileEx(srcFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &src);
     ok(SUCCEEDED(ret), "SHCreateStreamOnFileEx failed with ret=0x%08x\n", ret);
 
     written.QuadPart = 0;
@@ -703,7 +683,7 @@ static void test_SHCreateStreamOnFileEx_CopyTo(void)
     ret = IStream_Seek(src, distance, STREAM_SEEK_SET, &written);
     ok(SUCCEEDED(ret), "ISequentialStream_Seek failed with ret=0x%08x\n", ret);
 
-    ret = pSHCreateStreamOnFileEx(dstFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &dst);
+    ret = SHCreateStreamOnFileEx(dstFileName, STGM_CREATE | STGM_READWRITE | STGM_DELETEONRELEASE, FILE_ATTRIBUTE_TEMPORARY, FALSE, NULL, &dst);
     ok(SUCCEEDED(ret), "SHCreateStreamOnFileEx failed with ret=0x%08x\n", ret);
 
     /* Test using a count larger than the source file, so that the Read operation will fall short */
@@ -750,35 +730,15 @@ START_TEST(istream)
 
     int i, j, k;
 
-    hShlwapi = LoadLibraryA("shlwapi.dll");
-
-    pSHCreateStreamOnFileA = (void*)GetProcAddress(hShlwapi, "SHCreateStreamOnFileA");
-    pSHCreateStreamOnFileW = (void*)GetProcAddress(hShlwapi, "SHCreateStreamOnFileW");
-    pSHCreateStreamOnFileEx = (void*)GetProcAddress(hShlwapi, "SHCreateStreamOnFileEx");
-
-    if (!pSHCreateStreamOnFileA)
-        skip("SHCreateStreamOnFileA not found.\n");
-
-    if (!pSHCreateStreamOnFileW)
-        skip("SHCreateStreamOnFileW not found.\n");
-
-    if (!pSHCreateStreamOnFileEx)
-        skip("SHCreateStreamOnFileEx not found.\n");
-
     for (i = 0; i != sizeof(stgm_access)/sizeof(stgm_access[0]); i++) {
         for (j = 0; j != sizeof(stgm_sharing)/sizeof(stgm_sharing[0]); j ++) {
-            if (pSHCreateStreamOnFileA)
-                test_SHCreateStreamOnFileA(stgm_access[i], stgm_sharing[j]);
-
-            if (pSHCreateStreamOnFileW)
-                test_SHCreateStreamOnFileW(stgm_access[i], stgm_sharing[j]);
+            test_SHCreateStreamOnFileA(stgm_access[i], stgm_sharing[j]);
+            test_SHCreateStreamOnFileW(stgm_access[i], stgm_sharing[j]);
 
-            if (pSHCreateStreamOnFileEx) {
-                for (k = 0; k != sizeof(stgm_flags)/sizeof(stgm_flags[0]); k++)
-                    test_SHCreateStreamOnFileEx(stgm_access[i], stgm_sharing[j] | stgm_flags[k]);
-            }
+            for (k = 0; k != sizeof(stgm_flags)/sizeof(stgm_flags[0]); k++)
+                test_SHCreateStreamOnFileEx(stgm_access[i], stgm_sharing[j] | stgm_flags[k]);
         }
     }
 
-    if (pSHCreateStreamOnFileEx) test_SHCreateStreamOnFileEx_CopyTo();
+    test_SHCreateStreamOnFileEx_CopyTo();
 }
index a35ee2c..7bd30fc 100755 (executable)
@@ -993,6 +993,7 @@ static void test_StrXXX_overflows(void)
     WCHAR wstr1[2*MAX_PATH+1], wbuf[2*MAX_PATH];
     const WCHAR fmt[] = {'%','s',0};
     STRRET strret;
+    HRESULT hres;
     int ret;
     int i;
 
@@ -1064,9 +1065,27 @@ if (0)
         memset(wbuf, 0xbf, sizeof(wbuf));
         strret.uType = STRRET_WSTR;
         U(strret).pOleStr = StrDupW(wstr1);
-        expect_eq2(pStrRetToBufW(&strret, NULL, wbuf, 10), S_OK, E_NOT_SUFFICIENT_BUFFER /* Vista */, HRESULT, "%x");
+        hres = pStrRetToBufW(&strret, NULL, wbuf, 10);
+        ok(hres == E_NOT_SUFFICIENT_BUFFER || broken(hres == S_OK) /* winxp */,
+           "StrRetToBufW returned %08x\n", hres);
+        if (hres == E_NOT_SUFFICIENT_BUFFER)
+            expect_eq(wbuf[0], 0, WCHAR, "%x");
         expect_eq(wbuf[9], 0, WCHAR, "%x");
         expect_eq(wbuf[10], (WCHAR)0xbfbf, WCHAR, "%x");
+
+        memset(wbuf, 0xbf, sizeof(wbuf));
+        strret.uType = STRRET_CSTR;
+        StrCpyNA(U(strret).cStr, str1, MAX_PATH);
+        hres = pStrRetToBufW(&strret, NULL, wbuf, 10);
+        ok(hres == S_OK, "StrRetToBufW returned %08x\n", hres);
+        ok(!memcmp(wbuf, wstr1, 9*sizeof(WCHAR)) && !wbuf[9], "StrRetToBuf returned %s\n", wine_dbgstr_w(wbuf));
+
+        memset(wbuf, 0xbf, sizeof(wbuf));
+        strret.uType = STRRET_WSTR;
+        U(strret).pOleStr = NULL;
+        hres = pStrRetToBufW(&strret, NULL, wbuf, 10);
+        ok(hres == E_FAIL, "StrRetToBufW returned %08x\n", hres);
+        ok(!wbuf[0], "StrRetToBuf returned %s\n", wine_dbgstr_w(wbuf));
     }
     else
         win_skip("StrRetToBufW() is not available\n");