diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-02-19 10:00:25 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-02-19 10:00:25 +0100 |
commit | c7668971968e044e85446d79362d7744846efdd0 (patch) | |
tree | e2d5b4f54edebe1373684ceb007cad39f2399c0f /image/decoders | |
parent | 85edb1c711f7816ed1a30edd07b37d314fac216a (diff) | |
download | UXP-c7668971968e044e85446d79362d7744846efdd0.tar UXP-c7668971968e044e85446d79362d7744846efdd0.tar.gz UXP-c7668971968e044e85446d79362d7744846efdd0.tar.lz UXP-c7668971968e044e85446d79362d7744846efdd0.tar.xz UXP-c7668971968e044e85446d79362d7744846efdd0.zip |
Remove the use of GetProcAddress() for shell32
This avoids manually hooking into shell32.dll and using the native shell API instead.
Tag #22.
Diffstat (limited to 'image/decoders')
-rw-r--r-- | image/decoders/icon/win/nsIconChannel.cpp | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/image/decoders/icon/win/nsIconChannel.cpp b/image/decoders/icon/win/nsIconChannel.cpp index 9ddcbbc48..04680627a 100644 --- a/image/decoders/icon/win/nsIconChannel.cpp +++ b/image/decoders/icon/win/nsIconChannel.cpp @@ -29,11 +29,6 @@ #include "nsContentSecurityManager.h" #include "nsContentUtils.h" -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0600 - // we need windows.h to read out registry information... #include <windows.h> #include <shellapi.h> @@ -416,41 +411,27 @@ nsIconChannel::GetStockHIcon(nsIMozIconURI* aIconURI, { nsresult rv = NS_OK; - // We can only do this on Vista or above - HMODULE hShellDLL = ::LoadLibraryW(L"shell32.dll"); - decltype(SHGetStockIconInfo)* pSHGetStockIconInfo = - (decltype(SHGetStockIconInfo)*) ::GetProcAddress(hShellDLL, - "SHGetStockIconInfo"); - - if (pSHGetStockIconInfo) { - uint32_t desiredImageSize; - aIconURI->GetImageSize(&desiredImageSize); - nsAutoCString stockIcon; - aIconURI->GetStockIcon(stockIcon); - - SHSTOCKICONID stockIconID = GetStockIconIDForName(stockIcon); - if (stockIconID == SIID_INVALID) { - return NS_ERROR_NOT_AVAILABLE; - } + uint32_t desiredImageSize; + aIconURI->GetImageSize(&desiredImageSize); + nsAutoCString stockIcon; + aIconURI->GetStockIcon(stockIcon); - UINT infoFlags = SHGSI_ICON; - infoFlags |= GetSizeInfoFlag(desiredImageSize); + SHSTOCKICONID stockIconID = GetStockIconIDForName(stockIcon); + if (stockIconID == SIID_INVALID) { + return NS_ERROR_NOT_AVAILABLE; + } - SHSTOCKICONINFO sii = {0}; - sii.cbSize = sizeof(sii); - HRESULT hr = pSHGetStockIconInfo(stockIconID, infoFlags, &sii); + UINT infoFlags = SHGSI_ICON; + infoFlags |= GetSizeInfoFlag(desiredImageSize); - if (SUCCEEDED(hr)) { - *hIcon = sii.hIcon; - } else { - rv = NS_ERROR_FAILURE; - } - } else { - rv = NS_ERROR_NOT_AVAILABLE; - } + SHSTOCKICONINFO sii = {0}; + sii.cbSize = sizeof(sii); + HRESULT hr = SHGetStockIconInfo(stockIconID, infoFlags, &sii); - if (hShellDLL) { - ::FreeLibrary(hShellDLL); + if (SUCCEEDED(hr)) { + *hIcon = sii.hIcon; + } else { + rv = NS_ERROR_FAILURE; } return rv; |