Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1001 B

  1. /*++
  2. Copyright (c) 2003 Microsoft Corporation
  3. Module Name:
  4. xstring.h
  5. Abstract:
  6. Author:
  7. Stephen A Sulzer (ssulzer) 16-Jan-2003
  8. --*/
  9. //
  10. // class implementation of CSecureStr
  11. //
  12. class CSecureStr
  13. {
  14. LPWSTR _lpsz;
  15. int _stringLength;
  16. BOOL _fEncryptString;
  17. public:
  18. CSecureStr()
  19. {
  20. _lpsz = NULL;
  21. _stringLength = 0;
  22. _fEncryptString = TRUE;
  23. }
  24. ~CSecureStr()
  25. {
  26. Free();
  27. }
  28. void Free (void)
  29. {
  30. if (_lpsz)
  31. {
  32. SecureZeroMemory(_lpsz, _stringLength * sizeof(WCHAR));
  33. delete [] _lpsz;
  34. }
  35. _lpsz = NULL;
  36. _stringLength = 0;
  37. }
  38. LPWSTR GetPtr(void)
  39. {
  40. return _lpsz;
  41. }
  42. DWORD GetStrLen() const
  43. {
  44. return _stringLength;
  45. }
  46. LPWSTR GetUnencryptedString(); // always allocates memory regardless of _fEncryptString
  47. BOOL SetData(LPCWSTR lpszIn);
  48. };