Sync to Wine-20050419: Peter Berg Larsen pebl@math.ku.dk - Strncpy elimination. - Janitorial: Get rid of strncpy/strncpyW. Jakob Eriksson jakov@vmlinux.org - Get rid of HeapAlloc casts. Troy Rollo wine@troy.rollo.name - Corrections to UrlIsW and UrlIsA. - URL_IS_OPAQUE results depend only on the scheme, not on the URL. - URL_IS_FILEURL also only depends on the scheme ("file:"). Francois Gouget fgouget@free.fr - Assorted spelling fixes. Robert Shearman rob@codeweavers.com - Fix SHCopyKey to treat string parameter correctly as source path instead of destination path. Jon Griffiths jon_p_griffiths@yahoo.com - Use LMEM_ flags for LocalAlloc(), not GMEM_ (GlobalAlloc). - Implement @188,190,195,200,256,478,481. - IUnknown_EnableModeless() also handles IOleInPlaceActiveObject. - Tests and small fix for PathMakePretty(). - Fix a crash and test failure with early native dlls. Modified: trunk/reactos/include/wine/shlguid.h Modified: trunk/reactos/lib/shlwapi/istream.c Modified: trunk/reactos/lib/shlwapi/ordinal.c Modified: trunk/reactos/lib/shlwapi/path.c Modified: trunk/reactos/lib/shlwapi/reg.c Modified: trunk/reactos/lib/shlwapi/regstream.c Modified: trunk/reactos/lib/shlwapi/shlwapi.spec Modified: trunk/reactos/lib/shlwapi/string.c Modified: trunk/reactos/lib/shlwapi/url.c Modified: trunk/reactos/w32api/include/ocidl.h Modified: trunk/reactos/w32api/include/oleidl.h Modified: trunk/reactos/w32api/include/shlguid.h Modified: trunk/reactos/w32api/include/shlobj.h _____
Modified: trunk/reactos/include/wine/shlguid.h --- trunk/reactos/include/wine/shlguid.h 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/include/wine/shlguid.h 2005-05-06 16:23:24 UTC (rev 15050) @@ -34,6 +34,7 @@
DEFINE_SHLGUID(IID_IShellLinkW, 0x000214F9L, 0, 0); DEFINE_SHLGUID(IID_IShellExecuteHookA, 0x000214F5L, 0, 0); DEFINE_SHLGUID(IID_IShellExecuteHookW, 0x000214FBL, 0, 0); +DEFINE_SHLGUID(IID_IQueryInfo, 0x00021500L, 0, 0);
DEFINE_GUID(SID_STopLevelBrowser, 0x4C96BE40L, 0x915C, 0x11CF, 0x99, 0xD3, 0x00, 0xAA, 0x00, 0x4A, 0xE8, 0x37);
@@ -52,4 +53,7 @@
DEFINE_GUID(CLSID_AutoComplete, 0x00bb2763, 0x6a77, 0x11d0, 0xa5, 0x35, 0x00, 0xc0, 0x4f, 0xd7, 0xd0, 0x62);
+DEFINE_GUID(IID_IInputObject, 0x068284FAA, 0x6A48, 0x11D0, 0x8C, 0x78, 0x00, 0xC0, 0x4F, 0xD9, 0x18, 0xB4); +DEFINE_GUID(IID_IInputObjectSite, 0x0F1DB8392, 0x7331, 0x11D0, 0x8C, 0x99, 0x00, 0xA0, 0xC9, 0x2D, 0xBF, 0xE8); + #endif /* __WINE_SHLGUID_H */ _____
Modified: trunk/reactos/lib/shlwapi/istream.c --- trunk/reactos/lib/shlwapi/istream.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/istream.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -352,7 +352,7 @@
{ ISHFileStream* fileStream;
- fileStream = (ISHFileStream*)HeapAlloc(GetProcessHeap(), 0, sizeof(ISHFileStream)); + fileStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHFileStream));
if (fileStream) { _____
Modified: trunk/reactos/lib/shlwapi/ordinal.c --- trunk/reactos/lib/shlwapi/ordinal.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/ordinal.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -1339,7 +1339,7 @@
*lpUnknown = NULL;
TRACE("doing Release\n"); - + return IUnknown_Release(temp); }
@@ -1397,7 +1397,7 @@
if (lpUnknown1 == lpUnknown2) return TRUE; - + return FALSE; }
@@ -1848,12 +1848,46 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.188] + * + * Call IOleControlSite_TranslateAccelerator() on an object. + * + * PARAMS + * lpUnknown [I] Object supporting the IOleControlSite interface. + * lpMsg [I] Key message to be processed. + * dwModifiers [I] Flags containing the state of the modifier keys. + * + * RETURNS + * Success: S_OK. + * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL. + */ +HRESULT WINAPI IUnknown_TranslateAcceleratorOCS(IUnknown *lpUnknown, LPMSG lpMsg, DWORD dwModifiers) +{ + IOleControlSite* lpCSite = NULL; + HRESULT hRet = E_INVALIDARG; + + TRACE("(%p,%p,0x%08lx)\n", lpUnknown, lpMsg, dwModifiers); + if (lpUnknown) + { + hRet = IUnknown_QueryInterface(lpUnknown, &IID_IOleControlSite, + (void**)&lpCSite); + if (SUCCEEDED(hRet) && lpCSite) + { + hRet = IOleControlSite_TranslateAccelerator(lpCSite, lpMsg, dwModifiers); + IOleControlSite_Release(lpCSite); + } + } + return hRet; +} + + +/********************************************************************** *** * @ [SHLWAPI.189] * * Call IOleControlSite_GetExtendedControl() on an object. * * PARAMS - * lpUnknown [I] Object supporting the IOleControlSite interface + * lpUnknown [I] Object supporting the IOleControlSite interface. * lppDisp [O] Destination for resulting IDispatch. * * RETURNS @@ -1862,7 +1896,7 @@ */ DWORD WINAPI IUnknown_OnFocusOCS(IUnknown *lpUnknown, IDispatch** lppDisp) { - IOleControlSite* lpCSite; + IOleControlSite* lpCSite = NULL; HRESULT hRet = E_FAIL;
TRACE("(%p,%p)\n", lpUnknown, lppDisp); @@ -1880,6 +1914,41 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.190] + */ +HRESULT WINAPI IUnknown_HandleIRestrict(LPUNKNOWN lpUnknown, PVOID lpArg1, + PVOID lpArg2, PVOID lpArg3, PVOID lpArg4) +{ + /* FIXME: {D12F26B2-D90A-11D0-830D-00AA005B4383} - What object does this represent? */ + static const DWORD service_id[] = { 0xd12f26b2, 0x11d0d90a, 0xaa000d83, 0x83435b00 }; + /* FIXME: {D12F26B1-D90A-11D0-830D-00AA005B4383} - Also Unknown/undocumented */ + static const DWORD function_id[] = { 0xd12f26b1, 0x11d0d90a, 0xaa000d83, 0x83435b00 }; + HRESULT hRet = E_INVALIDARG; + LPUNKNOWN lpUnkInner = NULL; /* FIXME: Real type is unknown */ + + TRACE("(%p,%p,%p,%p,%p)\n", lpUnknown, lpArg1, lpArg2, lpArg3, lpArg4); + + if (lpUnknown && lpArg4) + { + hRet = IUnknown_QueryService(lpUnknown, (REFGUID)service_id, + (REFGUID)function_id, (void**)&lpUnkInner); + + if (SUCCEEDED(hRet) && lpUnkInner) + { + /* FIXME: The type of service object requested is unknown, however + * testing shows that its first method is called with 4 parameters. + * Fake this by using IParseDisplayName_ParseDisplayName since the + * signature and position in the vtable matches our unknown object type. + */ + hRet = IParseDisplayName_ParseDisplayName((LPPARSEDISPLAYNAME)lpUnkInner, + lpArg1, lpArg2, lpArg3, lpArg4); + IUnknown_Release(lpUnkInner); + } + } + return hRet; +} + +/********************************************************************** *** * @ [SHLWAPI.192] * * Get a sub-menu from a menu item. @@ -1966,6 +2035,55 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.195] + * + * Determine if a shell folder can be expanded. + * + * PARAMS + * lpFolder [I] Parent folder containing the object to test. + * pidl [I] Id of the object to test. + * + * RETURNS + * Success: S_OK, if the object is expandable, S_FALSE otherwise. + * Failure: E_INVALIDARG, if any argument is invalid. + * + * NOTES + * If the object to be tested does not expose the IQueryInfo() interface it + * will not be identified as an expandable folder. + */ +HRESULT WINAPI SHIsExpandableFolder(LPSHELLFOLDER lpFolder, LPCITEMIDLIST pidl) +{ + HRESULT hRet = E_INVALIDARG; + IQueryInfo *lpInfo; + + if (lpFolder && pidl) + { + hRet = IShellFolder_GetUIObjectOf(lpFolder, NULL, 1, &pidl, &IID_IQueryInfo, + NULL, (void**)&lpInfo); + if (FAILED(hRet)) + hRet = S_FALSE; /* Doesn't expose IQueryInfo */ + else + { + DWORD dwFlags = 0; + + /* MSDN states of IQueryInfo_GetInfoFlags() that "This method is not + * currently used". Really? You wouldn't be holding out on me would you? + */ + hRet = IQueryInfo_GetInfoFlags(lpInfo, &dwFlags); + + if (SUCCEEDED(hRet)) + { + /* 0x2 is an undocumented flag apparently indicating expandability */ + hRet = dwFlags & 0x2 ? S_OK : S_FALSE; + } + + IQueryInfo_Release(lpInfo); + } + } + return hRet; +} + +/********************************************************************** *** * @ [SHLWAPI.197] * * Blank out a region of text by drawing the background only. @@ -2051,6 +2169,21 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.200] + * + */ +HRESULT WINAPI MayQSForward(IUnknown* lpUnknown, PVOID lpReserved, + REFGUID riidCmdGrp, ULONG cCmds, + OLECMD *prgCmds, OLECMDTEXT* pCmdText) +{ + FIXME("(%p,%p,%p,%ld,%p,%p) - stub\n", + lpUnknown, lpReserved, riidCmdGrp, cCmds, prgCmds, pCmdText); + + /* FIXME: Calls IsQSForward & IUnknown_QueryStatus */ + return DRAGDROP_E_NOTREGISTERED; +} + +/********************************************************************** *** * @ [SHLWAPI.201] * */ @@ -2351,6 +2484,29 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.256] + */ +HRESULT WINAPI IUnknown_GetSite(LPUNKNOWN lpUnknown, REFIID iid, PVOID *lppSite) +{ + HRESULT hRet = E_INVALIDARG; + LPOBJECTWITHSITE lpSite = NULL; + + TRACE("(%p,%s,%p)\n", lpUnknown, debugstr_guid(iid), lppSite); + + if (lpUnknown && iid && lppSite) + { + hRet = IUnknown_QueryInterface(lpUnknown, &IID_IObjectWithSite, + (void**)&lpSite); + if (SUCCEEDED(hRet) && lpSite) + { + hRet = IObjectWithSite_GetSite(lpSite, iid, lppSite); + IObjectWithSite_Release(lpSite); + } + } + return hRet; +} + +/********************************************************************** *** * @ [SHLWAPI.257] * * Create a worker window using CreateWindowExA(). @@ -2510,7 +2666,7 @@ * Failure: An HRESULT error code. * * NOTES - * This QueryInterface asks the inner object for a interface. In case + * This QueryInterface asks the inner object for an interface. In case * of aggregation this request would be forwarded by the inner to the * outer object. This function asks the inner object directly for the * interface circumventing the forwarding to the outer object. @@ -3051,7 +3207,8 @@ * NOTES * lpUnknown must support the IOleInPlaceFrame interface, the * IInternetSecurityMgrSite interface, the IShellBrowser interface - * or the IDocHostUIHandler interface, or this call fails. + * the IDocHostUIHandler interface, or the IOleInPlaceActiveObject interface, + * or this call will fail. */ HRESULT WINAPI IUnknown_EnableModeless(IUnknown *lpUnknown, BOOL bModeless) { @@ -3063,7 +3220,9 @@ if (!lpUnknown) return E_FAIL;
- if (IsIface(IOleInPlaceFrame)) + if (IsIface(IOleInPlaceActiveObject)) + EnableModeless(IOleInPlaceActiveObject); + else if (IsIface(IOleInPlaceFrame)) EnableModeless(IOleInPlaceFrame); else if (IsIface(IShellBrowser)) EnableModeless(IShellBrowser); @@ -3696,7 +3855,7 @@ case OS_HOME: ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT && majorv >= 5 && minorv >= 1) case OS_PROFESSIONAL: - ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT) + ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT) case OS_DATACENTER: ISOS_RETURN(platform == VER_PLATFORM_WIN32_NT) case OS_ADVSERVER: @@ -3747,6 +3906,70 @@ }
/*********************************************************************** ** + * @ [SHLWAPI.478] + * + * Call IInputObject_TranslateAcceleratorIO() on an object. + * + * PARAMS + * lpUnknown [I] Object supporting the IInputObject interface. + * lpMsg [I] Key message to be processed. + * + * RETURNS + * Success: S_OK. + * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL. + */ +HRESULT WINAPI IUnknown_TranslateAcceleratorIO(IUnknown *lpUnknown, LPMSG lpMsg) +{ + IInputObject* lpInput = NULL; + HRESULT hRet = E_INVALIDARG; + + TRACE("(%p,%p)\n", lpUnknown, lpMsg); + if (lpUnknown) + { + hRet = IUnknown_QueryInterface(lpUnknown, &IID_IInputObject, + (void**)&lpInput); + if (SUCCEEDED(hRet) && lpInput) + { + hRet = IInputObject_TranslateAcceleratorIO(lpInput, lpMsg); + IInputObject_Release(lpInput); + } + } + return hRet; +} + +/********************************************************************** *** + * @ [SHLWAPI.481] + * + * Call IInputObject_HasFocusIO() on an object. + * + * PARAMS + * lpUnknown [I] Object supporting the IInputObject interface. + * + * RETURNS + * Success: S_OK, if lpUnknown is an IInputObject object and has the focus, + * or S_FALSE otherwise. + * Failure: An HRESULT error code, or E_INVALIDARG if lpUnknown is NULL. + */ +HRESULT WINAPI IUnknown_HasFocusIO(IUnknown *lpUnknown) +{ + IInputObject* lpInput = NULL; + HRESULT hRet = E_INVALIDARG; + + TRACE("(%p)\n", lpUnknown); + if (lpUnknown) + { + hRet = IUnknown_QueryInterface(lpUnknown, &IID_IInputObject, + (void**)&lpInput); + if (SUCCEEDED(hRet) && lpInput) + { + hRet = IInputObject_HasFocusIO(lpInput); + IInputObject_Release(lpInput); + } + } + return hRet; +} + +/********************************************************************** *** * ColorRGBToHLS [SHLWAPI.@] * * Convert an rgb COLORREF into the hls color space. @@ -3940,9 +4163,9 @@
/*********************************************************************** ** * @ [SHLWAPI.461] */ -DWORD WINAPI SHGetAppCompatFlags(DWORD Unknown) +DWORD WINAPI SHGetAppCompatFlags(DWORD dwUnknown) { - FIXME("stub\n"); + FIXME("(0x%08lx) stub\n", dwUnknown); return 0; }
@@ -4015,17 +4238,24 @@
/*********************************************************************** * IUnknown_OnFocusChangeIS (SHLWAPI.@) */ -DWORD WINAPI IUnknown_OnFocusChangeIS(IUnknown * pUnk, IUnknown * pFocusObject, BOOL bChange) +HRESULT WINAPI IUnknown_OnFocusChangeIS(LPUNKNOWN lpUnknown, LPUNKNOWN pFocusObject, BOOL bFocus) { - FIXME("(%p, %p, %s)\n", pUnk, pFocusObject, bChange ? "TRUE" : "FALSE"); + IInputObjectSite *pIOS = NULL; + HRESULT hRet = E_INVALIDARG;
-/* - IInputObjectSite * pIOS = NULL; - if (SUCCEEDED(IUnknown_QueryInterface(pUnk, &IID_IInputObjectSite, (void **)&pIOS)) - IInputObjectSite_OnFocusChangeIS(pIOS, pFocusObject, bChange); -*/ + TRACE("(%p, %p, %s)\n", lpUnknown, pFocusObject, bFocus ? "TRUE" : "FALSE");
- return 0; + if (lpUnknown) + { + hRet = IUnknown_QueryInterface(lpUnknown, &IID_IInputObjectSite, + (void **)&pIOS); + if (SUCCEEDED(hRet) && pIOS) + { + hRet = IInputObjectSite_OnFocusChangeIS(pIOS, pFocusObject, bFocus); + IInputObjectSite_Release(pIOS); + } + } + return hRet; }
/*********************************************************************** _____
Modified: trunk/reactos/lib/shlwapi/path.c --- trunk/reactos/lib/shlwapi/path.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/path.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -168,14 +168,14 @@
if (!lpszFile || !*lpszFile) { /* Use dir only */ - strncpyW(szTemp, lpszDir, MAX_PATH); + lstrcpynW(szTemp, lpszDir, MAX_PATH); } else if (!lpszDir || !*lpszDir || !PathIsRelativeW(lpszFile)) { if (!lpszDir || !*lpszDir || *lpszFile != '\' || PathIsUNCW(lpszFile)) { /* Use file only */ - strncpyW(szTemp, lpszFile, MAX_PATH); + lstrcpynW(szTemp, lpszFile, MAX_PATH); } else { @@ -188,7 +188,7 @@
if (bUseBoth) { - strncpyW(szTemp, lpszDir, MAX_PATH); + lstrcpynW(szTemp, lpszDir, MAX_PATH); if (bStrip) { PathStripToRootW(szTemp); @@ -1687,7 +1687,8 @@ if (!lpszPath) return FALSE;
- iPrevErrMode = SetErrorMode(1); + /* Prevent a dialog box if path is on a disk that has been ejected. */ + iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); dwAttr = GetFileAttributesA(lpszPath); SetErrorMode(iPrevErrMode); return dwAttr == INVALID_FILE_ATTRIBUTES ? FALSE : TRUE; @@ -1708,7 +1709,7 @@ if (!lpszPath) return FALSE;
- iPrevErrMode = SetErrorMode(1); + iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); dwAttr = GetFileAttributesW(lpszPath); SetErrorMode(iPrevErrMode); return dwAttr == INVALID_FILE_ATTRIBUTES ? FALSE : TRUE; @@ -2580,21 +2581,24 @@
TRACE("(%s)\n", debugstr_a(lpszPath));
- if (!pszIter || !*pszIter) + if (!pszIter) return FALSE;
- while (*pszIter) + if (*pszIter) { - if (islower(*pszIter) || IsDBCSLeadByte(*pszIter)) - return FALSE; /* Not DOS path */ - pszIter++; + do + { + if (islower(*pszIter) || IsDBCSLeadByte(*pszIter)) + return FALSE; /* Not DOS path */ + pszIter++; + } while (*pszIter); + pszIter = lpszPath + 1; + while (*pszIter) + { + *pszIter = tolower(*pszIter); + pszIter++; + } } - pszIter = lpszPath + 1; - while (*pszIter) - { - *pszIter = tolower(*pszIter); - pszIter++; - } return TRUE; }
@@ -2609,21 +2613,24 @@
TRACE("(%s)\n", debugstr_w(lpszPath));
- if (!pszIter || !*pszIter) + if (!pszIter) return FALSE;
- while (*pszIter) + if (*pszIter) { - if (islowerW(*pszIter)) - return FALSE; /* Not DOS path */ - pszIter++; + do + { + if (islowerW(*pszIter)) + return FALSE; /* Not DOS path */ + pszIter++; + } while (*pszIter); + pszIter = lpszPath + 1; + while (*pszIter) + { + *pszIter = tolowerW(*pszIter); + pszIter++; + } } - pszIter = lpszPath + 1; - while (*pszIter) - { - *pszIter = tolowerW(*pszIter); - pszIter++; - } return TRUE; }
@@ -2767,7 +2774,7 @@ * dx [I] Desired width * * RETURNS - * TRUE If the path was modified. + * TRUE If the path was modified/went well. * FALSE Otherwise. */ BOOL WINAPI PathCompactPathA(HDC hDC, LPSTR lpszPath, UINT dx) @@ -2803,7 +2810,7 @@ TRACE("(%p,%s,%d)\n", hDC, debugstr_w(lpszPath), dx);
if (!lpszPath) - return bRet; + return FALSE;
if (!hDC) hdc = hDC = GetDC(0); @@ -2838,7 +2845,7 @@ * the file name as possible, allowing for the ellipses, e.g: * c:\some very long path\filename ==> c:\some v...\filename */ - strncpyW(buff, sFile, MAX_PATH); + lstrcpynW(buff, sFile, MAX_PATH);
do { @@ -2880,7 +2887,7 @@
if (dwLen > MAX_PATH - 3) dwLen = MAX_PATH - 3; - strncpyW(buff, sFile, dwLen); + lstrcpynW(buff, sFile, dwLen);
do { dwLen--; @@ -3390,8 +3397,8 @@ return FALSE;
*lpszPath = '\0'; - strncpyW(szFrom, lpszFrom, MAX_PATH); - strncpyW(szTo, lpszTo, MAX_PATH); + lstrcpynW(szFrom, lpszFrom, MAX_PATH); + lstrcpynW(szTo, lpszTo, MAX_PATH);
if(!(dwAttrFrom & FILE_ATTRIBUTE_DIRECTORY)) PathRemoveFileSpecW(szFrom); @@ -3739,7 +3746,7 @@ if (!lpszPath || !PathIsDirectoryW(lpszPath)) return FALSE;
- strncpyW(szSearch, lpszPath, MAX_PATH); + lstrcpynW(szSearch, lpszPath, MAX_PATH); PathAddBackslashW(szSearch); dwLen = strlenW(szSearch); if (dwLen > MAX_PATH - 4) _____
Modified: trunk/reactos/lib/shlwapi/reg.c --- trunk/reactos/lib/shlwapi/reg.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/reg.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -133,7 +133,7 @@
*phNewUSKey = NULL;
/* Create internal HUSKEY */ - hKey = (LPSHUSKEY)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*hKey)); + hKey = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*hKey)); lstrcpynW(hKey->lpszPath, Path, sizeof(hKey->lpszPath));
if (hRelativeUSKey) @@ -1305,7 +1305,7 @@ * * subcase-2: buffer is to small to hold the expanded string: * the function return success (!!) and the result is truncated - * *** This is clearly a error in the native implementation. *** + * *** This is clearly an error in the native implementation. *** * * case-2: the unexpanded string is bigger than the expanded one * The buffer must have enough space to hold the unexpanded @@ -1340,7 +1340,7 @@ char cNull = '\0'; nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData;
- szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc); + szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); RegQueryValueExA (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); dwExpDataLen = ExpandEnvironmentStringsA(szData, &cNull, 1); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); @@ -1349,7 +1349,7 @@ else { nBytesToAlloc = (lstrlenA(pvData)+1) * sizeof (CHAR); - szData = (LPSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc ); + szData = (LPSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc ); lstrcpyA(szData, pvData); dwExpDataLen = ExpandEnvironmentStringsA(szData, pvData, *pcbData / sizeof(CHAR)); if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; @@ -1401,7 +1401,7 @@ WCHAR cNull = '\0'; nBytesToAlloc = (!pvData || (dwRet == ERROR_MORE_DATA)) ? dwUnExpDataLen : *pcbData;
- szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc); + szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc); RegQueryValueExW (hKey, lpszValue, lpReserved, NULL, (LPBYTE)szData, &nBytesToAlloc); dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1); dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen); @@ -1410,7 +1410,7 @@ else { nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR); - szData = (LPWSTR) LocalAlloc(GMEM_ZEROINIT, nBytesToAlloc ); + szData = (LPWSTR) LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc ); lstrcpyW(szData, pvData); dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, *pcbData/sizeof(WCHAR) ); if (dwExpDataLen > *pcbData) dwRet = ERROR_MORE_DATA; @@ -2183,7 +2183,7 @@ * * PARAMS * hKeySrc [I] Source key to copy from - * lpszSubKey [I] Sub key under hKeyDst, or NULL to use hKeyDst directly + * lpszSrcSubKey [I] Sub key under hKeySrc, or NULL to use hKeySrc directly * hKeyDst [I] Destination key * dwReserved [I] Reserved, must be 0 * @@ -2196,16 +2196,16 @@ * (It will loop until out of stack, or the registry is full). This * bug is present in Win32 also. */ -DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSubKey, HKEY hKeyDst, DWORD dwReserved) +DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved) { WCHAR szSubKeyW[MAX_PATH];
- TRACE("(hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_a(lpszSubKey), hKeyDst, dwReserved); + TRACE("(hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_a(lpszSrcSubKey), hKeyDst, dwReserved);
- if (lpszSubKey) - MultiByteToWideChar(0, 0, lpszSubKey, -1, szSubKeyW, MAX_PATH); + if (lpszSrcSubKey) + MultiByteToWideChar(0, 0, lpszSrcSubKey, -1, szSubKeyW, MAX_PATH);
- return SHCopyKeyW(hKeySrc, lpszSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved); + return SHCopyKeyW(hKeySrc, lpszSrcSubKey ? szSubKeyW : NULL, hKeyDst, dwReserved); }
/*********************************************************************** ** @@ -2213,7 +2213,7 @@ * * See SHCopyKeyA. */ -DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dwReserved) +DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSrcSubKey, HKEY hKeyDst, DWORD dwReserved) { DWORD dwKeyCount = 0, dwValueCount = 0, dwMaxKeyLen = 0; DWORD dwMaxValueLen = 0, dwMaxDataLen = 0, i; @@ -2222,18 +2222,18 @@ WCHAR szName[MAX_PATH], *lpszName = szName; DWORD dwRet = S_OK;
- TRACE("hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_w(lpszSubKey), hKeyDst, dwReserved); + TRACE("hkey=%p,%s,%p08x,%ld)\n", hKeySrc, debugstr_w(lpszSrcSubKey), hKeyDst, dwReserved);
if(!hKeyDst || !hKeySrc) dwRet = ERROR_INVALID_PARAMETER; else { - /* Open destination key */ - if(lpszSubKey) - dwRet = RegOpenKeyExW(hKeyDst, lpszSubKey, 0, KEY_ALL_ACCESS, &hKeyDst); + /* Open source key */ + if(lpszSrcSubKey) + dwRet = RegOpenKeyExW(hKeySrc, lpszSrcSubKey, 0, KEY_ALL_ACCESS, &hKeySrc);
if(dwRet) - hKeyDst = 0; /* Don't close this key since we didn't open it */ + hKeyDst = NULL; /* Don't close this key since we didn't open it */ else { /* Get details about sub keys and values */ @@ -2303,7 +2303,7 @@ if (lpBuff != buff) HeapFree(GetProcessHeap(), 0, lpBuff);
- if (lpszSubKey && hKeyDst) + if (lpszSrcSubKey && hKeyDst) RegCloseKey(hKeyDst); return dwRet; } _____
Modified: trunk/reactos/lib/shlwapi/regstream.c --- trunk/reactos/lib/shlwapi/regstream.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/regstream.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -343,7 +343,7 @@
{ ISHRegStream* regStream;
- regStream = (ISHRegStream*)HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream)); + regStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream));
if (regStream) { @@ -493,7 +493,7 @@
if (lpbData) { - LPBYTE lpbDup = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, dwDataLen); + LPBYTE lpbDup = HeapAlloc(GetProcessHeap(), 0, dwDataLen);
if (lpbDup) { _____
Modified: trunk/reactos/lib/shlwapi/shlwapi.spec --- trunk/reactos/lib/shlwapi/shlwapi.spec 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/shlwapi.spec 2005-05-06 16:23:24 UTC (rev 15050) @@ -185,19 +185,19 @@
185 stdcall -noname SHMessageBoxCheckA(ptr str str long long str) 186 stdcall -noname SHSimulateDrop(ptr ptr long ptr ptr) 187 stdcall -noname SHLoadFromPropertyBag(ptr ptr) -188 stub -noname IUnknown_TranslateAcceleratorOCS +188 stdcall -noname IUnknown_TranslateAcceleratorOCS(ptr ptr long) 189 stdcall -noname IUnknown_OnFocusOCS(ptr ptr) -190 stub -noname IUnknown_HandleIRestrict +190 stdcall -noname IUnknown_HandleIRestrict(ptr ptr ptr ptr ptr) 191 stdcall -noname SHMessageBoxCheckW(ptr wstr wstr long long wstr) 192 stdcall -noname SHGetMenuFromID(ptr long) 193 stdcall -noname SHGetCurColorRes() 194 stdcall -noname SHWaitForSendMessageThread(ptr long) -195 stub -noname SHIsExpandableFolder -196 stub -noname DnsRecordSetCompare +195 stdcall -noname SHIsExpandableFolder(ptr ptr) +196 stub -noname DnsRecordSetCompare #stdcall @(ptr ptr ptr ptr) dnsapi.DnsRecordSetCompare 197 stdcall -noname SHFillRectClr(long ptr long) 198 stdcall -noname SHSearchMapInt(ptr ptr long long) 199 stdcall -noname IUnknown_Set(ptr ptr) -200 stub -noname MayQSForward +200 stdcall -noname MayQSForward(ptr ptr ptr long ptr ptr) 201 stdcall -noname MayExecForward(ptr long ptr long long ptr ptr) 202 stdcall -noname IsQSForward(ptr long ptr) 203 stdcall -noname SHStripMneumonicA(str) @@ -253,7 +253,7 @@ 253 stub -noname StopWatchExA 254 stub -noname StopWatchExW 255 stub -noname EventTraceHandler -256 stub -noname IUnknown_GetSite +256 stdcall -noname IUnknown_GetSite(ptr ptr ptr) 257 stdcall -noname SHCreateWorkerWindowA(long ptr long long ptr long) 258 stub -noname SHRegisterWaitForSingleObject 259 stub -noname SHUnregisterWait @@ -475,10 +475,10 @@ 475 stub -noname GetShellSecurityDescriptor 476 stub -noname SHGetObjectCompatFlags 477 stub -noname SHCreatePropertyBagOnMemory -478 stub -noname IUnknown_TranslateAcceleratorIO +478 stdcall -noname IUnknown_TranslateAcceleratorIO(ptr ptr) 479 stub -noname IUnknown_UIActivateIO 480 stub -noname UrlCrackW -481 stub -noname IUnknown_HasFocusIO +481 stdcall -noname IUnknown_HasFocusIO(ptr) 482 stub -noname SHMessageBoxHelpA 483 stub -noname SHMessageBoxHelpW 484 stub -noname IUnknown_QueryServiceExec @@ -543,7 +543,7 @@
548 stub -noname SHAreIconsEqual 549 stdcall -noname SHCoCreateInstanceAC(ptr ptr long ptr ptr) -550 stub -noname GetTemplateInfoFroHandle +550 stub -noname GetTemplateInfoFromHandle 551 stub -noname IShellFolder_CompareIDs
@ stdcall AssocCreate(long long long long ptr ptr) _____
Modified: trunk/reactos/lib/shlwapi/string.c --- trunk/reactos/lib/shlwapi/string.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/string.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -1577,7 +1577,7 @@
ulKB = (ulKB - ulNextDigit) / 10; } while (ulKB > 0);
- strncpy(lpszDest, szOut + 1, cchMax); + lstrcpynA(lpszDest, szOut + 1, cchMax); return lpszDest; }
@@ -1605,7 +1605,7 @@ ulKB = (ulKB - ulNextDigit) / 10; } while (ulKB > 0);
- strncpyW(lpszDest, szOut + 1, cchMax); + lstrcpynW(lpszDest, szOut + 1, cchMax); return lpszDest; }
@@ -2027,7 +2027,7 @@ if (iDigits) /* Always write seconds if we have significant digits */ SHLWAPI_WriteTimeClass(szCopy, dwMS, szSec, iDigits);
- strncpyW(lpszStr, szCopy, cchMax); + lstrcpynW(lpszStr, szCopy, cchMax); iRet = strlenW(lpszStr); } return iRet; @@ -2301,7 +2301,7 @@ sprintfW(wszBuff, bfFormats[i].lpwszFormat, dBytes); wszAdd[1] = bfFormats[i].wPrefix; strcatW(wszBuff, wszAdd); - strncpyW(lpszDest, wszBuff, cchMax); + lstrcpynW(lpszDest, wszBuff, cchMax); return lpszDest; }
@@ -2546,7 +2546,7 @@
if (nWideCharCount < len - 1) { - mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpiLen); + mem = HeapAlloc(GetProcessHeap(), 0, *lpiLen); if (!mem) return 0;
@@ -2577,7 +2577,7 @@ reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, NULL, 0, NULL, NULL); if (reqLen) { - mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, reqLen); + mem = HeapAlloc(GetProcessHeap(), 0, reqLen); if (mem) { reqLen = WideCharToMultiByte(CodePage, 0, lpSrcStr, len, mem, @@ -2638,9 +2638,6 @@
TRACE("(%s,%p,0x%08x)\n", debugstr_a(lpszSrc), lpszDst, iLen);
- /* Our original version used lstrncpy/lstrlen, incorrectly filling up all - * of lpszDst with extra NULs. This version is correct, and faster too. - */ lpszRet = StrCpyNXA(lpszDst, lpszSrc, iLen); return lpszRet - lpszDst + 1; } _____
Modified: trunk/reactos/lib/shlwapi/url.c --- trunk/reactos/lib/shlwapi/url.c 2005-05-06 16:21:30 UTC (rev 15049) +++ trunk/reactos/lib/shlwapi/url.c 2005-05-06 16:23:24 UTC (rev 15050) @@ -238,7 +238,7 @@
/* see if known scheme and return indicator number */ len = WideCharToMultiByte(0, 0, y->pszProtocol, y->cchProtocol, 0, 0, 0, 0); - cmpstr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, len); + cmpstr = HeapAlloc(GetProcessHeap(), 0, len); WideCharToMultiByte(0, 0, y->pszProtocol, y->cchProtocol, cmpstr, len, 0, 0); y->nScheme = URL_SCHEME_UNKNOWN; inet_pro = shlwapi_schemes; @@ -329,7 +329,7 @@ DWORD EscapeFlags; LPWSTR lpszUrlCpy, wk1, wk2, mp, root; INT nByteLen, state; - DWORD nLen; + DWORD nLen, nWkLen;
TRACE("(%s %p %p 0x%08lx)\n", debugstr_w(pszUrl), pszCanonicalized, pcchCanonicalized, dwFlags); @@ -379,9 +379,10 @@ state = 4; break; case 3: - strcpyW(wk2, wk1); - wk1 += strlenW(wk1); - wk2 += strlenW(wk2); + nWkLen = strlenW(wk1); + memcpy(wk2, wk1, (nWkLen + 1) * sizeof(WCHAR)); + wk1 += nWkLen; + wk2 += nWkLen; break; case 4: if (!isalnumW(*wk1) && (*wk1 != L'-') && (*wk1 != L'.')) {state = 3; break;} @@ -401,13 +402,14 @@ TRACE("wk1=%c\n", (CHAR)*wk1); mp = strchrW(wk1, L'/'); if (!mp) { - strcpyW(wk2, wk1); - wk1 += strlenW(wk1); - wk2 += strlenW(wk2); + nWkLen = strlenW(wk1); + memcpy(wk2, wk1, (nWkLen + 1) * sizeof(WCHAR)); + wk1 += nWkLen; + wk2 += nWkLen; continue; } nLen = mp - wk1 + 1; - strncpyW(wk2, wk1, nLen); + memcpy(wk2, wk1, nLen * sizeof(WCHAR)); wk2 += nLen; wk1 += nLen; if (*wk1 == L'.') { @@ -517,7 +519,7 @@ if(!pszBase || !pszRelative || !pcchCombined) return E_INVALIDARG;
- base = (LPWSTR) HeapAlloc(GetProcessHeap(), 0, + base = HeapAlloc(GetProcessHeap(), 0, (3*INTERNET_MAX_URL_LENGTH) * sizeof(WCHAR)); relative = base + INTERNET_MAX_URL_LENGTH; combined = relative + INTERNET_MAX_URL_LENGTH; @@ -718,7 +720,7 @@ * Return the pszBase scheme with pszRelative. Basically * keeps the scheme and replaces the domain and following. */ - strncpyW(preliminary, base.pszProtocol, base.cchProtocol + 1); + memcpy(preliminary, base.pszProtocol, (base.cchProtocol + 1)*sizeof(WCHAR)); work = preliminary + base.cchProtocol + 1; strcpyW(work, relative.pszSuffix); if (!(dwFlags & URL_PLUGGABLE_PROTOCOL) && @@ -731,7 +733,7 @@ * after the location is pszRelative. (Replace document * from root on.) */ - strncpyW(preliminary, base.pszProtocol, base.cchProtocol+1+sizeloc); + memcpy(preliminary, base.pszProtocol, (base.cchProtocol+1+sizeloc)*sizeof(WCHAR)); work = preliminary + base.cchProtocol + 1 + sizeloc; if (dwFlags & URL_PLUGGABLE_PROTOCOL) *(work++) = L'/'; @@ -742,7 +744,8 @@ * Return the pszBase without its document (if any) and * append pszRelative after its scheme. */ - strncpyW(preliminary, base.pszProtocol, base.cchProtocol+1+base.cchSuffix); + memcpy(preliminary, base.pszProtocol, + (base.cchProtocol+1+base.cchSuffix)*sizeof(WCHAR)); work = preliminary + base.cchProtocol+1+base.cchSuffix - 1; if (*work++ != L'/') *(work++) = L'/'; @@ -1640,13 +1643,19 @@ base.cbSize = sizeof(base); res1 = ParseURLA(pszUrl, &base); if (res1) return FALSE; /* invalid scheme */ - if ((*base.pszSuffix == '/') && (*(base.pszSuffix+1) == '/')) - /* has scheme followed by 2 '/' */ - return FALSE; - return TRUE; + switch (base.nScheme) + { + case URL_SCHEME_MAILTO: + case URL_SCHEME_SHELL: + case URL_SCHEME_JAVASCRIPT: + case URL_SCHEME_VBSCRIPT: + case URL_SCHEME_ABOUT: + return TRUE; + } + return FALSE;
case URLIS_FILEURL: - return !StrCmpNA("file://", pszUrl, 7); + return !StrCmpNA("file:", pszUrl, 5);
case URLIS_DIRECTORY: last = pszUrl + strlen(pszUrl) - 1; @@ -1671,7 +1680,7 @@ */ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis) { - static const WCHAR stemp[] = { 'f','i','l','e',':','/','/',0 }; + static const WCHAR stemp[] = { 'f','i','l','e',':',0 }; PARSEDURLW base; DWORD res1; [truncated at 1000 lines; 222 more skipped]