From c6b35167c8839dc64312f8ec2084a5e586737597 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 1 Sep 2009 14:31:22 -0700 Subject: [PATCH] fix proc_exe fallback to wmi --- src/os/win32/peb.c | 9 +++------ src/os/win32/win32_sigar.c | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/os/win32/peb.c b/src/os/win32/peb.c index ed0147d1..4fdbfcb8 100644 --- a/src/os/win32/peb.c +++ b/src/os/win32/peb.c @@ -99,6 +99,9 @@ int sigar_proc_exe_peb_get(sigar_t *sigar, HANDLE proc, RTL_USER_PROCESS_PARAMETERS rtl; DWORD size; + procexe->name[0] = '\0'; + procexe->cwd[0] = '\0'; + if ((status = sigar_rtl_get(sigar, proc, &rtl)) != SIGAR_OK) { 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)); } - else { - procexe->name[0] = '\0'; - } size = rtl_bufsize(buf, rtl.CurrentDirectoryName); 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)); } - else { - procexe->cwd[0] = '\0'; - } return SIGAR_OK; } diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index ccbd4456..c98af479 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -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); - if (status == ERROR_DATATYPE_MISMATCH) { - /* we are 32-bit, pid process is 64-bit */ - procexe->cwd[0] = '\0'; /* XXX where else can we try? */ + if (procexe->name[0] == '\0') { + /* likely we are 32-bit, pid process is 64-bit */ + /* procexe->cwd[0] = XXX where else can we try? */ status = sigar_proc_exe_wmi_get(sigar, pid, procexe); }