Skip to content

Commit

Permalink
IsWow64Process在32位系统始终返回False
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Apr 10, 2023
1 parent 55943f0 commit 78e21ee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
10 changes: 4 additions & 6 deletions LunaTranslator/LunaTranslator/textsource/embedded.py
Original file line number Diff line number Diff line change
@@ -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) :
Expand All @@ -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)
Expand Down
9 changes: 4 additions & 5 deletions LunaTranslator/LunaTranslator/textsource/textractor.py
Original file line number Diff line number Diff line change
@@ -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 ):
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions LunaTranslator/LunaTranslator/utils/hwnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion LunaTranslator/LunaTranslator/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version="v2.12.0"
version="v2.12.1"

0 comments on commit 78e21ee

Please sign in to comment.