Class Kernel32FFM


public final class Kernel32FFM extends WindowsForeignFunctions
  • Constructor Details

    • Kernel32FFM

      public Kernel32FFM()
  • Method Details

    • isInvalidHandle

      public static boolean isInvalidHandle(MemorySegment handle)
      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

      public static OptionalInt CloseHandle(MemorySegment handle)
    • 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

      public static OptionalInt FindVolumeClose(MemorySegment hFindVolume)
    • GetComputerName

      public static Optional<String> GetComputerName()
    • GetComputerNameEx

      public static Optional<String> GetComputerNameEx()
    • GetCurrentProcess

      public static Optional<MemorySegment> GetCurrentProcess()
    • GetCurrentProcessId

      public static OptionalInt GetCurrentProcessId()
    • GetLastError

      public static OptionalInt GetLastError()
    • GetCurrentThreadId

      public static OptionalInt GetCurrentThreadId()
    • GetDiskFreeSpaceEx

      public static OptionalInt GetDiskFreeSpaceEx(MemorySegment lpDirectoryName, MemorySegment lpFreeBytesAvailableToCaller, MemorySegment lpTotalNumberOfBytes, MemorySegment lpTotalNumberOfFreeBytes)
    • GetDriveType

      public static OptionalInt GetDriveType(MemorySegment lpRootPathName)
    • 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

      public static OptionalLong GetTickCount()
    • SetErrorMode

      public static OptionalInt SetErrorMode(int uMode)
    • 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 path
      cchBufferLength - 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 object
      bInheritHandle - If TRUE, processes created by this process will inherit the handle
      dwProcessId - 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 process
      lpProcessAffinity - Pointer to receive the affinity mask for the process
      lpSystemAffinity - Pointer to receive the affinity mask for the system
      Returns:
      true if successful
    • IsWow64Process

      public static boolean IsWow64Process(MemorySegment hProcess, MemorySegment Wow64Process)
      Determines whether the specified process is running under WOW64.
      Parameters:
      hProcess - Handle to the process
      Wow64Process - 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 read
      lpBaseAddress - Pointer to the base address in the specified process from which to read
      lpBuffer - Buffer to receive the contents
      nSize - Number of bytes to be read
      lpNumberOfBytesRead - 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 process
      dwFlags - Flags (0 for Win32 path format, PROCESS_NAME_NATIVE for native system path format)
      lpExeName - Buffer to receive the path
      lpdwSize - 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 process
      dwFlags - Flags (0 for Win32 path format)
      arena - Arena for memory allocation
      Returns:
      The full process image name, or empty if failed
    • LocalFree

      public static MemorySegment LocalFree(MemorySegment hMem)
      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 VerifyVersionInfo
      typeMask - A mask that indicates the member of the OSVERSIONINFOEX structure whose comparison operator is being set
      condition - 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 compare
      dwTypeMask - A mask that indicates the members of the OSVERSIONINFOEX structure to be tested
      dwlConditionMask - 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

      public static boolean GetNativeSystemInfo(MemorySegment lpSystemInfo)
      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 time
      lpKernelTime - kernel time
      lpUserTime - 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