Class WindowsOSProcessJNA
java.lang.Object
oshi.software.common.AbstractOSProcess
oshi.software.common.os.windows.WindowsOSProcess
oshi.software.os.windows.WindowsOSProcessJNA
- All Implemented Interfaces:
OSProcess
JNA-based Windows OS process implementation.
-
Nested Class Summary
Nested classes/interfaces inherited from interface OSProcess
OSProcess.StateModifier and TypeInterfaceDescriptionstatic enumProcess and Thread Execution States -
Field Summary
Fields inherited from class WindowsOSProcess
MAX_WINDOWS_HANDLES, USE_BATCH_COMMANDLINE, USE_PROCSTATE_SUSPENDEDModifier and TypeFieldDescriptionprotected static final longMaximum number of handles per process, accounting for 32-bit vs 64-bit Windows.protected static final booleanWhether to use batch WMI queries for command line retrieval.protected static final booleanWhether to check thread states to determine if a process is suspended. -
Constructor Summary
ConstructorsConstructorDescriptionWindowsOSProcessJNA(int pid, WindowsOperatingSystemJNA os, Map<Integer, ProcessPerfCounterBlock> processMap, Map<Integer, WtsInfo> processWtsMap, Map<Integer, ThreadPerfCounterBlock> threadMap) -
Method Summary
Modifier and TypeMethodDescriptionprotected OSThreadcreateOSThread(int pid, int tid, String procName, ThreadPerfCounterBlock pcb) Creates a platform-specific OS thread instance.longGets the process affinity mask for this process.Queries the argument list for this process.protected StringQueries the command line for this process.Queries the current working directory, command line, and environment variables from process memory.Queries group account information for this process.protected Map<Integer, ThreadPerfCounterBlock> queryMatchingThreads(Set<Integer> pids) Queries thread performance data matching the given process IDs.Queries user account information for this process.booleanAttempts to update process attributes.protected booleanupdateAttributes(ProcessPerfCounterBlock pcb, WtsInfo wts) Updates process attributes from performance counter and WTS data, then performs native-specific updates.Methods inherited from class WindowsOSProcess
defaultCwdCommandlineEnvironment, defaultPair, getArguments, getBitness, getBytesRead, getBytesWritten, getCommandLine, getCurrentWorkingDirectory, getCwdCmdEnv, getEnvironmentVariables, getGroup, getGroupID, getHardOpenFileLimit, getKernelTime, getMinorFaults, getName, getOpenFiles, getOs, getParentProcessID, getPath, getPriority, getPrivateResidentMemory, getResidentMemory, getSoftOpenFileLimit, getStartTime, getState, getThreadCount, getThreadDetails, getUpTime, getUser, getUserID, getUserTime, getVirtualSize, setBitness, setName, setPath, setState, setTcbModifier and TypeMethodDescriptionReturns a default empty triplet for cwd, command line, and environment.Returns a default pair of unknown values.Makes a best effort attempt to get a list of the the command-line arguments of the process.intAttempts to get the bitness (32 or 64) of the process.longGets the bytes read by the process.longGets the bytes written by the process.Gets the process command line used to start the process, including arguments if available to be determined.Makes a best effort attempt to obtain the current working directory for the process.Returns the memoized CWD/CommandLine/Environment triplet.Makes a best effort attempt to obtain the environment variables of the process.getGroup()Gets the group under which the process is executing.Gets the group id under which the process is executing.longGets the hard limit for open file handles (or network connections) that belong to the given process.longGets kernel/system (privileged) time used by the process.longGets the number of minor (soft) faults the process has made which have not required loading a memory page from disk.getName()Gets the name of the process, often the executable program.longGets the number of open file handles (or network connections) that belongs to the process.protected OperatingSystemgetOs()Returns theOperatingSysteminstance associated with this process.intGets the process ID of this process's parent.getPath()Gets the full filesystem path of the executing process.intGets the priority of this process.longReturns an estimate of the portion of physical memory (RAM) uniquely attributed to this process.longReturns the total amount of physical memory (RAM) currently mapped to the process's address space.longGets the soft limit for open file handles (or network connections) of the given process.longGets the process start time.getState()Gets the process state.intGets the number of threads being executed by this process.Retrieves the threads of the process and their details.longGets up time / elapsed time since the process started.getUser()Gets the user name of the process owner.Gets the user id of the process owner.longGets user time used by the process.longGets the Virtual Memory Size (VSZ).protected voidsetBitness(int bitness) Sets the process bitness.protected voidSets the process name.protected voidSets the process executable path.protected voidsetState(OSProcess.State state) Sets the process state.protected voidsetTcb(Map<Integer, ThreadPerfCounterBlock> tcb) Sets the thread counter block map.Methods inherited from class AbstractOSProcess
getProcessCpuLoadBetweenTicks, getProcessCpuLoadCumulative, getProcessID, toStringModifier and TypeMethodDescriptiondoublegetProcessCpuLoadBetweenTicks(OSProcess priorSnapshot) Gets CPU usage of this process since a previous snapshot of the same process, provided as a parameter.doubleGets cumulative CPU usage of this process.intGets the process ID.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OSProcess
getContextSwitches, getInvoluntaryContextSwitches, getMajorFaults, getVoluntaryContextSwitchesModifier and TypeMethodDescriptiondefault longA snapshot of the context switches the process has done, equal to the sum ofOSProcess.getVoluntaryContextSwitches()andOSProcess.getInvoluntaryContextSwitches()on platforms that provide the split.default longThe number of involuntary context switches the process has made.default longGets the number of major (hard) faults the process has made which have required loading a memory page from disk.default longThe number of voluntary context switches the process has made.
-
Constructor Details
-
WindowsOSProcessJNA
public WindowsOSProcessJNA(int pid, WindowsOperatingSystemJNA os, Map<Integer, ProcessPerfCounterBlock> processMap, Map<Integer, WtsInfo> processWtsMap, Map<Integer, ThreadPerfCounterBlock> threadMap)
-
-
Method Details
-
getAffinityMask
public long getAffinityMask()Description copied from interface:OSProcessGets the process affinity mask for this process.On Windows systems with more than 64 processors, if the threads of the calling process are in a single processor group, returns the process affinity mask for that group (which may be zero if the specified process is running in a different group). If the calling process contains threads in multiple groups, returns zero.
Because macOS does not export interfaces that identify processors or control thread placement, explicit thread to processor binding is not supported and this method will return a bitmask of all logical processors.
If the Operating System fails to retrieve an affinity mask (e.g., the process has terminated), returns zero.
- Returns:
- a bit vector in which each bit represents the processors that a process is allowed to run on.
-
updateAttributes
public boolean updateAttributes()Description copied from interface:OSProcessAttempts to update process attributes. Returns false if the update fails, which will occur if the process no longer exists.- Returns:
trueif the update was successful, false if the update failed. In addition, on a failed update the process state will be changed toOSProcess.State.INVALID.
-
updateAttributes
Description copied from class:WindowsOSProcessUpdates process attributes from performance counter and WTS data, then performs native-specific updates. Subclasses should callsuper.updateAttributes(pcb, wts)and then perform native handle-based updates.- Overrides:
updateAttributesin classWindowsOSProcess- Parameters:
pcb- Performance counter block for this process, or null if unavailablewts- WTS info for this process, or null if unavailable- Returns:
- true if the process is valid after the update
-
createOSThread
Description copied from class:WindowsOSProcessCreates a platform-specific OS thread instance.- Specified by:
createOSThreadin classWindowsOSProcess- Parameters:
pid- the owning process IDtid- the thread IDprocName- the process namepcb- the thread performance counter block- Returns:
- a new OSThread instance
-
queryMatchingThreads
Description copied from class:WindowsOSProcessQueries thread performance data matching the given process IDs.- Specified by:
queryMatchingThreadsin classWindowsOSProcess- Parameters:
pids- the set of process IDs to match- Returns:
- a map of thread ID to thread performance counter block
-
queryCommandLine
Description copied from class:WindowsOSProcessQueries the command line for this process.- Specified by:
queryCommandLinein classWindowsOSProcess- Returns:
- the command line string
-
queryArguments
Description copied from class:WindowsOSProcessQueries the argument list for this process.- Specified by:
queryArgumentsin classWindowsOSProcess- Returns:
- the list of arguments
-
queryUserInfo
Description copied from class:WindowsOSProcessQueries user account information for this process.- Specified by:
queryUserInfoin classWindowsOSProcess- Returns:
- a pair of (account name, SID string)
-
queryGroupInfo
Description copied from class:WindowsOSProcessQueries group account information for this process.- Specified by:
queryGroupInfoin classWindowsOSProcess- Returns:
- a pair of (group name, SID string)
-
queryCwdCommandlineEnvironment
Description copied from class:WindowsOSProcessQueries the current working directory, command line, and environment variables from process memory.- Specified by:
queryCwdCommandlineEnvironmentin classWindowsOSProcess- Returns:
- a triplet of (cwd, commandLine, environmentVariables)
-