From: lx-s Date: Wed, 8 Jul 2026 12:42:59 +0000 (+0200) Subject: Use correct memory for extra dialog window data X-Git-Tag: 2.6.0.0~80 X-Git-Url: https://repos.lx-s.de/gitweb/?a=commitdiff_plain;h=8131892589e8275af35bb9ceccfd169335580c5d;p=winmute.git Use correct memory for extra dialog window data --- diff --git a/WinMute/AboutDlg.cpp b/WinMute/AboutDlg.cpp index 2236d6e..dcebc8d 100644 --- a/WinMute/AboutDlg.cpp +++ b/WinMute/AboutDlg.cpp @@ -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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); switch (msg) { case WM_INITDIALOG: { dlgData = new AboutDlgData(); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(dlgData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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); diff --git a/WinMute/LogDialog.cpp b/WinMute/LogDialog.cpp index 251182d..852de78 100644 --- a/WinMute/LogDialog.cpp +++ b/WinMute/LogDialog.cpp @@ -40,14 +40,14 @@ struct LogDlgData { INT_PTR CALLBACK LogDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { auto *dlgData = - reinterpret_cast(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(lParam); switch (msg) { case WM_INITDIALOG: { dlgData = new LogDlgData(); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(dlgData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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: diff --git a/WinMute/SettingsDlg.cpp b/WinMute/SettingsDlg.cpp index ab24e8f..6c60787 100644 --- a/WinMute/SettingsDlg.cpp +++ b/WinMute/SettingsDlg.cpp @@ -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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + reinterpret_cast(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(lParam); dlgData = new SettingsDlgData(settings); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(dlgData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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; diff --git a/WinMute/Settings_BluetoothDlg.cpp b/WinMute/Settings_BluetoothDlg.cpp index 68f5b30..e28a505 100644 --- a/WinMute/Settings_BluetoothDlg.cpp +++ b/WinMute/Settings_BluetoothDlg.cpp @@ -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(btDeviceData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + BtDeviceData* btDevName = reinterpret_cast(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(lParam); assert(settings != nullptr); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WMSettings* settings = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); std::vector devices = ExportBluetoothDeviceList(GetDlgItem(hDlg, IDC_BLUETOOTH_LIST)); settings->StoreBluetoothDevices(devices); diff --git a/WinMute/Settings_GeneralDlg.cpp b/WinMute/Settings_GeneralDlg.cpp index a9ffbb5..1e22dde 100644 --- a/WinMute/Settings_GeneralDlg.cpp +++ b/WinMute/Settings_GeneralDlg.cpp @@ -100,7 +100,7 @@ INT_PTR CALLBACK Settings_GeneralDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPA dlgData->settings = reinterpret_cast(lParam); assert(dlgData->settings != nullptr); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(dlgData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + SettingsGeneralData *dlgData = reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + SettingsGeneralData *dlgData = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); assert(dlgData != nullptr); HWND hAutostart = GetDlgItem(hDlg, IDC_RUNONSTARTUP); diff --git a/WinMute/Settings_ManageEndpointsDlg.cpp b/WinMute/Settings_ManageEndpointsDlg.cpp index 35158e7..baef2af 100644 --- a/WinMute/Settings_ManageEndpointsDlg.cpp +++ b/WinMute/Settings_ManageEndpointsDlg.cpp @@ -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(endpointData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + EndpointData *epData = reinterpret_cast(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(lParam); assert(settings != nullptr); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WMSettings *settings = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); std::vector devices = ExportEndpointNameList(GetDlgItem(hDlg, IDC_ENDPOINT_LIST)); settings->StoreManagedAudioEndpoints(devices); if (Button_GetCheck(GetDlgItem(hDlg, IDC_ENDPOINT_LIST_IS_ALLOWLIST))) { diff --git a/WinMute/Settings_MuteDlg.cpp b/WinMute/Settings_MuteDlg.cpp index f7bd910..f208956 100644 --- a/WinMute/Settings_MuteDlg.cpp +++ b/WinMute/Settings_MuteDlg.cpp @@ -102,7 +102,7 @@ INT_PTR CALLBACK Settings_MuteDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM WMSettings* settings = reinterpret_cast(lParam); assert(settings != nullptr); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WMSettings *settings = reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WMSettings* settings = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); HWND hNotify = GetDlgItem(hDlg, IDC_SHOWNOTIFICATIONS); HWND hManageEndpoints = GetDlgItem(hDlg, IDC_MANAGE_AUDIO_ENDPOINTS_INDIVIDUALLY); diff --git a/WinMute/Settings_QuietHoursDlg.cpp b/WinMute/Settings_QuietHoursDlg.cpp index 662b5e5..7285c76 100644 --- a/WinMute/Settings_QuietHoursDlg.cpp +++ b/WinMute/Settings_QuietHoursDlg.cpp @@ -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(qh_entry)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + auto *qh_entry = reinterpret_cast(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(qhdata)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + auto qhdata = reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + auto qhdata = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); delete qhdata; EndDialog(hDlg, 0); return TRUE; diff --git a/WinMute/Settings_WifiDlg.cpp b/WinMute/Settings_WifiDlg.cpp index 28e25c1..b0d5e70 100644 --- a/WinMute/Settings_WifiDlg.cpp +++ b/WinMute/Settings_WifiDlg.cpp @@ -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(wifiData)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WiFiData* wifiData = reinterpret_cast(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(lParam); assert(settings != nullptr); - SetWindowLongPtr(hDlg, GWLP_USERDATA, reinterpret_cast(settings)); + SetWindowLongPtr(hDlg, DWLP_USER, reinterpret_cast(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(GetWindowLongPtr(hDlg, GWLP_USERDATA)); + WMSettings* settings = reinterpret_cast(GetWindowLongPtr(hDlg, DWLP_USER)); std::vector networks = ExportSsidListItems(GetDlgItem(hDlg, IDC_WIFI_LIST)); settings->StoreWifiNetworks(networks);