Developer knowledge network · moderated exchange

UnreliableCode қауымдастығы

Әзірлеушілерді зерттеу, кері инженерия және кодтау қауымдастығы

Knowledge indexТірі
4Categories
919Threads
2.8KЖазбалар
Release

CS2 Entity iteration via dwGameEntitySystem pointer

csgo_offset_hound
Offset Master
MEMBER
Өкіл: 114
Қосылу күні: Apr 2019
Хабарламалар: 16
Рахмет: 16
1 ай бұрын · Jul 5, 2026 8:25 PM
#1

Source 2 manages entities in indexed chunks inside CGameEntitySystem (client.dll + dwGameEntitySystem):

CPP
uintptr_t GetEntityByIndex(int index) {
    uintptr_t entityList = Read<uintptr_t>(clientBase + dwGameEntitySystem);
    if (!entityList) return 0;
    
    // Source 2 chunk indexing (512 entities per chunk)
    uintptr_t listChunk = Read<uintptr_t>(entityList + 0x10 + (8 * ((index & 0x7FFF) >> 9)));
    if (!listChunk) return 0;
    
    return Read<uintptr_t>(listChunk + 120 * (index & 0x1FF));
}

Iterate from 1 to 64 to retrieve all player controllers (CCSPlayerController).

vtable_slayer
Senior Reverser
MEMBER
Өкіл: 215
Қосылу күні: Mar 2018
Хабарламалар: 86
Рахмет: 61
1 ай бұрын · Jul 6, 2026 2:07 AM
#2

From the controller, read m_hPlayerPawn and pass the handle into GetEntityByIndex to obtain the actual C_CSPlayerPawn pointer. Works perfectly.

sig_scanner_sam
Pattern Master
MEMBER
Өкіл: 210
Қосылу күні: Dec 2019
Хабарламалар: 11
Рахмет: 51
1 ай бұрын · Jul 6, 2026 3:52 PM
#3

The bitwise arithmetic ((index & 0x7FFF) >> 9) was the missing piece for my entity loop. Thanks!