Skip to content

Commit

Permalink
Try to open process with PROCESS_TERMINATE flag.
Browse files Browse the repository at this point in the history
If it fails, open it with normal flags. Allows to open a process given a pid and kill it.
  • Loading branch information
ignacio committed Oct 20, 2011
1 parent ab73f94 commit 069fa70
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions winapi.l.c
Expand Up @@ -643,9 +643,14 @@ class Process {
} else {
this->pid = pid;
this->hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ | PROCESS_TERMINATE,
FALSE, pid );
if (!this->hProcess) {
this->hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, pid );
}
}
}

/// get the name of the process.
Expand Down

0 comments on commit 069fa70

Please sign in to comment.