Drop Windows 2000 considerations in ps, fix uid field length
* ps.cc (main): Widen UID field in long format to accommodate longer UIDs since Cygwin 1.7.34. Remove Windows 2000 considerations. Fix comments accordingly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
6261fb30a9
commit
7701a023ff
@ -1,3 +1,9 @@
|
|||||||
|
2015-06-10 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* ps.cc (main): Widen UID field in long format to accommodate longer
|
||||||
|
UIDs since Cygwin 1.7.34. Remove Windows 2000 considerations. Fix
|
||||||
|
comments accordingly.
|
||||||
|
|
||||||
2015-06-08 Corinna Vinschen <corinna@vinschen.de>
|
2015-06-08 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* path.cc (from_fstab_line): Don't convert slashes to backslashes for
|
* path.cc (from_fstab_line): Don't convert slashes to backslashes for
|
||||||
|
@ -158,8 +158,8 @@ main (int argc, char *argv[])
|
|||||||
const char *dfmt = "%7d%4s%10s %s\n";
|
const char *dfmt = "%7d%4s%10s %s\n";
|
||||||
const char *ftitle = " UID PID PPID TTY STIME COMMAND\n";
|
const char *ftitle = " UID PID PPID TTY STIME COMMAND\n";
|
||||||
const char *ffmt = "%8.8s%8d%8d%4s%10s %s\n";
|
const char *ffmt = "%8.8s%8d%8d%4s%10s %s\n";
|
||||||
const char *ltitle = " PID PPID PGID WINPID TTY UID STIME COMMAND\n";
|
const char *ltitle = " PID PPID PGID WINPID TTY UID STIME COMMAND\n";
|
||||||
const char *lfmt = "%c %7d %7d %7d %10u %4s %4u %8s %s\n";
|
const char *lfmt = "%c %7d %7d %7d %10u %4s %8u %8s %s\n";
|
||||||
char ch;
|
char ch;
|
||||||
PUNICODE_STRING uni = (PUNICODE_STRING) unicode_buf;
|
PUNICODE_STRING uni = (PUNICODE_STRING) unicode_buf;
|
||||||
void *drive_map = NULL;
|
void *drive_map = NULL;
|
||||||
@ -259,27 +259,15 @@ main (int argc, char *argv[])
|
|||||||
version.dwOSVersionInfoSize = sizeof version;
|
version.dwOSVersionInfoSize = sizeof version;
|
||||||
GetVersionEx (&version);
|
GetVersionEx (&version);
|
||||||
if (version.dwMajorVersion <= 5) /* pre-Vista */
|
if (version.dwMajorVersion <= 5) /* pre-Vista */
|
||||||
{
|
proc_access = PROCESS_QUERY_INFORMATION;
|
||||||
proc_access = PROCESS_QUERY_INFORMATION;
|
|
||||||
if (version.dwMinorVersion < 1) /* Windows 2000 */
|
|
||||||
proc_access |= PROCESS_VM_READ;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Except on Windows 2000, fetch an opaque drive mapping object from the
|
drive_map = (void *) cygwin_internal (CW_ALLOC_DRIVE_MAP);
|
||||||
Cygwin DLL. This is used to map NT device paths to Win32 paths. */
|
/* Check old Cygwin version. */
|
||||||
if (!(proc_access & PROCESS_VM_READ))
|
if (drive_map == (void *) -1)
|
||||||
{
|
drive_map = NULL;
|
||||||
drive_map = (void *) cygwin_internal (CW_ALLOC_DRIVE_MAP);
|
/* Allow fallback to GetModuleFileNameEx. */
|
||||||
/* Check old Cygwin version. */
|
if (!drive_map)
|
||||||
if (drive_map == (void *) -1)
|
proc_access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ;
|
||||||
drive_map = NULL;
|
|
||||||
/* Allow fallback to GetModuleFileNameEx for post-W2K. */
|
|
||||||
if (!drive_map)
|
|
||||||
proc_access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int pid = 0;
|
for (int pid = 0;
|
||||||
@ -332,9 +320,9 @@ main (int argc, char *argv[])
|
|||||||
if (!h)
|
if (!h)
|
||||||
continue;
|
continue;
|
||||||
/* We use NtQueryInformationProcess in the first place, because
|
/* We use NtQueryInformationProcess in the first place, because
|
||||||
GetModuleFileNameEx does not work on 64 bit systems when trying
|
GetModuleFileNameEx does not work under WOW64 when trying
|
||||||
to fetch module names of 64 bit processes. */
|
to fetch module names of 64 bit processes. */
|
||||||
if (!(proc_access & PROCESS_VM_READ)) /* Windows 2000 */
|
if (!(proc_access & PROCESS_VM_READ))
|
||||||
{
|
{
|
||||||
status = NtQueryInformationProcess (h, ProcessImageFileName, uni,
|
status = NtQueryInformationProcess (h, ProcessImageFileName, uni,
|
||||||
sizeof unicode_buf, NULL);
|
sizeof unicode_buf, NULL);
|
||||||
@ -358,12 +346,9 @@ main (int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (GetModuleFileNameExW (h, NULL, (PWCHAR) unicode_buf,
|
||||||
{
|
NT_MAX_PATH))
|
||||||
if (GetModuleFileNameExW (h, NULL, (PWCHAR) unicode_buf,
|
win32path = (wchar_t *) unicode_buf;
|
||||||
NT_MAX_PATH))
|
|
||||||
win32path = (wchar_t *) unicode_buf;
|
|
||||||
}
|
|
||||||
if (win32path)
|
if (win32path)
|
||||||
wcstombs (pname, win32path, sizeof pname);
|
wcstombs (pname, win32path, sizeof pname);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user