Developer knowledge network ยท moderated exchange

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Knowledge indexLive
4Categories
919Threads
2.8KPosts
Release

CS2 Entity iteration via dwGameEntitySystem pointer

csgo_offset_hound
Offset Master
MEMBER
Rep: 114
Join Date: Apr 2019
Posts: 16
Thanks: 16
1 months ago ยท 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
Rep: 215
Join Date: Mar 2018
Posts: 86
Thanks: 61
1 months ago ยท 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
Rep: 210
Join Date: Dec 2019
Posts: 11
Thanks: 51
1 months ago ยท Jul 6, 2026 3:52 PM
#3

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