├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── Unlocker.exe.manifest ├── include ├── archive.h ├── buildsparser.h ├── colors.h ├── config.h ├── debug.h ├── filesystem.hpp ├── installinfo.h ├── logging │ ├── combinedlogstrategy.h │ ├── logstrategy.h │ ├── statusbarlogstrategy.h │ ├── streamlogstrategy.h │ └── terminallogstrategy.h ├── network.h ├── patcher.h ├── patchversioner.h ├── tar.h ├── toolsdownloader.h ├── unlocker_lnx.h ├── unlocker_win.h ├── versionparser.h ├── win32 │ ├── controls │ │ ├── button.h │ │ ├── checkbox.h │ │ ├── control.h │ │ ├── editbox.h │ │ ├── groupbox.h │ │ ├── label.h │ │ ├── progress.h │ │ ├── statusbar.h │ │ └── window.h │ ├── downloadtoolstask.h │ ├── events │ │ └── events.h │ ├── mainwindow.h │ ├── patchertask.h │ ├── patchresult.h │ ├── resources.h │ ├── task.h │ └── unpatchertask.h ├── winservices.h └── ziparchive.h ├── modules └── FindLibZip.cmake ├── src ├── archive.cpp ├── buildsparser.cpp ├── debug.cpp ├── installinfo.cpp ├── logging │ ├── combinedlogstrategy.cpp │ ├── logstrategy.cpp │ ├── statusbarlogstrategy.cpp │ ├── streamlogstrategy.cpp │ └── terminallogstrategy.cpp ├── main.cpp ├── network.cpp ├── patcher.cpp ├── patchversioner.cpp ├── tar.cpp ├── toolsdownloader.cpp ├── unlocker_lnx.cpp ├── unlocker_win.cpp ├── versionparser.cpp ├── win32 │ ├── controls │ │ ├── button.cpp │ │ ├── checkbox.cpp │ │ ├── control.cpp │ │ ├── editbox.cpp │ │ ├── groupbox.cpp │ │ ├── label.cpp │ │ ├── progress.cpp │ │ ├── statusbar.cpp │ │ └── window.cpp │ ├── downloadtoolstask.cpp │ ├── mainwindow.cpp │ ├── patchertask.cpp │ └── unpatchertask.cpp ├── winservices.cpp └── ziparchive.cpp └── tests ├── test.h ├── test_patch.cpp ├── test_tar.cpp └── test_zip.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /.vs 2 | /exe 3 | /out 4 | CMakeSettings.json 5 | /testing 6 | /LIBS 7 | /debug.log 8 | /test.tar 9 | /test.zip 10 | /testtar 11 | /tools 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) 2 | project (Unlocker) 3 | 4 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/modules) 5 | 6 | SET(UNLOCKER_STATIC_LIBS_WIN ON CACHE BOOL "Links statically") # Set to OFF for dynamic linking 7 | 8 | IF (MSVC) 9 | # prevent default manifest from being linked 10 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") 11 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO") 12 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") 13 | ENDIF(MSVC) 14 | 15 | find_package(ZLIB REQUIRED) 16 | 17 | if(ZLIB_FOUND) 18 | message (STATUS "ZLib found, version ${ZLIB_VERSION_STRING}") 19 | endif() 20 | 21 | 22 | find_package(CURL REQUIRED) 23 | 24 | if(CURL_FOUND) 25 | message (STATUS "Curl found, version ${CURL_VERSION_STRING}") 26 | endif() 27 | 28 | find_package(LibZip REQUIRED) 29 | 30 | include_directories(${ZLIB_INCLUDE_DIRS}) 31 | include_directories(${CURL_INCLUDE_DIRS}) 32 | include_directories(${LIBZIP_INCLUDE_DIRS}) 33 | 34 | if(LIBZIP_FOUND) 35 | message (STATUS "LibZip found") 36 | endif() 37 | 38 | # main include files 39 | include_directories ("${PROJECT_SOURCE_DIR}/include") 40 | 41 | # main source files 42 | set (SOURCE_FILES / 43 | src/versionparser.cpp / 44 | src/buildsparser.cpp / 45 | src/archive.cpp / 46 | src/network.cpp / 47 | src/debug.cpp / 48 | src/installinfo.cpp / 49 | src/patcher.cpp / 50 | src/tar.cpp / 51 | src/main.cpp / 52 | src/ziparchive.cpp / 53 | src/toolsdownloader.cpp / 54 | src/logging/combinedlogstrategy.cpp / 55 | src/logging/terminallogstrategy.cpp / 56 | src/logging/streamlogstrategy.cpp / 57 | src/logging/logstrategy.cpp / 58 | src/patchversioner.cpp / 59 | ) 60 | 61 | if(WIN32) 62 | set (SOURCE_FILES ${SOURCE_FILES} / 63 | src/unlocker_win.cpp / 64 | src/winservices.cpp / 65 | src/win32/mainwindow.cpp / 66 | src/win32/controls/button.cpp / 67 | src/win32/controls/editbox.cpp / 68 | src/win32/controls/window.cpp / 69 | src/win32/controls/control.cpp / 70 | src/win32/controls/label.cpp / 71 | src/win32/controls/progress.cpp / 72 | src/win32/controls/groupbox.cpp / 73 | src/win32/controls/checkbox.cpp / 74 | src/win32/controls/statusbar.cpp / 75 | src/win32/patchertask.cpp / 76 | src/win32/unpatchertask.cpp / 77 | src/win32/downloadtoolstask.cpp / 78 | src/logging/statusbarlogstrategy.cpp / 79 | ) 80 | else() 81 | set (SOURCE_FILES ${SOURCE_FILES} / 82 | src/unlocker_lnx.cpp / 83 | ) 84 | endif() 85 | 86 | IF (MSVC) 87 | IF (UNLOCKER_STATIC_LIBS_WIN) 88 | # Preprocessor definitions needed to avoid name mangling when statically importing libs on MSVC compiler 89 | # Name mangling is needed if libraries are built dynamically with MSVC 90 | # Should not be an issue with other compilers 91 | add_compile_definitions( "CURL_STATICLIB" ) 92 | ENDIF() 93 | ENDIF (MSVC) 94 | 95 | if(WIN32) 96 | add_executable(Unlocker WIN32 ${SOURCE_FILES}) 97 | else() 98 | add_executable(Unlocker ${SOURCE_FILES}) 99 | endif() 100 | 101 | # Support skipping file offsets when tar contains files larger than ~2 Gig 102 | target_compile_definitions(Unlocker PUBLIC _FILE_OFFSET_BITS=64) 103 | 104 | set_target_properties(Unlocker PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON) 105 | 106 | target_link_libraries (Unlocker ${ZLIB_LIBRARIES}) 107 | target_link_libraries (Unlocker ${CURL_LIBRARIES}) 108 | target_link_libraries (Unlocker ${LIBZIP_LIBRARY}) 109 | 110 | if(WIN32) 111 | target_link_libraries (Unlocker ws2_32 Wldap32 ComCtl32.lib Shlwapi.lib) 112 | endif() 113 | 114 | # Amend manifest to tell Windows that the app needs admin privileges 115 | IF (MSVC) 116 | IF (CMAKE_MAJOR_VERSION LESS 3) 117 | MESSAGE(WARNING "CMake version 3.0 or newer is required use build variable TARGET_FILE") 118 | ELSE() 119 | ADD_CUSTOM_COMMAND( 120 | TARGET Unlocker 121 | POST_BUILD 122 | COMMAND "mt.exe" -manifest \"${PROJECT_SOURCE_DIR}/Unlocker.exe.manifest\" -outputresource:\"$\"\;\#1 123 | COMMENT "Embedding manifest..." 124 | ) 125 | ENDIF() 126 | ENDIF(MSVC) 127 | 128 | # Main test 129 | # Tests need to be fixed to use the GUI-based functions 130 | #[[ 131 | set (TEST_SOURCES tests/test_patch.cpp / 132 | src/debug.cpp / 133 | src/patcher.cpp / 134 | src/network.cpp / 135 | src/versionparser.cpp / 136 | src/buildsparser.cpp / 137 | src/archive.cpp / 138 | src/installinfo.cpp / 139 | src/winservices.cpp / 140 | src/tar.cpp / 141 | src/unlocker.cpp / 142 | src/ziparchive.cpp / 143 | src/toolsdownloader.cpp) 144 | 145 | add_executable( TestPatch ${TEST_SOURCES}) 146 | 147 | target_compile_definitions(TestPatch PUBLIC _FILE_OFFSET_BITS=64) 148 | 149 | include_directories(TestPatch ${ZLIB_INCLUDE_DIRS}) 150 | include_directories(TestPatch ${CURL_INCLUDE_DIRS}) 151 | include_directories(TestPatch ${LIBZIP_INCLUDE_DIRS}) 152 | target_link_libraries (TestPatch ${ZLIB_LIBRARIES}) 153 | target_link_libraries (TestPatch ${CURL_LIBRARIES}) 154 | target_link_libraries (TestPatch ${LIBZIP_LIBRARY}) 155 | 156 | if(WIN32) 157 | target_link_libraries (TestPatch ws2_32 Wldap32) 158 | endif() 159 | 160 | set_target_properties( TestPatch PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON) 161 | 162 | enable_testing() 163 | add_test(NAME TestPatchTest COMMAND TestPatch "${PROJECT_SOURCE_DIR}") 164 | #]] 165 | 166 | 167 | # Tar test 168 | 169 | set (TESTTAR_SOURCES tests/test_tar.cpp / 170 | src/debug.cpp / 171 | src/patcher.cpp / 172 | src/versionparser.cpp / 173 | src/buildsparser.cpp / 174 | src/archive.cpp / 175 | src/installinfo.cpp / 176 | src/network.cpp / 177 | src/tar.cpp / 178 | src/ziparchive.cpp) 179 | 180 | add_executable( TestTar ${TESTTAR_SOURCES} "include/unlocker_lnx.h") 181 | 182 | target_compile_definitions(TestTar PUBLIC _FILE_OFFSET_BITS=64) 183 | 184 | include_directories(TestTar ${ZLIB_INCLUDE_DIRS}) 185 | include_directories(TestTar ${CURL_INCLUDE_DIRS}) 186 | include_directories(TestTar ${LIBZIP_INCLUDE_DIRS}) 187 | target_link_libraries (TestTar ${ZLIB_LIBRARIES}) 188 | target_link_libraries (TestTar ${CURL_LIBRARIES}) 189 | target_link_libraries (TestTar ${LIBZIP_LIBRARY}) 190 | 191 | if(WIN32) 192 | target_link_libraries (TestTar ws2_32 Wldap32) 193 | endif() 194 | 195 | set_target_properties( TestTar PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON) 196 | 197 | enable_testing() 198 | add_test(NAME TestTarTest COMMAND TestTar "${PROJECT_SOURCE_DIR}") 199 | 200 | # Zip test 201 | 202 | set (TESTZIP_SOURCES tests/test_zip.cpp / 203 | src/debug.cpp / 204 | src/patcher.cpp / 205 | src/versionparser.cpp / 206 | src/buildsparser.cpp / 207 | src/archive.cpp / 208 | src/installinfo.cpp / 209 | src/network.cpp / 210 | src/tar.cpp / 211 | src/ziparchive.cpp / 212 | src/toolsdownloader.cpp) 213 | 214 | add_executable( TestZip ${TESTZIP_SOURCES} "include/unlocker_lnx.h") 215 | 216 | target_compile_definitions(TestZip PUBLIC _FILE_OFFSET_BITS=64) 217 | 218 | include_directories(TestZip ${ZLIB_INCLUDE_DIRS}) 219 | include_directories(TestZip ${CURL_INCLUDE_DIRS}) 220 | include_directories(TestZip ${LIBZIP_INCLUDE_DIRS}) 221 | target_link_libraries (TestZip ${ZLIB_LIBRARIES}) 222 | target_link_libraries (TestZip ${CURL_LIBRARIES}) 223 | target_link_libraries (TestZip ${LIBZIP_LIBRARY}) 224 | 225 | if(WIN32) 226 | target_link_libraries (TestZip ws2_32 Wldap32) 227 | endif() 228 | 229 | set_target_properties( TestZip PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS ON) 230 | 231 | enable_testing() 232 | add_test(NAME TestZipTest COMMAND TestZip "${PROJECT_SOURCE_DIR}") 233 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX = /usr 2 | 3 | CXX ?= g++ 4 | 5 | src = src/versionparser.cpp \ 6 | src/buildsparser.cpp \ 7 | src/archive.cpp \ 8 | src/network.cpp \ 9 | src/debug.cpp \ 10 | src/installinfo.cpp \ 11 | src/patcher.cpp \ 12 | src/tar.cpp \ 13 | src/main.cpp \ 14 | src/ziparchive.cpp \ 15 | src/toolsdownloader.cpp \ 16 | src/logging/combinedlogstrategy.cpp \ 17 | src/logging/terminallogstrategy.cpp \ 18 | src/logging/streamlogstrategy.cpp \ 19 | src/logging/logstrategy.cpp \ 20 | src/patchversioner.cpp \ 21 | src/unlocker_lnx.cpp 22 | 23 | obj = $(src:.cpp=.o) 24 | 25 | INCLUDE = -Iinclude 26 | CXXFLAGS = -Wall -std=c++17 $(INCLUDE) 27 | 28 | LIBS += -lcurl -lzip -lstdc++fs 29 | 30 | auto-unlocker: $(obj) 31 | $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) 32 | 33 | .PHONY: clean 34 | clean: 35 | rm -f $(obj) auto-unlocker 36 | 37 | depend: $(src) 38 | makedepend -- $(INCLUDE) $^ 39 | 40 | .PHONY: install 41 | install: auto-unlocker 42 | install -D $< $(DESTDIR)$(PREFIX)/bin/auto-unlocker 43 | # mkdir -p $(DESTDIR)$(PREFIX)/bin 44 | # cp $< $(DESTDIR)$(PREFIX)/bin/auto-unlocker 45 | 46 | .PHONY: uninstall 47 | uninstall: auto-unlocker 48 | -rm -f $(DESTDIR)$(PREFIX)/bin/auto-unlocker 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Auto-Unlocker 2 | A one-click Unlocker for VMWare Player and Workstation. 3 | 4 | **A C++ port of the [DrDonk Python Unlocker](https://github.com/DrDonk/unlocker)** 5 | 6 | ## The tool 7 | 8 | This project is born to provide a native solution, mainly on Windows, to the original Unlocker project. 9 | Since the original project requires python, and it's not installed by default on windows, this tool has 10 | been coded to provide an all-in-one solution with no additional dependencies needed. 11 | 12 | It relies on libcurl for the networking (get requests and file download) and libzip for the zip extraction. 13 | The tar extraction, being relatively easy to implement, has been coded from scratch. 14 | The libraries are linked statically to provide one final executable for the sake of simplicity. 15 | 16 | The Windows target features a GUI implemented throught the Win32 API. 17 | Although this solution brings more complexity than using one of the many GUI libraries out there, 18 | the resulting executable will be smaller and with better compatibility. 19 | 20 | For the linux target, it is still shell-based, given the better-instructed user base running 21 | this tool on linux os-es. 22 | 23 | ## DrDonk Unlocker 24 | 25 | Unlocker 3 is designed for VMware Workstation 11-15 and Player 7-15. 26 | 27 | The patch code carries out the following modifications dependent on the product 28 | being patched: 29 | 30 | * Fix vmware-vmx and derivatives to allow macOS to boot 31 | * Fix vmwarebase .dll or .so to allow Apple to be selected during VM creation 32 | * Download a copy of the latest VMware Tools for macOS 33 | 34 | Note that not all products recognise the darwin.iso via install tools menu item. 35 | You will have to manually mount the darwin.iso for example on Workstation 11 and Player 7. 36 | 37 | In all cases make sure VMware is not running, and any background guests have 38 | been shutdown. 39 | 40 | ## How to use 41 | 42 | **Windows (GUI):** just download from the *releases* section, extract to a folder (store it if you want to be able to uninstall later) and run the executable. 43 | 44 | **Linux (shell):** You need to compile the program first. After you compiled it, ```chmod +x``` if needed and run ```sudo ./auto-unlocker```. Refer to the next section for more info about compiling the tool. 45 | 46 | **Command line options (linux):** 47 | 48 | * ```--install``` *(Default behavior when called with no arguments)* Installs the patch. 49 | * ```--uninstall``` Uninstalls the patch. Works only if the patch was previously installed and the *backup* folder is intact 50 | * ```--download-tools``` Downloads the tools in the `tools` folder 51 | * ```--help``` Shows a list of the available options 52 | 53 | ## Compile 54 | The program can be compiled on Windows with CMake, provided you get or compile the needed libraries first. Run CMake on the source dir and it will generate a ready to build project. 55 | 56 | The program needs the following libraries: 57 | 58 | * libcurl 59 | * libzip 60 | 61 | The tar extraction is handled internally, while the zip decompression needs the `libzip` library. `libcurl` is used for downloading the tools. 62 | 63 | **Windows:** 64 | Run *CMake* on the source folder to generate a Visual Studio Project. The CMakeList is set up to compile with static libraries, if you have shared ones change *CMakeLists.txt* file accordingly (**UNLOCKER_STATIC_LIBS_WIN** variable). Point the CMake utility to the proper library/headers paths when prompted or add them to your PATH. 65 | 66 | **Linux:** 67 | Use the embedded Makefile. Get needed libraries (or compile them and install) first, then run ```make``` 68 | 69 | On Ubuntu: 70 | 71 | ```bash 72 | sudo apt-get install libcurl4-openssl-dev libzip-dev 73 | git clone https://github.com/paolo-projects/auto-unlocker 74 | cd auto-unlocker 75 | make 76 | chmod +x ./auto-unlocker 77 | sudo ./auto-unlocker 78 | ``` -------------------------------------------------------------------------------- /Unlocker.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /include/archive.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCHIVEUTILS_H 2 | #define ARCHIVEUTILS_H 3 | 4 | #include "filesystem.hpp" 5 | #ifdef __linux__ 6 | #include 7 | #endif 8 | 9 | #include "ziparchive.h" 10 | #include "tar.h" 11 | #include "debug.h" 12 | #include 13 | 14 | class Archive 15 | { 16 | public: 17 | static bool extractZip(fs::path from, std::string filename, fs::path to); 18 | static bool extractTar(fs::path from, std::string filename, fs::path to); 19 | static void extractionProgress(float progress); 20 | }; 21 | 22 | #endif // ARCHIVEUTILS_H 23 | -------------------------------------------------------------------------------- /include/buildsparser.h: -------------------------------------------------------------------------------- 1 | #ifndef BUILDSPARSER_H 2 | #define BUILDSPARSER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "config.h" 10 | 11 | class BuildsParser 12 | { 13 | public: 14 | BuildsParser(const std::string& buildshtmltext); 15 | const std::string& getLatest() const; 16 | std::list::const_iterator cbegin() const; 17 | std::list::const_iterator cend() const; 18 | int size() const; 19 | private: 20 | std::string htmltext; 21 | std::list builds; 22 | std::regex pattern = std::regex(VERSION_REGEX_PATTERN, std::regex::icase); 23 | }; 24 | 25 | #endif // BUILDSPARSER_H 26 | -------------------------------------------------------------------------------- /include/colors.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORS_H 2 | #define COLORS_H 3 | 4 | #define ANSI_COLOR_RED "\x1b[31m" 5 | #define ANSI_COLOR_GREEN "\x1b[32m" 6 | #define ANSI_COLOR_YELLOW "\x1b[33m" 7 | #define ANSI_COLOR_BLUE "\x1b[34m" 8 | #define ANSI_COLOR_MAGENTA "\x1b[35m" 9 | #define ANSI_COLOR_CYAN "\x1b[36m" 10 | #define ANSI_COLOR_RESET "\x1b[0m" 11 | 12 | #endif // COLORS_H -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | /* 5 | All the URLS, file names and patterns needed by the app 6 | Grouped here to make it easy to fix something if they change some url or file names 7 | */ 8 | 9 | // Program options 10 | #define PROG_VERSION "v2.0.0" 11 | 12 | // File used for checking if the patch has been applied 13 | #define PATCH_VER_FILE ".unlocker" 14 | #define LNX_PATCH_VER_PATH "/usr/lib/vmware" 15 | 16 | // Log level 17 | // 0 - none 18 | // 1 - info (standard info, files being extracted, downloaded, etc.) 19 | // 2 - debug (useful info for debugging the patch e.g. addresses, values) 20 | // 3 - verbose (detailed info about the code) 21 | #define LOGLEVEL 3 22 | 23 | #define ARCH "x86_x64" 24 | 25 | // Install - Default option 26 | #define INSTALL_OPTION "--install" 27 | // Uninstall 28 | #define UNINSTALL_OPTION "--uninstall" 29 | // Only download tools 30 | #define DOWNLOADONLY_OPTION "--download-tools" 31 | // Show help message 32 | #define HELP_OPTION "--help" 33 | 34 | // Paths 35 | #define TOOLS_DOWNLOAD_FOLDER "tools" 36 | #define BACKUP_FOLDER "backup" 37 | 38 | // Base URL to parse for the tools 39 | #define FUSION_BASE_URL "http://softwareupdate.vmware.com/cds/vmw-desktop/fusion/" 40 | 41 | // Relative URLs and file names to be appended to version/build numbers 42 | #define FUSION_DEF_CORE_LOC "/universal/core/com.vmware.fusion.zip.tar" 43 | #define FUSION_DEF_CORE_NAME "com.vmware.fusion.zip.tar" 44 | #define FUSION_DEF_CORE_NAME_ZIP "com.vmware.fusion.zip" 45 | 46 | // Tools locations in the core TAR 47 | #define FUSION_ZIP_TOOLS_ISO "payload/VMware Fusion.app/Contents/Library/isoimages/" ARCH "/darwin.iso" 48 | #define FUSION_ZIP_TOOLS_NAME "darwin.iso" 49 | 50 | #define FUSION_ZIP_PRE15_TOOLS_ISO "payload/VMware Fusion.app/Contents/Library/isoimages/" ARCH "/darwinPre15.iso" 51 | #define FUSION_ZIP_PRE15_TOOLS_NAME "darwinPre15.iso" 52 | 53 | // Pattern to parse the versions/builds 54 | #define VERSION_REGEX_PATTERN "
  • ([^<]+)<\\/a><\\/li>" 55 | 56 | // Windows registry configuration 57 | #define HKEY_VMWARE HKEY_LOCAL_MACHINE 58 | #define HKEY_SUBKEY_VMWARE "SOFTWARE\\Wow6432Node\\VMware, Inc.\\VMware Player" 59 | #define HKEY_QUERY_VALUE_INSTALLPATH "InstallPath" 60 | #define HKEY_QUERY_VALUE_INSTALLPATH64 "InstallPath64" 61 | #define HKEY_QUERY_VALUE_PRODUCTVERSION "ProductVersion" 62 | 63 | // Windows services to stop 64 | #define VM_KILL_SERVICES {"vmware-view-usbd", "VMwareHostd", "VMAuthdService", "VMUSBArbService", "VMnetDHCP", "VMware NAT Service"} 65 | #define VM_KILL_PROCESSES {"vmware-tray.exe"} 66 | 67 | // Files to backup (win) { source, destination } 68 | #define VM_WIN_BACKUP_FILES { \ 69 | {"x64\\vmware-vmx.exe", "x64"}, \ 70 | {"x64\\vmware-vmx-debug.exe", "x64"}, \ 71 | {"x64\\vmware-vmx-stats.exe", "x64"}, \ 72 | {"vmwarebase.dll", ""} \ 73 | } 74 | 75 | // Files to backup (linux) { source, destination } 76 | #define VM_LNX_BACKUP_FILES { \ 77 | "/usr/lib/vmware/bin/vmware-vmx", \ 78 | "/usr/lib/vmware/bin/vmware-vmx-debug", \ 79 | "/usr/lib/vmware/bin/vmware-vmx-stats", \ 80 | } 81 | 82 | // Files to patch (have to keep the same order) 83 | #define VM_WIN_PATCH_FILES { \ 84 | "vmware-vmx.exe", \ 85 | "vmware-vmx-debug.exe", \ 86 | "vmware-vmx-stats.exe", \ 87 | "vmwarebase.dll" \ 88 | } 89 | 90 | // Linux paths and files 91 | #define VM_LNX_PATH "/usr/lib/vmware/bin" 92 | #define VM_LNX_BINS { \ 93 | "vmware-vmx", \ 94 | "vmware-vmx-debug", \ 95 | "vmware-vmx-stats", \ 96 | } 97 | #define VM_LNX_LIB_CANDIDATES { \ 98 | "/usr/lib/vmware/lib/libvmwarebase.so/libvmwarebase.so", \ 99 | "/usr/lib/vmware/lib/libvmwarebase.so.0/libvmwarebase.so.0" \ 100 | } 101 | #define VM_LNX_ISO_DESTPATH "/usr/lib/vmware/isoimages" 102 | 103 | // Patch data 104 | #define SMC_HEADER_V0 "\xF2\x00\x00\x00\xF0\x00\x00\x00" 105 | #define SMC_HEADER_V0_SZ 8 106 | #define SMC_HEADER_V1 "\xB4\x01\x00\x00\xB0\x01\x00\x00" 107 | #define SMC_HEADER_V1_SZ 8 108 | #define KEY_KEY "\x59\x45\x4B\x23\x04\x32\x33\x69\x75" 109 | #define KEY_KEY_SZ 9 110 | #define ADR_KEY "\x72\x64\x41\x24\x04\x32\x33\x69\x75" 111 | #define ADR_KEY_SZ 9 112 | 113 | #define DARWIN_REGEX "\\x10\\x00\\x00\\x00[\\x10|\\x20]\\x00\\x00\\x00[\\x01|\\x02]" \ 114 | "\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00" \ 115 | "\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00" 116 | 117 | #define DARWIN_PATTERN_PERM_1 {'\x10', '\x00', '\x00', '\x00', '\x10', '\x00', '\x00', '\x00', '\x01', \ 118 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',\ 119 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 120 | } 121 | 122 | #define DARWIN_PATTERN_PERM_2 {'\x10', '\x00', '\x00', '\x00', '\x20', '\x00', '\x00', '\x00', '\x01', \ 123 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 124 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 125 | } 126 | 127 | #define DARWIN_PATTERN_PERM_3 {'\x10', '\x00', '\x00', '\x00', '\x10', '\x00', '\x00', '\x00', '\x02', \ 128 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 129 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 130 | } 131 | 132 | #define DARWIN_PATTERN_PERM_4 {'\x10', '\x00', '\x00', '\x00', '\x20', '\x00', '\x00', '\x00', '\x02', \ 133 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 134 | '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', \ 135 | } 136 | 137 | #define SMC_NEW_DATA "bheuneqjbexolgurfrjbeqfthneqrqcy" 138 | #define SMC_NEW_DATA2 "rnfrqbagfgrny(p)NccyrPbzchgreVap" 139 | 140 | #define VMKCTL_FIND_STR "applesmc" 141 | #define VMKCTL_REPLACE_STR "vmkernel" 142 | 143 | #endif // CONFIG_H 144 | -------------------------------------------------------------------------------- /include/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef DEBUGUTILS_H 2 | #define DEBUGUTILS_H 3 | 4 | #include "config.h" 5 | #include 6 | #include 7 | #include "colors.h" 8 | #include "logging/logstrategy.h" 9 | 10 | #ifdef _WIN32 11 | #include 12 | #include "win32/controls/statusbar.h" 13 | #endif 14 | 15 | #define LOGLEVEL_VERBOSE 3 16 | #define LOGLEVEL_DEBUG 2 17 | #define LOGLEVEL_INFO 1 18 | #define LOGLEVEL_NONE 0 19 | 20 | class Logger 21 | { 22 | public: 23 | static void init(LogStrategy* strategy); 24 | static void free(); 25 | 26 | static void verbose(std::string msg); 27 | static void verbose(const char* msg, ...); 28 | 29 | static void debug(std::string msg); 30 | static void debug(const char* msg, ...); 31 | 32 | static void info(std::string msg); 33 | static void info(const char* msg, ...); 34 | 35 | static void error(std::string err); 36 | static void error(const char* err, ...); 37 | 38 | #ifdef _WIN32 39 | static void printWinDebug(const char* fmt, ...); 40 | #endif 41 | private: 42 | Logger(LogStrategy* strategy); 43 | 44 | static Logger* instance; 45 | LogStrategy* logStrategy; 46 | }; 47 | 48 | #endif // DEBUGUTILS_H 49 | -------------------------------------------------------------------------------- /include/filesystem.hpp: -------------------------------------------------------------------------------- 1 | // We haven't checked which filesystem to include yet 2 | #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 3 | 4 | // Check for feature test macro for 5 | # if defined(__cpp_lib_filesystem) 6 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 7 | 8 | // Check for feature test macro for 9 | # elif defined(__cpp_lib_experimental_filesystem) 10 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 11 | 12 | // We can't check if headers exist... 13 | // Let's assume experimental to be safe 14 | # elif !defined(__has_include) 15 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 16 | 17 | // Check if the header "" exists 18 | # elif __has_include() 19 | 20 | // If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental 21 | # ifdef _MSC_VER 22 | 23 | // Check and include header that defines "_HAS_CXX17" 24 | # if __has_include() 25 | # include 26 | 27 | // Check for enabled C++17 support 28 | # if defined(_HAS_CXX17) && _HAS_CXX17 29 | // We're using C++17, so let's use the normal version 30 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 31 | # endif 32 | # endif 33 | 34 | // If the marco isn't defined yet, that means any of the other VS specific checks failed, so we need to use experimental 35 | # ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 36 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 37 | # endif 38 | 39 | // Not on Visual Studio. Let's use the normal version 40 | # else // #ifdef _MSC_VER 41 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0 42 | # endif 43 | 44 | // Check if the header "" exists 45 | # elif __has_include() 46 | # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1 47 | 48 | // Fail if neither header is available with a nice error message 49 | # else 50 | # error Could not find system header "" or "" 51 | # endif 52 | 53 | // We priously determined that we need the exprimental version 54 | # if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 55 | // Include it 56 | # include 57 | 58 | // We need the alias from std::experimental::filesystem to std::filesystem 59 | //namespace std { 60 | // namespace filesystem = experimental::filesystem; 61 | //} 62 | 63 | namespace fs = std::experimental::filesystem; 64 | 65 | // We have a decent compiler and can use the normal version 66 | # else 67 | // Include it 68 | # include 69 | namespace fs = std::filesystem; 70 | 71 | # endif 72 | 73 | #endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 74 | -------------------------------------------------------------------------------- /include/installinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef INSTALLINFOUTILS_H 2 | #define INSTALLINFOUTILS_H 3 | 4 | #include 5 | #include 6 | 7 | #include "config.h" 8 | 9 | class VMWareInfoException : public std::runtime_error 10 | { 11 | public: 12 | VMWareInfoException(const char* message) : std::runtime_error(message) {} 13 | VMWareInfoException(const std::string& message) : std::runtime_error(message) {} 14 | }; 15 | 16 | class VMWareInfoRetriever 17 | { 18 | public: 19 | VMWareInfoRetriever(); 20 | std::string getInstallPath(); 21 | std::string getInstallPath64(); 22 | std::string getProductVersion(); 23 | 24 | private: 25 | std::string installPath, installPath64, prodVersion; 26 | }; 27 | 28 | #endif // INSTALLINFOUTILS_H 29 | -------------------------------------------------------------------------------- /include/logging/combinedlogstrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBINEDLOGSTRATEGY_H 2 | #define COMBINEDLOGSTRATEGY_H 3 | 4 | #include 5 | #include "logging/logstrategy.h" 6 | 7 | class CombinedLogStrategy : public LogStrategy 8 | { 9 | public: 10 | CombinedLogStrategy() {}; 11 | 12 | void add(LogStrategy* strategy); 13 | 14 | virtual void verbose(const char* message) override; 15 | virtual void debug(const char* message) override; 16 | virtual void info(const char* message) override; 17 | virtual void error(const char* message) override; 18 | private: 19 | std::vector logStrategies; 20 | }; 21 | 22 | #endif -------------------------------------------------------------------------------- /include/logging/logstrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGSTRATEGY_H 2 | #define LOGSTRATEGY_H 3 | 4 | class LogStrategy 5 | { 6 | public: 7 | virtual void verbose(const char* message) = 0; 8 | virtual void debug(const char* message) = 0; 9 | virtual void info(const char* message) = 0; 10 | virtual void error(const char* message) = 0; 11 | }; 12 | 13 | #endif -------------------------------------------------------------------------------- /include/logging/statusbarlogstrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef STATUSBARLOGSTRATEGY_H 2 | #define STATUSBARLOGSTRATEGY_H 3 | 4 | #include "logging/logstrategy.h" 5 | #include "win32/controls/statusbar.h" 6 | 7 | class StatusBarLogStrategy : public LogStrategy 8 | { 9 | public: 10 | StatusBarLogStrategy(StatusBar* statusBar); 11 | 12 | virtual void verbose(const char* message) override; 13 | virtual void debug(const char* message) override; 14 | virtual void info(const char* message) override; 15 | virtual void error(const char* message) override; 16 | private: 17 | StatusBar* statusBar; 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /include/logging/streamlogstrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef STREAMLOGSTRATEGY_H 2 | #define STREAMLOGSTRATEGY_H 3 | 4 | #include 5 | #include "logging/logstrategy.h" 6 | 7 | class StreamLogStrategy : public LogStrategy 8 | { 9 | public: 10 | StreamLogStrategy(std::ostream& stream); 11 | 12 | virtual void verbose(const char* message) override; 13 | virtual void debug(const char* message) override; 14 | virtual void info(const char* message) override; 15 | virtual void error(const char* message) override; 16 | private: 17 | std::ostream& stream; 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /include/logging/terminallogstrategy.h: -------------------------------------------------------------------------------- 1 | #ifndef TERMINALLOGSTRATEGY_H 2 | #define TERMINALLOGSTRATEGY_H 3 | 4 | #include 5 | #include "colors.h" 6 | #include "logging/logstrategy.h" 7 | 8 | class TerminalLogStrategy : public LogStrategy 9 | { 10 | public: 11 | virtual void verbose(const char* message) override; 12 | virtual void debug(const char* message) override; 13 | virtual void info(const char* message) override; 14 | virtual void error(const char* message) override; 15 | }; 16 | 17 | #endif -------------------------------------------------------------------------------- /include/network.h: -------------------------------------------------------------------------------- 1 | #ifndef NETUTILS_H 2 | #define NETUTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "debug.h" 14 | 15 | #define CURL_DEBUG false 16 | 17 | class NetworkException : public std::runtime_error 18 | { 19 | public: 20 | NetworkException(const char* message, CURLcode code) : std::runtime_error(message), code(code) {} 21 | NetworkException(const std::string& message, CURLcode code) : std::runtime_error(message), code(code) {} 22 | CURLcode getCode() const { return code; } 23 | private: 24 | CURLcode code; 25 | }; 26 | 27 | struct NetworkProgress { 28 | double mBytesDownloadedLastTime = 0.0; 29 | long long lastProgressUpdateTime = 0; 30 | }; 31 | 32 | class Network 33 | { 34 | public: 35 | Network(); 36 | ~Network(); 37 | void setProgressCallback(std::function progressCallback); 38 | void curlDownload(const std::string& url, const std::string& fileName); 39 | std::string curlGet(const std::string& url); 40 | private: 41 | static constexpr double mBytesProgressUpdateDelta = 0.1; // 0.1 MB 42 | static constexpr long long updatePeriodMs = 200; // update every 100ms 43 | 44 | std::function progressCallback = nullptr; 45 | 46 | NetworkProgress networkProgress = {}; 47 | static size_t write_data_file(char* ptr, size_t size, size_t nmemb, void* stream); 48 | static int progress_callback(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow); 49 | static int progress_callback_external(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow); 50 | }; 51 | 52 | #endif // NETUTILS_H 53 | -------------------------------------------------------------------------------- /include/patcher.h: -------------------------------------------------------------------------------- 1 | #ifndef PATCHUTILS_H 2 | #define PATCHUTILS_H 3 | 4 | #include "filesystem.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "debug.h" 15 | #include "config.h" 16 | 17 | class PatchException : public std::runtime_error 18 | { 19 | public: 20 | PatchException(const char* message) 21 | : std::runtime_error(message) 22 | {} 23 | PatchException(const std::string& message) 24 | : std::runtime_error(message) 25 | {} 26 | }; 27 | 28 | struct LLQQQQLLQQ // couldn't find a better name LOL 29 | { 30 | unsigned long l1; 31 | unsigned long l2; 32 | unsigned long long q1; 33 | unsigned long long q2; 34 | unsigned long long q3; 35 | unsigned long long q4; 36 | unsigned long l3; 37 | unsigned long l4; 38 | unsigned long long q5; 39 | unsigned long long q6; 40 | }; 41 | 42 | struct QQq // it's starting to feel awkward 43 | { 44 | unsigned long long Q1, Q2; 45 | long long q3; 46 | }; 47 | 48 | struct smc_key_struct 49 | { 50 | char s0[4]; 51 | unsigned char B1; 52 | char s2[4]; 53 | unsigned char B3; 54 | unsigned char padding[6]; 55 | unsigned long long Q4; 56 | }; 57 | 58 | class Patcher { 59 | public: 60 | // Utils 61 | static std::string rot13(const std::string& in); 62 | static std::string hexRepresentation(long long bin); 63 | static std::vector makeVector(const char* arr, size_t size); 64 | static std::string hexRepresentation(std::vector bin); 65 | static std::string hexRepresentation(std::string bin); 66 | static std::optional searchForOffset(const std::vector& memstream, const std::vector& sequence, unsigned long long from = 0); 67 | static std::optional searchForLastOffset(const std::vector& memstream, const std::vector& sequence); 68 | static std::optional searchForOffset(std::fstream& stream, const std::vector& sequence, unsigned long long from = 0); 69 | static std::optional searchForLastOffset(std::fstream& stream, const std::vector& sequence); 70 | static std::vector readFile(std::fstream& stream); 71 | static bool cmpcarr(const char* c1, const char* c2, size_t len); 72 | static void printkey(int i, unsigned long long offset, const smc_key_struct& smc_key, const std::vector& smc_data); 73 | 74 | // Core functions 75 | static void patchSMC(fs::path name, bool isSharedObj); 76 | static std::pair patchKeys(std::fstream& file, long long key); 77 | static void patchBase(fs::path name); 78 | static void patchVmkctl(fs::path name); 79 | static void patchElf(std::fstream& file, long long oldoffset, long long newoffset); 80 | }; 81 | 82 | #endif // PATCHUTILS_H 83 | -------------------------------------------------------------------------------- /include/patchversioner.h: -------------------------------------------------------------------------------- 1 | #ifndef PATCHVERSIONER_H 2 | #define PATCHVERSIONER_H 3 | 4 | #ifdef _WIN32 5 | #include 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "filesystem.hpp" 14 | #include "config.h" 15 | 16 | class PatchVersionerException : public std::runtime_error 17 | { 18 | public: 19 | PatchVersionerException(const char* msg) : std::runtime_error(msg) {} 20 | PatchVersionerException(const std::string& msg) : std::runtime_error(msg) {} 21 | }; 22 | 23 | class PatchVersioner 24 | { 25 | public: 26 | PatchVersioner(const fs::path& installPath); 27 | time_t getPatchTime() const; 28 | std::string getPatchVersion() const; 29 | void writePatchData(); 30 | void removePatchVersion(); 31 | bool hasPatch() const; 32 | 33 | private: 34 | typedef struct _patch_version_t { 35 | char timestamp[256]; 36 | char version[256]; 37 | } patch_version_t; 38 | 39 | std::string versionFile; 40 | bool haspatch = false; 41 | patch_version_t vData = {}; 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /include/tar.h: -------------------------------------------------------------------------------- 1 | #ifndef TAR_H 2 | #define TAR_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef WIN32 14 | #define fseek_e64(f, p, t) _fseeki64(f, p, t); 15 | #else 16 | #define fseek_e64(f, p, t) fseeko(f, p, t); 17 | #endif 18 | 19 | constexpr int TAR_BLOCK_SZ = 512; 20 | 21 | enum tar_type_flag { 22 | REGTYPE = '0', /* regular file */ 23 | AREGTYPE = '\0', /* regular file */ 24 | LNKTYPE = '1', /* link */ 25 | SYMTYPE = '2', /* reserved */ 26 | CHRTYPE = '3', /* character special */ 27 | BLKTYPE = '4', /* block special */ 28 | DIRTYPE = '5', /* directory */ 29 | FIFOTYPE = '6', /* FIFO special */ 30 | CONTTYPE = '7', /* reserved */ 31 | XHDTYPE = 'x', /* Extended header referring to the next file in the archive */ 32 | XGLTYPE = 'g' /* Global extended header */ 33 | }; 34 | 35 | struct tar_posix_header 36 | { /* byte offset */ 37 | char name[100]; /* 0 */ 38 | char mode[8]; /* 100 */ 39 | char uid[8]; /* 108 */ 40 | char gid[8]; /* 116 */ 41 | char size[12]; /* 124 */ 42 | char mtime[12]; /* 136 */ 43 | char chksum[8]; /* 148 */ 44 | char typeflag; /* 156 */ 45 | char linkname[100]; /* 157 */ 46 | char magic[6]; /* 257 */ 47 | char version[2]; /* 263 */ 48 | char uname[32]; /* 265 */ 49 | char gname[32]; /* 297 */ 50 | char devmajor[8]; /* 329 */ 51 | char devminor[8]; /* 337 */ 52 | char prefix[155]; /* 345 */ 53 | char pad[12]; /* 500 */ 54 | /* 512 */ 55 | }; 56 | 57 | class TarException : public std::runtime_error { 58 | public: 59 | TarException(const char* message) : std::runtime_error(message) {} 60 | TarException(const std::string& message) : std::runtime_error(message) {} 61 | }; 62 | 63 | class Tar 64 | { 65 | public: 66 | 67 | struct File 68 | { 69 | std::string name; 70 | int mode; 71 | int ownerId; 72 | int groupId; 73 | size_t size; 74 | int lastModified; 75 | tar_type_flag typeflag; 76 | std::string linkedName; 77 | size_t position; 78 | }; 79 | 80 | Tar(std::string filename); 81 | ~Tar(); 82 | void extract(const File& file, std::string to, void(*progressCallback)(float) = nullptr); 83 | bool extract(std::string fileName, std::string to, void(*progressCallback)(float) = nullptr); 84 | const std::vector& getFileList() const; 85 | bool contains(std::string fileName) const; 86 | std::vector search(const std::string& term); 87 | private: 88 | void(*progressCallback)(float) = nullptr; 89 | FILE* tarfile = NULL; 90 | std::vector fileList; 91 | 92 | int octToInt(char* oct); 93 | size_t octToSz(char* oct); 94 | 95 | static constexpr size_t EXTRACT_BUFFER_SZ = 1024 * 16; 96 | }; 97 | 98 | #endif // TAR_H -------------------------------------------------------------------------------- /include/toolsdownloader.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOLSDOWNLOADER_H 2 | #define TOOLSDOWNLOADER_H 3 | 4 | #include 5 | #include "filesystem.hpp" 6 | #include "network.h" 7 | #include "archive.h" 8 | #include "buildsparser.h" 9 | #include "debug.h" 10 | 11 | class ToolsDownloaderException : public std::runtime_error 12 | { 13 | public: 14 | ToolsDownloaderException(const char* message) : std::runtime_error(message) {} 15 | ToolsDownloaderException(const std::string& message) : std::runtime_error(message) {} 16 | }; 17 | 18 | class ToolsDownloader 19 | { 20 | public: 21 | ToolsDownloader(Network& network, const std::string& baseUrl, const std::string& version); 22 | bool download(const fs::path& to); 23 | private: 24 | Network& network; 25 | std::string baseUrl, versionNumber, versionUrl, buildurl; 26 | 27 | bool downloadFromCore(const fs::path& to); 28 | }; 29 | 30 | #endif // TOOLSDOWNLOADER_H -------------------------------------------------------------------------------- /include/unlocker_lnx.h: -------------------------------------------------------------------------------- 1 | #ifndef UNLOCKERLNX_H 2 | #define UNLOCKERLNX_H 3 | 4 | #include 5 | #include "filesystem.hpp" 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "config.h" 12 | #include "network.h" 13 | #include "versionparser.h" 14 | #include "debug.h" 15 | #include "toolsdownloader.h" 16 | #include "installinfo.h" 17 | #include "patcher.h" 18 | 19 | #include 20 | #include 21 | 22 | #include "patchversioner.h" 23 | 24 | #define stricmp(a, b) strcasecmp(a, b) 25 | 26 | #include 27 | 28 | #define CHECKRES(x) try{ (x); } catch (const PatchException& exc) { Logger::error(exc.what()); } 29 | #define KILL(x) (x); exit(1); 30 | 31 | bool downloadTools(fs::path path); 32 | void copyTools(fs::path toolspath); 33 | 34 | void installLnx(); 35 | void preparePatchLnx(fs::path backupPath); 36 | void applyPatchLnx(); 37 | void uninstallLnx(); 38 | 39 | #endif // UNLOKERLNX_H -------------------------------------------------------------------------------- /include/unlocker_win.h: -------------------------------------------------------------------------------- 1 | #ifndef UNLOCKERWIN_H 2 | #define UNLOCKERWIN_H 3 | 4 | #include 5 | #include "filesystem.hpp" 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "config.h" 12 | #include "network.h" 13 | #include "versionparser.h" 14 | #include "debug.h" 15 | #include "toolsdownloader.h" 16 | #include "installinfo.h" 17 | #include "winservices.h" 18 | #include "patcher.h" 19 | #include "patchversioner.h" 20 | 21 | #include 22 | 23 | bool downloadTools(fs::path path, std::function progressCallback = nullptr); 24 | void copyTools(fs::path toolspath, fs::path copyTo); 25 | 26 | void preparePatchWin(fs::path backupPath, fs::path vmInstallPath); 27 | void applyPatchWin(const fs::path& vmwareInstallPath, const fs::path& vmwareInstallPath64); 28 | void stopServices(); 29 | void restartServices(); 30 | 31 | #endif // UNLOCKERWIN_H -------------------------------------------------------------------------------- /include/versionparser.h: -------------------------------------------------------------------------------- 1 | #ifndef VERSIONPARSER_H 2 | #define VERSIONPARSER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "config.h" 10 | 11 | // Auxiliary class for version comparation 12 | class Version { 13 | public: 14 | // Version parse exception 15 | class VersionException : public std::exception 16 | { 17 | public: 18 | explicit VersionException(const char* message) : 19 | msg_(message) 20 | { 21 | } 22 | explicit VersionException(const std::string& message) : 23 | msg_(message) 24 | {} 25 | virtual ~VersionException() throw () {} 26 | virtual const char* what() const throw () { 27 | return msg_.c_str(); 28 | } 29 | 30 | protected: 31 | std::string msg_; 32 | }; 33 | 34 | enum VersionNumberType { 35 | MAJOR, 36 | MINOR, 37 | REVISION 38 | }; 39 | 40 | Version(std::string version) 41 | : version(version) 42 | { 43 | std::smatch mres; 44 | if (std::regex_match(version, mres, pattern)) { 45 | major = std::stoi(mres.str(1)); 46 | minor = std::stoi(mres.str(2)); 47 | revision = std::stoi(mres.str(3)); 48 | } 49 | else throw VersionException("Not a valid version string"); 50 | } 51 | 52 | std::string getVersionText() const { 53 | return version; 54 | } 55 | 56 | int getVersionNumber(VersionNumberType vnType = MAJOR) const { 57 | switch (vnType) { 58 | default: 59 | case MAJOR: 60 | return major; 61 | case MINOR: 62 | return minor; 63 | case REVISION: 64 | return revision; 65 | } 66 | } 67 | 68 | bool operator== (const Version& v2) const { 69 | return (major == v2.major && 70 | minor == v2.minor && 71 | revision == v2.revision 72 | ); 73 | } 74 | 75 | bool operator!= (const Version& v2) const { 76 | return !(*this == v2); 77 | } 78 | 79 | bool operator> (const Version& v2) const { 80 | if (major > v2.major) 81 | return true; 82 | if (major == v2.major) 83 | { 84 | if (minor > v2.minor) 85 | return true; 86 | if (minor == v2.minor) 87 | { 88 | if (revision > v2.revision) 89 | return true; 90 | } 91 | } 92 | 93 | return false; 94 | } 95 | 96 | bool operator< (const Version& v2) const { 97 | return !(*this > v2) && *this != v2; 98 | } 99 | 100 | bool operator>= (const Version& v2) const { 101 | return (*this > v2) || (*this == v2); 102 | } 103 | 104 | bool operator<= (const Version& v2) const { 105 | return (*this < v2) || (*this == v2); 106 | } 107 | private: 108 | std::string version; 109 | std::regex pattern = std::regex("(\\d+)\\.(\\d+)\\.(\\d+)"); 110 | int major = 0, minor = 0, revision = 0; 111 | }; 112 | 113 | class VersionParser 114 | { 115 | public: 116 | VersionParser(const std::string& versionhtmltext); 117 | const Version& getLatest() const; 118 | std::list::const_iterator cbegin() const; 119 | std::list::const_iterator cend() const; 120 | int size() const; 121 | private: 122 | std::string htmltext; 123 | std::list versions; 124 | std::regex pattern = std::regex(VERSION_REGEX_PATTERN, std::regex::icase); 125 | 126 | }; 127 | 128 | #endif // VERSIONPARSER_H 129 | -------------------------------------------------------------------------------- /include/win32/controls/button.h: -------------------------------------------------------------------------------- 1 | #ifndef BUTTON_H 2 | #define BUTTON_H 3 | 4 | #include 5 | #include 6 | #include "win32/events/events.h" 7 | #include "win32/controls/control.h" 8 | 9 | class Button : public Control 10 | { 11 | public: 12 | Button(HWND parent, int menuId, LPCSTR text, int x, int y, int width, int height); 13 | 14 | private: 15 | }; 16 | 17 | #endif -------------------------------------------------------------------------------- /include/win32/controls/checkbox.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECKBOX_H 2 | #define CHECKBOX_H 3 | 4 | #include 5 | #include 6 | #include "win32/events/events.h" 7 | #include "win32/controls/control.h" 8 | 9 | class CheckBox : public Control 10 | { 11 | public: 12 | CheckBox(HWND parent, int menuId, LPCSTR text, int x, int y, int width, int height); 13 | void set(bool checked); 14 | bool isChecked(); 15 | 16 | private: 17 | }; 18 | 19 | #endif -------------------------------------------------------------------------------- /include/win32/controls/control.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTROL_H 2 | #define CONTROL_H 3 | 4 | #include 5 | #include 6 | #include "win32/events/events.h" 7 | 8 | class Control 9 | { 10 | public: 11 | Control(); 12 | 13 | void addEventListener(EventType eventType, EventCallback callback); 14 | void triggerEvent(EventType eventType); 15 | 16 | void setEnabled(bool enabled); 17 | bool isEnabled(); 18 | 19 | HWND getHwnd() const; 20 | 21 | protected: 22 | std::map events; 23 | HWND hWnd = NULL; 24 | HWND parentHwnd = NULL; 25 | 26 | void applySystemFont(); 27 | }; 28 | 29 | #endif -------------------------------------------------------------------------------- /include/win32/controls/editbox.h: -------------------------------------------------------------------------------- 1 | #ifndef EDITBOX_H 2 | #define EDITBOX_H 3 | 4 | #include 5 | #include 6 | #include "win32/controls/control.h" 7 | 8 | class EditBox : public Control 9 | { 10 | public: 11 | EditBox(HWND parent, int menuId, LPCSTR text, int x, int y, int width, int height); 12 | 13 | void setReadOnly(bool readOnly); 14 | bool isReadOnly() const; 15 | void setText(std::string text); 16 | std::string getText() const; 17 | private: 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /include/win32/controls/groupbox.h: -------------------------------------------------------------------------------- 1 | #ifndef GROUPBOX_H 2 | #define GROUPBOX_H 3 | 4 | #include 5 | #include 6 | #include "win32/controls/control.h" 7 | 8 | class GroupBox : public Control 9 | { 10 | public: 11 | GroupBox(HWND parent, LPCSTR text, int x, int y, int width, int height); 12 | 13 | private: 14 | }; 15 | 16 | #endif -------------------------------------------------------------------------------- /include/win32/controls/label.h: -------------------------------------------------------------------------------- 1 | #ifndef LABEL_H 2 | #define LABEL_H 3 | 4 | #include 5 | #include "win32\controls\control.h" 6 | 7 | class Label : public Control 8 | { 9 | public: 10 | Label(HWND parent, int menuId, LPCSTR text, int x, int y, int width, int height); 11 | 12 | private: 13 | }; 14 | 15 | #endif -------------------------------------------------------------------------------- /include/win32/controls/progress.h: -------------------------------------------------------------------------------- 1 | #ifndef PROGRESS_H 2 | #define PROGRESS_H 3 | 4 | #include 5 | #include 6 | #include "win32/controls/control.h" 7 | 8 | class Progress : public Control 9 | { 10 | public: 11 | Progress(HWND parent, int menuId, int x, int y, int width, int height); 12 | void setRange(int range); 13 | void setStep(int step); 14 | void setProgress(int progress); 15 | void advance(); 16 | 17 | private: 18 | }; 19 | 20 | #endif -------------------------------------------------------------------------------- /include/win32/controls/statusbar.h: -------------------------------------------------------------------------------- 1 | #ifndef STATUSBAR_H 2 | #define STATUSBAR_H 3 | 4 | #include 5 | #include 6 | #include "win32/controls/control.h" 7 | 8 | class StatusBar : Control 9 | { 10 | public: 11 | StatusBar(HWND parent, int menuId, LPCSTR text); 12 | 13 | void setText(LPCSTR text); 14 | }; 15 | 16 | #endif -------------------------------------------------------------------------------- /include/win32/controls/window.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOW_H 2 | #define WINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "debug.h" 10 | #include "win32/controls/control.h" 11 | #include "win32/events/events.h" 12 | 13 | class Window : public Control 14 | { 15 | public: 16 | Window(HINSTANCE hInstance, int nCmdShow, const std::string& className, const std::string& title, int x = CW_USEDEFAULT, int y = CW_USEDEFAULT, int width = CW_USEDEFAULT, int height = CW_USEDEFAULT); 17 | ~Window(); 18 | // Override to setup buttons, controls, etc. 19 | virtual void onCreate(HWND hWnd) {}; 20 | void show(); 21 | void registerControl(int menuId, Control* control); 22 | protected: 23 | std::string className; 24 | std::string title; 25 | HINSTANCE hInstance = NULL; 26 | int nCmdShow, 27 | x, 28 | y, 29 | width, 30 | height; 31 | 32 | private: 33 | static LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMSG, WPARAM wParam, LPARAM lParam); 34 | std::map controls; 35 | 36 | void messageLoop(); 37 | }; 38 | 39 | #endif -------------------------------------------------------------------------------- /include/win32/downloadtoolstask.h: -------------------------------------------------------------------------------- 1 | #ifndef DOWNLOADTOOLSTASK_H 2 | #define DOWNLOADTOOLSTASK_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "win32/task.h" 10 | #include "win32/patchresult.h" 11 | #include "logging/streamlogstrategy.h" 12 | #include "logging/statusbarlogstrategy.h" 13 | #include "logging/combinedlogstrategy.h" 14 | #include "unlocker_win.h" 15 | 16 | class MainWindow; 17 | 18 | class DownloadToolsTask : public Task 19 | { 20 | public: 21 | DownloadToolsTask(MainWindow& mainWindow); 22 | void setOnCompleteCallback(std::function completeCallback); 23 | void setOnProgressCallback(std::function progressCallback); 24 | protected: 25 | void onProgressUpdate(float progress) override; 26 | PatchResult doInBackground(void* arg) override; 27 | void onPostExecute(PatchResult result) override; 28 | private: 29 | static constexpr int PROG_PERIOD_MS = 200; 30 | 31 | MainWindow& mainWindow; 32 | 33 | std::function onCompleteCallback = nullptr; 34 | std::function onProgressCallback = nullptr; 35 | 36 | void downloadProgress(double dltotal, double dlnow, double ultotal, double ulnow); 37 | 38 | std::chrono::milliseconds lastProgressUpdate = std::chrono::duration_cast( 39 | std::chrono::system_clock::now().time_since_epoch() 40 | ); 41 | double lastDlNow = 0.0; 42 | }; 43 | 44 | #endif -------------------------------------------------------------------------------- /include/win32/events/events.h: -------------------------------------------------------------------------------- 1 | #ifndef EVENTS_H 2 | #define EVENTS_H 3 | 4 | #include 5 | 6 | enum class EventType { 7 | CLICK_EVENT 8 | }; 9 | 10 | using EventCallback = std::function; 11 | 12 | #endif -------------------------------------------------------------------------------- /include/win32/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "filesystem.hpp" 11 | 12 | #include "config.h" 13 | #include "controls/button.h"; 14 | #include "controls/editbox.h" 15 | #include "controls/label.h" 16 | #include "controls/window.h" 17 | #include "controls/progress.h" 18 | #include "controls/groupbox.h" 19 | #include "controls/checkbox.h" 20 | #include "controls/statusbar.h" 21 | #include "patchertask.h" 22 | #include "unpatchertask.h" 23 | #include "downloadtoolstask.h" 24 | #include "resources.h" 25 | 26 | #include "installinfo.h" 27 | #include "unlocker_win.h" 28 | 29 | struct DialogState 30 | { 31 | bool pathEnabled, 32 | path64Enabled, 33 | pathBrowseEnabled, 34 | path64BrowseEnabled, 35 | downloadToolsEnabled, 36 | downloadToolsChecked, 37 | toolsPathEnabled, 38 | toolsBrowseEnabled, 39 | downloadToolsBtnEnabled, 40 | patchEnabled, 41 | unpatchEnabled; 42 | }; 43 | 44 | class MainWindow : public Window 45 | { 46 | public: 47 | MainWindow(HINSTANCE hInstance, int nCmdShow); 48 | ~MainWindow(); 49 | virtual void onCreate(HWND hWnd) override; 50 | 51 | std::unique_ptr