Find GiveNamedItem, UTIL_CreateEntityByName and CBaseEntity_DispatchSpawn
Locate GiveNamedItem, UTIL_CreateEntityByName and CBaseEntity_DispatchSpawn in CS2 server.dll or server.so using IDA Pro MCP tools.
Method
Part 1: Find GiveNamedItem
Search for the debug string:
mcp__ida-pro-mcp__find_regex pattern="GiveNamedItem: interpreting"
Get cross-references to the string:
mcp__ida-pro-mcp__xrefs_to addrs="<string_addr>"
Decompile and rename the referencing function:
mcp__ida-pro-mcp__decompile addr="<function_addr>"
- The decompiled function is
GiveNamedItem, and it needs to be renamed.
mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<function_addr>", "name": "GiveNamedItem"}]}
In the decompiled code, look for the entity creation pattern:
EntityByName = UTIL_CreateEntityByName((int)a2, -1);
v29 = (_QWORD *)EntityByName;
if ( EntityByName )
{
CBaseEntity_DispatchSpawn(EntityByName, 0LL);
goto LABEL_47;
}
Or similar pattern where:
UTIL_CreateEntityByName is called with the weapon name and -1
- If successful,
CBaseEntity_DispatchSpawn is called on the created entity
Part 2: Identify UTIL_CreateEntityByName and CBaseEntity_DispatchSpawn
From the GiveNamedItem decompiled code, identify:
UTIL_CreateEntityByName: The function called to create the entity (takes classname and spawn group handle)
CBaseEntity_DispatchSpawn: The function called to spawn/initialize the entity (takes entity pointer and optional parameter)
Rename UTIL_CreateEntityByName:
mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<util_createentitybyname_addr>", "name": "UTIL_CreateEntityByName"}]}
Rename CBaseEntity_DispatchSpawn:
mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<cbaseentity_dispatchspawn_addr>", "name": "CBaseEntity_DispatchSpawn"}]}
Part 3: Generate Signatures and Write YAML
Generate and validate unique signature for GiveNamedItem:
ALWAYS Use SKILL /generate-signature-for-function to generate a robust and unique signature for the function.
Write IDA analysis output for GiveNamedItem as YAML beside the binary:
ALWAYS Use SKILL /write-func-as-yaml to write the analysis results.
Required parameters:
func_name: GiveNamedItem
func_addr: The function address of GiveNamedItem from step 3
func_sig: The validated signature from step 8
Note: This is NOT a virtual function, so no vtable parameters are needed.
Generate and validate unique signature for UTIL_CreateEntityByName:
ALWAYS Use SKILL /generate-signature-for-function to generate a robust and unique signature for the function.
- Write IDA analysis output for
UTIL_CreateEntityByName as YAML beside the binary:
ALWAYS Use SKILL /write-func-as-yaml to write the analysis results.
Required parameters:
func_name: UTIL_CreateEntityByName
func_addr: The function address of UTIL_CreateEntityByName from step 5
func_sig: The validated signature from step 10
Note: This is NOT a virtual function, so no vtable parameters are needed.
- Generate and validate unique signature for
CBaseEntity_DispatchSpawn:
ALWAYS Use SKILL /generate-signature-for-function to generate a robust and unique signature for the function.
- Write IDA analysis output for
CBaseEntity_DispatchSpawn as YAML beside the binary:
ALWAYS Use SKILL /write-func-as-yaml to write the analysis results.
Required parameters:
func_name: CBaseEntity_DispatchSpawn
func_addr: The function address of CBaseEntity_DispatchSpawn from step 5
func_sig: The validated signature from step 12
Note: This is NOT a virtual function, so no vtable parameters are needed.
Function Characteristics
GiveNamedItem
- Prototype:
CBaseEntity* GiveNamedItem(CCSPlayer_ItemServices* pItemServices, const char* pszItem, int iSubType, CEconItemView* pScriptItem, bool bRemoveIfNotCarried, void* pReserved)
- Parameters:
pItemServices: Player's item services component
pszItem: Item/weapon class name string
iSubType: Item subtype
pScriptItem: Economy item view (can be null)
bRemoveIfNotCarried: Whether to remove if player can't carry
pReserved: Reserved parameter
- Return: Pointer to the created entity, or null on failure
- Purpose: Gives a named item (weapon, equipment) to a player entity
- Legacy weapon handling: Translates legacy weapon names (e.g., "weapon_galil", "weapon_mp5navy") to modern equivalents
UTIL_CreateEntityByName
- Prototype:
CBaseEntity* UTIL_CreateEntityByName(const char* classname, int spawnGroupHandle)
- Parameters:
classname: Entity class name string
spawnGroupHandle: Spawn group handle (-1 for default)
- Return: Pointer to the created entity, or null on failure
- Purpose: Creates an entity by its class name string
- Note: This is a simple wrapper that calls the internal implementation with default parameters
CBaseEntity_DispatchSpawn
- Prototype:
void CBaseEntity_DispatchSpawn(CBaseEntity* pEntity, CEntityKeyValues* pKeyValues)
- Parameters:
pEntity: The entity to spawn/initialize
pKeyValues: Entity key values (can be null)
- Purpose: Dispatches the spawn event to initialize a newly created entity
- Note: Must be called after
UTIL_CreateEntityByName to complete entity creation
Relationship Between Functions
GiveNamedItem
│
├── Translates weapon name if legacy
│
├── UTIL_CreateEntityByName(weaponName, -1)
│ │
│ └── Creates entity instance
│
└── CBaseEntity_DispatchSpawn(entity, null)
│
└── Initializes/spawns the entity
DLL Information
- DLL:
server.dll (Windows) / server.so (Linux)
Notes
- All three are regular functions, NOT virtual functions
GiveNamedItem is the entry point that orchestrates entity creation
UTIL_CreateEntityByName creates the raw entity instance
CBaseEntity_DispatchSpawn completes initialization by calling spawn handlers
- The error string
"nullptr Ent in GiveNamedItem: %s!\n" is logged when entity creation fails
Output YAML Format
The output YAML filenames depend on the platform:
server.dll → GiveNamedItem.windows.yaml, UTIL_CreateEntityByName.windows.yaml, CBaseEntity_DispatchSpawn.windows.yaml
server.so → GiveNamedItem.linux.yaml, UTIL_CreateEntityByName.linux.yaml, CBaseEntity_DispatchSpawn.linux.yaml
func_va: 0x180XXXXXX # Virtual address of the function - This can change when game updates.
func_rva: 0xXXXXXX # Relative virtual address (VA - image base) - This can change when game updates.
func_size: 0xXXX # Function size in bytes - This can change when game updates.
func_sig: XX XX XX XX XX # Unique byte signature for pattern scanning - This can change when game updates.
1---2name: find-givenameditem-utilcreateentitybyname-and3description: Locate GiveNamedItem, UTILCreateEntityByName and CBaseEntityDispatchSpawn in CS2 server.dll or server.so using IDA Pro MCP tools.4---56# Find GiveNamedItem, UTIL_CreateEntityByName and CBaseEntity_DispatchSpawn78Locate `GiveNamedItem`, `UTIL_CreateEntityByName` and `CBaseEntity_DispatchSpawn` in CS2 `server.dll` or `server.so` using IDA Pro MCP tools.910## Method1112### Part 1: Find GiveNamedItem13141. Search for the debug string:15 ```16 mcp__ida-pro-mcp__find_regex pattern="GiveNamedItem: interpreting"17 ```18192. Get cross-references to the string:20 ```21 mcp__ida-pro-mcp__xrefs_to addrs="<string_addr>"22 ```23243. Decompile and rename the referencing function:25 ```26 mcp__ida-pro-mcp__decompile addr="<function_addr>"27 ```2829 * The decompiled function is `GiveNamedItem`, and it needs to be renamed.3031 ```32 mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<function_addr>", "name": "GiveNamedItem"}]}33 ```3435 - Key Behaviors of GiveNamedItem:3637 1. Translates legacy weapon names to modern equivalents38 2. Handles special C4 weapon logic (triggers "player_given_c4" event)39 3. Calls `UTIL_CreateEntityByName` to create the entity40 4. Calls `CBaseEntity_DispatchSpawn` to initialize the created entity41 5. Returns the created entity pointer42434. In the decompiled code, look for the entity creation pattern:44 ```c45 EntityByName = UTIL_CreateEntityByName((int)a2, -1);46 v29 = (_QWORD *)EntityByName;47 if ( EntityByName )48 {49 CBaseEntity_DispatchSpawn(EntityByName, 0LL);50 goto LABEL_47;51 }52 ```5354 Or similar pattern where:55 - `UTIL_CreateEntityByName` is called with the weapon name and -156 - If successful, `CBaseEntity_DispatchSpawn` is called on the created entity5758### Part 2: Identify UTIL_CreateEntityByName and CBaseEntity_DispatchSpawn59605. From the GiveNamedItem decompiled code, identify:61 - `UTIL_CreateEntityByName`: The function called to create the entity (takes classname and spawn group handle)62 - `CBaseEntity_DispatchSpawn`: The function called to spawn/initialize the entity (takes entity pointer and optional parameter)63646. Rename `UTIL_CreateEntityByName`:65 ```66 mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<util_createentitybyname_addr>", "name": "UTIL_CreateEntityByName"}]}67 ```68697. Rename `CBaseEntity_DispatchSpawn`:70 ```71 mcp__ida-pro-mcp__rename batch={"func": [{"addr": "<cbaseentity_dispatchspawn_addr>", "name": "CBaseEntity_DispatchSpawn"}]}72 ```7374### Part 3: Generate Signatures and Write YAML75768. Generate and validate unique signature for `GiveNamedItem`:7778 **ALWAYS** Use SKILL `/generate-signature-for-function` to generate a robust and unique signature for the function.79809. Write IDA analysis output for `GiveNamedItem` as YAML beside the binary:8182 **ALWAYS** Use SKILL `/write-func-as-yaml` to write the analysis results.8384 Required parameters:85 - `func_name`: `GiveNamedItem`86 - `func_addr`: The function address of `GiveNamedItem` from step 387 - `func_sig`: The validated signature from step 88889 Note: This is NOT a virtual function, so no vtable parameters are needed.909110. Generate and validate unique signature for `UTIL_CreateEntityByName`:9293 **ALWAYS** Use SKILL `/generate-signature-for-function` to generate a robust and unique signature for the function.949511. Write IDA analysis output for `UTIL_CreateEntityByName` as YAML beside the binary:9697 **ALWAYS** Use SKILL `/write-func-as-yaml` to write the analysis results.9899 Required parameters:100 - `func_name`: `UTIL_CreateEntityByName`101 - `func_addr`: The function address of `UTIL_CreateEntityByName` from step 5102 - `func_sig`: The validated signature from step 10103104 Note: This is NOT a virtual function, so no vtable parameters are needed.10510612. Generate and validate unique signature for `CBaseEntity_DispatchSpawn`:107108 **ALWAYS** Use SKILL `/generate-signature-for-function` to generate a robust and unique signature for the function.10911013. Write IDA analysis output for `CBaseEntity_DispatchSpawn` as YAML beside the binary:111112 **ALWAYS** Use SKILL `/write-func-as-yaml` to write the analysis results.113114 Required parameters:115 - `func_name`: `CBaseEntity_DispatchSpawn`116 - `func_addr`: The function address of `CBaseEntity_DispatchSpawn` from step 5117 - `func_sig`: The validated signature from step 12118119 Note: This is NOT a virtual function, so no vtable parameters are needed.120121## Function Characteristics122123### GiveNamedItem124125- **Prototype**: `CBaseEntity* GiveNamedItem(CCSPlayer_ItemServices* pItemServices, const char* pszItem, int iSubType, CEconItemView* pScriptItem, bool bRemoveIfNotCarried, void* pReserved)`126- **Parameters**:127 - `pItemServices`: Player's item services component128 - `pszItem`: Item/weapon class name string129 - `iSubType`: Item subtype130 - `pScriptItem`: Economy item view (can be null)131 - `bRemoveIfNotCarried`: Whether to remove if player can't carry132 - `pReserved`: Reserved parameter133- **Return**: Pointer to the created entity, or null on failure134- **Purpose**: Gives a named item (weapon, equipment) to a player entity135- **Legacy weapon handling**: Translates legacy weapon names (e.g., "weapon_galil", "weapon_mp5navy") to modern equivalents136137### UTIL_CreateEntityByName138139- **Prototype**: `CBaseEntity* UTIL_CreateEntityByName(const char* classname, int spawnGroupHandle)`140- **Parameters**:141 - `classname`: Entity class name string142 - `spawnGroupHandle`: Spawn group handle (-1 for default)143- **Return**: Pointer to the created entity, or null on failure144- **Purpose**: Creates an entity by its class name string145- **Note**: This is a simple wrapper that calls the internal implementation with default parameters146147### CBaseEntity_DispatchSpawn148149- **Prototype**: `void CBaseEntity_DispatchSpawn(CBaseEntity* pEntity, CEntityKeyValues* pKeyValues)`150- **Parameters**:151 - `pEntity`: The entity to spawn/initialize152 - `pKeyValues`: Entity key values (can be null)153- **Purpose**: Dispatches the spawn event to initialize a newly created entity154- **Note**: Must be called after `UTIL_CreateEntityByName` to complete entity creation155156## Relationship Between Functions157158```159GiveNamedItem160 │161 ├── Translates weapon name if legacy162 │163 ├── UTIL_CreateEntityByName(weaponName, -1)164 │ │165 │ └── Creates entity instance166 │167 └── CBaseEntity_DispatchSpawn(entity, null)168 │169 └── Initializes/spawns the entity170```171172## DLL Information173174- **DLL**: `server.dll` (Windows) / `server.so` (Linux)175176## Notes177178- All three are regular functions, NOT virtual functions179- `GiveNamedItem` is the entry point that orchestrates entity creation180- `UTIL_CreateEntityByName` creates the raw entity instance181- `CBaseEntity_DispatchSpawn` completes initialization by calling spawn handlers182- The error string `"nullptr Ent in GiveNamedItem: %s!\n"` is logged when entity creation fails183184## Output YAML Format185186The output YAML filenames depend on the platform:187- `server.dll` → `GiveNamedItem.windows.yaml`, `UTIL_CreateEntityByName.windows.yaml`, `CBaseEntity_DispatchSpawn.windows.yaml`188- `server.so` → `GiveNamedItem.linux.yaml`, `UTIL_CreateEntityByName.linux.yaml`, `CBaseEntity_DispatchSpawn.linux.yaml`189190```yaml191func_va: 0x180XXXXXX # Virtual address of the function - This can change when game updates.192func_rva: 0xXXXXXX # Relative virtual address (VA - image base) - This can change when game updates.193func_size: 0xXXX # Function size in bytes - This can change when game updates.194func_sig: XX XX XX XX XX # Unique byte signature for pattern scanning - This can change when game updates.195```