def query_working_set(self):
if self.bitness == 64 or windows.current_process.bitness == 64:
WSET_BLOCK = EPSAPI_WORKING_SET_BLOCK64
dummy = PSAPI_WORKING_SET_INFORMATION64()
else:
WSET_BLOCK = EPSAPI_WORKING_SET_BLOCK32
dummy = PSAPI_WORKING_SET_INFORMATION32()
try:
windows.winproxy.QueryWorkingSet(self.handle, ctypes.byref(dummy), ctypes.sizeof(dummy))
except WindowsError as e:
if e.winerror != 24:
raise
NumberOfEntriesType = [f for f in WSET_BLOCK._fields_ if f[0] == "Flags"][0][1]
for i in range(10):
# use the same type as WSET_BLOCK.Flags
class GENERATED_PSAPI_WORKING_SET_INFORMATION(ctypes.Structure):
_fields_ = [
("NumberOfEntries", NumberOfEntriesType),
("WorkingSetInfo", WSET_BLOCK * dummy.NumberOfEntries),
]
res = GENERATED_PSAPI_WORKING_SET_INFORMATION()
try:
if windows.current_process.bitness == 32 and self.bitness == 64:
windows.syswow64.NtQueryVirtualMemory_32_to_64(self.handle, 0, MemoryWorkingSetList, res)
else:
windows.winproxy.QueryWorkingSet(self.handle, ctypes.byref(res), ctypes.sizeof(res))
except WindowsError as e:
if e.winerror != 24:
raise
dummy.NumberOfEntries = res.NumberOfEntries
continue
except windows.generated_def.ntstatus.NtStatusException as e:
if e.code != STATUS_INFO_LENGTH_MISMATCH:
raise
dummy.NumberOfEntries = res.NumberOfEntries
continue
return res.WorkingSetInfo
# Raise ?
return None
评论列表
文章目录