struct-offset-analyzer

Statically analyze C struct member offsets through code reading to calculate memory layouts

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "struct-offset-analyzer" with this command: npx skills add littleenough/struct-offset-analyzer/littleenough-struct-offset-analyzer-struct-offset-analyzer

struct-offset-analyzer

Statically analyze the memory offsets of C language struct members without needing to run code.

Use Cases

  • Locating struct members during reverse engineering
  • Confirming memory layouts during debugging
  • Analyzing data structures in security research
  • Understanding struct field positions in binary analysis

Workflow

1. Locate Struct Definition

# Search for struct definition
grep -n "struct xxx_st {" **/*.h
grep -n "typedef struct" **/*.h

2. Collect Type Information

Find definitions for all member types:

  • Nested structs
  • Enum types
  • typedef aliases
  • Constant definitions (e.g., #define EVP_MAX_MD_SIZE 64)

3. Calculate Alignment Rules

TypeSize (64-bit)Alignment Requirement
char/unsigned char11
short22
int/uint32_t44
long/size_t/pointer88
unsigned char[N]N1 (no padding needed)
enumusually 44
structdepends on membersaligned to largest member

Key Rules:

  • Member offset must be a multiple of its size
  • unsigned char arrays are 1-byte aligned, no padding required
  • Overall struct size is aligned to the size of its largest member
  • Padding bytes count toward offsets

4. Output Offset Table

Use hexadecimal representation for offsets, format:

| Offset(0x) | Member | Type | Size |
|------------|--------|------|------|
| 0x00 | field1 | int | 4 |
| 0x04 | *(padding)* | - | 4 |
| 0x08 | field2 | void * | 8 |

Common Search Patterns

# Find struct member definition
grep -n "struct xxx_st" **/*.h

# Find type definition
grep -n "typedef.*XXX" **/*.h

# Find constant definition
grep -n "#define.*SIZE" **/*.h

# Find enum definition
grep -n "typedef enum" **/*.h

Example: OpenSSL ssl_st Analysis

Analyzing client_app_traffic_secret member offset:

  1. Locate struct: ssl/ssl_local.h:1068
  2. Find constant: EVP_MAX_MD_SIZE = 64 (include/openssl/evp.h:19)
  3. Calculate layout, note that unsigned char arrays need no padding
  4. Result: offset 0x33c (828 bytes)

Notes

  • Confirm target platform (32-bit vs 64-bit)
  • Note that conditional compilation (#ifdef) may affect struct layout
  • Check for #pragma pack directives that may change alignment
  • Union members share the same offset

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

openclaw-version-monitor

监控 OpenClaw GitHub 版本更新,获取最新版本发布说明,翻译成中文, 并推送到 Telegram 和 Feishu。用于:(1) 定时检查版本更新 (2) 推送版本更新通知 (3) 生成中文版发布说明

Archived SourceRecently Updated
Coding

ask-claude

Delegate a task to Claude Code CLI and immediately report the result back in chat. Supports persistent sessions with full context memory. Safe execution: no data exfiltration, no external calls, file operations confined to workspace. Use when the user asks to run Claude, delegate a coding task, continue a previous Claude session, or any task benefiting from Claude Code's tools (file editing, code analysis, bash, etc.).

Archived SourceRecently Updated
Coding

ai-dating

This skill enables dating and matchmaking workflows. Use it when a user asks to make friends, find a partner, run matchmaking, or provide dating preferences/profile updates. The skill should execute `dating-cli` commands to complete profile setup, task creation/update, match checking, contact reveal, and review.

Archived SourceRecently Updated
Coding

clawhub-rate-limited-publisher

Queue and publish local skills to ClawHub with a strict 5-per-hour cap using the local clawhub CLI and host scheduler.

Archived SourceRecently Updated