Skip to content
Open
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
84 changes: 84 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: libuncso2-${{ matrix.c_compiler }}-${{ matrix.os }}
path: build/

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}/tests
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
#run: ./ci/test.ps1
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,25 @@
# Generated documentation
/docs

# VSCode configs
# VS Code settings
/.vscode
/.cache

# Visual Studio work directory
/.vs/
# Visual Studio build directory
/out/

# CMake build directory
/build

# AppImage executables
*.AppImage

/CMakeUserPresets.json

# Arch Linux
/.SRCINFO
/src
/pkg
*.tar.zst
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
[submodule "external/catch2"]
path = external/catch2
url = https://github.com/catchorg/Catch2
[submodule "external/cryptopp-cmake"]
path = external/cryptopp-cmake
url = https://github.com/noloader/cryptopp-cmake/
[submodule "external/cryptopp"]
path = external/cryptopp
url = https://github.com/weidai11/cryptopp
[submodule "external/gsl-lite"]
path = external/gsl-lite
url = https://github.com/martinmoene/gsl-lite
[submodule "external/cryptopp-cmake"]
path = external/cryptopp-cmake
url = https://github.com/abdes/cryptopp-cmake.git
69 changes: 15 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13.0)
cmake_minimum_required(VERSION 3.13)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
Expand Down Expand Up @@ -31,9 +31,6 @@ endif()
#
option(PKG_BUILD_SHARED "Build libuncso2 as a shared library" ON)
option(PKG_BUILD_TESTS "Build tests" ${PKG_IS_STANDALONE})
option(PKG_DEPS_AS_SHARED_LIBS
"Build libuncso2 dependencies as shared libraries" ON)
option(PKG_USE_CLANG_FSAPI "Use libc++fs when available" OFF)

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")

Expand All @@ -48,7 +45,6 @@ set(PKG_GENERATED_DIR "${CMAKE_BINARY_DIR}/generated")

set(PKG_LIB_CRYPTOPP_DIR "${PKG_LIBS_DIR}/cryptopp")
set(PKG_LIB_CRYPTOPP_CMAKE_DIR "${PKG_LIBS_DIR}/cryptopp-cmake")
set(PKG_LIB_GSL_DIR "${PKG_LIBS_DIR}/gsl-lite")
set(PKG_LIB_LZMA_DIR "${PKG_LIBS_DIR}/lzma")

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand All @@ -69,29 +65,8 @@ generate_libuc2_version(VERSION_FILE
# Dependencies
#

# Setup Crypto++'s CMake files
configure_file("${PKG_LIB_CRYPTOPP_CMAKE_DIR}/CMakeLists.txt"
"${PKG_LIB_CRYPTOPP_DIR}/" COPYONLY)
configure_file("${PKG_LIB_CRYPTOPP_CMAKE_DIR}/cryptopp-config.cmake"
"${PKG_LIB_CRYPTOPP_DIR}/" COPYONLY)

# Disable Crypto++ testing
set(BUILD_TESTING FALSE CACHE BOOL "" FORCE)

# Only build Crypto++ either static or shared libraries
if(NOT MSVC)
if(PKG_DEPS_AS_SHARED_LIBS)
# set(BUILD_STATIC FALSE CACHE BOOL "" FORCE)
else()
set(BUILD_SHARED FALSE CACHE BOOL "" FORCE)
endif()
else()
# Don't build FIPS DLL
set(BUILD_SHARED FALSE CACHE BOOL "" FORCE)
endif()

add_subdirectory("${PKG_LIB_CRYPTOPP_DIR}")
set(CryptoPP_INCLUDE_DIRS "${PKG_LIB_CRYPTOPP_DIR}")
set(CRYPTOPP_SOURCES "${PKG_LIB_CRYPTOPP_DIR}")
add_subdirectory("${PKG_LIB_CRYPTOPP_CMAKE_DIR}")

# Enable weak namespace for MD5
add_definitions(-DCRYPTOPP_ENABLE_NAMESPACE_WEAK=1)
Expand Down Expand Up @@ -170,7 +145,7 @@ source_group("Source Files" FILES ${PKG_SOURCES_BASE})
source_group("Public Header Files" FILES ${PKG_PUBLIC_HEADERS_BASE})
source_group("Header Files" FILES ${PKG_HEADERS_BASE})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
Expand All @@ -194,7 +169,7 @@ set_target_properties(uncso2 PROPERTIES VERSION ${LIB_VERSION})
# Enable all warnings
#
if(MSVC)
target_compile_options(uncso2 PRIVATE /W4)
target_compile_options(uncso2 PRIVATE /DWIN32 /D_WINDOWS /W4 /EHsc)
else()
target_compile_options(uncso2 PRIVATE -Wall -Wextra -pedantic)
endif()
Expand All @@ -205,10 +180,8 @@ endif()
target_include_directories(uncso2 PRIVATE "headers")
target_include_directories(uncso2 PRIVATE "${PKG_PUBLIC_HEADERS_DIR}")

target_include_directories(uncso2
PRIVATE "${LZMA_INCLUDE_DIR}"
"${CryptoPP_INCLUDE_DIRS}"
"${PKG_LIB_GSL_DIR}/include")
target_include_directories(uncso2 PRIVATE "external")
target_include_directories(uncso2 PRIVATE "${LZMA_INCLUDE_DIR}")

# the generated version header's directory
target_include_directories(uncso2 PRIVATE ${PKG_GENERATED_DIR})
Expand All @@ -217,26 +190,7 @@ target_include_directories(uncso2 PRIVATE ${PKG_GENERATED_DIR})
# Setup library directories
#

if(PKG_USE_CLANG_FSAPI)
message(STATUS "libuncso2: Using libc++fs")
target_link_libraries(uncso2 c++fs)
elseif(NOT MSVC)
message(STATUS "libuncso2: Using stdlibc++fs")
target_link_libraries(uncso2 stdc++fs)
endif()

if(NOT MSVC)
if(PKG_DEPS_AS_SHARED_LIBS)
target_link_libraries(uncso2 cryptopp-shared)
else()
target_link_libraries(uncso2 cryptopp-static)
endif()
else()
# Don't use FIPS DLL
target_link_libraries(uncso2 cryptopp-static)
endif()

target_link_libraries(uncso2 lzma)
target_link_libraries(uncso2 lzma cryptopp)

#
# Set include directory for dependent projects
Expand All @@ -256,3 +210,10 @@ if(PKG_BUILD_TESTS)
message("libuncso2: Building tests")
add_subdirectory(tests)
endif()

#
# Installation rules
#

install(TARGETS uncso2 DESTINATION lib)
install(DIRECTORY ${PKG_PUBLIC_HEADERS_ROOT_DIR}/ DESTINATION include/libuncso2)
41 changes: 41 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pkgname=libuncso2
pkgver=1.2.0
pkgrel=1
pkgdesc="Backend for UnCSO2"
arch=(any)
url="https://github.com/harmonytf/libuncso2"
license=(GPL-3.0-only)
makedepends=(cmake)
source=()
_sourcedir="$pkgname"

prepare() {
ln -snf "$startdir" "$srcdir"
}

build() {
cmake -B build -S "$_sourcedir" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/usr \
-Wno-dev
cmake --build build
}

check() {
ctest --test-dir "$_sourcedir/build/tests" --build-config RelWithDebInfo --output-on-failure
}

package() {
DESTDIR="$pkgdir" cmake --install build
install -Dm644 "$_sourcedir/COPYING" -t "$pkgdir/usr/share/licenses/$pkgname"

rm -rf "$pkgdir/usr/bin/cryptest"
rm -rf "$pkgdir/usr/include/cryptopp"
rm -rf "$pkgdir/usr/lib/libcryptopp.a"
rm -rf "$pkgdir/usr/share/cmake"
rm -rf "$pkgdir/usr/share/cryptopp"
rm -rf "$pkgdir/usr/share/pkgconfig/cryptopp.pc"

rm -rf "$pkgdir/usr/bin"
rm -rf "$pkgdir/usr/share/pkgconfig"
}
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# libuncso2

[![GitHub License](https://img.shields.io/github/license/harmonytf/libuncso2)](https://raw.githubusercontent.com/harmonytf/libuncso2/master/COPYING)
[![GitHub Release](https://img.shields.io/github/v/release/harmonytf/libuncso2)](https://github.com/harmonytf/libuncso2/releases/latest)
[![AUR Version](https://img.shields.io/aur/version/libuncso2?logo=archlinux)](https://aur.archlinux.org/packages/libuncso2)
[![AUR-BIN Version](https://img.shields.io/aur/version/libuncso2-bin?logo=archlinux&label=aur-bin)](https://aur.archlinux.org/packages/libuncso2-bin)

A library to decrypt and parse PKG files used by Nexon's videogame Counter-Strike Online 2.

PKG is an encrypted archive file format used in Counter-Strike Online 2 and Titanfall Online to store the games' file data.

It's based on the ekey's reversing work of at [XeNTaX's forums](https://forum.xentax.com/viewtopic.php?f=21&t=11117).

Used as the back-end for the GUI program [UnCSO2](https://github.com/L-Leite/UnCSO2).
Used as the back-end for the GUI program [UnCSO2](https://github.com/harmonytf/UnCSO2).

Tested on:
- GNU/Linux - GCC 8.3.0 (32 and 64 bits)
- GNU/Linux - Clang 8.0.0 (32 and 64 bits)
- Windows 10 - MSVC 2017 (32 and 64 bits)

- GNU/Linux - GCC 15.2.1 (64 bits)
- GNU/Linux - Clang 21.1.4 (64 bits)
- Windows 10 - MSVC 2022 (64 bits)

## Features

Expand All @@ -20,10 +26,6 @@ Tested on:
- Decrypt '.e*' files, such as files with .etxt, .escv or .ecfg extensions.
- Decompress LZMA deflated textures.

## Build status

[![Build status](https://ci.appveyor.com/api/projects/status/oygibb8s9c3xxdba/branch/master?svg=true)](https://ci.appveyor.com/project/L-Leite/libuncso2/branch/master)

## Examples

Decrypting and parsing a PKG file, then, extract its entries to the disk:
Expand Down Expand Up @@ -188,8 +190,8 @@ add_subdirectory("libuncso2")
file(GLOB SOMEAPP_ALL_SOURCES
"main.cpp")

# C++17 is required
set(CMAKE_CXX_STANDARD 17)
# C++20 is required
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(someapp ${SOMEAPP_ALL_SOURCES})
Expand All @@ -204,7 +206,6 @@ libuncso2 uses the following libraries:

- [Catch2](https://github.com/catchorg/Catch2) (used in the test application), Boost Software License.
- [Crypto++](https://www.cryptopp.com/), Public domain.
- [GSL Lite](https://github.com/martinmoene/gsl-lite), MIT license.
- [LZMA SDK](https://www.7-zip.org/sdk.html), Public domain.

## License
Expand Down
40 changes: 0 additions & 40 deletions appveyor.yml

This file was deleted.

Loading