Как программно эмулировать батарею в рабочей станции Windows без батарейного устройства? - PullRequest
0 голосов
/ 02 июня 2018

В целях тестирования мне нужно заставить Windows думать, что на ПК рабочей станции есть батарея.

Есть ли способ подделать / смоделировать / эмулировать / смоделировать состояние батареи / низкий уровень / зарядку / разрядку в Windowsрабочая станция без аккумулятора?

Можно ли программно установить уровень заряда батареи в Windows?

Ответы [ 2 ]

0 голосов
/ 03 января 2019

Ответ Олега был довольно прост, чтобы следовать, но я не смог заставить его имитировать батарею - действия по отключению и включению реальной батареи действительно были успешными.

PS C:\RunTime> .\RegisterWDTF.exe
This version of WDTF is compatible with Windows Build 17763.
-Delete registry state.
-Get registry path.
-Register COM DLLs.
   Process "C:\RunTime\Actions\Deprecated\DeviceManagement.dll".
   Process "C:\RunTime\Actions\DeviceSupport\WDTFDeviceSupportAction.dll".
   Process "C:\RunTime\Actions\DrvPkgLibExt.dll".
      Not a COM DLL

   Process "C:\RunTime\Actions\EDT\WDTFEDTAction.dll".
   Process "C:\RunTime\Actions\IoSpy\WDTFIoAttackAction.dll".
   Process "C:\RunTime\Actions\IoSpy\WDTFIoSpyAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\SimpleIO_D3DTest.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFAnySimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFAudioSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFBluetoothSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFCDROMSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMobileBroadbandSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMUTT2STRESSSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMUTT2TCDSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFNetworkSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\wdtfsensorsiosimpleioaction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFVolumeSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWebcamSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWirelessSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWPDSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimulatedBattery\WDTFSimulatedBatterySystemAction.dll".
   Process "C:\RunTime\Actions\System\WDTFSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFConcurrentIOAction.dll".
   Process "C:\RunTime\Actions\WDTFCpuUtilizationSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverPackageAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverSetupDeviceAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverSetupSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverVerifierSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFFuzzTestAction.dll".
   Process "C:\RunTime\Actions\WDTFInterfaces\WDTFInterfaces.dll".
   Process "C:\RunTime\Actions\WDTFPNPAction.dll".
   Process "C:\RunTime\Actions\WDTFSUPAction.dll".
   Process "C:\RunTime\WDTF.DLL".
-Update registry state.
-Install Drivers.
-Done

 WDTF Registration Successful
PS C:\RunTime> cscript.exe .\fake-battery.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

Loading Wex.Logger.dll from systemdata.cpp linep 922 failed.
WDTF_TARGET               : INFO  :  - GetInterface("SimulatedBatterySystem")
WDTF_TARGET               : INFO  :          Target: ORANGE
WDTF_SIMBATT              : INFO  : DisableRealBatteries()
WDTF_SIMBATT              : INFO  : EnableSimulatedBattery()
WDTF_SIMBATT              : ERROR : SimulatedBatterySystem critical error installing battbus device. HRESULT=0xE0000203
C:\RunTime\fake-battery.vbs(22, 1) WDTF.SimulatedBatterySystem.1: SimulatedBatterySystem critical error installing battbus device. HRESULT=0xE0000203

К сожалению, нет информации, которую я мог бынайти в общедоступном Интернете об этих ошибках.Надеемся, что кто-то там сталкивался с этим и знает, что делать дальше!

-

edit: похоже, что Visual Studio устанавливает различные драйверы в дополнение к инфраструктуре тестирования, поэтому просто копируйте папку RunTimeнедостаточноВ итоге я добавил свою рабочую станцию ​​в качестве полной цели, используя VS с другой рабочей станции.Затем позвольте мне смоделировать батарею.

enter image description here

0 голосов
/ 02 июня 2018

tl; dr : используйте Windows Driver Testing Framework (WDTF) Runtime Libraries из комплекта драйверов Windows (WDK)

Длинная инструкция:

  1. Установите Visual Studio с комплектом драйверов Windows (WDK)
  2. Создание виртуальной машины
  3. Поиск для WDK Test Target Setup x64-x64_en-us.msi в C:\Program Files (x86)\Windows Kits
  4. Установка WDK Test Target Setup x64-x64_en-us.msi на виртуальной машине.
  5. InVisual Studio, в главном меню Driver> Test> Configure Devices добавить виртуальную машину для установки (WDTF) Runtime Libraries.simulate windows battery device

  6. Из папки копирования виртуальной машины C:\Program Files (x86)\Windows Kits\10\Testing\Runtimes\WDTF\RunTime на вашей рабочей станции

  7. Из папки RunTime от имени администратора RegisterWDTF.exe

Вывод:

C:\RunTime>RegisterWDTF.exe
-Delete registry state.
-Get registry path.
-Register COM DLLs.
   Process "C:\RunTime\Actions\Deprecated\DeviceManagement.dll".
   Process "C:\RunTime\Actions\DeviceSupport\WDTFDeviceSupportAction.dll".
   Process "C:\RunTime\Actions\DrvPkgLibExt.dll".
      Not a COM DLL

   Process "C:\RunTime\Actions\EDT\WDTFEDTAction.dll".
   Process "C:\RunTime\Actions\IoSpy\WDTFIoAttackAction.dll".
   Process "C:\RunTime\Actions\IoSpy\WDTFIoSpyAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\SimpleIO_D3DTest.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFAnySimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFAudioSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFBluetoothSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFCDROMSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMobileBroadbandSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMUTT2STRESSSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFMUTT2TCDSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFNetworkSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFVolumeSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWebcamSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWirelessSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimpleIO\WDTFWPDSimpleIoAction.dll".
   Process "C:\RunTime\Actions\SimulatedBattery\WDTFSimulatedBatterySystemAction.dll".
   Process "C:\RunTime\Actions\System\WDTFSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFConcurrentIOAction.dll".
   Process "C:\RunTime\Actions\WDTFCpuUtilizationSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverPackageAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverSetupDeviceAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverSetupSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFDriverVerifierSystemAction.dll".
   Process "C:\RunTime\Actions\WDTFFuzzTestAction.dll".
   Process "C:\RunTime\Actions\WDTFInterfaces\WDTFInterfaces.dll".
   Process "C:\RunTime\Actions\WDTFPNPAction.dll".
   Process "C:\RunTime\Actions\WDTFSUPAction.dll".
   Process "C:\WDTF.DLL".
-Update registry state.
-Install Drivers.
-Done

 WDTF Registration Successful

Теперь вы можете использовать COM-объект "WDTF2.WDTF" на языке вашей программы, как в этом примере VBScript:

'
' Variable defenition 
'
Dim WDTF
Dim SimulatedBatterySystemSystemAction


'
' Create WDTF object
'
Set WDTF = CreateObject("WDTF2.WDTF")

'
'  Get your newly created SimulatedBatterySystem action interface
'
Set SimulatedBatterySystemSystemAction = WDTF.SystemDepot.ThisSystem.GetInterface("SimulatedBatterySystem")


'  enable the simulated battery
SimulatedBatterySystemSystemAction.EnableSimulatedBattery()

'  disable real batteries
SimulatedBatterySystemSystemAction.DisableRealBatteries()

'  set to DC power status
SimulatedBatterySystemSystemAction.SetSimulatedBatteryToDC()

'  set to 50% charge level
SimulatedBatterySystemSystemAction.SetSimulatedBatteryChargePercentage(50)

WScript.Sleep 10000 

'  set to AC power status
SimulatedBatterySystemSystemAction.SetSimulatedBatteryToAC()

'  enable real batteries
SimulatedBatterySystemSystemAction.EnableRealBatteries()

'  disable the simulated battery
SimulatedBatterySystemSystemAction.DisableSimulatedBattery()

Здесь все ссылки WDTF: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/_dtf/

На всякий случай, батарейный модуль Linux Fake: https://github.com/hoelzro/linux-fake-battery-module

...