refactor!: Replace premake5 with CMake. (#551)

Co-authored-by: tupoy-ya <tupoy-ya@users.noreply.github.com>
This commit is contained in:
tupoy-ya 2022-11-08 21:08:58 +00:00 committed by GitHub
parent d9d8aa30c1
commit bc05ecd78c
340 changed files with 19298 additions and 19449 deletions

View File

@ -11,32 +11,27 @@ jobs:
with:
submodules: recursive
- name: Setup premake
uses: abel0b/setup-premake@v2
with:
version: "5.0.0-beta1"
- name: Check CMake version
run: cmake --version
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Generate premake5 project
run: premake5 vs2019
shell: bash
- name: Generate CMake project
run: cmake -S. -Bbuild -G "Visual Studio 17 2022" -DCMAKE_CONFIGURATION_TYPES=Release
- name: Build 64bit release DLL
run: |
msbuild /p:Configuration=Release /p:Platform=x64 BigBaseV2.sln -m /warnaserror
run: cmake --build build --config Release --target ALL_BUILD
- name: Check if DLL got built
run: if (-Not (Test-Path -path "bin/Release/BigBaseV2.dll")) {throw 1}
run: if (-Not (Test-Path -path "build/Release/YimMenu.dll")) {throw 1}
- name: Rename DLL to YimMenu-dev-{GITHUB_SHA}.dll
run: ren BigBaseV2.dll YimMenu-dev-${{github.sha}}.dll
working-directory: bin/Release/
run: ren YimMenu.dll YimMenu-dev-${{github.sha}}.dll
working-directory: build/Release/
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: binary
path: |
bin/Release/YimMenu-dev-*.dll
path: build/Release/YimMenu-dev-*.dll

View File

@ -18,32 +18,23 @@ jobs:
with:
submodules: recursive
- name: Setup premake
uses: abel0b/setup-premake@v2
with:
version: "5.0.0-beta1"
- name: Check CMake version
run: cmake --version
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
- name: Generate premake5 project
run: premake5 vs2019
shell: bash
- name: Generate CMake project
run: cmake -S. -Bbuild -G "Visual Studio 17 2022" -DCMAKE_CONFIGURATION_TYPES=Release
- name: Build 64bit release DLL
run: |
msbuild /p:Configuration=Release /p:Platform=x64 BigBaseV2.sln /warnaserror
- name: Rename DLL to YimMenu.dll
run: ren BigBaseV2.dll YimMenu.dll
working-directory: bin/Release/
run: cmake --build build --config Release --target ALL_BUILD
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: binary
path: |
bin/Release/YimMenu.dll
path: build/Release/YimMenu.dll
- name: Generate Build Info
id: var

10
.gitignore vendored
View File

@ -1,16 +1,12 @@
# IDE
.vs/
.vscode/
.cache/
# output directory
bin/
# premake in project dir people
*.exe
build/
# precompiled headers
*.ipch
*.gch
*.pch
# project files
*.sln
*.vcxproj*

24
.gitmodules vendored
View File

@ -1,24 +0,0 @@
[submodule "vendor/json"]
path = vendor/json
url = https://github.com/nlohmann/json
ignore = dirty
[submodule "vendor/MinHook"]
path = vendor/MinHook
url = https://github.com/YimMenu/minhook
ignore = dirty
[submodule "vendor/g3log"]
path = vendor/g3log
url = https://github.com/YimMenu/g3log.git
ignore = dirty
[submodule "vendor/GTAV-Classes"]
path = vendor/GTAV-Classes
url = https://github.com/Yimura/GTAV-Classes.git
ignore = dirty
[submodule "vendor/ImGui"]
path = vendor/ImGui
url = https://github.com/YimMenu/imgui.git
ignore = dirty
[submodule "vendor/pugixml"]
path = vendor/pugixml
url = https://github.com/zeux/pugixml.git
ignore = dirty

55
CMakeLists.txt Normal file
View File

@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.20)
project(YimMenu CXX ASM_MASM)
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
# Fetch modules
message("\nFetching modules")
include(scripts/minhook.cmake)
include(scripts/g3log.cmake)
include(scripts/pugixml.cmake)
include(scripts/json.cmake)
message("\nFetching custom modules")
include(scripts/imgui.cmake)
include(scripts/gtav-classes.cmake)
# YimMenu
message(STATUS "YimMenu")
file(GLOB_RECURSE SRC_MAIN
"${SRC_DIR}/**.hpp"
"${SRC_DIR}/**.h"
"${SRC_DIR}/**.cpp"
"${SRC_DIR}/**.cc"
"${SRC_DIR}/**.cxx"
"${SRC_DIR}/**.asm"
)
add_library(YimMenu MODULE "${SRC_MAIN}")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET YimMenu PROPERTY CXX_STANDARD 23) # 23 Because std::format is not avalible in std:c++20 for some reason. Maybe it's because i use v142 toolset.
source_group(TREE "${SRC_DIR}" PREFIX "YimMenu" FILES "${SRC_MAIN}" )
target_include_directories(YimMenu PRIVATE
"${SRC_DIR}"
"${json_SOURCE_DIR}/single_include"
"${gtav_classes_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include"
"${imgui_SOURCE_DIR}"
)
target_precompile_headers(YimMenu PRIVATE "${SRC_DIR}/common.hpp")
target_link_libraries(YimMenu PRIVATE pugixml minhook g3log imgui d3dcompiler)
# Warnings as errors
set_property(TARGET YimMenu PROPERTY COMPILE_WARNING_AS_ERROR ON)
add_compile_definitions(YimMenu
"_CRT_SECURE_NO_WARNINGS"
"NOMINMAX"
"WIN32_LEAN_AND_MEAN"
)

View File

@ -1,10 +1,13 @@
# YimMenu made possible by [BigBaseV2](https://github.com/Pocakking/BigBaseV2)
# YimMenu
![](https://img.shields.io/badge/dynamic/json?color=ffab00&label=Online%20Version&query=%24.game.online&url=https%3A%2F%2Fraw.githubusercontent.com%2FYimMenu%2FYimMenu%2Fmaster%2Fmetadata.json&style=flat-square&labelColor=000000) ![](https://img.shields.io/badge/dynamic/json?color=ffab00&label=Game%20Build&query=%24.game.build&url=https%3A%2F%2Fraw.githubusercontent.com%2FYimMenu%2FYimMenu%2Fmaster%2Fmetadata.json&style=flat-square&labelColor=000000)
A mod menu base for Grand Theft Auto V.
Strictly for educational purposes.
YimMenu is originally based of off [BigBaseV2](https://github.com/Pocakking/BigBaseV2) which was an amazing base at the time but nowadays is a bit dated.
So here I am with an up-to-date menu focusses on protecting the user from toxic modders.
## Table of contents
* [How to build](#how-to-build)
@ -20,8 +23,8 @@ Strictly for educational purposes.
Requirements:
* [git](#git)
* [premake5](#premake5)
* [Git](#Git)
* [CMake](#CMake)
If you have both of the above requirements you can skip to [cloning the git repo and generating the project files](#cloning-and-generating-project-files).
@ -31,17 +34,17 @@ If you haven't installed git on your system go and do so it is **REQUIRED** for
[Download Link](https://git-scm.com/download/win)
### Premake5
### CMake
Premake5 is used to generate our project files, if you haven't used it before we will need to download and add it to our [System Path](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/).
CMake is used to generate our project files, if you haven't used it before we will need to download and install it.
[Download Link](https://premake.github.io/download/)
[Download Link](https://cmake.org/download/)
### Cloning and generating project files
Clone the repository including submodules:
```bash
git clone https://github.com/YimMenu/YimMenu.git --recursive || echo "You don't have git installed, install it from https://git-scm.com/download/win"
git clone https://github.com/YimMenu/YimMenu.git || echo "You don't have git installed, install it from https://git-scm.com/download/win"
```
Go into the directory you just cloned:
@ -49,17 +52,21 @@ Go into the directory you just cloned:
cd YimMenu
```
Generate project files:
#### Generate project files:
```bash
script.bat
mkdir build && cd build
cmake ..
```
Now, you will be able to open the solution, and simply build it in Visual Studio.
## Staying Up To Date
Make sure your Visual Studio is closed and regenerate project files:
```bash
script.bat
git pull https://github.com/YimMenu/YimMenu.git
cd build
cmake ..
```
## Project Structure

View File

@ -1,248 +0,0 @@
workspace "BigBaseV2"
architecture "x64"
startproject "BigBaseV2"
configurations
{
-- "Debug", -- Debug isn't buildable and causes confusion for new people
"Release"
}
outputdir = "%{cfg.buildcfg}"
CppVersion = "C++20"
MsvcToolset = "v143"
WindowsSdkVersion = "10.0"
function DeclareMSVCOptions()
filter "system:windows"
staticruntime "Off"
floatingpoint "Fast"
systemversion (WindowsSdkVersion)
toolset (MsvcToolset)
cppdialect (CppVersion)
defines
{
"_CRT_SECURE_NO_WARNINGS",
"NOMINMAX",
"WIN32_LEAN_AND_MEAN"
-- "_WIN32_WINNT=0x601" -- Support Windows 7
}
disablewarnings
{
"4100", -- C4100: unreferenced formal parameter
"4201", -- C4201: nameless struct/union
"4307", -- C4307: integral constant overflow
"4996" -- C4996: deprecated in C++17
}
end
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function DeclareDebugOptions()
filter "configurations:Debug"
defines { "_DEBUG" }
symbols "On"
filter "not configurations:Debug"
defines { "NDEBUG" }
end
project "g3log"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C++"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
includedirs
{
"vendor/%{prj.name}/src"
}
g3log_file = "vendor/g3log/src/g3log/generated_definitions.hpp"
if(file_exists(g3log_file) == false) then
file = io.open(g3log_file, "w")
if(file == nil) then
premake.error("Failed to locate vendor directories. Try doing git pull --recurse-submodules.")
end
file:write("#pragma once");
end
files
{
"vendor/%{prj.name}/src/**.hpp",
"vendor/%{prj.name}/src/**.cpp"
}
removefiles
{
"vendor/%{prj.name}/src/crashhandler_unix.cpp"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "GTAV-Classes"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C++"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
files
{
"vendor/%{prj.name}/**.hpp"
}
includedirs
{
"vendor/%{prj.name}"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "ImGui"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C++"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
files
{
"vendor/%{prj.name}/imgui.cpp",
"vendor/%{prj.name}/imgui_draw.cpp",
"vendor/%{prj.name}/imgui_tables.cpp",
"vendor/%{prj.name}/imgui_widgets.cpp",
"vendor/%{prj.name}/backends/imgui_impl_dx11.cpp",
"vendor/%{prj.name}/backends/imgui_impl_win32.cpp",
"vendor/%{prj.name}/misc/cpp/imgui_stdlib.cpp",
}
includedirs
{
"vendor/%{prj.name}"
}
defines {
"IMGUI_DISABLE_DEMO_WINDOWS",
"IMGUI_DISABLE_METRICS_WINDOW",
"IM_ASSERT(_EXPR) ((void)(_EXPR))"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "MinHook"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
files
{
"vendor/%{prj.name}/include/**.h",
"vendor/%{prj.name}/src/**.h",
"vendor/%{prj.name}/src/**.c"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "pugixml"
location "vendor/%{prj.name}"
kind "StaticLib"
language "C++"
targetdir ("bin/lib/" .. outputdir)
objdir ("bin/lib/int/" .. outputdir .. "/%{prj.name}")
files
{
"vendor/%{prj.name}/src/**.cpp",
"vendor/%{prj.name}/src/**.hpp"
}
includedirs
{
"vendor/%{prj.name}/src/"
}
DeclareMSVCOptions()
DeclareDebugOptions()
project "BigBaseV2"
location "BigBaseV2"
symbols "Off"
kind "SharedLib"
language "C++"
targetdir ("bin/" .. outputdir)
objdir ("bin/int/" .. outputdir .. "/%{prj.name}")
files
{
"%{prj.name}/src/**.hpp",
"%{prj.name}/src/**.h",
"%{prj.name}/src/**.cpp",
"%{prj.name}/src/**.cc",
"%{prj.name}/src/**.cxx",
"%{prj.name}/src/**.asm"
}
includedirs
{
"%{prj.name}/src/",
"vendor/g3log/src",
"vendor/GTAV-Classes",
"vendor/ImGui",
"vendor/json/single_include",
"vendor/MinHook/include",
"vendor/pugixml/src"
}
libdirs
{
"bin/lib"
}
links
{
"g3log",
"ImGui",
"MinHook",
"pugixml"
}
pchheader "common.hpp"
pchsource "%{prj.name}/src/common.cpp"
forceincludes { -- microsoft bad
"common.hpp"
}
DeclareMSVCOptions()
DeclareDebugOptions()
flags { "NoImportLib", "Maps", "LinkTimeOptimization", "MultiProcessorCompile" }
filter "configurations:Debug"
flags { }
editandcontinue "Off"
defines { "DEBUG" }
filter "configurations:Release"
flags { "FatalWarnings", "NoManifest" }
defines { "RELEASE" }
optimize "speed"

View File

@ -1,15 +0,0 @@
@echo off
git submodule update --init
echo Updating current branch and submodules
git pull && git submodule update
echo Generating project files
premake5 vs2022
IF %ERRORLEVEL% NEQ 0 (
PAUSE
)
echo "Opening project..."
tasklist /FI "WINDOWTITLE eq BigBaseV2 - Microsoft Visual Studio" /FI "STATUS eq running" 2>NUL | find /I /N "devenv.exe" >NUL
IF %ERRORLEVEL% NEQ 0 (start BigBaseV2.sln) ELSE (echo Visual Studio is already open, doing nothing. && PAUSE)

16
scripts/g3log.cmake Normal file
View File

@ -0,0 +1,16 @@
include(FetchContent)
set(ADD_FATAL_EXAMPLE OFF CACHE INTERNAL "")
set(INSTALL_G3LOG OFF CACHE INTERNAL "")
set(G3_SHARED_LIB OFF CACHE INTERNAL "")
set(G3_SHARED_RUNTIME OFF CACHE INTERNAL "")
FetchContent_Declare(
g3log
GIT_REPOSITORY https://github.com/YimMenu/g3log.git
GIT_TAG 6ccf93c2e966e9ae13df75496a88e7b45214f7f8
GIT_PROGRESS TRUE
)
message("g3log")
FetchContent_MakeAvailable(g3log)
set_property(TARGET g3log PROPERTY CXX_STANDARD 23)

View File

@ -0,0 +1,23 @@
include(FetchContent)
FetchContent_Declare(
gtav_classes
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
GIT_TAG 09d18c6f6f7f9f8ad67a00f83cdd8379c8a734e3
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
message("GTAV-Classes")
if(NOT gtav_classes_POPULATED)
FetchContent_Populate(gtav_classes)
file(GLOB_RECURSE SRC_GTAV_CLASSES "${gtav_classes_SOURCE_DIR}/*.hpp")
# Show GTAV-Classes project
add_library(gtav_classes "${SRC_GTAV_CLASSES}")
source_group(TREE "${gtav_classes_SOURCE_DIR}" PREFIX "GTAV-Classes" FILES "${SRC_GTAV_CLASSES}")
endif()
set_property(TARGET gtav_classes PROPERTY CXX_STANDARD 23)
set_target_properties(gtav_classes PROPERTIES LINKER_LANGUAGE CXX)

29
scripts/imgui.cmake Normal file
View File

@ -0,0 +1,29 @@
include(FetchContent)
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/YimMenu/imgui.git
GIT_TAG a241dc7990b631fde6575771173c2442d43d2812
GIT_PROGRESS TRUE
)
message("ImGui")
FetchContent_GetProperties(imgui)
if(NOT imgui_POPULATED)
FetchContent_Populate(imgui)
file(GLOB SRC_IMGUI
"${imgui_SOURCE_DIR}/*.cpp"
"${imgui_SOURCE_DIR}/*.h"
"${imgui_SOURCE_DIR}/backends/imgui_impl_win32.*"
"${imgui_SOURCE_DIR}/backends/imgui_impl_dx11.*"
"${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.*"
)
add_library(imgui STATIC ${SRC_IMGUI})
source_group(TREE ${imgui_SOURCE_DIR} PREFIX "imgui" FILES ${SRC_IMGUI} )
target_include_directories(imgui PRIVATE
"${imgui_SOURCE_DIR}"
"${imgui_SOURCE_DIR}/backends"
"${imgui_SOURCE_DIR}/misc/cpp"
)
endif()
set_property(TARGET imgui PROPERTY CXX_STANDARD 23)

17
scripts/json.cmake Normal file
View File

@ -0,0 +1,17 @@
include(FetchContent)
set(JSON_MultipleHeaders OFF)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent.git
GIT_TAG 67e6070f9d9a44b4dec79ebe6b591f39d2285593
GIT_PROGRESS TRUE
)
message("json")
FetchContent_MakeAvailable(json)
# Show json project
add_library(json ${json_SOURCE_DIR}/single_include/nlohmann/json.hpp)
set_property(TARGET json PROPERTY CXX_STANDARD 23)
set_target_properties(json PROPERTIES LINKER_LANGUAGE CXX)

11
scripts/minhook.cmake Normal file
View File

@ -0,0 +1,11 @@
include(FetchContent)
FetchContent_Declare(
minhook
GIT_REPOSITORY https://github.com/YimMenu/minhook.git
GIT_TAG 902ab63e0a771547961e132ccc0700d62e2a1423
GIT_PROGRESS TRUE
)
message("MinHook")
FetchContent_MakeAvailable(minhook)
set_property(TARGET minhook PROPERTY CXX_STANDARD 23)

11
scripts/pugixml.cmake Normal file
View File

@ -0,0 +1,11 @@
include(FetchContent)
FetchContent_Declare(
pugixml
GIT_REPOSITORY https://github.com/zeux/pugixml.git
GIT_TAG a0e064336317c9347a91224112af9933598714e9
GIT_PROGRESS TRUE
)
message("pugixml")
FetchContent_MakeAvailable(pugixml)
set_property(TARGET pugixml PROPERTY CXX_STANDARD 23)

View File

@ -1,4 +0,0 @@
@echo off
git checkout master
git pull && git submodule update

View File

@ -1,8 +1,10 @@
#pragma once
#ifndef COMMON_INC
#define COMMON_INC
#include <SDKDDKVer.h>
#include <Windows.h>
#include <D3D11.h>
#include <sdkddkver.h>
#include <winsock2.h>
#include <windows.h>
#include <d3d11.h>
#include <wrl/client.h>
#include <cinttypes>
@ -67,7 +69,6 @@ namespace big
inline HANDLE g_main_thread{};
inline DWORD g_main_thread_id{};
inline std::atomic_bool g_running{ false };
inline bool g_is_steam{ false };
inline CPed* g_local_player;
}
@ -79,3 +80,5 @@ namespace self
inline Vector3 pos;
inline Vehicle veh;
}
#endif

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
#include "detour_hook.hpp"
#include "logger.hpp"
#include "memory/handle.hpp"
#include <..\MinHook\include\MinHook.h>
#include <MinHook.h>
namespace big
{
@ -61,16 +61,9 @@ namespace big
void detour_hook::fix_hook_address()
{
__try {
auto ptr = memory::handle(m_target);
while (ptr.as<std::uint8_t&>() == 0xE9)
ptr = ptr.add(1).rip();
m_target = ptr.as<void*>();
}
__except (exp_handler(GetExceptionInformation(), m_name)) {
[this]() {
throw std::runtime_error(std::format("Failed to fix hook address for '{}'", m_name));
}();
}
auto ptr = memory::handle(m_target);
while (ptr.as<std::uint8_t&>() == 0xE9)
ptr = ptr.add(1).rip();
m_target = ptr.as<void*>();
}
}

View File

Before

Width:  |  Height:  |  Size: 698 B

After

Width:  |  Height:  |  Size: 698 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 684 B

After

Width:  |  Height:  |  Size: 684 B

Some files were not shown because too many files have changed in this diff Show More