diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-03 13:43:48 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-03 13:43:48 +0000 |
commit | 701bd3e9adb02d95e388539627eadd02bf54dc90 (patch) | |
tree | ffa6ef6bcbf2a18cb5cf8399ec79b241a65591a0 /include | |
parent | a4058bdd418f3a3168e26d1fc2a07ae2e9bab0c6 (diff) |
pass_ptrA, pass_ptrW and pass_ptrT moved to m_system_cpp.h [по просьбам трудящихся]
git-svn-id: http://svn.miranda-ng.org/main/trunk@14832 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include')
-rw-r--r-- | include/m_system_cpp.h | 31 |
1 files changed, 31 insertions, 0 deletions
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<char>
+{
+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<WCHAR>
+{
+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
|