diff options
author | Nick Mathewson <nickm@torproject.org> | 2010-09-21 13:07:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-09-21 14:39:23 -0400 |
commit | 418e6caeebfb13c66ea1b4904fb331fe57b82b80 (patch) | |
tree | 9189015c838c66a5f1d9d98af8aba69852ed138b /src/common | |
parent | fb34c66e83790bf03b163555128565823a3e58fe (diff) | |
download | tor-418e6caeebfb13c66ea1b4904fb331fe57b82b80.tar.gz tor-418e6caeebfb13c66ea1b4904fb331fe57b82b80.zip |
New function to load windows system libraries
This function uses GetSystemDirectory() to make sure we load the version
of the library from c:\windows\system32 (or local equivalent) rather than
whatever version lives in the cwd.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 15 | ||||
-rw-r--r-- | src/common/util.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c index 1d770458f7..12be008745 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -26,6 +26,7 @@ #include <io.h> #include <direct.h> #include <process.h> +#include <tchar.h> #else #include <dirent.h> #include <pwd.h> @@ -2793,3 +2794,17 @@ write_pidfile(char *filename) } } +#ifdef MS_WINDOWS +HANDLE +load_windows_system_library(const TCHAR *library_name) +{ + TCHAR path[MAX_PATH]; + unsigned n; + n = GetSystemDirectory(path, 1024); + if (n == 0 || n + _tcslen(library_name) + 2 >= MAX_PATH) + return 0; + _tcscat(path, TEXT("\\")); + _tcscat(path, library_name); + return LoadLibrary(path); +} +#endif diff --git a/src/common/util.h b/src/common/util.h index 4a31c277e3..833fd904c7 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -340,6 +340,10 @@ void start_daemon(void); void finish_daemon(const char *desired_cwd); void write_pidfile(char *filename); +#ifdef MS_WINDOWS +HANDLE load_windows_system_library(const TCHAR *library_name); +#endif + const char *libor_get_digests(void); #endif |