This commit is contained in:
恍兮惚兮 2024-05-12 00:32:01 +08:00
parent c021aca406
commit a29f16186b
3 changed files with 9 additions and 20 deletions

View File

@ -45,15 +45,6 @@ from winsharedutils import pid_running
from myutils.post import POSTSOLVE from myutils.post import POSTSOLVE
class _autolock:
def __init__(self, lock) -> None:
self.lock = lock
lock.acquire()
def __del__(self):
self.lock.release()
class MAINUI: class MAINUI:
def __init__(self) -> None: def __init__(self) -> None:
super().__init__() super().__init__()
@ -143,7 +134,12 @@ class MAINUI:
def textgetmethod( def textgetmethod(
self, text, is_auto_run=True, embedcallback=None, onlytrans=False self, text, is_auto_run=True, embedcallback=None, onlytrans=False
): ):
_autolock(self.solvegottextlock) with self.solvegottextlock:
return self.textgetmethod_1(text, is_auto_run, embedcallback, onlytrans)
def textgetmethod_1(
self, text, is_auto_run=True, embedcallback=None, onlytrans=False
):
returnandembedcallback = lambda: embedcallback("") if embedcallback else "" returnandembedcallback = lambda: embedcallback("") if embedcallback else ""

View File

@ -904,8 +904,6 @@ class hookselect(closeashidewindow):
def accept(self, key, select): def accept(self, key, select):
try: try:
gobject.baseobject.textsource.lock.acquire()
if key in gobject.baseobject.textsource.selectedhook: if key in gobject.baseobject.textsource.selectedhook:
gobject.baseobject.textsource.selectedhook.remove(key) gobject.baseobject.textsource.selectedhook.remove(key)
@ -928,7 +926,6 @@ class hookselect(closeashidewindow):
savehook_new_data[gobject.baseobject.textsource.pname].update( savehook_new_data[gobject.baseobject.textsource.pname].update(
{"hook": gobject.baseobject.textsource.selectedhook} {"hook": gobject.baseobject.textsource.selectedhook}
) )
gobject.baseobject.textsource.lock.release()
except: except:
print_exc() print_exc()

View File

@ -94,7 +94,6 @@ class texthook(basetext):
self.newline = Queue() self.newline = Queue()
self.newline_delaywait = Queue() self.newline_delaywait = Queue()
self.is64bit = Is64bit(pids[0]) self.is64bit = Is64bit(pids[0])
self.lock = threading.Lock()
self.hookdatacollecter = OrderedDict() self.hookdatacollecter = OrderedDict()
self.hooktypecollecter = OrderedDict() self.hooktypecollecter = OrderedDict()
self.currentname = None self.currentname = None
@ -312,14 +311,13 @@ class texthook(basetext):
def onremovehook(self, tp): def onremovehook(self, tp):
toremove = [] toremove = []
self.lock.acquire()
for key in self.hookdatacollecter: for key in self.hookdatacollecter:
if key[1] == tp.addr: if key[1] == tp.addr:
toremove.append(key) toremove.append(key)
for key in toremove: for key in toremove:
gobject.baseobject.hookselectdialog.removehooksignal.emit(key) gobject.baseobject.hookselectdialog.removehooksignal.emit(key)
self.hookdatacollecter.pop(key) self.hookdatacollecter.pop(key)
self.lock.release()
def parsetextthread(self, hc, hn, tp): def parsetextthread(self, hc, hn, tp):
key = (tp.processId, tp.addr, tp.ctx, tp.ctx2, hn.decode("ascii"), hc) key = (tp.processId, tp.addr, tp.ctx, tp.ctx2, hn.decode("ascii"), hc)
@ -344,7 +342,7 @@ class texthook(basetext):
self.Luna_RemoveHook(key[0], key[1]) self.Luna_RemoveHook(key[0], key[1])
return False return False
self.lock.acquire()
select = False select = False
for _i, autostarthookcode in enumerate(self.autostarthookcode): for _i, autostarthookcode in enumerate(self.autostarthookcode):
if self.match_compatibility(key, autostarthookcode): if self.match_compatibility(key, autostarthookcode):
@ -358,7 +356,6 @@ class texthook(basetext):
gobject.baseobject.hookselectdialog.addnewhooksignal.emit( gobject.baseobject.hookselectdialog.addnewhooksignal.emit(
key, select, [hc, hn, tp] key, select, [hc, hn, tp]
) )
self.lock.release()
return True return True
def setsettings(self): def setsettings(self):
@ -462,7 +459,7 @@ class texthook(basetext):
if key not in self.hookdatacollecter: if key not in self.hookdatacollecter:
if self.onnewhook(hc, hn, tp) == False: if self.onnewhook(hc, hn, tp) == False:
return False return False
self.lock.acquire()
if self.hooktypecollecter[key] == 1: if self.hooktypecollecter[key] == 1:
self.currentname = output self.currentname = output
if len(self.selectedhook) == 1: if len(self.selectedhook) == 1:
@ -479,7 +476,6 @@ class texthook(basetext):
self.hookdatacollecter[key] = self.hookdatacollecter[key][-100:] self.hookdatacollecter[key] = self.hookdatacollecter[key][-100:]
gobject.baseobject.hookselectdialog.update_item_new_line.emit(key, output) gobject.baseobject.hookselectdialog.update_item_new_line.emit(key, output)
self.lock.release()
return True return True
def checkisusingembed(self, address, ctx1, ctx2): def checkisusingembed(self, address, ctx1, ctx2):