From 9999d0f79b496b44dcdc9891572df4db3c8f20ad Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 27 Sep 2025 00:18:52 +0100 Subject: [PATCH 1/4] Add helper functions for Windows and Linux --- VERSION | 1 + lnx-helper-functions.sh | 87 ++++++++++++++++++++++++++++++++ lnx-install.sh | 31 +++++------- lnx-uninstall.sh | 16 +++--- lnx-update-tools.sh | 35 ++++++------- win-helper-functions.cmd | 104 +++++++++++++++++++++++++++++++++++++++ win-install.cmd | 55 +++++++-------------- win-test-install.cmd | 48 ++++++------------ win-uninstall.cmd | 40 ++++++--------- win-update-tools.cmd | 37 ++++++-------- 10 files changed, 294 insertions(+), 160 deletions(-) create mode 100644 VERSION create mode 100644 lnx-helper-functions.sh create mode 100644 win-helper-functions.cmd diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..fd2a018 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +3.1.0 diff --git a/lnx-helper-functions.sh b/lnx-helper-functions.sh new file mode 100644 index 0000000..1e3b3e9 --- /dev/null +++ b/lnx-helper-functions.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# Get application version from git tag or VERSION file +get_app_version() { + if [ -d .git ]; then + git describe --tags --abbrev=0 2>/dev/null || echo "unknown" + elif [ -f VERSION ]; then + cat VERSION + else + echo "unknown" + fi +} + +# Restrict PATH to unmodified system commands +restrict_path() { + export PATH=/bin:/sbin:/usr/bin:/usr/sbin +} + +# Require root privileges +require_root() { + if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" 1>&2 + exit 1 + fi +} + +# Detect VMware installation and version +detect_vmware() { + VMWARE_PATH="" + + if [ -d "/usr/lib/vmware/" ]; then + VMWARE_PATH="/usr/lib/vmware/" + fi + + if [ -z "$VMWARE_PATH" ]; then + echo "VMware is not installed" + return 1 + fi + + # Try to get product version if available + if [ -f "/etc/vmware/config" ]; then + PRODUCT_VERSION=$(grep -m1 -i "product.version" /etc/vmware/config | awk -F'"' '{print $2}') + elif command -v vmware &>/dev/null; then + PRODUCT_VERSION=$(vmware -v 2>/dev/null) + else + PRODUCT_VERSION="unknown" + fi + + echo "VMware product version: $PRODUCT_VERSION" +} + +# Check Python 3 interpreter +check_python3() { + PYVERSION="${PYVERSION:-python3}" + + if ! command -v "$PYVERSION" &> /dev/null; then + echo "Python 3 interpreter '$PYVERSION' not found." + exit 1 + fi + + # Optional: ensure version >= 3 + VERSION=$($PYVERSION -c 'import sys; print(sys.version_info[0])') + if [ "$VERSION" -lt 3 ]; then + echo "Python 3 is required. '$PYVERSION' is Python $VERSION." + exit 1 + fi + + echo Python version installed: $($PYVERSION --version) +} + +# Function to get VMware Tools +get_vmware_tools() { + echo "Getting VMware Tools..." + + # Run the Python script + $PYVERSION gettools.py || { + echo "Failed to run gettools.py" + exit 1 + } + + if [ -d "${VMWARE_PATH}isoimages/" ]; then + cp ./tools/darwin*.* "${VMWARE_PATH}isoimages/" + echo "Copied VMware Tools ISOs." + fi + + echo "Finished!" +} diff --git a/lnx-install.sh b/lnx-install.sh index 41b784e..5e67577 100755 --- a/lnx-install.sh +++ b/lnx-install.sh @@ -1,19 +1,22 @@ #!/bin/bash +# Source the helper +source lnx-helper-functions.sh + set -e -echo "Unlocker 3.0.4 for VMware Workstation" +echo "Unlocker $(get_app_version) for VMware Workstation" echo "=====================================" echo "(c) Dave Parsons 2011-18" # Ensure we only use unmodified commands -export PATH=/bin:/sbin:/usr/bin:/usr/sbin +restrict_path # Make sure only root can run our script -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi +require_root + +# Detect VMware installation +detect_vmware echo Creating backup-linux folder... rm -rf ./backup-linux @@ -27,19 +30,11 @@ elif [ -d /usr/lib/vmware/lib/libvmwarebase.so/ ]; then cp -v /usr/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so ./backup-linux/ fi -if [ -z "$PYVERSION" ]; then PYVERSION=""; fi -if command -v python3 &> /dev/null; then - PYVERSION="python3" -else - echo "Python 3 could not be found." - exit -fi +# Detect Python installation +check_python3 echo Patching... $PYVERSION ./unlocker.py -echo Getting VMware Tools... -$PYVERSION gettools.py -cp ./tools/darwin*.* /usr/lib/vmware/isoimages/ - -echo Finished! +# Get VMware Tools +get_vmware_tools \ No newline at end of file diff --git a/lnx-uninstall.sh b/lnx-uninstall.sh index 52824d8..7ecb985 100755 --- a/lnx-uninstall.sh +++ b/lnx-uninstall.sh @@ -1,18 +1,22 @@ #!/bin/bash + +# Source the helper +source lnx-helper-functions.sh + set -e -echo "Unlocker 3.0.4 for VMware Workstation" +echo "Unlocker $(get_app_version) for VMware Workstation" echo "=====================================" echo "(c) Dave Parsons 2011-18" # Ensure we only use unmodified commands -export PATH=/bin:/sbin:/usr/bin:/usr/sbin +restrict_path # Make sure only root can run our script -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi +require_root + +# Detect VMware installation +detect_vmware echo Restoring files... cp -v ./backup-linux/vmware-vmx /usr/lib/vmware/bin/ diff --git a/lnx-update-tools.sh b/lnx-update-tools.sh index 167883a..c9de10b 100755 --- a/lnx-update-tools.sh +++ b/lnx-update-tools.sh @@ -1,30 +1,25 @@ #!/bin/bash +# Source the helper +source lnx-helper-functions.sh + set -e -echo "Get macOS VMware Tools 3.0.4" +echo "Get macOS VMware Tools $(get_app_version)" echo "===============================" echo "(c) Dave Parsons 2015-18" # Ensure we only use unmodified commands -export PATH=/bin:/sbin:/usr/bin:/usr/sbin +restrict_path # Make sure only root can run our script -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root" 1>&2 - exit 1 -fi - -if [ -z "$PYVERSION" ]; then PYVERSION=""; fi -if command -v python3 &> /dev/null; then - PYVERSION="python3" -else - echo "Python 3 could not be found." - exit -fi - -echo Getting VMware Tools... -$PYVERSION gettools.py -cp ./tools/darwin*.* /usr/lib/vmware/isoimages/ - -echo Finished! +require_root + +# Detect VMware installation +detect_vmware + +# Detect Python installation +check_python3 + +# Get VMware Tools +get_vmware_tools \ No newline at end of file diff --git a/win-helper-functions.cmd b/win-helper-functions.cmd new file mode 100644 index 0000000..2581af2 --- /dev/null +++ b/win-helper-functions.cmd @@ -0,0 +1,104 @@ +@echo off +setlocal ENABLEEXTENSIONS + +:: Jump to the specified label if provided +if not "%~1"=="" ( + for %%L in (%~1) do goto :%%L +) + +goto :EOF + +:: --- Function: Get App Version --- +:get_app_version +set "APPVERSION=unknown" +if exist VERSION ( + set /p APPVERSION=NUL 2>&1 +if %errorlevel% equ 0 ( + set "IS_ADMIN=1" +) +endlocal & set "IS_ADMIN=%IS_ADMIN%" +goto :EOF + +:: --- Function: Detect VMware --- +:detect_vmware +set "INSTALLPATH=" +set KeyName="HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" +for /f "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v InstallPath 2^>nul') do set "INSTALLPATH=%%B" +if not defined INSTALLPATH ( + set "VMWARE_INSTALLED=0" + echo VMware is not installed +) else ( + set "VMWARE_INSTALLED=1" + echo VMware is installed at: "%InstallPath%" +) +for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v ProductVersion') do set ProductVersion=%%B +echo VMware product version: %ProductVersion% + +endlocal & set "INSTALLPATH=%INSTALLPATH%" & set "VMWARE_INSTALLED=%VMWARE_INSTALLED%" +goto :EOF + +:: --- Function: Get VMware Tools --- +:get_vmware_tools +echo Getting VMware Tools... +if not exist "gettools.exe" ( + echo ERROR: gettools.exe not found! + endlocal + exit /b 1 +) +gettools.exe +if errorlevel 1 ( + echo ERROR: gettools.exe failed with errorlevel=%errorlevel% + endlocal + exit /b 1 +) +if defined INSTALLPATH ( + xcopy /F /Y .\tools\darwin*.* "%INSTALLPATH%" + if errorlevel 1 ( + echo ERROR: xcopy failed with errorlevel=%errorlevel% + endlocal + exit /b 1 + ) +) +echo Finished! + +endlocal +goto :EOF + +:: --- Function: Stop VMware services --- +:stop_vmware_services +echo Stopping VMware services... +net stop vmware-view-usbd >NUL 2>&1 +net stop VMwareHostd >NUL 2>&1 +net stop VMAuthdService >NUL 2>&1 +net stop VMUSBArbService >NUL 2>&1 +taskkill /F /IM vmware-tray.exe >NUL 2>&1 +goto :EOF + +:: --- Function: Start VMware services --- +:start_vmware_services +echo Starting VMware services... +net start VMUSBArbService >NUL 2>&1 +net start VMAuthdService >NUL 2>&1 +net start VMwareHostd >NUL 2>&1 +net start vmware-view-usbd >NUL 2>&1 +goto :EOF + +:: --- Function: Backup VMware files --- +:backup_vmware_files +echo Backing up files... +rd /s /q .\backup-windows > NUL 2>&1 +mkdir .\backup-windows +mkdir .\backup-windows\x64 +xcopy /F /Y "%InstallPath%x64\vmware-vmx.exe" .\backup-windows\x64 +xcopy /F /Y "%InstallPath%x64\vmware-vmx-debug.exe" .\backup-windows\x64 +xcopy /F /Y "%InstallPath%x64\vmware-vmx-stats.exe" .\backup-windows\x64 +xcopy /F /Y "%InstallPath%vmwarebase.dll" .\backup-windows\ +goto :EOF diff --git a/win-install.cmd b/win-install.cmd index 2d5f4fc..5177211 100644 --- a/win-install.cmd +++ b/win-install.cmd @@ -1,67 +1,50 @@ @echo off setlocal ENABLEEXTENSIONS echo. -echo Unlocker 3.0.4 for VMware Workstation +rem --- Get app version --- +call win-helper-functions.cmd get_app_version +echo Unlocker %APPVERSION% for VMware Workstation echo ===================================== echo (c) Dave Parsons 2011-18 echo. echo Set encoding parameters... chcp 850 -net session >NUL 2>&1 -if %errorlevel% neq 0 ( - echo Administrator privileges required! - exit /b +rem --- Require admin --- +call win-helper-functions.cmd check_admin +if "%IS_ADMIN%"=="0" ( + echo Administrator privileges required! + exit /b 1 ) echo. -set KeyName="HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" -:: delims is a TAB followed by a space -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v InstallPath') do set InstallPath=%%B -if "%InstallPath%" == "" ( - echo VMware is not installed +rem --- Detect VMware installation --- +call win-helper-functions.cmd detect_vmware +if "%VMWARE_INSTALLED%" == "0" ( exit /b -) else ( - echo VMware is installed at: "%InstallPath%" ) -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v ProductVersion') do set ProductVersion=%%B -echo VMware product version: %ProductVersion% pushd %~dp0 echo. -echo Stopping VMware services... -net stop vmware-view-usbd > NUL 2>&1 -net stop VMwareHostd > NUL 2>&1 -net stop VMAuthdService > NUL 2>&1 -net stop VMUSBArbService > NUL 2>&1 -taskkill /F /IM vmware-tray.exe > NUL 2>&1 +rem --- Stop VMware services --- +call win-helper-functions.cmd stop_vmware_services echo. -echo Backing up files... -rd /s /q .\backup-windows > NUL 2>&1 -mkdir .\backup-windows -mkdir .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx-debug.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx-stats.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%vmwarebase.dll" .\backup-windows\ +rem --- Backup VMware Files --- +call win-helper-functions.cmd backup_vmware_files echo. echo Patching... unlocker.exe echo. -echo Getting VMware Tools... -gettools.exe -xcopy /F /Y .\tools\darwin*.* "%InstallPath%" +rem --- Download and copy tools --- +call win-helper-functions.cmd get_vmware_tools echo. -echo Starting VMware services... -net start VMUSBArbService > NUL 2>&1 -net start VMAuthdService > NUL 2>&1 -net start VMwareHostd > NUL 2>&1 -net start vmware-view-usbd > NUL 2>&1 +rem --- Start VMware services --- +call win-helper-functions.cmd start_vmware_services popd echo. diff --git a/win-test-install.cmd b/win-test-install.cmd index f18b2a6..6a17e35 100644 --- a/win-test-install.cmd +++ b/win-test-install.cmd @@ -1,51 +1,38 @@ @echo off setlocal ENABLEEXTENSIONS echo. -echo Unlocker 3.0.4 for VMware Workstation +rem --- Get app version --- +call win-helper-functions.cmd get_app_version +echo Unlocker %APPVERSION% for VMware Workstation echo ===================================== echo (c) Dave Parsons 2011-18 echo. echo Set encoding parameters... chcp 850 -net session >NUL 2>&1 -if %errorlevel% neq 0 ( +rem --- Require admin --- +call win-helper-functions.cmd check_admin +if "%IS_ADMIN%"=="0" ( echo Administrator privileges required! - exit /b + exit /b 1 ) echo. -set KeyName="HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" -:: delims is a TAB followed by a space -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v InstallPath') do set InstallPath=%%B -if "%InstallPath%" == "" ( - echo VMware is not installed +rem --- Detect VMware installation --- +call win-helper-functions.cmd detect_vmware +if "%VMWARE_INSTALLED%" == "0" ( exit /b -) else ( - echo VMware is installed at: "%InstallPath%" ) -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v ProductVersion') do set ProductVersion=%%B -echo VMware product version: %ProductVersion% pushd %~dp0 echo. -echo Stopping VMware services... -net stop vmware-view-usbd > NUL 2>&1 -net stop VMwareHostd > NUL 2>&1 -net stop VMAuthdService > NUL 2>&1 -net stop VMUSBArbService > NUL 2>&1 -taskkill /F /IM vmware-tray.exe > NUL 2>&1 +rem --- Stop VMware services --- +call win-helper-functions.cmd stop_vmware_services echo. -echo Backing up files... -rd /s /q .\backup-windows > NUL 2>&1 -mkdir .\backup-windows -mkdir .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx-debug.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%x64\vmware-vmx-stats.exe" .\backup-windows\x64 -xcopy /F /Y "%InstallPath%vmwarebase.dll" .\backup-windows\ +rem --- Backup VMware Files --- +call win-helper-functions.cmd backup_vmware_files echo. echo Patching... @@ -57,11 +44,8 @@ python gettools.py xcopy /F /Y .\tools\darwin*.* "%InstallPath%" echo. -echo Starting VMware services... -net start VMUSBArbService > NUL 2>&1 -net start VMAuthdService > NUL 2>&1 -net start VMwareHostd > NUL 2>&1 -net start vmware-view-usbd > NUL 2>&1 +rem --- Start VMware services --- +call win-helper-functions.cmd start_vmware_services popd echo. diff --git a/win-uninstall.cmd b/win-uninstall.cmd index 034fb77..60def86 100644 --- a/win-uninstall.cmd +++ b/win-uninstall.cmd @@ -1,38 +1,31 @@ @echo off setlocal ENABLEEXTENSIONS echo. -echo Unlocker 3.0.4 for VMware Workstation +rem --- Get app version --- +call win-helper-functions.cmd get_app_version +echo Unlocker %APPVERSION% for VMware Workstation echo ===================================== echo (c) Dave Parsons 2011-18 -net session >NUL 2>&1 -if %errorlevel% neq 0 ( - echo Administrator privileges required! - exit +rem --- Require admin --- +call win-helper-functions.cmd check_admin +if "%IS_ADMIN%"=="0" ( + echo Administrator privileges required! + exit /b 1 ) echo. -set KeyName="HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" -:: delims is a TAB followed by a space -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v InstallPath') do set InstallPath=%%B -if "%InstallPath%" == "" ( - echo VMware is not installed +rem --- Detect VMware installation --- +call win-helper-functions.cmd detect_vmware +if "%VMWARE_INSTALLED%" == "0" ( exit /b -) else ( - echo VMware is installed at: "%InstallPath%" ) -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v ProductVersion') do set ProductVersion=%%B -echo VMware product version: %ProductVersion% pushd %~dp0 echo. -echo Stopping VMware services... -net stop vmware-view-usbd > NUL 2>&1 -net stop VMwareHostd > NUL 2>&1 -net stop VMAuthdService > NUL 2>&1 -net stop VMUSBArbService > NUL 2>&1 -taskkill /F /IM vmware-tray.exe > NUL 2>&1 +rem --- Stop VMware services --- +call win-helper-functions.cmd stop_vmware_services echo. echo Restoring files... @@ -46,11 +39,8 @@ rd /s /q .\backup-windows > NUL 2>&1 rd /s /q .\tools > NUL 2>&1 echo. -echo Starting VMware services... -net start VMUSBArbService > NUL 2>&1 -net start VMAuthdService > NUL 2>&1 -net start VMwareHostd > NUL 2>&1 -net start vmware-view-usbd > NUL 2>&1 +rem --- Start VMware services --- +call win-helper-functions.cmd start_vmware_services popd echo. diff --git a/win-update-tools.cmd b/win-update-tools.cmd index 6a6d31e..404ae05 100644 --- a/win-update-tools.cmd +++ b/win-update-tools.cmd @@ -1,34 +1,25 @@ @echo off setlocal ENABLEEXTENSIONS -echo Get macOS VMware Tools 3.0.4 + +rem --- Get app version --- +call win-helper-functions.cmd get_app_version +echo Get macOS VMware Tools %APPVERSION% echo =============================== echo (c) Dave Parsons 2011-18 - -net session >NUL 2>&1 -if %errorlevel% neq 0 ( - echo Administrator privileges required! - exit +echo. +rem --- Require admin --- +call win-helper-functions.cmd check_admin +if "%IS_ADMIN%"=="0" ( + echo Administrator privileges required! + exit /b 1 ) pushd %~dp0 -set KeyName="HKLM\SOFTWARE\Wow6432Node\VMware, Inc.\VMware Player" -:: delims is a TAB followed by a space -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v InstallPath') do set InstallPath=%%B -if "%InstallPath%" == "" ( - echo VMware is not installed -) else ( - echo VMware is installed at: "%InstallPath%" -) -for /F "tokens=2* delims= " %%A in ('REG QUERY %KeyName% /v ProductVersion') do set ProductVersion=%%B -echo VMware product version: %ProductVersion% +rem --- Detect VMware installation --- +call win-helper-functions.cmd detect_vmware -echo Getting VMware Tools... -gettools.exe -if NOT "%InstallPath%" == "" ( - xcopy /F /Y .\tools\darwin*.* "%InstallPath%" -) +rem --- Download and copy tools --- +call win-helper-functions.cmd get_vmware_tools popd - -echo Finished! From 7c0f19924ec28a7be678446a653366e1113dc137 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 27 Sep 2025 00:25:16 +0100 Subject: [PATCH 2/4] Print the page url --- gettools.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gettools.py b/gettools.py index 664ea76..09fe10f 100644 --- a/gettools.py +++ b/gettools.py @@ -123,7 +123,7 @@ def GetResponseFromUrl(url): response = urlopen( req ) return response except: - print('Couldn\'t read page') + print("Couldn't read page: " + url) return False # Function to download a file From 69ee79adaf4ea8584316aa04b4a8f06d240eb2b2 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 27 Sep 2025 17:10:46 +0100 Subject: [PATCH 3/4] Remove python2 support --- dumpsmc.py | 12 ++++------ gettools.py | 59 +++++++++++++----------------------------------- test-unlocker.py | 6 +++++ unlocker.py | 17 ++++---------- 4 files changed, 31 insertions(+), 63 deletions(-) diff --git a/dumpsmc.py b/dumpsmc.py index cce5ca2..aa5e657 100755 --- a/dumpsmc.py +++ b/dumpsmc.py @@ -45,18 +45,14 @@ import struct import sys -if sys.version_info < (2, 7): - sys.stderr.write('You need Python 2.7 or later\n') +# Check minimal Python version is 3 +if sys.version_info < (3, 0): + sys.stderr.write('You need Python 3 or later\n') sys.exit(1) def bytetohex(data): - if sys.version_info > (3, 0): - # Python 3 code in this block - return "".join("{:02X} ".format(c) for c in data) - else: - # Python 2 code in this block - return "".join("{:02X} ".format(ord(c)) for c in data) + return "".join("{:02X} ".format(c) for c in data) def printkey(i, offset, smc_key, smc_data): diff --git a/gettools.py b/gettools.py index 09fe10f..5c03b39 100644 --- a/gettools.py +++ b/gettools.py @@ -31,21 +31,17 @@ import zipfile import time -try: - # For Python 3.0 and later - import urllib - # noinspection PyCompatibility - from urllib.request import urlopen, Request, urlretrieve, install_opener - # noinspection PyCompatibility - from html.parser import HTMLParser -except ImportError: - # Fall back to Python 2 - # noinspection PyCompatibility - import urllib2 - # noinspection PyCompatibility - from urllib2 import urlopen, Request - # noinspection PyCompatibility - from HTMLParser import HTMLParser +# For Python 3.0 and later +import urllib +# noinspection PyCompatibility +from urllib.request import urlopen, Request, urlretrieve, install_opener +# noinspection PyCompatibility +from html.parser import HTMLParser + +# Check minimal Python version is 3 +if sys.version_info < (3, 0): + sys.stderr.write('You need Python 3 or later\n') + sys.exit(1) # Parse the Fusion directory page @@ -66,13 +62,7 @@ def handle_data(self, data): def clean(self): self.HTMLDATA = [] -if sys.version_info > (3, 0): -# Python 3 code in this block pass -else: - # Python 2 code in this block - class MyURLopener(urllib.FancyURLopener): - http_error_default = urllib.URLopener.http_error_default def convertpath(path): # OS path separator replacement function @@ -99,12 +89,7 @@ def CheckToolsFilesExists(dest): if filesFound: while True: # Ask if the user want to download again - if sys.version_info > (3, 0): - # Python 3 code in this block - userResponse = input(askMsg) - else: - # Python 2 code in this block - userResponse = raw_input(askMsg) + userResponse = input(askMsg) if str(userResponse).upper() == 'Y': return False @@ -185,17 +170,10 @@ def DownloadAndExtractTarFile(url, dest): print('Retrieving Darwin tools from: ' + urlpost15) try: # Try to get tools from packages folder - if sys.version_info > (3, 0): - # Python 3 code in this block - opener = urllib.request.build_opener() - opener.addheaders = [('User-Agent','Magic Browser')] - install_opener(opener) - urlretrieve(urlpost15, convertpath(dest + '/tools/' + tarName), reporthook) - else: - # Python 2 code in this block - opener = MyURLopener() - opener.Version = [('User-Agent','Magic Browser')] - (f,headers)=opener.retrieve(urlpost15, convertpath(dest + '/tools/' + tarName), reporthook) + opener = urllib.request.build_opener() + opener.addheaders = [('User-Agent','Magic Browser')] + install_opener(opener) + urlretrieve(urlpost15, convertpath(dest + '/tools/' + tarName), reporthook) except: print('Couldn\'t find tools in ' + url) return False @@ -239,11 +217,6 @@ def DownloadAndExtractTarFile(url, dest): os.remove(convertpath(dest + '/tools/' + zipName)) def main(): - # Check minimal Python version is 2.7 - if sys.version_info < (2, 7): - sys.stderr.write('You need Python 2.7 or later\n') - sys.exit(1) - dest = os.getcwd() # Try local file check diff --git a/test-unlocker.py b/test-unlocker.py index d6d910b..55278f7 100644 --- a/test-unlocker.py +++ b/test-unlocker.py @@ -1,8 +1,14 @@ from __future__ import print_function +import sys import shutil import unlocker +# Check minimal Python version is 3 +if sys.version_info < (3, 0): + sys.stderr.write('You need Python 3 or later\n') + sys.exit(1) + def main(): # Test Windows patching diff --git a/unlocker.py b/unlocker.py index 25f1332..35bc7d8 100644 --- a/unlocker.py +++ b/unlocker.py @@ -48,28 +48,21 @@ import struct import sys -if sys.version_info < (2, 7): - sys.stderr.write('You need Python 2.7 or later\n') +# Check minimal Python version is 3 +if sys.version_info < (3, 0): + sys.stderr.write('You need Python 3 or later\n') sys.exit(1) # Setup imports depending on whether IronPython or CPython if sys.platform == 'win32' \ or sys.platform == 'cli': # noinspection PyUnresolvedReferences - if sys.version_info > (3, 0): - from winreg import * - else: - from _winreg import * + from winreg import * def bytetohex(data): - if sys.version_info > (3, 0): - # Python 3 code in this block - return "".join("{:02X} ".format(c) for c in data) - else: - # Python 2 code in this block - return "".join("{:02X} ".format(ord(c)) for c in data) + return "".join("{:02X} ".format(c) for c in data) def joinpath(folder, filename): From 2b453f3216f82c68aa58e2e967eb02a432b3fa89 Mon Sep 17 00:00:00 2001 From: BDisp Date: Sat, 27 Sep 2025 17:19:55 +0100 Subject: [PATCH 4/4] Tidying up readme files --- README.md | 12 ++++++------ README.zh-CN.md | 33 +++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0ed3b73..bac2e76 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ LINUX USERS: No bundled python for you, but make sure you have python 3.0+ insta | IMPORTANT: | --- -| Always uninstall the previous version of the Unlocker before using a new -| version. Failure to do this could render VMware unusable. +| Always uninstall the previous version of the Unlocker before using a new version. +| Failure to do this could render VMware unusable. @@ -23,14 +23,14 @@ LINUX USERS: No bundled python for you, but make sure you have python 3.0+ insta ### 1. Introduction --------------- -Unlocker 3 is designed for VMware Workstation 11-16 and Player 7-16. +Unlocker 3 is designed for VMware Workstation 11-17 and Player 7-17. If you are using an earlier product please continue using Unlocker 1. Version 3 has been tested against: -* Workstation 11/12/14/15/16 on Windows and Linux -* Workstation Player 7/12/14/15/16 on Windows and Linux +* Workstation 11/12/14/15/16/17 on Windows and Linux +* Workstation Player 7/12/14/15/16/17 on Windows and Linux The patch code carries out the following modifications dependent on the product being patched: @@ -39,7 +39,7 @@ being patched: * Fix vmwarebase .dll or .so to allow Apple to be selected during VM creation * Download a copy of the latest VMware Tools for macOS -Note that not all products recognise the darwin.iso via install tools menu item. +Note that not all products recognize the darwin.iso via install tools menu item. You will have to manually mount the darwin.iso for example on Workstation 11 and Player 7. In all cases make sure VMware is not running, and any background guests have diff --git a/README.zh-CN.md b/README.zh-CN.md index 545db4a..31ac4db 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -1,25 +1,36 @@ 用于 VMware Workstation 的 macOS Unlocker V3.0 ============================================== +*** +###
请在此处阅读:
+ +Windows用户:请从“版本发布”页面下载工具,该版本已预装了Python环境,可以避免因缺少Python而导致的病毒警告或其他问题。 + +Linux用户:Linux版本不包含预装的Python环境,请确保您已安装Python 3.0及以上版本。如果出现“不支持Python”之类的错误(但您已安装了Python),请尝试使用以下命令运行脚本:`PYVERSION=python3.7`(前提是您已安装了Python 3.7,否则请尝试使用python3或其他版本)。 + +***
- -| 重要提醒: + +| 重要的: | --- -| 请在使用新版本 Unlocker 前卸载旧版本,否则 VMWare 可能会无法使用。 +| 在使用新版本Unlocker之前,务必先卸载旧版本。 +| 如果未能完成此步骤,VMware可能无法正常运行。
+*** + ### 1. 介绍 ------- -Unlocker 3 适用于 VMware Workstation 11-16 以及 Player 7-16。 +Unlocker 3 适用于 VMware Workstation 11-17 以及 Player 7-17。 如果您正使用早期版本的 VMWare,请继续使用 Unlocker 1。 Unlocker 3 已对以下情况进行了测试: -* 在 Windows 或 Linux 上的 Workstation 11/12/14/15/16 -* 在 Windows 或 Linux 上的 Workstation Player 7/12/14/15/16 +* 在 Windows 或 Linux 上的 Workstation 11/12/14/15/16/17 +* 在 Windows 或 Linux 上的 Workstation Player 7/12/14/15/16/17 根据所修补的产品,本代码会作出以下修改: @@ -27,8 +38,8 @@ Unlocker 3 已对以下情况进行了测试: * 修补 vmwarebase .dll 或 .so,以允许创建虚拟机过程中选择 Apple 作为客户机操作系统。 * 下载一份最新的用于 Mac OS 的 VMWare Tools 副本。 -请注意,并非所有的 VMWare 版本都能通过“安装 VMWare Tools”菜单项识别 darwin.iso。 -例如,在 Workstation 11、Player 7上,您需要手动挂载 darwin.iso。 +请注意,并非所有产品都能通过安装工具菜单项识别 darwin.iso 文件。 +例如,在Workstation 11和Player 7中,您需要手动挂载darwin.iso文件。 无论何时都请确保 VMware 未在运行且所有后台的客户机都已关闭。 @@ -37,11 +48,9 @@ Unlocker 3 已对以下情况进行了测试: ### 2. 先决条件 ----------- -本代码需要 Python 2.7 以正常工作。大多数 Linux 发行版都附带一个兼容的 Python 解释器, -因此本代码应可在不需要任何额外软件的情况下工作。 +该程序需要Python 3.0或更高版本才能运行。大多数Linux发行版都预装了兼容的Python解释器,因此无需额外安装任何软件即可运行。 -Windows 版本的 Unlocker 有一个使用 PyInstaller 的打包版 Python 脚本,因此无需在计算机 -上安装 Python。 +Windows Unlocker使用PyInstaller将Python脚本打包,因此无需安装Python即可运行。 ### 3. 限制 -------