Skip to content

Commit

Permalink
WifiStatus: Test if the "wlanapi.dll" is available before attempting …
Browse files Browse the repository at this point in the history
…to call and "Wlan..." functions

This prevents any crashing on default Windows Server builds.
  • Loading branch information
brianferguson committed Sep 19, 2022
1 parent 5f318f2 commit 2ace7dd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Library/MeasureWifiStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ MeasureWifiStatus::MeasureWifiStatus(Skin* skin, const WCHAR* name) : Measure(sk

if (s_Instances == 1U)
{
// Temporarily load the "wlanapi.dll" library as a data file to test if it exists.
// Note: Freeing the temporary library should be okay since delay loading
// of the library occurs later (when WlanOpenHandle is called).
HMODULE lib = LoadLibraryEx(L"wlanapi.dll", nullptr,
LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_IMAGE_RESOURCE | LOAD_LIBRARY_SEARCH_SYSTEM32);
if (!lib)
{
LogDebugF(this, L"WifiStatus: Cannot find wlanapi.dll");
return;
}
FreeLibrary(lib);

// Create WINLAN API Handle
if (!s_Client)
{
Expand Down

0 comments on commit 2ace7dd

Please sign in to comment.