KernelWanderers / OCSysInfo

Basic, high-level and efficient CLI for discovering, outputting and parsing hardware information from the current system.
MIT License
94 stars 14 forks source link

[HELP WANTED] Implementations for platforms #12

Closed kernel-dev closed 2 years ago

kernel-dev commented 2 years ago

There are a few features lacking on Linux platforms, most notably:

These aren't core features, besides the optimization, but they'd be nice to implement, so the information extracted is consistent, structure-wise; with a little bit of spid.


There's one feature that's lacking in Windows, and it's only complimentary to Input device detection:


That's basically all for now. I'm simply putting this issue here so that each user is aware that we know it's missing. But we simply need time, and possibly help, to implement all these features.

However, @rvstry has taken it upon themselves to attempt to implement block device detection for Linux platforms, and to optimize the hardware discovery part. In the situation that they do, I will update this issue accordingly.

Apethesis commented 2 years ago

Since when was RAM detection on windows, or mac, OR ANYWHERE IN THIS CASE?

kernel-dev commented 2 years ago

@Apethesis please use the latest version of this application.

kernel-dev commented 2 years ago

Update on this issue: we've finally found a shred of hope with determining interface type for each device, especially important for laptops - trackpad, touchpad & keyboard.

It would appear that we are able to run the following command: Get-WmiObject -Class Win32_SystemDriver | Select-Object -Property *, from where we can see, let's use I2C HID as an example:

Example on a laptop with I2C HID devices
``` RunspaceId : __GENUS : 2 __CLASS : Win32_SystemDriver __SUPERCLASS : Win32_BaseService __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_SystemDriver.Name="hidi2c" __PROPERTY_COUNT : 22 __DERIVATION : {Win32_BaseService, CIM_Service, CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : __NAMESPACE : root\cimv2 __PATH : \\\root\cimv2:Win32_SystemDriver.Name="hidi2c" AcceptPause : False AcceptStop : True Caption : Microsoft I2C HID Miniport Driver CreationClassName : Win32_SystemDriver Description : Microsoft I2C HID Miniport Driver DesktopInteract : False DisplayName : Microsoft I2C HID Miniport Driver ErrorControl : Normal ExitCode : 0 InstallDate : Name : hidi2c PathName : C:\WINDOWS\system32\drivers\hidi2c.sys ServiceSpecificExitCode : 0 ServiceType : Kernel Driver Started : True StartMode : Manual StartName : State : Running Status : OK SystemCreationClassName : Win32_ComputerSystem SystemName : TagId : 38 ```


We can notice that State is equal to Running, meanwhile, on a PC without I2C HID devices, it would look something like:

Example on a PC without I2C HID devices
``` PSComputerName : DESKTOP-QN4FJQF Status : OK Name : hidi2c State : Stopped ExitCode : 1077 Started : False ServiceSpecificExitCode : 0 __GENUS : 2 __CLASS : Win32_SystemDriver __SUPERCLASS : Win32_BaseService __DYNASTY : CIM_ManagedSystemElement __RELPATH : Win32_SystemDriver.Name="hidi2c" __PROPERTY_COUNT : 22 __DERIVATION : {Win32_BaseService, CIM_Service, CIM_LogicalElement, CIM_ManagedSystemElement} __SERVER : DESKTOP-QN4FJQF __NAMESPACE : root\cimv2 __PATH : \\DESKTOP-QN4FJQF\root\cimv2:Win32_SystemDriver.Name="hidi2c" AcceptPause : False AcceptStop : False Caption : Microsoft I2C HID Miniport Driver CreationClassName : Win32_SystemDriver Description : Microsoft I2C HID Miniport Driver DesktopInteract : False DisplayName : Microsoft I2C HID Miniport Driver ErrorControl : Normal InstallDate : PathName : C:\WINDOWS\system32\drivers\hidi2c.sys ServiceType : Kernel Driver StartMode : Manual StartName : SystemCreationClassName : Win32_ComputerSystem SystemName : DESKTOP-QN4FJQF TagId : 38 Scope : System.Management.ManagementScope Path : \\DESKTOP-QN4FJQF\root\cimv2:Win32_SystemDriver.Name="hidi2c" Options : System.Management.ObjectGetOptions ClassPath : \\DESKTOP-QN4FJQF\root\cimv2:Win32_SystemDriver Properties : {AcceptPause, AcceptStop, Caption, CreationClassName...} SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...} Qualifiers : {dynamic, Locale, provider, UUID} Site : Container : ```

The state here is equal to Stopped; this is what we will be seeking out when detecting the type of interface for these devices. This will only be applied for touchpads, trackpads and keyboards for laptops.


We've also been able to accumulate a short list of the driver names:

All in all, it is looking pretty good so far!

kernel-dev commented 2 years ago

Thanks to 1Revenger1 and DhinakG, who have immensely assisted us in relation to detecting protocols used for each HID device, we've managed to pinpoint a method that is relatively reliable for distinguishing such devices.

The method they've guided us to goes as follows:


Here is a short version that should be a mockup of the aforementioned method mentioned:

Script to detect protocol used for device
```py import subprocess smbus_driver = subprocess.check_output(["powershell", "Get-WmiObject", "-Class", "Win32_PnPEntity", "|", "Where", "-Property", "CompatibleID", "-Contains", "-Value", '"PCI\CC_0C0500"', "|", "Select", "Name"]).decode().lower() smbus_elan = len(smbus_driver) > 0 and "elans" in smbus_driver smbus_syna = len(smbus_driver) > 0 and "synaptics" in smbus_driver def is_usb(inf, service): return inf.split(".")[0] in ("msmouse", "keyboard", "input") and service in ("mouhid", "kbdhid", "hidusb") def is_i2c(inf, service): return "hidi2c" in inf and service == "hidi2c" def is_smbus(desc): return ("synaptics" in desc and smbus_syna) or ("elans" in desc and smbus_elan) def is_ps2(service): return "i8042" in service.lower() def driver_type(pnp_id, desc, w): pnp_entity = w.query(f"SELECT * FROM Win32_PnPEntity WHERE PNPDeviceID = '{pnp_id}'")[ 0].GetDeviceProperties(["DEVPKEY_Device_DriverInfPath", "DEVPKEY_Device_Service", "DEVPKEY_Device_Stack"]) protocol = None for instances in pnp_entity: if type(instances) == int: continue inf = instances[0].Data.lower() service = instances[1].Data.lower() if is_usb(inf, service): protocol = "USB" elif is_i2c(inf, service): protocol = "I2C" elif is_ps2(service): if is_smbus(desc.lower()): protocol = "SMBus" else: protocol = "PS/2" return protocol ```


Massive amounts of gratitude goes over to the following individuals, for all of their help with this: