mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-11-03 23:12:24 +08:00
新增dll检测功能
This commit is contained in:
parent
386022ea36
commit
50cdbd13f4
BIN
CheckDLL/Check.exe
Executable file
BIN
CheckDLL/Check.exe
Executable file
Binary file not shown.
73
CheckDLL/CheckCommand.py
Executable file
73
CheckDLL/CheckCommand.py
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
# 使用系统默认的 python3 运行
|
||||
#################################################################################################################
|
||||
# 作者:gfdgd xi、为什么您不喜欢熊出没和阿布呢
|
||||
# 版本:2.5.0
|
||||
# 更新时间:2022年11月18日
|
||||
# 感谢:感谢 wine、deepin-wine 以及星火团队,提供了 wine、deepin-wine、spark-wine-devel 给大家使用,让我能做这个程序
|
||||
# 基于 Python3 的 PyQt5 构建
|
||||
#################################################################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
print("参数不足")
|
||||
sys.exit(1)
|
||||
|
||||
if "--help" in sys.argv:
|
||||
print("帮助:")
|
||||
print("[exe path] [option]")
|
||||
print("--json 以 json 格式输出")
|
||||
print("-w [wine botton] [wine program path]")
|
||||
|
||||
jsonPrint = "--json" in sys.argv
|
||||
if jsonPrint:
|
||||
del sys.argv[sys.argv.index("--json")]
|
||||
lists = []
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
checkDll = False
|
||||
if "-w" in sys.argv:
|
||||
wineCommand = sys.argv.index("-w")
|
||||
wineBotton = os.getenv("HOME")
|
||||
wineProgram = "deepin-wine6-stable"
|
||||
checkDll = True
|
||||
try:
|
||||
wineBotton = sys.argv[wineCommand + 1]
|
||||
wineProgram = sys.argv[wineCommand + 2]
|
||||
except:
|
||||
pass
|
||||
with open(sys.argv[1], "rb") as file:
|
||||
while True:
|
||||
things = file.readline()
|
||||
if things == b"":
|
||||
break
|
||||
for n in [".dll", ".DLL"]:
|
||||
if n.encode() in things:
|
||||
# 提取 DLL 名称
|
||||
for i in str(things[1: -2]).split("\\x"):
|
||||
if n in i:
|
||||
dllName = i[2: ].replace(",{M", "").replace("+", "")
|
||||
if dllName.lower() == ".dll":
|
||||
continue
|
||||
if dllName in lists:
|
||||
continue
|
||||
if checkDll:
|
||||
if jsonPrint:
|
||||
if os.system(f"WINEPREFIX='{wineBotton}' {wineProgram} '{programPath}/Check.exe' '{dllName}' > /dev/null 2>&1"):
|
||||
lists.append(dllName)
|
||||
continue
|
||||
else:
|
||||
os.system(f"WINEPREFIX='{wineBotton}' {wineProgram} '{programPath}/Check.exe' '{dllName}'")
|
||||
lists.append(dllName)
|
||||
elif jsonPrint:
|
||||
lists.append(dllName)
|
||||
continue
|
||||
else:
|
||||
print(dllName)
|
||||
lists.append(dllName)
|
||||
if jsonPrint:
|
||||
print(json.dumps(lists))
|
||||
78
CheckDLL/main.py
Normal file
78
CheckDLL/main.py
Normal file
@ -0,0 +1,78 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import traceback
|
||||
import subprocess
|
||||
import PyQt5.QtGui as QtGui
|
||||
import PyQt5.QtCore as QtCore
|
||||
import PyQt5.QtWidgets as QtWidgets
|
||||
|
||||
def ReadNeedDll(lists):
|
||||
nmodel = QtGui.QStandardItemModel(window)
|
||||
for i in lists:
|
||||
item = QtGui.QStandardItem(i)
|
||||
nmodel.appendRow(item)
|
||||
needDllList.setModel(nmodel)
|
||||
|
||||
def ReadBadNeedDll(lists):
|
||||
nmodel = QtGui.QStandardItemModel(window)
|
||||
for i in lists:
|
||||
item = QtGui.QStandardItem(i)
|
||||
nmodel.appendRow(item)
|
||||
badDllList.setModel(nmodel)
|
||||
|
||||
def ErrorMsg(message):
|
||||
QtWidgets.QMessageBox.critical(window, "错误", message)
|
||||
|
||||
class ReadDll(QtCore.QThread):
|
||||
readNeed = QtCore.pyqtSignal(list)
|
||||
readBad = QtCore.pyqtSignal(list)
|
||||
error = QtCore.pyqtSignal(str)
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def run(self):
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
try:
|
||||
output = subprocess.getoutput(f"python3 '{programPath}/CheckCommand.py' '{sys.argv[1]}' --json")
|
||||
print(output)
|
||||
self.readNeed.emit(json.loads(output))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
self.error.emit(traceback.format_exc())
|
||||
try:
|
||||
badoutput = subprocess.getoutput(f"python3 '{programPath}/CheckCommand.py' '{sys.argv[1]}' --json -w '{sys.argv[2]}' '{sys.argv[3]}'")
|
||||
print(badoutput)
|
||||
self.readBad.emit(json.loads(badoutput))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
self.error.emit(traceback.format_exc())
|
||||
|
||||
def GetDll():
|
||||
global read
|
||||
read = ReadDll()
|
||||
read.readNeed.connect(ReadNeedDll)
|
||||
read.readBad.connect(ReadBadNeedDll)
|
||||
read.start()
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
window = QtWidgets.QMainWindow()
|
||||
widget = QtWidgets.QWidget()
|
||||
layout = QtWidgets.QGridLayout()
|
||||
badDllList = QtWidgets.QListView()
|
||||
needDllList = QtWidgets.QListView()
|
||||
badDllList.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||
needDllList.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
|
||||
loadingTips = QtGui.QStandardItemModel(window)
|
||||
loadingTipsItem = QtGui.QStandardItem("正在读取……")
|
||||
loadingTips.appendRow(loadingTipsItem)
|
||||
badDllList.setModel(loadingTips)
|
||||
needDllList.setModel(loadingTips)
|
||||
layout.addWidget(needDllList, 0, 0)
|
||||
layout.addWidget(badDllList, 0, 1)
|
||||
widget.setLayout(layout)
|
||||
window.setCentralWidget(widget)
|
||||
window.resize(int(window.frameGeometry().width() * 1.2), int(window.frameGeometry().height() * 1.1))
|
||||
GetDll()
|
||||
window.show()
|
||||
app.exec_()
|
||||
24
demo/CheckDLL/Check.cpp
Normal file
24
demo/CheckDLL/Check.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/**********************************
|
||||
* 作者:gfdgd xi、为什么您不喜欢熊出没和阿布呢
|
||||
* 版本:2.5.0
|
||||
* 更新时间:2022年11月18日
|
||||
* 只能在 Wine/Windows 运行
|
||||
**********************************/
|
||||
#include <iostream>
|
||||
#include <Windows.h>
|
||||
using namespace std;
|
||||
int main(int argc, char* argv[]){
|
||||
HINSTANCE hdll;
|
||||
hdll = LoadLibrary(argv[1]);
|
||||
if(argv[1] == ""){
|
||||
cout << "Don't have full parameter" << endl;
|
||||
return 2;
|
||||
}
|
||||
cout << "Checking " << argv[1] << " ......" << endl;
|
||||
if(hdll == NULL){
|
||||
cout << "Error, can't load this library." << endl;
|
||||
return 1;
|
||||
}
|
||||
cout << "No Problem!" << endl;
|
||||
return 0;
|
||||
}
|
||||
BIN
demo/CheckDLL/Check.exe
Executable file
BIN
demo/CheckDLL/Check.exe
Executable file
Binary file not shown.
73
demo/CheckDLL/main.py
Normal file
73
demo/CheckDLL/main.py
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
# 使用系统默认的 python3 运行
|
||||
#################################################################################################################
|
||||
# 作者:gfdgd xi、为什么您不喜欢熊出没和阿布呢
|
||||
# 版本:2.5.0
|
||||
# 更新时间:2022年11月18日
|
||||
# 感谢:感谢 wine、deepin-wine 以及星火团队,提供了 wine、deepin-wine、spark-wine-devel 给大家使用,让我能做这个程序
|
||||
# 基于 Python3 的 PyQt5 构建
|
||||
#################################################################################################################
|
||||
#################
|
||||
# 引入所需的库
|
||||
#################
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
print("参数不足")
|
||||
sys.exit(1)
|
||||
|
||||
if "--help" in sys.argv:
|
||||
print("帮助:")
|
||||
print("[exe path] [option]")
|
||||
print("--json 以 json 格式输出")
|
||||
print("-w [wine botton] [wine program path]")
|
||||
|
||||
jsonPrint = "--json" in sys.argv
|
||||
if jsonPrint:
|
||||
del sys.argv[sys.argv.index("--json")]
|
||||
lists = []
|
||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||
checkDll = False
|
||||
if "-w" in sys.argv:
|
||||
wineCommand = sys.argv.index("-w")
|
||||
wineBotton = os.getenv("HOME")
|
||||
wineProgram = "deepin-wine6-stable"
|
||||
checkDll = True
|
||||
try:
|
||||
wineBotton = sys.argv[wineCommand + 1]
|
||||
wineProgram = sys.argv[wineCommand + 2]
|
||||
except:
|
||||
pass
|
||||
with open(sys.argv[1], "rb") as file:
|
||||
while True:
|
||||
things = file.readline()
|
||||
if things == b"":
|
||||
break
|
||||
for n in [".dll", ".DLL"]:
|
||||
if n.encode() in things:
|
||||
# 提取 DLL 名称
|
||||
for i in str(things[1: -2]).split("\\x"):
|
||||
if n in i:
|
||||
dllName = i[2: ].replace(",{M", "").replace("+", "")
|
||||
if dllName.lower() == ".dll":
|
||||
continue
|
||||
if dllName in lists:
|
||||
continue
|
||||
if checkDll:
|
||||
if jsonPrint:
|
||||
if os.system(f"WINEPREFIX='{wineBotton}' {wineProgram} '{programPath}/Check.exe' '{dllName}' > /dev/null 2>&1"):
|
||||
lists.append(dllName)
|
||||
continue
|
||||
else:
|
||||
os.system(f"WINEPREFIX='{wineBotton}' {wineProgram} '{programPath}/Check.exe' '{dllName}'")
|
||||
lists.append(dllName)
|
||||
elif jsonPrint:
|
||||
lists.append(dllName)
|
||||
continue
|
||||
else:
|
||||
print(dllName)
|
||||
lists.append(dllName)
|
||||
if jsonPrint:
|
||||
print(json.dumps(lists))
|
||||
157
mainwindow.py
157
mainwindow.py
@ -1804,80 +1804,94 @@ def AddDockerMenu():
|
||||
openFileManager = QtWidgets.QAction("打开默认文件管理器")
|
||||
openTerminal = QtWidgets.QAction("打开默认终端")
|
||||
openFileManager.triggered.connect(lambda: threading.Thread(target=os.system, args=[f"xdg-open '{get_home()}'"]).start())
|
||||
openTerminal.triggered.connect(lambda: threading.Thread(target=os.system, args=[f"x-terminal-emulator"]).start())
|
||||
dockers.addAction(openFileManager)
|
||||
dockers.addAction(openTerminal)
|
||||
|
||||
def GetVersion():
|
||||
global about
|
||||
global programVersionType
|
||||
# 目前分为几个版本(在 control 文件区分):
|
||||
# 星火版本:~spark
|
||||
# 商店版本:~uos
|
||||
# 编译版本:无版本号
|
||||
# Gitee/Github……:正常版本
|
||||
# Docker 版本
|
||||
programVersionTypeLnk = {
|
||||
"spark": "星火应用商店版本",
|
||||
"uos": "deepin/UOS 应用商店版本<带签名>"
|
||||
}
|
||||
# 直接判断是不是 Docker 版本
|
||||
if os.path.exists(f"{programPath}/docker.txt"):
|
||||
programVersionType = "Docker 内置版本"
|
||||
window.setWindowTitle(f"{title} (Docker 内置版本)")
|
||||
AddDockerMenu()
|
||||
else:
|
||||
programVersionType = "从源码运行的版本"
|
||||
try:
|
||||
if not os.path.exists("/var/lib/dpkg/status"):
|
||||
print("无 dpkg,结束")
|
||||
file = open("/var/lib/dpkg/status", "r")
|
||||
fileName = file.read().splitlines()
|
||||
package = False
|
||||
for i in range(0, len(fileName)):
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner-docker":
|
||||
programVersionType = "Docker 内置版本"
|
||||
window.setWindowTitle(f"{title} (Docker 内置版本)")
|
||||
AddDockerMenu()
|
||||
break
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner-52":
|
||||
programVersionType = "吾爱专版"
|
||||
window.setWindowTitle(f"{title}(吾爱专版)")
|
||||
break
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner":
|
||||
package = True
|
||||
continue
|
||||
if not package:
|
||||
continue
|
||||
if fileName[i].replace(" ", "").replace("\n", "") == "":
|
||||
# 空行,不再考虑
|
||||
break
|
||||
# 搜索版本号
|
||||
try:
|
||||
if fileName[i][:fileName[i].index(":")] == "Version":
|
||||
version = fileName[i][fileName[i].index(":") + 1:].strip()
|
||||
print(f"版本号为:{version}")
|
||||
if not "-" in version:
|
||||
programVersionType = "从Gitee/Github/Gitlink等平台获取的版本"
|
||||
break
|
||||
programVersionType = version[version.index("-") + 1:]
|
||||
print(programVersionType)
|
||||
if "-" in programVersionType:
|
||||
# 考虑到如 2.1.0-2-spark 的情况
|
||||
programVersionType = programVersionType[programVersionType.index("-") + 1:]
|
||||
try:
|
||||
programVersionType = programVersionTypeLnk[programVersionType]
|
||||
except:
|
||||
programVersionType = "从Gitee/Github/Gitlink等平台获取的版本"
|
||||
class GetVersionThread(QtCore.QThread):
|
||||
signal = QtCore.pyqtSignal(str)
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
def run(self):
|
||||
global about
|
||||
global window
|
||||
global programVersionType
|
||||
# 目前分为几个版本(在 control 文件区分):
|
||||
# 星火版本:~spark
|
||||
# 商店版本:~uos
|
||||
# 编译版本:无版本号
|
||||
# Gitee/Github……:正常版本
|
||||
# Docker 版本
|
||||
programVersionTypeLnk = {
|
||||
"spark": "星火应用商店版本",
|
||||
"uos": "deepin/UOS 应用商店版本<带签名>"
|
||||
}
|
||||
# 直接判断是不是 Docker 版本
|
||||
if os.path.exists(f"{programPath}/docker.txt") or os.path.exists("/.dockerenv"):
|
||||
programVersionType = "Docker 内置版本"
|
||||
window.setWindowTitle(f"{title} (Docker 内置版本)")
|
||||
self.signal.emit("")
|
||||
else:
|
||||
programVersionType = "从源码运行的版本"
|
||||
try:
|
||||
if not os.path.exists("/var/lib/dpkg/status"):
|
||||
print("无 dpkg,结束")
|
||||
file = open("/var/lib/dpkg/status", "r")
|
||||
fileName = file.read().splitlines()
|
||||
package = False
|
||||
for i in range(0, len(fileName)):
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner-docker":
|
||||
programVersionType = "Docker 内置版本"
|
||||
window.setWindowTitle(f"{title} (Docker 内置版本)")
|
||||
#AddDockerMenu()
|
||||
self.signal.emit("")
|
||||
break
|
||||
except:
|
||||
traceback.print_exc()
|
||||
continue
|
||||
except:
|
||||
print("无法读取,当没有处理")
|
||||
print(programVersionType)
|
||||
about = about.replace("@VersionForType@", programVersionType)
|
||||
# 获取程序体积
|
||||
about = about.replace("@programSize@", str(int(getFileFolderSize(programPath) / 1024 / 1024)))
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner-52":
|
||||
programVersionType = "吾爱专版"
|
||||
window.setWindowTitle(f"{title}(吾爱专版)")
|
||||
break
|
||||
if fileName[i] == "Package: spark-deepin-wine-runner":
|
||||
package = True
|
||||
continue
|
||||
if not package:
|
||||
continue
|
||||
if fileName[i].replace(" ", "").replace("\n", "") == "":
|
||||
# 空行,不再考虑
|
||||
break
|
||||
# 搜索版本号
|
||||
try:
|
||||
if fileName[i][:fileName[i].index(":")] == "Version":
|
||||
version = fileName[i][fileName[i].index(":") + 1:].strip()
|
||||
print(f"版本号为:{version}")
|
||||
if not "-" in version:
|
||||
programVersionType = "从Gitee/Github/Gitlink等平台获取的版本"
|
||||
break
|
||||
programVersionType = version[version.index("-") + 1:]
|
||||
print(programVersionType)
|
||||
if "-" in programVersionType:
|
||||
# 考虑到如 2.1.0-2-spark 的情况
|
||||
programVersionType = programVersionType[programVersionType.index("-") + 1:]
|
||||
try:
|
||||
programVersionType = programVersionTypeLnk[programVersionType]
|
||||
except:
|
||||
programVersionType = "从Gitee/Github/Gitlink等平台获取的版本"
|
||||
break
|
||||
except:
|
||||
traceback.print_exc()
|
||||
continue
|
||||
except:
|
||||
print("无法读取,当没有处理")
|
||||
print(programVersionType)
|
||||
about = about.replace("@VersionForType@", programVersionType)
|
||||
# 获取程序体积
|
||||
about = about.replace("@programSize@", str(int(getFileFolderSize(programPath) / 1024 / 1024)))
|
||||
|
||||
def GetVersion():
|
||||
global runVersion
|
||||
runVersion = GetVersionThread()
|
||||
runVersion.signal.connect(AddDockerMenu)
|
||||
runVersion.start()
|
||||
|
||||
programVersionType = ""
|
||||
print(wine)
|
||||
@ -2439,7 +2453,8 @@ h7.triggered.connect(about_this_program)
|
||||
h8.triggered.connect(lambda: QtWidgets.QMessageBox.aboutQt(widget))
|
||||
hm1_1.triggered.connect(lambda: webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner"))
|
||||
# 异同步获取信息
|
||||
threading.Thread(target=GetVersion).start()
|
||||
#threading.Thread(target=GetVersion).start()
|
||||
GetVersion()
|
||||
# 窗口设置
|
||||
window.resize(widget.frameGeometry().width() * 2, widget.frameGeometry().height())
|
||||
widget.setLayout(mainLayout)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user