Add macOS and FreeBSD support and fix DJGPP build (#48)

This commit is contained in:
techguy16 2023-07-25 18:53:42 +12:00 committed by GitHub
parent fefc8552b6
commit 20c84661b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 220 additions and 153 deletions

View File

@ -20,7 +20,11 @@
name: C/C++ CI (DOS DJGPP)
on: workflow_dispatch
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CMAKE_C_COMPILER: ${{ github.workspace }}/djgpp/bin/i586-pc-msdosdjgpp-gcc
@ -50,7 +54,6 @@ jobs:
cd watt32/util
make clean && make linux
cd ../src
source ${{ github.workspace }}/djgpp/setenv.sh
./configur.sh djgpp
make -f djgpp.mak
ln -s ${{ github.workspace }}/djgpp/watt32/lib/libwatt.a ${{ github.workspace }}/djgpp/lib
@ -64,6 +67,7 @@ jobs:
./Configure no-threads -DOPENSSL_DEV_NO_ATOMICS --prefix=${{ github.workspace }}/djgpp DJGPP
make && make install
popd
ls ${{ github.workspace }}/djgpp/i586-pc-msdosdjgpp/bin/
- name: Checkout Source Tree
uses: actions/checkout@v3
@ -71,19 +75,19 @@ jobs:
- name: Build
uses: threeal/cmake-action@v1.2.0
with:
c-compiler: ${{ github.workspace }}/djgpp/i586-pc-msdosdjgpp/bin/gcc
cxx-compiler: ${{ github.workspace }}/djgpp/i586-pc-msdosdjgpp/bin/g++
c-compiler: gcc
cxx-compiler: g++
options: OPENSSL_ROOT_DIR:string=${{ github.workspace }}/djgpp DJGPP_WATT32=ON
run-build: true
- name: Move files to correct directory
- name: Test & Move files to correct directory
run: |
mkdir build/actions_upload
tar -czf WindowsXPKg_linux_x86_64.tar.gz -C build xpkey keys.json
mv WindowsXPKg_linux_x86_64.tgz build/actions_upload/
mkdir -p build/actions_upload
mv build/umskt build/actions_upload/umskt
- name: Upload build artifact
uses: actions/upload-artifact@v3.1.2
with:
name: Build
name: UMSKT-DOS-DJGPP
path: build/actions_upload

61
.github/workflows/freebsd.yml vendored Normal file
View File

@ -0,0 +1,61 @@
# This file is a part of the UMSKT Project
#
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# @FileCreated by techguy16 on 07/23/2023
# @Maintainer techguy16
name: C/C++ CI (FreeBSD)
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: macos-12
name: build-x86_64
steps:
- uses: actions/checkout@v3
- name: Build & Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v0
with:
envs: 'MYTOKEN MYTOKEN2'
usesh: true
prepare: |
pkg install -y cmake openssl git bash
run: |
mkdir build
cd build
cmake ..
make
./umskt # Execute the test here
- name: Move files to correct directory
run: |
mkdir -p build/actions_upload
mv build/umskt build/actions_upload/umskt
- name: Upload build artifact
uses: actions/upload-artifact@v3.1.2
with:
name: UMSKT-FreeBSD
path: build/actions_upload

65
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,65 @@
# This file is a part of the UMSKT Project
#
# Copyleft (C) 2019-2023 UMSKT Contributors (et.al.)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# @FileCreated by techguy16 on 07/23/2023
# @Maintainer techguy16
name: C/C++ CI (macOS)
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-x86:
runs-on: macos-latest
strategy:
matrix:
include:
- arch: x86_64
steps:
- name: Checkout Source Tree
uses: actions/checkout@v3
- name: Configure and build UMSKT
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
- name: Move files to correct directory
run: |
mkdir -p build/actions_upload
mv build/umskt build/actions_upload/umskt
- name: Run tests
run: |
cd build/actions_upload
./umskt
- name: Zip artifact
run: |
cd build/actions_upload
zip -r UMSKT-macOS-${{ matrix.arch }}-static.zip umskt
- name: Upload build artifact
uses: actions/upload-artifact@v3.1.2
with:
name: UMSKT-macOS-${{ matrix.arch }}-static
path: build/actions_upload

View File

@ -18,88 +18,49 @@
# @FileCreated by Andrew on 05/30/2023
# @Maintainer Neo
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
PROJECT(UMSKT)
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
OPTION(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
OPTION(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
OPTION(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
OPTION(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
cmake_minimum_required(VERSION 3.12)
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS})
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS})
project(UMSKT)
set(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path")
IF(UMSKT_USE_SHARED_OPENSSL)
SET(OPENSSL_USE_STATIC_LIBS FALSE)
SET(OPENSSL_MSVC_STATIC_RT FALSE)
MESSAGE(WARNING "[UMSKT] Forcing shared OpenSSL runtime")
ELSE()
SET(OPENSSL_USE_STATIC_LIBS TRUE)
SET(OPENSSL_MSVC_STATIC_RT TRUE)
ENDIF()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
IF(DJGPP_WATT32)
SET(CMAKE_SYSTEM_NAME MSDOS)
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} ${DJGPP_WATT32})
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS} ${WATT_ROOT}/lib)
ENDIF()
option(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
option(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
option(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
option(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
# find the system installed OpenSSL development library
FIND_PACKAGE(OpenSSL REQUIRED)
IF(NOT OPENSSL_FOUND)
MESSAGE(SEND_ERROR "OpenSSL Development Libraries Not Found")
MESSAGE(SEND_ERROR "Please consult your package manager of choice to install the prerequisite")
MESSAGE(SEND_ERROR "The package name is commonly called libssl-dev or openssl-dev depending on distribution")
MESSAGE(FATAL_ERROR "Can not continue without OpenSSL")
ENDIF()
find_package(OpenSSL REQUIRED)
# if we found shared libraries - do the following:
STRING(REGEX MATCH "(\\.so|\\.dll|\\.dylib)$" OPENSSL_CRYPTO_SHARED "${OPENSSL_CRYPTO_LIBRARY}")
IF(OPENSSL_CRYPTO_SHARED)
MESSAGE(STATUS "[UMSKT] Detected Shared library version of OpenSSL")
SET(BUILD_SHARED_LIBS ON)
ELSE()
MESSAGE(STATUS "[UMSKT] Detected Static Library version of OpenSSL")
ENDIF()
if(NOT OpenSSL_FOUND)
message(FATAL_ERROR "OpenSSL Development Libraries Not Found. Please install the required OpenSSL development package.")
endif()
# if we're compiling with MSVC, respect the DEBUG compile option
IF(MSVC)
SET(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
IF(NOT BUILD_SHARED_LIBS)
SET(CMAKE_CXX_FLAGS_RELEASE "/MT")
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
ELSE()
SET(CMAKE_CXX_FLAGS_RELEASE "/MD")
SET(CMAKE_CXX_FLAGS_DEBUG "/MDd")
ENDIF()
SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
SET(CMAKE_ENABLE_EXPORTS ON)
SET(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
SET(UMSKT_EXE_WINDOWS_DLL src/windows/dllmain.cpp)
ENDIF()
if(UMSKT_USE_SHARED_OPENSSL)
set(OPENSSL_USE_STATIC_LIBS FALSE)
set(OPENSSL_MSVC_STATIC_RT FALSE)
else()
set(OPENSSL_USE_STATIC_LIBS TRUE)
set(OPENSSL_MSVC_STATIC_RT TRUE)
endif()
IF(MUSL_STATIC)
MESSAGE(STATUS "[UMSKT] Performing a fully static build using muslc")
SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
SET(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
ENDIF()
if(MUSL_STATIC AND NOT UMSKT_USE_SHARED_OPENSSL)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
# initalize cpm.CMake
INCLUDE(cmake/CPM.cmake)
include(cmake/CPM.cmake)
# fetch cpm.CMake dependencies
# Include JSON development library
CPMAddPackage(
NAME nlohmann_json
GITHUB_REPOSITORY nlohmann/json
VERSION 3.11.2
)
# Include fmt development library
CPMAddPackage(
NAME fmt
GITHUB_REPOSITORY fmtlib/fmt
@ -107,7 +68,6 @@ CPMAddPackage(
VERSION 10.0.0
)
# Include cmrc resource compiler
CPMAddPackage(
NAME cmrc
GITHUB_REPOSITORY vector-of-bool/cmrc
@ -115,63 +75,35 @@ CPMAddPackage(
VERSION 2.0.1
)
# Include Crypto++ development library
#CPMAddPackage(
# NAME cryptopp-cmake
# GITHUB_REPOSITORY abdes/cryptopp-cmake
# GIT_TAG CRYPTOPP_8_8_0
# VERSION 8.8.0
# OPTIONS "CRYPTOPP_BUILD_TESTING OFF"
#)
# For Emscripten builds, set CMAKE_TOOLCHAIN_FILE to the appropriate file
set(EMSCRIPTEN_BUILD OFF CACHE BOOL "Build for Emscripten" FORCE)
if(EMSCRIPTEN_BUILD)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/Emscripten.cmake" CACHE STRING "Emscripten toolchain file")
endif()
#include googletest unit testing library
#CPMAddPackage(
# NAME googletest
# GITHUB_REPOSITORY google/googletest
# VERSION 1.13.0
# OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
#)
### Resource compilation
CMRC_ADD_RESOURCE_LIBRARY(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json)
SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp src/libumskt/pidgen3/key.cpp src/libumskt/pidgen3/util.cpp src/libumskt/confid/confid.cpp src/libumskt/pidgen2/PIDGEN2.cpp src/libumskt/debugoutput.cpp)
set(LIBUMSKT_SRC
src/libumskt/libumskt.cpp
src/libumskt/pidgen3/BINK1998.cpp
src/libumskt/pidgen3/BINK2002.cpp
src/libumskt/pidgen3/key.cpp
src/libumskt/pidgen3/util.cpp
src/libumskt/confid/confid.cpp
src/libumskt/pidgen2/PIDGEN2.cpp
src/libumskt/debugoutput.cpp
)
#### Separate Build Path for emscripten
IF (EMSCRIPTEN)
ADD_EXECUTABLE(umskt ${LIBUMSKT_SRC})
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(umskt -static OpenSSL::Crypto cryptopp::cryptopp fmt)
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
if(UMSKT_USE_SHARED_OPENSSL)
add_library(_umskt SHARED ${LIBUMSKT_SRC})
else()
add_library(_umskt STATIC ${LIBUMSKT_SRC})
endif()
SET_TARGET_PROPERTIES(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
SET_TARGET_PROPERTIES(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
ELSE()
IF(NOT UMSKT_USE_SHARED_OPENSSL)
### Static library compilation
ADD_LIBRARY(_umskt STATIC ${LIBUMSKT_SRC})
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(_umskt -static OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
ELSE()
### Shared library compilation
ADD_LIBRARY(_umskt SHARED ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(_umskt OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
TARGET_LINK_DIRECTORIES(_umskt PUBLIC ${UMSKT_LINK_DIRS})
ENDIF()
target_include_directories(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
target_link_libraries(_umskt PRIVATE OpenSSL::Crypto fmt)
### UMSKT executable compilation
ADD_EXECUTABLE(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(umskt _umskt OpenSSL::Crypto fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
IF(MSVC AND MSVC_MSDOS_STUB)
SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
ENDIF()
add_executable(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
### Copy Shared Libraries and dependency files
IF (OPENSSL_CRYPTO_SHARED)
GET_FILENAME_COMPONENT(OPENSSL_CRYPTO_LIBRARY_FILENAME ${OPENSSL_CRYPTO_LIBRARY} NAME)
CONFIGURE_FILE(${OPENSSL_CRYPTO_LIBRARY} "${CMAKE_CURRENT_BINARY_DIR}/${OPENSSL_CRYPTO_LIBRARY_FILENAME}" COPYONLY)
ENDIF()
ENDIF()
target_include_directories(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
target_link_libraries(umskt PRIVATE _umskt OpenSSL::Crypto fmt nlohmann_json::nlohmann_json umskt::rc)

View File

@ -1,17 +1,22 @@
# **Universal MS Key Toolkit (UMSKT)**
# Universal MS Key Toolkit (UMSKT)
**Connect with us**
[![Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://umskt.zulipchat.com)
[![libera.chat - #mspid](https://img.shields.io/badge/libera.chat-%23mspid-brightgreen)](https://web.libera.chat/gamja/?nick=Guest?#mspid)
**Build status**
[![C/C++ CI (Linux)](https://github.com/UMSKT/UMSKT/actions/workflows/linux.yml/badge.svg)](../../actions/workflows/linux.yml)
[![C/C++ CI (Windows)](https://github.com/UMSKT/UMSKT/actions/workflows/windows.yml/badge.svg)](../../actions/workflows/windows.yml)
[![C/C++ CI (macOS)](https://github.com/UMSKT/UMSKT/actions/workflows/macos.yml/badge.svg)](../../actions/workflows/macos.yml)
[![C/C++ CI (DOS DJGPP)](https://github.com/UMSKT/UMSKT/actions/workflows/dos-djgpp.yml/badge.svg)](../../actions/workflows/freebsd.yml)
[![C/C++ CI (FreeBSD)](https://github.com/UMSKT/UMSKT/actions/workflows/freebsd.yml/badge.svg)](../../actions/workflows/dos-djgpp.yml)
### **Plan of Action / ToDo List**
Plan of Action / ToDo List
In light of the recent exponential interest in this project I've decided to put updates of this project here:
* [Please see ticket #8 for more information](../../issues/8)
Please see ticket #8 for more information
------
@ -31,25 +36,25 @@ In light of the recent exponential interest in this project I've decided to put
### **Usage**
#### 1. Download the latest version of WindowsXPKg
#### 1. Download the latest version of UMSKT
* *(GitHub account required)*
* Download the latest experimental version using the Actions tab ([Windows](../../actions/workflows/windows.yml?query=branch%3Amaster), [Linux](../../actions/workflows/linux.yml?query=branch%3Amaster)).
* Download the latest experimental version using the Actions tab ([Windows](../../actions/workflows/windows.yml?query=branch%3Amaster), [Linux](../../actions/workflows/linux.yml?query=branch%3Amaster)), [macOS](../../actions/workflows/macos.yml?query=branch%3Amaster), [FreeBSD](../../actions/workflows/freebsd.yml?query=branch%3Amaster), [DOS DJGPP](../../actions/workflows/.yml?qudos-djgppery=branch%3Amaster))
* *(GitHub account \*not\* required)*
* Download the latest release for your operating system and architecture from [the releases page](../../releases)
* **Note:** Before continuing, please ensure you have both the `xpkey` program and the `keys.json` datum extracted and in the same directory
* **Note:** Before continuing, please ensure you have the `umskt` executable extracted.
#### 2. Run `xpkey` to generate a key, or add `--help` to see more options.
#### 2. Run `umskt` to generate a key, or add `--help` to see more options.
#### 3. *(Activation step for `Retail` and `OEM` only)*
* After installation, you will be prompted to activate Windows.
* Select the **telephone activation** method, then, run `xpkey -i <Installation ID>` using the `Installation ID` the activation Wizard provides for you
* Select the **telephone activation** method, then, run `umskt -i <Installation ID>` using the `Installation ID` the activation Wizard provides for you
#### 4. Profit!
@ -92,4 +97,4 @@ The list of people who have helped to bring the XP generation to where it is now
| Language | Author | Repo URL |
|----------|-----------|-------------------------------------------------------|
| Rust | Alex Page | [anpage/umskt-rs](https://github.com/anpage/umskt-rs) |
| Python | techguy16 | No URL yet |

View File

@ -241,7 +241,7 @@ void CLI::printID(DWORD *pid) {
int i, digit = 0;
// Convert PID to ascii-number (=raw)
sprintf(raw, "%09u", pid[0]);
snprintf(raw, sizeof(raw), "%09u", pid[0]);
// Make b-part {640-....}
strncpy(b, raw, 3);