What is WinPR?
WinPR (Windows Portable Runtime) is a portability library that implements a broad subset of the Win32 API on non-Windows operating systems. FreeRDP is written against Win32 APIs internally —HANDLE, CreateThread, WaitForSingleObject, CreateMutex, and friends — and WinPR provides those APIs everywhere else.
This means the same FreeRDP source code compiles and runs on Linux, macOS, Android, and BSD without #ifdef sprawl scattered through every file.
WinPR can also be used as a standalone library in any C/C++ project that wants portable Win32-style primitives without pulling in the full FreeRDP stack.
Why it exists
The Win32 API has well-understood, widely-documented primitives for threading, synchronization, file I/O, networking, cryptography, and more. Rather than replacing those concepts with yet another abstraction layer, WinPR maps them to their POSIX or platform-native equivalents at compile time. The result is:- FreeRDP source stays readable to Windows developers.
- Platform-specific bugs are isolated inside WinPR, not spread across the codebase.
- Applications built on FreeRDP inherit portability for free.
Key modules
Each module lives underwinpr/libwinpr/ and exposes its public API through a header in winpr/include/winpr/.
Thread — winpr/thread.h
Thread — winpr/thread.h
Process and thread management:
CreateThread, ExitThread, GetCurrentThread, GetCurrentThreadId, WaitForSingleObject, TerminateThread, and the STARTUPINFO / PROCESS_INFORMATION structures used by CreateProcess.Synch — winpr/synch.h
Synch — winpr/synch.h
Synchronization primitives mirroring the Win32 kernel object model:
- Mutex —
CreateMutexA,CreateMutexW,ReleaseMutex - Semaphore —
CreateSemaphoreA,ReleaseSemaphore - Event —
CreateEventA,SetEvent,ResetEvent - Critical Section —
InitializeCriticalSection,EnterCriticalSection,LeaveCriticalSection - Wait functions —
WaitForSingleObject,WaitForMultipleObjects - Condition variables —
InitializeConditionVariable,SleepConditionVariableCS - Slim Reader/Writer locks —
InitializeSRWLock,AcquireSRWLockExclusive,ReleaseSRWLockExclusive - One-time init —
InitOnceExecuteOnce - Interlocked operations —
InterlockedIncrement,InterlockedCompareExchange
File — winpr/file.h
File — winpr/file.h
Win32 file I/O constants (
FILE_ATTRIBUTE_*, GENERIC_READ, GENERIC_WRITE), CreateFileA, ReadFile, WriteFile, CloseHandle, DeleteFileA, MoveFileExA, directory functions, and FindFirstFileA / FindNextFileA.Stream — winpr/stream.h
Stream — winpr/stream.h
wStream, a lightweight byte-buffer abstraction used pervasively inside FreeRDP for encoding and decoding RDP PDUs. Provides Stream_New, Stream_Free, read/write helpers with automatic endian conversion, and wStreamPool for reuse.SSPI — winpr/sspi.h
SSPI — winpr/sspi.h
Security Support Provider Interface implementation covering NTLM, Kerberos, Negotiate, and Schannel. Used by FreeRDP for RDP authentication.
Crypto — winpr/crypto.h / bcrypt.h
Crypto — winpr/crypto.h / bcrypt.h
Wrappers around OpenSSL (or platform CNG on Windows) providing digest, cipher, HMAC, and certificate functions under the familiar
BCrypt* / NCrypt* naming.Registry — winpr/registry.h
Registry — winpr/registry.h
Emulated Windows registry backed by an INI-style file on non-Windows platforms. Supports
RegOpenKeyExA, RegQueryValueExA, RegSetValueExA, and friends.Timezone — winpr/timezone.h
Timezone — winpr/timezone.h
GetTimeZoneInformation and GetDynamicTimeZoneInformation mapped to the platform’s tzdata database.SysInfo — winpr/sysinfo.h
SysInfo — winpr/sysinfo.h
GetSystemInfo, GetNativeSystemInfo, GetComputerNameA, GetComputerNameExA, GetTickCount64, GetSystemTime, GetLocalTime, and processor architecture constants.Environment — winpr/environment.h
Environment — winpr/environment.h
GetEnvironmentVariableA, SetEnvironmentVariableA, ExpandEnvironmentStringsA.Collections — winpr/collections.h
Collections — winpr/collections.h
Generic data structures:
wArrayList, wQueue, wStack, wHashTable, wLinkedList, wCountdownEvent, wMessageQueue, and wPubSub.Library — winpr/library.h
Library — winpr/library.h
LoadLibraryA, GetProcAddress, FreeLibrary mapped to dlopen / dlsym / dlclose on POSIX.Pipe — winpr/pipe.h
Pipe — winpr/pipe.h
CreatePipe and CreateNamedPipeA for anonymous and named pipes.Winsock — winpr/winsock.h
Winsock — winpr/winsock.h
Thin compatibility layer over BSD sockets that lets code written against
winsock2.h compile unchanged.WLog — winpr/wlog.h
WLog — winpr/wlog.h
WinPR’s own structured logging framework with hierarchical loggers, multiple appenders (console, file, syslog, journald, UDP, binary, callback), and environment-variable configuration. See the WLog reference for full details.
Using WinPR
As part of FreeRDP
WinPR is built and linked automatically when you build FreeRDP. No extra steps are needed — just include the relevant header.As a standalone library
WinPR can be built and installed independently:winpr3 (CMake target) or use pkg-config:
Include pattern
Every WinPR header is self-contained and guarded against multiple inclusion:Build options
| CMake option | Default | Description |
|---|---|---|
WITH_WINPR_TOOLS | ON | Build WinPR command-line utilities |
WITH_WINPR_DEPRECATED | OFF | Expose deprecated API symbols |
WITH_OPENSSL | detected | Use OpenSSL for crypto |
WITH_MBEDTLS | OFF | Use mbedTLS instead of OpenSSL |
WITH_SWSCALE | detected | Enable image scaling support |
CHANNEL_URBDRC | detected | USB redirection channel (requires libudev) |
Platform support
| Platform | Status |
|---|---|
| Linux (x86_64, aarch64, armv7) | Fully supported |
| macOS (x86_64, arm64) | Fully supported |
| Android (NDK) | Fully supported |
| FreeBSD / OpenBSD | Supported |
| Windows | WinPR headers thin-wrap the native Win32 API — no emulation needed |
