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!