From 701bd3e9adb02d95e388539627eadd02bf54dc90 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 3 Aug 2015 13:43:48 +0000 Subject: =?UTF-8?q?pass=5FptrA,=20pass=5FptrW=20and=20pass=5FptrT=20moved?= =?UTF-8?q?=20to=20m=5Fsystem=5Fcpp.h=20[=D0=BF=D0=BE=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D1=8C=D0=B1=D0=B0=D0=BC=20=D1=82=D1=80=D1=83=D0=B4=D1=8F?= =?UTF-8?q?=D1=89=D0=B8=D1=85=D1=81=D1=8F]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@14832 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- include/m_system_cpp.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index a0679e496b..7d28b70d39 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -86,6 +86,37 @@ public: __inline ~mir_cslock() { ::LeaveCriticalSection(&cs); } }; +////////////////////////////////////////////////////////////////////////////// +//pass_ptrA, pass_ptrW and pass_ptrT - automatic pointer for passwords + +class pass_ptrA : public mir_ptr +{ +public: + __inline explicit pass_ptrA() : mir_ptr(){} + __inline explicit pass_ptrA(char* _p) : mir_ptr(_p) {} + __inline ~pass_ptrA() { zero(); } + __inline char* operator = (char *_p){ zero(); mir_ptr::operator=(_p); } + __inline void zero() + { char *_data = mir_ptr::operator char *(); + if (_data) SecureZeroMemory(_data, mir_strlen(_data)); + } +}; + +class pass_ptrW : public mir_ptr +{ +public: + __inline explicit pass_ptrW() : mir_ptr(){} + __inline explicit pass_ptrW(WCHAR* _p) : mir_ptr(_p) {} + __inline ~pass_ptrW() { zero(); } + __inline WCHAR* operator = (WCHAR *_p){ zero(); mir_ptr::operator=(_p); } + __inline void zero() + { WCHAR *_data = mir_ptr::operator WCHAR *(); + if (_data) SecureZeroMemory(_data, mir_wstrlen(_data)*sizeof(WCHAR)); + } +}; + +typedef pass_ptrW pass_ptrT; + /////////////////////////////////////////////////////////////////////////////// // mir_cslockfull - controllable locker for the critical sections -- cgit v1.2.3