(SIGAR-168) always fallback to wmi when peb fails for proc_args

This commit is contained in:
Doug MacEachern 2009-09-01 14:09:46 -07:00
parent 0b335d9025
commit c88b49abe2
2 changed files with 16 additions and 17 deletions

View File

@ -171,15 +171,16 @@ int sigar_proc_args_peb_get(sigar_t *sigar, HANDLE proc,
}
size = rtl_bufsize(buf, rtl.CommandLine);
if (size <= 0) {
return ERROR_DATATYPE_MISMATCH; /* fallback to wmi */
}
memset(buf, '\0', sizeof(buf));
if ((size > 0) &&
ReadProcessMemory(proc, rtl.CommandLine.Buffer, buf, size, NULL))
{
if (ReadProcessMemory(proc, rtl.CommandLine.Buffer, buf, size, NULL)) {
return sigar_parse_proc_args(sigar, buf, procargs);
}
else {
return SIGAR_OK;
return GetLastError();
}
}

View File

@ -1434,20 +1434,18 @@ static int sigar_remote_proc_args_get(sigar_t *sigar, sigar_pid_t pid,
char cmdline[SIGAR_CMDLINE_MAX], *ptr = cmdline, *arg;
HANDLE proc = open_process(pid);
if (!proc) {
return GetLastError();
}
if (proc) {
status = sigar_proc_args_peb_get(sigar, proc, procargs);
CloseHandle(proc);
if (status == ERROR_DATATYPE_MISMATCH) {
/* we are 32-bit, pid process is 64-bit */
status = sigar_proc_args_wmi_get(sigar, pid, procargs);
if (status == SIGAR_OK) {
return status;
}
}
return status;
/* likely we are 32-bit, pid process is 64-bit */
return sigar_proc_args_wmi_get(sigar, pid, procargs);
}
int sigar_os_proc_args_get(sigar_t *sigar, sigar_pid_t pid,