wine的运行管理

# 运行exe程序
wine <exe程序>

# 运行msi程序
wine msiexec /i <msi程序>
wine start <msi程序>

# 静默安装
wine <exe程序> /q /doNotRequireDRMPrompt /noupdate

# 杀掉wine进程
wineserver -k
pkill wine

配置wine

配置环境变量

# 配置虚拟c盘路径,通常称为容器目录
export WINEPREFIX=<容器目录>

# 配置容器架构
WINEARCH=win32

# 配置DLL: b表示内置,n表示原生,配置为空或d时表示不加载dll
WINEDLLOVERRIDES="comdlg32=b,n;shell32=b;comctl32=n;oleaut32="
# 配置不加载mono和gecko
WINEDLLOVERRIDES="mscoree=d;mshtml=d"

# 配置debug
WINEDBG=trace+loddll,+cursor

# 配置dll搜索路径
WINEDLLPATH=<dll搜索路径>
WINEPATH=<dll搜索路径>

# 配置wineserver的加载路径
WINESERVER=<wineserver路径>

# 配置wineloader的加载路径
WINELOADER=<wineloader的路径>

# 配置3D渲染引擎
WINE_D3D_CONFIG="renderer=vulkan;VideoPciVendorID=0xc0de"

配置DLL

1.使用winecfg命令打开wine的控制面板:

winecfg

image.png

2.在wine中,dll分为原生dll和内置dll,原生dll就是Windows dll,内置dll就是wine生成的伪dll,可以配置搜索顺序,方法如下:

image.png

image.png

配置控制面板

# 控制面板
wine control

# 卸载程序
wine uninstaller

配置winetricks

下载winetricks:

wget https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod +x winetricks
sudo apt install cabextract

查看winetricks中存在的软件:

./winetricks list-all

使用winetricks安装软件:

./winetricks corefonts vcrun6 

配置注册表

查看/修改注册表

# 打开注册表
wine regedit

# 修改注册表后重启wine
wine reboot

配置Windows环境变量
修改HKEY_CURRENT_USER/Control Panel/Environment项。

配置binfmt

/etc/ 的优先级最高、 /run/ 的优先级居中、 /usr/lib/ 的优先级最低。

# wine
sudo sh -c 'echo ":DOSWin:M::MZ::/usr/bin/wine:" > /etc/binfmt.d/wine.conf'

# box86
sudo sh -c 'echo ":x86:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/box86:" > /etc/binfmt.d/box86.conf'

通用调试方法

对比分析法

查看论坛:
UOS论坛
Deepin论坛
ukylin/openkylin论坛
winehq
deepin-wine资源
Deepin Wiki - 深度百科
统信UOS:Deepin-Wine适配知识库

对比不同的wine:
deepin-wine,winehq-stable,winehq-staging,crossover。

正向分析法

wine调试脚本

# 向`~/.bashrc`中追加`test_wine`别名。如果不设置别名,会影响其他wine或者crossover的启动。
alias test_wine='
export WINEARCH=win32 
export WINEPREFIX=$HOME/.wine 
export WINEDEBUG=+loaddll,+timestamp
export WINEDLLOVERRIDES="mscoree=d;mshtml=d"
export WINEDIR=$HOME/work/wine-wrapper/wine/wine-hq/stable/release/usr/local/bin
export WINE=$WINEDIR/wine
alias wine=$WINEDIR/wine
alias wineserver=$WINEDIR/wineserver
alias winedbg=$WINEDIR/winedbg
alias winetricks=$HOME/work/wine-wrapper/scripts/winetricks/winetricks
alias wecom="wine $WINEPREFIX/drive_c/Program\ Files\ \(x86\)/WXWork/WXWork.exe"
alias wechat="wine $WINEPREFIX/drive_c/Program\ Files/Tencent/WeChat/WeChat.exe"
'

#  刷新当前终端的bashrc脚本
source ~/.bashrc

# 调试时,在终端启用test
test

# 测试,运行wine和wineserver
wine notepad
wineserver -k

log调试法

分析思路:
通过createWindow查找主进程和主线程id,
跟踪主进程id,查看主进程进度。

log通道用法如下,详情见Debug_Logging

# ------------输出log------------

# 默认输出`fixme`和`error`信息
export WINEDBG=+all     输出所有通道
+relay                  输出所有函数的参数及返回值
trace+loddll,+cursor    loaddll模块额外输出trace信息,cursor正常输出
warn-file               file通道不输出warn等级的log

过滤log:

wine notepad 2>&1 | grep dll

输出所有模块的log:

export WINEDEBUG="+all,-relay,-dbghelp_dwarf,-nsi,-heap"

逆向分析法

winedbg调试法:
wine中的进程有Windows进程、Windows线程和Linux线程三部分,通过winedbg命令可以查看并附加到进程:

# 启动debug
winedbg 

# 查看Windows进程信息
info process

# 附加到进程
attach <process-id>

# 单步调试
si
ni

另一种启动调试的方法:

winedbg telnet.exe

调试参数及方法可以参考:Debugging_Winegdb调试笔记逆向分析

其他方法

联系相关的技术人员、领导、社区等人寻求帮助。
百度、谷歌、论文、专利、技术论坛、淘宝、qq群。

常见问题

参考:WINE常见问题总结

参考链接

Debug Channels
wine用户手册
Wine
wine命令
Useful Registry Keys
Wine User’s Guide

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐