From b4ee6fa522c863a9997d3ce3d4fb2445615d0008 Mon Sep 17 00:00:00 2001 From: MisterY52 <11368116+MisterY52@users.noreply.github.com> Date: Wed, 3 Nov 2021 16:28:05 +0100 Subject: [PATCH] Replaced DirectX 9 with DirectX 11, removed spectators counter --- apex_dma/apex_dma.cpp | 149 +++------------ apex_guest/Client/Client/Client.vcxproj | 9 +- .../Client/Client/Client.vcxproj.filters | 11 +- apex_guest/Client/Client/main.cpp | 70 +++---- apex_guest/Client/Client/overlay.cpp | 173 +++++++----------- apex_guest/Client/Client/overlay.h | 10 +- 6 files changed, 127 insertions(+), 295 deletions(-) diff --git a/apex_dma/apex_dma.cpp b/apex_dma/apex_dma.cpp index 769592e..6ab7361 100644 --- a/apex_dma/apex_dma.cpp +++ b/apex_dma/apex_dma.cpp @@ -20,8 +20,6 @@ uintptr_t lastaimentity = 0; float max = 999.0f; float max_dist = 200.0f*40.0f; int team_player = 0; -int tmp_spec = 0, spectators = 0; -int tmp_all_spec = 0, allied_spectators = 0; float max_fov = 15; const int toRead = 100; int aim = false; @@ -29,7 +27,6 @@ bool esp = false; bool item_glow = false; bool player_glow = false; extern bool aim_no_recoil; -int safe_level = 0; bool aiming = false; extern float smooth; extern int bone; @@ -76,23 +73,7 @@ float lastvis_aim[toRead]; void ProcessPlayer(Entity& LPlayer, Entity& target, uint64_t entitylist, int index) { int entity_team = target.getTeamId(); - bool obs = target.Observing(entitylist); - if (obs) - { - /*if(obs == LPlayer.ptr) - { - if (entity_team == team_player) - { - tmp_all_spec++; - } - else - { - tmp_spec++; - } - }*/ - tmp_spec++; - return; - } + Vector EntityPosition = target.getPosition(); Vector LocalPlayerPosition = LPlayer.getPosition(); float dist = LocalPlayerPosition.DistTo(EntityPosition); @@ -177,8 +158,6 @@ void DoActions() } max = 999.0f; - tmp_spec = 0; - tmp_all_spec = 0; tmp_aimentity = 0; if(firing_range) { @@ -232,32 +211,6 @@ void DoActions() continue; } - switch (safe_level) - { - case 1: - if (spectators > 0) - { - if(Target.isGlowing()) - { - Target.disableGlow(); - } - continue; - } - break; - case 2: - if (spectators+allied_spectators > 0) - { - if(Target.isGlowing()) - { - Target.disableGlow(); - } - continue; - } - break; - default: - break; - } - if(player_glow && !Target.isGlowing()) { Target.enableGlow(); @@ -268,8 +221,7 @@ void DoActions() } } } - spectators = tmp_spec; - allied_spectators = tmp_all_spec; + if(!lock) aimentity = tmp_aimentity; else @@ -295,33 +247,6 @@ static void EspLoop() if (esp) { valid = false; - switch (safe_level) - { - case 1: - if (spectators > 0) - { - next = true; - while(next && g_Base!=0 && c_Base!=0 && esp) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - continue; - } - break; - case 2: - if (spectators+allied_spectators > 0) - { - next = true; - while(next && g_Base!=0 && c_Base!=0 && esp) - { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); - } - continue; - } - break; - default: - break; - } uint64_t LocalPlayer = 0; apex_mem.Read(g_Base + OFFSET_LOCAL_ENT, LocalPlayer); @@ -526,24 +451,6 @@ static void AimbotLoop() std::this_thread::sleep_for(std::chrono::milliseconds(1)); if (aim>0) { - switch (safe_level) - { - case 1: - if (spectators > 0) - { - continue; - } - break; - case 2: - if (spectators+allied_spectators > 0) - { - continue; - } - break; - default: - break; - } - if (aimentity == 0 || !aiming) { lock=false; @@ -575,47 +482,43 @@ static void set_vars(uint64_t add_addr) printf("Reading client vars...\n"); std::this_thread::sleep_for(std::chrono::milliseconds(50)); //Get addresses of client vars - uint64_t spec_addr = 0; - client_mem.Read(add_addr, spec_addr); - uint64_t all_spec_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t), all_spec_addr); + uint64_t check_addr = 0; + client_mem.Read(add_addr, check_addr); uint64_t aim_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*2, aim_addr); + client_mem.Read(add_addr + sizeof(uint64_t), aim_addr); uint64_t esp_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*3, esp_addr); - uint64_t safe_lev_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*4, safe_lev_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*2, esp_addr); uint64_t aiming_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*5, aiming_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*3, aiming_addr); uint64_t g_Base_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*6, g_Base_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*4, g_Base_addr); uint64_t next_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*7, next_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*5, next_addr); uint64_t player_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*8, player_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*6, player_addr); uint64_t valid_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*9, valid_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*7, valid_addr); uint64_t max_dist_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*10, max_dist_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*8, max_dist_addr); uint64_t item_glow_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*11, item_glow_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*9, item_glow_addr); uint64_t player_glow_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*12, player_glow_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*10, player_glow_addr); uint64_t aim_no_recoil_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*13, aim_no_recoil_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*11, aim_no_recoil_addr); uint64_t smooth_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*14, smooth_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*12, smooth_addr); uint64_t max_fov_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*15, max_fov_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*13, max_fov_addr); uint64_t bone_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*16, bone_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*14, bone_addr); uint64_t thirdperson_addr = 0; - client_mem.Read(add_addr + sizeof(uint64_t)*17, thirdperson_addr); + client_mem.Read(add_addr + sizeof(uint64_t)*15, thirdperson_addr); - int tmp = 0; - client_mem.Read(spec_addr, tmp); + uint32_t check = 0; + client_mem.Read(check_addr, check); - if(tmp != 1) + if(check != 0xABCD) { printf("Incorrect values read. Check if the add_off is correct. Quitting.\n"); active = false; @@ -626,18 +529,18 @@ static void set_vars(uint64_t add_addr) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); if(c_Base!=0 && g_Base!=0) + { + client_mem.Write(check_addr, 0); printf("\nReady\n"); + } while(c_Base!=0 && g_Base!=0) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); - client_mem.Write(all_spec_addr, allied_spectators); - client_mem.Write(spec_addr, spectators); client_mem.Write(g_Base_addr, g_Base); client_mem.Read(aim_addr, aim); client_mem.Read(esp_addr, esp); - client_mem.Read(safe_lev_addr, safe_level); client_mem.Read(aiming_addr, aiming); client_mem.Read(max_dist_addr, max_dist); client_mem.Read(item_glow_addr, item_glow); @@ -735,7 +638,7 @@ int main(int argc, char *argv[]) //const char* ap_proc = "EasyAntiCheat_launcher.exe"; //Client "add" offset - uint64_t add_off = 0x3e890; + uint64_t add_off = 0x3f870; std::thread aimbot_thr; std::thread esp_thr; diff --git a/apex_guest/Client/Client/Client.vcxproj b/apex_guest/Client/Client/Client.vcxproj index cfe4b27..05592a4 100644 --- a/apex_guest/Client/Client/Client.vcxproj +++ b/apex_guest/Client/Client/Client.vcxproj @@ -54,8 +54,8 @@ false - $(DXSDK_DIR)Include;$(IncludePath) - $(DXSDK_DIR)Lib\x64;$(LibraryPath) + $(VC_IncludePath);$(WindowsSDK_IncludePath) + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64) client_ap @@ -96,8 +96,9 @@ - + + @@ -105,7 +106,7 @@ - + diff --git a/apex_guest/Client/Client/Client.vcxproj.filters b/apex_guest/Client/Client/Client.vcxproj.filters index e39714b..274f8dd 100644 --- a/apex_guest/Client/Client/Client.vcxproj.filters +++ b/apex_guest/Client/Client/Client.vcxproj.filters @@ -34,7 +34,10 @@ Source\imgui - + + Source\imgui + + Source\imgui @@ -64,15 +67,15 @@ Headers\imgui - - Headers\imgui - Headers\imgui Headers + + Headers\imgui + diff --git a/apex_guest/Client/Client/main.cpp b/apex_guest/Client/Client/main.cpp index e38901f..3c8179b 100644 --- a/apex_guest/Client/Client/main.cpp +++ b/apex_guest/Client/Client/main.cpp @@ -17,22 +17,21 @@ typedef struct player char name[33] = { 0 }; }player; +uint32_t check = 0xABCD; + int aim_key = VK_RBUTTON; bool use_nvidia = true; bool active = true; bool ready = false; extern visuals v; -int spectators = 1; //write -int allied_spectators = 1; //write int aim = 0; //read bool esp = false; //read -int safe_level = 0; //read bool item_glow = false; bool player_glow = false; bool aim_no_recoil = true; bool aiming = false; //read uint64_t g_Base = 0; //write -float max_dist = 200.0f*40.0f; //read +float max_dist = 200.0f * 40.0f; //read float smooth = 12.0f; float max_fov = 15.0f; int bone = 2; @@ -41,11 +40,10 @@ bool thirdperson = false; bool valid = false; //write bool next = false; //read write -uint64_t add[18]; +uint64_t add[16]; bool k_f5 = 0; bool k_f6 = 0; -bool k_f7 = 0; bool k_f8 = 0; bool IsKeyDown(int vk) @@ -121,29 +119,28 @@ void Overlay::RenderEsp() int main(int argc, char** argv) { - add[0] = (uintptr_t)&spectators; - add[1] = (uintptr_t)&allied_spectators; - add[2] = (uintptr_t)&aim; - add[3] = (uintptr_t)&esp; - add[4] = (uintptr_t)&safe_level; - add[5] = (uintptr_t)&aiming; - add[6] = (uintptr_t)&g_Base; - add[7] = (uintptr_t)&next; - add[8] = (uintptr_t)&players[0]; - add[9] = (uintptr_t)&valid; - add[10] = (uintptr_t)&max_dist; - add[11] = (uintptr_t)&item_glow; - add[12] = (uintptr_t)&player_glow; - add[13] = (uintptr_t)&aim_no_recoil; - add[14] = (uintptr_t)&smooth; - add[15] = (uintptr_t)&max_fov; - add[16] = (uintptr_t)&bone; - add[17] = (uintptr_t)&thirdperson; + add[0] = (uintptr_t)✓ + add[1] = (uintptr_t)&aim; + add[2] = (uintptr_t)&esp; + add[3] = (uintptr_t)&aiming; + add[4] = (uintptr_t)&g_Base; + add[5] = (uintptr_t)&next; + add[6] = (uintptr_t)&players[0]; + add[7] = (uintptr_t)&valid; + add[8] = (uintptr_t)&max_dist; + add[9] = (uintptr_t)&item_glow; + add[10] = (uintptr_t)&player_glow; + add[11] = (uintptr_t)&aim_no_recoil; + add[12] = (uintptr_t)&smooth; + add[13] = (uintptr_t)&max_fov; + add[14] = (uintptr_t)&bone; + add[15] = (uintptr_t)&thirdperson; printf(XorStr("add offset: 0x%I64x\n"), (uint64_t)&add[0] - (uint64_t)GetModuleHandle(NULL)); + Overlay ov1 = Overlay(); ov1.Start(); printf(XorStr("Waiting for host process...\n")); - while (spectators == 1) + while (check == 0xABCD) { if (IsKeyDown(VK_F4)) { @@ -199,29 +196,6 @@ int main(int argc, char** argv) k_f6 = 0; } - if (IsKeyDown(VK_F7) && k_f7 == 0) - { - k_f7 = 1; - switch (safe_level) - { - case 0: - safe_level = 1; - break; - case 1: - safe_level = 2; - break; - case 2: - safe_level = 0; - break; - default: - break; - } - } - else if (!IsKeyDown(VK_F7) && k_f7 == 1) - { - k_f7 = 0; - } - if (IsKeyDown(VK_F8) && k_f8 == 0) { k_f8 = 1; diff --git a/apex_guest/Client/Client/overlay.cpp b/apex_guest/Client/Client/overlay.cpp index 866813a..e6e77db 100644 --- a/apex_guest/Client/Client/overlay.cpp +++ b/apex_guest/Client/Client/overlay.cpp @@ -7,9 +7,6 @@ extern bool player_glow; extern bool aim_no_recoil; extern bool ready; extern bool use_nvidia; -extern int safe_level; -extern int spectators; -extern int allied_spectators; extern float max_dist; extern float smooth; extern float max_fov; @@ -67,14 +64,16 @@ BOOL CALLBACK EnumWindowsCallback(HWND hwnd, LPARAM lParam) } // Data -static LPDIRECT3D9 g_pD3D = NULL; -static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; -static D3DPRESENT_PARAMETERS g_d3dpp = {}; +static ID3D11Device* g_pd3dDevice = NULL; +static ID3D11DeviceContext* g_pd3dDeviceContext = NULL; +static IDXGISwapChain* g_pSwapChain = NULL; +static ID3D11RenderTargetView* g_mainRenderTargetView = NULL; // Forward declarations of helper functions bool CreateDeviceD3D(HWND hWnd); void CleanupDeviceD3D(); -void ResetDevice(); +void CreateRenderTarget(); +void CleanupRenderTarget(); void Overlay::RenderMenu() { @@ -101,23 +100,6 @@ void Overlay::RenderMenu() vis_check = false; } - if (safe_level > 0) - { - spec_disable = true; - if (safe_level > 1) - { - all_spec_disable = true; - } - else - { - all_spec_disable = false; - } - } - else - { - spec_disable = false; - all_spec_disable = false; - } ImGui::SetNextWindowPos(ImVec2(0, 0)); ImGui::SetNextWindowSize(ImVec2(490, 215)); ImGui::Begin(XorStr("##title"), (bool*)true, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar); @@ -125,25 +107,6 @@ void Overlay::RenderMenu() { if (ImGui::BeginTabItem(XorStr("Main"))) { - ImGui::Checkbox(XorStr("Disable with enemy spectators"), &spec_disable); - if (spec_disable) - { - ImGui::SameLine(); - ImGui::Checkbox(XorStr("Disable with allied spectators"), &all_spec_disable); - if (all_spec_disable) - { - safe_level = 2; - } - else - { - safe_level = 1; - } - } - else - { - safe_level = 0; - } - ImGui::Checkbox(XorStr("ESP"), &esp); ImGui::Checkbox(XorStr("AIM"), &aim_enable); @@ -211,27 +174,9 @@ void Overlay::RenderMenu() void Overlay::RenderInfo() { ImGui::SetNextWindowPos(ImVec2(0, 0)); - ImGui::SetNextWindowSize(ImVec2(20, 20)); + ImGui::SetNextWindowSize(ImVec2(22, 12)); ImGui::Begin(XorStr("##info"), (bool*)true, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar); - switch (safe_level) - { - case 0: - DrawLine(ImVec2(9, 5), ImVec2(17, 5), RED, 2); - break; - case 1: - DrawLine(ImVec2(9, 5), ImVec2(17, 5), ORANGE, 2); - break; - case 2: - DrawLine(ImVec2(9, 5), ImVec2(17, 5), GREEN, 2); - break; - default: - break; - } - ImGui::TextColored(RED, "%d", spectators); - ImGui::SameLine(); - /*ImGui::Text("-"); - ImGui::SameLine(); - ImGui::TextColored(GREEN, "%d", allied_spectators);*/ + DrawLine(ImVec2(7, 5), ImVec2(17, 5), RED, 4); ImGui::End(); } @@ -265,7 +210,7 @@ DWORD Overlay::CreateOverlay() HDC hDC = ::GetWindowDC(NULL); width = ::GetDeviceCaps(hDC, HORZRES); height = ::GetDeviceCaps(hDC, VERTRES); - + running = true; // Initialize Direct3D @@ -286,10 +231,11 @@ DWORD Overlay::CreateOverlay() // Setup Dear ImGui style ImGui::StyleColorsDark(); + ImGui::GetStyle().WindowMinSize = ImVec2(1, 1); // Setup Platform/Renderer bindings ImGui_ImplWin32_Init(overlayHWND); - ImGui_ImplDX9_Init(g_pd3dDevice); + ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 0.00f); @@ -329,7 +275,7 @@ DWORD Overlay::CreateOverlay() } // Start the Dear ImGui frame - ImGui_ImplDX9_NewFrame(); + ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); @@ -351,34 +297,26 @@ DWORD Overlay::CreateOverlay() k_ins = true; } else if (!IsKeyDown(VK_INSERT) && k_ins) - { + { k_ins = false; } - - if(show_menu) + + if (show_menu) RenderMenu(); else RenderInfo(); RenderEsp(); + // Rendering ImGui::EndFrame(); - g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); - D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x * 255.0f), (int)(clear_color.y * 255.0f), (int)(clear_color.z * 255.0f), (int)(clear_color.w * 255.0f)); - g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); - if (g_pd3dDevice->BeginScene() >= 0) - { - ImGui::Render(); - ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); - g_pd3dDevice->EndScene(); - } - HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL); + ImGui::Render(); + const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; + g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); + g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - // Handle loss of D3D9 device - if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) - ResetDevice(); + g_pSwapChain->Present(1, 0); // Present with vsync std::this_thread::sleep_for(std::chrono::milliseconds(1)); } @@ -418,43 +356,58 @@ int Overlay::getHeight() // Helper functions -bool CreateDeviceD3D(HWND hWnd) +void CreateRenderTarget() { - if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) - return false; + ID3D11Texture2D* pBackBuffer; + g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); + if (pBackBuffer) + { + g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView); + pBackBuffer->Release(); + } +} - // Create the D3DDevice - ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); - g_d3dpp.Windowed = TRUE; - g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - g_d3dpp.EnableAutoDepthStencil = TRUE; - g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; - g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; - g_d3dpp.hDeviceWindow = hWnd; - g_d3dpp.MultiSampleQuality = D3DMULTISAMPLE_NONE; - g_d3dpp.BackBufferCount = 1; - g_d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; - g_d3dpp.BackBufferWidth = 0; - g_d3dpp.BackBufferHeight = 0; - if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) +bool CreateDeviceD3D(HWND hWnd) +{ + // Setup swap chain + DXGI_SWAP_CHAIN_DESC sd; + ZeroMemory(&sd, sizeof(sd)); + sd.BufferCount = 2; + sd.BufferDesc.Width = 0; + sd.BufferDesc.Height = 0; + sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + sd.BufferDesc.RefreshRate.Numerator = 60; + sd.BufferDesc.RefreshRate.Denominator = 1; + sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.OutputWindow = hWnd; + sd.SampleDesc.Count = 1; + sd.SampleDesc.Quality = 0; + sd.Windowed = TRUE; + sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + + UINT createDeviceFlags = 0; + //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; + D3D_FEATURE_LEVEL featureLevel; + const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, }; + if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK) return false; + CreateRenderTarget(); return true; } -void CleanupDeviceD3D() +void CleanupRenderTarget() { - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } - if (g_pD3D) { g_pD3D->Release(); g_pD3D = NULL; } + if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; } } -void ResetDevice() +void CleanupDeviceD3D() { - ImGui_ImplDX9_InvalidateDeviceObjects(); - HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp); - if (hr == D3DERR_INVALIDCALL) - IM_ASSERT(0); - ImGui_ImplDX9_CreateDeviceObjects(); + CleanupRenderTarget(); + if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; } + if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } void Overlay::DrawLine(ImVec2 a, ImVec2 b, ImColor color, float width) diff --git a/apex_guest/Client/Client/overlay.h b/apex_guest/Client/Client/overlay.h index 6f519f1..b34d4ad 100644 --- a/apex_guest/Client/Client/overlay.h +++ b/apex_guest/Client/Client/overlay.h @@ -1,6 +1,5 @@ #pragma once - #include #include #include @@ -13,12 +12,11 @@ #include #include "XorString.h" #include "imgui/imgui.h" -#include "imgui/imgui_impl_dx9.h" +#include "imgui/imgui_impl_dx11.h" #include "imgui/imgui_impl_win32.h" -#include -#pragma comment(lib, "d3d9.lib") -#include -#pragma comment(lib, "d3dx9.lib") +#include +#pragma comment(lib, "d3d11.lib") + #define GREEN ImColor(0, 255, 0) #define RED ImColor(255, 0, 0) #define BLUE ImColor(0, 0, 255)