Skip to main content

Overview

SysWhispers4 supports MinGW and Clang compilers using GAS (GNU Assembler) inline assembly syntax. This guide covers complete integration from generation to compilation.

Key Differences from MSVC

Quick Integration

1

Generate MinGW-compatible files

Generated files:
  • SW4Syscalls_Types.h — NT type definitions
  • SW4Syscalls.h — Function prototypes
  • SW4Syscalls.c — Runtime SSN resolution
  • SW4Syscalls_stubs.c — GAS inline assembly stubs (replaces .asm)
2

Create your main program

main.c:
3

Compile with MinGW

Important flags:
  • -masm=intel — Use Intel assembly syntax (required)
  • -lntdll — Link against ntdll (for initialization helpers)
4

Run the executable

Expected output:

Complete Process Injection Example

Generate Files

Source Code

injector.c:

Compilation

x64 build:
Flags explained:
  • -masm=intel — Intel syntax (required for inline asm)
  • -lntdll — Link ntdll.dll
  • -O2 — Optimize for speed
  • -s — Strip symbols (smaller binary)
x86 build (32-bit):

Build Output

Cross-Compilation from Linux

Install MinGW on Linux

Debian/Ubuntu:
Arch Linux:
Fedora/RHEL:

Generate and Compile

Using Clang

Generate for Clang

Note: Output is identical to MinGW (GAS inline assembly). Clang uses the same syntax.

Compile with Clang

Windows (with Clang installed):
Linux cross-compile:

Makefile Example

Makefile:
Usage:

Advanced Configurations

Maximum Evasion

Compile:
Additional flags:
  • -ffunction-sections — Separate functions into sections
  • -fdata-sections — Separate data into sections
  • -Wl,--gc-sections — Remove unused sections (smaller binary)

Shellcode Generation

Compile as position-independent code for shellcode conversion:
Extract shellcode:

Static Linking

Create fully self-contained executable:
Note: Binary size will be much larger (~1-2 MB vs ~50 KB).

DLL Creation

Generate Files

DLL Source

payload.c:

Compile DLL

Output: payload.dll ready for injection

Troubleshooting

Error: “operand type mismatch for ‘syscall’”

Cause: x64 instruction in x86 build. Solution:
  • Ensure you’re using x64 compiler: x86_64-w64-mingw32-gcc
  • Or regenerate with --arch x86 for 32-bit

Error: “undefined reference to ‘SW4_NtAllocateVirtualMemory’”

Cause: Missing SW4Syscalls_stubs.c in compilation. Solution:

Error: “Bad value (intel) for -masm= switch”

Cause: Old GCC version (< 4.9). Solution:
  • Update MinGW: sudo apt install --upgrade mingw-w64
  • Or remove -masm=intel (uses AT&T syntax — not recommended)

Warning: “implicit declaration of function ‘GetModuleHandleA’”

Cause: Missing Windows header. Solution:

Initialization Fails on Wine

Symptoms: SW4_Initialize() returns FALSE when running under Wine. Cause: Wine’s ntdll implementation differs from Windows. Solution:
  • Use --resolve static (embeds SSN table, no runtime parsing)
  • Or test on real Windows (Wine compatibility not guaranteed)

Comparison: MinGW vs MSVC

Binary Size

Performance

Nearly identical — syscall overhead dominates (assembly is the same).

Compatibility

  • MSVC: Windows-only (Visual Studio required)
  • MinGW: Cross-platform (compile from Linux/macOS)

Debugging

  • MSVC: Full Visual Studio debugger integration
  • MinGW: GDB (command-line or IDE integration)

Best Practices

  1. Always include -masm=intel:
  2. Link ntdll for initialization helpers:
  3. Use optimization for smaller binaries:
  4. Strip symbols in production:
    Or after compilation:
  5. Check NTSTATUS values:

Next Steps

MSVC Integration

Alternative: Visual Studio integration

Advanced Evasion

Learn about all evasion techniques