Source code of Windows XP (NT5)
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.

140 lines
1.9 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. memset(lpszString, 0, len) ;
  88. }
  89. }
  90. //
  91. // clear a unicode string. this is used to make sure we have no passwords in
  92. // memory that gets written out to pagefile.sys
  93. //
  94. VOID
  95. ClearStringW(
  96. LPWSTR lpszString)
  97. {
  98. DWORD len ;
  99. if (lpszString)
  100. {
  101. if (len = wcslen(lpszString))
  102. memset(lpszString, 0, len * sizeof(WCHAR)) ;
  103. }
  104. }