Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kickstart Vulkan API #19

Merged
merged 2 commits into from
Sep 1, 2023
Merged
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
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ cmake_minimum_required(VERSION 3.20.x)
project(NewBase VERSION 0.0.1 DESCRIPTION "A new base using new C++ features optimised for speed and ease of use")

# libs
include(cmake/vulkan.cmake)
include(cmake/async-logger.cmake)
include(cmake/imgui.cmake)
include(cmake/json.cmake)
include(cmake/minhook.cmake)
include(cmake/rdr-classes.cmake)


# source
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
file(GLOB_RECURSE SRC_FILES
"${SRC_DIR}/**.hpp"
"${SRC_DIR}/**.cpp"
"${SRC_DIR}/**.cpp"
)

add_library(${PROJECT_NAME} MODULE ${SRC_FILES})
Expand All @@ -27,7 +29,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE
"${imgui_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include"
"${rdr_classes_SOURCE_DIR}"
"${vulkan_SOURCE_DIR}/include"
)

message(STATUS "Setting up linked libraries")
target_link_libraries(${PROJECT_NAME} PRIVATE AsyncLogger imgui minhook nlohmann_json::nlohmann_json)
target_link_libraries(${PROJECT_NAME} PRIVATE AsyncLogger imgui minhook nlohmann_json::nlohmann_json "${SRC_DIR}/vulkan-1.lib")
2 changes: 2 additions & 0 deletions cmake/imgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ if(NOT imgui_POPULATED)
"${imgui_SOURCE_DIR}/*.h"
"${imgui_SOURCE_DIR}/backends/imgui_impl_win32.*"
"${imgui_SOURCE_DIR}/backends/imgui_impl_dx12.*"
"${imgui_SOURCE_DIR}/backends/imgui_impl_vulkan.*"
"${imgui_SOURCE_DIR}/misc/cpp/imgui_stdlib.*"
)

Expand All @@ -29,5 +30,6 @@ if(NOT imgui_POPULATED)
"${imgui_SOURCE_DIR}"
"${imgui_SOURCE_DIR}/backends"
"${imgui_SOURCE_DIR}/misc/cpp"
"${vulkan_SOURCE_DIR}/include"
)
endif()
2 changes: 1 addition & 1 deletion cmake/rdr-classes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FetchContent_Declare(
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
message("RDR-Classes")
message(STATUS "RDR-Classes")
if(NOT rdr_classes_POPULATED)
FetchContent_Populate(rdr_classes)
endif()
15 changes: 15 additions & 0 deletions cmake/vulkan.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(FetchContent)

message(STATUS "Setting up Vulkan Headers")
FetchContent_Declare(
Vulkan
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers.git
GIT_TAG sdk-1.1.108 # matches RDR2's SDK
GIT_PROGRESS TRUE
)

set(CMAKE_WARN_DEPRECATED 0 CACHE INTERNAL "Suppress deprecation shortly")
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 1 CACHE INTERNAL "No dev warnings")
FetchContent_MakeAvailable(Vulkan)
set(CMAKE_SUPPRESS_DEVELOPER_WARNINGS 0 CACHE INTERNAL "Re-enable dev warnings")
set(CMAKE_WARN_DEPRECATED 1 CACHE INTERNAL "Restore deprecation notices")
17 changes: 13 additions & 4 deletions src/core/hooking/Hooking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ namespace YimMenu
Hooking::Hooking()
{
BaseHook::Add<Hooks::Window::WndProc>(new DetourHook("WndProc", Pointers.WndProc, Hooks::Window::WndProc));

BaseHook::Add<Hooks::Window::SetCursorPos>(new DetourHook("SetCursorPos", ModuleMgr.Get("user32.dll")->GetExport<void*>("SetCursorPos"), Hooks::Window::SetCursorPos));

//RDR2 would typically crash or do nothing when using VMT hooks, something to look into in the future.
BaseHook::Add<Hooks::SwapChain::Present>(new DetourHook("SwapChain::Present", GetVF(*Pointers.SwapChain, Hooks::SwapChain::VMTPresentIdx), Hooks::SwapChain::Present));
BaseHook::Add<Hooks::SwapChain::ResizeBuffers>(new DetourHook("SwapChain::ResizeBuffers", GetVF(*Pointers.SwapChain, Hooks::SwapChain::VMTResizeBuffersIdx), Hooks::SwapChain::ResizeBuffers));
if (Pointers.IsVulkan)
{
BaseHook::Add<Hooks::Vulkan::QueuePresentKHR>(new DetourHook("Vulkan::QueuePresentKHR", Pointers.QueuePresentKHR, Hooks::Vulkan::QueuePresentKHR));
BaseHook::Add<Hooks::Vulkan::CreateSwapchainKHR>(new DetourHook("Vulkan::CreateSwapchainKHR", Pointers.CreateSwapchainKHR, Hooks::Vulkan::CreateSwapchainKHR));
BaseHook::Add<Hooks::Vulkan::AcquireNextImage2KHR>(new DetourHook("Vulkan::AcquireNextImage2KHR", Pointers.AcquireNextImage2KHR, Hooks::Vulkan::AcquireNextImage2KHR));
BaseHook::Add<Hooks::Vulkan::AcquireNextImageKHR>(new DetourHook("Vulkan::AcquireNextImageKHR", Pointers.AcquireNextImageKHR, Hooks::Vulkan::AcquireNextImageKHR));
}
else if (!Pointers.IsVulkan)
{
//RDR2 would typically crash or do nothing when using VMT hooks, something to look into in the future.
BaseHook::Add<Hooks::SwapChain::Present>(new DetourHook("SwapChain::Present", GetVF(*Pointers.SwapChain, Hooks::SwapChain::VMTPresentIdx), Hooks::SwapChain::Present));
BaseHook::Add<Hooks::SwapChain::ResizeBuffers>(new DetourHook("SwapChain::ResizeBuffers", GetVF(*Pointers.SwapChain, Hooks::SwapChain::VMTResizeBuffersIdx), Hooks::SwapChain::ResizeBuffers));
}

BaseHook::Add<Hooks::Script::RunScriptThreads>(new DetourHook("RunScriptThreads", Pointers.RunScriptThreads, Hooks::Script::RunScriptThreads));
}
Expand Down
Loading