From d3c165de79235d4e4480499c093e949a581f0142 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Mon, 2 Nov 2026 18:52:38 +0100 Subject: [PATCH] fix(feature-limits): keep flags above bit 31 on 32-bit builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CCheckListBox keeps its own per-row state in the item data slot and exposes a DWORD_PTR user field inside it, so every flag this dialog stored travelled through a value that is only 32 bits wide in a Win32 build. On a 32-bit server, each menu and context row at bit 32 or above therefore came back as zero: 26 entries in the 主菜单 tab, from 插件请求 to DLL内嵌TLS证书, and 14 in the 右键菜单 tab, from 虚拟屏幕(插件) to 执行代码. Ticking one wrote nothing into the generated master, and reopening the dialog showed it unticked again. The narrowing never produced a warning because C4244 is listed in DisableSpecificWarnings for all four configurations, and the x64 build, where DWORD_PTR is 64 bits wide, was unaffected. Store the row's index into the tab's item vector instead of the flag itself, and have CollectFlags() look the flag up in that vector, so the value never narrows in either architecture. The vector index also survives the compile-time skips in PopulateList and needs no change when the flags grow into a second 64-bit word. Verified by building the Debug server for x64 and x86. Co-Authored-By: deepseek-flash --- server/2015Remote/FeatureLimitsDlg.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/2015Remote/FeatureLimitsDlg.cpp b/server/2015Remote/FeatureLimitsDlg.cpp index 559cd38..cfd4ac8 100644 --- a/server/2015Remote/FeatureLimitsDlg.cpp +++ b/server/2015Remote/FeatureLimitsDlg.cpp @@ -261,13 +261,16 @@ void CFeatureLimitsDlg::PopulateList(int tabIndex) } // 添加项目到列表 - for (const auto& item : *items) { + for (size_t i = 0; i < items->size(); i++) { + const FeatureItem& item = (*items)[i]; // 编译时已隐藏的功能,不显示 if (item.compileMacro) continue; int index = m_CheckList.AddString(_TR(item.name)); - m_CheckList.SetItemData(index, item.flag); + // item data 存下标而不是 flag:item data 的宽度是 DWORD_PTR,32 位构建下只有 + // 32 位,直接存 uint64 标志位会把 bit >= 32 截成 0,这些功能就永远勾不上。 + m_CheckList.SetItemData(index, (DWORD_PTR)i); // 检查是否被上级禁用(继承)或用户已选择 bool isInherited = (inheritedFlags & item.flag) != 0; @@ -290,19 +293,23 @@ void CFeatureLimitsDlg::CollectFlags() { // 根据当前Tab收集选中状态到对应的标志位 uint64_t* targetFlags = nullptr; + const std::vector* items = nullptr; uint64_t inheritedFlags = 0; switch (m_CurrentTab) { case 0: targetFlags = &m_MenuFlags; + items = &m_MenuItems; inheritedFlags = m_InheritedMenuFlags; break; case 1: targetFlags = &m_ToolbarFlags; + items = &m_ToolbarItems; inheritedFlags = m_InheritedToolbarFlags; break; case 2: targetFlags = &m_ContextFlags; + items = &m_ContextItems; inheritedFlags = m_InheritedContextFlags; break; default: @@ -312,11 +319,14 @@ void CFeatureLimitsDlg::CollectFlags() // 保留继承的标志位 *targetFlags = inheritedFlags; - // 收集用户勾选的项目 + // 收集用户勾选的项目:item data 是在 items 里的下标(见 PopulateList), + // 这里取回完整的 64 位标志位,避免 32 位构建下的截断。 for (int i = 0; i < m_CheckList.GetCount(); i++) { - if (m_CheckList.GetCheck(i)) { - *targetFlags |= m_CheckList.GetItemData(i); - } + if (!m_CheckList.GetCheck(i)) + continue; + size_t itemIndex = (size_t)m_CheckList.GetItemData(i); + if (itemIndex < items->size()) + *targetFlags |= (*items)[itemIndex].flag; } }