Class Kernel32FFM
java.lang.Object
oshi.ffm.ForeignFunctions
oshi.ffm.windows.WindowsForeignFunctions
oshi.ffm.windows.Kernel32FFM
-
Field Summary
Fields inherited from class ForeignFunctions
CAPTURE_CALL_STATE, CAPTURED_STATE_LAYOUT, ERRNO_HANDLE, LIBRARY_ARENA, LINKER, NATIVE_LONG_SIZE, NATIVE_POINTER_SIZE, NATIVE_SIZE_T_SIZE, SYMBOL_LOOKUP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intCallNtPowerInformation(int informationLevel, MemorySegment lpInputBuffer, int nInputBufferSize, MemorySegment lpOutputBuffer, int nOutputBufferSize) Sets or retrieves power information.static OptionalIntCloseHandle(MemorySegment handle) static Optional<MemorySegment> CreateFile(MemorySegment lpFileName, int dwDesiredAccess, int dwShareMode, int dwCreationDisposition, int dwFlagsAndAttributes) static booleanDeviceIoControl(MemorySegment hDevice, int dwIoControlCode, MemorySegment lpInBuffer, int nInBufferSize, MemorySegment lpOutBuffer, int nOutBufferSize) static Optional<MemorySegment> FindFirstVolume(MemorySegment lpszVolumeName, int cchBufferLength) static OptionalIntFindNextVolume(MemorySegment hFindVolume, MemorySegment lpszVolumeName, int cchBufferLength) static OptionalIntFindVolumeClose(MemorySegment hFindVolume) static Optional<MemorySegment> static OptionalIntstatic OptionalIntstatic OptionalIntGetDiskFreeSpaceEx(MemorySegment lpDirectoryName, MemorySegment lpFreeBytesAvailableToCaller, MemorySegment lpTotalNumberOfBytes, MemorySegment lpTotalNumberOfFreeBytes) static OptionalIntGetDriveType(MemorySegment lpRootPathName) static OptionalIntstatic booleanGetLogicalProcessorInformationEx(int relationshipType, MemorySegment buffer, MemorySegment returnedLength) Retrieves information about the relationships of logical processors and related hardware.static booleanGetNativeSystemInfo(MemorySegment lpSystemInfo) Retrieves information about the current system to an application running under WOW64.static booleanGetProcessAffinityMask(MemorySegment hProcess, MemorySegment lpProcessAffinity, MemorySegment lpSystemAffinity) Retrieves the process affinity mask for the specified process and the system affinity mask.static booleanGetSystemTimes(MemorySegment lpIdleTime, MemorySegment lpKernelTime, MemorySegment lpUserTime) Retrieves system timing information.static OptionalLongstatic OptionalIntGetVolumeInformation(MemorySegment lpRootPathName, MemorySegment lpVolumeNameBuffer, int nVolumeNameSize, MemorySegment lpVolumeSerialNumber, MemorySegment lpMaximumComponentLength, MemorySegment lpFileSystemFlags, MemorySegment lpFileSystemNameBuffer, int nFileSystemNameSize) static OptionalIntGetVolumeNameForVolumeMountPoint(MemorySegment lpszVolumeMountPoint, MemorySegment lpszVolumeName, int cchBufferLength) Retrieves a volume GUID path for the volume that is associated with the specified volume mount point.static OptionalIntGetVolumePathNamesForVolumeName(MemorySegment lpszVolumeName, MemorySegment lpszVolumePathNames, int cchBufferLength, MemorySegment lpcchReturnLength) static booleanisInvalidHandle(MemorySegment handle) Checks if a handle represents INVALID_HANDLE_VALUE.static booleanIsProcessorFeaturePresent(int processorFeature) Determines whether the specified processor feature is supported by the current computer.static booleanIsWow64Process(MemorySegment hProcess, MemorySegment Wow64Process) Determines whether the specified process is running under WOW64.static MemorySegmentLocalFree(MemorySegment hMem) Frees the specified local memory object and invalidates its handle.static Optional<MemorySegment> OpenProcess(int dwDesiredAccess, boolean bInheritHandle, int dwProcessId) Opens an existing local process object.QueryFullProcessImageName(MemorySegment hProcess, int dwFlags, Arena arena) Retrieves the full name of the executable image for the specified process.static booleanQueryFullProcessImageName(MemorySegment hProcess, int dwFlags, MemorySegment lpExeName, MemorySegment lpdwSize) Retrieves the full name of the executable image for the specified process.static booleanReadProcessMemory(MemorySegment hProcess, MemorySegment lpBaseAddress, MemorySegment lpBuffer, long nSize, MemorySegment lpNumberOfBytesRead) Reads data from an area of memory in a specified process.static OptionalIntSetErrorMode(int uMode) static booleanVerifyVersionInfoW(MemorySegment lpVersionInformation, int dwTypeMask, long dwlConditionMask) Compares a set of operating system version requirements to the corresponding values for the currently running version of the system.static longVerSetConditionMask(long conditionMask, int typeMask, byte condition) Sets the bits of a 64-bit value to indicate the comparison operator to use for a specified operating system version attribute.Methods inherited from class WindowsForeignFunctions
checkSuccess, isSuccess, readAnsiString, readWideString, setupTokenPrivileges, toWideStringMethods inherited from class ForeignFunctions
downcall, getByteArrayFromNativePointer, getErrno, getStringFromNativePointer, getStructFromNativePointer, lib, libraryLookup
-
Constructor Details
-
Kernel32FFM
public Kernel32FFM()
-
-
Method Details
-
isInvalidHandle
Checks if a handle represents INVALID_HANDLE_VALUE.- Parameters:
handle- the handle to check- Returns:
- true if the handle is null or equals INVALID_HANDLE_VALUE
-
CloseHandle
-
CreateFile
public static Optional<MemorySegment> CreateFile(MemorySegment lpFileName, int dwDesiredAccess, int dwShareMode, int dwCreationDisposition, int dwFlagsAndAttributes) -
DeviceIoControl
public static boolean DeviceIoControl(MemorySegment hDevice, int dwIoControlCode, MemorySegment lpInBuffer, int nInBufferSize, MemorySegment lpOutBuffer, int nOutBufferSize) -
FindFirstVolume
public static Optional<MemorySegment> FindFirstVolume(MemorySegment lpszVolumeName, int cchBufferLength) -
FindNextVolume
public static OptionalInt FindNextVolume(MemorySegment hFindVolume, MemorySegment lpszVolumeName, int cchBufferLength) -
FindVolumeClose
-
GetComputerName
-
GetComputerNameEx
-
GetCurrentProcess
-
GetCurrentProcessId
-
GetLastError
-
GetCurrentThreadId
-
GetDiskFreeSpaceEx
public static OptionalInt GetDiskFreeSpaceEx(MemorySegment lpDirectoryName, MemorySegment lpFreeBytesAvailableToCaller, MemorySegment lpTotalNumberOfBytes, MemorySegment lpTotalNumberOfFreeBytes) -
GetDriveType
-
GetVolumeInformation
public static OptionalInt GetVolumeInformation(MemorySegment lpRootPathName, MemorySegment lpVolumeNameBuffer, int nVolumeNameSize, MemorySegment lpVolumeSerialNumber, MemorySegment lpMaximumComponentLength, MemorySegment lpFileSystemFlags, MemorySegment lpFileSystemNameBuffer, int nFileSystemNameSize) -
GetVolumePathNamesForVolumeName
public static OptionalInt GetVolumePathNamesForVolumeName(MemorySegment lpszVolumeName, MemorySegment lpszVolumePathNames, int cchBufferLength, MemorySegment lpcchReturnLength) -
GetTickCount
-
SetErrorMode
-
GetVolumeNameForVolumeMountPoint
public static OptionalInt GetVolumeNameForVolumeMountPoint(MemorySegment lpszVolumeMountPoint, MemorySegment lpszVolumeName, int cchBufferLength) Retrieves a volume GUID path for the volume that is associated with the specified volume mount point.- Parameters:
lpszVolumeMountPoint- the path of a mounted folder or a drive letter (e.g., "C:\\")lpszVolumeName- buffer to receive the volume GUID pathcchBufferLength- size of the buffer in characters- Returns:
- nonzero if successful, zero otherwise
-
OpenProcess
public static Optional<MemorySegment> OpenProcess(int dwDesiredAccess, boolean bInheritHandle, int dwProcessId) Opens an existing local process object.- Parameters:
dwDesiredAccess- The access to the process objectbInheritHandle- If TRUE, processes created by this process will inherit the handledwProcessId- The identifier of the local process to be opened- Returns:
- Handle to the process, or null segment if failed
-
GetProcessAffinityMask
public static boolean GetProcessAffinityMask(MemorySegment hProcess, MemorySegment lpProcessAffinity, MemorySegment lpSystemAffinity) Retrieves the process affinity mask for the specified process and the system affinity mask.- Parameters:
hProcess- Handle to the processlpProcessAffinity- Pointer to receive the affinity mask for the processlpSystemAffinity- Pointer to receive the affinity mask for the system- Returns:
- true if successful
-
IsWow64Process
Determines whether the specified process is running under WOW64.- Parameters:
hProcess- Handle to the processWow64Process- Pointer to receive a value indicating WOW64 status- Returns:
- true if the function succeeds
-
ReadProcessMemory
public static boolean ReadProcessMemory(MemorySegment hProcess, MemorySegment lpBaseAddress, MemorySegment lpBuffer, long nSize, MemorySegment lpNumberOfBytesRead) Reads data from an area of memory in a specified process.- Parameters:
hProcess- Handle to the process with memory to be readlpBaseAddress- Pointer to the base address in the specified process from which to readlpBuffer- Buffer to receive the contentsnSize- Number of bytes to be readlpNumberOfBytesRead- Pointer to receive the number of bytes transferred- Returns:
- true if successful
-
QueryFullProcessImageName
public static boolean QueryFullProcessImageName(MemorySegment hProcess, int dwFlags, MemorySegment lpExeName, MemorySegment lpdwSize) Retrieves the full name of the executable image for the specified process.- Parameters:
hProcess- Handle to the processdwFlags- Flags (0 for Win32 path format, PROCESS_NAME_NATIVE for native system path format)lpExeName- Buffer to receive the pathlpdwSize- On input, size of the buffer in characters. On output, size of the path in characters- Returns:
- true if successful
-
QueryFullProcessImageName
public static Optional<String> QueryFullProcessImageName(MemorySegment hProcess, int dwFlags, Arena arena) Retrieves the full name of the executable image for the specified process.- Parameters:
hProcess- Handle to the processdwFlags- Flags (0 for Win32 path format)arena- Arena for memory allocation- Returns:
- The full process image name, or empty if failed
-
LocalFree
Frees the specified local memory object and invalidates its handle.- Parameters:
hMem- A handle to the local memory object- Returns:
- If the function succeeds, the return value is NULL
-
VerSetConditionMask
public static long VerSetConditionMask(long conditionMask, int typeMask, byte condition) Sets the bits of a 64-bit value to indicate the comparison operator to use for a specified operating system version attribute.- Parameters:
conditionMask- A value to be passed as the dwlConditionMask parameter of VerifyVersionInfotypeMask- A mask that indicates the member of the OSVERSIONINFOEX structure whose comparison operator is being setcondition- The operator to be used for the comparison- Returns:
- The condition mask value
-
VerifyVersionInfoW
public static boolean VerifyVersionInfoW(MemorySegment lpVersionInformation, int dwTypeMask, long dwlConditionMask) Compares a set of operating system version requirements to the corresponding values for the currently running version of the system.- Parameters:
lpVersionInformation- A pointer to an OSVERSIONINFOEX structure containing the operating system version requirements to comparedwTypeMask- A mask that indicates the members of the OSVERSIONINFOEX structure to be testeddwlConditionMask- The type of comparison to be used for each lpVersionInformation member being compared- Returns:
- true if the currently running operating system satisfies the specified requirements
-
GetNativeSystemInfo
Retrieves information about the current system to an application running under WOW64.- Parameters:
lpSystemInfo- A pointer to a SYSTEM_INFO structure that receives the information.- Returns:
- true if the call succeeded
-
GetSystemTimes
public static boolean GetSystemTimes(MemorySegment lpIdleTime, MemorySegment lpKernelTime, MemorySegment lpUserTime) Retrieves system timing information.- Parameters:
lpIdleTime- idle timelpKernelTime- kernel timelpUserTime- user time- Returns:
- true if the call succeeded
-
IsProcessorFeaturePresent
public static boolean IsProcessorFeaturePresent(int processorFeature) Determines whether the specified processor feature is supported by the current computer.- Parameters:
processorFeature- The processor feature to be tested.- Returns:
- true if the feature is supported
-
GetLogicalProcessorInformationEx
public static boolean GetLogicalProcessorInformationEx(int relationshipType, MemorySegment buffer, MemorySegment returnedLength) Retrieves information about the relationships of logical processors and related hardware.- Parameters:
relationshipType- The type of relationship to retrieve.buffer- A pointer to a buffer that receives the information.returnedLength- On input, specifies the length of the buffer. On output, receives the actual length.- Returns:
- true if the call succeeded
-
CallNtPowerInformation
public static int CallNtPowerInformation(int informationLevel, MemorySegment lpInputBuffer, int nInputBufferSize, MemorySegment lpOutputBuffer, int nOutputBufferSize) Sets or retrieves power information.- Parameters:
informationLevel- The power information level requested.lpInputBuffer- Optional input buffer.nInputBufferSize- Size of input buffer.lpOutputBuffer- Optional output buffer.nOutputBufferSize- Size of output buffer.- Returns:
- 0 (STATUS_SUCCESS) on success, non-zero on failure
-