Win32 basic d3d11 present hook

pull/337/head^2
FlightlessMango 4 years ago
parent 86703ee364
commit ac821df7fa

@ -22,7 +22,6 @@ void check_keybinds(struct swapchain_stats& sw_stats, struct overlay_params& par
#endif
if (pressed && (now - logger->last_log_end() > 11s)) {
last_f2_press = now;
printf("pressed\n");
if (logger->is_active()) {
logger->stop_logging();
} else {

@ -48,6 +48,7 @@ if ['windows', 'mingw'].contains(host_machine.system())
'win/main.cpp',
'win/kiero.cpp',
'win/d3d12_hook.cpp',
'win/d3d11_hook.cpp',
'win/d3d_shared.cpp',
)
endif

@ -0,0 +1,28 @@
#include "kiero.h"
#if KIERO_INCLUDE_D3D11
#include "d3d11_hook.h"
#include <d3d11.h>
#include <assert.h>
#include "d3d_shared.h"
typedef long(__stdcall* Present)(IDXGISwapChain*, UINT, UINT);
static Present oPresent = NULL;
long __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
d3d_run();
return oPresent(pSwapChain, SyncInterval, Flags);
}
void impl::d3d11::init()
{
printf("init d3d11\n");
auto ret = kiero::bind(8, (void**)&oPresent, reinterpret_cast<void *>(hkPresent11));
assert(ret == kiero::Status::Success);
init_d3d_shared();
}
#endif // KIERO_INCLUDE_D3D11

@ -0,0 +1,13 @@
#ifndef __D3D11_IMPL_H__
#define __D3D11_IMPL_H__
namespace impl
{
namespace d3d11
{
void init();
}
}
#endif // __D3D11_IMPL_H__

@ -9,8 +9,7 @@ typedef long(__fastcall* PresentD3D12) (IDXGISwapChain* pSwapChain, UINT SyncInt
PresentD3D12 oPresentD3D12;
long __fastcall hkPresent12(IDXGISwapChain3* pSwapChain, UINT SyncInterval, UINT Flags){
check_keybinds(sw_stats, params, vendorID);
update_hud_info(sw_stats, params, vendorID);
d3d_run();
return oPresentD3D12(pSwapChain, SyncInterval, Flags);
}

@ -1,4 +1,5 @@
#include "d3d_shared.h"
#include "overlay.h"
bool cfg_inited = false;
ImVec2 window_size;
@ -13,4 +14,9 @@ void init_d3d_shared(){
parse_overlay_config(&params, getenv("MANGOHUD_CONFIG"));
cfg_inited = true;
// init_cpu_stats(params);
}
void d3d_run(){
check_keybinds(sw_stats, params, vendorID);
update_hud_info(sw_stats, params, vendorID);
}

@ -7,4 +7,5 @@ extern struct swapchain_stats sw_stats;
extern uint32_t vendorID;
extern void init_d3d_shared(void);
extern void d3d_run(void);
extern uint32_t get_device_id_dxgi(void);

@ -281,8 +281,8 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType)
return Status::ModuleNotFoundError;
}
void* D3D11CreateDeviceAndSwapChain;
if ((D3D11CreateDeviceAndSwapChain = ::GetProcAddress(libD3D11, "D3D11CreateDeviceAndSwapChain")) == NULL)
auto D3D11CreateDeviceAndSwapChain = reinterpret_cast<decltype(&::D3D11CreateDeviceAndSwapChain)>(::GetProcAddress(libD3D11, "D3D11CreateDeviceAndSwapChain"));
if (!D3D11CreateDeviceAndSwapChain)
{
::DestroyWindow(window);
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);

@ -7,7 +7,7 @@
#define KIERO_INCLUDE_D3D9 0 // 1 if you need D3D9 hook
#define KIERO_INCLUDE_D3D10 0 // 1 if you need D3D10 hook
#define KIERO_INCLUDE_D3D11 0 // 1 if you need D3D11 hook
#define KIERO_INCLUDE_D3D11 1 // 1 if you need D3D11 hook
#define KIERO_INCLUDE_D3D12 1 // 1 if you need D3D12 hook
#define KIERO_INCLUDE_OPENGL 0 // 1 if you need OpenGL hook
#define KIERO_INCLUDE_VULKAN 1 // 1 if you need Vulkan hook

@ -1,7 +1,9 @@
#include "windows.h"
#include <cstdio>
#include "kiero.h"
#if KIERO_INCLUDE_D3D11
# include "d3d11_hook.h"
#endif
#if KIERO_INCLUDE_D3D12
# include "d3d12_hook.h"
#endif
@ -24,6 +26,11 @@ int MainThread()
{
switch (kiero::getRenderType())
{
#if KIERO_INCLUDE_D3D11
case kiero::RenderType::D3D11:
impl::d3d11::init();
break;
#endif
#if KIERO_INCLUDE_D3D12
case kiero::RenderType::D3D12:
impl::d3d12::init();

Loading…
Cancel
Save