WizardKit/.bin/Scripts/borrowed/acpi.py
Alan Mason 6fc04266d4 2017-11: Retroactive Updates
## MAJOR refactoring done ##

* All .cmd Command scripts
  * Brandind / Settings variables now set via .bin/Scripts/settings/main.py
  * Window titles now set using KIT_FULL_NAME

* All .py Python scripts
  * All ClientDir paths should now use KIT_SHORT_NAME
  * Long lines wrapped to better follow PEP8
  * String formatting now more consistant
  * Updated run_program() and popen_program() calls to use lists
    * (e.g. cmd = ['', '', '']; run_program(cmd))
    ** Should improve clarity IMO
  * Update window titles AFTER init_global_vars() so KIT_FULL_NAME can be used

* Branding / Settings
  * Support tech now configurable
    * (e.g. "Please let {tech} know and they'll look into it")
  * Timezone now configurable
  * Upload info can now be disabled/enabled in .bin/Scripts/settings/main.py

* CHKDSK
  * Combined read-only and fix scripts and added menu

* DISM
  * Combined ScanHealth and RestoreHealth scripts and added menu

* functions/common.py
  * BREAKING: run_program() and popen_program() no longer accept 'args' variable

* Misc
  * Removed Win7 NVMe launcher
    * Never used and Win7 is deprecated
  * Removed "DeviceRemover" and "Display Driver Uninstaller" launchers
    * Both cut too deep and were not useful
  * Removed Nirsoft utilities and Sysinternals Suite launchers
    * Too many tools unused.
    * Added .url links to the websites in case the tools are needed
  * Replaced WinDirStat with TreeSizeFree
  * Replaced Q-Dir launcher with XYplorer launcher
    * Q-Dir was running into issues on Windows 10
  * Removed C.IntRep, ESET, and MBAM launchers from "OSR & VR"
  * Removed JRT
    * Deprecated and discontinued by MBAM
  * Removed unsupported QuickBooks launchers (2014 and older)
  * Removed unsupported Office launchers (2010 and 2013\365)
  * Removed "Revo Uninstaller" launcher
  * Removed infrequently used tools from "Diagnostics"
    * Auslogics DiskDefrag
    * BatteryInfoView
    * BIOSCodes
    * GpuTest
    * HeavyLoad

* Bugfixes
  * major_exception() try-blocks should catch CTL+c again
    * Allows for manual script bailing
2017-11-17 01:02:24 -07:00

57 lines
2.3 KiB
Python

import sys
# Code borrowed from https://github.com/aeruder/get_win8key
if sys.platform.startswith('win32'):
import ctypes
import ctypes.wintypes
def EnumAcpiTables():
#returns a list of the names of the ACPI tables on this system
FirmwareTableProviderSignature=ctypes.wintypes.DWORD(1094930505)
pFirmwareTableBuffer=ctypes.create_string_buffer(0)
BufferSize=ctypes.wintypes.DWORD(0)
#http://msdn.microsoft.com/en-us/library/windows/desktop/ms724259
EnumSystemFirmwareTables=ctypes.WinDLL("Kernel32").EnumSystemFirmwareTables
ret=EnumSystemFirmwareTables(FirmwareTableProviderSignature, pFirmwareTableBuffer, BufferSize)
pFirmwareTableBuffer=None
pFirmwareTableBuffer=ctypes.create_string_buffer(ret)
BufferSize.value=ret
ret2=EnumSystemFirmwareTables(FirmwareTableProviderSignature, pFirmwareTableBuffer, BufferSize)
return [pFirmwareTableBuffer.value[i:i+4] for i in range(0, len(pFirmwareTableBuffer.value), 4)]
def GetAcpiTable(table):
#returns raw contents of ACPI table
#http://msdn.microsoft.com/en-us/library/windows/desktop/ms724379x
tableID = 0
for b in reversed(table):
tableID = (tableID << 8) + b
GetSystemFirmwareTable=ctypes.WinDLL("Kernel32").GetSystemFirmwareTable
FirmwareTableProviderSignature=ctypes.wintypes.DWORD(1094930505)
FirmwareTableID=ctypes.wintypes.DWORD(int(tableID))
pFirmwareTableBuffer=ctypes.create_string_buffer(0)
BufferSize=ctypes.wintypes.DWORD(0)
ret = GetSystemFirmwareTable(FirmwareTableProviderSignature, FirmwareTableID, pFirmwareTableBuffer, BufferSize)
pFirmwareTableBuffer=None
pFirmwareTableBuffer=ctypes.create_string_buffer(ret)
BufferSize.value=ret
ret2 = GetSystemFirmwareTable(FirmwareTableProviderSignature, FirmwareTableID, pFirmwareTableBuffer, BufferSize)
return pFirmwareTableBuffer.raw
elif sys.platform.startswith('linux'):
import os
TABLE_ROOT = b'/sys/firmware/acpi/tables'
def EnumAcpiTables():
return os.listdir(TABLE_ROOT)
def GetAcpiTable(table):
with open(os.path.join(TABLE_ROOT, table), 'rb') as o:
return o.read()
else:
raise NotImplementedError('acpi support only implemented for linux and win32')
def FindAcpiTable(table):
#checks if specific ACPI table exists and returns True/False
tables = EnumAcpiTables()
if table in tables:
return True
else:
return False