When to Create Definitions
You should create custom API definitions when:- Analyzing applications that use undocumented Windows APIs
- Reverse engineering custom DLLs or internal libraries
- Working with third-party libraries not in the default definitions
- Adding missing functions from Windows APIs
- Defining internal functions within the target application
Prerequisites
Before creating definitions, ensure you have:- x64dbg with xAnalyzer installed - The plugin must be functional
- Access to the APIs definition folder - Located at
<x64dbg>/apis_def/ - Function documentation - MSDN docs, header files, or reverse engineering notes
- Text editor - Any editor that can save plain text files
Step-by-Step: Creating a Definition File
Step 1: Identify the Target Module
Determine which DLL or module contains the functions you want to define. Example: You’re analyzing a custom DLL calledCustomLib.dll
Step 2: Create the .api File
In theapis_def directory, create a new file:
Step 3: Define Your First Function
Let’s sayCustomLib.dll has a function InitializeLibrary with this prototype:
CustomLib.api:
Step 4: Add More Functions
Continue adding functions to the same file:Step 5: Test Your Definitions
- Restart x64dbg - Or reload the plugin to refresh definitions
- Load your target - Open the executable that uses your custom DLL
- Run analysis - Use xAnalyzer’s “Analyze Module” or “Analyze Function”
- Verify results - Check that function calls are now annotated correctly
Adding Custom Types
For parameters with specific flag or enum values, create a header file.Step 1: Create a Header File
Inapis_def/headers/, create:
Step 2: Define Flags
Let’s define theflags parameter from our example:
Step 3: Reference the Type
Update the function definition inCustomLib.api:
0x00000003 to INIT_FLAG_VERBOSE | INIT_FLAG_DEBUG.
Real-World Example: Adding Missing Windows API
SupposeNtQueryInformationProcess is missing from ntdll.api:
Research the Function
From documentation:Add to ntdll.api
Define the Enum in ntdll.h.api
Tips for Success
Use Standard Types When Possible
Use Standard Types When Possible
Prefer
DWORD, LPVOID, HANDLE over custom types unless the parameter has special meaning.Document Your Work
Document Your Work
Add comments in your definitions (as INI comments with
;) to note sources or special cases.Share Definitions
Share Definitions
Test Thoroughly
Test Thoroughly
Verify your definitions work on multiple call sites to ensure correctness.
Common Pitfalls
Template for New Definitions
Basic Function
Function with Custom Types
Function with No Parameters
Workflow Summary
Contributing Definitions
If you create useful definitions, consider contributing them:- Fork the repository - xAnalyzer is on GitHub
- Add your files - Place
.apiand.h.apifiles in appropriate directories - Test thoroughly - Ensure definitions work on various binaries
- Submit a pull request - Include notes about what you added
- Follow conventions - Match the existing style and naming patterns
Next Steps
Header Files
Deep dive into enum and flag definitions
File Format Reference
Complete syntax reference for .api files
GitHub Repository
Browse existing definitions and contribute
Configuration
Configure how xAnalyzer processes definitions
