|
|
@ -23,19 +23,18 @@ void DX11_Hook::hook_dx11(UINT SDKVersion)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!_hooked)
|
|
|
|
if (!_hooked)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PRINT_DEBUG("Hooked DirectX 11\n");
|
|
|
|
|
|
|
|
_hooked = true;
|
|
|
|
_hooked = true;
|
|
|
|
Hook_Manager::Inst().FoundHook(this);
|
|
|
|
Hook_Manager::Inst().FoundHook(this);
|
|
|
|
|
|
|
|
|
|
|
|
IDXGISwapChain* pSwapChain;
|
|
|
|
IDXGISwapChain* pSwapChain;
|
|
|
|
ID3D11Device* pDevice;
|
|
|
|
ID3D11Device* pDevice;
|
|
|
|
DXGI_SWAP_CHAIN_DESC SwapChainDesc = {};
|
|
|
|
DXGI_SWAP_CHAIN_DESC SwapChainDesc = {};
|
|
|
|
SwapChainDesc.BufferCount = 2;
|
|
|
|
SwapChainDesc.BufferCount = 1;
|
|
|
|
SwapChainDesc.BufferDesc.Width = 800;
|
|
|
|
SwapChainDesc.BufferDesc.Width = 1;
|
|
|
|
SwapChainDesc.BufferDesc.Height = 600;
|
|
|
|
SwapChainDesc.BufferDesc.Height = 1;
|
|
|
|
SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
|
|
|
SwapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
|
|
|
|
SwapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
|
|
|
|
SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
|
|
|
|
SwapChainDesc.BufferDesc.RefreshRate.Denominator = 0;
|
|
|
|
SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
|
|
|
SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
|
|
|
SwapChainDesc.OutputWindow = GetForegroundWindow();
|
|
|
|
SwapChainDesc.OutputWindow = GetForegroundWindow();
|
|
|
|
SwapChainDesc.SampleDesc.Count = 1;
|
|
|
|
SwapChainDesc.SampleDesc.Count = 1;
|
|
|
@ -44,19 +43,28 @@ void DX11_Hook::hook_dx11(UINT SDKVersion)
|
|
|
|
|
|
|
|
|
|
|
|
D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, NULL, SDKVersion, &SwapChainDesc, &pSwapChain, &pDevice, NULL, NULL);
|
|
|
|
D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, NULL, NULL, SDKVersion, &SwapChainDesc, &pSwapChain, &pDevice, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
loadFunctions(pDevice, pSwapChain);
|
|
|
|
if (pDevice != nullptr && pSwapChain != nullptr)
|
|
|
|
|
|
|
|
{
|
|
|
|
UnhookAll();
|
|
|
|
PRINT_DEBUG("Hooked DirectX 11\n");
|
|
|
|
BeginHook();
|
|
|
|
loadFunctions(pDevice, pSwapChain);
|
|
|
|
HookFuncs(
|
|
|
|
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::Present , &DX11_Hook::MyPresent),
|
|
|
|
UnhookAll();
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::ResizeTarget , &DX11_Hook::MyResizeTarget),
|
|
|
|
BeginHook();
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::ResizeBuffers, &DX11_Hook::MyResizeBuffers)
|
|
|
|
HookFuncs(
|
|
|
|
);
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::Present, &DX11_Hook::MyPresent),
|
|
|
|
EndHook();
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::ResizeTarget, &DX11_Hook::MyResizeTarget),
|
|
|
|
|
|
|
|
std::make_pair<void**, void*>(&(PVOID&)DX11_Hook::ResizeBuffers, &DX11_Hook::MyResizeBuffers)
|
|
|
|
pDevice->Release();
|
|
|
|
);
|
|
|
|
pSwapChain->Release();
|
|
|
|
EndHook();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PRINT_DEBUG("Failed to hook DirectX 11\n");
|
|
|
|
|
|
|
|
_hooked = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(pDevice) pDevice->Release();
|
|
|
|
|
|
|
|
if(pSwapChain) pSwapChain->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|