What Are Header Files?
Header files (.h.api files) contain type definitions for enums, flags, and constants used by API functions. These files allow xAnalyzer to:
- Resolve numeric values to symbolic constant names
- Display flag combinations as human-readable OR’d values
- Identify enum members instead of showing raw integers
apis_def/headers/ directory and referenced by module .api files.
File Naming Convention
- Format:
<module_name>.h.api - Location:
apis_def/headers/directory - Examples:
windows.h.api,shell.h.api,kernel32.h.api
Structure Overview
Header files use the INI format with sections for each type definition:Field Reference
The name of the custom type. This is what you reference in brackets in
.api files (e.g., [TypeName]).The data type to display in comments. Common values:
DWORD, UINT, int, LONG.The underlying base data type. Can be a primitive (DWORD, UINT) or another custom type in brackets.
Specifies how values are interpreted:
Flag- Values are bitwise flags that can be OR’d togetherEnum- Values are mutually exclusive enumeration members
Names of the constants. Must be numbered sequentially starting from 1.
Numeric values for each constant. Can be decimal or hexadecimal (prefix with
0x).Type: Flag
Flags are bitwise values that can be combined using the OR operator (|).
Example: MessageBox Flags
Fromshell.h.api:
Usage in Analysis
When xAnalyzer encounters:Flag Pattern Example
Fromuser32.h.api:
Type: Enum
Enums are mutually exclusive values where only one can be active at a time.Example: Special Folder IDs
Fromshell.h.api:
Note: In the source, this uses
Type=Flag but should logically be Type=Enum since CSIDL values are mutually exclusive.Proper Enum Example
Fromshell.h.api:
Usage in Analysis
When xAnalyzer sees:Nested Types
TheBase field can reference another custom type:
ExtendedAccessRights inherits from AccessRights.
Real-World Examples
Window Messages
Fromwindows.h.api:
Process Access Rights
Fromwindows.h.api:
Creating Your Own Header Files
Step 1: Identify the Data Type
Determine if your constants are:- Flags (can be OR’d together) → Use
Type=Flag - Enums (mutually exclusive) → Use
Type=Enum
Step 2: Research the Values
Find constant definitions from:- MSDN documentation
- Windows SDK header files (e.g.,
windows.h,winuser.h) - Reverse engineering and analysis
Step 3: Create the Definition
Example for custom application flags:Step 4: Reference in Function Definition
In your.api file:
Best Practices
Use Descriptive Names
Use Descriptive Names
Type names should clearly indicate what they represent (e.g.,
MessageBoxType, WindowStyle).Follow Microsoft Conventions
Follow Microsoft Conventions
When defining Windows API types, match the constant names from official headers exactly.
Hexadecimal for Flags
Hexadecimal for Flags
Use hex notation for flag values to make bit positions obvious (e.g.,
0x00000001, 0x00000002).Document Complex Types
Document Complex Types
Add INI comments (
;) to explain non-obvious values or special cases.Group Related Types
Group Related Types
Common Patterns
Bitwise Powers of Two (Flags)
Sequential Values (Enums)
High-Bit Flags
Troubleshooting
Template
Flag Type Template
Enum Type Template
Next Steps
Creating Definitions
Apply header files in complete API definitions
File Format
Review function definition syntax
Browse Examples
Explore existing header definitions
Configuration
Configure analysis behavior
