File Naming Convention
API definition files follow a strict naming pattern:- Format:
<module_name>.api - Location:
apis_def/directory - Examples:
user32.api,kernel32.api,ntdll.api
.dll extension) that contains the API functions.
INI-Based Structure
API definition files use the INI file format with sections for each function:Basic Function Definition
Here’s a simple example fromuser32.api:
Field Breakdown
The section name must exactly match the exported function name from the DLL.
Numbered lines define each parameter in order:
- Number corresponds to the parameter position (1-based)
- Format:
TYPE parameterName - Types can be base types (DWORD, LPSTR) or custom types in [brackets]
Total number of parameters the function accepts. Use
0 for functions with no parameters.Semicolon-separated list of header files containing type definitions referenced by this function.
The canonical function name. Usually matches the section name but can differ for aliases.
Functions With No Parameters
Functions that take no parameters still need a definition:Custom Type References
Parameters with custom types (enums or flags) use bracket notation:[WinMsg] notation indicates:
Msgis the parameter nameWinMsgis a custom type defined inwindows.h.api- xAnalyzer will resolve values to symbolic constants (e.g.,
WM_CLOSE,WM_PAINT)
Complex Example: MessageBox
Here’s the complete definition forMessageBox from user32.api:
- Parameter 1:
hWndis a window handle - Parameter 2:
lpTextis a string pointer (message text) - Parameter 3:
lpCaptionis a string pointer (title bar text) - Parameter 4:
uTypeuses theMessageBoxTypeenum fromshell.h.api - Referenced types are in
shell.h.apiandwindows.h.api
Multiple Headers
Functions can reference multiple header files:WindowExStyle and WindowStyle.
Advanced: Debugging Functions
Fromkernel32.api, here’s a debugging-related function:
Best Practices
Use Exact Names
Use Exact Names
Function and parameter names should exactly match Microsoft documentation for consistency.
Include All Parameters
Include All Parameters
Define every parameter, even simple ones like
DWORD or LPVOID. Complete definitions provide better analysis.Reference Headers
Reference Headers
Always include the
Header field when using custom types to ensure xAnalyzer can resolve them.Maintain Consistency
Maintain Consistency
Use consistent type names across definitions. If one function uses
[ProcessHandle], others should too.Common Patterns
Handle Types
String Parameters
Flag and Enum Parameters
Validation Checklist
Before adding a new definition, verify:- Section name matches the exported function name
- Parameters are numbered sequentially starting from 1
-
ParamCountmatches the actual number of parameters - Custom types are enclosed in brackets
- All referenced types have entries in the specified header files
- Header field ends with a semicolon
-
@field is present and correct
Next Steps
Creating Definitions
Step-by-step guide to writing custom definitions
Header Files
Learn about enum and flag definitions
