From 9c387a874df282754ac90e36106e27785cf32538 Mon Sep 17 00:00:00 2001 From: hugsy Date: Mon, 13 Nov 2023 10:51:52 -0800 Subject: [PATCH 01/16] modules work ! --- CMakeLists.txt | 2 +- Modules/Common/CMakeLists.txt | 11 +++++++++-- Modules/Common/Include/Common.ixx | 4 ++++ Modules/Common/Source/Common.cxx | 9 +++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 Modules/Common/Include/Common.ixx create mode 100644 Modules/Common/Source/Common.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index a56a6fc..72e527b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.26) +cmake_minimum_required(VERSION 3.28) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/Modules/Common/CMakeLists.txt b/Modules/Common/CMakeLists.txt index c9ff710..f9eb629 100644 --- a/Modules/Common/CMakeLists.txt +++ b/Modules/Common/CMakeLists.txt @@ -18,9 +18,16 @@ set(SOURCE_FILES # # Create and build the target static library # -add_library(${PROJECT_NAME} STATIC) +add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) add_library(PWN::Common ALIAS ${PROJECT_NAME}) -target_sources(${PROJECT_NAME} PRIVATE ${SOURCE_FILES}) + +target_sources(${PROJECT_NAME} + PRIVATE + FILE_SET CXX_MODULES FILES + + ${INTERFACE_DIR}/Common.ixx + ${SOURCE_DIR}/Common.cxx +) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) target_include_directories(${PROJECT_NAME} PUBLIC ${INTERFACE_DIR} PRIVATE ${HEADER_DIR}) diff --git a/Modules/Common/Include/Common.ixx b/Modules/Common/Include/Common.ixx new file mode 100644 index 0000000..fb64be8 --- /dev/null +++ b/Modules/Common/Include/Common.ixx @@ -0,0 +1,4 @@ +export module common; + +export void +test(); diff --git a/Modules/Common/Source/Common.cxx b/Modules/Common/Source/Common.cxx new file mode 100644 index 0000000..043f000 --- /dev/null +++ b/Modules/Common/Source/Common.cxx @@ -0,0 +1,9 @@ +module; +#include +module common; + +void +test() +{ + std::cout << "test modules\n"; +} From 46483d476a870b5590c0c715a773baaa6832b0b6 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 16 Dec 2023 12:29:51 -0800 Subject: [PATCH 02/16] try upgrade cmake via winget --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a227fff..a180720 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,7 @@ jobs: echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append Import-Module .\.github\Invoke-VisualStudio.ps1 Invoke-VisualStudio2022${{ matrix.variants.arch }} + winget upgrade Kitware.CMake - name: Setup environment variables (Linux) if: matrix.variants.os == 'ubuntu-latest' From 00814bbe8d7e2544fe221a57944a599351e3531e Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 16 Dec 2023 12:30:41 -0800 Subject: [PATCH 03/16] revert --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a180720..a227fff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,7 +54,6 @@ jobs: echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append Import-Module .\.github\Invoke-VisualStudio.ps1 Invoke-VisualStudio2022${{ matrix.variants.arch }} - winget upgrade Kitware.CMake - name: Setup environment variables (Linux) if: matrix.variants.os == 'ubuntu-latest' From 754f87c4f5ed4b396287658416efdc59fdd374ee Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Tue, 16 Jan 2024 11:51:03 -0800 Subject: [PATCH 04/16] force newer cmake --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a227fff..33fe626 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,8 @@ jobs: echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append Import-Module .\.github\Invoke-VisualStudio.ps1 Invoke-VisualStudio2022${{ matrix.variants.arch }} + choco install winget + winget upgrade Kitware.CMake - name: Setup environment variables (Linux) if: matrix.variants.os == 'ubuntu-latest' @@ -62,6 +64,13 @@ jobs: wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh chmod +x /tmp/llvm.sh sudo /tmp/llvm.sh 17 + sudo apt remove --purge --auto-remove cmake + sudo apt install -y software-properties-common lsb-release + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null + sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" + sudo apt update + sudo apt install kitware-archive-keyring + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 sudo apt update && sudo apt install -y cmake doxygen clang-17 libc++abi-17-dev libc++-17-dev llvm-17-dev nasm echo "NB_CPU=$(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV echo "CC=clang-17" >> $GITHUB_ENV From 24e5fd219a81d03996a0323f374ad822a4ef7e14 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Thu, 18 Jan 2024 17:16:09 -0800 Subject: [PATCH 05/16] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 33fe626..ef69c36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,7 +109,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja - name: Build pwn++ library run: | From 1d61b1f178564fbdea7dbeac9bf088cd62059ea9 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Thu, 18 Jan 2024 17:18:35 -0800 Subject: [PATCH 06/16] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef69c36..6e092c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,7 +109,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} - name: Build pwn++ library run: | From 6b735ad07307531c5537fe2887b4f493772c91ae Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Thu, 18 Jan 2024 17:20:44 -0800 Subject: [PATCH 07/16] Update build.yml --- .github/workflows/build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e092c7..4b023d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,12 @@ env: VERBOSE: "1" on: - push: - pull_request: workflow_dispatch: + pull_request: + push: + branches: + - main + jobs: build: @@ -109,7 +112,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_MAKE_PROGRAM=make - name: Build pwn++ library run: | From c0d1c1f25f73dfdf8c7b5bc3f4b172fd0fbd3a3e Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Thu, 18 Jan 2024 17:23:21 -0800 Subject: [PATCH 08/16] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f6c1ab..59d460f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -106,7 +106,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja -DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_C_COMPILER=${CC} -DCMAKE_MAKE_PROGRAM=make + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} - name: Build pwn++ library run: | From d4e6ef5a7ef070d74392e16497630af1dbf4197c Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Mon, 12 Feb 2024 09:15:28 -0800 Subject: [PATCH 09/16] [ci] upgrade cmake --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59d460f..17d4d72 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,8 +56,7 @@ jobs: echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append Import-Module .\.github\Invoke-VisualStudio.ps1 Invoke-VisualStudio2022${{ matrix.variants.arch }} - choco install winget - winget upgrade Kitware.CMake + choco install cmake --pre - name: Setup environment variables (Linux) if: matrix.variants.os == 'ubuntu-latest' From 0f0ea1516ed9b0ef6a4e76d39027f9d6ab704b61 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 9 Mar 2024 09:50:18 -0800 Subject: [PATCH 10/16] remove choco cmd in ci --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17d4d72..de27379 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,6 @@ jobs: echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append Import-Module .\.github\Invoke-VisualStudio.ps1 Invoke-VisualStudio2022${{ matrix.variants.arch }} - choco install cmake --pre - name: Setup environment variables (Linux) if: matrix.variants.os == 'ubuntu-latest' From c403d89580b935155fcdb7b61bf5fb5be92eed5c Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 9 Mar 2024 09:52:44 -0800 Subject: [PATCH 11/16] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de27379..97c0d27 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,7 +104,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja - name: Build pwn++ library run: | From 2b9eb8da9fbe2601fde5cdc518a1ca5a49f50041 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sat, 9 Mar 2024 09:55:15 -0800 Subject: [PATCH 12/16] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97c0d27..9a5fa91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,6 +104,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | + sudo apt install -y ninja-build cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja - name: Build pwn++ library From 6ebaf326257fd0aa64681df05aba945dff154e10 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 10 Mar 2024 10:01:27 -0700 Subject: [PATCH 13/16] Update build.yml --- .github/workflows/build.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a5fa91..fd6978d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,13 +64,6 @@ jobs: wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh chmod +x /tmp/llvm.sh sudo /tmp/llvm.sh 17 - sudo apt remove --purge --auto-remove cmake - sudo apt install -y software-properties-common lsb-release - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null - sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" - sudo apt update - sudo apt install kitware-archive-keyring - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 sudo apt update && sudo apt install -y cmake doxygen clang-17 libc++abi-17-dev libc++-17-dev llvm-17-dev nasm echo "NB_CPU=$(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV echo "CC=clang-17" >> $GITHUB_ENV @@ -78,7 +71,6 @@ jobs: - name: Prepare common environment run: | - mkdir build mkdir artifact - name: Prepare Windows environment From bf7256434cd3862d72ee37cccb846955c597b12f Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 10 Mar 2024 10:02:03 -0700 Subject: [PATCH 14/16] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd6978d..bf49082 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,6 @@ env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} PROJECT_NAME: "pwn++" REPO: hugsy/pwn-- - VERBOSE: "1" on: workflow_dispatch: @@ -19,6 +18,7 @@ jobs: env: CMAKE_FLAGS: '-DPWN_BUILD_DOCS=OFF -DPWN_DISASSEMBLE_X86=ON -DPWN_DISASSEMBLE_ARM64=ON -DPWN_BUILD_TOOLKIT=ON -DPWN_BUILD_TESTING=ON' NB_CPU: 1 + VERBOSE: 1 strategy: fail-fast: false From abe9396c3e4602c8261e246320259a6063191014 Mon Sep 17 00:00:00 2001 From: crazy hugsy Date: Sun, 10 Mar 2024 10:05:29 -0700 Subject: [PATCH 15/16] plop --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf49082..ed81390 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,8 +96,7 @@ jobs: - name: Initialize cmake (Linux) if: matrix.variants.os == 'ubuntu-latest' run: | - sudo apt install -y ninja-build - cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} -G Ninja + cmake -S . -B ./build ${{ env.CMAKE_FLAGS }} - name: Build pwn++ library run: | From 6eae818d9d6d17e78172f1bdd3afcadf7f8e7ac6 Mon Sep 17 00:00:00 2001 From: hugsy Date: Sat, 10 Aug 2024 10:45:01 -0700 Subject: [PATCH 16/16] starting pwn.ixx module, disabled everything but common --- CMakeLists.txt | 31 +++--- Modules/Common/CMakeLists.txt | 12 +-- Modules/Common/Include/Common.ixx | 4 - Modules/Common/Source/Common.cxx | 20 +++- pwn++/CMakeLists.txt | 6 +- pwn++/Include/pwn.ixx | 163 ++++++++++++++++++++++++++++++ pwn++/Source/Win32/dllmain.cpp | 17 ++-- pwn++/pwn.hpp.in | 159 ++++++++++++++++------------- 8 files changed, 309 insertions(+), 103 deletions(-) delete mode 100644 Modules/Common/Include/Common.ixx create mode 100644 pwn++/Include/pwn.ixx diff --git a/CMakeLists.txt b/CMakeLists.txt index c8876a1..cc005c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) # pwn++ is NOT a top dir (i.e. build as dependency) option(PWN_BUILD_TOOLKIT "Compile the executables of pwn++ toolkit" OFF) option(PWN_BUILD_TESTING "Compile the test suite" OFF) + option(PWN_BUILD_MODULE_CRYPTO "Compile the crypto module (requires m4)" OFF) option(PWN_BUILD_DOCS "Generate the Doxygen API files" OFF) else() # pwn++ is a top dir @@ -51,21 +52,21 @@ if(WIN32) # Listed by dependency order Common - Crypto - Network - Symbols - System - Security - Registry - Service - Shellcode + # Crypto + # Network + # Symbols + # System + # Security + # Registry + # Service + # Shellcode - FileSystem - Process - Remote + # FileSystem + # Process + # Remote - Binary - CTF + # Binary + # CTF # TODO : ideas for future modules # - WTS @@ -97,7 +98,9 @@ else() set(CMAKE_INTERPROCEDURAL_OPTIMIZATION True) endif() -find_package(MkCLib REQUIRED) +if(PWN_BUILD_MODULE_CRYPTO) + find_package(MkCLib REQUIRED) +endif(PWN_BUILD_MODULE_CRYPTO) if(PWN_DISASSEMBLE_X86) find_package(Zydis REQUIRED) diff --git a/Modules/Common/CMakeLists.txt b/Modules/Common/CMakeLists.txt index f8a0603..c71f7b9 100644 --- a/Modules/Common/CMakeLists.txt +++ b/Modules/Common/CMakeLists.txt @@ -8,11 +8,11 @@ set(HEADER_DIR ${SOURCE_DIR}/Include) set(SOURCE_FILES - ${SOURCE_DIR}/Architecture.cpp - ${SOURCE_DIR}/Context.cpp - ${SOURCE_DIR}/Error.cpp - ${SOURCE_DIR}/Log.cpp - ${SOURCE_DIR}/Utils.cpp + # ${SOURCE_DIR}/Architecture.cpp + # ${SOURCE_DIR}/Context.cpp + # ${SOURCE_DIR}/Error.cpp + # ${SOURCE_DIR}/Log.cpp + # ${SOURCE_DIR}/Utils.cpp ) # @@ -24,7 +24,7 @@ target_sources(${PROJECT_NAME} PRIVATE FILE_SET CXX_MODULES FILES - ${INTERFACE_DIR}/Common.ixx + # ${INTERFACE_DIR}/Common.ixx ${SOURCE_DIR}/Common.cxx ) diff --git a/Modules/Common/Include/Common.ixx b/Modules/Common/Include/Common.ixx deleted file mode 100644 index fb64be8..0000000 --- a/Modules/Common/Include/Common.ixx +++ /dev/null @@ -1,4 +0,0 @@ -export module common; - -export void -test(); diff --git a/Modules/Common/Source/Common.cxx b/Modules/Common/Source/Common.cxx index 043f000..e7453c6 100644 --- a/Modules/Common/Source/Common.cxx +++ b/Modules/Common/Source/Common.cxx @@ -1,8 +1,24 @@ module; #include -module common; +export module pwn.common; -void +export using u8 = std::uint8_t; +export using u16 = std::uint16_t; +export using u32 = std::uint32_t; +export using u64 = std::uint64_t; +export using i8 = std::int8_t; +export using i16 = std::int16_t; +export using i32 = std::int32_t; +export using i64 = std::int64_t; +#ifdef _M_IX86 +export using usize = unsigned long; +#else +export using usize = std::size_t; +#endif +export using ssize = std::intptr_t; +export using uptr = std::uintptr_t; + +export void test() { std::cout << "test modules\n"; diff --git a/pwn++/CMakeLists.txt b/pwn++/CMakeLists.txt index 3b58658..5f20240 100644 --- a/pwn++/CMakeLists.txt +++ b/pwn++/CMakeLists.txt @@ -14,7 +14,7 @@ set(PWN_BUILD_OS ${CMAKE_SYSTEM_NAME}) set(PWN_MODULES_AS_STRING "") foreach(MODULE ${PWN_MODULES}) - set(PWN_MODULES_AS_STRING "L\"${MODULE}\",${PWN_MODULES_AS_STRING}") + set(PWN_MODULES_AS_STRING "\"${MODULE}\",${PWN_MODULES_AS_STRING}") endforeach() set(INTERFACE_DIR ${PROJECT_SOURCE_DIR}/Include) @@ -30,10 +30,12 @@ endif() message(STATUS "Generating pwn++ main header") list(TRANSFORM PWN_MODULES PREPEND PWN:: OUTPUT_VARIABLE MODULE_NAMESPACES) list(LENGTH MODULE_NAMESPACES PWN_MODULES_LENGTH) -configure_file(${PROJECT_SOURCE_DIR}/pwn.hpp.in ${INTERFACE_DIR}/pwn NEWLINE_STYLE WIN32) +# configure_file(${PROJECT_SOURCE_DIR}/pwn.hpp.in ${INTERFACE_DIR}/pwn NEWLINE_STYLE WIN32) +configure_file(${PROJECT_SOURCE_DIR}/pwn.hpp.in ${INTERFACE_DIR}/pwn.ixx NEWLINE_STYLE WIN32) if(MSVC) target_sources(${PROJECT_NAME} PRIVATE ${SOURCE_DIR}/Win32/dllmain.cpp) + target_sources(${PROJECT_NAME} PRIVATE FILE_SET CXX_MODULES FILES ${INTERFACE_DIR}/pwn.ixx) target_link_options( ${PROJECT_NAME} diff --git a/pwn++/Include/pwn.ixx b/pwn++/Include/pwn.ixx new file mode 100644 index 0000000..a42b1cd --- /dev/null +++ b/pwn++/Include/pwn.ixx @@ -0,0 +1,163 @@ +module; + +/** + * Include non-module, locally only + */ +#include +#include + +/** + * Export module `pwn` + */ +export module pwn; + +/** + * Re-export submodules + */ +export import pwn.common; + +/** + * Additional imports + */ +import std; + +// // clang-format off +// #include "Common.hpp" +// #include "Architecture.hpp" +// #include "Log.hpp" +// #include "Literals.hpp" +// #include "Formatters.hpp" +// #include "Utils.hpp" +// #include "Handle.hpp" +// #include "Context.hpp" + +// #include "Crypto.hpp" + +// #ifdef PWN_INCLUDE_DISASSEMBLER +// #include "Disassembler.hpp" +// #endif // PWN_INCLUDE_DISASSEMBLER + +// #if defined(PWN_BUILD_FOR_WINDOWS) +// #include "Win32/Network.hpp" +// #include "Win32/FileSystem.hpp" +// #include "Win32/System.hpp" +// #include "Win32/PE.hpp" +// #include "Win32/Network.hpp" +// #include "Win32/Job.hpp" +// #include "Win32/Process.hpp" +// #include "Win32/Thread.hpp" +// #include "Win32/Token.hpp" +// #include "Win32/ObjectManager.hpp" +// #include "Win32/System.hpp" +// #include "Win32/Service.hpp" +// #include "Win32/ALPC.hpp" +// #include "Win32/RPC.hpp" +// #include "Win32/API.hpp" +// #include "Win32/Symbols.hpp" +// #include "CTF/Win32/Remote.hpp" +// #include "CTF/Win32/Process.hpp" + +// #elif defined(PWN_BUILD_FOR_LINUX) + +// #include "CTF/Linux/Remote.hpp" +// #include "CTF/Linux/Process.hpp" + +// #else + +// #error "Unsupported OS" + +// #endif // PWN_BUILD_FOR_WINDOWS +// clang-format on + +namespace pwn +{ +// clang-format off +/// +///@brief +/// +export constexpr std::string_view LibraryName = "pwn++"; + +/// +///@brief +/// +export constexpr std::string_view LibraryAuthor = "hugsy"; + +/// +///@brief +/// +export constexpr std::string_view LibraryLicense = "MIT"; + +/// +///@brief +/// +export constexpr std::string_view LibraryBanner = "pwn++" " v" "0.1.3" " - " "Standalone"; +// clang-format on + +/// +///@brief pwn++ version information +/// +constexpr struct VersionType +{ + /// + ///@brief pwn++ major version + /// + const u8 Major; + + /// + ///@brief pwn++ minor version + /// + const u8 Minor; + + /// + ///@brief pwn++ patch information + /// + const u16 Patch; + + /// + ///@brief pwn++ release information + /// + const std::string_view Release; + + /// + ///@brief pwn++ complete version information as wstring + /// + const std::string_view VersionString; +} Version = { + // clang-format off + 0, + 1, + 3, + "Standalone", + "0.1.3", + // clang-format on +}; + +/// +///@brief +/// +constexpr struct HostInfo +{ + /// + ///@brief The host architecture pwn++ was built against + /// + const std::string_view Architecture; + + /// + ///@brief The host OS pwn++ was built against + /// + const std::string_view System; +} Host { + // clang-format off + "AMD64", + "Windows" + // clang-format on +}; +// clang-format off + +/// +///@brief A list of all modules built with pwn++ +/// +export constexpr std::array ModuleNames = {"Common",}; +// clang-format on + +} // namespace pwn diff --git a/pwn++/Source/Win32/dllmain.cpp b/pwn++/Source/Win32/dllmain.cpp index 9027116..6281de6 100644 --- a/pwn++/Source/Win32/dllmain.cpp +++ b/pwn++/Source/Win32/dllmain.cpp @@ -1,6 +1,9 @@ -#include +#include +import pwn; +import std; -using namespace pwn; + +// using namespace pwn; void OnAttachRoutine() @@ -8,7 +11,9 @@ OnAttachRoutine() // // Initialize the RNG // - Utils::Random::Seed(); + // Utils::Random::Seed(); + std::println("loading library {}, {}", pwn::LibraryName, pwn::LibraryBanner); + test(); } @@ -19,10 +24,10 @@ OnDetachRoutine() BOOL APIENTRY -DllMain(_In_ HMODULE hModule, _In_ DWORD ul_reason_for_call, _In_ LPVOID lpReserved) +DllMain(_In_ HMODULE /* hModule */, _In_ DWORD ul_reason_for_call, _In_ LPVOID /* lpReserved */) { - UnusedParameter(hModule); - UnusedParameter(lpReserved); + // UnusedParameter(hModule); + // UnusedParameter(lpReserved); switch ( ul_reason_for_call ) { diff --git a/pwn++/pwn.hpp.in b/pwn++/pwn.hpp.in index 99fcb20..723d969 100644 --- a/pwn++/pwn.hpp.in +++ b/pwn++/pwn.hpp.in @@ -1,51 +1,72 @@ -#pragma once - -// clang-format off -#include "Common.hpp" -#include "Architecture.hpp" -#include "Log.hpp" -#include "Literals.hpp" -#include "Formatters.hpp" -#include "Utils.hpp" -#include "Handle.hpp" -#include "Context.hpp" - -#include "Crypto.hpp" - -#ifdef PWN_INCLUDE_DISASSEMBLER -#include "Disassembler.hpp" -#endif // PWN_INCLUDE_DISASSEMBLER - -#if defined(PWN_BUILD_FOR_WINDOWS) -#include "Win32/Network.hpp" -#include "Win32/FileSystem.hpp" -#include "Win32/System.hpp" -#include "Win32/PE.hpp" -#include "Win32/Network.hpp" -#include "Win32/Job.hpp" -#include "Win32/Process.hpp" -#include "Win32/Thread.hpp" -#include "Win32/Token.hpp" -#include "Win32/ObjectManager.hpp" -#include "Win32/System.hpp" -#include "Win32/Service.hpp" -#include "Win32/ALPC.hpp" -#include "Win32/RPC.hpp" -#include "Win32/API.hpp" -#include "Win32/Symbols.hpp" -#include "CTF/Win32/Remote.hpp" -#include "CTF/Win32/Process.hpp" - -#elif defined(PWN_BUILD_FOR_LINUX) - -#include "CTF/Linux/Remote.hpp" -#include "CTF/Linux/Process.hpp" - -#else - -#error "Unsupported OS" - -#endif // PWN_BUILD_FOR_WINDOWS +module; + +/** + * Include non-module, locally only + */ +#include +#include + +/** + * Export module `pwn` + */ +export module pwn; + +/** + * Re-export submodules + */ +export import pwn.common; + +/** + * Additional imports + */ +import std; + +// // clang-format off +// #include "Common.hpp" +// #include "Architecture.hpp" +// #include "Log.hpp" +// #include "Literals.hpp" +// #include "Formatters.hpp" +// #include "Utils.hpp" +// #include "Handle.hpp" +// #include "Context.hpp" + +// #include "Crypto.hpp" + +// #ifdef PWN_INCLUDE_DISASSEMBLER +// #include "Disassembler.hpp" +// #endif // PWN_INCLUDE_DISASSEMBLER + +// #if defined(PWN_BUILD_FOR_WINDOWS) +// #include "Win32/Network.hpp" +// #include "Win32/FileSystem.hpp" +// #include "Win32/System.hpp" +// #include "Win32/PE.hpp" +// #include "Win32/Network.hpp" +// #include "Win32/Job.hpp" +// #include "Win32/Process.hpp" +// #include "Win32/Thread.hpp" +// #include "Win32/Token.hpp" +// #include "Win32/ObjectManager.hpp" +// #include "Win32/System.hpp" +// #include "Win32/Service.hpp" +// #include "Win32/ALPC.hpp" +// #include "Win32/RPC.hpp" +// #include "Win32/API.hpp" +// #include "Win32/Symbols.hpp" +// #include "CTF/Win32/Remote.hpp" +// #include "CTF/Win32/Process.hpp" + +// #elif defined(PWN_BUILD_FOR_LINUX) + +// #include "CTF/Linux/Remote.hpp" +// #include "CTF/Linux/Process.hpp" + +// #else + +// #error "Unsupported OS" + +// #endif // PWN_BUILD_FOR_WINDOWS // clang-format on namespace pwn @@ -54,81 +75,81 @@ namespace pwn /// ///@brief /// -constexpr std::wstring_view LibraryName = L"@PWN_LIBRARY_NAME@"; +export constexpr std::string_view LibraryName = "@PWN_LIBRARY_NAME@"; /// ///@brief /// -constexpr std::wstring_view LibraryAuthor = L"@PWN_LIBRARY_AUTHOR@"; +export constexpr std::string_view LibraryAuthor = "@PWN_LIBRARY_AUTHOR@"; /// ///@brief /// -constexpr std::wstring_view LibraryLicense = L"@PWN_LIBRARY_LICENSE@"; +export constexpr std::string_view LibraryLicense = "@PWN_LIBRARY_LICENSE@"; /// ///@brief /// -constexpr std::wstring_view LibraryBanner = L"@PWN_LIBRARY_NAME@" L" v" L"@PWN_LIBRARY_VERSION@" L" - " L"@PWN_LIBRARY_VERSION_RELEASE@"; +export constexpr std::string_view LibraryBanner = "@PWN_LIBRARY_NAME@" " v" "@PWN_LIBRARY_VERSION@" " - " "@PWN_LIBRARY_VERSION_RELEASE@"; // clang-format on /// ///@brief pwn++ version information /// -constexpr struct +constexpr struct VersionType { /// ///@brief pwn++ major version /// - u8 Major; + const u8 Major; /// ///@brief pwn++ minor version /// - u8 Minor; + const u8 Minor; /// ///@brief pwn++ patch information /// - u16 Patch; + const u16 Patch; /// ///@brief pwn++ release information /// - std::wstring_view Release; + const std::string_view Release; /// ///@brief pwn++ complete version information as wstring /// - std::wstring_view VersionString; + const std::string_view VersionString; } Version = { // clang-format off @PWN_LIBRARY_VERSION_MAJOR@, @PWN_LIBRARY_VERSION_MINOR@, @PWN_LIBRARY_VERSION_PATCH@, - L"@PWN_LIBRARY_VERSION_RELEASE@", - L"@PWN_LIBRARY_VERSION@", + "@PWN_LIBRARY_VERSION_RELEASE@", + "@PWN_LIBRARY_VERSION@", // clang-format on }; /// ///@brief /// -constexpr struct +constexpr struct HostInfo { /// - ///@brief The target architecture pwn++ was built against + ///@brief The host architecture pwn++ was built against /// - std::wstring_view Architecture; + const std::string_view Architecture; /// - ///@brief The target OS pwn++ was built against + ///@brief The host OS pwn++ was built against /// - std::wstring_view System; -} Target { + const std::string_view System; +} Host { // clang-format off - L"@PWN_BUILD_ARCHITECTURE@", - L"@PWN_BUILD_OS@" + "@PWN_BUILD_ARCHITECTURE@", + "@PWN_BUILD_OS@" // clang-format on }; // clang-format off @@ -136,7 +157,7 @@ constexpr struct /// ///@brief A list of all modules built with pwn++ /// -constexpr std::array ModuleNames = {@PWN_MODULES_AS_STRING@}; +export constexpr std::array ModuleNames = {@PWN_MODULES_AS_STRING@}; // clang-format on } // namespace pwn