From 78e21ee24b89c0a85a981a13a7275f0d45628865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:53:21 +0800 Subject: [PATCH] =?UTF-8?q?IsWow64Process=E5=9C=A832=E4=BD=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=A7=8B=E7=BB=88=E8=BF=94=E5=9B=9EFalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LunaTranslator/textsource/embedded.py | 10 ++++------ .../LunaTranslator/textsource/textractor.py | 9 ++++----- LunaTranslator/LunaTranslator/utils/hwnd.py | 14 +++++++------- LunaTranslator/LunaTranslator/version.py | 2 +- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/LunaTranslator/LunaTranslator/textsource/embedded.py b/LunaTranslator/LunaTranslator/textsource/embedded.py index 3a96cef202..c6e63020a5 100644 --- a/LunaTranslator/LunaTranslator/textsource/embedded.py +++ b/LunaTranslator/LunaTranslator/textsource/embedded.py @@ -1,11 +1,8 @@ from utils.config import globalconfig ,_TR from textsource.textsourcebase import basetext -import functools,queue,time - -from utils.hwnd import getarch -from embedded.rpcman3 import RpcServer -from embedded.gameagent3 import GameAgent +import functools,queue,time,win32utils + class embedded(basetext ): def __init__(self,textgetmethod,hookselectdialog,pids,hwnd,pname,parent) : @@ -17,7 +14,8 @@ def __init__(self,textgetmethod,hookselectdialog,pids,hwnd,pname,parent) : self.hookselectdialog=hookselectdialog self.newline=queue.Queue() self.agentreceiveddata='' - if getarch(pids[0])!='86': + b=win32utils.GetBinaryType(pname) + if b!=0: self.embeddedfailed(_TR("暂不支持64程序")) else: self.parent.startembedsignal.emit(pids[0],self) diff --git a/LunaTranslator/LunaTranslator/textsource/textractor.py b/LunaTranslator/LunaTranslator/textsource/textractor.py index 7fd60045f5..505b694f22 100644 --- a/LunaTranslator/LunaTranslator/textsource/textractor.py +++ b/LunaTranslator/LunaTranslator/textsource/textractor.py @@ -1,14 +1,13 @@ import threading from queue import Queue import re -import time +import time,win32utils from traceback import print_exc from collections import OrderedDict from utils.hookcode import Parsecode from utils import somedef from utils.config import globalconfig ,savehook_new_data ,_TR from utils.subproc import u16lesubprocess -from utils.hwnd import getarch from textsource.textsourcebase import basetext from utils.utils import checkchaos class textractor(basetext ): @@ -22,7 +21,7 @@ def __init__(self,textgetmethod,hookselectdialog,pids,hwnd,pname ,autostarthook if len(autostarthookcode)==0: hookselectdialog.realshowhide.emit(True) self.newline=Queue() - self.arch=getarch(pids[0]) + self.arch=win32utils.GetBinaryType(pname) self.lock=threading.Lock() self.dontremove=dontremove self.hookdatacollecter=OrderedDict() @@ -56,8 +55,8 @@ def __init__(self,textgetmethod,hookselectdialog,pids,hwnd,pname ,autostarthook def textractor_init(self): if self.arch is None: return - - extra=f"./files/plugins/Textractor/x{self.arch}/ex_TextractorCLI.exe" + arch={0:'86',6:'64'}[self.arch] + extra=f"./files/plugins/Textractor/x{arch}/ex_TextractorCLI.exe" self.u16lesubprocess=u16lesubprocess([extra]) self.u16lesubprocess.readyread=self.handle_stdout self.u16lesubprocess.writelog=self.hookselectdialog.sysmessagesignal.emit diff --git a/LunaTranslator/LunaTranslator/utils/hwnd.py b/LunaTranslator/LunaTranslator/utils/hwnd.py index 80a6294aa8..11be4eabda 100644 --- a/LunaTranslator/LunaTranslator/utils/hwnd.py +++ b/LunaTranslator/LunaTranslator/utils/hwnd.py @@ -43,14 +43,14 @@ def getprocesslist(): pids= win32utils.EnumProcesses() return pids -def getarch(pid): - try: - process=win32utils.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, (pid)) +# def getarch(pid): +# try: +# process=win32utils.OpenProcess(win32con.PROCESS_ALL_ACCESS,False, (pid)) - arch='86' if win32utils.IsWow64Process( process) else '64' - except: - arch=None - return arch +# arch='86' if win32utils.IsWow64Process( process) else '64' +# except: +# arch=None +# return arch def getpidexe_x(pid,force=False): privi=win32con.PROCESS_QUERY_LIMITED_INFORMATION if force else win32con.PROCESS_ALL_ACCESS hwnd1=win32utils.OpenProcess(privi,False, (pid)) diff --git a/LunaTranslator/LunaTranslator/version.py b/LunaTranslator/LunaTranslator/version.py index c8ae0f414f..b293b7cec0 100644 --- a/LunaTranslator/LunaTranslator/version.py +++ b/LunaTranslator/LunaTranslator/version.py @@ -1 +1 @@ -version="v2.12.0" \ No newline at end of file +version="v2.12.1" \ No newline at end of file