From b02a62a917ab8e8ce1833ca06fda7e30f7ce57f4 Mon Sep 17 00:00:00 2001 From: Alan Mason <1923621+2Shirt@users.noreply.github.com> Date: Thu, 23 Nov 2017 14:35:32 -0800 Subject: [PATCH] Updated BIOS activation sections --- .bin/Scripts/activate.py | 19 ++++++++++--------- .bin/Scripts/functions/activation.py | 9 ++------- .bin/Scripts/functions/common.py | 3 +++ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.bin/Scripts/activate.py b/.bin/Scripts/activate.py index ae98b933..059d629a 100644 --- a/.bin/Scripts/activate.py +++ b/.bin/Scripts/activate.py @@ -7,15 +7,9 @@ import sys os.chdir(os.path.dirname(os.path.realpath(__file__))) sys.path.append(os.getcwd()) from functions.activation import * -from functions.common import * init_global_vars() os.system('title {}: Windows Activation Tool'.format(KIT_NAME_FULL)) -def activate_with_bios(): - """Attempt to activate Windows with a key stored in the BIOS.""" - try_and_print(message='BIOS Activation:', - function=activate_windows_with_bios, other_results=other_results) - if __name__ == '__main__': try: stay_awake() @@ -26,6 +20,10 @@ if __name__ == '__main__': print_info('This system is already activated') sleep(5) exit_script() + other_results = { + 'Error': { + 'BIOSKeyNotFoundError': 'BIOS key not found.', + }} # Determine activation method activation_methods = [ @@ -41,15 +39,18 @@ if __name__ == '__main__': selection = menu_select( '{}: Windows Activation Menu'.format(KIT_NAME_FULL), main_entries=activation_methods, action_entries=actions) - + if (selection.isnumeric()): - activation_methods[int(selection)-1]['Function']() + try_and_print( + message = activation_methods[int(selection)-1]['Name'], + function = activation_methods[int(selection)-1]['Function'], + other_results=other_results) break elif selection == 'Q': exit_script() # Done - print_success('Done.') + print_success('\nDone.') pause("Press Enter to exit...") exit_script() except SystemExit: diff --git a/.bin/Scripts/functions/activation.py b/.bin/Scripts/functions/activation.py index 7b401c0b..f54d1dca 100644 --- a/.bin/Scripts/functions/activation.py +++ b/.bin/Scripts/functions/activation.py @@ -3,16 +3,13 @@ import subprocess from borrowed import acpi +from functions.common import * from os import environ # Variables SLMGR = r'{}\System32\slmgr.vbs'.format(environ.get('SYSTEMROOT')) -# Error Classes -class BIOSKeyNotFoundError(Exception): - pass - -def activate_windows_with_bios(): +def activate_with_bios(): """Attempt to activate Windows with a key stored in the BIOS.""" # Code borrowed from https://github.com/aeruder/get_win8key ##################################################### @@ -29,8 +26,6 @@ def activate_windows_with_bios(): # = Microsoft 'software licensing data structure' \ # / 36 + 20 bytes offset from beginning = Win Key bios_key = rawtable[56:len(rawtable)].decode("utf-8") - else: - raise Exception('ACPI table {} not found.'.format(str(table))) if bios_key is None: raise BIOSKeyNotFoundError diff --git a/.bin/Scripts/functions/common.py b/.bin/Scripts/functions/common.py index ff373776..b1002f12 100644 --- a/.bin/Scripts/functions/common.py +++ b/.bin/Scripts/functions/common.py @@ -31,6 +31,9 @@ HKCU = winreg.HKEY_CURRENT_USER HKLM = winreg.HKEY_LOCAL_MACHINE # Error Classes +class BIOSKeyNotFoundError(Exception): + pass + class BinNotFoundError(Exception): pass