Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Вопрос Сломалась энтити система

Why would it crash lmao its calling the game's function to get the localplayer controller

for other entities you can do

C++:
Expand Collapse Copy
C_BaseEntity* SDK::GetBaseEntityByIndex(int i)
{
    using GetBaseEntityByIndexFn = void* (__fastcall*)(int index);
    static GetBaseEntityByIndexFn GetBaseEntityByIndex = reinterpret_cast<GetBaseEntityByIndexFn>(
        Utils::PatternScan(CLIENT_DLL, X("8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89")));
    return GetBaseEntityByIndex == nullptr ? nullptr : reinterpret_cast<C_BaseEntity*>(GetBaseEntityByIndex(i));
}
CBaseEntity = null

Example how i do it :
C++:
Expand Collapse Copy
auto pPlayerPawn = reinterpret_cast<C_CSPlayerPawn*>(gEntitySystem->GetEntity(pPlayerController->m_hPawn()));

C++:
Expand Collapse Copy
inline auto gEntitySystem = *reinterpret_cast<CGameEntitySystem**>(schema.FindPattern("client.dll", "48 8B 0D ? ? ? ? 0F 28 DE 4C 89 6C 24 ? 4C 8B C0 4C 89 6C 24 ? 49 8B D6"));

C++:
Expand Collapse Copy
class CGameEntitySystem {
public:
    template <typename T = C_BaseEntity>
    T* GetEntity(int Index)
    {
        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(Index));
    }

    template <typename T = C_BaseEntity>
    T* GetEntity(CBaseHandle hHandle)
    {
        if (!hHandle.IsValid())
            return nullptr;

        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(hHandle.GetEntryIndex()));
    }
   
    int GetHighestEntityIndex()
    {
        return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x20F0);
    }

private:
    void* GetEntityByIndexFunction(int Index)
    {
        SCHEMA schema;
        using fnGetBaseEntity = void* (__fastcall*)(void*, int);
        static auto GetBaseEntity = reinterpret_cast<fnGetBaseEntity>(schema.FindPattern("client.dll", "8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89"));
        return GetBaseEntity(this, Index);
    }
};
 
Последнее редактирование:
CBaseEntity = null

Example how i do it :
C++:
Expand Collapse Copy
auto pPlayerPawn = reinterpret_cast<C_CSPlayerPawn*>(gEntitySystem->GetEntity(pPlayerController->m_hPawn()));

C++:
Expand Collapse Copy
inline auto gEntitySystem = *reinterpret_cast<CGameEntitySystem**>(schema.FindPattern("client.dll", "48 8B 0D ? ? ? ? 0F 28 DE 4C 89 6C 24 ? 4C 8B C0 4C 89 6C 24 ? 49 8B D6"));

C++:
Expand Collapse Copy
class CGameEntitySystem {
public:
    template <typename T = C_BaseEntity>
    T* GetEntity(int Index)
    {
        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(Index));
    }

    template <typename T = C_BaseEntity>
    T* GetEntity(CBaseHandle hHandle)
    {
        if (!hHandle.IsValid())
            return nullptr;

        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(hHandle.GetEntryIndex()));
    }
  
    int GetHighestEntityIndex()
    {
        return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x20F0);
    }

private:
    void* GetEntityByIndexFunction(int Index)
    {
        SCHEMA schema;
        using fnGetBaseEntity = void* (__fastcall*)(void*, int);
        static auto GetBaseEntity = reinterpret_cast<fnGetBaseEntity>(schema.FindPattern("client.dll", "8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89"));
        return GetBaseEntity(this, Index);
    }
};
ты обновил GetSchemaClassInfo? если нет, то просто поменяй с 38 --> 42
 
C++:
Expand Collapse Copy
#define MAX_PATH_LENGTH 260

namespace Virtual
{
    template <int Index, typename ReturnType, typename... Args>
    inline ReturnType Call(void* pThis, Args... args)
    {
        using func = ReturnType(__thiscall*)(void*, Args...);
        return (*(func**)(pThis))[Index](pThis, args...);
    }
}

template <class T>
class CUtlVector
{
public:
    int m_Size;
    T* m_Elements;

    T& operator[](int i) { return m_Elements[i]; }
};

    class CSchemaSystem;
    class CSchemaSystemTypeScope;
    class CSchemaType_XXX;
    struct SchemaClassFieldData_t;
    struct SchemaBaseClassInfoData_t;
    struct SchemaStaticFieldData_t;
    struct SchemaClassInfoData_t;

    class CSchemaSystem
    {
    public:
        char                                      pad[0x190];
        CUtlVector<CSchemaSystemTypeScope *> m_TypeScope; // 0x190

    public:
        CSchemaSystemTypeScope *FindTypeScopeForModule(const char *moduleName)
        {
            return Virtual::Call<0xD, CSchemaSystemTypeScope *>(this, moduleName, nullptr);
        }
    };

    class CSchemaSystemTypeScope
    {
    public:
        void *vt;            // 0x00
        char  m_Name[0x100]; // 0x08
        // CUtlTSHash<CSchemaClassBinding> 0x588
        // CUtlTSHash<CSchemaEnumBinding>  0x2DD0

        SchemaClassInfoData_t *FindDeclaredClass(const char *className)
        {
            if (this == nullptr)
                return nullptr;

            SchemaClassInfoData_t *classInfo = nullptr;
            Virtual::Call<2, void *>(this, &classInfo, className);
            return classInfo;
        }
    };

    class CSchemaType_XXX
    {
    public:
        virtual void           *VirtualFunction_0() {} // 0x00
        const char             *m_TypeName;            // 0x08
        CSchemaSystemTypeScope *m_TypeScope;           // 0x10
    };

    struct SchemaClassFieldData_t
    {
        const char      *m_FieldName;  // 0x00
        CSchemaType_XXX *m_SchemaType; // 0x08
        int32_t          m_Offset;     // 0x10
        int32_t          pad0;         // 0x14
        int64_t          pad1;         // 0x18
    };

    struct SchemaBaseClassInfoData_t
    {
        uint64_t               pad0;        // 0x00
        SchemaClassInfoData_t *m_ClassInfo; // 0x08
    };

    struct SchemaStaticFieldData_t
    {
        const char      *m_FieldName;  // 0x0000
        CSchemaType_XXX *m_SchemaType; // 0x0008
        void            *m_Instance;   // 0x0010

        uint64_t pad_0x18; // 0x0018
        uint64_t pad_0x20; // 0x0020
    };

    // https://github.com/neverlosecc/source2gen/blob/main/include/sdk/interfaces/schemasystem/schema.h
    // https://github.com/bruhmoment21/cs2-sdk/blob/v2/cs2-sdk/sdk/include/interfaces/schemasystem.hpp
    struct SchemaClassInfoData_t
    {
        uint64_t    pad0;         // 0x00
        const char *m_ClassName;  // 0x08
        const char *m_ModuleName; // 0x10

        int32_t m_SizeOf;      // 0x18
        int16_t m_FieldsCount; // 0x1C
        int16_t m_StaticCount; // 0x1E

        int16_t m_MetadataCount;    // 0x20
        int8_t  m_AlignOf;          // 0x22 ???????,????:-1
        int8_t  m_BaseClassesCount; // 0x23 ??????,????:1
        int16_t pad2;               // 0x24
        int16_t pad3;               // 0x26

        SchemaClassFieldData_t    *m_Fields;       // 0x28
        SchemaStaticFieldData_t   *m_StaticFields; // 0x30
        SchemaBaseClassInfoData_t *m_BaseClasses;  // 0x38

        void                   *pad4;         // 0x40
        void                   *m_Metadata;   // 0x48 SchemaMetadataSetData_t
        CSchemaSystemTypeScope *m_TypeScope;  // 0x50
        CSchemaType_XXX        *m_SchemaType; // 0x58 CSchemaType_DeclaredClass
        uint64_t                m_ClassFlags; // 0x60 SchemaClassFlags_t

        // https://github.com/a2x/cs2-dumper
        void Dump()
        {
            if (this == nullptr)
                return;

            printf("// SchemaClassInfoData_t: 0x%p\r\n", this);
            printf("// m_ClassName: %s\r\n", this->m_ClassName);
            printf("// m_ModuleName: %s\r\n", this->m_ModuleName);
            printf("// m_SizeOf: 0x%X\r\n", this->m_SizeOf);
            printf("// m_FieldsCount: %d\r\n", this->m_FieldsCount);
            printf("// m_StaticCount: %d\r\n", this->m_StaticCount);
            printf("// m_MetadataCount: %d\r\n", this->m_MetadataCount);
            printf("// m_AlignOf: %d\r\n", this->m_AlignOf);
            printf("// m_BaseClassesCount: %d\r\n", this->m_BaseClassesCount);
            printf("// pad2: %d\r\n", this->pad2);
            printf("// pad3: %d\r\n", this->pad3);
            if (this->m_BaseClasses != nullptr)
                printf("// BaseClass: %s\r\n", this->m_BaseClasses->m_ClassInfo->m_ClassName);

            printf("namespace %s {\r\n", this->m_ClassName);
            for (size_t i = 0; i < this->m_FieldsCount; i++)
            {
                printf("    constexpr std::ptrdiff_t %s = 0x%X; // %s \r\n",
                       this->m_Fields[i].m_FieldName,
                       this->m_Fields[i].m_Offset,
                       this->m_Fields[i].m_SchemaType->m_TypeName);
            }
            printf("}\r\n\r\n");

            if (this->m_BaseClasses != nullptr)
                this->m_BaseClasses->m_ClassInfo->Dump();
        }
    };
Я не думаю что нужно выстраивать пады для GetSchemaClassInfo вот
C++:
Expand Collapse Copy
SchemaClassInfoData_t* classInfo = SchemaSystem->FindTypeScopeForModule(moduleName)->FindDeclaredClass(className);

полная версия :
C++:
Expand Collapse Copy
CSchemaSystem* SchemaSystem = static_cast<CSchemaSystem*>(interfacemanager.GetInterface("schemasystem.dll", "SchemaSystem_001"));

int32_t SCHEMA::GetSchemaOffset(const char* moduleName, const char* className, const char* fieldName)
{
    SchemaClassInfoData_t* classInfo = SchemaSystem->FindTypeScopeForModule(moduleName)->FindDeclaredClass(className);

    for (int16_t i = 0; i < classInfo->m_FieldsCount; i++)
    {
        if (std::string(fieldName) == classInfo->m_Fields[i].m_FieldName)
        {
            return classInfo->m_Fields[i].m_Offset;
        }
    }

    return 0;
}
 
Последнее редактирование:
Я не думаю что нужно выстраивать пады для GetSchemaClassInfo вот
C++:
Expand Collapse Copy
SchemaClassInfoData_t* classInfo = SchemaSystem->FindTypeScopeForModule(moduleName)->FindDeclaredClass(className);

полная версия :
C++:
Expand Collapse Copy
CSchemaSystem* SchemaSystem = static_cast<CSchemaSystem*>(interfacemanager.GetInterface("schemasystem.dll", "SchemaSystem_001"));

int32_t SCHEMA::GetSchemaOffset(const char* moduleName, const char* className, const char* fieldName)
{
    SchemaClassInfoData_t* classInfo = SchemaSystem->FindTypeScopeForModule(moduleName)->FindDeclaredClass(className);

    for (int16_t i = 0; i < classInfo->m_FieldsCount; i++)
    {
        if (std::string(fieldName) == classInfo->m_Fields[i].m_FieldName)
        {
            return classInfo->m_Fields[i].m_Offset;
        }
    }

    return 0;
}
Не в схеме надо... А CEntityInstance (если у тебя база апфуксии), там и находится GetSchemaClassInfo как раз-таки
 
ты обновил GetSchemaClassInfo? если нет, то просто поменяй с 38 --> 42
нет я не использую асфиксию в виде базы я получаю игроков вот так
C++:
Expand Collapse Copy
 for (int i = 1; i <= engine_interface->GetMaxClients(); ++i) {

        auto controller = reinterpret_cast<C_CSPlayerController*>(gEntitySystem->GetEntity(i));
        if (!controller || !controller->IsPawnAlive())
            continue;

        auto pawn = gEntitySystem->GetEntity<C_CSPlayerPawn>(controller->m_hPawn());
        if (!pawn || pawn == pPlayerPawn || pawn->m_iTeamNum() == pPlayerPawn->m_iTeamNum())
            continue;


C++:
Expand Collapse Copy
inline auto gEntitySystem = *reinterpret_cast<CGameEntitySystem**>(schema.FindPattern("client.dll", "48 8B 0D ? ? ? ? 0F 28 DE 4C 89 6C 24 ? 4C 8B C0 4C 89 6C 24 ? 49 8B D6"));

C++:
Expand Collapse Copy
class CGameEntitySystem {
public:
    template <typename T = C_BaseEntity>
    T* GetEntity(int Index)
    {
        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(Index));
    }

    template <typename T = C_BaseEntity>
    T* GetEntity(CBaseHandle hHandle)
    {
        if (!hHandle.IsValid())
            return nullptr;

        return reinterpret_cast<T*>(this->GetEntityByIndexFunction(hHandle.GetEntryIndex()));
    }
    
    int GetHighestEntityIndex()
    {
        return *reinterpret_cast<int*>(reinterpret_cast<std::uintptr_t>(this) + 0x20F0);
    }

private:
    void* GetEntityByIndexFunction(int Index)
    {
        SCHEMA schema;
        using fnGetBaseEntity = void* (__fastcall*)(void*, int);
        static auto GetBaseEntity = reinterpret_cast<fnGetBaseEntity>(schema.FindPattern("client.dll", "8B D1 48 8B 0D ? ? ? ? E9 ? ? ? ? CC CC 48 8B 89"));
        return GetBaseEntity(this, Index);
    }
};
 
нет я не использую асфиксию в виде базы я получаю игроков вот так
C++:
Expand Collapse Copy
 for (int i = 1; i <= engine_interface->GetMaxClients(); ++i) {

        auto controller = reinterpret_cast<C_CSPlayerController*>(gEntitySystem->GetEntity(i));
        if (!controller || !controller->IsPawnAlive())
            continue;

        auto pawn = gEntitySystem->GetEntity<C_CSPlayerPawn>(controller->m_hPawn());
        if (!pawn || pawn == pPlayerPawn || pawn->m_iTeamNum() == pPlayerPawn->m_iTeamNum())
            continue;
Ну обнови индексы в интерфейсе или перепиши логику
 
Ну обнови индексы в интерфейсе или перепиши логику
C++:
Expand Collapse Copy
    int GetLocalPlayerIndex() {
        SCHEMA schema;
        int nIndex = -1;
        schema.CallVMT<void, 53U>(this, std::ref(nIndex), 0);
        return nIndex + 1;
    }

    int GetMaxClients()
    {
        SCHEMA schema;
        return schema.CallVMT<int, 37U>(this);
    }

    bool IsInGame()
    {
        SCHEMA schema;
        return schema.CallVMT<bool, 38U>(this);
    }

    bool IsConnected()
    {
        SCHEMA schema;
        return schema.CallVMT<bool, 39U>(this);
    }

Они разве старые?

Логику уже пытался через resource service.
struct Game_Resource_Service
{
#define MEM_PAD(SIZE)
MEM_PAD(0x58);
CGameEntitySystem* gEntitySystem_Resource;
};

но ничего не получилось
Ну обнови индексы в интерфейсе или перепиши логику
ты знаешь другие методы как получить entity list??
была затея через
C++:
Expand Collapse Copy
    void* function_CGameEntitySystem(int i) {
        int64_t v2 = reinterpret_cast<int64_t>(this) + 16;

        if ((unsigned int)i <= 0x7FFE) {
            int v3 = i >> 9;
            if ((unsigned int)v3 <= 0x3F) {
                uint64_t v4 = *reinterpret_cast<uint64_t*>(v2 + 8LL * v3);
                if (v4 != 0) {
                    uint64_t v5 = v4 + 120LL * (i & 0x1FF);
                    if (v5 != 0) {
                        uint32_t StoredIndex = *reinterpret_cast<uint32_t*>(v5 + 16) & 0x7FFF;
                        if (StoredIndex == (uint32_t)i) {
                            return *reinterpret_cast<void**>(v4 + 120LL * (i & 0x1FF));
                        }
                    }
                }
            }
        }

        return nullptr;
    }
 
Последнее редактирование:
Кто-то знает в чем проблема почему CBaseEntity = null??
Всю информацию уже говорил в прошлых сообщениях, не знаю как пофиксить.

Does anyone know what the problem is? Why is CBaseEntity = null?
I've already provided all the information in previous messages, but I don't know how to fix it.
 
Кто-то знает в чем проблема почему CBaseEntity = null??
Всю информацию уже говорил в прошлых сообщениях, не знаю как пофиксить.

Does anyone know what the problem is? Why is CBaseEntity = null?
I've already provided all the information in previous messages, but I don't know how to fix it.
Перебирай энтити из CConcreteEntityList или хукни добавление и удаление сущностей и там уже делай массив их

Если не знаешь что за класс такой то реверси игру
 
Перебирай энтити из CConcreteEntityList или хукни добавление и удаление сущностей и там уже делай массив их

Если не знаешь что за класс такой то реверси игру
Ты имеешь виду
Создать массив entity list и по max clients получить всех клиентов перебирая каждого а затем использовать addEntity я как понял получаю так CBaseEntity вопрос как мне теперь сделать в C_CSPlayerController а потом из него через m_hPawn() и получить C_CSPlayerPawn??
 
Перебирай энтити из CConcreteEntityList или хукни добавление и удаление сущностей и там уже делай массив их

Ты имеешь виду
Создать массив entity list и по max clients получить всех клиентов перебирая каждого а затем использовать addEntity я как понял получаю так CBaseEntity вопрос как мне теперь сделать в C_CSPlayerController а потом из него через m_hPawn() и получить C_CSPlayerPawn??
В энтити системе есть массив всех энтити на 0x10 класс у него CConcreteEntityList и там уже сам реверси
 
Назад
Сверху Снизу