summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tclWin32Dll.c164
-rw-r--r--win/tclWinPort.h15
2 files changed, 69 insertions, 110 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index 1a8250e..c3fb6f8 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWin32Dll.c,v 1.67 2010/09/10 20:56:36 nijtmans Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.68 2010/09/14 08:53:49 nijtmans Exp $
*/
#include "tclWinInt.h"
@@ -70,59 +70,61 @@ static Tcl_Encoding winTCharEncoding = NULL;
* versions of the operating system calls.
*/
-static TclWinProcs winProcs = {
+static const TclWinProcs winProcs = {
1,
- (BOOL (WINAPI *)(const TCHAR *, LPDCB)) BuildCommDCBW,
- (TCHAR *(WINAPI *)(TCHAR *)) CharLowerW,
- (BOOL (WINAPI *)(const TCHAR *, const TCHAR *, BOOL)) CopyFileW,
- (BOOL (WINAPI *)(const TCHAR *, LPSECURITY_ATTRIBUTES)) CreateDirectoryW,
+ (BOOL (WINAPI *)(const TCHAR *, LPDCB)) BuildCommDCB,
+ (TCHAR *(WINAPI *)(TCHAR *)) CharLower,
+ (BOOL (WINAPI *)(const TCHAR *, const TCHAR *, BOOL)) CopyFile,
+ (BOOL (WINAPI *)(const TCHAR *, LPSECURITY_ATTRIBUTES)) CreateDirectory,
(HANDLE (WINAPI *)(const TCHAR *, DWORD, DWORD, SECURITY_ATTRIBUTES *,
- DWORD, DWORD, HANDLE)) CreateFileW,
+ DWORD, DWORD, HANDLE)) CreateFile,
(BOOL (WINAPI *)(const TCHAR *, TCHAR *, LPSECURITY_ATTRIBUTES,
LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, const TCHAR *,
- LPSTARTUPINFO, LPPROCESS_INFORMATION)) CreateProcessW,
- (BOOL (WINAPI *)(const TCHAR *)) DeleteFileW,
- (HANDLE (WINAPI *)(const TCHAR *, WIN32_FIND_DATAT *)) FindFirstFileW,
- (BOOL (WINAPI *)(HANDLE, WIN32_FIND_DATAT *)) FindNextFileW,
- (BOOL (WINAPI *)(TCHAR *, LPDWORD)) GetComputerNameW,
- (DWORD (WINAPI *)(DWORD, TCHAR *)) GetCurrentDirectoryW,
- (DWORD (WINAPI *)(const TCHAR *)) GetFileAttributesW,
+ LPSTARTUPINFO, LPPROCESS_INFORMATION)) CreateProcess,
+ (BOOL (WINAPI *)(const TCHAR *)) DeleteFile,
+ (HANDLE (WINAPI *)(const TCHAR *, WIN32_FIND_DATAT *)) FindFirstFile,
+ (BOOL (WINAPI *)(HANDLE, WIN32_FIND_DATAT *)) FindNextFile,
+ (BOOL (WINAPI *)(TCHAR *, LPDWORD)) GetComputerName,
+ (DWORD (WINAPI *)(DWORD, TCHAR *)) GetCurrentDirectory,
+ (DWORD (WINAPI *)(const TCHAR *)) GetFileAttributes,
(DWORD (WINAPI *)(const TCHAR *, DWORD nBufferLength, TCHAR *,
- TCHAR **)) GetFullPathNameW,
- (DWORD (WINAPI *)(const TCHAR *, TCHAR *, DWORD)) GetShortPathNameW,
+ TCHAR **)) GetFullPathName,
+ (DWORD (WINAPI *)(const TCHAR *, TCHAR *, DWORD)) GetShortPathName,
(UINT (WINAPI *)(const TCHAR *, const TCHAR *, UINT uUnique,
- TCHAR *)) GetTempFileNameW,
- (DWORD (WINAPI *)(DWORD, TCHAR *)) GetTempPathW,
+ TCHAR *)) GetTempFileName,
+ (DWORD (WINAPI *)(DWORD, TCHAR *)) GetTempPath,
(BOOL (WINAPI *)(const TCHAR *, TCHAR *, DWORD, LPDWORD, LPDWORD, LPDWORD,
- TCHAR *, DWORD)) GetVolumeInformationW,
- (HINSTANCE (WINAPI *)(const TCHAR *, HANDLE, DWORD)) LoadLibraryExW,
- (BOOL (WINAPI *)(const TCHAR *, const TCHAR *)) MoveFileW,
- (BOOL (WINAPI *)(const TCHAR *)) RemoveDirectoryW,
+ TCHAR *, DWORD)) GetVolumeInformation,
+ (HINSTANCE (WINAPI *)(const TCHAR *, HANDLE, DWORD)) LoadLibraryEx,
+ (BOOL (WINAPI *)(const TCHAR *, const TCHAR *)) MoveFile,
+ (BOOL (WINAPI *)(const TCHAR *)) RemoveDirectory,
(DWORD (WINAPI *)(const TCHAR *, const TCHAR *, const TCHAR *, DWORD,
- TCHAR *, TCHAR **)) SearchPathW,
- (BOOL (WINAPI *)(const TCHAR *)) SetCurrentDirectoryW,
- (BOOL (WINAPI *)(const TCHAR *, DWORD)) SetFileAttributesW,
-
- /*
- * The three NULL function pointers will only be set when
- * Tcl_FindExecutable is called. If you don't ever call that function, the
- * application will crash whenever WinTcl tries to call functions through
- * these null pointers. That is not a bug in Tcl - Tcl_FindExecutable is
- * mandatory in recent Tcl releases.
- */
-
- NULL,
- NULL,
- NULL,
- NULL,
- /* getLongPathNameProc */
- NULL,
- /* Security SDK - will be filled in on NT,XP,2000,2003 */
- NULL, NULL, NULL, NULL, NULL, NULL,
+ TCHAR *, TCHAR **)) SearchPath,
+ (BOOL (WINAPI *)(const TCHAR *)) SetCurrentDirectory,
+ (BOOL (WINAPI *)(const TCHAR *, DWORD)) SetFileAttributes,
+ (BOOL (WINAPI *)(const TCHAR *, GET_FILEEX_INFO_LEVELS,
+ LPVOID)) GetFileAttributesEx,
+ (BOOL (WINAPI *)(const TCHAR *, const TCHAR*,
+ LPSECURITY_ATTRIBUTES)) CreateHardLink,
+ (HANDLE (WINAPI *)(const TCHAR*, UINT, LPVOID, UINT,
+ LPVOID, DWORD)) FindFirstFileEx,
+ (BOOL (WINAPI *)(const TCHAR*, TCHAR*,
+ DWORD)) GetVolumeNameForVolumeMountPoint,
+ (DWORD (WINAPI *)(const TCHAR*, TCHAR*,
+ DWORD)) GetLongPathName,
+ /* Security SDK */
+ (BOOL (WINAPI *)(LPCTSTR, SECURITY_INFORMATION,
+ PSECURITY_DESCRIPTOR, DWORD, LPDWORD)) GetFileSecurity,
+ (BOOL (WINAPI *) (SECURITY_IMPERSONATION_LEVEL)) ImpersonateSelf,
+ (BOOL (WINAPI *) (HANDLE, DWORD, BOOL, PHANDLE)) OpenThreadToken,
+ (BOOL (WINAPI *) (void)) RevertToSelf,
+ (void (WINAPI *) (PDWORD, PGENERIC_MAPPING)) MapGenericMask,
+ (BOOL (WINAPI *)(PSECURITY_DESCRIPTOR, HANDLE, DWORD,
+ PGENERIC_MAPPING, PPRIVILEGE_SET, LPDWORD, LPDWORD, LPBOOL)) AccessCheck,
/* ReadConsole and WriteConsole */
- (BOOL (WINAPI *)(HANDLE, LPVOID, DWORD, LPDWORD, LPVOID)) ReadConsoleW,
- (BOOL (WINAPI *)(HANDLE, const void*, DWORD, LPDWORD, LPVOID)) WriteConsoleW,
- (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserNameW,
+ (BOOL (WINAPI *)(HANDLE, LPVOID, DWORD, LPDWORD, LPVOID)) ReadConsole,
+ (BOOL (WINAPI *)(HANDLE, const void*, DWORD, LPDWORD, LPVOID)) WriteConsole,
+ (BOOL (WINAPI *)(LPTSTR, LPDWORD)) GetUserName,
(const TCHAR *(*)(const char *, int, Tcl_DString *)) Tcl_WinUtfToTChar,
(const char *(*)(const TCHAR *, int, Tcl_DString *)) Tcl_WinTCharToUtf
};
@@ -387,62 +389,6 @@ TclWinSetInterfaces(
if (wide) {
winTCharEncoding = Tcl_GetEncoding(NULL, "unicode");
- if (winProcs.getFileAttributesExProc == NULL) {
- HINSTANCE hInstance = LoadLibrary(TEXT("kernel32"));
-
- if (hInstance != NULL) {
- winProcs.getFileAttributesExProc =
- (BOOL (WINAPI *)(const TCHAR *, GET_FILEEX_INFO_LEVELS,
- LPVOID)) GetProcAddress(hInstance,
- "GetFileAttributesExW");
- winProcs.createHardLinkProc =
- (BOOL (WINAPI *)(const TCHAR *, const TCHAR*,
- LPSECURITY_ATTRIBUTES)) GetProcAddress(hInstance,
- "CreateHardLinkW");
- winProcs.findFirstFileExProc =
- (HANDLE (WINAPI *)(const TCHAR*, UINT, LPVOID, UINT,
- LPVOID, DWORD)) GetProcAddress(hInstance,
- "FindFirstFileExW");
- winProcs.getVolumeNameForVMPProc =
- (BOOL (WINAPI *)(const TCHAR*, TCHAR*,
- DWORD)) GetProcAddress(hInstance,
- "GetVolumeNameForVolumeMountPointW");
- winProcs.getLongPathNameProc =
- (DWORD (WINAPI *)(const TCHAR*, TCHAR*,
- DWORD)) GetProcAddress(hInstance, "GetLongPathNameW");
- FreeLibrary(hInstance);
- }
- hInstance = LoadLibrary(TEXT("advapi32"));
- if (hInstance != NULL) {
- winProcs.getFileSecurityProc = (BOOL (WINAPI *)(
- LPCTSTR lpFileName,
- SECURITY_INFORMATION RequestedInformation,
- PSECURITY_DESCRIPTOR pSecurityDescriptor,
- DWORD nLength, LPDWORD lpnLengthNeeded))
- GetProcAddress(hInstance, "GetFileSecurityW");
- winProcs.impersonateSelfProc = (BOOL (WINAPI *) (
- SECURITY_IMPERSONATION_LEVEL ImpersonationLevel))
- GetProcAddress(hInstance, "ImpersonateSelf");
- winProcs.openThreadTokenProc = (BOOL (WINAPI *) (
- HANDLE ThreadHandle, DWORD DesiredAccess,
- BOOL OpenAsSelf, PHANDLE TokenHandle))
- GetProcAddress(hInstance, "OpenThreadToken");
- winProcs.revertToSelfProc = (BOOL (WINAPI *) (void))
- GetProcAddress(hInstance, "RevertToSelf");
- winProcs.mapGenericMaskProc = (void (WINAPI *) (
- PDWORD AccessMask, PGENERIC_MAPPING GenericMapping))
- GetProcAddress(hInstance, "MapGenericMask");
- winProcs.accessCheckProc = (BOOL (WINAPI *)(
- PSECURITY_DESCRIPTOR pSecurityDescriptor,
- HANDLE ClientToken, DWORD DesiredAccess,
- PGENERIC_MAPPING GenericMapping,
- PPRIVILEGE_SET PrivilegeSet,
- LPDWORD PrivilegeSetLength, LPDWORD GrantedAccess,
- LPBOOL AccessStatus)) GetProcAddress(hInstance,
- "AccessCheck");
- FreeLibrary(hInstance);
- }
- }
}
}
@@ -555,7 +501,7 @@ TclWinDriveLetterForVolMountPoint(
Tcl_MutexLock(&mountPointMap);
dlIter = driveLetterLookup;
while (dlIter != NULL) {
- if (wcscmp((WCHAR *)dlIter->volumeName, mountPoint) == 0) {
+ if (wcscmp(dlIter->volumeName, mountPoint) == 0) {
/*
* We need to check whether this information is still valid, since
* either the user or various programs could have adjusted the
@@ -568,9 +514,9 @@ TclWinDriveLetterForVolMountPoint(
* Try to read the volume mount point and see where it points.
*/
- if (tclWinProcs->getVolumeNameForVMPProc((TCHAR *) drive,
- (TCHAR *) Target, 55) != 0) {
- if (wcscmp((WCHAR *) dlIter->volumeName, Target) == 0) {
+ if (GetVolumeNameForVolumeMountPoint(drive,
+ Target, 55) != 0) {
+ if (wcscmp(dlIter->volumeName, Target) == 0) {
/*
* Nothing has changed.
*/
@@ -627,13 +573,13 @@ TclWinDriveLetterForVolMountPoint(
* Try to read the volume mount point and see where it points.
*/
- if (tclWinProcs->getVolumeNameForVMPProc((TCHAR *) drive,
- (TCHAR *) Target, 55) != 0) {
+ if (GetVolumeNameForVolumeMountPoint(drive,
+ Target, 55) != 0) {
int alreadyStored = 0;
for (dlIter = driveLetterLookup; dlIter != NULL;
dlIter = dlIter->nextPtr) {
- if (wcscmp((WCHAR *) dlIter->volumeName, Target) == 0) {
+ if (wcscmp(dlIter->volumeName, Target) == 0) {
alreadyStored = 1;
break;
}
@@ -654,7 +600,7 @@ TclWinDriveLetterForVolMountPoint(
for (dlIter = driveLetterLookup; dlIter != NULL;
dlIter = dlIter->nextPtr) {
- if (wcscmp((WCHAR *)dlIter->volumeName, mountPoint) == 0) {
+ if (wcscmp(dlIter->volumeName, mountPoint) == 0) {
Tcl_MutexUnlock(&mountPointMap);
return dlIter->driveLetter;
}
diff --git a/win/tclWinPort.h b/win/tclWinPort.h
index 1acf980..669fceb 100644
--- a/win/tclWinPort.h
+++ b/win/tclWinPort.h
@@ -10,12 +10,25 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinPort.h,v 1.60 2010/09/09 14:30:20 nijtmans Exp $
+ * RCS: @(#) $Id: tclWinPort.h,v 1.61 2010/09/14 08:53:49 nijtmans Exp $
*/
#ifndef _TCLWINPORT
#define _TCLWINPORT
+/*
+ * We must specify the lower version we intend to support.
+ *
+ * WINVER = 0x0500 means Windows 2000 and above
+ */
+
+#ifndef WINVER
+# define WINVER 0x0500
+#endif
+#ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0500
+#endif
+
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN