I'm the author/primary maintainer of OSHI and a committer at JNA. JNA's Platform class does not distinguish between Windows and Windows PE. OSHI's code relies on the standard Windows Version Helper API to determine OS support for DLL functions. However, Windows PE is not indicated as a separate version.
In fact, Windows PE is not designed to be a standalone operating system. Its purpose (and authorized use) is very limited. From the Windows PE docs (emphasis mine):
Windows PE is not a general-purpose operating system. It may not be used for any purpose other than deployment and recovery.
Further,
To prevent its use as a production operating system, Windows PE automatically stops running the shell and restarts after 72 hours of continuous use.
Essentially, some features available in the Windows 10 API are not present in PE. From these Microsoft docs:
API Compatibility reference
Windows PE is a lightweight, bootstrap operating system based on a subset of components from the Windows operating system. It is designed to host deployment and recovery apps. As such, it contains many Windows binaries that are needed to host the APIs that are most important to these classes of app. Due to size and other design constraints, not all Windows binaries are present in Windows PE, and therefore not all Windows APIs are present or usable.
This is a feature of WinPE, not a bug.
OSHI is designed as a cross-platform library to provide information. It is not a "deployment and recovery" app. OSHI links (via JNA) to standard Windows DLLs such as Kernel32
, while WinPE has its own set of MinCore DLLs.
Windows PE is intended to be very lightweight, and very specific to the Windows operating system family, and very specific to deployment and recovery tasks.
You should probably be using command-line or Powershell tools for operating system and hardware information necessary for "deployment and recovery", the only authorized uses of WinPE. OSHI's ExecutingCommand
class is a nice utility class for processing command-line responses as Java Strings, that you are welcome to copy and use in your own Java project, without the overhead of the entire OSHI/JNA dependencies.
If you can specify specific points where "JNA is crashing" I can help you identify ways to work around any exceptions that may be thrown. Alternately, you can submit an issue/feature request at the OSHI project identifying these failures, to make it more robust to the PE environment, although "more robust" will likely be in the form of "avoiding crashes" rather than in providing information that is not available from the Windows API in WinPE. Finally, you may choose to bring up your issues for an extended discussion on the JNA mailing list.