Files
verify/shell/duilib/build-duilib32.sh
T
admin f90b77b9bb
Docker Build / Build and Push Docker Image (push) Successful in 1m8s
Docker Build / Deploy to Server (push) Successful in 3s
feat(protect): 32 位程序也能用 DuiLib 多皮肤壳
问题:x86 一直固定用 classic 壳(Direct2D 单皮肤),选了 dark/light/industrial
等皮肤照样出经典界面 —— 界面上那句「DuiLib 皮肤只做了 64 位构建,32 位程序
固定用经典壳」就是这个限制的说明。预览图按选择显示,产物却是另一套界面。

根因不是技术不可行,是 DuiLib 的 payload DLL 只编了 x64 一份
(assets/shell64_dui.bin),AssetsThemed 里 x86 分支没有对应资产。

做法
- 装 i686-w64-mingw32 工具链,用同一份不修改的 DuiLib 源码编 32 位 libduilib32.a
  (排除 UIWebBrowser/UIRichEdit/UIActiveX/UIFlash,stb_image.c 按 C 编)
- 用 shell9_v6.cpp 编出 shell32_dui.dll(1,018K,PE32 i386),
  落在 assets/shell32_dui.bin
- AssetsThemed 的 x86 分支:theme != classic → shell32_dui.bin
- 新增 shell/duilib/build-duilib32.sh 记录完整构建方式(含老 DuiLib 的补丁清单)
- 前端 zh/en 文案改为「32 位与 64 位共用同一套皮肤,效果一致」

验证(wine32 + Xvfb)
- packthemed 打 32 位样本:theme=dark → .vfy size=1050997(DuiLib),
  theme=classic → .vfy size=337487(经典壳),差 700K 说明取的确实是不同 payload
- 两个产物分别启动截图:dark 是深灰 + 4 个 tab(登录/注册/卡密充值/忘记密码)
  + 皮肤化标题栏;classic 是圆角卡片 + 单页「登录以继续」。界面完全不同,
  确认 32 位真的换到 DuiLib 了

注意:assets 是 //go:embed 进 cmd/packthemed 和主服务的,改完必须重编
(CI 会做;本地验证要手动 go build ./cmd/packthemed)。
2026-11-26 13:55:17 +08:00

48 lines
2.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 交叉编译 32 位 DuiLib 多皮肤壳 → shell32_dui.dll(x86 对应 shell64_dui.dll)
# 用法: DUILIB_DIR=/path/to/duilib ./build-duilib32.sh [源码] [输出目录]
#
# 与 64 位同源、同皮肤、同交互,只是工具链换成 i686。
#
# 前置:
# 1. apt install g++-mingw-w64-i686
# 2. 编 32 位 libduilib.a(见本文件末尾的说明,老 DuiLib 需要那几处改动)
#
# 产物拷进 backend/internal/protect/assets/shell32_dui.bin,
# 然后 **必须重编 cmd/packthemed 与主服务**(资产是 //go:embed 进去的,
# 不重编的话改了半天什么都没变,字节数一模一样)。
set -euo pipefail
DIR=$(cd "$(dirname "$0")" && pwd)
SRC=${1:-$DIR/shell9_v6.cpp}
DUILIB_DIR=${DUILIB_DIR:-/root/work/duilib-src}
OUTDIR=${2:-$DIR/out}
LIBDUILIB=${LIBDUILIB:-$OUTDIR/libduilib32.a}
[ -f "$LIBDUILIB" ] || {
echo "缺少 $LIBDUILIB(32 位 libduilib.a)。"
echo "先按下面步骤编:"
echo " 1) 用 i686-w64-mingw32-g++ -c 逐个编 $DUILIB_DIR/DuiLib 下的 cpp,"
echo " 排除 UIWebBrowser / UIRichEdit / UIActiveX / UIFlash"
echo " (前三个 mingw 没有对应头,UIFlash 要 atlcomcli.h)"
echo " 2) stb_image.c 必须用 i686-w64-mingw32-gcc 按 C 编(header-only,"
echo " 否则链接时 stbi_load_from_memory 未定义)"
echo " 3) i686-w64-mingw32-ar rcs libduilib32.a *.o"
exit 1
}
mkdir -p "$OUTDIR"
i686-w64-mingw32-g++ -std=c++17 -O2 -shared -s \
-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x0601 -D_WIN32_LEAN_AND_MEAN \
-I"$DUILIB_DIR/shim" -I"$DUILIB_DIR" -I"$DUILIB_DIR/DuiLib" \
-I"$DUILIB_DIR/DuiLib/Core" -I"$DUILIB_DIR/DuiLib/Control" \
-I"$DUILIB_DIR/DuiLib/Layout" -I"$DUILIB_DIR/DuiLib/Utils" \
-include "$DUILIB_DIR/shim/compat.h" -fpermissive -w \
-o "$OUTDIR/shell32_dui.dll" "$SRC" "$LIBDUILIB" \
-static -lcomctl32 -lgdiplus -lole32 -loleaut32 -luuid -lshlwapi -limm32 \
-lwinmm -lversion -lgdi32 -luser32 -lwinhttp -ladvapi32 -lbcrypt -Wl,--kill-at
echo "生成 $OUTDIR/shell32_dui.dll($(stat -c%s "$OUTDIR/shell32_dui.dll") 字节)"
echo "下一步:cp 到 backend/internal/protect/assets/shell32_dui.bin,再 go build ./cmd/packthemed"