benilla-re systems structs docs

__initptd

function · crt · orchestration

Address
0x40aca8 · 19 bytes, up to 0x40acba
Signature
void __cdecl (void *ptd)
Meaning
Sets a new thread's rand seed at +0x14 to 1 and its exception action table at +0x50 to 0x82f2a0
Confidence
verified, proof one
Name from
the community database (idb)
Finding
random#other-threads-rand

Finding: Other threads' rand in random

A thread's rand state starts at 1: __initptd (0x40aca8) stores 1 at +0x14 of the thread data, and only the main thread's is seeded, so another thread draws the default sequence. MakeSocketPipe (0x5bcf90) calls rand at 0x5bcfc5 and picks the port 40000 + rand() % 10000. It binds a listening socket to 127.0.0.1 at that port (WSOCK32 ordinals 2 bind at 0x5bd010 and 13 listen at 0x5bd01e). When bind fails, or listen fails and the socket is closed and reopened, it takes the next port (0x5bd043), up to 64999. Only after listen succeeds does it create a second socket and connect it to that port (0x5bd077 to 0x5bd0da).

The derivation is in the doc.

Callers 2

Callees 0

None by a direct call or jump.

Calls and jumps by a bare address, from tables/calls.tsv.