Subtle Aimbot/Triggerbot

Posts 1–4 of 4 · Page 1 of 1
Subtle Aimbot/Triggerbot
**Puddin Poppins Source for his Aimbot/Triggerbot**

dllmain.cpp:

Code:
#include "stdafx.h"

#pragma region HackBack

#pragma region decl

#pragma region group1//these change with updates

const DWORD DwEntityList = 0x4A0F014;
const DWORD DwEnginePointer = 0x55A434;
const DWORD DwLocalPlayer = 0xA6C90C;
#pragma endregion 

#pragma region group2//these normally don't
const DWORD DwCrosshairId = 0x23F8;
const DWORD DwViewAngle = 0x4CE0;
const DWORD DwVecViewOrigin = 0x104;
const DWORD DwVecOrigin = 0x134;
const DWORD DwVecPunch = 0x13DC;
const DWORD DwTeamNumber = 0xF0;
const DWORD DwShotsFired = 0x1D58;
const DWORD DwFlags = 0x100;
const DWORD DwBoneMatrix = 0xA78;
const DWORD DwEntitySize = 0x10;
const DWORD DwHealth = 0xFC;
const DWORD DwLifeState = 0x25B;
const DWORD DwVecVelocity = 0x110;
#pragma endregion

#pragma region group3//other shit
HANDLE TargetProcess;
DWORD DwClient;
DWORD DwEngine;
CConsole Console1;
bool KILLAPP = false;
bool Thread1Paused = false;
bool TRIG = true;
bool AIM = true;
string aimval = "ON";
string trigval = "ON";
float PitchMinPunch = 2.f;
float PitchMaxPunch = 2.f;
float YawMinPunch = 2.f;
float YawMaxPunch = 2.f;
int TargetBone = 10;
float smoothamount = 20.f;
DWORD TrigVkeyCode = 4;
DWORD AimVkeyCode = 1;
#pragma endregion

#pragma endregion

void EnableDebugPriv()
{
    HANDLE HTOKEN;
    LUID LUID;
    TOKEN_PRIVILEGES TOKEN_PRIV;
    OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &HTOKEN);
    LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &LUID);
    TOKEN_PRIV.PrivilegeCount = 1;
    TOKEN_PRIV.Privileges[0].Luid = LUID;
    TOKEN_PRIV.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    AdjustTokenPrivileges(HTOKEN, false, &TOKEN_PRIV, sizeof(TOKEN_PRIV), NULL, NULL);
    CloseHandle(HTOKEN);
}

struct //ghetto memory class
{
    template <typename ReadType> ReadType R(DWORD Address, bool isarray = false, int elementcount = 1, ReadType SrcData = 0)
    {
        if (!isarray)
        {
            ReadType Data;
            ReadProcessMemory(TargetProcess, (LPVOID)(Address), &Data, sizeof(ReadType), 0);
            return Data;
        }
        else if (isarray)
        {
            ReadProcessMemory(TargetProcess, (LPVOID)(Address), (ReadType*)SrcData, sizeof(ReadType)* elementcount, 0);
            return NULL;
        }
    }
    template<typename WriteType> WriteType W(DWORD Address, WriteType Data, bool isarray = false, int elementcount = 1)
    {
        if (!isarray)
        {
            WriteProcessMemory(TargetProcess, (LPVOID)(Address), &Data, sizeof(WriteType)* elementcount, 0);
            return Data;
        }
        else if (isarray)
        {
            WriteProcessMemory(TargetProcess, (LPVOID)(Address), (WriteType*)Data, sizeof(WriteType)* elementcount, 0);
            return NULL;
        }
    }
}Mem;

DWORD GetModuleHandleByName(wchar_t* ModuleName, DWORD ProcID)
{
    MODULEENTRY32 ENTRY;
    ENTRY.dwSize = sizeof(MODULEENTRY32);
    HANDLE HSNAP = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcID);
    if (Module32First(HSNAP, &ENTRY) == TRUE)
    {
        if (!_wcsicmp(ENTRY.szModule, ModuleName))
        {
            DWORD HMODULE = (DWORD)ENTRY.modBaseAddr;
            return HMODULE;
        }
        else
        {
            while (Module32Next(HSNAP, &ENTRY) == TRUE)
            {
                if (!_wcsicmp(ENTRY.szModule, ModuleName))
                {
                    DWORD HMODULE = (DWORD)ENTRY.modBaseAddr;
                    return HMODULE;
                }
            }
            return 0;
        }
    }
    CloseHandle(HSNAP);
}

HANDLE GetProcessHandleByName(wchar_t* ProcessName)
{
    PROCESSENTRY32 ENTRY;
    ENTRY.dwSize = sizeof(PROCESSENTRY32);
    HANDLE HSNAP = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
    if (Process32First(HSNAP, &ENTRY) == TRUE)
    {
        if (!_wcsicmp(ENTRY.szExeFile, ProcessName))
        {
            HANDLE HPROC = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ENTRY.th32ProcessID);
            return HPROC;
        }
        else
        {
            while (Process32Next(HSNAP, &ENTRY) == TRUE)
            {
                if (!_wcsicmp(ENTRY.szExeFile, ProcessName))
                {
                    HANDLE HPROC = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ENTRY.th32ProcessID);
                    return HPROC;
                }
            }
            return 0;
        }
    }
    CloseHandle(HSNAP);
}

#pragma endregion

struct
{

    DWORD GetBaseEntity(int PlayerNumber)
    {
        return Mem.R<DWORD>(DwClient + DwEntityList + (DwEntitySize * PlayerNumber));
    }

    bool IsDead(int PlayerNumber)
    {
        DWORD BaseEntity = GetBaseEntity(PlayerNumber);
        if (BaseEntity)
        {
            return Mem.R<bool>(BaseEntity + DwLifeState);
        }
    }

    int GetTeam(int PlayerNumber)
    {
        DWORD BaseEntity = GetBaseEntity(PlayerNumber);
        if (BaseEntity)
        {
            return Mem.R<int>(BaseEntity + DwTeamNumber);
        }
    }

    void GetVelocity(int PlayerNumber, float* Buffer)
    {
        DWORD BaseEntity = GetBaseEntity(PlayerNumber);
        if (BaseEntity)
        {
            Mem.R<float*>(BaseEntity + DwVecVelocity, true, 3, Buffer);
        }
    }

    void GetBonePosition(int PlayerNumber, float* BonePosition)
    {
        DWORD BaseEntity = GetBaseEntity(PlayerNumber);
        if (BaseEntity)
        {
            DWORD BoneMatrix = Mem.R<DWORD>(BaseEntity + DwBoneMatrix);
            if (BoneMatrix)
            {
                Mem.R<float*>(BoneMatrix + 0x30 * TargetBone + 0x0C, true, 1, &BonePosition[0]);
                Mem.R<float*>(BoneMatrix + 0x30 * TargetBone + 0x1C, true, 1, &BonePosition[1]);
                Mem.R<float*>(BoneMatrix + 0x30 * TargetBone + 0x2C, true, 1, &BonePosition[2]);
            }
        }
    }

}EntityList;

struct
{

    DWORD GetPlayerBase()
    {
        return Mem.R<DWORD>(DwClient + DwLocalPlayer);
    }

    void SetAngles(float* Angles)
    {
        DWORD AnglePointer = Mem.R<DWORD>(DwEngine + DwEnginePointer);
        if (AnglePointer)
        {
            Mem.W<float*>(AnglePointer + DwViewAngle, Angles, true, 3);
        }
    }

    void GetVelocity(float* Buffer)
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            Mem.R<float*>(PlayerBase + DwVecVelocity, true, 3, Buffer);
        }
    }

    void GetAngles(float* Angles)
    {
        DWORD AnglePointer = Mem.R<DWORD>(DwEngine + DwEnginePointer);
        if (AnglePointer)
        {
            Mem.R<float*>(AnglePointer + DwViewAngle, true, 3, Angles);
        }
    }

    int GetTeam()
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            return Mem.R<int>(PlayerBase + DwTeamNumber);
        }
    }

    int GetCrosshairId()
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            return Mem.R<int>(PlayerBase + DwCrosshairId) - 1;
        }
    }

    void GetPunch(float* Punch)
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            Mem.R<float*>(PlayerBase + DwVecPunch, true, 2, Punch);
        }
    }

    float GetViewOrigin()
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            float Vecview[3];
            Mem.R<float*>(PlayerBase + DwVecViewOrigin, true, 3, Vecview);
            return Vecview[2];
        }
    }

    void GetPosition(float* Position)
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            Mem.R<float*>(PlayerBase + DwVecOrigin, true, 3, Position);
        }
    }

    int GetShotsFired()
    {
        DWORD PlayerBase = GetPlayerBase();
        if (PlayerBase)
        {
            return Mem.R<int>(PlayerBase + DwShotsFired);
        }
    }

}Player;

void AngleNormalize(float* angle)
{
    if (angle[0] > 89.0f && angle[0] <= 180.0f)
    {
        angle[0] = 89.0f;
    }
    if (angle[0] > 180.f)
    {
        angle[0] -= 360.f;
    }
    if (angle[0] < -89.0f)
    {
        angle[0] = -89.0f;
    }
    if (angle[1] > 180.f)
    {
        angle[1] -= 360.f;
    }
    if (angle[1] < -180.f)
    {
        angle[1] += 360.f;
    }
    if (angle[2] != 0.0f)
    {
        angle[2] = 0.0f;
    }
}

void calcang(float *src, float *dst, float *angles)
{
    random_device Random;
    mt19937 RandomGen(Random());
    uniform_real<float> RandomXdistrib(PitchMinPunch, PitchMaxPunch);
    uniform_real<float> RandomYdistrib(YawMinPunch, YawMaxPunch);
    float MyPunch[2];
    Player.GetPunch(MyPunch);
    float pitchreduction = RandomXdistrib(RandomGen);
    float yawreduction = RandomYdistrib(RandomGen);
    float delta[3] = { (src[0] - dst[0]), (src[1] - dst[1]), ((src[2] + Player.GetViewOrigin()) - dst[2]) };
    float hyp = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
    angles[0] = atanf(delta[2] / hyp) * 57.295779513082f - MyPunch[0] * pitchreduction;
    angles[1] = atanf(delta[1] / delta[0]) * 57.295779513082f - MyPunch[1] * yawreduction;
    angles[2] = 0.0f;
    if (delta[0] >= 0.0)
    {
        angles[1] += 180.0f;
    }
}

void SmoothAngleSet(float* dest, float* orig)
{
    float SmoothAngles[3];
    SmoothAngles[0] = dest[0] - orig[0];
    SmoothAngles[1] = dest[1] - orig[1];
    SmoothAngles[2] = 0.0f;
    AngleNormalize(SmoothAngles);
    SmoothAngles[0] = orig[0] + SmoothAngles[0] / 100.0f * smoothamount;
    SmoothAngles[1] = orig[1] + SmoothAngles[1] / 100.0f * smoothamount;
    SmoothAngles[2] = 0.0f;
    AngleNormalize(SmoothAngles);
    Player.SetAngles(SmoothAngles);
    Sleep(1);
}

void Click()
{
    mouse_event(MOUSEEVENTF_LEFTDOWN, NULL, NULL, NULL, NULL);
    Sleep(1);
    mouse_event(MOUSEEVENTF_LEFTUP, NULL, NULL, NULL, NULL);
    Sleep(30);
}

void VelocityComp(int PlayerNumber, float* EnemyPos)
{
    float EnemyVelocity[3];
    float MyVelocity[3];
    EntityList.GetVelocity(PlayerNumber, EnemyVelocity);
    Player.GetVelocity(MyVelocity);
    EnemyPos[0] = EnemyPos[0] + (EnemyVelocity[0] / 100.f) * (40.f / smoothamount); //not sure why 40 works. I tried a lot of different values and 40 seems to scale perfectly
    EnemyPos[1] = EnemyPos[1] + (EnemyVelocity[1] / 100.f) * (40.f / smoothamount);
    EnemyPos[2] = EnemyPos[2] + (EnemyVelocity[2] / 100.f) * (40.f / smoothamount);
    EnemyPos[0] = EnemyPos[0] - (MyVelocity[0] / 100.f) * (40.f / smoothamount);
    EnemyPos[1] = EnemyPos[1] - (MyVelocity[1] / 100.f) * (40.f / smoothamount);
    EnemyPos[2] = EnemyPos[2] - (MyVelocity[2] / 100.f) * (40.f / smoothamount);
}

DWORD WINAPI AB(LPVOID params)
{
    cout << "$ Aimbot/Triggerbot thread is running..." << endl;
    while (true)
    {
        Sleep(1);
        if (KILLAPP)
        {
            cout << "$ Ending thread..." << endl;
            ExitThread(0);
        }
        if (AIM || TRIG)
        {
            Thread1Paused = false;
            if (AIM)
            {
                int PlayerNumber = Player.GetCrosshairId();
                while (GetAsyncKeyState(AimVkeyCode) < 0 && Player.GetShotsFired() > 1 && PlayerNumber < 64 && PlayerNumber >= 0 && EntityList.GetTeam(PlayerNumber) != Player.GetTeam() && EntityList.IsDead(PlayerNumber) != true)
                {
                    int TempPlayerNumber = Player.GetCrosshairId();
                    if (TempPlayerNumber < 64 && TempPlayerNumber >= 0 && EntityList.GetTeam(TempPlayerNumber) != Player.GetTeam() && EntityList.IsDead(TempPlayerNumber) != true)
                    {
                        PlayerNumber = TempPlayerNumber;
                    }
                    float PlayerPos[3];
                    float EnemyPos[3];
                    float AimAngle[3];
                    float CurrentAngle[3];
                    Player.GetPosition(PlayerPos);
                    EntityList.GetBonePosition(PlayerNumber, EnemyPos);
                    VelocityComp(PlayerNumber, EnemyPos);
                    calcang(PlayerPos, EnemyPos, AimAngle);
                    AngleNormalize(AimAngle);
                    Player.GetAngles(CurrentAngle);
                    AngleNormalize(CurrentAngle);
                    SmoothAngleSet(AimAngle, CurrentAngle);
                    Sleep(1);
                }
            }
            if (TRIG)
            {
                if (GetAsyncKeyState(TrigVkeyCode) < 0 && TrigVkeyCode != 1)
                {
                    int PlayerNumber = Player.GetCrosshairId();
                    if (PlayerNumber < 64 && PlayerNumber >= 0 && EntityList.GetTeam(PlayerNumber) != Player.GetTeam() && EntityList.IsDead(PlayerNumber) != true)
                    {
                        Click();
                    }
                    else
                    {
                        Sleep(1);
                    }
                }
            }
        }
        else
        {
            Thread1Paused = true;
            Sleep(500);
        }
    }
}

void Init()
{
    cout << "$ Adjusting privilages..." << endl;
    EnableDebugPriv();
    cout << "$ Done." << endl;
    cout << "$ Waiting for process..." << endl;
    TargetProcess = NULL;
    while (!TargetProcess)
    {
        cout << ".";
        TargetProcess = GetProcessHandleByName(L"csgo.exe");
        Sleep(500);
    }
    cout << endl;
    cout << "$ Getting Client handle..." << endl;
    DwClient = NULL;
    while (!DwClient)
    {
        cout << ".";
        DwClient = GetModuleHandleByName(L"Client.dll", GetProcessId(TargetProcess));
        Sleep(500);
    }
    cout << endl;
    cout << "$ Getting Engine handle..." << endl;
    DwEngine = NULL;
    while (!DwEngine)
    {
        cout << ".";
        DwEngine = GetModuleHandleByName(L"Engine.dll", GetProcessId(TargetProcess));
        Sleep(500);
    }
    cout << endl;
    cout << "$ Done." << endl;
}

DWORD WINAPI Main(LPVOID params)
{
    cout << "$ ---Puddin' Poppin's CS:GO subtle-aimbot & triggerbot--- ~ENJOY!" << endl;
    system("pause");
    Init();
    CreateThread(0, 0x1000, &AB, 0, 0, 0);
    Sleep(1000);
    cout << "$ Instructions:" << endl << "$ CRTL+F10 to reload hack" << endl << "$ CTRL+F8 to close" << endl << "$ CTRL+NUMPAD0 to manually set options" << endl << "$ CTRL+NUMPAD1 to toggle subtle-aimbot" << endl << "$ CTRL+NUMPAD2 to toggle triggerbot" << endl << "$ CTRL+NUMPAD3 to print current settings" << endl;
    cout << "$ AIM: " << aimval << " | TRIG: " << trigval << endl;
    while (true)
    {
        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F8) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F8) < 0)
            {
                Sleep(100);
            }
            KILLAPP = true;
            if (KILLAPP)
            {
                cout << "$ Ending Main thread..." << endl;
                Console1.~CConsole();
                ExitThread(0);
            }
        }

        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD3) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD3) < 0)
            {
                Sleep(100);
            }
            cout << "$ Current settings: " << endl << "$ Smoothing factor (float) = " << smoothamount << endl << "$ Minimum RCS pitch compensation scale (float) = " << PitchMinPunch << endl << "$ Maximum RCS pitch compensation scale (float) = " << PitchMaxPunch << endl << "$ Minimum RCS yaw compensation scale (float) = " << YawMinPunch << endl << "$ Maximum RCS yaw compensation scale (float) = " << YawMaxPunch << endl << "$ Bone number to target(int) = " << TargetBone << endl << "$ Virtual-Key code of button to use for aimbot (int) = " << AimVkeyCode << endl << "$ Virtual-Key code of button to use for triggerbot (int) = " << TrigVkeyCode << endl << "$ Done." << endl;
        }

        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F10) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_F10) < 0)
            {
                Sleep(100);
            }
            cout << "$ Reloading hack..." << endl;
            bool storedAIM = AIM;
            bool storedTRIG = TRIG;
            AIM = false;
            TRIG = false;
            cout << "$ Waiting for threads to enter paused state...";
            while (!Thread1Paused)
            {
                cout << ".";
                Sleep(500);
            }
            cout << endl << "$ Done." << endl;
            Init();
            cout << "$ Done. Threads should be restored." << endl;
            AIM = storedAIM;
            TRIG = storedTRIG;
        }

        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD0) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD0) < 0)
            {
                Sleep(100);
            }
            cout << "$ Options manual reset started..." << endl;
            bool storedAIM = AIM;
            bool storedTRIG = TRIG;
            AIM = false;
            TRIG = false;
            cout << "$ Waiting for threads to enter paused state..." << endl;
            while (!Thread1Paused)
            {
                cout << ".";
                Sleep(500);
            }
            cout << endl << "$ Done." << endl;
            cout << "$ Options: " << endl;
            cout << "$ Smoothing factor (float) = ";
            cin.sync();
            float tempSmoothWriteCount;
            if (cin >> tempSmoothWriteCount)
            {
                smoothamount = tempSmoothWriteCount;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Minimum RCS pitch compensation scale (float) = ";
            cin.sync();
            float tempPitchMinPunch;
            if (cin >> tempPitchMinPunch)
            {
                PitchMinPunch = tempPitchMinPunch;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Maximum RCS pitch compensation scale (float) = ";
            cin.sync();
            float tempPitchMaxPunch;
            if (cin >> tempPitchMaxPunch)
            {
                PitchMaxPunch = tempPitchMaxPunch;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Minimum RCS yaw compensation scale (float) = ";
            cin.sync();
            float tempYawMinPunch;
            if (cin >> tempYawMinPunch)
            {
                YawMinPunch = tempYawMinPunch;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Maximum RCS yaw compensation scale (float) = ";
            cin.sync();
            float tempYawMaxPunch;
            if (cin >> tempYawMaxPunch)
            {
                YawMaxPunch = tempYawMaxPunch;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Bone number to target(int) = ";
            cin.sync();
            int tempboneid;
            if (cin >> tempboneid)
            {
                TargetBone = tempboneid;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Virtual-Key code of button to use for aimbot (int) = ";
            cin.sync();
            int tempaimkey;
            if (cin >> tempaimkey)
            {
                AimVkeyCode = tempaimkey;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Virtual-Key code of button to use for triggerbot (int) = ";
            cin.sync();
            int temptrigkey;
            if (cin >> temptrigkey)
            {
                TrigVkeyCode = temptrigkey;
            }
            else
            {
                cout << "$ Invalid Value. Keeping default..." << endl;
                cin.clear();
                cin.ignore(10000, '\n');
            }
            cout << "$ Done. Threads should be restored." << endl;
            AIM = storedAIM;
            TRIG = storedTRIG;
        }
        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD1) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD1) < 0)
            {
                Sleep(100);
            }
            if (AIM)
            {
                AIM = false;
            }
            else
            {
                AIM = true;
            }
            if (AIM)
            {
                aimval = "ON";
            }
            else
            {
                aimval = "OFF";
            }
            cout << "$ AIM: " << aimval << " | TRIG: " << trigval << endl;
        }
        if (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD2) < 0)
        {
            while (GetAsyncKeyState(VK_CONTROL) < 0 && GetAsyncKeyState(VK_NUMPAD2) < 0)
            {
                Sleep(100);
            }
            if (TRIG)
            {
                TRIG = false;
            }
            else
            {
                TRIG = true;
            }
            if (TRIG)
            {
                trigval = "ON";
            }
            else
            {
                trigval = "OFF";
            }
            cout << "$ AIM: " << aimval << " | TRIG: " << trigval << endl;
        }
        Sleep(25);
    }
    return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    {
        CreateThread(0, 0x1000, &Main, 0, 0, 0);
    }
    }
    return TRUE;
}
Console.cpp:
Code:
#include "stdafx.h"
static BOOL WINAPI MyConsoleCtrlHandler(DWORD dwCtrlEvent) { return dwCtrlEvent == CTRL_C_EVENT; }
const char* version = "Ver.2.3.7";
CConsole::CConsole() : ownconsole(false) {
    if (!AllocConsole()) return;
    SetConsoleCtrlHandler(MyConsoleCtrlHandler, TRUE);
    SetConsoleTitleA(version);
    RemoveMenu(GetSystemMenu(GetConsoleWindow(), FALSE), SC_CLOSE, MF_BYCOMMAND); //removes close button in the topright of the newly created console window. could cause problems. if so, just remove this line.
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_INTENSITY);
    SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_MOUSE_INPUT);
    const int in = _open_osfhandle(INT_PTR(GetStdHandle(STD_INPUT_HANDLE)), _O_TEXT);
    const int out = _open_osfhandle(INT_PTR(GetStdHandle(STD_OUTPUT_HANDLE)), _O_TEXT);
    oldstdin = *stdin;
    oldstdout = *stdout;
    *stdin = *_fdopen(in, "r");
    *stdout = *_fdopen(out, "w");
    ownconsole = true;
}

CConsole::~CConsole() {
    if (ownconsole) {
        fclose(stdout);
        fclose(stdin);
        *stdout = oldstdout;
        *stdin = oldstdin;
        SetConsoleCtrlHandler(MyConsoleCtrlHandler, FALSE);
        FreeConsole();
    }
}
Console.h
Code:
#include "stdafx.h"
#pragma once
class CConsole {
    FILE oldstdin, oldstdout;
    bool ownconsole;
public:
    CConsole();
    ~CConsole();
};
#includes to add in stdafx.h(some of these might not be necessary):

Code:
#include <windows.h>
#include <TlHelp32.h>
#include <cstdio>
#include <windows.h>
#include <conio.h>
#include <FCNTL.H>
#include <io.h>
#include "Console.h"
#include <iostream>
#include <string>
#include <sstream>
#include <random>
#include <stdint.h>
using namespace std;
seems like he get banned for this
Are you allowed to post some else's source code?
Quote Originally Posted by bigjoocycawk View Post
Are you allowed to post some else's source code?
Other people have.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?