Инжект .dll в процесс игры

Забаненный
Статус
Оффлайн
Регистрация
8 Фев 2019
Сообщения
13
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Здравствуйте! Решил попробовать сделать что-нибудь по кс 1.6. При инжекте - крашит. Подскажите новичку)

C++:
#include "main.h"
#include <Windows.h>
#include <StrSafe.h>
#include <Shlwapi.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <stdlib.h>
#include <cstdint>
#include <string>
#include <sstream>
#include <memory>
#include <stdlib.h>
#include <algorithm>
#include <vector>

bool FirstFrame = false;

cl_clientfunc_t* g_pClient;
cl_enginefunc_t* g_pEngine;
engine_studio_api_t* g_pStudio;

cl_clientfunc_t g_Client;
cl_enginefunc_t g_Engine;
engine_studio_api_t g_Studio;
PColor24 Console_TextColor;

void ConsolePrintColor(BYTE R, BYTE G, BYTE B, const char* fmt, ...) {
    va_list va_alist;
    char buf[1024];

    va_start(va_alist, fmt);
    _vsnprintf(buf, sizeof(buf), fmt, va_alist);

    va_end(va_alist);

    TColor24 DefaultColor; PColor24 Ptr; Ptr = Console_TextColor; DefaultColor = *Ptr; Ptr->R = R; Ptr->G = G; Ptr->B = B; g_Engine.Con_Printf(buf); *Ptr = DefaultColor;
}

void Loaded() {
    if (g_Engine.Con_IsVisible() == 0)g_Engine.pfnClientCmd((char*)"toggleconsole");
    ConsolePrintColor(0, 255, 11, "-- TEST CONSOLE\n");
}

void HUD_Frame(double time) {
    if (!FirstFrame) {
        Loaded(); FirstFrame = true;
    }
    g_Client.HUD_Frame(time);
}

void HookFunction() {
    g_pClient->HUD_Frame = HUD_Frame;
}

BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )
{
    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
        {
            LoadLibrary((LPCWSTR)"hw.dll");

            CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HookFunction, 0, 0, 0);
            break;
        }
        case DLL_THREAD_ATTACH:
        case DLL_THREAD_DETACH:
        case DLL_PROCESS_DETACH: break;
    }

    return TRUE;
}
 
Забаненный
Статус
Оффлайн
Регистрация
8 Фев 2019
Сообщения
13
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
А g_Engine мы получать не будем?
так оно получается вроде))
C++:
#pragma once
#pragma warning(disable:4996)
#pragma warning(disable:4305)
#pragma warning(disable:4309)
#pragma warning(disable:4018)
#pragma warning(disable:4101)
#pragma warning(disable:4244)
#pragma warning(disable:4800)
#pragma warning(disable:4244)
#pragma warning(disable:4995)
#include <Windows.h>
#include <TlHelp32.h>
#include <string>
#include <map>
#include <vector>
#include <fstream>
#include <algorithm>

using namespace std;

#include "ValveSDK/engine/wrect.h"
#include "ValveSDK/engine/cl_dll.h"
#include "ValveSDK/engine/r_studioint.h"
#include "ValveSDK/engine/cl_entity.h"
#include "ValveSDK/misc/com_model.h"
#include "ValveSDK/engine/triangleapi.h"
#include "ValveSDK/engine/pmtrace.h"
#include "ValveSDK/engine/pm_defs.h"
#include "ValveSDK/engine/pm_info.h"
#include "ValveSDK/common/ref_params.h"
#include "ValveSDK/common/studio_event.h"
#include "ValveSDK/common/net_api.h"
#include "ValveSDK/common/r_efx.h"
#include "ValveSDK/engine/cvardef.h"
#include "ValveSDK/engine/util_vector.h"
#include "ValveSDK/misc/parsemsg.h"
#include "ValveSDK/engine/studio.h"
#include "ValveSDK/engine/event_args.h"
#include "ValveSDK/engine/event_flags.h"
#include "ValveSDK/common/event_api.h"
#include "ValveSDK/common/screenfade.h"
#include "ValveSDK/engine/keydefs.h"
#include "ValveSDK/common/engine_launcher_api.h"
#include "ValveSDK/common/entity_types.h"

#include "struct.h"

extern cl_clientfunc_t *g_pClient;
extern cl_enginefunc_t *g_pEngine;
extern engine_studio_api_t *g_pStudio;

extern cl_clientfunc_t g_Client;
extern cl_enginefunc_t g_Engine;
extern engine_studio_api_t g_Studio;

extern PUserMsg pUserMsgBase;
extern PEngineMsg pEngineMsgBase;
extern PEventMsg pEventMsgBase;
extern PColor24 Console_TextColor;

extern SCREENINFO g_Screen;

extern char* BaseDir;

extern bool FirstFrame;
extern GameInfo_s BuildInfo;
void ConsolePrintColor(BYTE R, BYTE G, BYTE B, const char* fmt, ...);
//void HookUserMessages();
//void HookEngineMessages();
void HookFunction();
//void SearchPrintConsole();

/* enum cvar_modes {
    cvar_bad = 0,
    cvar_fake = 1,
    cvar_open = 2
};

struct m_Cvar {
    byte mode;
    string name;
    string value;
    string default;
};
void AddOrModCvar(const string line);
extern vector<m_Cvar> Cvars;
extern ptrdiff_t FindCvar(string name, vector<m_Cvar> vec_cvar); */
C++:
#pragma once

#include "main.h"

typedef void(*pfnEngineMessage)();
typedef void(*pfnEventMsgHook)(event_args_t *args);

typedef unsigned __int16 uint16;

typedef struct Color24
{
    BYTE R, G, B;
} TColor24, *PColor24;

typedef struct UserMsg
{
    int number;
    int size;
    char name[16];
    struct UserMsg* next;
    pfnUserMsgHook pfn;
} *PUserMsg;

typedef struct EngineMsg
{
    int number;
    char* name;
    pfnEngineMessage pfn;
} *PEngineMsg;
typedef struct EventMsg
{
    struct EventMsg* next;
    char* name;
    pfnEventMsgHook pfn;
} *PEventMsg;
typedef struct cmd_s
{
    struct cmd_s *next;
    char *name;
    xcommand_t function;
    int flags;
} cmd_t, *pcmd_t;

typedef struct sizebuf_s
{
    const char *buffername;
    uint16 flags;
    byte *data;
    int maxsize;
    int cursize;
} sizebuf_t;

typedef struct GameInfo_s
{
    char*        GameName;
    char*        GameVersion;
    BYTE        Protocol;
    DWORD        Build;
} GameInfo_t, *pGameInfo_s;

typedef struct cl_clientfuncs_s
{
    int(*Initialize) (cl_enginefunc_t *pEnginefuncs, int iVersion);
    int(*HUD_Init) (void);
    int(*HUD_VidInit) (void);
    void(*HUD_Redraw) (float time, int intermission);
    int(*HUD_UpdateClientData) (client_data_t *pcldata, float flTime);
    int(*HUD_Reset) (void);
    void(*HUD_PlayerMove) (struct playermove_s *ppmove, int server);
    void(*HUD_PlayerMoveInit) (struct playermove_s *ppmove);
    char(*HUD_PlayerMoveTexture) (char *name);
    void(*IN_ActivateMouse) (void);
    void(*IN_DeactivateMouse) (void);
    void(*IN_MouseEvent) (int mstate);
    void(*IN_ClearStates) (void);
    void(*IN_Accumulate) (void);
    void(*CL_CreateMove) (float frametime, struct usercmd_s *cmd, int active);
    int(*CL_IsThirdPerson) (void);
    void(*CL_CameraOffset) (float *ofs);
    struct kbutton_s *(*KB_Find) (const char *name);
    void(*CAM_Think) (void);
    void(*V_CalcRefdef) (struct ref_params_s *pparams);
    int(*HUD_AddEntity) (int type, struct cl_entity_s *ent, const char *modelname);
    void(*HUD_CreateEntities) (void);
    void(*HUD_DrawNormalTriangles) (void);
    void(*HUD_DrawTransparentTriangles) (void);
    void(*HUD_StudioEvent) (const struct mstudioevent_s *event, const struct cl_entity_s *entity);
    void(*HUD_PostRunCmd) (struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed);
    void(*HUD_Shutdown) (void);
    void(*HUD_TxferLocalOverrides) (struct entity_state_s *state, const struct clientdata_s *client);
    void(*HUD_ProcessPlayerState) (struct entity_state_s *dst, const struct entity_state_s *src);
    void(*HUD_TxferPredictionData) (struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd);
    void(*Demo_ReadBuffer) (int size, unsigned char *buffer);
    int(*HUD_ConnectionlessPacket) (struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size);
    int(*HUD_GetHullBounds) (int hullnumber, float *mins, float *maxs);
    void(*HUD_Frame) (double time);
    int(*HUD_Key_Event) (int down, int keynum, const char *pszCurrentBinding);
    void(*HUD_TempEntUpdate) (double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int(*Callback_AddVisibleEntity)(struct cl_entity_s *pEntity), void(*Callback_TempEntPlaySound)(struct tempent_s *pTemp, float damp));
    struct cl_entity_s *(*HUD_GetUserEntity) (int index);
    int(*HUD_VoiceStatus) (int entindex, qboolean bTalking);
    int(*HUD_DirectorMessage) (unsigned char command, unsigned int firstObject, unsigned int secondObject, unsigned int flags);
    int(*HUD_GetStudioModelInterface) (int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio);
    void(*HUD_CHATINPUTPOSITION_FUNCTION) (int *x, int *y);
    int(*HUD_GETPLAYERTEAM_FUNCTION) (int iplayer);
    void(*CLIENTFACTORY) (void);
} cl_clientfunc_t;

#define    SVC_BAD                   0
#define    SVC_NOP                   1
#define    SVC_DISCONNECT            2
#define    SVC_EVENT                 3
#define    SVC_VERSION               4
#define    SVC_SETVIEW               5
#define    SVC_SOUND                 6
#define    SVC_TIME                  7
#define    SVC_PRINT                 8
#define    SVC_STUFFTEXT             9
#define    SVC_SETANGLE              10
#define    SVC_SERVERINFO            11
#define    SVC_LIGHTSTYLE            12
#define    SVC_UPDATEUSERINFO        13
#define    SVC_DELTADESCRIPTION      14
#define    SVC_CLIENTDATA            15
#define    SVC_STOPSOUND             16
#define    SVC_PINGS                 17
#define    SVC_PARTICLE              18
#define    SVC_DAMAGE                19
#define    SVC_SPAWNSTATIC           20
#define    SVC_EVENT_RELIABLE        21
#define    SVC_SPAWNBASELINE         22
#define    SVC_TEMPENTITY            23
#define    SVC_SETPAUSE              24
#define    SVC_SIGNONNUM             25
#define    SVC_CENTERPRINT           26
#define    SVC_KILLEDMONSTER         27
#define    SVC_FOUNDSECRET           28
#define    SVC_SPAWNSTATICSOUND      29
#define    SVC_INTERMISSION          30
#define    SVC_FINALE                31
#define    SVC_CDTRACK               32
#define    SVC_RESTORE               33
#define    SVC_CUTSCENE              34
#define    SVC_WEAPONANIM            35
#define    SVC_DECALNAME             36
#define    SVC_ROOMTYPE              37
#define    SVC_ADDANGLE              38
#define    SVC_NEWUSERMSG            39
#define    SVC_PACKETENTITIES        40
#define    SVC_DELTAPACKETENTITIES   41
#define    SVC_CHOKE                 42
#define    SVC_RESOURCELIST          43
#define    SVC_NEWMOVEVARS           44
#define    SVC_RESOURCEREQUEST       45
#define    SVC_CUSTOMIZATION         46
#define    SVC_CROSSHAIRANGLE        47
#define    SVC_SOUNDFADE             48
#define    SVC_FILETXFERFAILED       49
#define    SVC_HLTV                  50
#define    SVC_DIRECTOR              51
#define    SVC_VOICEINIT             52
#define    SVC_VOICEDATA             53
#define    SVC_SENDEXTRAINFO         54
#define    SVC_TIMESCALE             55
#define    SVC_RESOURCELOCATION      56
#define    SVC_SENDCVARVALUE         57
#define    SVC_SENDCVARVALUE2        58
 
Участник
Статус
Оффлайн
Регистрация
28 Янв 2019
Сообщения
552
Реакции[?]
192
Поинты[?]
1K
так оно получается вроде))
Оно получается примерно так:

Код:
//это вызывается после инжекта, перед хуком любых функций
Globals::pEngine = (cl_enginefunc_t*)Memory::EngineTable();
memcpy(&Globals::Engine, Globals::pEngine, sizeof(cl_enginefunc_t));//копируем ориги для их дальнейшего возврата из функции

//что-то такое есть в любом чите на 1.6
PVOID EngineTable()
    {
        DWORD Address = (DWORD)FindMemoryClone(HW.Base, HW.End, C("ScreenFade"), strlen(C("ScreenFade")));
        PVOID EnginePtr = (PVOID) * (PDWORD)(FindReference(HW.Base, HW.End, Address) + 0x0D);

        if (FarProc((DWORD)EnginePtr, HW.Base, HW.End))
            Utils::MsgBox(C("Engine not found"));

        return EnginePtr;
    }
Такое точно есть в вашей базе (хотя выглядит немного иначе). В файле offset.cpp или memory.cpp. А вообще, база не самая чистая. Это из-под 101xd или чего-то такого. Там код грязноват.
 
Забаненный
Статус
Оффлайн
Регистрация
8 Фев 2019
Сообщения
13
Реакции[?]
0
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код вообще брал с ExtraMirror xD. offset.cpp
C++:
#include "offset.h"

cOffset offset;

void cOffset::GetRenderType()
{
    HwDll = (DWORD)GetModuleHandleA(HW_DLL);
    SwDll = (DWORD)GetModuleHandleA(SW_DLL);
    HlMod = (DWORD)GetModuleHandleA(NULL);
}

bool cOffset::GetModuleInfo()
{
    GetRenderType();

    if (HwDll)
        HwBase = HwDll;
    else if (SwDll)
        HwBase = SwDll;
    else
        HwBase = HlMod;

    HwSize = GetModuleSize(HwBase);
    HwEnd = HwBase + HwSize - 1;

    HlBase = HlMod;
    HlSize = (DWORD)GetModuleSize(HlBase);
    HlEnd = HlBase + HlSize - 1;

    ClBase = (DWORD)GetModuleHandleA(CLIENT_DLL);

    if (ClBase)
    {
        ClSize = GetModuleSize(ClBase);
        ClEnd = ClBase + ClSize - 1;
    }
    else
    {
        ClBase = HwBase;
        ClEnd = HwEnd;
        ClSize = HwSize;
    }

    VgBase = (DWORD)GetModuleHandleA(GAMEUI_DLL);

    if (VgBase)
    {
        VgSize = (DWORD)GetModuleSize(VgBase);
        VgEnd = VgBase + VgSize - 1;
    }

    return (HwBase && ClBase && HlBase && VgBase);
}

void cOffset::Error(char* Msg)
{
    MessageBoxA(0, Msg, OFF_ERROR, MB_OK | MB_ICONERROR);
}

DWORD cOffset::FindClientTable()
{
    BYTE ClientOffset[2] = { 0x10, 0x13 };

    DWORD PatternAddress = FindPattern(OFF_CLIENT_PATTERN, HwBase, HwEnd, 0);

    if (PatternAddress)
    {
        for (byte i = 0; i < sizeof(ClientOffset); i++)
        {
            DWORD ClientTablePtr = *(PDWORD)(FindReference(HwBase, HwEnd, PatternAddress) + ClientOffset[i]);

            if (!FarProc((DWORD)ClientTablePtr, HwBase, HwEnd) &&
                !IsBadReadPtr((PVOID)ClientTablePtr, sizeof(cl_clientfunc_t)))
            {
                return ClientTablePtr;
            }
        }
    }

    return 0;
}

DWORD cOffset::FindEngineTable()
{
    DWORD PatternAddress = FindPattern(OFF_ENGINE_PATTERN, OFF_ENGINE_MASK, ClBase, ClEnd, 0x02);

    if (PatternAddress)
    {
        if (!FarProc((DWORD)PatternAddress, ClBase, ClEnd))
        {
            return *(PDWORD)PatternAddress;
        }
    }
    else
    {
        PatternAddress = FindPattern(OFF_ENGINE_PATTERN, OFF_ENGINE_MASK, HlBase, HlEnd, 0x02);

        if (PatternAddress)
        {
            if (!FarProc((DWORD)PatternAddress, HlBase, HlEnd))
            {
                return *(PDWORD)PatternAddress;
            }
        }
    }

    return 0;
}

DWORD cOffset::FindStudioTable()
{
    DWORD StudioTablePtr = *(DWORD*)((DWORD)g_pClient->HUD_GetStudioModelInterface + 0x30); // old patch, dod

    if (FarProc((DWORD)StudioTablePtr, HwBase, HwEnd) && FarProc((DWORD)StudioTablePtr, HlBase, HlEnd) &&
        FarProc((DWORD)StudioTablePtr, ClBase, ClEnd))
    {
        StudioTablePtr = *(DWORD*)((DWORD)g_pClient->HUD_GetStudioModelInterface + 0x1A); // new patch / steam   

        if (FarProc((DWORD)StudioTablePtr, ClBase, ClEnd))
            return 0;
    }

    return StudioTablePtr;
}

DWORD cOffset::FindUserMsgBase()
{
    BYTE Pattern_UserMsg[9] =
    {
        0x52, 0x50, 0xE8, 0xFF, 0xFF, 0xFF, 0xFF, 0x83, 0x00
    };

    BYTE Pattern_UserMsg2[13] =
    {
        0xFF, 0xFF, 0xFF, 0x0C,
        0x56, 0x8B, 0x35, 0xFF, 0xFF, 0xFF, 0xFF, 0x57, 0x00
    };

    DWORD Address = (DWORD)g_Engine.pfnHookUserMsg;
    DWORD UserMsgBase = Absolute(FindPattern((PCHAR)Pattern_UserMsg, OFF_MSG_USER_MASK1, Address, Address + 0x32, 3));

    if (FarProc(UserMsgBase, HwBase, HwEnd))
    {
        Error(OFF_USER_MSG_EROR1);
        return 0;
    }

    UserMsgBase = FindPattern((PCHAR)Pattern_UserMsg2, OFF_MSG_USER_MASK2, UserMsgBase, UserMsgBase + 0x32, 7);

    if (FarProc(UserMsgBase, HwBase, HwEnd))
    {
        Error(OFF_USER_MSG_EROR2);
        return 0;
    }

    return **(PDWORD*)UserMsgBase;
}

DWORD cOffset::FindGameConsole()
{
    DWORD PatternAddress = FindPattern(OFF_GAME_CONSOLE_P, VgBase, VgEnd, 0);
    DWORD ReferenAddress = FindReference(VgBase, VgEnd, PatternAddress) + 0x21;

    if (FarProc(ReferenAddress, VgBase, VgEnd))
    {
        Error(OFF_GAME_CONSOLE_R);
        return 0;
    }

    DWORD GameConsole = *(PDWORD)ReferenAddress;

    return GameConsole;
}

DWORD cOffset::FindSVCMessages()
{
    DWORD EngineMsgBase = FindPattern(OFF_SVC_MSG_PATTERN, OFF_SVC_MSG_MASK, HwBase, HwEnd, 1);

    PEngineMsg pEngineMsgBase = (PEngineMsg)(*(PDWORD)EngineMsgBase - sizeof(DWORD));

    if (pEngineMsgBase)
    {
        MSG_ReadByte = (HL_MSG_ReadByte)offset.Absolute(((DWORD)pEngineMsgBase[SVC_CDTRACK].pfn) + 1);
        MSG_ReadShort = (HL_MSG_ReadShort)offset.Absolute(((DWORD)pEngineMsgBase[SVC_STOPSOUND].pfn) + 1);
        MSG_ReadLong = (HL_MSG_ReadLong)offset.Absolute(((DWORD)pEngineMsgBase[SVC_VERSION].pfn) + 1);
        MSG_ReadFloat = (HL_MSG_ReadFloat)offset.Absolute(((DWORD)pEngineMsgBase[SVC_TIMESCALE].pfn) + 1);
        MSG_ReadString = (HL_MSG_ReadString)offset.Absolute(((DWORD)pEngineMsgBase[SVC_PRINT].pfn) + 1);

        DWORD CallMSG_ReadCoord = offset.Absolute((DWORD)(pEngineMsgBase[SVC_PARTICLE].pfn) + 1);

        if (*(PBYTE)(CallMSG_ReadCoord + 0x13) == 0xE8)    // STEAM
            MSG_ReadCoord = (HL_MSG_ReadCoord)offset.Absolute((CallMSG_ReadCoord + 0x14));
        else if (*(PBYTE)(CallMSG_ReadCoord + 0x15) == 0xE8)    // OLD PATCH (SOFTWARE)
            MSG_ReadCoord = (HL_MSG_ReadCoord)offset.Absolute((CallMSG_ReadCoord + 0x16));
        else if (*(PBYTE)(CallMSG_ReadCoord + 0x0E) == 0xE8)    // OLD PATCH
            MSG_ReadCoord = (HL_MSG_ReadCoord)offset.Absolute((CallMSG_ReadCoord + 0x0F));
        else if (*(PBYTE)(CallMSG_ReadCoord + 0x0B) == 0xE8)    // OLD OLD PATCH
            MSG_ReadCoord = (HL_MSG_ReadCoord)offset.Absolute((CallMSG_ReadCoord + 0x0C));
        else
            offset.Error(OFF_MSG_READ_CORD);

        MSG_ReadCount = *(PINT*)((INT)(MSG_ReadByte)+1);
        MSG_CurrentSize = *(PINT*)((INT)(MSG_ReadByte)+7);
        MSG_BadRead = *(PINT*)((INT)(MSG_ReadByte)+20);

        DWORD SVC_SoundBase = (DWORD)pEngineMsgBase[SVC_SOUND].pfn;

        if (*(PBYTE)(SVC_SoundBase + 0x0E) == 0xE8)
        {
            MSG_Buffer = (sizebuf_t *)(*(PDWORD)(SVC_SoundBase + 0x0A));
            MSG_StartBitReading = (HL_MSG_StartBitReading)offset.Absolute(SVC_SoundBase + 0x0F);
            MSG_ReadBits = (HL_MSG_ReadBits)offset.Absolute(SVC_SoundBase + 0x16);
        }
        else if (*(PBYTE)(SVC_SoundBase + 0x0C) == 0xE8)
        {
            MSG_Buffer = (sizebuf_t *)(*(PDWORD)(SVC_SoundBase + 0x08));
            MSG_StartBitReading = (HL_MSG_StartBitReading)offset.Absolute(SVC_SoundBase + 0x0D);
            MSG_ReadBits = (HL_MSG_ReadBits)offset.Absolute(SVC_SoundBase + 0x14);
        }
        else
            offset.Error(OFF_MSG_STR_READING);

        if (*(PBYTE)(SVC_SoundBase + 0xD6) == 0xE8)
        {
            MSG_EndBitReading = (HL_MSG_EndBitReading)offset.Absolute(SVC_SoundBase + 0xD7);
            MSG_ReadBitVec3Coord = (HL_MSG_ReadBitVec3Coord)offset.Absolute(SVC_SoundBase + 0xAF);
        }
        else if (*(PBYTE)(SVC_SoundBase + 0xE2) == 0xE8)
        {
            MSG_EndBitReading = (HL_MSG_EndBitReading)offset.Absolute(SVC_SoundBase + 0xE3);
            MSG_ReadBitVec3Coord = (HL_MSG_ReadBitVec3Coord)offset.Absolute(SVC_SoundBase + 0xBE);
        }
        else
            offset.Error(OFF_MSG_END_READING);
    }
    else
        offset.Error(OFF_ENGINE_MSG_BASE);

    return (DWORD)pEngineMsgBase;
}
#define equali !stricmp
DWORD cOffset::FindEventMsgBase ( )
{
    DWORD PatternAddress = FindPattern ( OFF_EVENT_MSG_BASE, HwBase, HwEnd, 0 );
    DWORD ReferenAddress;
    if ( BuildInfo.Build >= 7561 ) {
        ReferenAddress = FindReference ( HwBase, HwEnd, PatternAddress ) - 0x1B;
    }
    else if ( BuildInfo.Build<6027 ) {
        ReferenAddress = FindReference ( HwBase, HwEnd, PatternAddress ) - 0x06;
    }
    else { ReferenAddress = FindReference ( HwBase, HwEnd, PatternAddress ) - 0x07; }

    if ( FarProc ( ReferenAddress, HwBase, HwEnd ) )
    {
        Error ( OFF_EVENT_MSG_ERROR );
        return 0;
    }

    return *( PDWORD )( *( PDWORD )ReferenAddress );
}
void cOffset::ConsoleColorInitalize()
{
    DWORD GameConsole = FindGameConsole();

    if (GameConsole)
    {
        DWORD Panel = (*(PDWORD)(GameConsole + 8) - GameConsole);

        Console_TextColor = PColor24(Panel + GameConsole + 288 + sizeof(DWORD));

        if (*(PDWORD)(DWORD(Console_TextColor) + 8) != 0)
        {
            Console_TextColor = PColor24(Panel + GameConsole + 288 + (sizeof(DWORD) * 2));
        }
    }
}

void cOffset::GetGameInfo(pGameInfo_s GameInfo)
{
    typedef int(*function)();
    pcmd_t cmd = CommandByName("version");
    DWORD Address = (DWORD)cmd->function;

    GameInfo->GameName = *(PCHAR*)(UINT(Address) + 1);
    GameInfo->GameVersion = *(PCHAR*)(UINT(Address) + 6);
    GameInfo->Protocol = *(PBYTE)(UINT(Address) + 11);

    Address = Absolute(UINT(Address) + 23);

    if (FarProc(Address, HwBase, HwEnd))
        Error(OFF_ERR_GAMEINFO);

    function GetBuild = (function)Address;
    GameInfo->Build = GetBuild();
}

void cOffset::CopyClient()
{
    native_memcpy(&g_Client, g_pClient, sizeof(cl_clientfunc_t));
}

void cOffset::CopyEngine()
{
    native_memcpy(&g_Engine, g_pEngine, sizeof(cl_enginefunc_t));
}

void cOffset::CopyStudio()
{
    native_memcpy(&g_Studio, g_pStudio, sizeof(engine_studio_api_t));
}

DWORD cOffset::Absolute(DWORD Address)
{
    return Address + *(PDWORD)Address + 4;
}

DWORD cOffset::FarProc(DWORD Address, DWORD LB, DWORD HB)
{
    return ((Address < LB) || (Address > HB));
}

DWORD cOffset::FindReference(DWORD start, DWORD end, DWORD Address)
{
    char szPattern[] = { 0x68, 0x00, 0x00, 0x00, 0x00, 0x00 };
    *(PDWORD)&szPattern[1] = Address;
    return FindPattern(szPattern, start, end, 0);
}

DWORD cOffset::FindPattern(PCHAR pattern, PCHAR mask, DWORD start, DWORD end, DWORD offset)
{
    int patternLength = native_strlen(pattern);
    bool found = false;

    for (DWORD i = start; i < end - patternLength; i++)
    {
        found = true;
        for (int idx = 0; idx < patternLength; idx++)
        {
            if (mask[idx] == 'x' && pattern[idx] != *(PCHAR)(i + idx))
            {
                found = false;
                break;
            }
        }
        if (found)
        {
            return i + offset;
        }
    }

    return 0;
}

DWORD cOffset::FindPattern(PCHAR pattern, DWORD start, DWORD end, DWORD offset)
{
    int patternLength = native_strlen(pattern);
    bool found = false;

    for (DWORD i = start; i < end - patternLength; i++)
    {
        found = true;
        for (int idx = 0; idx < patternLength; idx++)
        {
            if (pattern[idx] != *(PCHAR)(i + idx))
            {
                found = false;
                break;
            }
        }
        if (found)
        {
            return i + offset;
        }
    }

    return 0;
}

DWORD cOffset::GetModuleSize(DWORD Address)
{
    return PIMAGE_NT_HEADERS(Address + (DWORD)PIMAGE_DOS_HEADER(Address)->e_lfanew)->OptionalHeader.SizeOfImage;
}
 
Участник
Статус
Оффлайн
Регистрация
28 Янв 2019
Сообщения
552
Реакции[?]
192
Поинты[?]
1K
Код вообще брал с ExtraMirror xD. offset.cpp
Ну вот - FindEngineTable. Тоже самое, только тут поддерживаются овер-старые билды игры. Которые уже никто и не использует тысячу лет. Так что не стоит под движок и многие другие вещи делать по 10 возможных оффсетов. Многие из оффсетов не менялись годами, так что пусть будет лучше "ScreenFade" + 0x0D, и всё на этом.
 
Сверху Снизу