Вопрос Почему вх в случайный момент останавливает отрисовку на месте ? APEX EXTERNAL

На самом деле я Zodiak
Участник
Статус
Оффлайн
Регистрация
22 Дек 2020
Сообщения
1,052
Реакции[?]
183
Поинты[?]
72K
Рисую с помощью ImGui
В какой то момент вх встаёт на месте и приходится перезапускать программу, в чем проблема?



Функция рендера

C++:
void Render() {

    HDC hdc = GetDC(FindWindowA(NULL, "Apex Legends"));//Getting the Window to Draw Over

    process_id = get_process_id("r5apex.exe");//Getting the Process Id
    base_address = get_module_base_address("r5apex.exe");//Getting The Module Base


    if (GetAsyncKeyState(VK_INSERT) & 1) ShowMenu = !ShowMenu;
    ImGui_ImplDX9_NewFrame();
    ImGui_ImplWin32_NewFrame();
    ImGui::NewFrame();
    Draw();
    ImGui::GetIO().MouseDrawCursor = ShowMenu;

    
    if (ShowMenu == true) {
        
        

        ImGui::Begin("dasdas", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoCollapse |
            ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar);





        



            Matrix ViewMatrix = Read<Matrix>(base_address + Offsets::ViewMatrix);//Reading the ViewMatrix and Storing it as a 16 Matrix (Not a 4x4 matrix)
            uintptr_t LocalPlayer = Read<uintptr_t>(base_address + Offsets::LocalPlayer);//Reading LocalPlayer for Own TeamMates and Calculating Enemy Distance
            render_crosshair(ScreenWidth, ScreenHeight, 60);
            for (int Entity = 0; Entity < 100; Entity++) { // For Loop so that we can loop through every Entity in Game (Enemies and TeamMates)
                uintptr_t Base = Read<uintptr_t>(base_address + Offsets::EntityList + (Entity << 5));//Reading the EntityList and storing Each Enemy (its inside a for loop so it will store all 100 entity inside the 'Base' for max loop times)

                Vector3 LocalOrigin = Read<Vector3>(LocalPlayer + Offsets::Origin);//Locating Ourselves inside Game (Owr Own Position inside Game) and Storing it as a Vecto3 (Length, Height, Breadth)
                Vector3 Origin = Read<Vector3>(Base + Offsets::Origin);//Locating Enemy inside Game (Enemy Position inside Game) and Storing it as a Vecto3 (Length, Height, Breadth)

                float Distance = (Vector3::Distance(LocalOrigin, Origin)) / 36.5f; //Calculating the distance of each enemy from ourself (not Our teammate but only YOU)

                char Dist[100];
                snprintf(Dist, sizeof(Dist), "%f", Distance);//Storing Distance(float value) as a character so that we can print it

                //DrawCrosshair(hdc, ScreenWidth, ScreenHeight, 60);//Draw CrossHasir
                render_crosshair(ScreenWidth, ScreenHeight, 60);
                if ((int)Distance <= 500) { //Emitting out the enemies who are 500 meters far away from us so we can save cpu usage and improve the fps
                    int OwnTeam = Read<int>(LocalPlayer + Offsets::TeamId);//Reading Own Team id and storing it as integer
                    int Team = Read<int>(Base + Offsets::TeamId);//Reading Enemy Team id and storing it as integer
                    float Health = Read<int>(Base + Offsets::Health);//Reading Current Enemy Health and storing it as float
                    float MaxHealth = Read<int>(Base + Offsets::MaxHealth);//Reading Maximum Enemy Health that they can have and storing it as float
                    int Knocked = Read<int>(Base + Offsets::Knocked);//Reading if enemy is knocked or not and storing it as int but we will use it as a boolean by passing 0 or 1 argument
                    int Dead = Read<int>(Base + Offsets::Dead);//Reading if enemy is Dead or not and storing it as int but we will use it as a boolean by passing 0 or 1 argument

                    Vector3 HeadPos;//Making a variable for Enemy Head Location
                    HeadPos.x = Origin.x;
                    HeadPos.y = Origin.y;
                    HeadPos.z = Origin.z + 75.f;//The height of every Object inside any game is somewhat the same as 75.f from their base of their foot (origin)

                    Vector3 OriginPos = WorldToScreen(Origin, ViewMatrix, ScreenWidth, ScreenHeight);//Converting Enemy position to 2d so we can print it or calculate stuff easilywith it
                    Vector3 HeadLocation = WorldToScreen(HeadPos, ViewMatrix, ScreenWidth, ScreenHeight);//Converting Enemy HeadLocation to 2d so we can print it or calculate stuff easilywith it

                    /************************************************************************************************
                    NOTE: I also have added the bone reading function and made it easy to understand,
                    so u can also directly read the head position instead of adding 75.f to origin,
                    but the reason is this way the box created over enemy looks better
                    *************************************************************************************************/

                    float height = HeadLocation.y - OriginPos.y;//Calculations for box height
                    float width = height / 2.4f;//Calculations for box width
                    //crosshair

                    //Draw Esp
                    if (OriginPos.z >= 0.01f && Team != OwnTeam && Health > 0 && Health < 101 && Dead == 0) {//Ommiting the entities which doesnt agree to these parameters
                        if (Knocked > 0) { // If enemy is knowcked then draw different color and stuff
                            DrawKnockedString(hdc, OriginPos.x, OriginPos.y + 30, "Knocked");//Draw a string when enemy is knocked
                            DrawKnockedString(hdc, OriginPos.x, OriginPos.y + 10, Dist);//Draw Ditance of enemy
                            //DrawKnockedRectangle(hdc, OriginPos.x - (width / 2), OriginPos.y, width, height, 1);//Draw a Rectangular box over enemy
                            //DrawKnockedLine(hdc, ScreenWidth / 2, ScreenHeight / 8, HeadLocation.x, HeadLocation.y);//Draw a line from screen top to enemy head
                            ImGui::GetBackgroundDrawList()->AddLine(ImVec2(960, 135), (ImVec2(HeadLocation.x, HeadLocation.y)), ImGui::GetColorU32(ImGuiCol_Text), 2.f);
                            ImGui::GetBackgroundDrawList()->AddRect(ImVec2(OriginPos.x - (width / 2), OriginPos.y), ImVec2(OriginPos.x + (width / 2), HeadLocation.y + 5), ImGui::GetColorU32(ImGuiCol_Text), 0.f, NULL, 1.f);

                        }
                        else { //if not knocked then do other stuff
                            DrawNotSeenString(hdc, OriginPos.x, OriginPos.y + 10, Dist);//Draw Ditance of enemy
                            DrawNotSeenRectangle(hdc, OriginPos.x - (width / 2), OriginPos.y, width, height, 1);//Draw a Rectangular box over enemy
                            //DrawNotSeenLine(hdc, ScreenWidth / 2, ScreenHeight / 8, HeadLocation.x, HeadLocation.y);//Draw a line from screen top to enemy head
                            ImGui::GetBackgroundDrawList()->AddLine(ImVec2(960, 135), (ImVec2(HeadLocation.x, HeadLocation.y)), ImGui::GetColorU32(ImGuiCol_Text), 2.f);
                            ImGui::GetBackgroundDrawList()->AddRect(ImVec2(OriginPos.x - (width / 2), OriginPos.y), ImVec2(OriginPos.x + (width / 2), HeadLocation.y + 5), ImGui::GetColorU32(ImGuiCol_Text), 0.f, NULL, 1.f);

                        }
                    }
                    //Aimbot
                            //This will aim at knocked enemy also to omit out knocked put this code inside the else of if knocked above
                    if (GetAsyncKeyState(VK_LSHIFT)) {//Holding Left Shift will activate Aimbot
                        float aimspeed = 250.f;//Speed At which it will aim
                        float lock = 10.f;//Target Locking Power (High = Aimlock)
                        float Fov = 100.f;//Fov Aim

                        if (CenterDistance(HeadLocation.x, HeadLocation.y, ScreenWidth / 2, ScreenHeight / 2) <= Fov)
                        {
                            auto Aimat = Vector2((float)round(HeadLocation.x), (float)round(HeadLocation.y + 20));
                            AimAtPos(ScreenWidth, ScreenHeight, Aimat.x, Aimat.y, aimspeed, lock, false);
                        }
                    }

                    /************************************************************************************************
                    NOTE: For those who wonder why i am reading like this 'if (Knocked > 0) 'because
                    i read the knocked as int so if it is false then it will return 1 which is actually true
                    (read details of boolean, 1 is true and 0 is false) so if knocked is more than 0 (not including 0)
                    then its a knocked, but if enemy is not knocked then it will be less than 1 so this is a better way
                    to do stuff
                    ************************************************************************************************/



                }
            }


        

        ImGui::End();

        
        



    }
    
    
    
    ImGui::EndFrame();
    ImGui::Render();


    DirectX9Interface::pDevice->SetRenderState(D3DRS_ZENABLE, false);
    DirectX9Interface::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
    DirectX9Interface::pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);

    DirectX9Interface::pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
    if (DirectX9Interface::pDevice->BeginScene() >= 0) {
        ImGui::Render();
        ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
        DirectX9Interface::pDevice->EndScene();
    }

    HRESULT result = DirectX9Interface::pDevice->Present(NULL, NULL, NULL, NULL);
    if (result == D3DERR_DEVICELOST && DirectX9Interface::pDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
        ImGui_ImplDX9_InvalidateDeviceObjects();
        DirectX9Interface::pDevice->Reset(&DirectX9Interface::pParams);
        ImGui_ImplDX9_CreateDeviceObjects();
    }
}
 
Эксперт
Статус
Оффлайн
Регистрация
17 Янв 2020
Сообщения
2,197
Реакции[?]
718
Поинты[?]
79K
Товары в продаже
1
Рисую с помощью ImGui
В какой то момент вх встаёт на месте и приходится перезапускать программу, в чем проблема?



Функция рендера

C++:
void Render() {

    HDC hdc = GetDC(FindWindowA(NULL, "Apex Legends"));//Getting the Window to Draw Over

    process_id = get_process_id("r5apex.exe");//Getting the Process Id
    base_address = get_module_base_address("r5apex.exe");//Getting The Module Base


    if (GetAsyncKeyState(VK_INSERT) & 1) ShowMenu = !ShowMenu;
    ImGui_ImplDX9_NewFrame();
    ImGui_ImplWin32_NewFrame();
    ImGui::NewFrame();
    Draw();
    ImGui::GetIO().MouseDrawCursor = ShowMenu;

 
    if (ShowMenu == true) {
     
     

        ImGui::Begin("dasdas", nullptr, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoCollapse |
            ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoScrollbar);





     



            Matrix ViewMatrix = Read<Matrix>(base_address + Offsets::ViewMatrix);//Reading the ViewMatrix and Storing it as a 16 Matrix (Not a 4x4 matrix)
            uintptr_t LocalPlayer = Read<uintptr_t>(base_address + Offsets::LocalPlayer);//Reading LocalPlayer for Own TeamMates and Calculating Enemy Distance
            render_crosshair(ScreenWidth, ScreenHeight, 60);
            for (int Entity = 0; Entity < 100; Entity++) { // For Loop so that we can loop through every Entity in Game (Enemies and TeamMates)
                uintptr_t Base = Read<uintptr_t>(base_address + Offsets::EntityList + (Entity << 5));//Reading the EntityList and storing Each Enemy (its inside a for loop so it will store all 100 entity inside the 'Base' for max loop times)

                Vector3 LocalOrigin = Read<Vector3>(LocalPlayer + Offsets::Origin);//Locating Ourselves inside Game (Owr Own Position inside Game) and Storing it as a Vecto3 (Length, Height, Breadth)
                Vector3 Origin = Read<Vector3>(Base + Offsets::Origin);//Locating Enemy inside Game (Enemy Position inside Game) and Storing it as a Vecto3 (Length, Height, Breadth)

                float Distance = (Vector3::Distance(LocalOrigin, Origin)) / 36.5f; //Calculating the distance of each enemy from ourself (not Our teammate but only YOU)

                char Dist[100];
                snprintf(Dist, sizeof(Dist), "%f", Distance);//Storing Distance(float value) as a character so that we can print it

                //DrawCrosshair(hdc, ScreenWidth, ScreenHeight, 60);//Draw CrossHasir
                render_crosshair(ScreenWidth, ScreenHeight, 60);
                if ((int)Distance <= 500) { //Emitting out the enemies who are 500 meters far away from us so we can save cpu usage and improve the fps
                    int OwnTeam = Read<int>(LocalPlayer + Offsets::TeamId);//Reading Own Team id and storing it as integer
                    int Team = Read<int>(Base + Offsets::TeamId);//Reading Enemy Team id and storing it as integer
                    float Health = Read<int>(Base + Offsets::Health);//Reading Current Enemy Health and storing it as float
                    float MaxHealth = Read<int>(Base + Offsets::MaxHealth);//Reading Maximum Enemy Health that they can have and storing it as float
                    int Knocked = Read<int>(Base + Offsets::Knocked);//Reading if enemy is knocked or not and storing it as int but we will use it as a boolean by passing 0 or 1 argument
                    int Dead = Read<int>(Base + Offsets::Dead);//Reading if enemy is Dead or not and storing it as int but we will use it as a boolean by passing 0 or 1 argument

                    Vector3 HeadPos;//Making a variable for Enemy Head Location
                    HeadPos.x = Origin.x;
                    HeadPos.y = Origin.y;
                    HeadPos.z = Origin.z + 75.f;//The height of every Object inside any game is somewhat the same as 75.f from their base of their foot (origin)

                    Vector3 OriginPos = WorldToScreen(Origin, ViewMatrix, ScreenWidth, ScreenHeight);//Converting Enemy position to 2d so we can print it or calculate stuff easilywith it
                    Vector3 HeadLocation = WorldToScreen(HeadPos, ViewMatrix, ScreenWidth, ScreenHeight);//Converting Enemy HeadLocation to 2d so we can print it or calculate stuff easilywith it

                    /************************************************************************************************
                    NOTE: I also have added the bone reading function and made it easy to understand,
                    so u can also directly read the head position instead of adding 75.f to origin,
                    but the reason is this way the box created over enemy looks better
                    *************************************************************************************************/

                    float height = HeadLocation.y - OriginPos.y;//Calculations for box height
                    float width = height / 2.4f;//Calculations for box width
                    //crosshair

                    //Draw Esp
                    if (OriginPos.z >= 0.01f && Team != OwnTeam && Health > 0 && Health < 101 && Dead == 0) {//Ommiting the entities which doesnt agree to these parameters
                        if (Knocked > 0) { // If enemy is knowcked then draw different color and stuff
                            DrawKnockedString(hdc, OriginPos.x, OriginPos.y + 30, "Knocked");//Draw a string when enemy is knocked
                            DrawKnockedString(hdc, OriginPos.x, OriginPos.y + 10, Dist);//Draw Ditance of enemy
                            //DrawKnockedRectangle(hdc, OriginPos.x - (width / 2), OriginPos.y, width, height, 1);//Draw a Rectangular box over enemy
                            //DrawKnockedLine(hdc, ScreenWidth / 2, ScreenHeight / 8, HeadLocation.x, HeadLocation.y);//Draw a line from screen top to enemy head
                            ImGui::GetBackgroundDrawList()->AddLine(ImVec2(960, 135), (ImVec2(HeadLocation.x, HeadLocation.y)), ImGui::GetColorU32(ImGuiCol_Text), 2.f);
                            ImGui::GetBackgroundDrawList()->AddRect(ImVec2(OriginPos.x - (width / 2), OriginPos.y), ImVec2(OriginPos.x + (width / 2), HeadLocation.y + 5), ImGui::GetColorU32(ImGuiCol_Text), 0.f, NULL, 1.f);

                        }
                        else { //if not knocked then do other stuff
                            DrawNotSeenString(hdc, OriginPos.x, OriginPos.y + 10, Dist);//Draw Ditance of enemy
                            DrawNotSeenRectangle(hdc, OriginPos.x - (width / 2), OriginPos.y, width, height, 1);//Draw a Rectangular box over enemy
                            //DrawNotSeenLine(hdc, ScreenWidth / 2, ScreenHeight / 8, HeadLocation.x, HeadLocation.y);//Draw a line from screen top to enemy head
                            ImGui::GetBackgroundDrawList()->AddLine(ImVec2(960, 135), (ImVec2(HeadLocation.x, HeadLocation.y)), ImGui::GetColorU32(ImGuiCol_Text), 2.f);
                            ImGui::GetBackgroundDrawList()->AddRect(ImVec2(OriginPos.x - (width / 2), OriginPos.y), ImVec2(OriginPos.x + (width / 2), HeadLocation.y + 5), ImGui::GetColorU32(ImGuiCol_Text), 0.f, NULL, 1.f);

                        }
                    }
                    //Aimbot
                            //This will aim at knocked enemy also to omit out knocked put this code inside the else of if knocked above
                    if (GetAsyncKeyState(VK_LSHIFT)) {//Holding Left Shift will activate Aimbot
                        float aimspeed = 250.f;//Speed At which it will aim
                        float lock = 10.f;//Target Locking Power (High = Aimlock)
                        float Fov = 100.f;//Fov Aim

                        if (CenterDistance(HeadLocation.x, HeadLocation.y, ScreenWidth / 2, ScreenHeight / 2) <= Fov)
                        {
                            auto Aimat = Vector2((float)round(HeadLocation.x), (float)round(HeadLocation.y + 20));
                            AimAtPos(ScreenWidth, ScreenHeight, Aimat.x, Aimat.y, aimspeed, lock, false);
                        }
                    }

                    /************************************************************************************************
                    NOTE: For those who wonder why i am reading like this 'if (Knocked > 0) 'because
                    i read the knocked as int so if it is false then it will return 1 which is actually true
                    (read details of boolean, 1 is true and 0 is false) so if knocked is more than 0 (not including 0)
                    then its a knocked, but if enemy is not knocked then it will be less than 1 so this is a better way
                    to do stuff
                    ************************************************************************************************/



                }
            }


     

        ImGui::End();

     
     



    }
 
 
 
    ImGui::EndFrame();
    ImGui::Render();


    DirectX9Interface::pDevice->SetRenderState(D3DRS_ZENABLE, false);
    DirectX9Interface::pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false);
    DirectX9Interface::pDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, false);

    DirectX9Interface::pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0);
    if (DirectX9Interface::pDevice->BeginScene() >= 0) {
        ImGui::Render();
        ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
        DirectX9Interface::pDevice->EndScene();
    }

    HRESULT result = DirectX9Interface::pDevice->Present(NULL, NULL, NULL, NULL);
    if (result == D3DERR_DEVICELOST && DirectX9Interface::pDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
        ImGui_ImplDX9_InvalidateDeviceObjects();
        DirectX9Interface::pDevice->Reset(&DirectX9Interface::pParams);
        ImGui_ImplDX9_CreateDeviceObjects();
    }
}
Насчет краш вх хз но позволь мне поправить тебя:
1648193480966.png
Не надо это пихать в оверлей. Не думаю что он поменяется просто так. Создаешь лишнюю нагрузку.(Лучше в начале запуска программе запихни или как ниже в отдельном потоке)
1648193545986.png и это тоже. Можешь отдельном потоке каждые 1-10 секунд проверять а не в каждую тик. Потом будешь гадать почему у тебя цп 60%.
1648193612866.png - А вдруг энтити больше 100, лучше получи как то список энтити (ака EntityList). Может крашит у тебя из за несуществующих энтити и лишные вычисление?
Ну то что я написал даже если не поможет с проблемой, поможет чуток с оптимизацией.

Я помню когда впервые как ты пастил чит у меня так лагала менюшка) так много говна была)
 
Сверху Снизу