List<Process> (File file) { // If the DLL was not present (XP or other OS), do not try to find it again. if (!ourFailed) { try { IntByReference session = new IntByReference(); char[] sessionKey = new char[Win32RestartManager.CCH_RM_SESSION_KEY + 1]; int error = Win32RestartManager.INSTANCE.RmStartSession(session, 0, sessionKey); if (error != 0) { LOG.warning("RmStartSession(): " + error); } else { try { StringArray resources = new StringArray(new WString[]{new WString(file.toString())}); error = Win32RestartManager.INSTANCE.RmRegisterResources(session.getValue(), 1, resources, 0, Pointer.NULL, 0, null); if (error != 0) { LOG.warning("RmRegisterResources('" + file + "'): " + error); } else { IntByReference procInfoNeeded = new IntByReference(); Win32RestartManager.RmProcessInfo info = new Win32RestartManager.RmProcessInfo(); Win32RestartManager.RmProcessInfo[] infos = (Win32RestartManager.RmProcessInfo[])info.toArray(MAX_PROCESSES); IntByReference procInfo = new IntByReference(infos.length); error = Win32RestartManager.INSTANCE.RmGetList(session.getValue(), procInfoNeeded, procInfo, info, new LongByReference()); if (error != 0) { LOG.warning("RmGetList('" + file + "'): " + error); } else { int n = procInfo.getValue(); List<Process> processes = new ArrayList<>(n); for (int i = 0; i < n; i++) { processes.add(new Process(infos[i].Process.dwProcessId, new String(infos[i].strAppName).trim())); } return processes; } } } finally { Win32RestartManager.INSTANCE.RmEndSession(session.getValue()); } } } catch (Throwable t) { // Best effort approach, if no DLL is found ignore. ourFailed = true; LOG.log(Level.WARNING, "Missing or dysfunctional restart manager DLL", t); } } return List.of(); }