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.

95 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. error.c
  5. Abstract:
  6. Error handle module for the pfmon program
  7. Author:
  8. Mark Lucovsky (markl) 26-Jan-1995
  9. Revision History:
  10. --*/
  11. #include "pfmonp.h"
  12. VOID
  13. __cdecl
  14. DeclareError(
  15. UINT ErrorCode,
  16. UINT SupplementalErrorCode,
  17. ...
  18. )
  19. {
  20. va_list arglist;
  21. HMODULE ModuleHandle;
  22. DWORD Flags, Size;
  23. UCHAR MessageBuffer[ 512 ];
  24. va_start( arglist, SupplementalErrorCode );
  25. if ((ErrorCode & 0x0FFF0000) >> 16 == FACILITY_APPLICATION) {
  26. ModuleHandle = PfmonModuleHandle;
  27. Flags = FORMAT_MESSAGE_FROM_HMODULE;
  28. }
  29. else {
  30. ModuleHandle = NULL;
  31. Flags = FORMAT_MESSAGE_FROM_SYSTEM;
  32. }
  33. Size = FormatMessage( Flags,
  34. (LPCVOID)ModuleHandle,
  35. ErrorCode,
  36. 0,
  37. MessageBuffer,
  38. sizeof( MessageBuffer ),
  39. &arglist
  40. );
  41. va_end( arglist );
  42. if (Size != 0) {
  43. fprintf( stderr, "PFMON: %s", MessageBuffer );
  44. }
  45. else {
  46. fprintf( stderr, "PFMON: Unable to get message text for %08x\n", ErrorCode );
  47. }
  48. if (ModuleHandle == PfmonModuleHandle &&
  49. SupplementalErrorCode != 0 &&
  50. SupplementalErrorCode != ERROR_GEN_FAILURE
  51. ) {
  52. ModuleHandle = NULL;
  53. Flags = FORMAT_MESSAGE_FROM_SYSTEM;
  54. Size = FormatMessage( Flags,
  55. (LPCVOID)ModuleHandle,
  56. SupplementalErrorCode,
  57. 0,
  58. MessageBuffer,
  59. sizeof( MessageBuffer ),
  60. NULL
  61. );
  62. if (Size != 0) {
  63. while (Size != 0 && MessageBuffer[ Size ] <= ' ') {
  64. MessageBuffer[ Size ] = '\0';
  65. Size -= 1;
  66. }
  67. printf( " '%s'\n", MessageBuffer );
  68. }
  69. else {
  70. printf( "PFMON: Unable to get message text for %08x\n", SupplementalErrorCode );
  71. }
  72. }
  73. return;
  74. }