This commit is contained in:
恍兮惚兮 2024-09-22 20:55:19 +08:00
parent bd4f1da8c8
commit 9e38de84e6
2 changed files with 25 additions and 2 deletions

View File

@ -310,8 +310,23 @@ try:
except:
_QueryFullProcessImageNameW = 0
_GetLongPathName = _kernel32.GetLongPathNameW
_GetLongPathName.argtypes = (LPCWSTR, LPWSTR, DWORD)
_GetLongPathName.restype = DWORD
MAX_PATH = 260
def GetProcessFileName(hHandle):
def GetLongPathName(file):
succ = _GetLongPathName(file, None, 0)
if succ == 0:
return file
buff = create_unicode_buffer(succ)
succ = _GetLongPathName(file, buff, succ)
path = buff.value
return path
def _GetProcessFileName(hHandle):
w = create_unicode_buffer(65535)
# 我佛了,太混乱了,不同权限获取的东西完全不一样
if (
@ -351,6 +366,14 @@ def GetProcessFileName(hHandle):
return v
def GetProcessFileName(hHandle):
p = _GetProcessFileName(hHandle)
if p:
# GetModuleFileNameExW有可能莫名其妙得到短路径导致部分路径无法匹配
p = GetLongPathName(p)
return p
_CreateProcessW = _kernel32.CreateProcessW
_CreateProcessW.argtypes = (
c_wchar_p,

View File

@ -29,7 +29,7 @@ include(generate_product_version)
set(VERSION_MAJOR 5)
set(VERSION_MINOR 38)
set(VERSION_PATCH 8)
set(VERSION_PATCH 9)
add_library(pch pch.cpp)
target_precompile_headers(pch PUBLIC pch.h)