\r
     nssm processes <servicename>\r
 \r
+Note that if 32-bit NSSM is run on a 64-bit system running an older version of\r
+Windows than Vista it will not be able to query the paths of 64-bit processes.\r
+\r
 \r
 Exporting service configuration\r
 -------------------------------\r
 
       if (error != ERROR_PROC_NOT_FOUND) return 2;\r
     }\r
 \r
+    imports.QueryFullProcessImageName = (QueryFullProcessImageName_ptr) get_import(imports.kernel32, QUERYFULLPROCESSIMAGENAME_EXPORT, &error);\r
+    if (! imports.QueryFullProcessImageName) {\r
+      if (error != ERROR_PROC_NOT_FOUND) return 3;\r
+    }\r
+\r
     imports.SleepConditionVariableCS = (SleepConditionVariableCS_ptr) get_import(imports.kernel32, "SleepConditionVariableCS", &error);\r
     if (! imports.SleepConditionVariableCS) {\r
-      if (error != ERROR_PROC_NOT_FOUND) return 3;\r
+      if (error != ERROR_PROC_NOT_FOUND) return 4;\r
     }\r
 \r
     imports.WakeConditionVariable = (WakeConditionVariable_ptr) get_import(imports.kernel32, "WakeConditionVariable", &error);\r
     if (! imports.WakeConditionVariable) {\r
-      if (error != ERROR_PROC_NOT_FOUND) return 4;\r
+      if (error != ERROR_PROC_NOT_FOUND) return 5;\r
     }\r
   }\r
   else if (error != ERROR_MOD_NOT_FOUND) return 1;\r
   if (imports.advapi32) {\r
     imports.CreateWellKnownSid = (CreateWellKnownSid_ptr) get_import(imports.advapi32, "CreateWellKnownSid", &error);\r
     if (! imports.CreateWellKnownSid) {\r
-      if (error != ERROR_PROC_NOT_FOUND) return 6;\r
+      if (error != ERROR_PROC_NOT_FOUND) return 7;\r
     }\r
     imports.IsWellKnownSid = (IsWellKnownSid_ptr) get_import(imports.advapi32, "IsWellKnownSid", &error);\r
     if (! imports.IsWellKnownSid) {\r
-      if (error != ERROR_PROC_NOT_FOUND) return 7;\r
+      if (error != ERROR_PROC_NOT_FOUND) return 8;\r
     }\r
   }\r
-  else if (error != ERROR_MOD_NOT_FOUND) return 5;\r
+  else if (error != ERROR_MOD_NOT_FOUND) return 6;\r
 \r
   return 0;\r
 }\r
 
 #ifndef IMPORTS_H\r
 #define IMPORTS_H\r
 \r
+/* Some functions don't have decorated versions. */\r
+#ifdef UNICODE\r
+#define QUERYFULLPROCESSIMAGENAME_EXPORT "QueryFullProcessImageNameW"\r
+#else\r
+#define QUERYFULLPROCESSIMAGENAME_EXPORT "QueryFullProcessImageNameA"\r
+#endif\r
+\r
 typedef BOOL (WINAPI *AttachConsole_ptr)(DWORD);\r
 typedef BOOL (WINAPI *SleepConditionVariableCS_ptr)(PCONDITION_VARIABLE, PCRITICAL_SECTION, DWORD);\r
+typedef BOOL (WINAPI *QueryFullProcessImageName_ptr)(HANDLE, unsigned long, LPTSTR, unsigned long *);\r
 typedef void (WINAPI *WakeConditionVariable_ptr)(PCONDITION_VARIABLE);\r
 typedef BOOL (WINAPI *CreateWellKnownSid_ptr)(WELL_KNOWN_SID_TYPE, SID *, SID *, unsigned long *);\r
 typedef BOOL (WINAPI *IsWellKnownSid_ptr)(SID *, WELL_KNOWN_SID_TYPE);\r
   HMODULE advapi32;\r
   AttachConsole_ptr AttachConsole;\r
   SleepConditionVariableCS_ptr SleepConditionVariableCS;\r
+  QueryFullProcessImageName_ptr QueryFullProcessImageName;\r
   WakeConditionVariable_ptr WakeConditionVariable;\r
   CreateWellKnownSid_ptr CreateWellKnownSid;\r
   IsWellKnownSid_ptr IsWellKnownSid;\r
 
       buffer[i] = _T('\0');\r
     }\r
   }\r
-  if (! GetModuleFileNameEx(k->process_handle, NULL, exe, _countof(exe))) _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("???"));\r
+\r
+  unsigned long size = _countof(exe);\r
+  if (! imports.QueryFullProcessImageName || ! imports.QueryFullProcessImageName(k->process_handle, 0, exe, &size)) {\r
+    /*\r
+      Fall back to GetModuleFileNameEx(), which won't work for WOW64 processes.\r
+    */\r
+    if (! GetModuleFileNameEx(k->process_handle, NULL, exe, _countof(exe))) {\r
+      long error = GetLastError();\r
+      if (error == ERROR_PARTIAL_COPY) _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("[WOW64]"));\r
+      else _sntprintf_s(exe, _countof(exe), _TRUNCATE, _T("???"));\r
+    }\r
+  }\r
 \r
   _tprintf(_T("% 8lu %s%s\n"), k->pid, buffer ? buffer : _T(""), exe);\r
 \r