Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</td></tr></table>

Expand All @@ -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:
Expand All @@ -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
Expand Down
33 changes: 21 additions & 12 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,45 @@
用于 VMware Workstation 的 macOS Unlocker V3.0
==============================================

***
### <div align="center">请在此处阅读:</div>

Windows用户:请从“版本发布”页面下载工具,该版本已预装了Python环境,可以避免因缺少Python而导致的病毒警告或其他问题。

Linux用户:Linux版本不包含预装的Python环境,请确保您已安装Python 3.0及以上版本。如果出现“不支持Python”之类的错误(但您已安装了Python),请尝试使用以下命令运行脚本:`PYVERSION=python3.7`(前提是您已安装了Python 3.7,否则请尝试使用python3或其他版本)。

***
<table align="center"><tr><td align="center" width="9999">
| 重要提醒:

| 重要的:
| ---
| 请在使用新版本 Unlocker 前卸载旧版本,否则 VMWare 可能会无法使用。
| 在使用新版本Unlocker之前,务必先卸载旧版本。
| 如果未能完成此步骤,VMware可能无法正常运行。

</td></tr></table>

***

### 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

根据所修补的产品,本代码会作出以下修改:

* 修补 vmware-vmx 及其相关组件,以允许 Mac OS 启动。
* 修补 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 未在运行且所有后台的客户机都已关闭。

Expand All @@ -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. 限制
-------
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.0
12 changes: 4 additions & 8 deletions dumpsmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
61 changes: 17 additions & 44 deletions gettools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -123,7 +108,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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
87 changes: 87 additions & 0 deletions lnx-helper-functions.sh
Original file line number Diff line number Diff line change
@@ -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!"
}
31 changes: 13 additions & 18 deletions lnx-install.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Loading