]> repos.lx-s.de Git - winmute.git/commitdiff
Use correct memory for extra dialog window data
authorlx-s <lx-s@users.noreply.github.com>
Wed, 8 Jul 2026 12:42:59 +0000 (14:42 +0200)
committerlx-s <lx-s@users.noreply.github.com>
Wed, 8 Jul 2026 12:42:59 +0000 (14:42 +0200)
WinMute/AboutDlg.cpp
WinMute/LogDialog.cpp
WinMute/SettingsDlg.cpp
WinMute/Settings_BluetoothDlg.cpp
WinMute/Settings_GeneralDlg.cpp
WinMute/Settings_ManageEndpointsDlg.cpp
WinMute/Settings_MuteDlg.cpp
WinMute/Settings_QuietHoursDlg.cpp
WinMute/Settings_WifiDlg.cpp

index 2236d6eef7ca139b02fdd95290e8178d97d1b787..dcebc8db76c2a8f8c4c2187beb8e73886cf210ab 100644 (file)
@@ -220,11 +220,11 @@ static void TranslateAboutDlgProc(HWND hDlg)
 INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
    AboutDlgData* dlgData =
-      reinterpret_cast<AboutDlgData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      reinterpret_cast<AboutDlgData*>(GetWindowLongPtr(hDlg, DWLP_USER));
    switch (msg) {
    case WM_INITDIALOG: {
       dlgData = new AboutDlgData();
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(dlgData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(dlgData));
 
       dlgData->hTabCtrl = GetDlgItem(hDlg, IDC_ABOUT_TAB);
 
@@ -312,7 +312,7 @@ INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
    case WM_DESTROY:
       DeleteObject(dlgData->hTitleFont);
       delete dlgData;
-      SetWindowLongPtrW(hDlg, GWLP_USERDATA, 0);
+      SetWindowLongPtrW(hDlg, DWLP_USER, 0);
       return 0;
    case WM_CLOSE:
       EndDialog(hDlg, 0);
index 251182dcf7edeb5d8ea25077e3f4fd2a20fe6e53..852de783f62ae5bbe438657fb2fbdef1f816f0b9 100644 (file)
@@ -40,14 +40,14 @@ struct LogDlgData {
 INT_PTR CALLBACK LogDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
    auto *dlgData =
-      reinterpret_cast<LogDlgData *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      reinterpret_cast<LogDlgData *>(GetWindowLongPtr(hDlg, DWLP_USER));
    UNREFERENCED_PARAMETER(wParam);
    UNREFERENCED_PARAMETER(lParam);
    switch (msg) {
    case WM_INITDIALOG:
    {
       dlgData = new LogDlgData();
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(dlgData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(dlgData));
 
       WMi18n &i18n = WMi18n::GetInstance();
       SetWindowText(hDlg, i18n.GetTranslationW("log.title").c_str());
@@ -117,7 +117,7 @@ INT_PTR CALLBACK LogDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
    }
    case WM_DESTROY:
       delete dlgData;
-      SetWindowLongPtrW(hDlg, GWLP_USERDATA, 0);
+      SetWindowLongPtrW(hDlg, DWLP_USER, 0);
       WMLog::GetInstance().UnregisterForLogUpdates(hDlg);
       return 0;
    case WM_CLOSE:
index ab24e8f79d903785f543b9d91a4106985bcbb510..6c6078795e814ad0d610d3c2a1604f955093b0ae 100644 (file)
@@ -130,7 +130,7 @@ static void ResizeTabs(HWND hTabCtrl, HWND* hTabs, int tabCount)
 INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
    SettingsDlgData* dlgData =
-      reinterpret_cast<SettingsDlgData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      reinterpret_cast<SettingsDlgData*>(GetWindowLongPtr(hDlg, DWLP_USER));
    switch (msg) {
    case WM_INITDIALOG: {
       WMi18n &i18n = WMi18n::GetInstance();
@@ -138,7 +138,7 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar
       assert(dlgData == nullptr);
       WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
       dlgData = new SettingsDlgData(settings);
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(dlgData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(dlgData));
       
       dlgData->hTabCtrl = GetDlgItem(hDlg, IDC_SETTINGS_TAB);
 
@@ -236,7 +236,7 @@ INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPar
       return TRUE;
    case WM_DESTROY:
       delete dlgData;
-      SetWindowLongPtrW(hDlg, GWLP_USERDATA, 0);
+      SetWindowLongPtrW(hDlg, DWLP_USER, 0);
       return 0;
    default:
       break;
index 68f5b302ac9121125f35b1a28fc46fc3e503481b..e28a505886e1b6bf11b2ba1e79f6600d7f11c796 100644 (file)
@@ -92,7 +92,7 @@ static INT_PTR CALLBACK Settings_BluetoothAddDlgProc(HWND hDlg, UINT msg, WPARAM
       if (btDeviceData == nullptr) {
          return FALSE;
       }
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(btDeviceData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(btDeviceData));
       LoadBluetoothAddDlgTranslation(hDlg, btDeviceData->devName.length() != 0);
       if (btDeviceData->devName.length() != 0) {
          SetWindowTextW(GetDlgItem(hDlg, IDC_BT_DEVICE_NAME),
@@ -133,7 +133,7 @@ static INT_PTR CALLBACK Settings_BluetoothAddDlgProc(HWND hDlg, UINT msg, WPARAM
          const int textLen = Edit_GetTextLength(hDevName);
          if (textLen != 0) {
             wchar_t devNameBuf[BT_DEV_NAME_MAX_LEN + 1] = { 'L\0' };
-            BtDeviceData* btDevName = reinterpret_cast<BtDeviceData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+            BtDeviceData* btDevName = reinterpret_cast<BtDeviceData*>(GetWindowLongPtr(hDlg, DWLP_USER));
             if (btDevName != nullptr) {
                Edit_GetText(hDevName, devNameBuf, ARRAY_SIZE(devNameBuf));
                btDevName->devName = devNameBuf;
@@ -215,7 +215,7 @@ INT_PTR CALLBACK Settings_BluetoothDlgProc(HWND hDlg, UINT msg, WPARAM wParam, L
 
       WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
       assert(settings != nullptr);
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(settings));
 
       DWORD enabled = settings->QueryValue(SettingsKey::MUTE_ON_BLUETOOTH);
 
@@ -350,7 +350,7 @@ INT_PTR CALLBACK Settings_BluetoothDlgProc(HWND hDlg, UINT msg, WPARAM wParam, L
       return 0;
    }
    case WM_SAVESETTINGS: {
-      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, DWLP_USER));
       std::vector<std::wstring> devices = ExportBluetoothDeviceList(GetDlgItem(hDlg, IDC_BLUETOOTH_LIST));
       settings->StoreBluetoothDevices(devices);
 
index a9ffbb54d20cfda9b84048388d5ba90e2676a3e6..1e22dded26ffffa69b651465484a75f7c89a6d3a 100644 (file)
@@ -100,7 +100,7 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       dlgData->settings = reinterpret_cast<WMSettings *>(lParam);
       assert(dlgData->settings != nullptr);
 
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(dlgData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(dlgData));
      
       FillLanguageList(GetDlgItem(hDlg, IDC_LANGUAGE), *dlgData);
 
@@ -143,10 +143,10 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       return TRUE;
    }
    case WM_DESTROY: {
-      SettingsGeneralData *dlgData = reinterpret_cast<SettingsGeneralData *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      SettingsGeneralData *dlgData = reinterpret_cast<SettingsGeneralData *>(GetWindowLongPtr(hDlg, DWLP_USER));
       if (dlgData != nullptr) {
          delete dlgData;
-         SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
+         SetWindowLongPtr(hDlg, DWLP_USER, 0);
       }
       return FALSE;
    }
@@ -197,7 +197,7 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       return 0;
    }
    case WM_SAVESETTINGS: {
-      SettingsGeneralData *dlgData = reinterpret_cast<SettingsGeneralData *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      SettingsGeneralData *dlgData = reinterpret_cast<SettingsGeneralData *>(GetWindowLongPtr(hDlg, DWLP_USER));
       assert(dlgData != nullptr);
 
       HWND hAutostart = GetDlgItem(hDlg, IDC_RUNONSTARTUP);
index 35158e764320b2d35482c99e55a969c6dcfcf1dc..baef2af4e5b1bd97e291667f8480e715509efcb4 100644 (file)
@@ -110,7 +110,7 @@ static INT_PTR CALLBACK Settings_EndpointAddDlgProc(HWND hDlg, UINT msg, WPARAM
       if (endpointData == nullptr) {
          return FALSE;
       }
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(endpointData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(endpointData));
 
       LoadManageEndpointsAddDlgTranslation(hDlg, endpointData->name.length() != 0);
       if (endpointData->name.length() != 0) {
@@ -151,7 +151,7 @@ static INT_PTR CALLBACK Settings_EndpointAddDlgProc(HWND hDlg, UINT msg, WPARAM
          const int textLen = Edit_GetTextLength(hEpName);
          if (textLen != 0) {
             wchar_t epNameBuf[ENDPOINT_NAME_MAX_LEN + 1] = { 'L\0' };
-            EndpointData *epData = reinterpret_cast<EndpointData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+            EndpointData *epData = reinterpret_cast<EndpointData*>(GetWindowLongPtr(hDlg, DWLP_USER));
             if (epData != nullptr) {
                Edit_GetText(hEpName, epNameBuf, ARRAY_SIZE(epNameBuf));
                epData->name = epNameBuf;
@@ -218,7 +218,7 @@ INT_PTR CALLBACK Settings_ManageEndpointsDlgProc(HWND hDlg, UINT msg, WPARAM wPa
 
       WMSettings *settings = reinterpret_cast<WMSettings *>(lParam);
       assert(settings != nullptr);
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(settings));
 
       DWORD endpointMode = settings->QueryValue(SettingsKey::MUTE_INDIVIDUAL_ENDPOINTS_MODE);
       if (endpointMode == MUTE_ENDPOINT_MODE_INDIVIDUAL_ALLOW_LIST) {
@@ -320,7 +320,7 @@ INT_PTR CALLBACK Settings_ManageEndpointsDlgProc(HWND hDlg, UINT msg, WPARAM wPa
          Button_Enable(GetDlgItem(hDlg, IDC_ENDPOINT_REMOVE), FALSE);
          Button_Enable(GetDlgItem(hDlg, IDC_ENDPOINT_REMOVEALL), FALSE);
       } else if (LOWORD(wParam) == IDOK) {
-         WMSettings *settings = reinterpret_cast<WMSettings *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+         WMSettings *settings = reinterpret_cast<WMSettings *>(GetWindowLongPtr(hDlg, DWLP_USER));
          std::vector<std::wstring> devices = ExportEndpointNameList(GetDlgItem(hDlg, IDC_ENDPOINT_LIST));
          settings->StoreManagedAudioEndpoints(devices);
          if (Button_GetCheck(GetDlgItem(hDlg, IDC_ENDPOINT_LIST_IS_ALLOWLIST))) {
index f7bd910bd77e6e627e4d08af9ccaa64fa16571be..f20895626122b6e4f25c1e10434e9d5c22ce1c96 100644 (file)
@@ -102,7 +102,7 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 
       WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
       assert(settings != nullptr);
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(settings));
 
       // General
       SetCheckButton(hNotify, *settings, SettingsKey::NOTIFICATIONS_ENABLED);
@@ -132,7 +132,7 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
          int isEnabled = Button_GetCheck(GetDlgItem(hDlg, IDC_MANAGE_AUDIO_ENDPOINTS_INDIVIDUALLY));
          Button_Enable(GetDlgItem(hDlg, IDC_MANAGE_ENDPOINTS), isEnabled);
       } else if (LOWORD(wParam) == IDC_MANAGE_ENDPOINTS) {
-         WMSettings *settings = reinterpret_cast<WMSettings *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+         WMSettings *settings = reinterpret_cast<WMSettings *>(GetWindowLongPtr(hDlg, DWLP_USER));
          if (!DialogBoxParam(
                nullptr,
                MAKEINTRESOURCE(IDD_MANAGE_ENDPOINTS),
@@ -145,7 +145,7 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
       return 0;
    case WM_SAVESETTINGS:
    {
-      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, DWLP_USER));
 
       HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hManageEndpoints = GetDlgItem(hDlg, IDC_MANAGE_AUDIO_ENDPOINTS_INDIVIDUALLY);
index 662b5e59d9df7c5218c33b759126dbcff94c0775..7285c766da6c11a8eac3f4234d67f36ebebe97bb 100644 (file)
@@ -218,7 +218,7 @@ static INT_PTR CALLBACK Settings_QuietHoursAddDlgProc(HWND hDlg, UINT msg, WPARA
       if (qh_entry == nullptr) {
          return FALSE;
       }
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(qh_entry));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(qh_entry));
 
       const bool isEdit = qh_entry->start != 0 || qh_entry->end != 0;
       LoadQuietHoursAddDlgTranslation(hDlg, isEdit);
@@ -252,7 +252,7 @@ static INT_PTR CALLBACK Settings_QuietHoursAddDlgProc(HWND hDlg, UINT msg, WPARA
                 nullptr);
             return FALSE;
          } else {
-            auto *qh_entry = reinterpret_cast<QuietHoursEntry *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+            auto *qh_entry = reinterpret_cast<QuietHoursEntry *>(GetWindowLongPtr(hDlg, DWLP_USER));
             qh_entry->start = start.wHour * 3600 + start.wMinute * 60 + start.wSecond;
             qh_entry->end = end.wHour * 3600 + end.wMinute * 60 + end.wSecond;
             EndDialog(hDlg, 0);
@@ -341,7 +341,7 @@ INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
       auto qhdata = new QuietHoursDlgData();
       assert(qhdata != nullptr);
       qhdata->settings = settings;
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(qhdata));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(qhdata));
 
       if (IsAppThemed())
       {
@@ -395,7 +395,7 @@ INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
       HWND hForce = GetDlgItem(hDlg, IDC_FORCEUNMUTE);
       HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS);
       HWND hQuietHoursTimes = GetDlgItem(hDlg, IDC_QUIET_HOURS_TIMES);
-      auto qhdata = reinterpret_cast<QuietHoursDlgData *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      auto qhdata = reinterpret_cast<QuietHoursDlgData *>(GetWindowLongPtr(hDlg, DWLP_USER));
 
       const int qhEnabled = Button_GetCheck(hEnable) == BST_CHECKED;
       const int qhForceUnmute = Button_GetCheck(hForce) == BST_CHECKED;
@@ -502,7 +502,7 @@ INT_PTR CALLBACK Settings_QuietHoursDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
    {
       HWND hQuietHoursTimes = GetDlgItem(hDlg, IDC_QUIET_HOURS_TIMES);
       FreeListViewEntries(hQuietHoursTimes);
-      auto qhdata = reinterpret_cast<QuietHoursDlgData *>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      auto qhdata = reinterpret_cast<QuietHoursDlgData *>(GetWindowLongPtr(hDlg, DWLP_USER));
       delete qhdata;
       EndDialog(hDlg, 0);
       return TRUE;
index 28e25c18173375ae698bfec022990d187886a7d2..b0d5e70fa6267f556a2f2b8c622be0801e622f78 100644 (file)
@@ -66,7 +66,7 @@ INT_PTR CALLBACK Settings_WifiAddDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
       if (wifiData == nullptr) {
          return FALSE;
       }
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(wifiData));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(wifiData));
 
       LoadWifiAddDlgTranslation(hDlg, wifiData->ssidName.length() != 0);
 
@@ -94,7 +94,7 @@ INT_PTR CALLBACK Settings_WifiAddDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA
          const int textLen = Edit_GetTextLength(hSsid);
          if (textLen != 0) {
             wchar_t ssidBuf[SSID_MAX_LEN + 1];
-            WiFiData* wifiData = reinterpret_cast<WiFiData*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+            WiFiData* wifiData = reinterpret_cast<WiFiData*>(GetWindowLongPtr(hDlg, DWLP_USER));
             if (wifiData != nullptr) {
                Edit_GetText(hSsid, ssidBuf, ARRAY_SIZE(ssidBuf));
                wifiData->ssidName = ssidBuf;
@@ -174,7 +174,7 @@ INT_PTR CALLBACK Settings_WifiDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
       LoadWifiDlgTranslation(hDlg);
       WMSettings* settings = reinterpret_cast<WMSettings*>(lParam);
       assert(settings != nullptr);
-      SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(settings));
+      SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast<LONG_PTR>(settings));
 
       DWORD enabled = settings->QueryValue(SettingsKey::MUTE_ON_WLAN);
       Button_SetCheck(GetDlgItem(hDlg, IDC_ENABLE_WIFI_MUTE),
@@ -309,7 +309,7 @@ INT_PTR CALLBACK Settings_WifiDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
       return 0;
    }
    case WM_SAVESETTINGS: {
-      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, GWLP_USERDATA));
+      WMSettings* settings = reinterpret_cast<WMSettings*>(GetWindowLongPtr(hDlg, DWLP_USER));
       std::vector<std::wstring> networks = ExportSsidListItems(GetDlgItem(hDlg, IDC_WIFI_LIST));
       settings->StoreWifiNetworks(networks);