Skip to content

mrc4tt/CS2_VibeSignatures / .claude/skills/create-preprocessor-scripts

create-preprocessor-scripts

Verified

Create a new find-XXXX preprocessor Python script from scratch (no existing SKILL.md), add configs/<GAMEVER>.yaml skill and symbol entries. Covers xref-string-based and LLM_DECOMPILE-based discovery patterns. Use when a GitHub issue or user instruction specifies a new function to find.

FileKindSize
SKILL.mdskill md69.0 KB
agents/openai.yamlconfig43 B
references/pattern-A.mdmarkdown3.2 KB
references/pattern-B.mdmarkdown3.5 KB
references/pattern-C.mdmarkdown4.5 KB
references/pattern-D.mdmarkdown2.0 KB
references/pattern-E.mdmarkdown4.1 KB
references/pattern-F.mdmarkdown6.7 KB
references/pattern-G.mdmarkdown3.0 KB
references/pattern-H.mdmarkdown3.7 KB
references/pattern-I.mdmarkdown8.7 KB
references/pattern-J.mdmarkdown5.2 KB
references/pattern-L.mdmarkdown8.4 KB
references/pattern-M.mdmarkdown11.9 KB

references/pattern-E.md

View on GitHub
# Pattern E -- Struct member offset via LLM_DECOMPILE

**Use when:** target is a **struct member offset** (not a function), discovered by decompiling a known predecessor function.

## Decide Whether to Emit `size`

Use the instruction selected for `offset_sig` to decide whether `size` belongs in
`GENERATE_YAML_DESIRED_FIELDS`:

- For a member read/write with a natural operand width (such as `mov`, `movss`, or `cmp`), include `size`.
- For `lea reg, [base+offset]`, omit `size`. It identifies the offset of an embedded member by computing its
  address; it does not read or write the member and cannot establish its extent.

## Template

```python
#!/usr/bin/env python3
"""Preprocess script for find-{SKILL_NAME} skill."""

from ida_analyze_util import preprocess_common_skill

TARGET_STRUCT_MEMBER_NAMES = [
    "{STRUCT_MEMBER_NAME}",  # e.g. "CCheckTransmitInfo_m_nPlayerSlot"
]

LLM_DECOMPILE = [
    # (symbol_name, path_to_prompt, path_to_reference)
    (
        "{STRUCT_MEMBER_NAME}",
        "prompt/call_llm_decompile.md",
        "references/{MODULE}/{PREDECESSOR_FUNC}.{platform}.yaml",
    ),
]

GENERATE_YAML_DESIRED_FIELDS = [
    # (symbol_name, generate_yaml_fields)
    (
        "{STRUCT_MEMBER_NAME}",
        [
            "struct_name",
            "member_name",
            "offset",
            # This template assumes a `lea` locator. Add "size" for a real memory access.
            "offset_sig",
            "offset_sig_disp",
        ],
    ),
]

async def preprocess_skill(
    session, skill_name, expected_outputs, old_yaml_map,
    new_binary_dir, platform, image_base, llm_config=None, debug=False,
):
    """Reuse previous gamever offset_sig to locate target struct offset and write YAML."""
    return await preprocess_common_skill(
        session=session,
        expected_outputs=expected_outputs,
        old_yaml_map=old_yaml_map,
        new_binary_dir=new_binary_dir,
        platform=platform,
        image_base=image_base,
        struct_member_names=TARGET_STRUCT_MEMBER_NAMES,
        llm_decompile_specs=LLM_DECOMPILE,
        llm_config=llm_config,
        generate_yaml_desired_fields=GENERATE_YAML_DESIRED_FIELDS,
        debug=debug,
    )
```

## Reference YAML Annotation

In the predecessor YAML, annotate every struct field access that corresponds to a target member. Use the `(structmember, struct=X, member=Y)` tag on **all** access sites for that field in both `disasm_code` and `procedure`.

`disasm_code` (IDA hex with `h` suffix, `;` comment):

```asm
  .text:0000000180C99633                 mov     ecx, [rdi+240h]  ; 240h = CCheckTransmitInfo::m_nPlayerSlot (structmember, struct=CCheckTransmitInfo, member=m_nPlayerSlot)
```

`procedure` (C `//` comment, decimal then hex):

```c
*(unsigned int *)(*v6 + 576);  // 576 = 0x240 = CCheckTransmitInfo::m_nPlayerSlot (structmember, struct=CCheckTransmitInfo, member=m_nPlayerSlot)
```

Multiple access sites for the same field all need the same annotation — the LLM uses them together to confirm the offset.

## Key differences from Pattern D

- Uses `TARGET_STRUCT_MEMBER_NAMES` instead of `TARGET_FUNCTION_NAMES`
- Passes `struct_member_names=` instead of `func_names=` to `preprocess_common_skill`
- YAML fields are struct-specific: `struct_name, member_name, offset, offset_sig, offset_sig_disp`; add `size`
  only when the locating instruction is a non-`lea` memory access
- No `FUNC_VTABLE_RELATIONS`
- configs/<GAMEVER>.yaml symbol category is `structmember` (not `func` or `vfunc`)

## Checklist

- [ ] `TARGET_STRUCT_MEMBER_NAMES` lists all struct member targets
- [ ] `LLM_DECOMPILE` reference path points to the correct predecessor function YAML
- [ ] `preprocess_skill` signature includes `llm_config=None`
- [ ] `preprocess_common_skill` call passes `struct_member_names=`, `llm_decompile_specs=`, and `llm_config=`
- [ ] A `lea` locator omits `size`; a member read/write locator includes it
- [ ] No `FUNC_VTABLE_RELATIONS` (struct member, not virtual function)
- [ ] configs/<GAMEVER>.yaml symbol category is `structmember`
- [ ] configs/<GAMEVER>.yaml `expected_input` includes the predecessor YAML
- [ ] Reference YAMLs exist or generated for both platforms
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 466kUpdated Claude CodeCodexVerifiedInstall
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 466kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 319kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 319kUpdated Claude CodeCodexVerifiedInstall