From bb1d3b119bd5e8a6ea9289d11afe6f17b08438a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Fri, 6 May 2005 16:23:24 +0000 Subject: [PATCH] Sync to Wine-20050419: Peter Berg Larsen - Strncpy elimination. - Janitorial: Get rid of strncpy/strncpyW. Jakob Eriksson - Get rid of HeapAlloc casts. Troy Rollo - 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 - Assorted spelling fixes. Robert Shearman - Fix SHCopyKey to treat string parameter correctly as source path instead of destination path. Jon Griffiths - 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. svn path=/trunk/; revision=15050 --- reactos/include/wine/shlguid.h | 4 + reactos/lib/shlwapi/istream.c | 2 +- reactos/lib/shlwapi/ordinal.c | 266 ++++++++++++++++++++++++++++--- reactos/lib/shlwapi/path.c | 75 +++++---- reactos/lib/shlwapi/reg.c | 38 ++--- reactos/lib/shlwapi/regstream.c | 4 +- reactos/lib/shlwapi/shlwapi.spec | 18 +-- reactos/lib/shlwapi/string.c | 15 +- reactos/lib/shlwapi/url.c | 89 ++++++----- reactos/w32api/include/ocidl.h | 11 ++ reactos/w32api/include/oleidl.h | 16 ++ reactos/w32api/include/shlguid.h | 2 + reactos/w32api/include/shlobj.h | 56 +++++++ 13 files changed, 466 insertions(+), 130 deletions(-) diff --git a/reactos/include/wine/shlguid.h b/reactos/include/wine/shlguid.h index 2206ca234bd..f9027b89af1 100644 --- a/reactos/include/wine/shlguid.h +++ b/reactos/include/wine/shlguid.h @@ -34,6 +34,7 @@ DEFINE_SHLGUID(IID_IEnumIDList, 0x000214F2L, 0, 0); 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_DragDropHelper, 0x4657278a, 0x411b, 0x11d2, 0x83, 0x9a, 0x0, 0 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 */ diff --git a/reactos/lib/shlwapi/istream.c b/reactos/lib/shlwapi/istream.c index 50581c02d62..46967fe52a8 100644 --- a/reactos/lib/shlwapi/istream.c +++ b/reactos/lib/shlwapi/istream.c @@ -352,7 +352,7 @@ static IStream *IStream_Create(LPCWSTR lpszPath, HANDLE hFile, DWORD dwMode) { ISHFileStream* fileStream; - fileStream = (ISHFileStream*)HeapAlloc(GetProcessHeap(), 0, sizeof(ISHFileStream)); + fileStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHFileStream)); if (fileStream) { diff --git a/reactos/lib/shlwapi/ordinal.c b/reactos/lib/shlwapi/ordinal.c index 112c124fbcb..6fafe1dbb06 100644 --- a/reactos/lib/shlwapi/ordinal.c +++ b/reactos/lib/shlwapi/ordinal.c @@ -1339,7 +1339,7 @@ DWORD WINAPI IUnknown_AtomicRelease(IUnknown ** lpUnknown) *lpUnknown = NULL; TRACE("doing Release\n"); - + return IUnknown_Release(temp); } @@ -1397,7 +1397,7 @@ BOOL WINAPI SHIsSameObject(IUnknown* lpInt1, IUnknown* lpInt2) if (lpUnknown1 == lpUnknown2) return TRUE; - + return FALSE; } @@ -1847,13 +1847,47 @@ DWORD WINAPI SHLoadFromPropertyBag(IUnknown *lpUnknown, IPropertyBag* lpPropBag) return hRet; } +/************************************************************************* + * @ [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 SHLoadFromPropertyBag(IUnknown *lpUnknown, IPropertyBag* lpPropBag) */ DWORD WINAPI IUnknown_OnFocusOCS(IUnknown *lpUnknown, IDispatch** lppDisp) { - IOleControlSite* lpCSite; + IOleControlSite* lpCSite = NULL; HRESULT hRet = E_FAIL; TRACE("(%p,%p)\n", lpUnknown, lppDisp); @@ -1879,6 +1913,41 @@ DWORD WINAPI IUnknown_OnFocusOCS(IUnknown *lpUnknown, IDispatch** lppDisp) return hRet; } +/************************************************************************* + * @ [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] * @@ -1965,6 +2034,55 @@ DWORD WINAPI SHWaitForSendMessageThread(HANDLE hand, DWORD dwTimeout) return dwRet; } +/************************************************************************* + * @ [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] * @@ -2050,6 +2168,21 @@ VOID WINAPI IUnknown_Set(IUnknown **lppDest, IUnknown *lpUnknown) } } +/************************************************************************* + * @ [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] * @@ -2350,6 +2483,29 @@ LRESULT CALLBACK SHDefWindowProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM return DefWindowProcA(hWnd, uMessage, wParam, lParam); } +/************************************************************************* + * @ [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] * @@ -2510,7 +2666,7 @@ DWORD WINAPI SHRestrictionLookup( * 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 @@ WORD WINAPI VerQueryValueWrapW( * 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 @@ HRESULT WINAPI IUnknown_EnableModeless(IUnknown *lpUnknown, BOOL bModeless) 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 @@ BOOL WINAPI IsOS(DWORD feature) 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: @@ -3746,6 +3905,70 @@ BOOL WINAPI IsOS(DWORD feature) return FALSE; } +/************************************************************************* + * @ [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.@] * @@ -3940,9 +4163,9 @@ VOID WINAPI FixSlashesAndColonW(LPWSTR lpwstr) /************************************************************************* * @ [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 @@ HRESULT WINAPI SHQueueUserWorkItem(DWORD a, DWORD b, DWORD c, DWORD d, DWORD e, /*********************************************************************** * 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; } /*********************************************************************** diff --git a/reactos/lib/shlwapi/path.c b/reactos/lib/shlwapi/path.c index 1c070f1e6cd..bb1c3f21e03 100644 --- a/reactos/lib/shlwapi/path.c +++ b/reactos/lib/shlwapi/path.c @@ -168,14 +168,14 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) 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 @@ LPWSTR WINAPI PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) if (bUseBoth) { - strncpyW(szTemp, lpszDir, MAX_PATH); + lstrcpynW(szTemp, lpszDir, MAX_PATH); if (bStrip) { PathStripToRootW(szTemp); @@ -1687,7 +1687,8 @@ BOOL WINAPI PathFileExistsA(LPCSTR lpszPath) 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 @@ BOOL WINAPI PathFileExistsW(LPCWSTR lpszPath) if (!lpszPath) return FALSE; - iPrevErrMode = SetErrorMode(1); + iPrevErrMode = SetErrorMode(SEM_FAILCRITICALERRORS); dwAttr = GetFileAttributesW(lpszPath); SetErrorMode(iPrevErrMode); return dwAttr == INVALID_FILE_ATTRIBUTES ? FALSE : TRUE; @@ -2580,20 +2581,23 @@ BOOL WINAPI PathMakePrettyA(LPSTR lpszPath) 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++; - } - pszIter = lpszPath + 1; - while (*pszIter) - { - *pszIter = tolower(*pszIter); - pszIter++; + do + { + if (islower(*pszIter) || IsDBCSLeadByte(*pszIter)) + return FALSE; /* Not DOS path */ + pszIter++; + } while (*pszIter); + pszIter = lpszPath + 1; + while (*pszIter) + { + *pszIter = tolower(*pszIter); + pszIter++; + } } return TRUE; } @@ -2609,20 +2613,23 @@ BOOL WINAPI PathMakePrettyW(LPWSTR lpszPath) 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++; - } - pszIter = lpszPath + 1; - while (*pszIter) - { - *pszIter = tolowerW(*pszIter); - pszIter++; + do + { + if (islowerW(*pszIter)) + return FALSE; /* Not DOS path */ + pszIter++; + } while (*pszIter); + pszIter = lpszPath + 1; + while (*pszIter) + { + *pszIter = tolowerW(*pszIter); + pszIter++; + } } return TRUE; } @@ -2767,7 +2774,7 @@ int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPat * 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 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx) 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 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx) * 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 @@ BOOL WINAPI PathCompactPathW(HDC hDC, LPWSTR lpszPath, UINT dx) if (dwLen > MAX_PATH - 3) dwLen = MAX_PATH - 3; - strncpyW(buff, sFile, dwLen); + lstrcpynW(buff, sFile, dwLen); do { dwLen--; @@ -3390,8 +3397,8 @@ BOOL WINAPI PathRelativePathToW(LPWSTR lpszPath, LPCWSTR lpszFrom, DWORD dwAttrF 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 @@ BOOL WINAPI PathIsDirectoryEmptyW(LPCWSTR lpszPath) 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) diff --git a/reactos/lib/shlwapi/reg.c b/reactos/lib/shlwapi/reg.c index 15a1f17c86c..f4ce4373bfd 100644 --- a/reactos/lib/shlwapi/reg.c +++ b/reactos/lib/shlwapi/reg.c @@ -133,7 +133,7 @@ LONG WINAPI SHRegOpenUSKeyW(LPCWSTR Path, REGSAM AccessType, HUSKEY hRelativeUSK *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 @@ LONG WINAPI SHQueryInfoKeyW(HKEY hKey, LPDWORD pwSubKeys, LPDWORD pwSubKeyMax, * * 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 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue, 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 @@ DWORD WINAPI SHQueryValueExA( HKEY hKey, LPCSTR lpszValue, 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 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, 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 @@ DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, 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 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey) * * 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 @@ HKEY WINAPI SHRegDuplicateHKey(HKEY hKey) * (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 @@ DWORD WINAPI SHCopyKeyA(HKEY hKeySrc, LPCSTR lpszSubKey, HKEY hKeyDst, DWORD dwR * * 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 @@ DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dw 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 @@ DWORD WINAPI SHCopyKeyW(HKEY hKeySrc, LPCWSTR lpszSubKey, HKEY hKeyDst, DWORD dw if (lpBuff != buff) HeapFree(GetProcessHeap(), 0, lpBuff); - if (lpszSubKey && hKeyDst) + if (lpszSrcSubKey && hKeyDst) RegCloseKey(hKeyDst); return dwRet; } diff --git a/reactos/lib/shlwapi/regstream.c b/reactos/lib/shlwapi/regstream.c index 172e1bbd842..894176c2c85 100644 --- a/reactos/lib/shlwapi/regstream.c +++ b/reactos/lib/shlwapi/regstream.c @@ -343,7 +343,7 @@ static IStream *IStream_Create(HKEY hKey, LPBYTE pbBuffer, DWORD dwLength) { ISHRegStream* regStream; - regStream = (ISHRegStream*)HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream)); + regStream = HeapAlloc(GetProcessHeap(), 0, sizeof(ISHRegStream)); if (regStream) { @@ -493,7 +493,7 @@ IStream * WINAPI SHCreateMemStream(LPBYTE lpbData, DWORD dwDataLen) if (lpbData) { - LPBYTE lpbDup = (LPBYTE)HeapAlloc(GetProcessHeap(), 0, dwDataLen); + LPBYTE lpbDup = HeapAlloc(GetProcessHeap(), 0, dwDataLen); if (lpbDup) { diff --git a/reactos/lib/shlwapi/shlwapi.spec b/reactos/lib/shlwapi/shlwapi.spec index f234b7eb6ad..2291f7190c0 100644 --- a/reactos/lib/shlwapi/shlwapi.spec +++ b/reactos/lib/shlwapi/shlwapi.spec @@ -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) diff --git a/reactos/lib/shlwapi/string.c b/reactos/lib/shlwapi/string.c index 78f5c1d6141..39ad6414c36 100644 --- a/reactos/lib/shlwapi/string.c +++ b/reactos/lib/shlwapi/string.c @@ -1577,7 +1577,7 @@ LPSTR WINAPI StrFormatKBSizeA(LONGLONG llBytes, LPSTR lpszDest, UINT cchMax) ulKB = (ulKB - ulNextDigit) / 10; } while (ulKB > 0); - strncpy(lpszDest, szOut + 1, cchMax); + lstrcpynA(lpszDest, szOut + 1, cchMax); return lpszDest; } @@ -1605,7 +1605,7 @@ LPWSTR WINAPI StrFormatKBSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax) ulKB = (ulKB - ulNextDigit) / 10; } while (ulKB > 0); - strncpyW(lpszDest, szOut + 1, cchMax); + lstrcpynW(lpszDest, szOut + 1, cchMax); return lpszDest; } @@ -2027,7 +2027,7 @@ INT WINAPI StrFromTimeIntervalW(LPWSTR lpszStr, UINT cchMax, DWORD dwMS, 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 @@ LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax) 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 @@ INT WINAPI SHUnicodeToAnsiCP(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr, if (nWideCharCount < len - 1) { - mem = (LPSTR)HeapAlloc(GetProcessHeap(), 0, *lpiLen); + mem = HeapAlloc(GetProcessHeap(), 0, *lpiLen); if (!mem) return 0; @@ -2577,7 +2577,7 @@ INT WINAPI SHUnicodeToAnsiCP(UINT CodePage, LPCWSTR lpSrcStr, LPSTR lpDstStr, 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 @@ DWORD WINAPI SHAnsiToAnsi(LPCSTR lpszSrc, LPSTR lpszDst, int iLen) 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; } diff --git a/reactos/lib/shlwapi/url.c b/reactos/lib/shlwapi/url.c index db67c348b36..eedb50b28fc 100644 --- a/reactos/lib/shlwapi/url.c +++ b/reactos/lib/shlwapi/url.c @@ -238,7 +238,7 @@ HRESULT WINAPI ParseURLW(LPCWSTR x, PARSEDURLW *y) /* 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 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, 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 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, 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 @@ HRESULT WINAPI UrlCanonicalizeW(LPCWSTR pszUrl, LPWSTR pszCanonicalized, 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 @@ HRESULT WINAPI UrlCombineA(LPCSTR pszBase, LPCSTR pszRelative, 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 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, * 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 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, * 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 @@ HRESULT WINAPI UrlCombineW(LPCWSTR pszBase, LPCWSTR pszRelative, * 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 @@ BOOL WINAPI UrlIsA(LPCSTR pszUrl, URLIS Urlis) 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 UrlIsA(LPCSTR pszUrl, URLIS Urlis) */ 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; LPCWSTR last; @@ -1684,13 +1693,19 @@ BOOL WINAPI UrlIsW(LPCWSTR pszUrl, URLIS Urlis) base.cbSize = sizeof(base); res1 = ParseURLW(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 !strncmpW(stemp, pszUrl, 7); + return !strncmpW(stemp, pszUrl, 5); case URLIS_DIRECTORY: last = pszUrl + strlenW(pszUrl) - 1; @@ -1937,7 +1952,9 @@ static LONG URL_ParseUrl(LPCWSTR pszUrl, WINE_PARSE_URL *pl) * PARAMS * pszIn [I] Url to parse * pszOut [O] Destination for part of pszIn requested - * pcchOut [I/O] Length of pszOut/destination for length of pszOut + * pcchOut [I] Size of pszOut + * [O] length of pszOut string EXLUDING '\0' if S_OK, otherwise + * needed size of pszOut INCLUDING '\0'. * dwPart [I] URL_PART_ enum from "shlwapi.h" * dwFlags [I] URL_ flags from "shlwapi.h" * @@ -1989,7 +2006,6 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, HRESULT ret; DWORD size, schsize; LPCWSTR addr, schaddr; - LPWSTR work; TRACE("(%s %p %p(%ld) %08lx %08lx)\n", debugstr_w(pszIn), pszOut, pcchOut, *pcchOut, dwPart, dwFlags); @@ -2041,24 +2057,21 @@ HRESULT WINAPI UrlGetPartW(LPCWSTR pszIn, LPWSTR pszOut, LPDWORD pcchOut, } if (dwFlags == URL_PARTFLAG_KEEPSCHEME) { - if (*pcchOut < size + schsize + 2) { - *pcchOut = size + schsize + 2; + if (*pcchOut < schsize + size + 2) { + *pcchOut = schsize + size + 2; return E_POINTER; } - strncpyW(pszOut, schaddr, schsize); - work = pszOut + schsize; - *work = L':'; - strncpyW(work+1, addr, size); - *pcchOut = size + schsize + 1; - work += (size + 1); - *work = L'\0'; + memcpy(pszOut, schaddr, schsize*sizeof(WCHAR)); + pszOut[schsize] = ':'; + memcpy(pszOut+schsize+1, addr, size*sizeof(WCHAR)); + pszOut[schsize+1+size] = 0; + *pcchOut = schsize + 1 + size; } else { if (*pcchOut < size + 1) {*pcchOut = size+1; return E_POINTER;} - strncpyW(pszOut, addr, size); + memcpy(pszOut, addr, size*sizeof(WCHAR)); + pszOut[size] = 0; *pcchOut = size; - work = pszOut + size; - *work = L'\0'; } TRACE("len=%ld %s\n", *pcchOut, debugstr_w(pszOut)); } diff --git a/reactos/w32api/include/ocidl.h b/reactos/w32api/include/ocidl.h index 5c2006bdf07..43f0dce8eda 100644 --- a/reactos/w32api/include/ocidl.h +++ b/reactos/w32api/include/ocidl.h @@ -21,6 +21,7 @@ typedef interface IFont *LPFONT; typedef interface IFontDisp *LPFONTDISP; typedef interface IOleUndoManager *LPOLEUNDOMANAGER; typedef interface IQuickActivate *LPQUICKACTIVATE; +typedef interface IObjectWithSite *LPOBJECTWITHSITE; #ifndef OLE2ANSI typedef TEXTMETRICW TEXTMETRICOLE; @@ -731,6 +732,16 @@ DECLARE_INTERFACE_(IObjectWithSite,IUnknown) }; #undef INTERFACE +#ifdef COBJMACROS +/*** IUnknown methods ***/ +#define IObjectWithSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IObjectWithSite_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IObjectWithSite_Release(p) (p)->lpVtbl->Release(p) +/*** IObjectWithSite methods ***/ +#define IObjectWithSite_SetSite(p,a) (p)->lpVtbl->SetSite(p,a) +#define IObjectWithSite_GetSite(p,a,b) (p)->lpVtbl->GetSite(p,a,b) +#endif + EXTERN_C const IID IID_IOleInPlaceSiteWindowless; #define INTERFACE IOleInPlaceSiteWindowless DECLARE_INTERFACE_(IOleInPlaceSiteWindowless,IOleInPlaceSiteEx) diff --git a/reactos/w32api/include/oleidl.h b/reactos/w32api/include/oleidl.h index e2a3460bec0..6b920159653 100644 --- a/reactos/w32api/include/oleidl.h +++ b/reactos/w32api/include/oleidl.h @@ -308,6 +308,22 @@ DECLARE_INTERFACE_(IOleInPlaceActiveObject,IOleWindow) }; #undef INTERFACE +#ifdef COBJMACROS +/*** IUnknown methods ***/ +#define IOleInPlaceActiveObject_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IOleInPlaceActiveObject_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IOleInPlaceActiveObject_Release(p) (p)->lpVtbl->Release(p) +/*** IOleWindow methods ***/ +#define IOleInPlaceActiveObject_GetWindow(p,a) (p)->lpVtbl->GetWindow(p,a) +#define IOleInPlaceActiveObject_ContextSensitiveHelp(p,a) (p)->lpVtbl->ContextSensitiveHelp(p,a) +/*** IOleInPlaceActiveObject methods ***/ +#define IOleInPlaceActiveObject_TranslateAccelerator(p,a) (p)->lpVtbl->TranslateAccelerator(p,a) +#define IOleInPlaceActiveObject_OnFrameWindowActivate(p,a) (p)->lpVtbl->OnFrameWindowActivate(p,a) +#define IOleInPlaceActiveObject_OnDocWindowActivate(p,a) (p)->lpVtbl->OnDocWindowActivate(p,a) +#define IOleInPlaceActiveObject_ResizeBorder(p,a,b,c) (p)->lpVtbl->ResizeBorder(p,a,b,c) +#define IOleInPlaceActiveObject_EnableModeless(p,a) (p)->lpVtbl->EnableModeless(p,a) +#endif + EXTERN_C const IID IID_IOleInPlaceFrame; #define INTERFACE IOleInPlaceFrame DECLARE_INTERFACE_(IOleInPlaceFrame,IOleInPlaceUIWindow) diff --git a/reactos/w32api/include/shlguid.h b/reactos/w32api/include/shlguid.h index 56b706ac22a..4b2830d8058 100644 --- a/reactos/w32api/include/shlguid.h +++ b/reactos/w32api/include/shlguid.h @@ -95,6 +95,8 @@ extern const GUID IID_IFileSystemBindData; #define IID_IShellExecuteHook IID_IShellExecuteHookA #define IID_INewShortcutHook IID_INewShortcutHookA #endif +extern const GUID IID_IInputObject; +extern const GUID IID_IInputObjectSite; #ifdef __cplusplus } diff --git a/reactos/w32api/include/shlobj.h b/reactos/w32api/include/shlobj.h index a05909d7db1..6af4cb12ff2 100644 --- a/reactos/w32api/include/shlobj.h +++ b/reactos/w32api/include/shlobj.h @@ -930,6 +930,16 @@ DECLARE_INTERFACE_(IQueryInfo,IUnknown) }; #undef INTERFACE +#if !defined(__cplusplus) || defined(CINTERFACE) +/*** IUnknown methods ***/ +#define IQueryInfo_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IQueryInfo_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IQueryInfo_Release(p) (p)->lpVtbl->Release(p) +/*** IQueryInfo methods ***/ +#define IQueryInfo_GetInfoTip(p,a,b) (p)->lpVtbl->GetInfoTip(p,a,b) +#define IQueryInfo_GetInfoFlags(p,a) (p)->lpVtbl->GetInfoFlags(p,a) +#endif + #define INTERFACE IShellExtInit DECLARE_INTERFACE_(IShellExtInit, IUnknown) { @@ -1622,6 +1632,52 @@ DECLARE_INTERFACE_(IDropTargetHelper, IUnknown) #undef INTERFACE #endif /* _WIN32_IE >= 0x0500 */ +#define INTERFACE IInputObject +DECLARE_INTERFACE_(IInputObject,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + /*** IInputObject methods ***/ + STDMETHOD(UIActivateIO)(THIS_ BOOL bActivating, LPMSG lpMsg) PURE; + STDMETHOD(HasFocusIO)(THIS) PURE; + STDMETHOD(TranslateAcceleratorIO)(THIS_ LPMSG lpMsg) PURE; +}; +#undef INTERFACE + +#if defined(COBJMACROS) +/*** IUnknown methods ***/ +#define IInputObject_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IInputObject_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IInputObject_Release(p) (p)->lpVtbl->Release(p) +/*** IInputObject methods ***/ +#define IInputObject_UIActivateIO(p,a,b) (p)->lpVtbl->UIActivateIO(p,a,b) +#define IInputObject_HasFocusIO(p) (p)->lpVtbl->HasFocusIO(p) +#define IInputObject_TranslateAcceleratorIO(p,a) (p)->lpVtbl->TranslateAcceleratorIO(p,a) +#endif + +#define INTERFACE IInputObjectSite +DECLARE_INTERFACE_(IInputObjectSite,IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IInputObjectSite methods ***/ + STDMETHOD(OnFocusChangeIS)(THIS_ LPUNKNOWN lpUnknown, BOOL bFocus) PURE; +}; +#undef INTERFACE + +#if defined(COBJMACROS) +/*** IUnknown methods ***/ +#define IInputObjectSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IInputObjectSite_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IInputObjectSite_Release(p) (p)->lpVtbl->Release(p) +/*** IInputObject methods ***/ +#define IInputObjectSite_OnFocusChangeIS(p,a,b) (p)->lpVtbl->OnFocusChangeIS(p,a,b) +#endif + typedef HRESULT (CALLBACK *LPFNVIEWCALLBACK)( IShellView* dwUser, IShellFolder* pshf,