summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm30
1 files changed, 23 insertions, 7 deletions
diff --git a/Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm b/Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm
index 03f2469d337..26dd7ccba6e 100644
--- a/Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm
+++ b/Master/tlpkg/tlperl/lib/Win32/Process/Info/NT.pm
@@ -28,11 +28,13 @@ only be called via that package.
=head1 DESCRIPTION
-The main purpose of the Win32::Process::Info package is to get whatever
+The main purpose of the Win32::Process::Info::NT package is to get whatever
information is convenient (for the author!) about one or more Windows
32 processes. GetProcInfo (which see) is therefore the most-important
subroutine in the package. See it for more information.
+This package returns Windows process IDs, even under Cygwin.
+
Unless explicitly stated otherwise, modules, variables, and so
on are considered private. That is, the author reserves the right
to make arbitrary changes in the way they work, without telling
@@ -73,9 +75,9 @@ sub Win32::Process::Info::DummyRoutine::Call {
return undef; ## no critic (ProhibitExplicitReturnUndef)
}
-use base qw{Win32::Process::Info};
+use base qw{ Win32::Process::Info };
-our $VERSION = '1.019';
+our $VERSION = '1.020';
our $AdjustTokenPrivileges;
our $CloseHandle;
@@ -343,13 +345,14 @@ my $tac = TOKEN_READ;
my @pinf;
my $dat;
+my $my_pid = $self->My_Pid();
my %sid_to_name;
my @trydac = (
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
PROCESS_QUERY_INFORMATION,
);
-foreach my $pid (map {$_ eq '.' ? $$ : $_} @args) {
+foreach my $pid (map {$_ eq '.' ? $my_pid : $_} @args) {
local $^E = 0;
$dat = $self->_build_hash (undef, ProcessId => $pid);
@@ -527,7 +530,10 @@ reference to the list is returned.
sub ListPids {
my ( $self, @args ) = @_;
my $filter = undef;
-@args and $filter = {map {(($_ eq '.' ? $$ : $_), 1)} @args};
+my $my_pid = $self->My_Pid();
+@args and $filter = {
+ map { ($_ eq '.' ? $my_pid : $_) => 1 } @args
+};
$EnumProcesses ||= _map ('PSAPI', 'EnumProcesses', [qw{P N P}], 'I');
my $psiz = 4;
my $bsiz = 0;
@@ -581,6 +587,12 @@ confess 'Programming error - should not get here';
# appropriate size. A further unpack may be necessary to extract
# data from the finally-obtained structure. You'll be seeing a
# lot of this pack/unpack idiom in the code that follows.
+#
+# Interestingly enough in February 2013 I found (fairly easily)
+# ConvertSidToStringSid(), which seems to do what I need, and
+# seems to have the same vintage as the other calls used above.
+# But in September of 2002 when I was writing this code I never
+# found it - certainly the docs cited never mentioned it.
sub _text_sid {
my $sid = shift;
@@ -599,7 +611,11 @@ $GetSidIdentifierAuthority ||=
_map ('ADVAPI32', 'GetSidIdentifierAuthority', [qw{P}], 'N');
my $sia = $GetSidIdentifierAuthority->Call ($sid);
$sia = pack 'L', $sia;
-$sia = unpack 'P6', $sia;
+# Occasionally we end up with an undef value here, which indicates a
+# failure. The docs say this only happens with an invalid SID, but what
+# do they know?
+defined( $sia = unpack 'P6', $sia )
+ or return;
# Get the number of subauthorities.
@@ -694,7 +710,7 @@ Thomas R. Wyant, III (F<wyant at cpan dot org>)
Copyright (C) 2001-2003 by E. I. DuPont de Nemours and Company, Inc.
-Copyright (C) 2007-2011 by Thomas R. Wyant, III
+Copyright (C) 2007-2011, 2013 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text