diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..11b3963 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: Build Windows + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: 'pip' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -r requirements.txt + + - name: Build with PyInstaller + run: | + pyinstaller spec/Windows.spec + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: USBToolBox-Windows + path: dist/Windows.exe diff --git a/Scripts/shared.py b/Scripts/shared.py index 6376417..18ed0be 100644 --- a/Scripts/shared.py +++ b/Scripts/shared.py @@ -7,7 +7,7 @@ from Scripts._build import BUILD -VERSION = "0.2" +VERSION = "0.3.1" if getattr(sys, "frozen", False) and hasattr(sys, "_MEIPASS"): current_dir = Path(sys.executable).parent diff --git a/base.py b/base.py index 65b6312..2d84130 100644 --- a/base.py +++ b/base.py @@ -532,14 +532,25 @@ def build_kext(self): ]["_items"][0]["machine_model"] else: model_menu = utils.TUIOnlyPrint( - "Enter Model Identifier", - "Enter the model identifier: ", + "Enter Model Identifier or config.plist", + "Enter the model identifier or drag config.plist here: ", [ "You are seeing this as you have selected to use native classes. Model identifier autodetection is unavailable as you are not on macOS.", - "Please enter the model identifier of the target system below. You can find it in System Information or with 'system_profiler -detailLevel mini SPHardwareDataType'.", + "Please enter the model identifier of the target system, or drag your config.plist here to auto-detect it.", ], ).start() - model_identifier = model_menu.strip() + user_input = model_menu.strip().strip('"').strip("'") + + if Path(user_input).is_file() and user_input.lower().endswith(".plist"): + try: + plist_data = plistlib.load(open(user_input, "rb")) + model_identifier = plist_data.get("PlatformInfo", {}).get("Generic", {}).get("SystemProductName", "") + if not model_identifier: + model_identifier = input("SystemProductName not found. Enter manually: ").strip() + except Exception: + model_identifier = input("Failed to parse config.plist. Enter manually: ").strip() + else: + model_identifier = user_input ignore = response == "I" @@ -607,7 +618,9 @@ def build_kext(self): personality["IOProviderMergeProperties"]["ports"][port_name] = { "port": binascii.a2b_hex(hexswap(hex(port["index"])[2:].zfill(8))), + "usb-port-number": binascii.a2b_hex(hexswap(hex(port["index"])[2:].zfill(8))), "UsbConnector": port["type"] or port["guessed"], + "usb-port-type": port["type"] or port["guessed"], } if self.settings["add_comments_to_map"] and port["comment"]: