fix proc_exe fallback to wmi

This commit is contained in:
Doug MacEachern 2009-09-01 14:31:22 -07:00
parent c88b49abe2
commit c6b35167c8
2 changed files with 6 additions and 9 deletions

View File

@ -99,6 +99,9 @@ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
RTL_USER_PROCESS_PARAMETERS rtl; RTL_USER_PROCESS_PARAMETERS rtl;
DWORD size; DWORD size;
procexe->name[0] = '\0';
procexe->cwd[0] = '\0';
if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) { if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) {
return status; return status;
} }
@ -111,9 +114,6 @@ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
{ {
SIGAR_W2A(buf, procexe->name, sizeof(procexe->name)); SIGAR_W2A(buf, procexe->name, sizeof(procexe->name));
} }
else {
procexe->name[0] = '\0';
}
size = rtl_bufsize(buf, rtl.CurrentDirectoryName); size = rtl_bufsize(buf, rtl.CurrentDirectoryName);
memset(buf, '\0', sizeof(buf)); memset(buf, '\0', sizeof(buf));
@ -123,9 +123,6 @@ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc,
{ {
SIGAR_W2A(buf, procexe->cwd, sizeof(procexe->cwd)); SIGAR_W2A(buf, procexe->cwd, sizeof(procexe->cwd));
} }
else {
procexe->cwd[0] = '\0';
}
return SIGAR_OK; return SIGAR_OK;
} }

View File

@ -1605,9 +1605,9 @@ SIGAR_DECLARE(int) sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid,
} }
status = sigar_proc_exe_peb_get(sigar, proc, procexe); status = sigar_proc_exe_peb_get(sigar, proc, procexe);
if (status == ERROR_DATATYPE_MISMATCH) { if (procexe->name[0] == '\0') {
/* we are 32-bit, pid process is 64-bit */ /* likely we are 32-bit, pid process is 64-bit */
procexe->cwd[0] = '\0'; /* XXX where else can we try? */ /* procexe->cwd[0] = XXX where else can we try? */
status = sigar_proc_exe_wmi_get(sigar, pid, procexe); status = sigar_proc_exe_wmi_get(sigar, pid, procexe);
} }