From 79f05a23a8e403df7d59b6b3bdade5b2a072b51f Mon Sep 17 00:00:00 2001 From: 87owo <85057800+87owo@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:51:18 +0800 Subject: [PATCH] Add files via upload --- PYAS.py | 21 ++++++++++++--------- PYAS_Engine.py | 1 - 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/PYAS.py b/PYAS.py index 1907bc7..367fb06 100644 --- a/PYAS.py +++ b/PYAS.py @@ -1768,17 +1768,20 @@ class MainWindow_Controller(QMainWindow): bytes_returned = ctypes.wintypes.DWORD() res = self.kernel32.ReadDirectoryChangesW(hDir, buffer, ctypes.sizeof(buffer), True, 0x0000001F, ctypes.byref(bytes_returned), None, None) + if not res: + continue - if res: - notify = FILE_NOTIFY_INFORMATION.from_buffer_copy(buffer) - raw_filename = notify.FileName[:notify.FileNameLength // 2] - file_path = self.norm_path(os.path.join(self.path_user, raw_filename)) + notify = FILE_NOTIFY_INFORMATION.from_buffer_copy(buffer) + raw_filename = notify.FileName[:notify.FileNameLength // 2] + if not raw_filename: + continue - if notify.Action in [2, 3, 4] and not self.is_in_whitelist(file_path): - state = self.scan_engine(file_path) - if state: - self.add_to_quarantine([file_path]) - self.send_message(f"檔案防護 | 靜態掃描攔截 | None | {file_path} | None", "notify", True) + file_path = self.norm_path(os.path.join(self.path_user, raw_filename), must_exist=False) + if notify.Action in [2, 3, 4] and not self.is_in_whitelist(file_path): + state = self.scan_engine(file_path) + if state: + self.add_to_quarantine([file_path]) + self.send_message(f"檔案防護 | 靜態掃描攔截 | None | {file_path} | None", "notify", True) except Exception as e: self.send_message(e, "warn", False) self.kernel32.CloseHandle(hDir) diff --git a/PYAS_Engine.py b/PYAS_Engine.py index 279e45f..c97bb98 100644 --- a/PYAS_Engine.py +++ b/PYAS_Engine.py @@ -2,7 +2,6 @@ import os, yara, numpy, base64, onnxruntime import ctypes, ctypes.wintypes, pefile from PIL import Image from io import BytesIO -from pathlib import Path ####################################################################################################