Malware Analysis

WINDOWS API

Reference guide for Windows API functions commonly encountered in malware analysis, covering kernel32.dll, ntdll.dll, and user32.dll function families.

Contents

The Windows API (Application Programming Interface) is simply the official set of functions that Microsoft provides so that programs (normal software and malware alike) can interact with the Windows operating system.

Think of it as the only legal way a program can ask Windows to do anything useful: create a file, start a process, open a network connection, press a key, hide a window, etc.

Every piece of Windows malware you will ever analyze uses the Windows API — there is no other way.

1. Where does the Windows API live?

DLL (Dynamic Link Library)What it contains – most important for malware
kernel32.dllFile, process, thread, memory, handles – the core
user32.dllWindows, messages, keyboard/mouse, GUI stuff
advapi32.dllRegistry, services, privileges, crypto
ntdll.dllLow-level NT system calls (the real kernel interface)
ws2_32.dll / wininet.dllNetwork: sockets, HTTP, DNS
shell32.dll / shlwapi.dllShell operations, file shortcuts, URLs
ole32.dll / oleaut32.dllCOM, automation, often used for Office macros
winhttp.dllModern HTTPS (common in 2024–2025 malware)
crypt32.dllCertificate functions (often abused)

2. Two ways programs call the Windows API

MethodWhat you see in static analysisWhat you see when running
Dynamic linking (99% of normal programs & most malware)Clear Import Address Table (IAT) with function names: CreateFileA, WriteProcessMemory, RegSetValueEx, etc.Easy to see in ProcMon, API monitors
Dynamic / manual loading (common evasion technique)No imported names, or only LoadLibrary + GetProcAddressAt runtime it loads the DLL and resolves functions manually → hides real API usage from static tools

3. The Most Important Windows API Functions You Will See in Malware (2025 hit list)

CategoryAPI FunctionWhat malware uses it for
Process InjectionVirtualAllocEx, WriteProcessMemory, CreateRemoteThreadClassic DLL/code injection
NtMapViewOfSection, NtCreateThreadEx (ntdll)Stealthier injection (direct syscalls)
PersistenceRegCreateKeyEx, RegSetValueExWrites to HKCU\Run, HKLM\Run, etc.
CreateService, StartServiceInstalls itself as service
File OperationsCreateFile, WriteFile, CopyFileDrops payload, ransomware encryption
URLDownloadToFile, WinHttpOpenDownloads next stage
Networksocket, connect, WSAConnectRaw sockets (ws2_32)
InternetOpen, HttpOpenRequestOld wininet style C2
WinHttpConnect, WinHttpSendRequestModern HTTPS C2 (2023–2025)
Anti-AnalysisIsDebuggerPresent, CheckRemoteDebuggerPresentDetects if being debugged
NtQueryInformationProcessProcessDebugPort, ProcessDebugObjectHandle
GetTickCount, QueryPerformanceCounter → XOR checkTiming checks against sandboxes
Privilege EscalationLookupPrivilegeValue, AdjustTokenPrivilegesEnables SeDebugPrivilege, SeImpersonate, etc.
EvasionLoadLibrary, GetProcAddressDynamic API resolution (hides real functions)
NtOpenProcess, NtReadVirtualMemoryDirect syscall versions (bypasses API hooks)
HidingSetWindowsHookEx, RegisterHotKeyKeylogger or persistence
CreateMutex, OpenMutexSingleton check (only one instance)

4. How malware hides Windows API usage (2025 techniques)

TechniqueWhat it looks like in tools
Direct syscallsCalls ntdll functions with syscall numbers instead of using kernel32
API hashingHashes function names at runtime, resolves via GetProcAddress
String encryptionAll API and DLL names are encrypted/obfuscated
Reflective DLL injectionNo LoadLibrary on disk, everything in memory
Syscall stubbingMalware contains its own syscall stubs (e.g., Tartarus Gate, SysWhispers)

5. Quick cheat sheet for daily malware analysis

When you open a sample in PE-bear, x64dbg, or IDA, ask yourself these questions:

  1. Does it import suspicious APIs? → CreateRemoteThread + WriteProcessMemory = almost certainly injection
  2. Does it only import LoadLibrary + GetProcAddress? → It’s doing dynamic resolution (common evasion)
  3. Does it import a lot of Nt* functions from ntdll? → Probably doing direct syscalls to evade EDR hooks
  4. Does it import networking APIs but no URLs visible? → Domain generation algorithm (DGA) or encrypted config
  5. Does it import VirtualAlloc + CreateThread + WinHttp*? → Typical downloader → shellcode → next-stage pattern