|
|
@@ -1,6 +1,6 @@
|
|
|
#include <d3d10_1.h>
|
|
|
#include <d3d11.h>
|
|
|
-#include <dxgi.h>
|
|
|
+#include <dxgi1_2.h>
|
|
|
#include <d3dcompiler.h>
|
|
|
|
|
|
#include "d3d1x_shaders.hpp"
|
|
|
@@ -14,9 +14,12 @@
|
|
|
typedef HRESULT (STDMETHODCALLTYPE *resize_buffers_t)(IDXGISwapChain*, UINT,
|
|
|
UINT, UINT, DXGI_FORMAT, UINT);
|
|
|
typedef HRESULT (STDMETHODCALLTYPE *present_t)(IDXGISwapChain*, UINT, UINT);
|
|
|
+typedef HRESULT (STDMETHODCALLTYPE *present1_t)(IDXGISwapChain1*, UINT, UINT,
|
|
|
+ const DXGI_PRESENT_PARAMETERS *);
|
|
|
|
|
|
static struct func_hook resize_buffers;
|
|
|
static struct func_hook present;
|
|
|
+static struct func_hook present1;
|
|
|
|
|
|
struct dxgi_swap_data {
|
|
|
IDXGISwapChain *swap;
|
|
|
@@ -165,6 +168,53 @@ static HRESULT STDMETHODCALLTYPE hook_present(IDXGISwapChain *swap,
|
|
|
return hr;
|
|
|
}
|
|
|
|
|
|
+static HRESULT STDMETHODCALLTYPE hook_present1(IDXGISwapChain1 *swap,
|
|
|
+ UINT sync_interval, UINT flags,
|
|
|
+ const DXGI_PRESENT_PARAMETERS *params)
|
|
|
+{
|
|
|
+ IUnknown *backbuffer = nullptr;
|
|
|
+ bool capture_overlay = global_hook_info->capture_overlay;
|
|
|
+ bool test_draw = (flags & DXGI_PRESENT_TEST) != 0;
|
|
|
+ bool capture;
|
|
|
+ HRESULT hr;
|
|
|
+
|
|
|
+ if (!data.swap && !capture_active()) {
|
|
|
+ setup_dxgi(swap);
|
|
|
+ }
|
|
|
+
|
|
|
+ capture = !test_draw && swap == data.swap && !!data.capture;
|
|
|
+ if (capture && !capture_overlay) {
|
|
|
+ backbuffer = get_dxgi_backbuffer(swap);
|
|
|
+
|
|
|
+ if (!!backbuffer) {
|
|
|
+ DXGI_SWAP_CHAIN_DESC1 desc;
|
|
|
+ swap->GetDesc1(&desc);
|
|
|
+ data.capture(swap, backbuffer, capture_overlay);
|
|
|
+ backbuffer->Release();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ unhook(&present1);
|
|
|
+ present1_t call = (present1_t)present1.call_addr;
|
|
|
+ hr = call(swap, sync_interval, flags, params);
|
|
|
+ rehook(&present1);
|
|
|
+
|
|
|
+ if (capture && capture_overlay) {
|
|
|
+ if (resize_buffers_called) {
|
|
|
+ resize_buffers_called = false;
|
|
|
+ } else {
|
|
|
+ backbuffer = get_dxgi_backbuffer(swap);
|
|
|
+
|
|
|
+ if (!!backbuffer) {
|
|
|
+ data.capture(swap, backbuffer, capture_overlay);
|
|
|
+ backbuffer->Release();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return hr;
|
|
|
+}
|
|
|
+
|
|
|
static pD3DCompile get_compiler(void)
|
|
|
{
|
|
|
pD3DCompile compile = nullptr;
|
|
|
@@ -202,6 +252,7 @@ bool hook_dxgi(void)
|
|
|
HRESULT hr;
|
|
|
void *present_addr;
|
|
|
void *resize_addr;
|
|
|
+ void *present1_addr = nullptr;
|
|
|
|
|
|
if (!dxgi_module) {
|
|
|
return false;
|
|
|
@@ -251,14 +302,22 @@ bool hook_dxgi(void)
|
|
|
global_hook_info->offsets.dxgi.present);
|
|
|
resize_addr = get_offset_addr(dxgi_module,
|
|
|
global_hook_info->offsets.dxgi.resize);
|
|
|
+ if (global_hook_info->offsets.dxgi.present1)
|
|
|
+ present1_addr = get_offset_addr(dxgi_module,
|
|
|
+ global_hook_info->offsets.dxgi.present1);
|
|
|
|
|
|
hook_init(&present, present_addr, (void*)hook_present,
|
|
|
"IDXGISwapChain::Present");
|
|
|
hook_init(&resize_buffers, resize_addr, (void*)hook_resize_buffers,
|
|
|
"IDXGISwapChain::ResizeBuffers");
|
|
|
+ if (present1_addr)
|
|
|
+ hook_init(&present1, present1_addr, (void*)hook_present1,
|
|
|
+ "IDXGISwapChain1::Present1");
|
|
|
|
|
|
rehook(&resize_buffers);
|
|
|
rehook(&present);
|
|
|
+ if (present1_addr)
|
|
|
+ rehook(&present1);
|
|
|
|
|
|
hlog("Hooked DXGI");
|
|
|
return true;
|