查找CBaseEntitySetOwner

tools-only2026-10-27查看 1512复制 900

| 使用 IDA Pro MCP 在 CS2 二进制文件中查找并识别 CBaseEntity_SetOwner 虚函数。 在逆向工程 CS2 server.dll 或 server.so 时定位 SetOwner 函数时使用此技能。 CBaseEntity_SetOwner 是 CBaseEntity 上的虚函数,通过 CCSPlayer_WeaponServices_EquipWeapon 中的 vtable 偏移解析。 触发词:CBaseEntity_SetOwner、SetOwner

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md5366 chars
---
name: find-CBaseEntity_SetOwner
description: |
  Find and identify the CBaseEntity_SetOwner virtual function in CS2 binary using IDA Pro MCP.
  Use this skill when reverse engineering CS2 server.dll or server.so to locate the SetOwner function.
  CBaseEntity_SetOwner is a virtual function on CBaseEntity, resolved via vtable offset in CCSPlayer_WeaponServices_EquipWeapon.
  Trigger: CBaseEntity_SetOwner, SetOwner
disable-model-invocation: true
---

# Find CBaseEntity_SetOwner

Locate the `CBaseEntity_SetOwner` virtual function in CS2 server binary using IDA Pro MCP tools.

## Overview

`CBaseEntity_SetOwner` is a virtual function on `CBaseEntity`. It is identified by decompiling `CCSPlayer_WeaponServices_EquipWeapon` and resolving the vtable call at offset `416` (Windows) / `408` (Linux) from the weapon entity's vtable pointer.

## Prerequisites

- `CCSPlayer_WeaponServices_EquipWeapon` must already be identified (YAML must exist)
- `CBaseEntity` vtable must already be identified (vtable YAML must exist)

If either is missing, run the corresponding skill first:
- `/find-CCSPlayer_WeaponServices_PickupItem-AND-CCSPlayer_WeaponServices_EquipWeapon`
- `/write-vtable-as-yaml` with `class_name=CBaseEntity`

## Method

### 1. Get CCSPlayer_WeaponServices_EquipWeapon Function Info

**ALWAYS** Use SKILL `/get-func-from-yaml` with `func_name=CCSPlayer_WeaponServices_EquipWeapon`.

If the skill returns an error, stop and report to user.
Otherwise, extract `func_va` for subsequent steps.

### 2. Get CBaseEntity VTable Info

**ALWAYS** Use SKILL `/get-vtable-from-yaml` with `class_name=CBaseEntity`.

If the skill returns an error, stop and report to user.
Otherwise, extract `vtable_va`, `vtable_numvfunc` and `vtable_entries` for subsequent steps.

### 3. Decompile CCSPlayer_WeaponServices_EquipWeapon and Locate SetOwner Call

Decompile the function at `func_va` from step 1 and look for the following code pattern:

Windows binary:
```c
  sub_XXXXXXXX((__int64)(a2 + 182));
  v7 = *(void (__fastcall **)(_QWORD *, _QWORD))(*a2 + 416LL); // <-- CBaseEntity_SetOwner
  if ( !*(_QWORD *)(a1 + 56) )
    nullsub_XXX(a1);
  v7(a2, *(_QWORD *)(a1 + 56));
  sub_YYYYYYYY(a1, a2);
  v8 = *(void (__fastcall **)(_QWORD *, _QWORD))(*a2 + 816LL);
```

Linux binary:
```c
  sub_XXXXXXXX(a2 + 274);
  v9 = *(void (__fastcall **)(_QWORD *, double, double, double))(*a2 + 408LL); // <-- CBaseEntity_SetOwner
  if ( !*(_QWORD *)(a1 + 56) )
    nullsub_XXXX();
  v9(a2, ...);
  sub_YYYYYYYY(a1, a2);
  v10 = *(void (__fastcall **)(_QWORD *, _QWORD))(*a2 + 808LL);
```

Key identification:
- Windows: vtable offset `416` (`0x1A0`), vtable index = 416 / 8 = **52**
- Linux: vtable offset `408` (`0x198`), vtable index = 408 / 8 = **51**

### 4. Resolve VTable Entry

Using the vtable entries from step 2, look up the entry at the platform-specific index:
- Windows: `vtable_entries[52]`
- Linux: `vtable_entries[51]`

The address at that index is `CBaseEntity_SetOwner`.

### 5. Rename CBaseEntity_SetOwner

Verify the function name at the resolved address. If not already renamed:

```
mcp__ida-pro-mcp__rename(batch={"func": {"addr": "<resolved_addr>", "name": "CBaseEntity_SetOwner"}})
```

### 6. Generate and Validate Unique Signature

**ALWAYS** Use SKILL `/generate-signature-for-function` to generate a robust and unique signature for `CBaseEntity_SetOwner`.

### 7. Write IDA Analysis Output as YAML

**ALWAYS** Use SKILL `/write-vfunc-as-yaml` to write the analysis results.

Required parameters:
- `func_name`: `CBaseEntity_SetOwner`
- `func_addr`: The resolved function address from step 4
- `func_sig`: The validated signature from step 6

VTable parameters:
- `vtable_name`: `CBaseEntity`
- `vfunc_offset`: `0x1A0` (Windows) / `0x198` (Linux) — may change with game updates
- `vfunc_index`: `52` (Windows) / `51` (Linux) — may change with game updates

## Function Characteristics

- **VTable Class**: `CBaseEntity`
- **Parameters**: `(CBaseEntity* this, CBaseEntity* owner)`
- **Purpose**: Sets the owner entity for a given entity (e.g., assigning weapon ownership to a player pawn during equip)
- **Called from**: `CCSPlayer_WeaponServices_EquipWeapon` — called with the player's pawn as the owner argument

## VTable Information

- **VTable Name**: `CBaseEntity`
- **VTable Mangled Name**:
  - Windows: `??_7CBaseEntity@@6B@`
  - Linux: `_ZTV11CBaseEntity`
- **VTable Offset**: `0x1A0` (Windows) / `0x198` (Linux) — may change with game updates
- **VTable Index**: `52` (Windows) / `51` (Linux) — may change with game updates

## Output YAML Format

The output YAML filename depends on the platform:
- `server.dll` → `CBaseEntity_SetOwner.windows.yaml`
- `server.so` / `libserver.so` → `CBaseEntity_SetOwner.linux.yaml`

## Troubleshooting

**If CCSPlayer_WeaponServices_EquipWeapon YAML not found:**
- Run `/find-CCSPlayer_WeaponServices_PickupItem-AND-CCSPlayer_WeaponServices_EquipWeapon` first

**If CBaseEntity vtable YAML not found:**
- Run `/write-vtable-as-yaml` with `class_name=CBaseEntity` first

**If the vtable offset differs from expected:**
- The vtable layout may have changed in a game update
- Look for the first vtable call after `sub_XXXXXXXX(a2 + 182)` / `sub_XXXXXXXX(a2 + 274)` in the decompiled output
- The call passes `*(_QWORD *)(a1 + 56)` (the player pawn) as the second argument — this is the distinguishing pattern
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧