β If this tool helped you, please consider giving it a star! β
Professional GUI tool for replacing API imports in PE files. Batch process EXE, DLL, VST, and SYS files with automatic backups and detailed logging.
PE API Replacer is a professional desktop application built on PyQt6 that performs binary patching of PE files (Portable Executable). The tool replaces calls to Windows API DLLs (for example, winhttp.dll, wininet.dll) with alternative DLLs (for example, exhttp.dll, exinet.dll) through modification of binary file data.
Provide a simple and secure method for batch redirecting API calls in executable files without requiring recompilation or detailed knowledge of PE internal structure.
ββββββββββββββββββββββββββββββββββββββββββββ
β UI Layer (PyQt6) β β User Interface
ββββββββββββββββββββββββββββββββββββββββββββ€
β Business Logic (Threading Workers) β β Asynchronous Processing
ββββββββββββββββββββββββββββββββββββββββββββ€
β Binary I/O (pefile + OS) β β File Operations
ββββββββββββββββββββββββββββββββββββββββββββ
Defines API replacement pairs in the DLL_REPLACEMENTS dictionary. Contains 10 groups of Windows APIs with their replacements.
Critical Feature: String length for binary replacement in PE format must exactly match the original. For padding, null bytes \x00 are used.
Configuration Example:
DLL_REPLACEMENTS = {
1: {'name': 'WINHTTP', 'replacements': {
b'winhttp.dll': b'exhttp.dll\x00', # 11 bytes + 1 null = 12 bytes
}},
5: {'name': 'IPHLPAPI', 'replacements': {
b'iphlpapi.dll': b'exiphl.dll\x00\x00', # 12 bytes = 12 bytes
}},
}UniversalPEPatcherβ Main class for modifications:- Loads PE files using the
pefilelibrary - Identifies patch locations in Import Address Table (IAT) and raw data
- Performs binary replacements with length verification
- Saves modified files while preserving PE structure
- Loads PE files using the
ThreadManager (coordinator)
ββ PatcherWorker (main file processing)
ββ FileProcessorWorker (file analysis)
ββ FolderScannerWorker (folder scanning)
ββ QThread (background thread)
Signal-Slot System:
log_signalβ Transmit log messages with color codesfile_processedβ Update file information in UIprogress_updatedβ Update progress barfinishedβ Signal task completionfile_status_updatedβ Change current file status
- Refined Material Design β Custom dark theme with violet accents
- Splitter-based Layout:
- Left panel β File list with swipe-to-delete
- Right panel β Settings + logs
- Animated Components:
- File element swipe-to-delete
- Deletion animation
- Smooth state transitions
# Read file as bytearray for modification
with open(file_path, 'rb') as f:
data = bytearray(f.read())
# Parse PE structure for analysis
pe = pefile.PE(data=data)check_if_patchable() method:
- Scans Import Directory Entry for matching DLL names
- Searches for binary sequences in file body
- Counts total replacements to perform
Result:
[IAT] winhttp.dll (1 occurrence)
[HEX] winhttp.dll (3 occurrences)
Total: 4 patchable locations
patch_all() method:
IAT Patching (import table):
# Find import entry for winhttp.dll
offset = pe.get_offset_from_rva(entry.struct.Name)
# Replace with exhttp.dll\x00 (14 bytes = 14 bytes)
data[offset:offset+14] = b'exhttp.dll\x00'Hex Patching (raw data):
# Search for b'winhttp.dll' in entire file
# Replace with b'exhttp.dll\x00' at each found location
# β οΈ Only if lengths match!# Use pefile for proper structure preservation
pe_patched = pefile.PE(data=modified_data)
pe_patched.write(output_path)Original.exe (original location)
β (backup copy)
backup/Original.backup1.exe
β (patching)
patched/Original.exe
β (optional: overwrite)
Original.exe (replaces original)
Processing Flow:
- If
backup=Trueβ copy created inbackup/folder - Patching performed in
patched/folder - If
overwrite=Trueβ patched file replaces original - If both options enabled β protection duplicated
config.py / main.py
β
TranslationManager
β
load_language('en')
β
lang_en.xml
β
QWidget.setText(translator.get('key'))
<resources>
<string name="app_title">PE API Replacer</string>
<string name="log_processing_file">Processing: {0} {1}</string>
<string name="summary_patched">{0} patched</string>
</resources># Template with placeholders
template = "Found {0} files in {1} seconds"
# Parameter transmission
translator.get('found_files', 25, "10")
# β "Found 25 files in 10 seconds"[Settings]
language = uk
show_dialog = FalseFile normalization.exe
βββββββββββββββββββββββββββββββββββββββββββββββ
[Info] Ready [Remove]
βββββββββββββββββββββββββββββββββββββββββββββββ
π Drag left to delete
Animation:
- Swipe left β show delete icon (ποΈ)
- Release β slide-out animation (300ms)
- Height reduction (250ms)
- Remove from UI
Functionality:
- Recursively scans folder for PE files
- Automatically skips
patched/andbackup/folders - Shows progress in real-time
- Allows cancellation of scan
- Lists skipped folders with reasons
Supported Extensions:
.exe, .dll, .vst3, .vst, .sys, .ocx, .ax
14:32:15 βΉοΈ Started PE API Replacer v1.0.9
14:32:16 π Processing: [1/5] app.exe
14:32:18 β
[IAT] winhttp.dll β exhttp.dll
14:32:19 β
[HEX] winhttp.dll β exhttp.dll (3x)
14:32:20 β
Total: 4 changes
14:32:22 πΎ Saved: patched/app.exe
14:32:25 β
Finished: 1 patched, 0 skipped, 0 with errors
Color Semantics:
- Gray β Time and metadata
- Blue β General information
- Green (β ) β Success
- Yellow (
β οΈ ) β Warning - Red (β) β Error
- Shows version, author, GitHub link
- Donation Addresses for Copy:
- Bitcoin, Ethereum, Monero, TON
- USDT (TRC20, ERC20), USDC, Tron, BNB
- One-click copy to clipboard
1οΈβ£ User clicks "Start Patching"
β
2οΈβ£ UI collects selected APIs (getChecked())
β
3οΈβ£ Build active_replacements dictionary
β
4οΈβ£ PatcherWorker launched in background thread
β
5οΈβ£ For each file:
ββ PermissionsManager: check/modify permissions
ββ UniversalPEPatcher: load file
ββ check_if_patchable(): verify possibility
ββ patch_all(): perform replacements
ββ Save to backup/ (if enabled)
ββ Save to patched/
ββ Move to original (if overwrite=True)
ββ Emit file_status_updated
ββ Emit progress_updated
β
6οΈβ£ patching_done signal
β
7οΈβ£ Clear UI, show summary
User clicks Cancel
β
is_cancelled = True
β
Current file finishes
β
For all remaining files: status = 'cancelled'
β
Remove processed files from list
β
Show count of remaining files
β
Allow user to continue patching
| # | Name | Original | Replacement |
|---|---|---|---|
| 1 | WINHTTP | winhttp.dll |
exhttp.dll\x00 |
| 2 | WININET | wininet.dll |
exinet.dll\x00 |
| 3 | WS2_32 | ws2_32.dll |
exws2.dll\x00 |
| 4 | SENSAPI | sensapi.dll |
exsens.dll\x00 |
| 5 | IPHLPAPI | iphlpapi.dll |
exiphl.dll\x00\x00 |
| 6 | URLMON | urlmon.dll |
exurlm.dll |
| 7 | NETAPI32 | netapi32.dll |
exnetapi.dll |
| 8 | WSOCK32 | wsock32.dll |
exws.dll\x00\x00\x00 |
| 9 | WINTRUST | wintrust.dll |
extrust.dll\x00 |
| 10 | MSWSOCK | mswsock.dll |
exmsw.dll\x00\x00 |
Note: All replacements have null bytes for exact length correspondence.
- Python 3.10+ β Main application logic
- PyQt6 β Cross-platform GUI framework
- C/C++ β High-performance substitute libraries
- llvm-mingw 21.1.3 β Compiler for Windows PE
- Clang/LLVM 21.1.3
- MinGW-w64 runtime
- Full Windows API support
- Optimization for x64 binary generation
requirements:
- PyQt6 β₯ 6.0
- pefile β₯ 2022.8.7
- Python β₯ 3.10
optional (for development):
- llvm-mingw 21.1.3 (C compiler for binary generation)
# Cloning
git clone https://github.com/EXLOUD/PE-API-REPLACER.git
cd PE-API-REPLACER
# Installing dependencies
pip install PyQt6 pefilepython main.py- Click "Add Files" or "Add Folder"
- Select APIs for replacement (checkboxes)
- Adjust options (backup copy, overwrite)
- Click "Start Patching"
- Wait for completion
GNU General Public License v3.0 (GPL-3.0)
β
Can be used, modified, distributed
β
Can be used commercially
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make commits
- Submit to a branch
- Open a Pull Request
For C/C++ contributions β compile with llvm-mingw 21.1.3.
- Version: 1.0.10
- Status: β Stable
- Dependencies: Python 3.10+, PyQt6, pefile
- License: GPL-3.0
- OS: Windows, macOS, Linux
- Architecture: 64-bit PE files
PE API Replacer is a production-ready tool for binary patching with complete error handling, localization, professional UX design, and extended architecture.