From ffbeffe7737cd48da8bf7af120cfa236ff577430 Mon Sep 17 00:00:00 2001 From: Alessandro ZANNI Date: Fri, 14 Oct 2016 12:16:23 +0200 Subject: [PATCH] listSids fix error --- pupy/packages/windows/all/pupwinutils/security.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pupy/packages/windows/all/pupwinutils/security.py b/pupy/packages/windows/all/pupwinutils/security.py index 1250e9b9..de16073a 100644 --- a/pupy/packages/windows/all/pupwinutils/security.py +++ b/pupy/packages/windows/all/pupwinutils/security.py @@ -7,6 +7,7 @@ from ctypes import * import subprocess import psutil import ctypes +import platform LPVOID = c_void_p PVOID = LPVOID @@ -219,6 +220,11 @@ def EnablePrivilege(privilegeStr, hToken = None): def ListSids(): sids=[] + # A well know bug in windows version > 8 (major >= 6.2) occurs when a "GetTokenSid" function is called from a 64 bits process. Stop it before its call + win_version = float("%s.%s" % (sys.getwindowsversion()[0], sys.getwindowsversion()[1])) + if "64" in platform.architecture()[0] and win_version > 6.1: + raise OSError("Can't let you to do that because a well known bug is not fixed yet, migrate to a 32 bits process and run this action again.\nEx: run migrate -c \'C:\\Windows\\SysWOW64\\notepad.exe\'") + for proc in psutil.process_iter(): try: pinfo = proc.as_dict(attrs=['pid', 'username', 'name'])