winlib.c (797B)
1 /* Copyright (c) 2003, Roger Dingledine 2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson. 3 * Copyright (c) 2007-2021, The Tor Project, Inc. */ 4 /* See LICENSE for licensing information */ 5 6 /** 7 * \file winlib.c 8 * 9 * \brief Find and load windows system libraries. 10 * 11 * We use this function to dynamically load code at runtime that might not be 12 * available on all versions of Windows that we support. 13 **/ 14 15 #ifdef _WIN32 16 #include "lib/fs/winlib.h" 17 18 HANDLE 19 load_windows_system_library(const TCHAR *library_name) 20 { 21 TCHAR path[MAX_PATH]; 22 unsigned n; 23 n = GetSystemDirectory(path, MAX_PATH); 24 if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH) 25 return 0; 26 _tcscat(path, TEXT("\\")); 27 _tcscat(path, library_name); 28 return LoadLibrary(path); 29 } 30 #endif /* defined(_WIN32) */