Untitled

 avatar
unknown
plain_text
2 years ago
13 kB
6
Indexable
#pragma once

#include "pch.h"
#include <Windows.h>
#include <stdio.h>
#include <iostream>
#include <thread>
#include <chrono>
#include "Menu.h"
#include <Windows.h>
#include <iostream>
#include <stdlib.h>
#include <random>


#include "ini.h"
#ifdef _WIN32
#include <io.h> 
#define access    _access_s
#else
#include <unistd.h>
#endif
#define INAME L"VALORANT  " 


using namespace std;
std::string random_string(std::string::size_type length)
{
    static auto& chrs = "0123456789"
        "abcdefghijklmnopqrstuvwxyz"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    thread_local static std::mt19937 rg{ std::random_device{}() };
    thread_local static std::uniform_int_distribution<std::string::size_type> pick(0, sizeof(chrs) - 2);

    std::string s;

    s.reserve(length);

    while (length--)
        s += chrs[pick(rg)];

    return s;
}


typedef int(*pDD_btn)(int btn);
typedef int(*pDD_movR)(int dx, int dy);

pDD_btn      DD_btn;          //Mouse button
pDD_movR   DD_movR;	     //VK to ddcode


int snapValue = 3;
int fovW;
int fovH;

int colorMode = 0;

int get_screen_width(void) {
    return GetSystemMetrics(SM_CXSCREEN);
}

int get_screen_height(void) {
    return GetSystemMetrics(SM_CYSCREEN);
}

struct point {
    double x;
    double y;
    point(double x, double y) : x(x), y(y) {}
};


//to hide console cursor (doesn't work for some reason? it did before.)
void ShowConsoleCursor(bool showFlag)
{
    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);

    CONSOLE_CURSOR_INFO     cursorInfo;

    GetConsoleCursorInfo(out, &cursorInfo);
    cursorInfo.bVisible = showFlag;
    SetConsoleCursorInfo(out, &cursorInfo);
}
//to avoid system()
void clear() {
    COORD topLeft = { 0, 0 };
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
    CONSOLE_SCREEN_BUFFER_INFO screen;
    DWORD written;

    GetConsoleScreenBufferInfo(console, &screen);
    FillConsoleOutputCharacterA(
        console, ' ', screen.dwSize.X * screen.dwSize.Y, topLeft, &written
    );
    FillConsoleOutputAttribute(
        console, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE,
        screen.dwSize.X * screen.dwSize.Y, topLeft, &written
    );
    SetConsoleCursorPosition(console, topLeft);
}



inline bool is_color(int red, int green, int blue) {

    //original color purple
    if (colorMode == 0) {
        if (green >= 170) {
            return false;
        }

        if (green >= 120) {
            return abs(red - blue) <= 8 &&
                red - green >= 50 &&
                blue - green >= 50 &&
                red >= 105 &&
                blue >= 105;
        }

        return abs(red - blue) <= 13 &&
            red - green >= 60 &&
            blue - green >= 60 &&
            red >= 110 &&
            blue >= 100;
    }

    // yellow
    else {
        if (red < 160)
        {
            return false;
        }
        if (red > 161 && red < 255) {
            return green > 150 && green < 255 && blue > 0 && blue < 79;
        }
        return false;
    }
}


//checking if settings.ini is present
bool FileExists(const std::string& Filename)
{
    return access(Filename.c_str(), 0) == 0;
}

BYTE* screenData = 0;
bool run_threads = true;
const int screen_width = get_screen_width(), screen_height = get_screen_height();

int aim_x = 0.5f;
int aim_y = 0.5f;

//bot with purple (original (again not default))
void bot() {
    int w = fovW, h = fovH;
    auto t_start = std::chrono::high_resolution_clock::now();
    auto t_end = std::chrono::high_resolution_clock::now();

    HDC hScreen = GetDC(NULL);
    HBITMAP hBitmap = CreateCompatibleBitmap(hScreen, w, h);
    screenData = (BYTE*)malloc(5 * screen_width * screen_height);
    HDC hDC = CreateCompatibleDC(hScreen);
    point middle_screen(screen_width / 2, screen_height / 2);

    BITMAPINFOHEADER amawwers = { 0 };
    amawwers.biSize = sizeof(BITMAPINFOHEADER);
    amawwers.biPlanes = 1;
    amawwers.biBitCount = 32;
    amawwers.biWidth = w;
    amawwers.biHeight = -h;
    amawwers.biCompression = BI_RGB;
    amawwers.biSizeImage = 0;

    while (run_threads) {
        Sleep(6);
        HGDIOBJ old_obj = SelectObject(hDC, hBitmap);
        BOOL bRet = BitBlt(hDC, 0, 0, w, h, hScreen, middle_screen.x - (w / 2), middle_screen.y - (h / 2), SRCCOPY);
        SelectObject(hDC, old_obj);
        GetDIBits(hDC, hBitmap, 0, h, screenData, (BITMAPINFO*)&amawwers, DIB_RGB_COLORS);
        bool stop_loop = false;
        for (int j = 0; j < h; ++j) {
            for (int i = 0; i < w * 4; i += 4) {
                 #define red screenData[i + (j*w*4) + 2]
                 #define green screenData[i + (j*w*4) + 1]
                 #define blue screenData[i + (j*w*4) + 0]

                if (is_color(red, green, blue)) {
                    aim_x = (i / 4) - (w / 2);
                    aim_y = j - (h / 2) + snapValue;
                    stop_loop = true;
                    break;
                }
            }
            if (stop_loop) {
                break;
            }
        }
        if (!stop_loop) {
            aim_x = 0.5f;
            aim_y = 0.5f;
        }
    }
}

int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    HMODULE hModule = LoadLibraryW(L"DDDLL.dll");
    if (hModule == nullptr)
    {
        return 0;
    }
    DD_btn = (pDD_btn)GetProcAddress(hModule, "DD_btn");
    DD_movR = (pDD_movR)GetProcAddress(hModule, "DD_movR");

    if (!(DD_btn && DD_movR))
    {
        return 0;
    }
    int st = DD_btn(0);
    if (st != 1)
    {
        return st;
    }

    //for toggle keys
    bool tagglekey = false;
    bool taggleactive = true;
    bool ha = false;
    bool yawajey = false;
    bool lClick = false;
    bool Lalt = false;
    bool hold = false;



    string amaw; //originally string color;
    int mode = 0;


    double sensitivity = 0.52;
    double smoothing = 0.5;
    AllocConsole();
    AttachConsole(GetCurrentProcessId());
    auto w_f = freopen("CON", "w", stdout);
    auto r_f = freopen("CON", "r", stdin);

   
    INIReader basa("config.ini");

   

    if (FileExists("config.ini") == true) {
        cout << "" << endl; //auto inject the file

        cout << endl << endl << "freeze" << endl << "closing in few days";

        Sleep(3000);
        fclose(w_f);
        fclose(r_f);
        FreeConsole();

            sensitivity = basa.GetFloat("config", "speed", 0.00);
            smoothing = basa.GetFloat("config", "smooth", 0.00);
            mode = basa.GetInteger("config", "mode", 0);

            
            if (basa.Get("settings", "snapping area", "") == "ulo") {
                snapValue = 1;
            }
            else if (basa.Get("settings", "snapping area", "") == "liog") {
                snapValue = 3;
            }
            if (basa.Get("settings", "toggle key", "") == "lclick") {
                lClick = true;
            }
            else if (basa.Get("settings", "toggle key", "") == "alt") {
                Lalt = true;
            }
            if (basa.Get("settings", "hold or toggle", "") == "") {
                hold = false;
            }
            if (basa.Get("settings", "hold or toggle", "") == "halt") {
                hold = true;
            }

            fovW = basa.GetInteger("settings", "hFov", 0);
            fovH = basa.GetInteger("settings", "vFov", 0);

            
            thread(bot).detach();

            auto t_start = std::chrono::high_resolution_clock::now();
            auto t_end = std::chrono::high_resolution_clock::now();
            auto left_start = std::chrono::high_resolution_clock::now();
            auto left_end = std::chrono::high_resolution_clock::now();
            double sensitivity_x = 1.0 / sensitivity / (screen_width / 1920.0) * 1.08;
            double sensitivity_y = 1.0 / sensitivity / (screen_height / 1080.0) * 1.08;
            bool left_down = false;


            while (run_threads) {
                t_end = std::chrono::high_resolution_clock::now();
                double elapsed_time_ms = std::chrono::duration<double, std::milli>(t_end - t_start).count();

                if (GetAsyncKeyState(VK_LBUTTON))
                {
                    left_down = true;
                }
                else
                {
                    left_down = false;
                }

                if (taggleactive == true) {

                    if (hold == true) {
                        if (lClick == true) {
                            if (GetAsyncKeyState(VK_LBUTTON))
                            {
                                ha = true;
                            }
                            else
                            {
                                ha = false;
                            }
                        }

                        if (Lalt == true) {
                            if (GetAsyncKeyState(VK_MENU))
                            {
                                ha = true;
                            }
                            else
                            {
                                ha = false;
                                
                            }
                        }

                    }

                    if (hold == false) {
                        if (lClick == true) {
                            if (GetAsyncKeyState(VK_LBUTTON) & 1)
                            {
                                ha = !ha;

                            }
                        }

                        if (Lalt == true) {
                            if (GetAsyncKeyState(VK_MENU) & 1)
                            {
                                ha = !ha;
                            }
                        }

                    }
                    if (ha) {
                        CURSORINFO cursorInfo = { 0 };
                        cursorInfo.cbSize = sizeof(cursorInfo);
                        GetCursorInfo(&cursorInfo);
                        if (cursorInfo.flags != 1) {
                            if (((mode & 1) > 0) && (VK_LBUTTON)) {
                                left_down = true;
                                if (elapsed_time_ms > 7) {
                                    t_start = std::chrono::high_resolution_clock::now();
                                    left_start = std::chrono::high_resolution_clock::now();
                                    if (aim_x != 0.5 || aim_y != 0.5) {
                                        DD_movR(double(aim_x) * sensitivity_x, double(aim_y) * sensitivity_y);
                         
                                    }
                                }
                            }
                            else if (((mode & 2) > 0)) {
                                if (elapsed_time_ms > 7) {
                                    t_start = std::chrono::high_resolution_clock::now();
                                    if (aim_x != 0 || aim_y != 0) {
                                        left_end = std::chrono::high_resolution_clock::now();
                                        double recoil_ms = std::chrono::duration<double, std::milli>(left_end - left_start).count();
                                        double extra = 38.0 * (screen_height / 1080.0) * (recoil_ms / 1000.0);
                                        if (!left_down) {
                                            extra = 0;
                                        }
                                        else if (extra > 38.0) {
                                            extra = 38.0;
                                        }
                                        double v_x = double(aim_x) * sensitivity_x * smoothing;
                                        double v_y = double(aim_y + extra) * sensitivity_y * smoothing;
                                        if (fabs(v_x) < 1.0) {
                                            v_x = v_x > 0 ? 1.05 : -1.05;
                                        }
                                        if (fabs(v_y) < 1.0) {
                                            v_y = v_y > 0 ? 1.05 : -1.05;
                                        }
                                        DD_movR(v_x, v_y);
                                    }
                                }
                            }
                        }
                    }
                }
                //end

            }
    }
    return 0;
}
Editor is loading...