Skip to content

Commit a9d0e7f

Browse files
committed
Migrate project to C++11 with cxxopts and add GitHub Actions workflow
Major changes: - Convert main.c to main.cpp with C++11 features - Integrate cxxopts library for modern command-line argument parsing - Add support for positional arguments and multi-DLL injection - Fix extern "C" guards placement in all header files - Remove unnecessary extern "C" blocks from .c source files - Add GitHub Actions workflow for automated MSVC builds - Update CMakeLists.txt for C++11 standard and cxxopts integration Technical improvements: - All header files now follow correct extern "C" pattern - C source files cleaned from C++ linkage directives - Ready for CI/CD with Visual Studio 2022 on Windows runners - Modern C++ argument parsing with type safety
1 parent 51405d3 commit a9d0e7f

7 files changed

Lines changed: 292 additions & 159 deletions

File tree

.github/workflows/build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build GhostInjector
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-windows-msvc:
12+
runs-on: windows-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
20+
- name: Setup MSVC
21+
uses: microsoft/setup-msbuild@v2
22+
23+
- name: Configure CMake
24+
run: |
25+
cmake -B build -G "Visual Studio 17 2022" -A x64
26+
27+
- name: Build
28+
run: |
29+
cmake --build build --config Release
30+
31+
- name: Check DLL dependencies
32+
shell: pwsh
33+
run: |
34+
Write-Host "=== Executable Info ==="
35+
Get-ChildItem -Path build\Release\ghostinjector-*.exe | ForEach-Object {
36+
Write-Host "File: $($_.Name)"
37+
Write-Host "Size: $([math]::Round($_.Length / 1MB, 2)) MB"
38+
Write-Host ""
39+
}
40+
Write-Host "=== Checking for MSVC Runtime Dependencies ==="
41+
Write-Host "Note: This executable requires Visual C++ Redistributable (vcruntime140.dll, msvcp140.dll)"
42+
43+
- name: Upload artifact
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: ghostinjector-windows-x64-msvc
47+
path: build/Release/ghostinjector-*.exe
48+
if-no-files-found: error
49+
retention-days: 30
50+
51+
- name: Create Release (on tag)
52+
if: startsWith(github.ref, 'refs/tags/')
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
files: build/Release/ghostinjector-*.exe
56+
draft: false
57+
prerelease: false
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(GhostInjector VERSION 1.0.2 LANGUAGES C)
2+
project(GhostInjector VERSION 1.0.2 LANGUAGES C CXX)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
8+
include(FetchContent)
9+
10+
# Fetch cxxopts
11+
FetchContent_Declare(
12+
cxxopts
13+
GIT_REPOSITORY https://github.com/jarro2783/cxxopts.git
14+
GIT_TAG v3.2.1
15+
)
16+
FetchContent_MakeAvailable(cxxopts)
317

418
add_subdirectory(Neptune)
519
add_subdirectory(NThread)
@@ -8,15 +22,18 @@ add_subdirectory(NThreadOSUtils)
822
set(GHOSTINJECTOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
923
set(GHOSTINJECTOR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
1024

11-
file(GLOB_RECURSE GHOSTINJECTOR_HEADERS CONFIGURE_DEPENDS ${GHOSTINJECTOR_INCLUDE_DIR}/*.h)
12-
file(GLOB_RECURSE GHOSTINJECTOR_SOURCES CONFIGURE_DEPENDS ${GHOSTINJECTOR_SOURCE_DIR}/*.c)
25+
file(GLOB_RECURSE GHOSTINJECTOR_HEADERS CONFIGURE_DEPENDS ${GHOSTINJECTOR_INCLUDE_DIR}/*.h ${GHOSTINJECTOR_INCLUDE_DIR}/*.hpp)
26+
file(GLOB_RECURSE GHOSTINJECTOR_SOURCES CONFIGURE_DEPENDS ${GHOSTINJECTOR_SOURCE_DIR}/*.c ${GHOSTINJECTOR_SOURCE_DIR}/*.cpp)
1327

1428
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
1529
set(EXECUTABLE_NAME "${PROJECT_NAME_LOWER}-${PROJECT_VERSION}")
1630

1731
add_executable(${EXECUTABLE_NAME} ${GHOSTINJECTOR_SOURCES})
1832
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${GHOSTINJECTOR_INCLUDE_DIR})
19-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE NThreadOSUtils)
33+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE NThreadOSUtils cxxopts)
34+
35+
# Dynamic linking - will use MSVC runtime DLLs (msvcp140.dll, vcruntime140.dll)
36+
# Removed: -static -static-libgcc -static-libstdc++
2037

2138
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE
2239
LOG_LEVEL_2

src/main.c

Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
 (0)