Skip to content

Commit

Permalink
Add Vulkan API Support (#21)
Browse files Browse the repository at this point in the history
* Add Vulkan Support [UNFINISHED]

It will work in current state but when resizing the menu will disappear. Vulkan needs to be re-initted. I would've done this now but i have to be up tomorrow and not home for 2 days. Will be marked as draft if anyone wants to edit feel free.

* Stuff

* Fix resizing issue's and misc stuff

* Remove unused pointer
  • Loading branch information
MarkEcza authored Sep 1, 2023
1 parent 54c36f2 commit ef912c3
Show file tree
Hide file tree
Showing 15 changed files with 801 additions and 94 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ 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)
include(cmake/vulkan.cmake)


# source
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
Expand All @@ -32,4 +33,4 @@ target_include_directories(${PROJECT_NAME} PRIVATE
)

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/vulkan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ 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")
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

0 comments on commit ef912c3

Please sign in to comment.