aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fs/winlib.c
blob: b7302bd4cab7f8719460a968f3a494b71000f57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Copyright (c) 2003, Roger Dingledine
 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
 * Copyright (c) 2007-2019, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file winlib.c
 *
 * \brief Find and load windows system libraries.
 *
 * We use this function to dynamically load code at runtime that might not be
 * available on all versions of Windows that we support.
 **/

#ifdef _WIN32
#include "lib/fs/winlib.h"

HANDLE
load_windows_system_library(const TCHAR *library_name)
{
  TCHAR path[MAX_PATH];
  unsigned n;
  n = GetSystemDirectory(path, MAX_PATH);
  if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH)
    return 0;
  _tcscat(path, TEXT("\\"));
  _tcscat(path, library_name);
  return LoadLibrary(path);
}
#endif /* defined(_WIN32) */