X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=process.cpp;h=e78283c1f05a0f7cf8b55fa9f8f116bf55a875c8;hb=ee9a86c8408feaf173733aea12a80211e5d74483;hp=dc995976c6790e31b14182f553ef4f25de1390a6;hpb=586ea54f696a562ed3837b6b55e3fa1bbe1b2b22;p=nssm.git diff --git a/process.cpp b/process.cpp index dc99597..e78283c 100644 --- a/process.cpp +++ b/process.cpp @@ -411,7 +411,18 @@ int print_process(nssm_service_t *service, kill_t *k) { buffer[i] = _T('\0'); } } - if (! GetModuleFileNameEx(k->process_handle, NULL, exe, _countof(exe))) _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("???")); + + unsigned long size = _countof(exe); + if (! imports.QueryFullProcessImageName || ! imports.QueryFullProcessImageName(k->process_handle, 0, exe, &size)) { + /* + Fall back to GetModuleFileNameEx(), which won't work for WOW64 processes. + */ + if (! GetModuleFileNameEx(k->process_handle, NULL, exe, _countof(exe))) { + long error = GetLastError(); + if (error == ERROR_PARTIAL_COPY) _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("[WOW64]")); + else _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("???")); + } + } _tprintf(_T("% 8lu %s%s\n"), k->pid, buffer ? buffer : _T(""), exe);