From f309ad61684c07c2c74db38fe072a22d7cc0e332 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 27 Oct 2024 02:13:47 -0400 Subject: [PATCH] Remove old Windows version macros and set _WIN32_WINNT+WINVER from setup.py --- Pythonwin/stdafx.h | 6 -- com/TestSources/PyCOMTest/preconn.h | 1 - com/win32com/src/include/stdafx.h | 1 - setup.py | 25 +++-- win32/Lib/win32con.py | 6 -- win32/src/PyACL.cpp | 13 +-- win32/src/PythonService.cpp | 5 - win32/src/_winxptheme.i | 4 - win32/src/win32apimodule.cpp | 6 -- win32/src/win32consolemodule.cpp | 6 -- win32/src/win32credmodule.cpp | 1 - win32/src/win32crypt/win32cryptmodule.cpp | 1 - win32/src/win32file.i | 5 - win32/src/win32gui.i | 4 - win32/src/win32job.i | 4 - win32/src/win32net/win32net.h | 3 - win32/src/win32net/win32netmisc.cpp | 4 - win32/src/win32net/win32netmodule.cpp | 11 -- win32/src/win32rasmodule.cpp | 8 -- win32/src/win32security.i | 121 +++++++++------------- win32/src/win32tsmodule.cpp | 1 - 21 files changed, 67 insertions(+), 169 deletions(-) diff --git a/Pythonwin/stdafx.h b/Pythonwin/stdafx.h index b8d9811e0..cd558624a 100644 --- a/Pythonwin/stdafx.h +++ b/Pythonwin/stdafx.h @@ -5,12 +5,6 @@ #define WIN32_LEAN_AND_MEAN -#ifndef WINVER -// we don't need this, but vs2009 makes noise without it set to something - -// and this is what we currently use... -#define WINVER 0x0600 -#endif - #define _USING_V110_SDK71_ // MFC support for mbcs is going away, but no need for us to constantly be told... #define NO_WARN_MBCS_MFC_DEPRECATION diff --git a/com/TestSources/PyCOMTest/preconn.h b/com/TestSources/PyCOMTest/preconn.h index 338d58dbf..8db478163 100644 --- a/com/TestSources/PyCOMTest/preconn.h +++ b/com/TestSources/PyCOMTest/preconn.h @@ -2,7 +2,6 @@ // or project specific include files that are used frequently, // but are changed infrequently -#define _WIN32_WINNT 0x0403 #define _WIN32_DCOM #include diff --git a/com/win32com/src/include/stdafx.h b/com/win32com/src/include/stdafx.h index 8b8b51337..d0d705076 100644 --- a/com/win32com/src/include/stdafx.h +++ b/com/win32com/src/include/stdafx.h @@ -7,7 +7,6 @@ // so we don't lose all the constants etc that come with DCOM // #define _WIN32_DCOM -#define _WIN32_WINNT 0x0501 // we use some of these features. // objidl.h checks for this to define IContext and IEnumContextProps #define USE_COM_CONTEXT_DEF diff --git a/setup.py b/setup.py index e72edf0ad..01a87d3b9 100644 --- a/setup.py +++ b/setup.py @@ -116,17 +116,28 @@ def __init__( if export_symbol_file: extra_link_args.append("/DEF:" + export_symbol_file) + self.windows_h_version = 0x600 # Vista + if windows_h_version: + self.windows_h_version = max(self.windows_h_version, windows_h_version) + # Some of our swigged files behave differently in distutils vs # MSVC based builds. Always define DISTUTILS_BUILD so they can tell. define_macros = define_macros or [] - define_macros.append(("DISTUTILS_BUILD", None)) - define_macros.append(("_CRT_SECURE_NO_WARNINGS", None)) - # CRYPT_DECRYPT_MESSAGE_PARA.dwflags is in an ifdef for some unknown reason - # See github PR #1444 for more details... - define_macros.append(("CRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS", None)) + define_macros.extend( + ( + ("DISTUTILS_BUILD", None), + ("_CRT_SECURE_NO_WARNINGS", None), + # CRYPT_DECRYPT_MESSAGE_PARA.dwflags is in an ifdef for some unknown reason + # See github PR #1444 for more details... + ("CRYPT_DECRYPT_MESSAGE_PARA_HAS_EXTRA_FIELDS", None), + # Minimum Windows version supported + # https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt + ("_WIN32_WINNT", hex(self.windows_h_version)), + ("WINVER", hex(self.windows_h_version)), + ) + ) self.pch_header = pch_header self.extra_swig_commands = extra_swig_commands or [] - self.windows_h_version = windows_h_version self.optional_headers = optional_headers self.is_regular_dll = is_regular_dll self.base_address = base_address @@ -926,7 +937,7 @@ class my_compiler(MSVCCompiler): # worse! This can probably go away once we kill the VS project files # though, as we can just specify the lowercase name in the module def. _cpp_extensions = MSVCCompiler._cpp_extensions + [".CPP"] - src_extensions = MSVCCompiler.src_extensions + [".CPP"] + src_extensions = MSVCCompiler.src_extensions + [".CPP"] # type: ignore[operator] # TODO: Fix in typeshed def link( self, diff --git a/win32/Lib/win32con.py b/win32/Lib/win32con.py index 5e798ee29..753cad21d 100644 --- a/win32/Lib/win32con.py +++ b/win32/Lib/win32con.py @@ -4247,10 +4247,8 @@ def GetBValue(rgb): # winuser.h line 4249 KEYEVENTF_EXTENDEDKEY = 1 KEYEVENTF_KEYUP = 2 -# if(_WIN32_WINNT >= 0x0500) KEYEVENTF_UNICODE = 4 KEYEVENTF_SCANCODE = 8 -# endif /* _WIN32_WINNT >= 0x0500 */ MOUSEEVENTF_MOVE = 1 MOUSEEVENTF_LEFTDOWN = 2 MOUSEEVENTF_LEFTUP = 4 @@ -4261,12 +4259,8 @@ def GetBValue(rgb): MOUSEEVENTF_XDOWN = 128 MOUSEEVENTF_XUP = 256 MOUSEEVENTF_WHEEL = 2048 -# if (_WIN32_WINNT >= 0x0600) MOUSEEVENTF_HWHEEL = 4096 -# endif -# if(WINVER >= 0x0600) MOUSEEVENTF_MOVE_NOCOALESCE = 8192 -# endif /* WINVER >= 0x0600 */ MOUSEEVENTF_VIRTUALDESK = 16384 MOUSEEVENTF_ABSOLUTE = 32768 INPUT_MOUSE = 0 diff --git a/win32/src/PyACL.cpp b/win32/src/PyACL.cpp index fb2ec3530..693f4f8f6 100644 --- a/win32/src/PyACL.cpp +++ b/win32/src/PyACL.cpp @@ -263,7 +263,6 @@ BOOL PyWinObject_AsTRUSTEE(PyObject *obtrustee, TRUSTEE_W *ptrustee) } break; } -#if WINVER >= 0x0501 case TRUSTEE_IS_OBJECTS_AND_SID: case TRUSTEE_IS_OBJECTS_AND_NAME: { // still need to add TRUSTEE_IS_OBJECTS_AND_SID and TRUSTEE_IS_OBJECTS_AND_NAME @@ -271,11 +270,6 @@ BOOL PyWinObject_AsTRUSTEE(PyObject *obtrustee, TRUSTEE_W *ptrustee) bsuccess = FALSE; break; } -#else -#pragma message( \ - "NOTE: You are building with an early Platform SDK - not all" \ - "TRUSTEE operations on SIDs will be supported") -#endif // WINVER default: { PyErr_SetString(PyExc_ValueError, "Invalid value for TrusteeForm"); bsuccess = FALSE; @@ -298,13 +292,11 @@ PyObject *PyWinObject_FromTRUSTEE(TRUSTEE_W *ptrustee) obIdentifier = PyWinObject_FromWCHAR(ptrustee->ptstrName); break; } -#if WINVER >= 0x0501 case TRUSTEE_IS_OBJECTS_AND_SID: case TRUSTEE_IS_OBJECTS_AND_NAME: { PyErr_SetString(PyExc_NotImplementedError, "TrusteeForm not yet supported"); return FALSE; } -#endif default: { PyErr_SetString(PyExc_ValueError, "Invalid value for TrusteeForm"); return FALSE; @@ -964,10 +956,7 @@ PyObject *PyACL::GetAce(PyObject *self, PyObject *args) case ACCESS_ALLOWED_ACE_TYPE: case ACCESS_DENIED_ACE_TYPE: case SYSTEM_AUDIT_ACE_TYPE: -#ifdef _WIN32_WINNT_LONGHORN - case SYSTEM_MANDATORY_LABEL_ACE_TYPE: -#endif - { + case SYSTEM_MANDATORY_LABEL_ACE_TYPE: { ACCESS_ALLOWED_ACE *pAce = (ACCESS_ALLOWED_ACE *)p; return Py_BuildValue("(ll)lN", pAceHeader->AceType, pAceHeader->AceFlags, pAce->Mask, PyWinObject_FromSID((PSID)(&pAce->SidStart))); diff --git a/win32/src/PythonService.cpp b/win32/src/PythonService.cpp index c6d8e1364..27b45bdce 100644 --- a/win32/src/PythonService.cpp +++ b/win32/src/PythonService.cpp @@ -70,11 +70,6 @@ static void CheckRegisterEventSourceFile(); // increased to MAX_SERVICES DWORD g_maxServices = 1; -#if (WINVER < 0x0500) -// SDK probably doesn't define LPHANDLER_FUNCTION_EX, so do it ourselves. -typedef DWORD(WINAPI *LPHANDLER_FUNCTION_EX)(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext); -#endif - typedef SERVICE_STATUS_HANDLE(WINAPI *REGSVC_EX_FN)(LPCTSTR lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, LPVOID lpContext); diff --git a/win32/src/_winxptheme.i b/win32/src/_winxptheme.i index 3ef07bbb9..af79c4e6a 100644 --- a/win32/src/_winxptheme.i +++ b/win32/src/_winxptheme.i @@ -15,15 +15,11 @@ %include "pywintypes.i" %{ -#define _WIN32_WINNT 0x0501 - #undef PyHANDLE #include "pywinobjects.h" #include "windows.h" #include "Uxtheme.h" #include "commctrl.h" - - %} // @object PyHTHEME|A object wrapping a HTHEME. diff --git a/win32/src/win32apimodule.cpp b/win32/src/win32apimodule.cpp index 45d8d532e..9cbfe26c6 100644 --- a/win32/src/win32apimodule.cpp +++ b/win32/src/win32apimodule.cpp @@ -29,12 +29,6 @@ generates Windows .hlp files. #define PyW32_END_ALLOW_THREADS PyEval_RestoreThread(_save); #define PyW32_BLOCK_THREADS Py_BLOCK_THREADS -#if (_WIN32_WINNT < 0x0500) -// We don't get COMPUTER_NAME_FORMAT unless we bump this. -// As we use it dynamically, we don't *need* to bump it. -typedef int COMPUTER_NAME_FORMAT; -#endif - // from kernel32.dll typedef BOOL(WINAPI *GetComputerNameExfunc)(COMPUTER_NAME_FORMAT, LPWSTR, PULONG); static GetComputerNameExfunc pfnGetComputerNameEx = NULL; diff --git a/win32/src/win32consolemodule.cpp b/win32/src/win32consolemodule.cpp index 48e84d727..56f61e431 100644 --- a/win32/src/win32consolemodule.cpp +++ b/win32/src/win32consolemodule.cpp @@ -1,5 +1,4 @@ // @doc -#define _WIN32_WINNT 0x501 #include "PyWinTypes.h" #include "PyWinObjects.h" #include "structmember.h" @@ -941,11 +940,6 @@ PyObject *PyConsoleScreenBuffer::PySetConsoleMode(PyObject *self, PyObject *args return Py_None; } -#ifndef _WIN32_WINNT_LONGHORN -// 'reserved' ReadConsole param is defined as a PCONSOLE_READCONSOLE_CONTROL -// in Vista's SDK. If no such def exists, assume it's still 'void *' -#define PCONSOLE_READCONSOLE_CONTROL void * -#endif // @pymethod |PyConsoleScreenBuffer|ReadConsole|Reads characters from the console input buffer PyObject *PyConsoleScreenBuffer::PyReadConsole(PyObject *self, PyObject *args, PyObject *kwargs) { diff --git a/win32/src/win32credmodule.cpp b/win32/src/win32credmodule.cpp index 2825c2213..f992382fc 100644 --- a/win32/src/win32credmodule.cpp +++ b/win32/src/win32credmodule.cpp @@ -1,5 +1,4 @@ // @doc -#define _WIN32_WINNT 0x501 // Credentials functions only available on WinXP #include "PyWinTypes.h" #include "PyWinObjects.h" #include "WinCred.h" diff --git a/win32/src/win32crypt/win32cryptmodule.cpp b/win32/src/win32crypt/win32cryptmodule.cpp index 3f801fc12..102422fb1 100644 --- a/win32/src/win32crypt/win32cryptmodule.cpp +++ b/win32/src/win32crypt/win32cryptmodule.cpp @@ -1,5 +1,4 @@ // @doc -#define _WIN32_WINNT 0x502 #include "win32crypt.h" // @pymethod bytes|win32crypt|CryptProtectData|Encrypts data using a session key derived from current user's logon diff --git a/win32/src/win32file.i b/win32/src/win32file.i index 716b76262..7547173dc 100644 --- a/win32/src/win32file.i +++ b/win32/src/win32file.i @@ -22,11 +22,6 @@ // RemoveDirectory / RemoveDirectoryTransacted %{ -//#define FAR -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0600 -#endif - // We use the deprecated API #define _WINSOCK_DEPRECATED_NO_WARNINGS diff --git a/win32/src/win32gui.i b/win32/src/win32gui.i index fa0906b7e..99236090f 100644 --- a/win32/src/win32gui.i +++ b/win32/src/win32gui.i @@ -3,10 +3,6 @@ %module win32gui // A module which provides an interface to the native win32 GUI API. -%{ -#define _WIN32_WINNT 0x0501 - -%} %include "typemaps.i" %include "pywintypes.i" diff --git a/win32/src/win32job.i b/win32/src/win32job.i index ccf0faf38..80f3cdf8b 100644 --- a/win32/src/win32job.i +++ b/win32/src/win32job.i @@ -4,10 +4,6 @@ // available in Windows 2000 and later. %{ -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x500 -#endif - #include "PyWinTypes.h" #define CHECK_PFN(fname)if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); diff --git a/win32/src/win32net/win32net.h b/win32/src/win32net/win32net.h index a9ffd635d..69a2c51e4 100644 --- a/win32/src/win32net/win32net.h +++ b/win32/src/win32net/win32net.h @@ -60,7 +60,6 @@ PyObject *PyDoDel(PyObject *self, PyObject *args, PFNDEL pfn, char *fnname); PyObject *PyDoGroupDelMembers(PyObject *self, PyObject *args); -#if WINVER >= 0x0500 typedef NET_API_STATUS(NET_API_FUNCTION *NetValidateNamefunc)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, NETSETUP_NAME_TYPE); extern "C" NetValidateNamefunc pfnNetValidateName; @@ -73,5 +72,3 @@ extern "C" NetValidatePasswordPolicyfunc pfnNetValidatePasswordPolicy; typedef NET_API_STATUS(NET_API_FUNCTION *NetValidatePasswordPolicyFreefunc)(LPVOID *); extern "C" NetValidatePasswordPolicyFreefunc pfnNetValidatePasswordPolicyFree; - -#endif // WINVER diff --git a/win32/src/win32net/win32netmisc.cpp b/win32/src/win32net/win32netmisc.cpp index 025665e36..aa1b5da94 100644 --- a/win32/src/win32net/win32netmisc.cpp +++ b/win32/src/win32net/win32netmisc.cpp @@ -1353,8 +1353,6 @@ PyObject *PyNetServerComputerNameDel(PyObject *self, PyObject *args) return ret; } -#if WINVER >= 0x0500 - extern "C" NetValidateNamefunc pfnNetValidateName = NULL; // @pymethod |win32net|NetValidateName|Checks that domain/machine/workgroup name is valid for given context // @rdesc Returns none if valid, exception if not @@ -1652,5 +1650,3 @@ PyObject *PyNetValidatePasswordPolicy(PyObject *self, PyObject *args) (*pfnNetValidatePasswordPolicyFree)((void **)&out_arg); return ret; } - -#endif // WINVER diff --git a/win32/src/win32net/win32netmodule.cpp b/win32/src/win32net/win32netmodule.cpp index e4b7ba108..39bfd1dc7 100644 --- a/win32/src/win32net/win32netmodule.cpp +++ b/win32/src/win32net/win32netmodule.cpp @@ -32,9 +32,7 @@ conversion is required. #include "assert.h" -#if WINVER >= 0x0500 NetGetJoinInformationfunc pfnNetGetJoinInformation = NULL; -#endif /*****************************************************************************/ /* error helpers */ @@ -946,8 +944,6 @@ PyObject *PyNetGetAnyDCName(PyObject *self, PyObject *args) return ret; } -#if WINVER >= 0x0500 - // @pymethod , int|win32net|NetGetJoinInformation|Retrieves join status information for the specified // computer. static PyObject *PyNetGetJoinInformation(PyObject *self, PyObject *args) @@ -979,7 +975,6 @@ static PyObject *PyNetGetJoinInformation(PyObject *self, PyObject *args) NetApiBufferFree(result); return ret; } -#endif // WINVER /************************************************************************************************************* ** @@ -1059,10 +1054,8 @@ extern PyObject *PyNetServerComputerNameDel(PyObject *self, PyObject *args); /* List of functions exported by this module */ // @module win32net|A module encapsulating the Windows Network API. static struct PyMethodDef win32net_functions[] = { -#if WINVER >= 0x0500 {"NetGetJoinInformation", PyNetGetJoinInformation, 1}, // @pymeth NetGetJoinInformation|Retrieves join status information for the specified computer. -#endif {"NetGroupGetInfo", PyNetGroupGetInfo, 1}, // @pymeth NetGroupGetInfo|Retrieves information about a particular group on a server. {"NetGroupGetUsers", PyNetGroupGetUsers, 1}, // @pymeth NetGroupGetUsers|Enumerates the users in a group. @@ -1180,13 +1173,11 @@ static struct PyMethodDef win32net_functions[] = { {"NetServerComputerNameDel", PyNetServerComputerNameDel, 1}, // @pymeth NetServerComputerNameDel|Deletes an emulated computer name created by -#if WINVER >= 0x0500 {"NetValidateName", PyNetValidateName, 1}, // @pymeth NetValidateName|Verify that computer/domain name is valid for given context {"NetValidatePasswordPolicy", PyNetValidatePasswordPolicy, 1}, // @pymeth NetValidatePasswordPolicy|Allows an application to check password compliance against an // application-provided account database. -#endif {NULL, NULL}}; static void AddConstant(PyObject *dict, char *name, long val) @@ -1212,7 +1203,6 @@ PYWIN_MODULE_INIT_FUNC(win32net) AddConstant(dict, "USE_LOTS_OF_FORCE", USE_LOTS_OF_FORCE); HMODULE hmodule = PyWin_GetOrLoadLibraryHandle("netapi32.dll"); -#if WINVER >= 0x0500 if (hmodule != NULL) { pfnNetValidateName = (NetValidateNamefunc)GetProcAddress(hmodule, "NetValidateName"); pfnNetGetJoinInformation = (NetGetJoinInformationfunc)GetProcAddress(hmodule, "NetGetJoinInformation"); @@ -1221,6 +1211,5 @@ PYWIN_MODULE_INIT_FUNC(win32net) pfnNetValidatePasswordPolicyFree = (NetValidatePasswordPolicyFreefunc)GetProcAddress(hmodule, "NetValidatePasswordPolicyFree"); } -#endif PYWIN_MODULE_INIT_RETURN_SUCCESS; } diff --git a/win32/src/win32rasmodule.cpp b/win32/src/win32rasmodule.cpp index 3ed8c33fe..2213d20db 100644 --- a/win32/src/win32rasmodule.cpp +++ b/win32/src/win32rasmodule.cpp @@ -11,10 +11,6 @@ generates Windows .hlp files. ******************************************************************/ -#ifndef WINVER -#define WINVER 0x500 -#endif - #include "pywintypes.h" #include "ras.h" #include "raserror.h" @@ -285,7 +281,6 @@ PyObject *PyRASDIALEXTENSIONS::getattro(PyObject *self, PyObject *obname) // @prop integer|reserved| if (strcmp(name, "reserved") == 0) return PyWinObject_FromULONG_PTR(py->m_ext.reserved); -#if (WINVER >= 0x500) // @prop integer|reserved1| if (strcmp(name, "reserved1") == 0) return PyWinObject_FromULONG_PTR(py->m_ext.reserved1); @@ -294,7 +289,6 @@ PyObject *PyRASDIALEXTENSIONS::getattro(PyObject *self, PyObject *obname) Py_INCREF(py->m_pyeap); return py->m_pyeap; } -#endif return PyObject_GenericGetAttr(self, obname); } @@ -329,7 +323,6 @@ int PyRASDIALEXTENSIONS::setattro(PyObject *self, PyObject *obname, PyObject *va py->m_ext.reserved = v; return 0; } -#if (WINVER >= 0x500) if (strcmp(name, "reserved1") == 0) { long v = PyLong_AsLong(val); if (v == -1 && PyErr_Occurred()) @@ -348,7 +341,6 @@ int PyRASDIALEXTENSIONS::setattro(PyObject *self, PyObject *obname, PyObject *va Py_INCREF(val); return 0; } -#endif return PyObject_GenericSetAttr(self, obname, val); } diff --git a/win32/src/win32security.i b/win32/src/win32security.i index c614d3081..c9c4aff70 100644 --- a/win32/src/win32security.i +++ b/win32/src/win32security.i @@ -4,10 +4,6 @@ %module win32security // An interface to the win32 security API's -%{ -#define _WIN32_WINNT 0x0600 // Vista! -%} - %include "typemaps.i" %include "pywin32.i" @@ -613,14 +609,11 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) ADD_UNICODE_CONSTANT(SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME); ADD_UNICODE_CONSTANT(SE_IMPERSONATE_NAME); ADD_UNICODE_CONSTANT(SE_CREATE_GLOBAL_NAME); - // Requires Vista SDK - #ifdef _WIN32_WINNT_LONGHORN ADD_UNICODE_CONSTANT(SE_TRUSTED_CREDMAN_ACCESS_NAME); ADD_UNICODE_CONSTANT(SE_RELABEL_NAME); ADD_UNICODE_CONSTANT(SE_INC_WORKING_SET_NAME); ADD_UNICODE_CONSTANT(SE_TIME_ZONE_NAME); ADD_UNICODE_CONSTANT(SE_CREATE_SYMBOLIC_LINK_NAME); - #endif PyDict_SetItemString(d,"MSV1_0_PACKAGE_NAME",PyBytes_FromString(MSV1_0_PACKAGE_NAME)); PyDict_SetItemString(d,"MICROSOFT_KERBEROS_NAME_A",PyBytes_FromString(MICROSOFT_KERBEROS_NAME_A)); @@ -643,42 +636,37 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) PyModule_AddIntConstant(m,"TokenSandBoxInert", TokenSandBoxInert); PyModule_AddIntConstant(m,"TokenAuditPolicy", TokenAuditPolicy); PyModule_AddIntConstant(m,"TokenOrigin", TokenOrigin); - // ??? These are defined in Vista platform SDK, but they aren't conditionally defined. - // This symbol is defined in the Vista SDK, but not in earlier ones. - // There's probably a better way to determine which SDK is in use. ??? - #ifdef _WIN32_WINNT_LONGHORN PyModule_AddIntConstant(m,"TokenElevationType", TokenElevationType); - PyModule_AddIntConstant(m,"TokenLinkedToken", TokenLinkedToken); - PyModule_AddIntConstant(m,"TokenElevation", TokenElevation); - PyModule_AddIntConstant(m,"TokenHasRestrictions", TokenHasRestrictions); - PyModule_AddIntConstant(m,"TokenAccessInformation", TokenAccessInformation); - PyModule_AddIntConstant(m,"TokenVirtualizationAllowed", TokenVirtualizationAllowed); - PyModule_AddIntConstant(m,"TokenVirtualizationEnabled", TokenVirtualizationEnabled); - PyModule_AddIntConstant(m,"TokenIntegrityLevel", TokenIntegrityLevel); - PyModule_AddIntConstant(m,"TokenUIAccess", TokenUIAccess); - PyModule_AddIntConstant(m,"TokenMandatoryPolicy", TokenMandatoryPolicy); - PyModule_AddIntConstant(m,"TokenLogonSid", TokenLogonSid); - - // TOKEN_ELEVATION_TYPE enum - PyModule_AddIntConstant(m,"TokenElevationTypeDefault",TokenElevationTypeDefault); - PyModule_AddIntConstant(m,"TokenElevationTypeFull",TokenElevationTypeFull); - PyModule_AddIntConstant(m,"TokenElevationTypeLimited",TokenElevationTypeLimited); - - // TOKEN_MANDATORY_POLICY enum - PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_OFF",TOKEN_MANDATORY_POLICY_OFF); - PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_NO_WRITE_UP",TOKEN_MANDATORY_POLICY_NO_WRITE_UP); - PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN",TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN); - PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_VALID_MASK",TOKEN_MANDATORY_POLICY_VALID_MASK); - - PyModule_AddIntConstant(m,"SE_GROUP_INTEGRITY", SE_GROUP_INTEGRITY); - PyModule_AddIntConstant(m,"SE_GROUP_INTEGRITY_ENABLED", SE_GROUP_INTEGRITY_ENABLED); - - // Access mask used with integrity level ACE's (SYSTEM_MANDATORY_LABEL_ACE_TYPE) - PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_WRITE_UP", SYSTEM_MANDATORY_LABEL_NO_WRITE_UP); - PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_READ_UP", SYSTEM_MANDATORY_LABEL_NO_READ_UP); - PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP", SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP); - PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_VALID_MASK", SYSTEM_MANDATORY_LABEL_VALID_MASK); - #endif + PyModule_AddIntConstant(m,"TokenLinkedToken", TokenLinkedToken); + PyModule_AddIntConstant(m,"TokenElevation", TokenElevation); + PyModule_AddIntConstant(m,"TokenHasRestrictions", TokenHasRestrictions); + PyModule_AddIntConstant(m,"TokenAccessInformation", TokenAccessInformation); + PyModule_AddIntConstant(m,"TokenVirtualizationAllowed", TokenVirtualizationAllowed); + PyModule_AddIntConstant(m,"TokenVirtualizationEnabled", TokenVirtualizationEnabled); + PyModule_AddIntConstant(m,"TokenIntegrityLevel", TokenIntegrityLevel); + PyModule_AddIntConstant(m,"TokenUIAccess", TokenUIAccess); + PyModule_AddIntConstant(m,"TokenMandatoryPolicy", TokenMandatoryPolicy); + PyModule_AddIntConstant(m,"TokenLogonSid", TokenLogonSid); + + // TOKEN_ELEVATION_TYPE enum + PyModule_AddIntConstant(m,"TokenElevationTypeDefault",TokenElevationTypeDefault); + PyModule_AddIntConstant(m,"TokenElevationTypeFull",TokenElevationTypeFull); + PyModule_AddIntConstant(m,"TokenElevationTypeLimited",TokenElevationTypeLimited); + + // TOKEN_MANDATORY_POLICY enum + PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_OFF",TOKEN_MANDATORY_POLICY_OFF); + PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_NO_WRITE_UP",TOKEN_MANDATORY_POLICY_NO_WRITE_UP); + PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN",TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN); + PyModule_AddIntConstant(m,"TOKEN_MANDATORY_POLICY_VALID_MASK",TOKEN_MANDATORY_POLICY_VALID_MASK); + + PyModule_AddIntConstant(m,"SE_GROUP_INTEGRITY", SE_GROUP_INTEGRITY); + PyModule_AddIntConstant(m,"SE_GROUP_INTEGRITY_ENABLED", SE_GROUP_INTEGRITY_ENABLED); + + // Access mask used with integrity level ACE's (SYSTEM_MANDATORY_LABEL_ACE_TYPE) + PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_WRITE_UP", SYSTEM_MANDATORY_LABEL_NO_WRITE_UP); + PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_READ_UP", SYSTEM_MANDATORY_LABEL_NO_READ_UP); + PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP", SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP); + PyModule_AddIntConstant(m,"SYSTEM_MANDATORY_LABEL_VALID_MASK", SYSTEM_MANDATORY_LABEL_VALID_MASK); // WELL_KNOWN_SID_TYPE used with CreateWellKnownSid PyModule_AddIntConstant(m,"WinNullSid", WinNullSid); @@ -740,27 +728,24 @@ void PyWinObject_FreeTOKEN_PRIVILEGES(TOKEN_PRIVILEGES *pPriv) PyModule_AddIntConstant(m,"WinBuiltinIncomingForestTrustBuildersSid", WinBuiltinIncomingForestTrustBuildersSid); PyModule_AddIntConstant(m,"WinBuiltinPerfMonitoringUsersSid", WinBuiltinPerfMonitoringUsersSid); PyModule_AddIntConstant(m,"WinBuiltinPerfLoggingUsersSid", WinBuiltinPerfLoggingUsersSid); - // These require recent SDK - #ifdef _WIN32_WINNT_LONGHORN - PyModule_AddIntConstant(m,"WinBuiltinAuthorizationAccessSid", WinBuiltinAuthorizationAccessSid); - PyModule_AddIntConstant(m,"WinBuiltinTerminalServerLicenseServersSid", WinBuiltinTerminalServerLicenseServersSid); - PyModule_AddIntConstant(m,"WinBuiltinDCOMUsersSid", WinBuiltinDCOMUsersSid); - PyModule_AddIntConstant(m,"WinBuiltinIUsersSid", WinBuiltinIUsersSid); - PyModule_AddIntConstant(m,"WinIUserSid", WinIUserSid); - PyModule_AddIntConstant(m,"WinBuiltinCryptoOperatorsSid", WinBuiltinCryptoOperatorsSid); - PyModule_AddIntConstant(m,"WinUntrustedLabelSid", WinUntrustedLabelSid); - PyModule_AddIntConstant(m,"WinLowLabelSid", WinLowLabelSid); - PyModule_AddIntConstant(m,"WinMediumLabelSid", WinMediumLabelSid); - PyModule_AddIntConstant(m,"WinHighLabelSid", WinHighLabelSid); - PyModule_AddIntConstant(m,"WinSystemLabelSid", WinSystemLabelSid); - PyModule_AddIntConstant(m,"WinWriteRestrictedCodeSid", WinWriteRestrictedCodeSid); - PyModule_AddIntConstant(m,"WinCreatorOwnerRightsSid", WinCreatorOwnerRightsSid); - PyModule_AddIntConstant(m,"WinCacheablePrincipalsGroupSid", WinCacheablePrincipalsGroupSid); - PyModule_AddIntConstant(m,"WinNonCacheablePrincipalsGroupSid", WinNonCacheablePrincipalsGroupSid); - PyModule_AddIntConstant(m,"WinEnterpriseReadonlyControllersSid", WinEnterpriseReadonlyControllersSid); - PyModule_AddIntConstant(m,"WinAccountReadonlyControllersSid", WinAccountReadonlyControllersSid); - PyModule_AddIntConstant(m,"WinBuiltinEventLogReadersGroup", WinBuiltinEventLogReadersGroup); - #endif + PyModule_AddIntConstant(m,"WinBuiltinAuthorizationAccessSid", WinBuiltinAuthorizationAccessSid); + PyModule_AddIntConstant(m,"WinBuiltinTerminalServerLicenseServersSid", WinBuiltinTerminalServerLicenseServersSid); + PyModule_AddIntConstant(m,"WinBuiltinDCOMUsersSid", WinBuiltinDCOMUsersSid); + PyModule_AddIntConstant(m,"WinBuiltinIUsersSid", WinBuiltinIUsersSid); + PyModule_AddIntConstant(m,"WinIUserSid", WinIUserSid); + PyModule_AddIntConstant(m,"WinBuiltinCryptoOperatorsSid", WinBuiltinCryptoOperatorsSid); + PyModule_AddIntConstant(m,"WinUntrustedLabelSid", WinUntrustedLabelSid); + PyModule_AddIntConstant(m,"WinLowLabelSid", WinLowLabelSid); + PyModule_AddIntConstant(m,"WinMediumLabelSid", WinMediumLabelSid); + PyModule_AddIntConstant(m,"WinHighLabelSid", WinHighLabelSid); + PyModule_AddIntConstant(m,"WinSystemLabelSid", WinSystemLabelSid); + PyModule_AddIntConstant(m,"WinWriteRestrictedCodeSid", WinWriteRestrictedCodeSid); + PyModule_AddIntConstant(m,"WinCreatorOwnerRightsSid", WinCreatorOwnerRightsSid); + PyModule_AddIntConstant(m,"WinCacheablePrincipalsGroupSid", WinCacheablePrincipalsGroupSid); + PyModule_AddIntConstant(m,"WinNonCacheablePrincipalsGroupSid", WinNonCacheablePrincipalsGroupSid); + PyModule_AddIntConstant(m,"WinEnterpriseReadonlyControllersSid", WinEnterpriseReadonlyControllersSid); + PyModule_AddIntConstant(m,"WinAccountReadonlyControllersSid", WinAccountReadonlyControllersSid); + PyModule_AddIntConstant(m,"WinBuiltinEventLogReadersGroup", WinBuiltinEventLogReadersGroup); advapi32_dll=loadmodule(_T("Advapi32.dll")); secur32_dll =loadmodule(_T("Secur32.dll")); @@ -1871,13 +1856,11 @@ static PyObject *PyGetTokenInformation(PyObject *self, PyObject *args) case TokenSandBoxInert: // @flag TokenSandBoxInert|Boolean case TokenType: // @flag TokenType|Value from TOKEN_TYPE enum (TokenPrimary,TokenImpersonation) case TokenImpersonationLevel: // @flag TokenImpersonationLevel|Value from SECURITY_IMPERSONATION_LEVEL enum - #ifdef _WIN32_WINNT_LONGHORN // Vista info types related to UAC case TokenVirtualizationEnabled: // @flag TokenVirtualizationEnabled|Boolean case TokenVirtualizationAllowed: // @flag TokenVirtualizationAllowed|Boolean case TokenHasRestrictions: // @flag TokenHasRestrictions|Boolean case TokenElevationType: // @flag TokenElevationType|int - TokenElevation* value indicating what type of token is linked to case TokenUIAccess: // @flag TokenUIAccess|Boolean - #endif bufSize = sizeof(DWORD); if (!GetTokenInformation(handle, typ, &dwordbuf, bufSize, &retLength)) return PyWin_SetAPIError("GetTokenInformation"); @@ -1981,9 +1964,6 @@ static PyObject *PyGetTokenInformation(PyObject *self, PyObject *args) ret = PyWinObject_FromLARGE_INTEGER(luid); break; } - - #ifdef _WIN32_WINNT_LONGHORN - // Vista-specific types require recent platform SDK case TokenLinkedToken: { // @flag TokenLinkedToken| - Returns handle to the access token to which token is linked TOKEN_LINKED_TOKEN *tlt=(TOKEN_LINKED_TOKEN *)buf; @@ -2033,7 +2013,6 @@ static PyObject *PyGetTokenInformation(PyObject *self, PyObject *args) SID_HASH_ENTRY Hash[SID_HASH_SIZE]; } SID_AND_ATTRIBUTES_HASH */ - #endif default: PyErr_Format(PyExc_NotImplementedError, "TokenInformationClass %d is not supported yet", typ); } @@ -2364,10 +2343,8 @@ static PyObject *PySetTokenInformation(PyObject *self, PyObject *args) break; } case TokenSessionId: // @flag TokenSessionId|Int - Terminal services session id - #ifdef _WIN32_WINNT_LONGHORN // Vista info types related to UAC case TokenVirtualizationEnabled: // @flag TokenVirtualizationEnabled|Boolean case TokenVirtualizationAllowed: // @flag TokenVirtualizationAllowed|Boolean - #endif bufsize = sizeof(DWORD); buf=malloc(bufsize); if (buf==NULL) @@ -2380,7 +2357,6 @@ static PyObject *PySetTokenInformation(PyObject *self, PyObject *args) goto done; } break; - #ifdef _WIN32_WINNT_LONGHORN case TokenIntegrityLevel: // @flag TokenIntegrityLevel| containing an integrity SID and SE_GROUP_INTEGRITY flag bufsize=sizeof(TOKEN_MANDATORY_LABEL); buf=malloc(bufsize); @@ -2402,7 +2378,6 @@ static PyObject *PySetTokenInformation(PyObject *self, PyObject *args) goto done; } break; - #endif default: PyErr_Format(PyExc_NotImplementedError, "TokenInformationClass %d is not yet supported", typ); goto done; diff --git a/win32/src/win32tsmodule.cpp b/win32/src/win32tsmodule.cpp index ac18c03dc..c57781ca8 100644 --- a/win32/src/win32tsmodule.cpp +++ b/win32/src/win32tsmodule.cpp @@ -1,5 +1,4 @@ // @doc -#define _WIN32_WINNT 0x501 #include "PyWinTypes.h" #include "PyWinObjects.h" #include "structmember.h"