VOID DrawStateEa(PVOID m_pSwapChain)
{
if (InitOnceVal == false)
{
LPVOID pSwapChainBase = *(LPVOID*)((UINT8*)m_pSwapChain - BaseSwappChaian);
if (pSwapChainBase != 0)
{
IDXGISwapChain* DxgiSwapChain = *(IDXGISwapChain**)((UINT8*)pSwapChainBase + 0x8);
if (DxgiSwapChain != 0)
{
if (SUCCEEDED(DxgiSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&g_pd3dDevice)))
{
g_pd3dDevice->GetImmediateContext(&g_pd3dDeviceContext);
}
ID3D11Texture2D* RenderTargetTexture = nullptr;
if (SUCCEEDED(DxgiSwapChain->GetBuffer(0, IID_PPV_ARGS(&RenderTargetTexture))))
{
g_pd3dDevice->CreateRenderTargetView(RenderTargetTexture, NULL, &g_mainRenderTargetView);
if (!g_mainRenderTargetView)
return;
RenderTargetTexture->Release();
}
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGui::StyleColorsDark();
ImGui_ImplWin32_Init(GloabalHwnd);
HWND hwnd = FindWindowA("Progman", "Program Manager");
WNDProc = (OWindowProc)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
InitOnceVal = true;
}
}
}
else
{
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
WNDProc = (OWindowProc)SetWindowLongPtr(GetForegroundWindow(), GWLP_WNDPROC, (LONG_PTR)WndProc);
ImGui::Begin("Hello, Justin!");
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
ImGui::End();
ImGui::GetForegroundDrawList()->AddText(ImVec2(100, 10), IM_COL32_WHITE, "DwmStared");
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}
}
INT64 Present(PVOID m_pSwapChain, uint32_t a2, uint32_t a3, INT64 a4, uint32_t a5)
{
DrawStateEa(m_pSwapChain);
return oPresent(m_pSwapChain, a2, a3, a4, a5);
}
INT64 PresentMulti(PVOID m_pSwapChain, uint32_t a2, uint32_t a3, int32_t a4, PVOID a5, INT64 a6, int32_t a7)
{
DrawStateEa(m_pSwapChain);
return oPresentMulti(m_pSwapChain, a2, a3, a4, a5, a6, a7);
}
bool FindGameInfo(_Out_ LPDWORD lpdwProcessId)
{
GloabalHwnd = FindWindowW(L"dbgviewClass", NULL); //Class name
if (GloabalHwnd != NULL)
{
GetWindowThreadProcessId(GloabalHwnd, lpdwProcessId);
return true;
}
return false;
}
void InitOnceThread()
{
DWORD ProcId = 0;
while (false == (FindGameInfo(&ProcId)))
Sleep(500);
Sleep(1000);
InitGlobalData();
}
void InitGlobalData()
{
PVOID dwmBase = GetModuleHandleA("dwmcore.dll");
if (!dwmBase)
return;
DWORD OldProtect = 0;
ULONG64 LegacySwapChain = (ULONG64)FindPattern(dwmBase, ".text", "48 8D 05 ? ? ? ? 48 89 44 19 ? 48 8B 43 18 48 63 48 04 8D 91 ? ? ? ? 89 54 19 14 48 8B 43 18 48 63 48 08 8D 91 ? ? ? ? 89 54 19 14 48 8B 43 18 48");
ULONG64 LegacySwapChainEx = (ULONG64)RVA_TO_VA(LegacySwapChain + 3);
ULONG64 OriginalPresent = *(ULONG64*)((ULONG64)LegacySwapChainEx + 0x80);
ULONG64 OriginalPresent2 = *(ULONG64*)((ULONG64)LegacySwapChainEx + 0x90);
oPresent = decltype(&Present)(OriginalPresent);
oPresentMulti = decltype(&PresentMulti)(OriginalPresent2);
VirtualProtect((PVOID)LegacySwapChainEx, 0x1000, PAGE_EXECUTE_READWRITE, &OldProtect);
*(DWORD64*)(LegacySwapChainEx + 0x80) = (DWORD64)&Present;
*(DWORD64*)(LegacySwapChainEx + 0x90) = (DWORD64)&PresentMulti;
VirtualProtect((PVOID)LegacySwapChainEx, 0x1000, OldProtect, &OldProtect);
} Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++ and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter name:";
getline (cin, name);
cout << "Hello " << name;
return 0;
}
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
//code
}
else {
//code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression){
case value1:
// code
break; // optional
case value2:
// code
break; // optional
......
default:
code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
return_type function_name(parameters);
function_name (parameters)
return_type function_name(parameters) {
// code
}