-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHooks.cpp
More file actions
50 lines (39 loc) · 1.43 KB
/
Hooks.cpp
File metadata and controls
50 lines (39 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "stdafx.h"
#include "Hooks.h"
#include "Helpers.h"
#include "CCheat.h"
#include "Renderer.h"
#include "UserInterface.h"
tD3D11Present Hooks::oPresent = NULL;
bool bOnce = false;
HRESULT __stdcall Hooks::hkD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
if (!bOnce)
{
HWND hWindow = FindWindowA(NULL, "Rainbow Six");
if (SUCCEEDED(pSwapChain->GetDevice(__uuidof(ID3D11Device), (void **)&CCheat::pDevice)))
{
pSwapChain->GetDevice(__uuidof(CCheat::pDevice), (void**)&CCheat::pDevice);
CCheat::pDevice->GetImmediateContext(&CCheat::pContext);
}
ID3D11Texture2D* renderTargetTexture = nullptr;
if (SUCCEEDED(pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(&renderTargetTexture))))
{
CCheat::pDevice->CreateRenderTargetView(renderTargetTexture, NULL, &CCheat::pRenderTargetView);
renderTargetTexture->Release();
}
ImGui_ImplDX11_Init(hWindow, CCheat::pDevice, CCheat::pContext);
ImGui_ImplDX11_CreateDeviceObjects();
//Renderer::GetInstance()->Initialize();
Helpers::Log("D3D11Present initialised");
bOnce = true;
}
CCheat::pContext->OMSetRenderTargets(1, &CCheat::pRenderTargetView, NULL);
ImGui_ImplDX11_NewFrame();
Renderer::GetInstance()->BeginScene();
Renderer::GetInstance()->DrawScene();
Renderer::GetInstance()->EndScene();
UserInterface::GetInstance()->Render();
ImGui::Render();
return Hooks::oPresent(pSwapChain, SyncInterval, Flags);
}