[pywin32-checkins] /hgroot/pywin32/pywin32: 2 new changesets
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <pyw...@li...> - 2013-03-24 14:33:10
|
changeset e97376eb14b6 in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=e97376eb14b6 summary: win32com: changeset 554980ba3e5a in /hgroot/pywin32/pywin32 details: http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=554980ba3e5a summary: Added tag b218.3 for changeset e97376eb14b6 diffstat: .hgtags | 1 + com/win32com/src/PyComHelpers.cpp | 11 + com/win32com/src/PythonCOM.cpp | 343 ++++++-- com/win32com/src/Register.cpp | 21 +- com/win32com/src/extensions/PyICancelMethodCalls.cpp | 96 ++ com/win32com/src/extensions/PyIClientSecurity.cpp | 248 ++++++ com/win32com/src/extensions/PyIContext.cpp | 141 +++ com/win32com/src/extensions/PyIEnumContextProps.cpp | 159 ++++ com/win32com/src/extensions/PyIEnumSTATPROPSETSTG.cpp | 113 ++ com/win32com/src/extensions/PyIEnumSTATPROPSTG.cpp | 124 +++- com/win32com/src/extensions/PyIPropertySetStorage.cpp | 86 ++ com/win32com/src/extensions/PyIPropertyStorage.cpp | 364 ++++++++- com/win32com/src/extensions/PyIServerSecurity.cpp | 197 +++++ com/win32com/src/include/PyICancelMethodCalls.h | 41 + com/win32com/src/include/PyIClientSecurity.h | 60 + com/win32com/src/include/PyIContext.h | 23 + com/win32com/src/include/PyIEnumContextProps.h | 24 + com/win32com/src/include/PyIEnumSTATPROPSETSTG.h | 27 + com/win32com/src/include/PyIEnumSTATPROPSTG.h | 26 + com/win32com/src/include/PyIPropertySetStorage.h | 33 + com/win32com/src/include/PyIPropertyStorage.h | 64 + com/win32com/src/include/PyIServerSecurity.h | 55 + com/win32com/src/include/PythonCOM.h | 1 + com/win32com/src/include/stdafx.h | 5 +- com/win32comext/shell/demos/ITransferAdviseSink.py | 74 + com/win32comext/shell/shellcon.py | 84 ++ com/win32comext/shell/src/PyICurrentItem.cpp | 41 + com/win32comext/shell/src/PyICurrentItem.h | 36 + com/win32comext/shell/src/PyIDisplayItem.cpp | 42 + com/win32comext/shell/src/PyIDisplayItem.h | 36 + com/win32comext/shell/src/PyIEnumResources.cpp | 268 ++++++ com/win32comext/shell/src/PyIEnumResources.h | 49 + com/win32comext/shell/src/PyIIdentityName.cpp | 41 + com/win32comext/shell/src/PyIIdentityName.h | 36 + com/win32comext/shell/src/PyIRelatedItem.cpp | 108 ++ com/win32comext/shell/src/PyIRelatedItem.h | 41 + com/win32comext/shell/src/PyIShellItemResources.cpp | 433 +++++++++++ com/win32comext/shell/src/PyIShellItemResources.h | 82 ++ com/win32comext/shell/src/PyITransferAdviseSink.cpp | 427 ++++++++++ com/win32comext/shell/src/PyITransferAdviseSink.h | 76 + com/win32comext/shell/src/PyITransferDestination.cpp | 194 ++++ com/win32comext/shell/src/PyITransferDestination.h | 53 + com/win32comext/shell/src/PyITransferMediumItem.cpp | 41 + com/win32comext/shell/src/PyITransferMediumItem.h | 36 + com/win32comext/shell/src/PyITransferSource.cpp | 703 ++++++++++++++++++ com/win32comext/shell/src/PyITransferSource.h | 107 ++ com/win32comext/shell/src/shell.cpp | 56 +- com/win32comext/shell/src/shell_pch.h | 8 + setup.py | 17 +- 49 files changed, 5218 insertions(+), 134 deletions(-) diffs (truncated from 6068 to 300 lines): diff -r 4c7503da2658 -r 554980ba3e5a .hgtags --- a/.hgtags Wed Feb 06 09:37:53 2013 -0500 +++ b/.hgtags Sun Mar 24 10:10:32 2013 -0400 @@ -49,3 +49,4 @@ b7968cc5d12a148df3005979adb804ab79dd1d17 b218 b7968cc5d12a148df3005979adb804ab79dd1d17 b218 ed400a27739ff3ff7a850e69f574a1ad66de6c5e b218 +e97376eb14b6d95e79e01e1bf68ef8427bcbafdc b218.3 diff -r 4c7503da2658 -r 554980ba3e5a com/win32com/src/PyComHelpers.cpp --- a/com/win32com/src/PyComHelpers.cpp Wed Feb 06 09:37:53 2013 -0500 +++ b/com/win32com/src/PyComHelpers.cpp Sun Mar 24 10:10:32 2013 -0400 @@ -419,3 +419,14 @@ Py_XDECREF(obatime); return ret; } + +BOOL PyCom_PyObjectAsSTATPROPSETSTG(PyObject *obstat, STATPROPSETSTG *pstat) +{ + return PyArg_ParseTuple(obstat, "O&O&kO&O&O&:STATPROPSETSTG", + PyWinObject_AsIID, &pstat->fmtid, + PyWinObject_AsIID, &pstat->clsid, + &pstat->grfFlags, + PyWinObject_AsFILETIME, &pstat->mtime, + PyWinObject_AsFILETIME, &pstat->ctime, + PyWinObject_AsFILETIME, &pstat->atime); +} diff -r 4c7503da2658 -r 554980ba3e5a com/win32com/src/PythonCOM.cpp --- a/com/win32com/src/PythonCOM.cpp Wed Feb 06 09:37:53 2013 -0500 +++ b/com/win32com/src/PythonCOM.cpp Sun Mar 24 10:10:32 2013 -0400 @@ -11,12 +11,14 @@ #include "stdafx.h" #include <objbase.h> +#include <ComSvcs.h> #include "PythonCOM.h" #include "PythonCOMServer.h" #include "PyFactory.h" #include "PyRecord.h" #include "PyComTypeObjects.h" #include "OleAcc.h" // for ObjectFromLresult proto... +#include "IAccess.h" // for IAccessControl #include "pyerrors.h" // for PyErr_Warn in 2.5 and earlier... @@ -88,6 +90,11 @@ // Function pointers we load at runtime. #define CHECK_PFN(fname) if (pfn##fname==NULL) return PyCom_BuildPyException(E_NOTIMPL); +// Requires IE 5.5 or later +typedef HRESULT (STDAPICALLTYPE *CreateURLMonikerExfunc)(LPMONIKER,LPCWSTR,LPMONIKER *,DWORD); +static CreateURLMonikerExfunc pfnCreateURLMonikerEx = NULL; + +// Win2k or later typedef HRESULT (STDAPICALLTYPE *CoWaitForMultipleHandlesfunc)(DWORD dwFlags, DWORD dwTimeout, ULONG cHandles, @@ -95,13 +102,25 @@ LPDWORD lpdwindex ); static CoWaitForMultipleHandlesfunc pfnCoWaitForMultipleHandles = NULL; - -typedef HRESULT (STDAPICALLTYPE *CreateURLMonikerExfunc)(LPMONIKER,LPCWSTR,LPMONIKER *,DWORD); -static CreateURLMonikerExfunc pfnCreateURLMonikerEx = NULL; +typedef HRESULT (STDAPICALLTYPE *CoGetObjectContextfunc)(REFIID, void **); +static CoGetObjectContextfunc pfnCoGetObjectContext = NULL; +typedef HRESULT (STDAPICALLTYPE *CoGetCancelObjectfunc)(DWORD, REFIID, void **); +static CoGetCancelObjectfunc pfnCoGetCancelObject = NULL; +typedef HRESULT (STDAPICALLTYPE *CoSetCancelObjectfunc)(IUnknown *); +static CoSetCancelObjectfunc pfnCoSetCancelObject = NULL; // typedefs for the function pointers are in OleAcc.h +// WinXP or later LPFNOBJECTFROMLRESULT pfnObjectFromLresult = NULL; +// May not be available on Windows 95, although I'm not sure that's even a concern anymore +typedef HRESULT (STDAPICALLTYPE *CoCreateInstanceExfunc)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); +static CoCreateInstanceExfunc pfnCoCreateInstanceEx = NULL; +typedef HRESULT (STDAPICALLTYPE *CoInitializeSecurityfunc)(PSECURITY_DESCRIPTOR, LONG, SOLE_AUTHENTICATION_SERVICE*, + void *, DWORD, DWORD, void *, DWORD, void *); +static CoInitializeSecurityfunc pfnCoInitializeSecurity = NULL; + + BOOL PyCom_HasDCom() { #ifndef MS_WINCE @@ -139,7 +158,7 @@ if (!PyArg_ParseTuple(args, "OOiO:CoCreateInstance", &obCLSID, // @pyparm <o PyIID>|clsid||Class identifier (CLSID) of the object &obUnk, // @pyparm <o PyIUnknown>|unkOuter||The outer unknown, or None - &dwClsContext,// @pyparm int|context||The create context for the object + &dwClsContext,// @pyparm int|context||The create context for the object, combination of pythoncom.CLSCTX_* flags &obiid)) // @pyparm <o PyIID>|iid||The IID required from the object return NULL; if (!PyWinObject_AsIID(obCLSID, &clsid)) @@ -170,6 +189,7 @@ // @pymethod <o PyIUnknown>|pythoncom|CoCreateInstanceEx|Create a new instance of an OLE automation server possibly on a remote machine. static PyObject *pythoncom_CoCreateInstanceEx(PyObject *self, PyObject *args) { + CHECK_PFN(CoCreateInstanceEx); PyObject *obCLSID; PyObject *obUnk; PyObject *obCoServer; @@ -184,11 +204,10 @@ PyObject *result = NULL; ULONG numIIDs = 0; ULONG i; - Py_ssize_t py_numIIDs; if (!PyArg_ParseTuple(args, "OOiOO:CoCreateInstanceEx", &obCLSID, // @pyparm <o PyIID>|clsid||Class identifier (CLSID) of the object &obUnk, // @pyparm <o PyIUnknown>|unkOuter||The outer unknown, or None - &dwClsContext, // @pyparm int|context||The create context for the object + &dwClsContext, // @pyparm int|context||The create context for the object, combination of pythoncom.CLSCTX_* flags &obCoServer, // @pyparm (server, authino=None, reserved1=0,reserved2=0)|serverInfo||May be None, or describes the remote server to execute on. &obrgiids)) // @pyparm [<o PyIID>, ...]|iids||A list of IIDs required from the object return NULL; @@ -215,55 +234,30 @@ if (!PyCom_InterfaceFromPyInstanceOrObject(obUnk, IID_IUnknown, (void **)&punk, TRUE)) goto done; - if (!PySequence_Check(obrgiids)) { - PyErr_SetString(PyExc_TypeError, "IID's must be sequence of IID objects"); + if (!SeqToVector(obrgiids, &iids, &numIIDs, PyWinObject_AsIID)) goto done; - } - py_numIIDs = PySequence_Length(obrgiids); - if (py_numIIDs > ULONG_MAX){ - PyErr_Format(PyExc_ValueError, "%u is maximum number of IIDs", ULONG_MAX); - goto done; - } - numIIDs=(ULONG)py_numIIDs; - iids = new IID[numIIDs]; mqi = new MULTI_QI[numIIDs]; - if (iids==NULL || mqi==NULL) { + if (mqi==NULL) { PyErr_SetString(PyExc_MemoryError, "Allocating MULTIQI array"); goto done; } for (i=0;i<numIIDs;i++) { - PyObject *me = PySequence_GetItem(obrgiids, i); - if (me==NULL) goto done; - BOOL ok = PyWinObject_AsIID(me, iids+i); - Py_DECREF(me); - if (!ok) goto done; mqi[i].pIID = iids+i; mqi[i].pItf = NULL; mqi[i].hr = 0; } - // Jump hoops in case the platform doesnt have it. + { // scoping - HRESULT (STDAPICALLTYPE *mypfn)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *); - HMODULE hMod = GetModuleHandle(_T("ole32.dll")); - if (hMod==0) { - PyCom_BuildInternalPyException("Can not load ole32.dll"); - goto done; - } - FARPROC fp = GetProcAddress(hMod, "CoCreateInstanceEx"); - if (fp==NULL) { - PyCom_BuildPyException(E_NOTIMPL); - goto done; - } - mypfn = (HRESULT (STDAPICALLTYPE *)(REFCLSID, IUnknown *, DWORD, COSERVERINFO *, ULONG, MULTI_QI *))fp; PY_INTERFACE_PRECALL; - HRESULT hr = (*mypfn)(clsid, punk, dwClsContext, pServerInfo, numIIDs, mqi); + HRESULT hr = (*pfnCoCreateInstanceEx)(clsid, punk, dwClsContext, pServerInfo, numIIDs, mqi); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyCom_BuildPyException(hr); goto done; } - } // end scoping. + } // end scoping + result = PyTuple_New(numIIDs); if (result==NULL) goto done; for (i=0;i<numIIDs;i++) { @@ -289,7 +283,7 @@ PyWinObject_FreeWCHAR(serverInfo.pwszName); for (i=0;i<numIIDs;i++) PYCOM_RELEASE(mqi[i].pItf) - delete [] iids; + CoTaskMemFree(iids); delete [] mqi; return result; } @@ -300,29 +294,32 @@ // @pymethod |pythoncom|CoInitializeSecurity|Registers security and sets the default security values. static PyObject *pythoncom_CoInitializeSecurity(PyObject *self, PyObject *args) { + CHECK_PFN(CoInitializeSecurity); DWORD cAuthSvc; SOLE_AUTHENTICATION_SERVICE *pAS = NULL; DWORD dwAuthnLevel; DWORD dwImpLevel; DWORD dwCapabilities; - PSECURITY_DESCRIPTOR pSD, pSD_absolute=NULL; + PSECURITY_DESCRIPTOR pSD=NULL, pSD_absolute=NULL; + IID appid; + IAccessControl *pIAC = NULL; PyObject *obSD, *obAuthSvc, *obReserved1, *obReserved2, *obAuthInfo; if (!PyArg_ParseTuple(args, "OOOiiOiO:CoInitializeSecurity", - &obSD, // @pyparm <o PySECURITY_DESCRIPTOR>|sd||Security descriptor containing access permissions for process' objects, can be None - &obAuthSvc, // @pyparm object|authInfo||A value of None tells COM to choose which authentication services to use. An empty list means use no services. + &obSD, // @pyparm <o PySECURITY_DESCRIPTOR>|sd||Security descriptor containing access permissions for process' objects, can be None. + // <nl>If Capabilities contains EOAC_APPID, sd should be an AppId (guid), or None to use server executable. + // <nl>If Capabilities contains EOAC_ACCESS_CONTROL, sd parameter should be an IAccessControl interface. + &obAuthSvc, // @pyparm object|authSvc||A value of None tells COM to choose which authentication services to use. An empty list means use no services. &obReserved1,// @pyparm object|reserved1||Must be None &dwAuthnLevel, // @pyparm int|authnLevel||One of pythoncom.RPC_C_AUTHN_LEVEL_* values. The default authentication level for proxies. On the server side, COM will fail calls that arrive at a lower level. All calls to AddRef and Release are made at this level. &dwImpLevel, // @pyparm int|impLevel||One of pythoncom.RPC_C_IMP_LEVEL_* values. The default impersonation level for proxies. This value is not checked on the server side. AddRef and Release calls are made with this impersonation level so even security aware apps should set this carefully. Setting IUnknown security only affects calls to QueryInterface, not AddRef or Release. &obAuthInfo, // @pyparm object|authInfo||Must be None - &dwCapabilities, // @pyparm int|capabilities||Additional client and/or server-side capabilities. Any set of pythoncom.EOAC_* flags may be passed. Currently only EOAC_MUTUAL_AUTH, EOAC_SECURE_REFS, and EOAC_NONE are defined + &dwCapabilities, // @pyparm int|capabilities||Authentication capabilities, combination of pythoncom.EOAC_* flags. &obReserved2)) // @pyparm object|reserved2||Must be None return NULL; if (obReserved1 != Py_None || obReserved2 != Py_None || obAuthInfo != Py_None) { PyErr_SetString(PyExc_TypeError, "Not all of the 'None' arguments are None!"); return NULL; } - if (!PyWinObject_AsSECURITY_DESCRIPTOR(obSD, &pSD, /*BOOL bNoneOK = */TRUE)) - return NULL; if (obAuthSvc==Py_None) cAuthSvc = (DWORD)-1; @@ -332,22 +329,39 @@ PyErr_SetString(PyExc_TypeError, "obAuthSvc must be None or an empty sequence."); return NULL; } - HMODULE hMod = GetModuleHandle(_T("ole32.dll")); - if (hMod==0) return PyCom_BuildInternalPyException("Can not load ole32.dll"); - FARPROC fp = GetProcAddress(hMod, "CoInitializeSecurity"); - if (fp==NULL) return PyCom_BuildPyException(E_NOTIMPL); - typedef HRESULT (STDAPICALLTYPE *CoInitializeSecurityfunc) - (PSECURITY_DESCRIPTOR, LONG, SOLE_AUTHENTICATION_SERVICE*, void *, DWORD, DWORD, void *, DWORD, void *); - CoInitializeSecurityfunc mypfn=(CoInitializeSecurityfunc)fp; - // Security descriptor must be in absolute form - if (pSD!=NULL) - if (!_MakeAbsoluteSD(pSD, &pSD_absolute)) + // Depending on capabilities flags, first arg can be one of: + // AppId (or NULL to lookup server executable in APPID registry key) + // IAccessControl interface (cannot be NULL) + // Absolute security descriptor (or NULL to use a default SD) + if (dwCapabilities & EOAC_APPID){ + if (obSD != Py_None){ + if (!PyWinObject_AsIID(obSD, &appid)) + return NULL; + pSD = (PSECURITY_DESCRIPTOR)&appid; + } + } + else if (dwCapabilities & EOAC_ACCESS_CONTROL){ + if (!PyCom_InterfaceFromPyObject(obSD, IID_IAccessControl, (void **)&pIAC, FALSE)) return NULL; + pSD = (PSECURITY_DESCRIPTOR)pIAC; + } + else{ + if (!PyWinObject_AsSECURITY_DESCRIPTOR(obSD, &pSD, /*BOOL bNoneOK = */TRUE)) + return NULL; + // Security descriptor must be in absolute form + if (pSD){ + if (!_MakeAbsoluteSD(pSD, &pSD_absolute)) + return NULL; + pSD = pSD_absolute; + } + } PY_INTERFACE_PRECALL; - HRESULT hr = (*mypfn)(pSD_absolute, cAuthSvc, pAS, NULL, dwAuthnLevel, dwImpLevel, NULL, dwCapabilities, NULL); -// HRESULT hr = CoInitializeSecurity(pSD, cAuthSvc, pAS, NULL, dwAuthnLevel, dwImpLevel, NULL, dwCapabilities, NULL); + HRESULT hr = (*pfnCoInitializeSecurity)(pSD, cAuthSvc, pAS, NULL, dwAuthnLevel, + dwImpLevel, NULL, dwCapabilities, NULL); + if (pIAC) + pIAC->Release(); PY_INTERFACE_POSTCALL; if (pSD_absolute!=NULL) FreeAbsoluteSD(pSD_absolute); @@ -858,15 +872,14 @@ if ( !PyArg_ParseTuple(args, "O:CreateFileMoniker", &obName) ) return NULL; - BSTR bstrName; - if (!PyWinObject_AsBstr(obName, &bstrName)) + TmpWCHAR Name; + if (!PyWinObject_AsWCHAR(obName, &Name)) return NULL; IMoniker *pmk; PY_INTERFACE_PRECALL; - HRESULT hr = CreateFileMoniker(bstrName, &pmk); + HRESULT hr = CreateFileMoniker(Name, &pmk); PY_INTERFACE_POSTCALL; - PyWinObject_FreeBstr(bstrName); if ( FAILED(hr) ) return PyCom_BuildPyException(hr); @@ -884,25 +897,18 @@ if ( !PyArg_ParseTuple(args, "OO:CreateItemMoniker", &obDelim, &obItem) ) return NULL; |