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.

144 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. MSYSTEM.C
  5. Abstract:
  6. 32 bit version of mapping routines for Base API
  7. Author:
  8. Dan Hinsley (danhi) 06-Jun-1991
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. 24-Apr-1991 danhi
  13. Created
  14. 06-Jun-1991 Danhi
  15. Sweep to conform to NT coding style
  16. 09-Oct-1991 JohnRo
  17. Fixed bug #3215 - bogus messages when setting time.
  18. --*/
  19. //
  20. // INCLUDES
  21. //
  22. #include <windows.h>
  23. #include <lmerr.h>
  24. #include <lmcons.h>
  25. #include <lmapibuf.h>
  26. #include <netlib.h>
  27. #include "msystem.h"
  28. //
  29. // Used to replace uses of BigBuf and Buffer
  30. //
  31. TCHAR *
  32. GetBuffer(
  33. DWORD Size
  34. )
  35. {
  36. LPVOID lp;
  37. //
  38. // Allocate the buffer so that it can be freed with NetApiBufferFree
  39. //
  40. NetapipBufferAllocate(Size, &lp);
  41. return lp;
  42. }
  43. //
  44. // Replacement for DosAllocSeg
  45. //
  46. DWORD
  47. AllocMem(
  48. DWORD Size,
  49. PVOID * pBuffer
  50. )
  51. {
  52. return NetApiBufferAllocate(Size, pBuffer);
  53. }
  54. //
  55. // Replacement for DosReallocSeg
  56. //
  57. DWORD
  58. ReallocMem(
  59. DWORD Size,
  60. PVOID *pBuffer
  61. )
  62. {
  63. return NetApiBufferReallocate(*pBuffer, Size, pBuffer);
  64. }
  65. //
  66. // Frees up memory allocated with MAllocMem
  67. //
  68. DWORD
  69. FreeMem(
  70. PVOID Buffer
  71. )
  72. {
  73. return NetApiBufferFree(Buffer);
  74. }
  75. //
  76. // clear a 8 bit string. this is used to make sure we have no passwords in
  77. // memory that gets written out to pagefile.sys
  78. //
  79. VOID
  80. ClearStringA(
  81. LPSTR lpszString)
  82. {
  83. DWORD len ;
  84. if (lpszString)
  85. {
  86. if (len = strlen(lpszString))
  87. {
  88. RtlSecureZeroMemory(lpszString, len);
  89. }
  90. }
  91. }
  92. //
  93. // clear a unicode string. this is used to make sure we have no passwords in
  94. // memory that gets written out to pagefile.sys
  95. //
  96. VOID
  97. ClearStringW(
  98. LPWSTR lpszString)
  99. {
  100. DWORD len ;
  101. if (lpszString)
  102. {
  103. if (len = wcslen(lpszString))
  104. {
  105. RtlSecureZeroMemory(lpszString, len * sizeof(WCHAR));
  106. }
  107. }
  108. }