From 8dd2a255683fc81089c1c5447168d3c21cc8aac6 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 5 Aug 2009 14:27:08 -0700 Subject: [PATCH] add wmi proc_args wrapper --- src/os/win32/wmi.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/os/win32/wmi.cpp b/src/os/win32/wmi.cpp index 0e8b0281..a61737a9 100644 --- a/src/os/win32/wmi.cpp +++ b/src/os/win32/wmi.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "sigar.h" #pragma comment(lib, "wbemuuid.lib") @@ -163,3 +164,31 @@ HRESULT WMI::GetProcCommandLine(DWORD pid, TCHAR *value) { return GetProcStringProperty(pid, L"CommandLine", value, SIGAR_CMDLINE_MAX); } + +/* in peb.c */ +extern "C" int sigar_parse_proc_args(sigar_t *sigar, WCHAR *buf, + sigar_proc_args_t *procargs); + +extern "C" int sigar_proc_args_wmi_get(sigar_t *sigar, sigar_pid_t pid, + sigar_proc_args_t *procargs) +{ + int status; + TCHAR buf[SIGAR_CMDLINE_MAX]; + WMI *wmi = new WMI(); + + if (FAILED(wmi->Open())) { + return GetLastError(); + } + + if (FAILED(wmi->GetProcCommandLine(pid, buf))) { + status = GetLastError(); + } + else { + status = sigar_parse_proc_args(sigar, buf, procargs); + } + + wmi->Close(); + delete wmi; + + return status; +}