Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2008-10-22 17:30:42 +0400
committerCorinna Vinschen <corinna@vinschen.de>2008-10-22 17:30:42 +0400
commit3e97726f98fae9a1acdc4dd26f837782047397bb (patch)
tree8b62da09dd6cadc3cfb977fc3a68499b916f30a6 /winsup/cygwin/kernel32.cc
parentdf54adb746cf0f3cb92b38abc030db5d52465f51 (diff)
* autoload.cc (GetSystemWindowsDirectoryW): Define.
* kernel32.cc (GetWindowsDirectoryW): Implement to abstract from running under Terminal Services or not. (GetWindowsDirectoryA): Ditto.
Diffstat (limited to 'winsup/cygwin/kernel32.cc')
-rw-r--r--winsup/cygwin/kernel32.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/winsup/cygwin/kernel32.cc b/winsup/cygwin/kernel32.cc
index ce83c5655..47bd2844e 100644
--- a/winsup/cygwin/kernel32.cc
+++ b/winsup/cygwin/kernel32.cc
@@ -11,6 +11,7 @@ details. */
#include "winsup.h"
#include "shared_info.h"
#include "ntdll.h"
+#include <wchar.h>
/* Implement CreateEvent/OpenEvent so that named objects are always created in
Cygwin shared object namespace. */
@@ -402,3 +403,37 @@ OpenFileMappingA (DWORD dwDesiredAccess, BOOL bInheritHandle, LPCSTR lpName)
}
return OpenFileMappingW (dwDesiredAccess, bInheritHandle, lpName ? name : NULL);
}
+
+/* When Terminal Services are installed, the GetWindowsDirectory function
+ does not return the system installation dir, but a user specific directory
+ instead. That's not what we have in mind when calling GetWindowsDirectory
+ from within Cygwin. So we're calling GetSystemWindowsDirectory from here,
+ except on NT4 where we use the method as described in KB186498. */
+
+#define SYSTEM32 (sizeof ("\\System32") - 1)
+
+UINT WINAPI
+GetWindowsDirectoryW (LPWSTR buf, UINT size)
+{
+ if (wincap.has_terminal_services ())
+ return GetSystemWindowsDirectoryW (buf, size);
+ /* NT4 */
+ WCHAR name [size + SYSTEM32];
+ UINT ret = GetSystemDirectoryW (name, size + SYSTEM32);
+ if (ret < size + SYSTEM32)
+ {
+ name[ret - SYSTEM32] = L'\0';
+ wcscpy (buf, name);
+ }
+ return ret - SYSTEM32;
+}
+
+UINT WINAPI
+GetWindowsDirectoryA (LPSTR buf, UINT size)
+{
+ WCHAR name[MAX_PATH];
+ UINT ret = GetWindowsDirectoryW (name, min (size, MAX_PATH));
+ if (ret < size)
+ sys_wcstombs (buf, size, name);
+ return ret;
+}