pywin32-checkins Mailing List for Python for Windows Extensions (Page 116)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Mark H. <mha...@us...> - 2005-03-06 23:27:12
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25147/src Modified Files: PyTime.cpp PyWinTypes.h win32security.i Added Files: win32security_sspi.cpp win32security_sspi.h Log Message: Some excellent sspi additions to win32security, and a number of tests and demos, originally from Roger Upole. Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** win32security.i 1 Oct 2004 00:16:20 -0000 1.20 --- win32security.i 6 Mar 2005 23:27:01 -0000 1.21 *************** *** 1,3 **** --- 1,4 ---- /* File : win32security.i */ + // $Id$ // @doc *************** *** 8,12 **** %} - [...1362 lines suppressed...] + PyWinObject_FreeWCHAR(((PKERB_PURGE_TKT_CACHE_REQUEST)inputbuf)->RealmName.Buffer); + } + break; + } + if (inputbuf!=NULL) + free(inputbuf); + if (outputbuf!=NULL) + (*pfnLsaFreeReturnBuffer)(outputbuf); + return ret; + } + %} + #define TOKEN_ADJUST_DEFAULT TOKEN_ADJUST_DEFAULT // Required to change the default ACL, primary group, or owner of an access token. #define TOKEN_ADJUST_GROUPS TOKEN_ADJUST_GROUPS // Required to change the groups specified in an access token. *************** *** 2896,2897 **** --- 3584,3586 ---- #define DISABLE_MAX_PRIVILEGE DISABLE_MAX_PRIVILEGE #define SANDBOX_INERT SANDBOX_INERT + --- NEW FILE: win32security_sspi.cpp --- // SSPI objects for the win32security module, by Roger Upole // $Id: win32security_sspi.cpp,v 1.1 2005/03/06 23:27:02 mhammond Exp $ // Currently this file contains only object definitions - the SSPI methods // themselves are defined in win32security.i. In the future this may change. // @doc - This file contains autoduck documentation #include "PyWinTypes.h" #include "structmember.h" #include "PyWinObjects.h" #include "PySecurityObjects.h" #include "win32security_sspi.h" #include "schannel.h" //////////////////////////////////////////////////////////////////////// // // PySecBufferDesc // //////////////////////////////////////////////////////////////////////// [...1179 lines suppressed...] // @flag SECPKG_CRED_ATTR_NAMES|<o PyUnicode> - returns username that credentials represent case SECPKG_CRED_ATTR_NAMES: PSecPkgCredentials_NamesW cn; cn=(PSecPkgCredentials_NamesW)&buf; ret=PyWinObject_FromWCHAR(cn->sUserName); (*psecurityfunctiontable->FreeContextBuffer)(cn->sUserName); break; // @flag SECPKG_ATTR_SUPPORTED_ALGS|Not supported yet case SECPKG_ATTR_SUPPORTED_ALGS: // SecPkgCred_SupportedAlgs: // @flag SECPKG_ATTR_CIPHER_STRENGTHS|Not supported yet case SECPKG_ATTR_CIPHER_STRENGTHS: // SecPkgCred_CipherStrengths: // @flag SECPKG_ATTR_SUPPORTED_PROTOCOLS|Not supported yet case SECPKG_ATTR_SUPPORTED_PROTOCOLS: // SecPkgCred_SupportedProtocols: default: PyErr_SetString(PyExc_NotImplementedError,"Attribute is not supported yet"); } return ret; } --- NEW FILE: win32security_sspi.h --- // Definitions for the win32security sspi support, by Roger Upole // $Id: win32security_sspi.h,v 1.1 2005/03/06 23:27:02 mhammond Exp $ #define SECURITY_WIN32 #include "Security.h" // SecBuffer objects for SSPI functionality extern __declspec(dllexport) PyTypeObject PySecBufferType; extern BOOL PyWinObject_AsSecBuffer(PyObject *, PSecBuffer *, BOOL); extern PyObject *PyWinObject_FromSecBuffer(PSecBuffer); extern __declspec(dllexport) PyTypeObject PySecBufferDescType; extern BOOL PyWinObject_AsSecBufferDesc(PyObject *, PSecBufferDesc *, BOOL); extern PyObject *PyWinObject_FromSecBufferDesc(PSecBufferDesc); // PyCtxtHandle object for SSPI support extern __declspec(dllexport) PyTypeObject PyCtxtHandleType; extern BOOL PyWinObject_AsCtxtHandle(PyObject *, PCtxtHandle *, BOOL); extern PyObject *PyWinObject_FromCtxtHandle(PCtxtHandle); extern __declspec(dllexport) PyTypeObject PyCredHandleType; extern BOOL PyWinObject_AsCredHandle(PyObject *, PCredHandle *, BOOL); extern PyObject *PyWinObject_FromCredHandle(PCredHandle); extern PyObject *PyWinObject_FromSecPkgInfo(PSecPkgInfoW psecpkginfo); extern PyObject *PyWinObject_FromSecHandle(PSecHandle h); extern PSecurityFunctionTableW psecurityfunctiontable; #define CHECK_SECURITYFUNCTIONTABLE(fname)if (psecurityfunctiontable==NULL||psecurityfunctiontable->fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); class PySecBuffer : public PyObject { public: #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; static struct PyMethodDef methods[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER PySecBuffer(PSecBuffer psecbuffer); PySecBuffer(ULONG cbBuffer, ULONG BufferType); ~PySecBuffer(); static void deallocFunc(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *); static PyObject *Clear(PyObject *self, PyObject *args); PSecBuffer GetSecBuffer(void); PyObject *obdummy; // InitializeSecurityContext and AcceptSecurityContext change the cbBuffer in the structure to reflect // bytes used, keep our own allocated size unsigned long maxbufsize; protected: SecBuffer secbuffer; }; class PySecBufferDesc : public PyObject { public: #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; static struct PyMethodDef methods[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER // ??? might need this, some protocols will allocate output buffers for you if ISC_REQ_ALLOCATE_MEMORY is specified PySecBufferDesc(ULONG ulVersion); PySecBufferDesc(PSecBufferDesc psecbufferdesc); ~PySecBufferDesc(); static void deallocFunc(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *); static PySequenceMethods sequencemethods; PSecBufferDesc GetSecBufferDesc(void); PyObject **obBuffers; unsigned long max_buffers; static PyObject *append(PyObject *self, PyObject *args); void modify_in_place(void); protected: SecBufferDesc secbufferdesc; }; class PyCtxtHandle : public PyObject { public: #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; static struct PyMethodDef methods[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER PyCtxtHandle(PCtxtHandle pctxthandle); PyCtxtHandle(void); ~PyCtxtHandle(); static void deallocFunc(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *); static PyObject *MakeSignature(PyObject *self, PyObject *args); static PyObject *VerifySignature(PyObject *self, PyObject *args); static PyObject *EncryptMessage(PyObject *self, PyObject *args); static PyObject *DecryptMessage(PyObject *self, PyObject *args); static PyObject *Detach(PyObject *self, PyObject *args); static PyObject *DeleteSecurityContext(PyObject *self, PyObject *args); static PyObject *CompleteAuthToken(PyObject *self, PyObject *args); static PyObject *QueryContextAttributes(PyObject *self, PyObject *args); static PyObject *QuerySecurityContextToken(PyObject *self, PyObject *args); static PyObject *ImpersonateSecurityContext(PyObject *self, PyObject *args); static PyObject *RevertSecurityContext(PyObject *self, PyObject *args); PCtxtHandle GetCtxtHandle(void); protected: CtxtHandle ctxthandle; }; class PyCredHandle : public PyObject { public: #ifdef _MSC_VER #pragma warning( disable : 4251 ) #endif // _MSC_VER static struct PyMemberDef members[]; static struct PyMethodDef methods[]; #ifdef _MSC_VER #pragma warning( default : 4251 ) #endif // _MSC_VER PyCredHandle(PCredHandle); PyCredHandle(void); ~PyCredHandle(); static void deallocFunc(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *); static PyObject *Detach(PyObject *self, PyObject *args); static PyObject *FreeCredentialsHandle(PyObject *self, PyObject *args); static PyObject *QueryCredentialsAttributes(PyObject *self, PyObject *args); PCredHandle GetCredHandle(void); protected: CredHandle credhandle; }; Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyTime.cpp 4 Mar 2005 11:56:55 -0000 1.13 --- PyTime.cpp 6 Mar 2005 23:27:01 -0000 1.14 *************** *** 127,130 **** --- 127,140 ---- } + // Converts a TimeStamp, which is in 100 nanosecond units like a FILETIME + // See comments in pywintypes.h re LARGE_INTEGER vs TimeStamp + PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &ts) + { + FILETIME ft; + ft.dwHighDateTime=ts.HighPart; + ft.dwLowDateTime=ts.LowPart; + return new PyTime(ft); + } + BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) { *************** *** 712,716 **** return PyFloat_FromDouble(PyCE_SystemTimeToCTime(&st)); } - //PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) //{ --- 722,725 ---- Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PyWinTypes.h 30 Nov 2004 21:30:29 -0000 1.25 --- PyWinTypes.h 6 Mar 2005 23:27:01 -0000 1.26 *************** *** 285,288 **** --- 285,294 ---- PYWINTYPES_EXPORT PyObject *PyWinObject_FromFILETIME(const FILETIME &t); + // Converts a TimeStamp, which is in 100 nanosecond units like a FILETIME + // TimeStamp is actually defined as a LARGE_INTEGER, so this function will also + // accept Windows security "TimeStamp" objects directly - however, we use a + // LARGE_INTEGER prototype to avoid pulling in the windows security headers. + PYWINTYPES_EXPORT PyObject *PyWinObject_FromTimeStamp(const LARGE_INTEGER &t); + PYWINTYPES_EXPORT BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate); PYWINTYPES_EXPORT BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate); |
From: Mark H. <mha...@us...> - 2005-03-06 23:27:12
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25147/Lib Added Files: sspi.py sspicon.py Log Message: Some excellent sspi additions to win32security, and a number of tests and demos, originally from Roger Upole. --- NEW FILE: sspi.py --- """ Helper classes for SSPI authentication via the win32security module. SSPI authentication involves a token-exchange "dance", the exact details of which depends on the authentication provider used. There are also a number of complex flags and constants that need to be used - in most cases, there are reasonable defaults. These classes attempt to hide these details from you until you really need to know. """ # Based on Roger Upole's sspi demos. # $Id: sspi.py,v 1.1 2005/03/06 23:27:00 mhammond Exp $ import win32security, sspicon try: True, False except NameError: False = 1==0 True = not False class _BaseAuth(object): def __init__(self): self.reset() def reset(self): self.ctxt = None self.authenticated = False def encrypt(self, data): """Encrypt a string, returning a string suitable for transmission""" pkg_size_info=self.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) trailersize=pkg_size_info['SecurityTrailer'] encbuf=win32security.SecBufferDescType() encbuf.append(win32security.SecBufferType(len(data), sspicon.SECBUFFER_DATA)) encbuf.append(win32security.SecBufferType(trailersize, sspicon.SECBUFFER_TOKEN)) encbuf[0].Buffer=data self.ctxt.EncryptMessage(0,encbuf,1) # And return all buffers as a string return "".join([b.Buffer for b in encbuf]) def decrypt(self, data): """Decrypt a previously encrypted string, returning the orignal data""" pkg_size_info=self.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) trailersize=pkg_size_info['SecurityTrailer'] msgsize = len(data)-trailersize assert msgsize >= 0, "trailer is %d bytes, but data only %d long" \ % (trailersize, len(data)) encbuf=win32security.SecBufferDescType() encbuf.append(win32security.SecBufferType(msgsize, sspicon.SECBUFFER_DATA)) encbuf.append(win32security.SecBufferType(trailersize, sspicon.SECBUFFER_TOKEN)) encbuf[0].Buffer=data[:msgsize] encbuf[1].Buffer=data[msgsize:] self.ctxt.DecryptMessage(encbuf,1) return encbuf[0].Buffer def sign(self, data): """sign a string suitable for transmission. """ pkg_size_info=self.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) sigsize=pkg_size_info['MaxSignature'] sigbuf=win32security.SecBufferDescType() sigbuf.append(win32security.SecBufferType(len(data), sspicon.SECBUFFER_DATA)) sigbuf.append(win32security.SecBufferType(sigsize, sspicon.SECBUFFER_TOKEN)) sigbuf[0].Buffer=data self.ctxt.MakeSignature(0,sigbuf,1) # And return all buffers as a string return "".join([b.Buffer for b in sigbuf]) def unsign(self, data): """Takes a message as a 'signed' string, verifies the signature and returns the original data""" pkg_size_info=self.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) sigsize=pkg_size_info['MaxSignature'] msgsize = len(data)-sigsize assert msgsize >= 0, "signature is %d bytes, but data only %d long" \ % (sigsize, len(data)) sigbuf=win32security.SecBufferDescType() sigbuf.append(win32security.SecBufferType(msgsize, sspicon.SECBUFFER_DATA)) sigbuf.append(win32security.SecBufferType(sigsize, sspicon.SECBUFFER_TOKEN)) sigbuf[0].Buffer=data[:msgsize] sigbuf[1].Buffer=data[msgsize:] self.ctxt.VerifySignature(sigbuf,1) return sigbuf[0].Buffer class ClientAuth(_BaseAuth): """Manages the client side of an SSPI authentication handshake """ def __init__(self, pkg_name, # Name of the package to used. client_name = None, # User for whom credentials are used. auth_info = None, # or a tuple of (username, domain, password) targetspn = None, # Target security context provider name. scflags=None, # security context flags datarep=sspicon.SECURITY_NETWORK_DREP): if scflags is None: scflags = sspicon.ISC_REQ_INTEGRITY|sspicon.ISC_REQ_SEQUENCE_DETECT|\ sspicon.ISC_REQ_REPLAY_DETECT|sspicon.ISC_REQ_CONFIDENTIALITY self.scflags=scflags self.datarep=datarep self.targetspn=targetspn self.pkg_info=win32security.QuerySecurityPackageInfo(pkg_name) self.credentials, \ self.credentials_expiry=win32security.AcquireCredentialsHandle( client_name, self.pkg_info['Name'], sspicon.SECPKG_CRED_OUTBOUND, None, auth_info) _BaseAuth.__init__(self) # Perform *one* step of the client authentication process. def authorize(self, sec_buffer_in): if sec_buffer_in is not None and type(sec_buffer_in) != win32security.SecBufferDescType: # User passed us the raw data - wrap it into a SecBufferDesc sec_buffer_new=win32security.SecBufferDescType() tokenbuf=win32security.SecBufferType(self.pkg_info['MaxToken'], sspicon.SECBUFFER_TOKEN) tokenbuf.Buffer=sec_buffer_in sec_buffer_new.append(tokenbuf) sec_buffer_in = sec_buffer_new sec_buffer_out=win32security.SecBufferDescType() tokenbuf=win32security.SecBufferType(self.pkg_info['MaxToken'], sspicon.SECBUFFER_TOKEN) sec_buffer_out.append(tokenbuf) ## input context handle should be NULL on first call ctxtin=self.ctxt if self.ctxt is None: self.ctxt=win32security.CtxtHandleType() err, attr, exp=win32security.InitializeSecurityContext( self.credentials, ctxtin, self.targetspn, self.scflags, self.datarep, sec_buffer_in, self.ctxt, sec_buffer_out) # Stash these away incase someone needs to know the state from the # final call. self.ctxt_attr = attr self.ctxt_expiry = exp if err in (sspicon.SEC_I_COMPLETE_NEEDED,sspicon.SEC_I_COMPLETE_AND_CONTINUE): self.ctxt.CompleteAuthToken(sec_buffer_out) self.authenticated = err == 0 return err, sec_buffer_out class ServerAuth(_BaseAuth): """Manages the server side of an SSPI authentication handshake """ def __init__(self, pkg_name, spn = None, scflags=None, datarep=sspicon.SECURITY_NETWORK_DREP): self.spn=spn self.datarep=datarep if scflags is None: scflags = sspicon.ASC_REQ_INTEGRITY|sspicon.ASC_REQ_SEQUENCE_DETECT|\ sspicon.ASC_REQ_REPLAY_DETECT|sspicon.ASC_REQ_CONFIDENTIALITY # Should we default to sspicon.KerbAddExtraCredentialsMessage # if pkg_name=='Kerberos'? self.scflags=scflags self.pkg_info=win32security.QuerySecurityPackageInfo(pkg_name) self.credentials, \ self.credentials_expiry=win32security.AcquireCredentialsHandle(spn, self.pkg_info['Name'], sspicon.SECPKG_CRED_INBOUND, None, None) _BaseAuth.__init__(self) # Perform *one* step of the server authentication process. def authorize(self, sec_buffer_in): if sec_buffer_in is not None and type(sec_buffer_in) != win32security.SecBufferDescType: # User passed us the raw data - wrap it into a SecBufferDesc sec_buffer_new=win32security.SecBufferDescType() tokenbuf=win32security.SecBufferType(self.pkg_info['MaxToken'], sspicon.SECBUFFER_TOKEN) tokenbuf.Buffer=sec_buffer_in sec_buffer_new.append(tokenbuf) sec_buffer_in = sec_buffer_new sec_buffer_out=win32security.SecBufferDescType() tokenbuf=win32security.SecBufferType(self.pkg_info['MaxToken'], sspicon.SECBUFFER_TOKEN) sec_buffer_out.append(tokenbuf) ## input context handle is None initially, then handle returned from last call thereafter ctxtin=self.ctxt if self.ctxt is None: self.ctxt=win32security.CtxtHandleType() err, attr, exp = win32security.AcceptSecurityContext(self.credentials, ctxtin, sec_buffer_in, self.scflags, self.datarep, self.ctxt, sec_buffer_out) # Stash these away incase someone needs to know the state from the # final call. self.ctxt_attr = attr self.ctxt_expiry = exp if err in (sspicon.SEC_I_COMPLETE_NEEDED,sspicon.SEC_I_COMPLETE_AND_CONTINUE): self.ctxt.CompleteAuthToken(sec_buffer_out) self.authenticated = err == 0 return err, sec_buffer_out if __name__=='__main__': # Setup the 2 contexts. sspiclient=ClientAuth("NTLM") sspiserver=ServerAuth("NTLM") # Perform the authentication dance, each loop exchanging more information # on the way to completing authentication. sec_buffer=None while 1: err, sec_buffer = sspiclient.authorize(sec_buffer) err, sec_buffer = sspiserver.authorize(sec_buffer) if err==0: break assert sspiserver.unsign(sspiclient.sign("hello")) == "hello" assert sspiserver.decrypt(sspiclient.encrypt("hello")) == "hello" print "cool!" --- NEW FILE: sspicon.py --- # Generated by h2py from c:\microsoft sdk\include\sspi.h ISSP_LEVEL = 32 ISSP_MODE = 1 ISSP_LEVEL = 32 ISSP_MODE = 0 ISSP_LEVEL = 32 ISSP_MODE = 1 def SEC_SUCCESS(Status): return ((Status) >= 0) SECPKG_FLAG_INTEGRITY = 0x00000001 SECPKG_FLAG_PRIVACY = 0x00000002 SECPKG_FLAG_TOKEN_ONLY = 0x00000004 SECPKG_FLAG_DATAGRAM = 0x00000008 SECPKG_FLAG_CONNECTION = 0x00000010 SECPKG_FLAG_MULTI_REQUIRED = 0x00000020 SECPKG_FLAG_CLIENT_ONLY = 0x00000040 SECPKG_FLAG_EXTENDED_ERROR = 0x00000080 SECPKG_FLAG_IMPERSONATION = 0x00000100 SECPKG_FLAG_ACCEPT_WIN32_NAME = 0x00000200 SECPKG_FLAG_STREAM = 0x00000400 SECPKG_FLAG_NEGOTIABLE = 0x00000800 SECPKG_FLAG_GSS_COMPATIBLE = 0x00001000 SECPKG_FLAG_LOGON = 0x00002000 SECPKG_FLAG_ASCII_BUFFERS = 0x00004000 SECPKG_FLAG_FRAGMENT = 0x00008000 SECPKG_FLAG_MUTUAL_AUTH = 0x00010000 SECPKG_FLAG_DELEGATION = 0x00020000 SECPKG_FLAG_READONLY_WITH_CHECKSUM = 0x00040000 SECPKG_ID_NONE = 0xFFFF SECBUFFER_VERSION = 0 SECBUFFER_EMPTY = 0 SECBUFFER_DATA = 1 SECBUFFER_TOKEN = 2 SECBUFFER_PKG_PARAMS = 3 SECBUFFER_MISSING = 4 SECBUFFER_EXTRA = 5 SECBUFFER_STREAM_TRAILER = 6 SECBUFFER_STREAM_HEADER = 7 SECBUFFER_NEGOTIATION_INFO = 8 SECBUFFER_PADDING = 9 SECBUFFER_STREAM = 10 SECBUFFER_MECHLIST = 11 SECBUFFER_MECHLIST_SIGNATURE = 12 SECBUFFER_TARGET = 13 SECBUFFER_CHANNEL_BINDINGS = 14 SECBUFFER_ATTRMASK = (-268435456) SECBUFFER_READONLY = (-2147483648) SECBUFFER_READONLY_WITH_CHECKSUM = 0x10000000 SECBUFFER_RESERVED = 0x60000000 SECURITY_NATIVE_DREP = 0x00000010 SECURITY_NETWORK_DREP = 0x00000000 SECPKG_CRED_INBOUND = 0x00000001 SECPKG_CRED_OUTBOUND = 0x00000002 SECPKG_CRED_BOTH = 0x00000003 SECPKG_CRED_DEFAULT = 0x00000004 SECPKG_CRED_RESERVED = -268435456 ISC_REQ_DELEGATE = 0x00000001 ISC_REQ_MUTUAL_AUTH = 0x00000002 ISC_REQ_REPLAY_DETECT = 0x00000004 ISC_REQ_SEQUENCE_DETECT = 0x00000008 ISC_REQ_CONFIDENTIALITY = 0x00000010 ISC_REQ_USE_SESSION_KEY = 0x00000020 ISC_REQ_PROMPT_FOR_CREDS = 0x00000040 ISC_REQ_USE_SUPPLIED_CREDS = 0x00000080 ISC_REQ_ALLOCATE_MEMORY = 0x00000100 ISC_REQ_USE_DCE_STYLE = 0x00000200 ISC_REQ_DATAGRAM = 0x00000400 ISC_REQ_CONNECTION = 0x00000800 ISC_REQ_CALL_LEVEL = 0x00001000 ISC_REQ_FRAGMENT_SUPPLIED = 0x00002000 ISC_REQ_EXTENDED_ERROR = 0x00004000 ISC_REQ_STREAM = 0x00008000 ISC_REQ_INTEGRITY = 0x00010000 ISC_REQ_IDENTIFY = 0x00020000 ISC_REQ_NULL_SESSION = 0x00040000 ISC_REQ_MANUAL_CRED_VALIDATION = 0x00080000 ISC_REQ_RESERVED1 = 0x00100000 ISC_REQ_FRAGMENT_TO_FIT = 0x00200000 ISC_RET_DELEGATE = 0x00000001 ISC_RET_MUTUAL_AUTH = 0x00000002 ISC_RET_REPLAY_DETECT = 0x00000004 ISC_RET_SEQUENCE_DETECT = 0x00000008 ISC_RET_CONFIDENTIALITY = 0x00000010 ISC_RET_USE_SESSION_KEY = 0x00000020 ISC_RET_USED_COLLECTED_CREDS = 0x00000040 ISC_RET_USED_SUPPLIED_CREDS = 0x00000080 ISC_RET_ALLOCATED_MEMORY = 0x00000100 ISC_RET_USED_DCE_STYLE = 0x00000200 ISC_RET_DATAGRAM = 0x00000400 ISC_RET_CONNECTION = 0x00000800 ISC_RET_INTERMEDIATE_RETURN = 0x00001000 ISC_RET_CALL_LEVEL = 0x00002000 ISC_RET_EXTENDED_ERROR = 0x00004000 ISC_RET_STREAM = 0x00008000 ISC_RET_INTEGRITY = 0x00010000 ISC_RET_IDENTIFY = 0x00020000 ISC_RET_NULL_SESSION = 0x00040000 ISC_RET_MANUAL_CRED_VALIDATION = 0x00080000 ISC_RET_RESERVED1 = 0x00100000 ISC_RET_FRAGMENT_ONLY = 0x00200000 ASC_REQ_DELEGATE = 0x00000001 ASC_REQ_MUTUAL_AUTH = 0x00000002 ASC_REQ_REPLAY_DETECT = 0x00000004 ASC_REQ_SEQUENCE_DETECT = 0x00000008 ASC_REQ_CONFIDENTIALITY = 0x00000010 ASC_REQ_USE_SESSION_KEY = 0x00000020 ASC_REQ_ALLOCATE_MEMORY = 0x00000100 ASC_REQ_USE_DCE_STYLE = 0x00000200 ASC_REQ_DATAGRAM = 0x00000400 ASC_REQ_CONNECTION = 0x00000800 ASC_REQ_CALL_LEVEL = 0x00001000 ASC_REQ_EXTENDED_ERROR = 0x00008000 ASC_REQ_STREAM = 0x00010000 ASC_REQ_INTEGRITY = 0x00020000 ASC_REQ_LICENSING = 0x00040000 ASC_REQ_IDENTIFY = 0x00080000 ASC_REQ_ALLOW_NULL_SESSION = 0x00100000 ASC_REQ_ALLOW_NON_USER_LOGONS = 0x00200000 ASC_REQ_ALLOW_CONTEXT_REPLAY = 0x00400000 ASC_REQ_FRAGMENT_TO_FIT = 0x00800000 ASC_REQ_FRAGMENT_SUPPLIED = 0x00002000 ASC_REQ_NO_TOKEN = 0x01000000 ASC_RET_DELEGATE = 0x00000001 ASC_RET_MUTUAL_AUTH = 0x00000002 ASC_RET_REPLAY_DETECT = 0x00000004 ASC_RET_SEQUENCE_DETECT = 0x00000008 ASC_RET_CONFIDENTIALITY = 0x00000010 ASC_RET_USE_SESSION_KEY = 0x00000020 ASC_RET_ALLOCATED_MEMORY = 0x00000100 ASC_RET_USED_DCE_STYLE = 0x00000200 ASC_RET_DATAGRAM = 0x00000400 ASC_RET_CONNECTION = 0x00000800 ASC_RET_CALL_LEVEL = 0x00002000 ASC_RET_THIRD_LEG_FAILED = 0x00004000 ASC_RET_EXTENDED_ERROR = 0x00008000 ASC_RET_STREAM = 0x00010000 ASC_RET_INTEGRITY = 0x00020000 ASC_RET_LICENSING = 0x00040000 ASC_RET_IDENTIFY = 0x00080000 ASC_RET_NULL_SESSION = 0x00100000 ASC_RET_ALLOW_NON_USER_LOGONS = 0x00200000 ASC_RET_ALLOW_CONTEXT_REPLAY = 0x00400000 ASC_RET_FRAGMENT_ONLY = 0x00800000 SECPKG_CRED_ATTR_NAMES = 1 SECPKG_ATTR_SIZES = 0 SECPKG_ATTR_NAMES = 1 SECPKG_ATTR_LIFESPAN = 2 SECPKG_ATTR_DCE_INFO = 3 SECPKG_ATTR_STREAM_SIZES = 4 SECPKG_ATTR_KEY_INFO = 5 SECPKG_ATTR_AUTHORITY = 6 SECPKG_ATTR_PROTO_INFO = 7 SECPKG_ATTR_PASSWORD_EXPIRY = 8 SECPKG_ATTR_SESSION_KEY = 9 SECPKG_ATTR_PACKAGE_INFO = 10 SECPKG_ATTR_USER_FLAGS = 11 SECPKG_ATTR_NEGOTIATION_INFO = 12 SECPKG_ATTR_NATIVE_NAMES = 13 SECPKG_ATTR_FLAGS = 14 SECPKG_ATTR_USE_VALIDATED = 15 SECPKG_ATTR_CREDENTIAL_NAME = 16 SECPKG_ATTR_TARGET_INFORMATION = 17 SECPKG_ATTR_ACCESS_TOKEN = 18 SECPKG_ATTR_TARGET = 19 SECPKG_ATTR_AUTHENTICATION_ID = 20 ## attributes from schannel.h SECPKG_ATTR_REMOTE_CERT_CONTEXT = 83 SECPKG_ATTR_LOCAL_CERT_CONTEXT = 84 SECPKG_ATTR_ROOT_STORE = 85 SECPKG_ATTR_SUPPORTED_ALGS = 86 SECPKG_ATTR_CIPHER_STRENGTHS = 87 SECPKG_ATTR_SUPPORTED_PROTOCOLS = 88 SECPKG_ATTR_ISSUER_LIST_EX = 89 SECPKG_ATTR_CONNECTION_INFO = 90 SECPKG_ATTR_EAP_KEY_BLOCK = 91 SECPKG_ATTR_MAPPED_CRED_ATTR = 92 SECPKG_ATTR_SESSION_INFO = 93 SECPKG_ATTR_APP_DATA = 94 SECPKG_NEGOTIATION_COMPLETE = 0 SECPKG_NEGOTIATION_OPTIMISTIC = 1 SECPKG_NEGOTIATION_IN_PROGRESS = 2 SECPKG_NEGOTIATION_DIRECT = 3 SECPKG_NEGOTIATION_TRY_MULTICRED = 4 SECPKG_CONTEXT_EXPORT_RESET_NEW = 0x00000001 SECPKG_CONTEXT_EXPORT_DELETE_OLD = 0x00000002 SECQOP_WRAP_NO_ENCRYPT = (-2147483647) SECURITY_ENTRYPOINT_ANSIW = "InitSecurityInterfaceW" SECURITY_ENTRYPOINT_ANSIA = "InitSecurityInterfaceA" SECURITY_ENTRYPOINT16 = "INITSECURITYINTERFACEA" SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINT_ANSIW SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINT_ANSIA SECURITY_ENTRYPOINT = SECURITY_ENTRYPOINT16 SECURITY_ENTRYPOINT_ANSI = SECURITY_ENTRYPOINT16 SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION = 1 SECURITY_SUPPORT_PROVIDER_INTERFACE_VERSION_2 = 2 SASL_OPTION_SEND_SIZE = 1 SASL_OPTION_RECV_SIZE = 2 SASL_OPTION_AUTHZ_STRING = 3 SASL_OPTION_AUTHZ_PROCESSING = 4 SEC_WINNT_AUTH_IDENTITY_ANSI = 0x1 SEC_WINNT_AUTH_IDENTITY_UNICODE = 0x2 SEC_WINNT_AUTH_IDENTITY_VERSION = 0x200 SEC_WINNT_AUTH_IDENTITY_MARSHALLED = 0x4 SEC_WINNT_AUTH_IDENTITY_ONLY = 0x8 SECPKG_OPTIONS_TYPE_UNKNOWN = 0 SECPKG_OPTIONS_TYPE_LSA = 1 SECPKG_OPTIONS_TYPE_SSPI = 2 SECPKG_OPTIONS_PERMANENT = 0x00000001 SEC_E_INSUFFICIENT_MEMORY = 0x80090300L SEC_E_INVALID_HANDLE = 0x80090301L SEC_E_UNSUPPORTED_FUNCTION = 0x80090302L SEC_E_TARGET_UNKNOWN = 0x80090303L SEC_E_INTERNAL_ERROR = 0x80090304L SEC_E_SECPKG_NOT_FOUND = 0x80090305L SEC_E_NOT_OWNER = 0x80090306L SEC_E_CANNOT_INSTALL = 0x80090307L SEC_E_INVALID_TOKEN = 0x80090308L SEC_E_CANNOT_PACK = 0x80090309L SEC_E_QOP_NOT_SUPPORTED = 0x8009030AL SEC_E_NO_IMPERSONATION = 0x8009030BL SEC_E_LOGON_DENIED = 0x8009030CL SEC_E_UNKNOWN_CREDENTIALS = 0x8009030DL SEC_E_NO_CREDENTIALS = 0x8009030EL SEC_E_MESSAGE_ALTERED = 0x8009030FL SEC_E_OUT_OF_SEQUENCE = 0x80090310L SEC_E_NO_AUTHENTICATING_AUTHORITY = 0x80090311L SEC_I_CONTINUE_NEEDED = 0x00090312L SEC_I_COMPLETE_NEEDED = 0x00090313L SEC_I_COMPLETE_AND_CONTINUE = 0x00090314L SEC_I_LOCAL_LOGON = 0x00090315L SEC_E_BAD_PKGID = 0x80090316L SEC_E_CONTEXT_EXPIRED = 0x80090317L SEC_I_CONTEXT_EXPIRED = 0x00090317L SEC_E_INCOMPLETE_MESSAGE = 0x80090318L SEC_E_INCOMPLETE_CREDENTIALS = 0x80090320L SEC_E_BUFFER_TOO_SMALL = 0x80090321L SEC_I_INCOMPLETE_CREDENTIALS = 0x00090320L SEC_I_RENEGOTIATE = 0x00090321L SEC_E_WRONG_PRINCIPAL = 0x80090322L SEC_I_NO_LSA_CONTEXT = 0x00090323L SEC_E_TIME_SKEW = 0x80090324L SEC_E_UNTRUSTED_ROOT = 0x80090325L SEC_E_ILLEGAL_MESSAGE = 0x80090326L SEC_E_CERT_UNKNOWN = 0x80090327L SEC_E_CERT_EXPIRED = 0x80090328L SEC_E_ENCRYPT_FAILURE = 0x80090329L SEC_E_DECRYPT_FAILURE = 0x80090330L SEC_E_ALGORITHM_MISMATCH = 0x80090331L SEC_E_SECURITY_QOS_FAILED = 0x80090332L SEC_E_UNFINISHED_CONTEXT_DELETED = 0x80090333L SEC_E_NO_TGT_REPLY = 0x80090334L SEC_E_NO_IP_ADDRESSES = 0x80090335L SEC_E_WRONG_CREDENTIAL_HANDLE = 0x80090336L SEC_E_CRYPTO_SYSTEM_INVALID = 0x80090337L SEC_E_MAX_REFERRALS_EXCEEDED = 0x80090338L SEC_E_MUST_BE_KDC = 0x80090339L SEC_E_STRONG_CRYPTO_NOT_SUPPORTED = 0x8009033AL SEC_E_TOO_MANY_PRINCIPALS = 0x8009033BL SEC_E_NO_PA_DATA = 0x8009033CL SEC_E_PKINIT_NAME_MISMATCH = 0x8009033DL SEC_E_SMARTCARD_LOGON_REQUIRED = 0x8009033EL SEC_E_SHUTDOWN_IN_PROGRESS = 0x8009033FL SEC_E_KDC_INVALID_REQUEST = 0x80090340L SEC_E_KDC_UNABLE_TO_REFER = 0x80090341L SEC_E_KDC_UNKNOWN_ETYPE = 0x80090342L SEC_E_UNSUPPORTED_PREAUTH = 0x80090343L SEC_E_DELEGATION_REQUIRED = 0x80090345L SEC_E_BAD_BINDINGS = 0x80090346L SEC_E_MULTIPLE_ACCOUNTS = 0x80090347L SEC_E_NO_KERB_KEY = 0x80090348L ERROR_IPSEC_QM_POLICY_EXISTS = 13000L ERROR_IPSEC_QM_POLICY_NOT_FOUND = 13001L ERROR_IPSEC_QM_POLICY_IN_USE = 13002L ERROR_IPSEC_MM_POLICY_EXISTS = 13003L ERROR_IPSEC_MM_POLICY_NOT_FOUND = 13004L ERROR_IPSEC_MM_POLICY_IN_USE = 13005L ERROR_IPSEC_MM_FILTER_EXISTS = 13006L ERROR_IPSEC_MM_FILTER_NOT_FOUND = 13007L ERROR_IPSEC_TRANSPORT_FILTER_EXISTS = 13008L ERROR_IPSEC_TRANSPORT_FILTER_NOT_FOUND = 13009L ERROR_IPSEC_MM_AUTH_EXISTS = 13010L ERROR_IPSEC_MM_AUTH_NOT_FOUND = 13011L ERROR_IPSEC_MM_AUTH_IN_USE = 13012L ERROR_IPSEC_DEFAULT_MM_POLICY_NOT_FOUND = 13013L ERROR_IPSEC_DEFAULT_MM_AUTH_NOT_FOUND = 13014L ERROR_IPSEC_DEFAULT_QM_POLICY_NOT_FOUND = 13015L ERROR_IPSEC_TUNNEL_FILTER_EXISTS = 13016L ERROR_IPSEC_TUNNEL_FILTER_NOT_FOUND = 13017L ERROR_IPSEC_MM_FILTER_PENDING_DELETION = 13018L ERROR_IPSEC_TRANSPORT_FILTER_PENDING_DELETION = 13019L ERROR_IPSEC_TUNNEL_FILTER_PENDING_DELETION = 13020L ERROR_IPSEC_MM_POLICY_PENDING_DELETION = 13021L ERROR_IPSEC_MM_AUTH_PENDING_DELETION = 13022L ERROR_IPSEC_QM_POLICY_PENDING_DELETION = 13023L WARNING_IPSEC_MM_POLICY_PRUNED = 13024L WARNING_IPSEC_QM_POLICY_PRUNED = 13025L ERROR_IPSEC_IKE_NEG_STATUS_BEGIN = 13800L ERROR_IPSEC_IKE_AUTH_FAIL = 13801L ERROR_IPSEC_IKE_ATTRIB_FAIL = 13802L ERROR_IPSEC_IKE_NEGOTIATION_PENDING = 13803L ERROR_IPSEC_IKE_GENERAL_PROCESSING_ERROR = 13804L ERROR_IPSEC_IKE_TIMED_OUT = 13805L ERROR_IPSEC_IKE_NO_CERT = 13806L ERROR_IPSEC_IKE_SA_DELETED = 13807L ERROR_IPSEC_IKE_SA_REAPED = 13808L ERROR_IPSEC_IKE_MM_ACQUIRE_DROP = 13809L ERROR_IPSEC_IKE_QM_ACQUIRE_DROP = 13810L ERROR_IPSEC_IKE_QUEUE_DROP_MM = 13811L ERROR_IPSEC_IKE_QUEUE_DROP_NO_MM = 13812L ERROR_IPSEC_IKE_DROP_NO_RESPONSE = 13813L ERROR_IPSEC_IKE_MM_DELAY_DROP = 13814L ERROR_IPSEC_IKE_QM_DELAY_DROP = 13815L ERROR_IPSEC_IKE_ERROR = 13816L ERROR_IPSEC_IKE_CRL_FAILED = 13817L ERROR_IPSEC_IKE_INVALID_KEY_USAGE = 13818L ERROR_IPSEC_IKE_INVALID_CERT_TYPE = 13819L ERROR_IPSEC_IKE_NO_PRIVATE_KEY = 13820L ERROR_IPSEC_IKE_DH_FAIL = 13822L ERROR_IPSEC_IKE_INVALID_HEADER = 13824L ERROR_IPSEC_IKE_NO_POLICY = 13825L ERROR_IPSEC_IKE_INVALID_SIGNATURE = 13826L ERROR_IPSEC_IKE_KERBEROS_ERROR = 13827L ERROR_IPSEC_IKE_NO_PUBLIC_KEY = 13828L ERROR_IPSEC_IKE_PROCESS_ERR = 13829L ERROR_IPSEC_IKE_PROCESS_ERR_SA = 13830L ERROR_IPSEC_IKE_PROCESS_ERR_PROP = 13831L ERROR_IPSEC_IKE_PROCESS_ERR_TRANS = 13832L ERROR_IPSEC_IKE_PROCESS_ERR_KE = 13833L ERROR_IPSEC_IKE_PROCESS_ERR_ID = 13834L ERROR_IPSEC_IKE_PROCESS_ERR_CERT = 13835L ERROR_IPSEC_IKE_PROCESS_ERR_CERT_REQ = 13836L ERROR_IPSEC_IKE_PROCESS_ERR_HASH = 13837L ERROR_IPSEC_IKE_PROCESS_ERR_SIG = 13838L ERROR_IPSEC_IKE_PROCESS_ERR_NONCE = 13839L ERROR_IPSEC_IKE_PROCESS_ERR_NOTIFY = 13840L ERROR_IPSEC_IKE_PROCESS_ERR_DELETE = 13841L ERROR_IPSEC_IKE_PROCESS_ERR_VENDOR = 13842L ERROR_IPSEC_IKE_INVALID_PAYLOAD = 13843L ERROR_IPSEC_IKE_LOAD_SOFT_SA = 13844L ERROR_IPSEC_IKE_SOFT_SA_TORN_DOWN = 13845L ERROR_IPSEC_IKE_INVALID_COOKIE = 13846L ERROR_IPSEC_IKE_NO_PEER_CERT = 13847L ERROR_IPSEC_IKE_PEER_CRL_FAILED = 13848L ERROR_IPSEC_IKE_POLICY_CHANGE = 13849L ERROR_IPSEC_IKE_NO_MM_POLICY = 13850L ERROR_IPSEC_IKE_NOTCBPRIV = 13851L ERROR_IPSEC_IKE_SECLOADFAIL = 13852L ERROR_IPSEC_IKE_FAILSSPINIT = 13853L ERROR_IPSEC_IKE_FAILQUERYSSP = 13854L ERROR_IPSEC_IKE_SRVACQFAIL = 13855L ERROR_IPSEC_IKE_SRVQUERYCRED = 13856L ERROR_IPSEC_IKE_GETSPIFAIL = 13857L ERROR_IPSEC_IKE_INVALID_FILTER = 13858L ERROR_IPSEC_IKE_OUT_OF_MEMORY = 13859L ERROR_IPSEC_IKE_ADD_UPDATE_KEY_FAILED = 13860L ERROR_IPSEC_IKE_INVALID_POLICY = 13861L ERROR_IPSEC_IKE_UNKNOWN_DOI = 13862L ERROR_IPSEC_IKE_INVALID_SITUATION = 13863L ERROR_IPSEC_IKE_DH_FAILURE = 13864L ERROR_IPSEC_IKE_INVALID_GROUP = 13865L ERROR_IPSEC_IKE_ENCRYPT = 13866L ERROR_IPSEC_IKE_DECRYPT = 13867L ERROR_IPSEC_IKE_POLICY_MATCH = 13868L ERROR_IPSEC_IKE_UNSUPPORTED_ID = 13869L ERROR_IPSEC_IKE_INVALID_HASH = 13870L ERROR_IPSEC_IKE_INVALID_HASH_ALG = 13871L ERROR_IPSEC_IKE_INVALID_HASH_SIZE = 13872L ERROR_IPSEC_IKE_INVALID_ENCRYPT_ALG = 13873L ERROR_IPSEC_IKE_INVALID_AUTH_ALG = 13874L ERROR_IPSEC_IKE_INVALID_SIG = 13875L ERROR_IPSEC_IKE_LOAD_FAILED = 13876L ERROR_IPSEC_IKE_RPC_DELETE = 13877L ERROR_IPSEC_IKE_BENIGN_REINIT = 13878L ERROR_IPSEC_IKE_INVALID_RESPONDER_LIFETIME_NOTIFY = 13879L ERROR_IPSEC_IKE_INVALID_CERT_KEYLEN = 13881L ERROR_IPSEC_IKE_MM_LIMIT = 13882L ERROR_IPSEC_IKE_NEGOTIATION_DISABLED = 13883L ERROR_IPSEC_IKE_NEG_STATUS_END = 13884L CRYPT_E_MSG_ERROR = ((-2146889727)) CRYPT_E_UNKNOWN_ALGO = ((-2146889726)) CRYPT_E_OID_FORMAT = ((-2146889725)) CRYPT_E_INVALID_MSG_TYPE = ((-2146889724)) CRYPT_E_UNEXPECTED_ENCODING = ((-2146889723)) CRYPT_E_AUTH_ATTR_MISSING = ((-2146889722)) CRYPT_E_HASH_VALUE = ((-2146889721)) CRYPT_E_INVALID_INDEX = ((-2146889720)) CRYPT_E_ALREADY_DECRYPTED = ((-2146889719)) CRYPT_E_NOT_DECRYPTED = ((-2146889718)) CRYPT_E_RECIPIENT_NOT_FOUND = ((-2146889717)) CRYPT_E_CONTROL_TYPE = ((-2146889716)) CRYPT_E_ISSUER_SERIALNUMBER = ((-2146889715)) CRYPT_E_SIGNER_NOT_FOUND = ((-2146889714)) CRYPT_E_ATTRIBUTES_MISSING = ((-2146889713)) CRYPT_E_STREAM_MSG_NOT_READY = ((-2146889712)) CRYPT_E_STREAM_INSUFFICIENT_DATA = ((-2146889711)) CRYPT_I_NEW_PROTECTION_REQUIRED = (0x00091012L) CRYPT_E_BAD_LEN = ((-2146885631)) CRYPT_E_BAD_ENCODE = ((-2146885630)) CRYPT_E_FILE_ERROR = ((-2146885629)) CRYPT_E_NOT_FOUND = ((-2146885628)) CRYPT_E_EXISTS = ((-2146885627)) CRYPT_E_NO_PROVIDER = ((-2146885626)) CRYPT_E_SELF_SIGNED = ((-2146885625)) CRYPT_E_DELETED_PREV = ((-2146885624)) CRYPT_E_NO_MATCH = ((-2146885623)) CRYPT_E_UNEXPECTED_MSG_TYPE = ((-2146885622)) CRYPT_E_NO_KEY_PROPERTY = ((-2146885621)) CRYPT_E_NO_DECRYPT_CERT = ((-2146885620)) CRYPT_E_BAD_MSG = ((-2146885619)) CRYPT_E_NO_SIGNER = ((-2146885618)) CRYPT_E_PENDING_CLOSE = ((-2146885617)) CRYPT_E_REVOKED = ((-2146885616)) CRYPT_E_NO_REVOCATION_DLL = ((-2146885615)) CRYPT_E_NO_REVOCATION_CHECK = ((-2146885614)) CRYPT_E_REVOCATION_OFFLINE = ((-2146885613)) CRYPT_E_NOT_IN_REVOCATION_DATABASE = ((-2146885612)) CRYPT_E_INVALID_NUMERIC_STRING = ((-2146885600)) CRYPT_E_INVALID_PRINTABLE_STRING = ((-2146885599)) CRYPT_E_INVALID_IA5_STRING = ((-2146885598)) CRYPT_E_INVALID_X500_STRING = ((-2146885597)) CRYPT_E_NOT_CHAR_STRING = ((-2146885596)) CRYPT_E_FILERESIZED = ((-2146885595)) CRYPT_E_SECURITY_SETTINGS = ((-2146885594)) CRYPT_E_NO_VERIFY_USAGE_DLL = ((-2146885593)) CRYPT_E_NO_VERIFY_USAGE_CHECK = ((-2146885592)) CRYPT_E_VERIFY_USAGE_OFFLINE = ((-2146885591)) CRYPT_E_NOT_IN_CTL = ((-2146885590)) CRYPT_E_NO_TRUSTED_SIGNER = ((-2146885589)) CRYPT_E_MISSING_PUBKEY_PARA = ((-2146885588)) CRYPT_E_OSS_ERROR = ((-2146881536)) ## Kerberos message types for LsaCallAuthenticationPackage (from ntsecapi.h) KerbDebugRequestMessage = 0 KerbQueryTicketCacheMessage = 1 KerbChangeMachinePasswordMessage = 2 KerbVerifyPacMessage = 3 KerbRetrieveTicketMessage = 4 KerbUpdateAddressesMessage = 5 KerbPurgeTicketCacheMessage = 6 KerbChangePasswordMessage = 7 KerbRetrieveEncodedTicketMessage = 8 KerbDecryptDataMessage = 9 KerbAddBindingCacheEntryMessage = 10 KerbSetPasswordMessage = 11 KerbSetPasswordExMessage = 12 KerbVerifyCredentialsMessage = 13 KerbQueryTicketCacheExMessage = 14 KerbPurgeTicketCacheExMessage = 15 KerbRefreshSmartcardCredentialsMessage = 16 KerbAddExtraCredentialsMessage = 17 KerbQuerySupplementalCredentialsMessage = 18 ## messages used with msv1_0 from ntsecapi.h MsV1_0Lm20ChallengeRequest = 0 MsV1_0Lm20GetChallengeResponse = 1 MsV1_0EnumerateUsers = 2 MsV1_0GetUserInfo = 3 MsV1_0ReLogonUsers = 4 MsV1_0ChangePassword = 5 MsV1_0ChangeCachedPassword = 6 MsV1_0GenericPassthrough = 7 MsV1_0CacheLogon = 8 MsV1_0SubAuth = 9 MsV1_0DeriveCredential = 10 MsV1_0CacheLookup = 11 MsV1_0SetProcessOption = 12 |
From: Mark H. <mha...@us...> - 2005-03-06 23:27:12
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25147/test Added Files: test_sspi.py Log Message: Some excellent sspi additions to win32security, and a number of tests and demos, originally from Roger Upole. --- NEW FILE: test_sspi.py --- # Some tests of the win32security sspi functions. # Stolen from Roger's original test_sspi.c, a version of which is in "Demos" # See also the other SSPI demos. import win32security, sspi, sspicon, win32api import unittest class TestSSPI(unittest.TestCase): def _doAuth(self, pkg_name): sspiclient=sspi.ClientAuth(pkg_name,targetspn=win32api.GetUserName()) sspiserver=sspi.ServerAuth(pkg_name) sec_buffer=None err = 1 while err != 0: err, sec_buffer = sspiclient.authorize(sec_buffer) err, sec_buffer = sspiserver.authorize(sec_buffer) return sspiclient, sspiserver def _doTestImpersonate(self, pkg_name): # Just for the sake of code exercising! sspiclient, sspiserver = self._doAuth(pkg_name) sspiserver.ctxt.ImpersonateSecurityContext() sspiserver.ctxt.RevertSecurityContext() def testImpersonateKerberos(self): self._doTestImpersonate("Kerberos") def testImpersonateNTLM(self): self._doTestImpersonate("NTLM") def _doTestEncrypt(self, pkg_name): sspiclient, sspiserver = self._doAuth(pkg_name) pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) msg='some data to be encrypted ......' trailersize=pkg_size_info['SecurityTrailer'] encbuf=win32security.SecBufferDescType() encbuf.append(win32security.SecBufferType(len(msg), sspicon.SECBUFFER_DATA)) encbuf.append(win32security.SecBufferType(trailersize, sspicon.SECBUFFER_TOKEN)) encbuf[0].Buffer=msg sspiclient.ctxt.EncryptMessage(0,encbuf,1) sspiserver.ctxt.DecryptMessage(encbuf,1) self.failUnlessEqual(msg, encbuf[0].Buffer) # and test the higher-level functions self.assertEqual(sspiserver.decrypt(sspiclient.encrypt("hello")), "hello") self.assertEqual(sspiclient.decrypt(sspiserver.encrypt("hello")), "hello") def testEncryptNTLM(self): self._doTestEncrypt("NTLM") def testEncryptKerberos(self): self._doTestEncrypt("Kerberos") def _doTestSign(self, pkg_name): sspiclient, sspiserver = self._doAuth(pkg_name) pkg_size_info=sspiclient.ctxt.QueryContextAttributes(sspicon.SECPKG_ATTR_SIZES) msg='some data to be encrypted ......' sigsize=pkg_size_info['MaxSignature'] sigbuf=win32security.SecBufferDescType() sigbuf.append(win32security.SecBufferType(len(msg), sspicon.SECBUFFER_DATA)) sigbuf.append(win32security.SecBufferType(sigsize, sspicon.SECBUFFER_TOKEN)) sigbuf[0].Buffer=msg sspiclient.ctxt.MakeSignature(0,sigbuf,1) sspiserver.ctxt.VerifySignature(sigbuf,1) # and test the higher-level functions self.assertEqual(sspiserver.unsign(sspiclient.sign("hello")), "hello") # and the other way self.assertEqual(sspiclient.unsign(sspiserver.sign("hello")), "hello") def testSignNTLM(self): self._doTestSign("NTLM") def testSignKerberos(self): self._doTestSign("Kerberos") if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2005-03-06 13:15:23
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29244 Modified Files: PyWinTypesmodule.cpp Log Message: Correct brace placement loading function pointers from AdvAPI32.dll Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyWinTypesmodule.cpp 30 Nov 2004 21:30:29 -0000 1.18 --- PyWinTypesmodule.cpp 6 Mar 2005 13:15:06 -0000 1.19 *************** *** 593,600 **** if (fp) addauditaccessobjectace=(BOOL (WINAPI *)(PACL,DWORD,DWORD,DWORD,GUID*,GUID*,PSID,BOOL,BOOL))(fp); - } fp=GetProcAddress(hmodule,"SetSecurityDescriptorControl"); if (fp) setsecuritydescriptorcontrol=(BOOL (WINAPI *)(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL))(fp); #endif // NO_PYWINTYPES_SECURITY --- 593,600 ---- if (fp) addauditaccessobjectace=(BOOL (WINAPI *)(PACL,DWORD,DWORD,DWORD,GUID*,GUID*,PSID,BOOL,BOOL))(fp); fp=GetProcAddress(hmodule,"SetSecurityDescriptorControl"); if (fp) setsecuritydescriptorcontrol=(BOOL (WINAPI *)(PSECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_CONTROL, SECURITY_DESCRIPTOR_CONTROL))(fp); + } #endif // NO_PYWINTYPES_SECURITY |
From: Mark H. <mha...@us...> - 2005-03-06 10:45:37
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/security/sspi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20609/sspi Log Message: Directory /cvsroot/pywin32/pywin32/win32/Demos/security/sspi added to the repository |
From: Mark H. <mha...@us...> - 2005-03-05 05:53:47
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19087 Modified Files: testall.py Log Message: Always avoid trying to import _winxptheme (ideally we should check the platform - later!) Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/testall.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** testall.py 2 Nov 2003 10:15:43 -0000 1.3 --- testall.py 5 Mar 2005 05:53:39 -0000 1.4 *************** *** 13,19 **** base, ext = os.path.splitext(name) if (ext==".pyd") and \ (is_debug and base.endswith("_d") or \ not is_debug and not base.endswith("_d")): ! __import__(base) num += 1 --- 13,24 ---- base, ext = os.path.splitext(name) if (ext==".pyd") and \ + name != "_winxptheme.pyd" and \ (is_debug and base.endswith("_d") or \ not is_debug and not base.endswith("_d")): ! try: ! __import__(base) ! except ImportError: ! print "FAILED to import", name ! raise num += 1 |
From: Mark H. <mha...@us...> - 2005-03-05 05:06:40
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9127 Modified Files: win32pdhutil.py Log Message: [ 1051453 ] win32pdhutil.browse broken (intentionally?) It was indeed unintentional! Index: win32pdhutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32pdhutil.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** win32pdhutil.py 25 Apr 2004 07:44:41 -0000 1.8 --- win32pdhutil.py 5 Mar 2005 05:06:31 -0000 1.9 *************** *** 133,141 **** def browse( callback = BrowseCallBackDemo, title="Python Browser", level=win32pdh.PERF_DETAIL_WIZARD): ! print "Virtual Bytes = ", FindPerformanceAttributesByName("python", counter="Virtual Bytes") ! print "Available Bytes = ", GetPerformanceAttributes("Memory", "Available Bytes") if __name__=='__main__': ShowAllProcesses() print "Browsing for counters..." browse() --- 133,144 ---- def browse( callback = BrowseCallBackDemo, title="Python Browser", level=win32pdh.PERF_DETAIL_WIZARD): ! win32pdh.BrowseCounters(None,0, callback, level, title) if __name__=='__main__': ShowAllProcesses() + # Show how to get a couple of attributes by name. + print "Virtual Bytes = ", FindPerformanceAttributesByName("python", counter="Virtual Bytes") + print "Available Bytes = ", GetPerformanceAttributes("Memory", "Available Bytes") + # And a browser. print "Browsing for counters..." browse() |
From: Mark H. <mha...@us...> - 2005-03-05 05:00:03
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7588 Modified Files: win32gui.i Log Message: GetWindowText was returning Unicode for an empty string, and string objects otherwise. That is insane - it always returns a string now. Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** win32gui.i 10 Feb 2005 23:56:02 -0000 1.57 --- win32gui.i 5 Mar 2005 04:59:52 -0000 1.58 *************** *** 1801,1805 **** len = GetWindowText(hwnd, buffer, sizeof(buffer)/sizeof(TCHAR)); Py_END_ALLOW_THREADS ! if (len == 0) return PyUnicodeObject_FromString(""); return PyWinObject_FromTCHAR(buffer, len); } --- 1801,1807 ---- len = GetWindowText(hwnd, buffer, sizeof(buffer)/sizeof(TCHAR)); Py_END_ALLOW_THREADS ! // @comm Note that previous versions of PyWin32 returned a (empty) Unicode ! // object when the string was empty, or an MBCS encoded string value ! // otherwise. A String is now returned in all cases. return PyWinObject_FromTCHAR(buffer, len); } |
From: Mark H. <mha...@us...> - 2005-03-05 04:57:19
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7152 Modified Files: win32font.cpp Log Message: Fix [ 1037571 ] PyCFont should have .GetSafeHandle() Index: win32font.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32font.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32font.cpp 15 Apr 2002 15:17:49 -0000 1.2 --- win32font.cpp 5 Mar 2005 04:57:04 -0000 1.3 *************** *** 65,72 **** --- 65,82 ---- } + // @pymethod int|PyCFont|GetSafeHandle|Retrieves the HFONT for the font as an integer + static PyObject *PyCFont_GetSafeHandle(PyObject *self, PyObject *args) + { + CHECK_NO_ARGS2(args, "GetSafeHandle"); + CFont *pFont = PyCFont::GetFont(self); + if (pFont==NULL) return NULL; + return PyInt_FromLong((long)pFont->GetSafeHandle()); + } + // @object PyCFont|A windows font object. Encapsulates an MFC <c CFont> class. // Derived from a <o PyCGDIObject>. static struct PyMethodDef ui_font_methods[] = { + {"GetSafeHandle", PyCFont_GetSafeHandle, 1}, // @pymeth GetSafeHandle|Retrieves the HFONT for the font as an integer {NULL, NULL} // sentinel }; |
From: Mark H. <mha...@us...> - 2005-03-05 04:50:59
|
Update of /cvsroot/pywin32/pywin32/win32/src/PerfMon In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6053 Modified Files: MappingManager.cpp perfmondata.cpp Log Message: perfmon side of [ 1067148 ] win32trace and perfmon fail to load on Windows NT Index: MappingManager.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/MappingManager.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MappingManager.cpp 13 Sep 2004 01:49:35 -0000 1.2 --- MappingManager.cpp 5 Mar 2005 04:50:47 -0000 1.3 *************** *** 42,46 **** BOOL MappingManager::Init(const TCHAR *szServiceName, const TCHAR *szMappingName /* = NULL */, const TCHAR *szEventSourceName /* = NULL */) { ! TCHAR szGlobalMapping[MAX_PATH+10]; --- 42,46 ---- BOOL MappingManager::Init(const TCHAR *szServiceName, const TCHAR *szMappingName /* = NULL */, const TCHAR *szEventSourceName /* = NULL */) { ! TCHAR szGlobalMapping[MAX_PATH+10] = _T(""); *************** *** 50,55 **** szEventSourceName = szServiceName; - _tcscpy(szGlobalMapping, _T("Global\\")); _tcscat(szGlobalMapping, szMappingName); --- 50,61 ---- szEventSourceName = szServiceName; + // Use a TerminalServices friendly "Global\\" prefix if supported. + OSVERSIONINFO info; + info.dwOSVersionInfoSize = sizeof(info); + GetVersionEx(&info); + if (info.dwMajorVersion > 4) + // 2000 or later - "Global\\" prefix OK. + _tcscpy(szGlobalMapping, _T("Global\\")); _tcscat(szGlobalMapping, szMappingName); Index: perfmondata.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/perfmondata.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** perfmondata.cpp 13 Sep 2004 01:49:35 -0000 1.2 --- perfmondata.cpp 5 Mar 2005 04:50:48 -0000 1.3 *************** *** 148,155 **** DWORD type; TCHAR registryKeyName[MAX_PATH]; ! TCHAR szFileMapping[MAX_PATH+10]; ! _tcscpy(szFileMapping, _T("Global\\")); ! _tcscat(szFileMapping, szModuleName); // --- 148,161 ---- DWORD type; TCHAR registryKeyName[MAX_PATH]; ! TCHAR szFileMapping[MAX_PATH+10] = _T(""); ! // Use a TerminalServices friendly "Global\\" prefix if supported. ! OSVERSIONINFO info; ! info.dwOSVersionInfoSize = sizeof(info); ! GetVersionEx(&info); ! if (info.dwMajorVersion > 4) ! // 2000 or later - "Global\\" prefix OK. ! _tcscpy(szFileMapping, _T("Global\\")); ! _tcscat(szFileMapping, szModuleName); // |
From: Mark H. <mha...@us...> - 2005-03-05 04:42:48
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4695 Modified Files: win32apimodule.cpp Log Message: Fix [ 1075751 ] SetConsoleCtrlHandler rejects ctrlHandler=None and also report errors calling ::SetConsoleCtrlHandler Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** win32apimodule.cpp 4 Mar 2005 11:50:32 -0000 1.46 --- win32apimodule.cpp 5 Mar 2005 04:42:38 -0000 1.47 *************** *** 4563,4566 **** --- 4563,4573 ---- if (!PyArg_ParseTuple(args, "O|i:SetConsoleCtrlHandler", &func, &bAdd)) return NULL; + // Handle special case of None first + if (func == Py_None) { + if (!SetConsoleCtrlHandler(NULL, bAdd)) + return ReturnAPIError("SetConsoleCtrlHandler"); + Py_INCREF(Py_None); + return Py_None; + } if (!PyCallable_Check(func)) return PyErr_Format(PyExc_TypeError, *************** *** 4573,4582 **** return NULL; if (bAdd) { if (0 != PyList_Append(consoleControlHandlers, func)) return NULL; if (!addedCtrlHandler) { ! SetConsoleCtrlHandler(PyCtrlHandler, TRUE); ! addedCtrlHandler = TRUE; } } else { --- 4580,4590 ---- return NULL; + BOOL ok = TRUE; // we may not actually make the call! if (bAdd) { if (0 != PyList_Append(consoleControlHandlers, func)) return NULL; if (!addedCtrlHandler) { ! ok = SetConsoleCtrlHandler(PyCtrlHandler, TRUE); ! addedCtrlHandler = ok; } } else { *************** *** 4593,4600 **** return PyErr_Format(PyExc_ValueError, "The object has not been registered"); if (addedCtrlHandler && PyList_Size(consoleControlHandlers)==0) { ! SetConsoleCtrlHandler(PyCtrlHandler, FALSE); addedCtrlHandler = FALSE; } } Py_INCREF(Py_None); return Py_None; --- 4601,4610 ---- return PyErr_Format(PyExc_ValueError, "The object has not been registered"); if (addedCtrlHandler && PyList_Size(consoleControlHandlers)==0) { ! ok = SetConsoleCtrlHandler(PyCtrlHandler, FALSE); addedCtrlHandler = FALSE; } } + if (!ok) + return ReturnAPIError("SetConsoleCtrlHandler"); Py_INCREF(Py_None); return Py_None; |
From: Mark H. <mha...@us...> - 2005-03-05 03:24:23
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19393/pywin/framework Modified Files: intpyapp.py Log Message: Hopefully a final fix for "[ 944506 ] PythonWin Menus don't work" and many other bugs relating to the registry filling up with toolbar registry entries. The problem was the fact that the debugging package dynamically created docable toolbars. When pythonwin started for the first time, references to these debugging toolbars caused MFC to get upset, and left the "stale" entries for those toolbars in the list. Later, when a debugging session started, these toolbars again got new entries which were written to the registry along with the old ones. Next startup, the cycle started again (but this time creating even more new ones, ignoring even more stale ones) Also incorporates [ 1101347 ] Docking toolbar AV at shut down from Greg Chapman, which was also reflected in other bugs relating to the task-bar icon remaining and the MRU menus not updating in Python 2.4. Index: intpyapp.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpyapp.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** intpyapp.py 9 Apr 2004 11:31:57 -0000 1.8 --- intpyapp.py 5 Mar 2005 03:24:13 -0000 1.9 *************** *** 29,41 **** tb.EnableDocking(afxres.CBRS_ALIGN_ANY) tb.SetWindowText("Standard") - - tbd = win32ui.CreateToolBar (self, style, win32ui.ID_VIEW_TOOLBAR_DBG) - tbd.ModifyStyle(0, commctrl.TBSTYLE_FLAT) - tbd.LoadToolBar(win32ui.IDR_DEBUGGER) - tbd.EnableDocking(afxres.CBRS_ALIGN_ANY) - tbd.SetWindowText("Debugger") - self.DockControlBar(tb) ! self.DockControlBar(tbd) # And a "Tools" menu on the main frame. menu = self.GetMenu() --- 29,38 ---- tb.EnableDocking(afxres.CBRS_ALIGN_ANY) tb.SetWindowText("Standard") self.DockControlBar(tb) ! # Any other packages which use toolbars ! from pywin.debugger.debugger import PrepareControlBars ! PrepareControlBars(self) ! # Note "interact" also uses dockable windows, but they already happen ! # And a "Tools" menu on the main frame. menu = self.GetMenu() *************** *** 64,69 **** --- 61,77 ---- from pywin.framework import help help.FinalizeHelp() + + self.DestroyControlBar(afxres.AFX_IDW_TOOLBAR) + self.DestroyControlBar(win32ui.ID_VIEW_TOOLBAR_DBG) return self._obj_.OnClose() + + def DestroyControlBar(self, id): + try: + bar = self.GetControlBar(id) + except win32ui.error: + return + bar.DestroyWindow() + def OnCommand(self, wparam, lparam): # By default, the current MDI child frame will process WM_COMMAND |
From: Mark H. <mha...@us...> - 2005-03-05 03:24:23
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19393/pywin/debugger Modified Files: debugger.py Log Message: Hopefully a final fix for "[ 944506 ] PythonWin Menus don't work" and many other bugs relating to the registry filling up with toolbar registry entries. The problem was the fact that the debugging package dynamically created docable toolbars. When pythonwin started for the first time, references to these debugging toolbars caused MFC to get upset, and left the "stale" entries for those toolbars in the list. Later, when a debugging session started, these toolbars again got new entries which were written to the registry along with the old ones. Next startup, the cycle started again (but this time creating even more new ones, ignoring even more stale ones) Also incorporates [ 1101347 ] Docking toolbar AV at shut down from Greg Chapman, which was also reflected in other bugs relating to the task-bar icon remaining and the MRU menus not updating in Python 2.4. Index: debugger.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/debugger/debugger.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** debugger.py 9 Oct 2004 05:53:33 -0000 1.14 --- debugger.py 5 Mar 2005 03:24:12 -0000 1.15 *************** *** 127,135 **** class HierListDebugger(hierlist.HierListWithItems): """ Hier List of stack frames, breakpoints, whatever """ ! def __init__(self, debugger): ! self.debugger = debugger hierlist.HierListWithItems.__init__(self, None, win32ui.IDB_DEBUGGER_HIER, None, win32api.RGB(255,0,0)) ! def Setup(self): ! root = HierStackRoot(self.debugger) self.AcceptRoot(root) # def Refresh(self): --- 127,134 ---- class HierListDebugger(hierlist.HierListWithItems): """ Hier List of stack frames, breakpoints, whatever """ ! def __init__(self): hierlist.HierListWithItems.__init__(self, None, win32ui.IDB_DEBUGGER_HIER, None, win32api.RGB(255,0,0)) ! def Setup(self, debugger): ! root = HierStackRoot(debugger) self.AcceptRoot(root) # def Refresh(self): *************** *** 137,140 **** --- 136,146 ---- class DebuggerWindow(window.Wnd): + def __init__(self, ob): + window.Wnd.__init__(self, ob) + self.debugger = None + + def Init(self, debugger): + self.debugger = debugger + def GetDefRect(self): defRect = app.LoadWindowSize("Debugger Windows\\" + self.title) *************** *** 172,179 **** class DebuggerStackWindow(DebuggerWindow): title = "Stack" ! def __init__(self, debugger): DebuggerWindow.__init__(self, win32ui.CreateTreeCtrl()) ! self.list = HierListDebugger(debugger) ! self.listOK = 1 def SaveState(self): self.list.DeleteAllItems() --- 178,185 ---- class DebuggerStackWindow(DebuggerWindow): title = "Stack" ! def __init__(self): DebuggerWindow.__init__(self, win32ui.CreateTreeCtrl()) ! self.list = HierListDebugger() ! self.listOK = 0 def SaveState(self): self.list.DeleteAllItems() *************** *** 185,194 **** self.HookMessage(self.OnKeyDown, win32con.WM_SYSKEYDOWN) self.list.HierInit (parent, self) ! self.list.Setup() def RespondDebuggerState(self, state): if not self.listOK: self.listOK = 1 ! self.list.Setup() else: self.list.Refresh() --- 191,202 ---- self.HookMessage(self.OnKeyDown, win32con.WM_SYSKEYDOWN) self.list.HierInit (parent, self) ! self.listOK = 0 # delayed setup ! #self.list.Setup() def RespondDebuggerState(self, state): + assert self.debugger is not None, "Init not called" if not self.listOK: self.listOK = 1 ! self.list.Setup(self.debugger) else: self.list.Refresh() *************** *** 212,218 **** class DebuggerListViewWindow(DebuggerWindow): ! def __init__(self, debugger): DebuggerWindow.__init__(self, win32ui.CreateListCtrl()) - self.debugger = debugger def CreateWindow(self, parent): list = self --- 220,225 ---- class DebuggerListViewWindow(DebuggerWindow): ! def __init__(self): DebuggerWindow.__init__(self, win32ui.CreateListCtrl()) def CreateWindow(self, parent): list = self *************** *** 396,401 **** self.SetItemText(i, 1, val) ! def CreateDebuggerDialog(parent, klass, debugger): ! control = klass(debugger) control.CreateWindow(parent) return control --- 403,408 ---- self.SetItemText(i, 1, val) ! def CreateDebuggerDialog(parent, klass): ! control = klass() control.CreateWindow(parent) return control *************** *** 407,410 **** --- 414,450 ---- ) + # Prepare all the "control bars" for this package. + # If control bars are not all loaded when the toolbar-state functions are + # called, things go horribly wrong. + def PrepareControlBars(frame): + style = win32con.WS_CHILD | afxres.CBRS_SIZE_DYNAMIC | afxres.CBRS_TOP | afxres.CBRS_TOOLTIPS | afxres.CBRS_FLYBY + tbd = win32ui.CreateToolBar (frame, style, win32ui.ID_VIEW_TOOLBAR_DBG) + tbd.ModifyStyle(0, commctrl.TBSTYLE_FLAT) + tbd.LoadToolBar(win32ui.IDR_DEBUGGER) + tbd.EnableDocking(afxres.CBRS_ALIGN_ANY) + tbd.SetWindowText("Debugger") + frame.DockControlBar(tbd) + + # and the other windows. + for id, klass, float in DebuggerDialogInfos: + try: + frame.GetControlBar(id) + exists=1 + except win32ui.error: + exists=0 + if exists: continue + bar = pywin.docking.DockingBar.DockingBar() + style=win32con.WS_CHILD | afxres.CBRS_LEFT # don't create visible. + bar.CreateWindow(frame, CreateDebuggerDialog, klass.title, id, style, childCreatorArgs=(klass,)) + bar.SetBarStyle( bar.GetBarStyle()|afxres.CBRS_TOOLTIPS|afxres.CBRS_FLYBY|afxres.CBRS_SIZE_DYNAMIC) + bar.EnableDocking(afxres.CBRS_ALIGN_ANY) + if float is None: + frame.DockControlBar(bar) + else: + frame.FloatControlBar(bar, float, afxres.CBRS_ALIGN_ANY) + + frame.ShowControlBar(bar, 0, 1) + + SKIP_NONE=0 SKIP_STEP=1 *************** *** 459,467 **** frame = win32ui.GetMainFrame() ! # See bug [ 944506 ] PythonWin Menus don't work ! # This relieves most of the symptoms, but I'd love ! # to know what is going on. Sounds alot like ! # Q151446, but that is for MFC4, and doesn't fix it. ! # frame.SaveBarState("ToolbarDebugging") # Hide the debuger toolbars (as they wont normally form part of the main toolbar state. for id, klass, float in DebuggerDialogInfos: --- 499,503 ---- frame = win32ui.GetMainFrame() ! frame.SaveBarState("ToolbarDebugging") # Hide the debuger toolbars (as they wont normally form part of the main toolbar state. for id, klass, float in DebuggerDialogInfos: *************** *** 745,764 **** frame = win32ui.GetMainFrame() ! # And the other dockable debugger dialogs. for id, klass, float in DebuggerDialogInfos: ! try: ! frame.GetControlBar(id) ! exists=1 ! except win32ui.error: ! exists=0 ! if exists: continue ! bar = pywin.docking.DockingBar.DockingBar() ! bar.CreateWindow(win32ui.GetMainFrame(), CreateDebuggerDialog, klass.title, id, childCreatorArgs=(klass, self)) ! bar.SetBarStyle( bar.GetBarStyle()|afxres.CBRS_TOOLTIPS|afxres.CBRS_FLYBY|afxres.CBRS_SIZE_DYNAMIC) ! bar.EnableDocking(afxres.CBRS_ALIGN_ANY) ! if float is None: ! frame.DockControlBar(bar) ! else: ! frame.FloatControlBar(bar, float, afxres.CBRS_ALIGN_ANY) try: frame.LoadBarState("ToolbarDebugging") --- 781,789 ---- frame = win32ui.GetMainFrame() ! # Ensure the debugger windows are attached to the debugger. for id, klass, float in DebuggerDialogInfos: ! w = frame.GetControlBar(id).dialog ! w.Init(self) ! try: frame.LoadBarState("ToolbarDebugging") |
From: Mark H. <mha...@us...> - 2005-03-05 03:24:20
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19393 Modified Files: win32uiExt.h Log Message: Hopefully a final fix for "[ 944506 ] PythonWin Menus don't work" and many other bugs relating to the registry filling up with toolbar registry entries. The problem was the fact that the debugging package dynamically created docable toolbars. When pythonwin started for the first time, references to these debugging toolbars caused MFC to get upset, and left the "stale" entries for those toolbars in the list. Later, when a debugging session started, these toolbars again got new entries which were written to the registry along with the old ones. Next startup, the cycle started again (but this time creating even more new ones, ignoring even more stale ones) Also incorporates [ 1101347 ] Docking toolbar AV at shut down from Greg Chapman, which was also reflected in other bugs relating to the task-bar icon remaining and the MRU menus not updating in Python 2.4. Index: win32uiExt.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiExt.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32uiExt.h 24 Sep 2004 07:34:08 -0000 1.5 --- win32uiExt.h 5 Mar 2005 03:24:11 -0000 1.6 *************** *** 147,158 **** } void _BaseOnClose() { - __try { T::OnClose(); - } - __except (EXCEPTION_EXECUTE_HANDLER) { - // *sob* - no idea what is causing this in VC7 (other than vaguely - // "docking toolbars" - ; - } } afx_msg void OnPaletteChanged(CWnd* pFocusWnd) { --- 147,151 ---- |
From: Mark H. <mha...@us...> - 2005-03-05 03:17:32
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/dialogs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18684 Modified Files: status.py Log Message: Allow the threaded status dialog to work in a pythonwin environment. Index: status.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/dialogs/status.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** status.py 1 Jun 2002 08:16:42 -0000 1.2 --- status.py 5 Mar 2005 03:17:22 -0000 1.3 *************** *** 6,9 **** --- 6,10 ---- import win32con import win32api + import time def MakeProgressDlgTemplate(caption, staticText = ""): *************** *** 184,188 **** t = ProgressThread(title, msg, maxticks) t.CreateThread() ! t.createdEvent.wait(10) # timeout if things go terribly wrong. return t.dialog --- 185,199 ---- t = ProgressThread(title, msg, maxticks) t.CreateThread() ! # Need to run a basic "PumpWaitingMessages" loop just incase we are ! # running inside Pythonwin. ! # Basic timeout incase things go terribly wrong. Ideally we should use ! # win32event.MsgWaitForMultipleObjects(), but we use a threading module ! # event - so use a dumb strategy ! end_time = time.time() + 10 ! while time.time() < end_time: ! if t.createdEvent.isSet(): ! break ! win32ui.PumpWaitingMessages() ! time.sleep(0.1) return t.dialog |
From: Mark H. <mha...@us...> - 2005-03-05 03:16:43
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18435 Modified Files: win32thread.cpp Log Message: m_nDisablePumpCount wasn't removed in MFC7, just moved. This should prevent some debugging assertions in Python 2.4 Index: win32thread.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32thread.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32thread.cpp 7 Oct 2004 08:45:24 -0000 1.6 --- win32thread.cpp 5 Mar 2005 03:16:34 -0000 1.7 *************** *** 120,125 **** // pump message, but quit on WM_QUIT if (!PumpMessage()) { ! #if defined(_DEBUG) && _MFC_VER < 0x0710 m_nDisablePumpCount--; // application must NOT die #endif return; --- 120,129 ---- // pump message, but quit on WM_QUIT if (!PumpMessage()) { ! #if defined(_DEBUG) ! # if _MFC_VER < 0x0710 m_nDisablePumpCount--; // application must NOT die + # else + pState->m_nDisablePumpCount--; // application must NOT die + # endif #endif return; |
From: Mark H. <mha...@us...> - 2005-03-05 03:15:34
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/Demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18241 Modified Files: toolbar.py Log Message: Ensure the toolbar sample uses a unique toolbar ID Index: toolbar.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/Demos/toolbar.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** toolbar.py 1 Sep 1999 23:33:35 -0000 1.1 --- toolbar.py 5 Mar 2005 03:15:25 -0000 1.2 *************** *** 25,29 **** buttons = (win32ui.ID_APP_ABOUT,win32ui.ID_VIEW_INTERACTIVE) bitmap = win32ui.IDB_BROWSER_HIER ! self.toolbar = tb = win32ui.CreateToolBar (parent, style) tb.LoadBitmap(bitmap) tb.SetButtons(buttons) --- 25,30 ---- buttons = (win32ui.ID_APP_ABOUT,win32ui.ID_VIEW_INTERACTIVE) bitmap = win32ui.IDB_BROWSER_HIER ! tbid = 0xE840 ! self.toolbar = tb = win32ui.CreateToolBar (parent, style, tbid) tb.LoadBitmap(bitmap) tb.SetButtons(buttons) |
From: Mark H. <mha...@us...> - 2005-03-04 23:50:05
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29063 Modified Files: __init__.py Log Message: Fix [ 1097153 ] DispatchWithEvents always rebuild makepy support We were checking the instance for CLSID, but it is the class that has it. Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** __init__.py 20 Jan 2004 01:54:33 -0000 1.32 --- __init__.py 4 Mar 2005 23:49:56 -0000 1.33 *************** *** 242,246 **** # Create/Get the object. disp = Dispatch(clsid) ! if not disp.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it. try: ti = disp._oleobj_.GetTypeInfo() --- 242,246 ---- # Create/Get the object. disp = Dispatch(clsid) ! if not disp.__class__.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it. try: ti = disp._oleobj_.GetTypeInfo() *************** *** 294,298 **** """ disp = Dispatch(disp) ! if not disp.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it. try: ti = disp._oleobj_.GetTypeInfo() --- 294,298 ---- """ disp = Dispatch(disp) ! if not disp.__class__.__dict__.get("CLSID"): # Eeek - no makepy support - try and build it. try: ti = disp._oleobj_.GetTypeInfo() |
From: Mark H. <mha...@us...> - 2005-03-04 11:57:24
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7597 Modified Files: PyTime.cpp Log Message: Allow any date-like object for any method wanting a win32 time object (eg, datetime objects can be passed directly to COM, win32file.SetFileTime, etc) Index: PyTime.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyTime.cpp 26 May 2004 08:30:41 -0000 1.12 --- PyTime.cpp 4 Mar 2005 11:56:55 -0000 1.13 *************** *** 36,51 **** } ! // @pymethod <o PyTime>|pywintypes|Time|Creates a new time object. ! PyObject *PyWinMethod_NewTime(PyObject *self, PyObject *args) { - PyObject *timeOb; - // @pyparm object|timeRepr||An integer/float/tuple time representation. - // @comm Note that the parameter can be any object that supports - // int(object) - for example , another PyTime object. - // <nl>The integer should be as defined by the Python time module. - // See the description of the <o PyTime> object for more information. - if ( !PyArg_ParseTuple(args, "O", &timeOb) ) - return NULL; - PyObject *result = NULL; /***** Commented out temporarily --- 36,41 ---- } ! PyObject *PyWin_NewTime(PyObject *timeOb) { PyObject *result = NULL; /***** Commented out temporarily *************** *** 100,109 **** } else ! { ! PyErr_BadArgument(); return NULL; - } ! return result; } --- 90,111 ---- } else ! return PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be used as a time object", ! timeOb->ob_type->tp_name); ! return result; ! } ! ! // @pymethod <o PyTime>|pywintypes|Time|Creates a new time object. ! PyObject *PyWinMethod_NewTime(PyObject *self, PyObject *args) ! { ! PyObject *timeOb; ! // @pyparm object|timeRepr||An integer/float/tuple time representation. ! // @comm Note that the parameter can be any object that supports ! // int(object) - for example , another PyTime object. ! // <nl>The integer should be as defined by the Python time module. ! // See the description of the <o PyTime> object for more information. ! if ( !PyArg_ParseTuple(args, "O", &timeOb) ) return NULL; ! return PyWin_NewTime(timeOb); } *************** *** 127,152 **** BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) { if (!PyTime_Check(ob)) { ! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object"); ! return FALSE; } ! return ((PyTime *)ob)->GetTime(pDate); } BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate) { if (!PyTime_Check(ob)) { ! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object"); ! return FALSE; } ! return ((PyTime *)ob)->GetTime(pDate); } BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate) { if (!PyTime_Check(ob)) { ! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object"); ! return FALSE; } ! return ((PyTime *)ob)->GetTime(pDate); } --- 129,169 ---- BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate) { + PyObject *newref = NULL; + BOOL rc; if (!PyTime_Check(ob)) { ! if (!(ob = PyWin_NewTime(ob))) ! return FALSE; ! newref = ob; } ! rc = ((PyTime *)ob)->GetTime(pDate); ! Py_XDECREF(newref); ! return rc; } BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate) { + PyObject *newref = NULL; + BOOL rc; if (!PyTime_Check(ob)) { ! if (!(ob = PyWin_NewTime(ob))) ! return FALSE; ! newref = ob; } ! rc = ((PyTime *)ob)->GetTime(pDate); ! Py_XDECREF(newref); ! return rc; } BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate) { + PyObject *newref = NULL; + BOOL rc; if (!PyTime_Check(ob)) { ! if (!(ob = PyWin_NewTime(ob))) ! return FALSE; ! newref = ob; } ! rc = ((PyTime *)ob)->GetTime(pDate); ! Py_XDECREF(newref); ! return rc; } |
From: Mark H. <mha...@us...> - 2005-03-04 11:51:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6593/src Modified Files: win32apimodule.cpp Log Message: Add GetDateFormat/GetTimeFormat Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** win32apimodule.cpp 9 Feb 2005 08:18:52 -0000 1.45 --- win32apimodule.cpp 4 Mar 2005 11:50:32 -0000 1.46 *************** *** 1835,1838 **** --- 1835,1888 ---- } + // @pymethod string|win32api|GetDateFormat|Formats a date as a date string for a specified locale. The function formats either a specified date or the local system date. + static PyObject *PyGetDateFormat(PyObject *self, PyObject *args) + { + int locale, flags; + PyObject *obTime; + char *szFormat = NULL; + if (!PyArg_ParseTuple(args, "iiO|z:GetDateFormat", + &locale, // @pyparm int|locale|| + &flags, // @pyparm int|flags|| + &obTime, // @pyparm <o PyTime>|time||The time to use, or None to use the current time. + &szFormat)) // @pyparm string|format||May be None + return NULL; + SYSTEMTIME st, *pst = NULL; + if (obTime != Py_None) { + if (!PyWinObject_AsSYSTEMTIME(obTime, &st)) + return NULL; + pst = &st; + } + char buf[512]; + int nchars = ::GetDateFormat(locale, flags, pst, szFormat, buf, sizeof(buf)/sizeof(buf)[0]); + if (nchars==0) + return PyWin_SetAPIError("GetDateFormat"); + return PyString_FromStringAndSize(buf, nchars-1); + } + + // @pymethod string|win32api|GetTimeFormat|Formats a time as a time string for a specified locale. The function formats either a specified time or the local system time. + static PyObject *PyGetTimeFormat(PyObject *self, PyObject *args) + { + int locale, flags; + PyObject *obTime; + char *szFormat = NULL; + if (!PyArg_ParseTuple(args, "iiO|z:GetTimeFormat", + &locale, // @pyparm int|locale|| + &flags, // @pyparm int|flags|| + &obTime, // @pyparm <o PyTime>|time||The time to use, or None to use the current time. + &szFormat)) // @pyparm string|format||May be None + return NULL; + SYSTEMTIME st, *pst = NULL; + if (obTime != Py_None) { + if (!PyWinObject_AsSYSTEMTIME(obTime, &st)) + return NULL; + pst = &st; + } + char buf[512]; + int nchars = ::GetTimeFormat(locale, flags, pst, szFormat, buf, sizeof(buf)/sizeof(buf)[0]); + if (nchars==0) + return PyWin_SetAPIError("GetTimeFormat"); + return PyString_FromStringAndSize(buf, nchars-1); + } + // @pymethod int|win32api|GetSysColor|Returns the current system color for the specified element. static PyObject * *************** *** 4605,4608 **** --- 4655,4659 ---- {"GetCurrentProcess", PyGetCurrentProcess, 1}, // @pymeth GetCurrentProcess|Returns a pseudohandle for the current process. {"GetConsoleTitle", PyGetConsoleTitle, 1}, // @pymeth GetConsoleTitle|Return the application's console title. + {"GetDateFormat", PyGetDateFormat, 1}, // @pymeth GetDateFormat|Formats a date as a date string for a specified locale. {"GetDiskFreeSpace", PyGetDiskFreeSpace, 1}, // @pymeth GetDiskFreeSpace|Retrieves information about a disk. {"GetDiskFreeSpaceEx", PyGetDiskFreeSpaceEx, 1}, // @pymeth GetDiskFreeSpaceEx|Retrieves information about a disk. *************** *** 4638,4641 **** --- 4689,4693 ---- {"GetThreadLocale", PyGetThreadLocale, 1}, // @pymeth GetThreadLocale|Returns the current thread's locale. {"GetTickCount", PyGetTickCount, 1}, // @pymeth GetTickCount|Returns the milliseconds since windows started. + {"GetTimeFormat", PyGetTimeFormat, 1}, // @pymeth GetTimeFormat|Formats a time as a time string for a specified locale. {"GetTimeZoneInformation", PyGetTimeZoneInformation,1}, // @pymeth GetTimeZoneInformation|Returns the system time-zone information. {"GetVersion", PyGetVersion, 1}, // @pymeth GetVersion|Returns Windows version information. |
From: Mark H. <mha...@us...> - 2005-03-04 11:51:00
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6593/test Modified Files: test_win32api.py Log Message: Add GetDateFormat/GetTimeFormat Index: test_win32api.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32api.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_win32api.py 13 Jul 2004 07:12:46 -0000 1.7 --- test_win32api.py 4 Mar 2005 11:50:32 -0000 1.8 *************** *** 11,15 **** self.failUnless(name == win32api.GetUserNameEx(win32api.NameSamCompatible)) ! class TimeZone(unittest.TestCase): def testTimezone(self): # GetTimeZoneInformation --- 11,15 ---- self.failUnless(name == win32api.GetUserNameEx(win32api.NameSamCompatible)) ! class TestTime(unittest.TestCase): def testTimezone(self): # GetTimeZoneInformation *************** *** 21,26 **** tz_str = tzinfo[1] tz_time = tzinfo[2] ! print "Time zone in effect is", tz_str.encode() ! print "Next timezone change happens at", tz_time.Format() class Registry(unittest.TestCase): --- 21,40 ---- tz_str = tzinfo[1] tz_time = tzinfo[2] ! # for the sake of code exercise but don't output ! tz_str.encode() ! tz_time.Format() ! def TestDateFormat(self): ! DATE_LONGDATE = 2 ! date_flags = DATE_LONGDATE ! win32api.GetDateFormat(0, date_flags, None) ! win32api.GetDateFormat(0, date_flags, 0) ! win32api.GetDateFormat(0, date_flags, datetime.datetime.now()) ! win32api.GetDateFormat(0, date_flags, time.time()) ! def TestTimeFormat(self): ! win32api.GetTimeFormat(0, 0, None) ! win32api.GetTimeFormat(0, 0, 0) ! win32api.GetTimeFormat(0, 0, datetime.datetime.now()) ! win32api.GetTimeFormat(0, 0, time.time()) ! class Registry(unittest.TestCase): |
From: Mark H. <mha...@us...> - 2005-03-02 02:25:11
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31612 Modified Files: PyIFilter.cpp Log Message: Correct silly error in my mem leak fixes. Index: PyIFilter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src/PyIFilter.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyIFilter.cpp 28 Feb 2005 01:08:18 -0000 1.5 --- PyIFilter.cpp 2 Mar 2005 02:25:02 -0000 1.6 *************** *** 112,116 **** HRESULT hr; ! if (nBufSize = 0) nBufSize = 8192; // 8k default --- 112,116 ---- HRESULT hr; ! if (nBufSize == 0) nBufSize = 8192; // 8k default |
From: Mark H. <mha...@us...> - 2005-02-28 01:08:31
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv445 Modified Files: PyIFilter.cpp Log Message: Plug some IFilter memory and object leaks. Index: PyIFilter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src/PyIFilter.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIFilter.cpp 28 Feb 2005 00:09:31 -0000 1.4 --- PyIFilter.cpp 28 Feb 2005 01:08:18 -0000 1.5 *************** *** 85,93 **** } ! PyObject * obAttr = Py_BuildValue("OO", PyWinObject_FromIID(stat.attribute.guidPropSet), obProp); ! return Py_BuildValue("iiiiOiii", stat.idChunk, stat.breakType, stat.flags, --- 85,93 ---- } ! PyObject * obAttr = Py_BuildValue("NN", PyWinObject_FromIID(stat.attribute.guidPropSet), obProp); ! return Py_BuildValue("iiiiNiii", stat.idChunk, stat.breakType, stat.flags, *************** *** 112,117 **** HRESULT hr; ! PY_INTERFACE_PRECALL; ! if (nBufSize <= 0) nBufSize = 8192; // 8k default --- 112,116 ---- HRESULT hr; ! if (nBufSize = 0) nBufSize = 8192; // 8k default *************** *** 122,137 **** } hr = pIF->GetText( &nBufSize, wBuffer ); PY_INTERFACE_POSTCALL; ! PyObject *obRet = PyWinObject_FromWCHAR(wBuffer, nBufSize); ! ! PyWinObject_FreeWCHAR(wBuffer); ! ! if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIF, IID_IFilter ); ! ! return obRet; } --- 121,136 ---- } + PY_INTERFACE_PRECALL; hr = pIF->GetText( &nBufSize, wBuffer ); PY_INTERFACE_POSTCALL; ! if ( FAILED(hr) ) { ! PyMem_Free(wBuffer); return PyCom_BuildPyException(hr, pIF, IID_IFilter ); ! } + PyObject *obRet = PyWinObject_FromWCHAR(wBuffer, nBufSize); + PyMem_Free(wBuffer); + return obRet; } |
From: Mark H. <mha...@us...> - 2005-02-28 00:09:46
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16084 Modified Files: PyIFilter.cpp Log Message: Register query.dll as supplying all IFilter based error messages. Index: PyIFilter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src/PyIFilter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIFilter.cpp 25 Jan 2005 12:14:47 -0000 1.3 --- PyIFilter.cpp 28 Feb 2005 00:09:31 -0000 1.4 *************** *** 332,336 **** // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); ! // NOTE: New constants should go in ifiltercon.py // IFilter Init functions --- 332,343 ---- // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, g_interfaceSupportData, sizeof(g_interfaceSupportData)/sizeof(PyCom_InterfaceSupportInfo)); ! ! // Tell pywintypes that IFilter error messages can be extracted from ! // query.dll ! HMODULE hmod = GetModuleHandle("query.dll"); ! if (hmod) ! // According to FiltErr.h, "Codes 0x1700-0x172F are reserved for FILTER" ! PyWin_RegisterErrorMessageModule(0x80041700, 0x8004172F, hmod); ! // NOTE: New constants should go in ifiltercon.py // IFilter Init functions |
From: Mark H. <mha...@us...> - 2005-02-28 00:08:46
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15525 Modified Files: ErrorUtils.cpp Log Message: When formatting a COM error message, check if the HRESULT has been registered as being supplied by a specific DLL, and if so, use it. Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ErrorUtils.cpp 26 Jan 2005 02:27:54 -0000 1.24 --- ErrorUtils.cpp 28 Feb 2005 00:08:36 -0000 1.25 *************** *** 1172,1175 **** --- 1172,1189 ---- return; } + // Next see if this particular error code is registerd as being supplied + // by a specific DLL. + HINSTANCE hi = PyWin_GetErrorMessageModule(hr); + if (hi) { + numCopied = ::FormatMessage(FORMAT_MESSAGE_FROM_HMODULE, hi, hr, 0, buf, bufSize, NULL ); + if (numCopied>0) { + if (numCopied<bufSize) { + // trim trailing crap + if (numCopied>2 && (buf[numCopied-2]=='\n'||buf[numCopied-2]=='\r')) + buf[numCopied-2] = '\0'; + } + return; + } + } // else look for it in the table |