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.

77 lines
1.6 KiB

  1. // ===========================================================================
  2. // macstrsafe.h � 2002 Microsoft Corp. All rights reserved.
  3. // ===========================================================================
  4. // Porting header for Windows strsafe.h
  5. //
  6. // We also use this header to define some other security related routines
  7. // like RtlSecureZeroMemory().
  8. //
  9. #ifndef _MAC_STRSAFE_H_INCLUDE
  10. #define _MAC_STRSAFE_H_INCLUDE
  11. #pragma once
  12. #ifndef MAC
  13. #define MAC
  14. #endif
  15. //
  16. //We need to include this here so that other files that use it
  17. //won't fail with predefined errors.
  18. //
  19. #include "winerror.h"
  20. #include "macwindefs.h"
  21. //
  22. //To implicitly support wide characters. Mac calls will always map
  23. //to the "A" routines, this makes the unmodified strsafe.h compile
  24. //though.
  25. //
  26. #ifndef MAC_TARGET_CARBON
  27. #include <wchar.h>
  28. #else
  29. //
  30. //In Carbon under OS X, we have to define all the wcsXXX routines.
  31. //
  32. #define wcslen(w) 0
  33. #define getwc(c) 0
  34. #endif
  35. //
  36. //These macros map to the correct vsXXXX function calls on Macintosh
  37. //
  38. #define _vsnprintf vsnprintf
  39. #ifndef MAC_TARGET_CARBON
  40. #define _vsnwprintf vswprintf
  41. #else
  42. #define _vsnwprintf(a,b,c,d) vsnprintf((char*)a,b,(char*)c,d);
  43. #endif
  44. //
  45. //This is the "real" strsafe.h from the Windows SDK.
  46. //
  47. #include <strsafe.h>
  48. //
  49. //The following actually exists in ntrtl.h on windows. It is a safe
  50. //zero memory to be used when zeroing out password and auth data in memory.
  51. //
  52. inline PVOID RtlSecureZeroMemory(
  53. IN PVOID ptr,
  54. IN size_t cnt
  55. )
  56. {
  57. volatile char *vptr = (volatile char*)ptr;
  58. while(cnt)
  59. {
  60. *vptr = 0;
  61. vptr++;
  62. cnt--;
  63. }
  64. return ptr;
  65. }
  66. #endif //_MAC_STRSAFE_H_INCLUDE