Thread-safe implementation of profile functions (Windows and Wine).