summaryrefslogtreecommitdiff
path: root/psutil/arch/windows/security.c
diff options
context:
space:
mode:
authorEccoTheFlintstone <32797240+EccoTheFlintstone@users.noreply.github.com>2019-02-03 07:56:45 -0500
committerGiampaolo Rodola <g.rodola@gmail.com>2019-02-03 13:56:45 +0100
commita45365980d9ae9237caa61dc71d68ffd60c44acf (patch)
tree332de8b3560b2eb9523c03182c258c00b231deab /psutil/arch/windows/security.c
parentaf7e4b5fcac3e543664058adfe068ab881048832 (diff)
downloadpsutil-a45365980d9ae9237caa61dc71d68ffd60c44acf.tar.gz
Starting from windows 8.1, get commandline content using NtQueryInformationProcess (see #1384) (#1398)
#1384, #1398: on windows 8.1, get cmdline() using NtQueryInformationProcess in case the original method fails with ACCESS_DENIED
Diffstat (limited to 'psutil/arch/windows/security.c')
-rw-r--r--psutil/arch/windows/security.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/psutil/arch/windows/security.c b/psutil/arch/windows/security.c
index 331d9622..d5f8f8d3 100644
--- a/psutil/arch/windows/security.c
+++ b/psutil/arch/windows/security.c
@@ -34,7 +34,7 @@ psutil_token_from_handle(HANDLE hProcess) {
* constant, we pass through the TOKEN_PRIVILEGES constant. This value returns
* an array of privileges that the account has in the environment. Iterating
* through the array, we call the function LookupPrivilegeName looking for the
- * string “SeTcbPrivilege. If the function returns this string, then this
+ * string “SeTcbPrivilege. If the function returns this string, then this
* account has Local System privileges
*/
int
@@ -131,7 +131,6 @@ psutil_set_privilege(HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege) {
);
if (GetLastError() != ERROR_SUCCESS) return FALSE;
-
// second pass. set privilege based on previous setting
tpPrevious.PrivilegeCount = 1;
tpPrevious.Privileges[0].Luid = luid;
@@ -160,9 +159,8 @@ psutil_set_privilege(HANDLE hToken, LPCTSTR Privilege, BOOL bEnablePrivilege) {
int
psutil_set_se_debug() {
HANDLE hToken;
- if (! OpenThreadToken(GetCurrentThread(),
+ if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
- FALSE,
&hToken)
) {
if (GetLastError() == ERROR_NO_TOKEN) {
@@ -170,9 +168,8 @@ psutil_set_se_debug() {
CloseHandle(hToken);
return 0;
}
- if (!OpenThreadToken(GetCurrentThread(),
+ if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
- FALSE,
&hToken)
) {
RevertToSelf();
@@ -198,17 +195,15 @@ psutil_set_se_debug() {
int
psutil_unset_se_debug() {
HANDLE hToken;
- if (! OpenThreadToken(GetCurrentThread(),
+ if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
- FALSE,
&hToken)
) {
if (GetLastError() == ERROR_NO_TOKEN) {
if (! ImpersonateSelf(SecurityImpersonation))
return 0;
- if (!OpenThreadToken(GetCurrentThread(),
+ if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
- FALSE,
&hToken))
{
return 0;
@@ -223,3 +218,4 @@ psutil_unset_se_debug() {
CloseHandle(hToken);
return 1;
}
+