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.

225 lines
5.3 KiB

  1. /*** cmUtl.C - Utility functions for Win 32 Clear Memory.
  2. *
  3. *
  4. * Title:
  5. * cmUtl - Clear Memory Utility Routines
  6. *
  7. * Copyright (c) 1990-1993, Microsoft Corporation.
  8. * Russ Blake.
  9. *
  10. *
  11. * Description:
  12. *
  13. * This file includes all the utility functions used by the Win 32
  14. * clear memory. (clearmem.c)
  15. *
  16. *
  17. * Design/Implementation Notes:
  18. *
  19. *
  20. * Modification History:
  21. * 90.03.08 RussBl -- Created
  22. * 93.05.12 HonWahChan -- removed timer related error msgs.
  23. *
  24. */
  25. /* * * * * * * * * * * * * I N C L U D E F I L E S * * * * * * * * * * */
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29. #include <malloc.h>
  30. #include <nt.h>
  31. #include <ntrtl.h>
  32. #include <nturtl.h>
  33. #include <windows.h>
  34. #include "clearmem.h"
  35. /* * * * * * * * * * G L O B A L D E C L A R A T I O N S * * * * * * * * */
  36. /* none */
  37. /* * * * * * * * * * F U N C T I O N P R O T O T Y P E S * * * * * * * * */
  38. #include "cmUtl.h"
  39. /* * * * * * * * * * * G L O B A L V A R I A B L E S * * * * * * * * * */
  40. /* none */
  41. /* * * * * * E X P O R T E D G L O B A L V A R I A B L E S * * * * * */
  42. /* none */
  43. /******************************* F a i l e d *******************************
  44. *
  45. * Failed(rc, lpstrFname, lineno, lpstrMsg) -
  46. * Checks the RC for an error type if an error has occured,
  47. * prints the appropriate error message. It logs the error
  48. * message to the testlog file.
  49. *
  50. * ENTRY rc - return code from the last API call
  51. * lpstrFname - contains file name of where error occured
  52. * lineno - contains line number of failed API call
  53. * lpstrMsg - contains a general purpose message about the error
  54. *
  55. * EXIT -none-
  56. *
  57. * RETURN TRUE - if API failed
  58. * FALSE - if API successful
  59. *
  60. * WARNING:
  61. * -none-
  62. *
  63. * COMMENT:
  64. * -none-
  65. *
  66. */
  67. BOOL Failed (RC rc, LPSTR lpstrFname, WORD lineno, LPSTR lpstrMsg)
  68. {
  69. LPSTR lpstrErrMsg;
  70. if (rc != STATUS_SUCCESS) {
  71. switch (rc) {
  72. case (NTSTATUS)STATUS_INVALID_PARAMETER:
  73. lpstrErrMsg = "Invalid parameter";
  74. break;
  75. case STATUS_TIMEOUT:
  76. lpstrErrMsg = "TimeOut occured";
  77. break;
  78. case STATUS_INVALID_HANDLE:
  79. lpstrErrMsg = "Invalid handle";
  80. break;
  81. case STATUS_BUFFER_OVERFLOW:
  82. lpstrErrMsg = "Buffer overflow";
  83. break;
  84. case STATUS_ABANDONED:
  85. lpstrErrMsg = "Object abandoned";
  86. break;
  87. case ERROR_NOT_ENOUGH_MEMORY:
  88. lpstrErrMsg = "Not enough memory";
  89. break;
  90. case LOGIC_ERR:
  91. lpstrErrMsg = "Logic error encountered";
  92. break;
  93. case INPUTARGS_ERR:
  94. lpstrErrMsg = "Invalid number of input arguments";
  95. break;
  96. case FILEARG_ERR:
  97. lpstrErrMsg = "Invalid cf data file argument";
  98. break;
  99. case TIMEARG_ERR:
  100. lpstrErrMsg = "Invalid trial time argument";
  101. break;
  102. case INSUFMEM_ERR:
  103. lpstrErrMsg = "Insufficient Memory";
  104. break;
  105. case FCLOSE_ERR:
  106. lpstrErrMsg = "fclose() failed";
  107. break;
  108. case FFLUSH_ERR:
  109. lpstrErrMsg = "fflush() failed";
  110. break;
  111. case FOPEN_ERR:
  112. lpstrErrMsg = "fopen() failed";
  113. break;
  114. case FSEEK_ERR:
  115. lpstrErrMsg = "fseek() failed";
  116. break;
  117. case MEANSDEV_ERR:
  118. lpstrErrMsg = "Invalid Mean and/or Standard Deviation";
  119. break;
  120. case PRCSETUP_ERR:
  121. lpstrErrMsg = "Child process setup/init failed";
  122. break;
  123. case THDSETUP_ERR:
  124. lpstrErrMsg = "Thread setup/init failed";
  125. break;
  126. default:
  127. lpstrErrMsg = "";
  128. } /* switch(rc) */
  129. printf(" **************************\n");
  130. printf(" * FAILure --> Line=%d File=%s (pid=0x%lX tid=0x%lX)\n",
  131. lineno, lpstrFname, GetCurrentProcessId(),
  132. GetCurrentThreadId());
  133. printf(" * RC=0x%lX (%s)\n", rc, lpstrErrMsg);
  134. printf(" * %s\n", lpstrMsg);
  135. printf(" **************************\n");
  136. return(TRUE);
  137. } /* if(rc..) */
  138. return(FALSE);
  139. } /* Failed() */
  140. /************************** D i s p l a y U s a g e ************************
  141. *
  142. * DisplayUsage() -
  143. * Displays usgae for Multi-Processor Response cf
  144. *
  145. * ENTRY -none-
  146. *
  147. * EXIT -none-
  148. *
  149. * RETURN -none-
  150. *
  151. * WARNING:
  152. * -none-
  153. *
  154. * COMMENT:
  155. * -none-
  156. *
  157. */
  158. void DisplayUsage (void)
  159. {
  160. printf("\nUsage: cf FlushFile\n");
  161. printf(" FlushFile - File used to flush the cache, should be 128kb\n");
  162. return;
  163. } /* DisplayUsage() */
  164.