From c7668971968e044e85446d79362d7744846efdd0 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 19 Feb 2018 10:00:25 +0100 Subject: Remove the use of GetProcAddress() for shell32 This avoids manually hooking into shell32.dll and using the native shell API instead. Tag #22. --- image/decoders/icon/win/nsIconChannel.cpp | 53 ++++++++++--------------------- 1 file changed, 17 insertions(+), 36 deletions(-) (limited to 'image/decoders/icon/win') 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 #include @@ -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; -- cgit v1.2.3