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.

177 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1992-2001 Microsoft Corporation
  3. Module Name:
  4. mqrcvr.cpp
  5. Abstract:
  6. Receives file names from server and launches debugger
  7. --*/
  8. //
  9. // Includes
  10. //
  11. #include <stdio.h>
  12. #include <windows.h>
  13. #include <objbase.h>
  14. #include <tchar.h>
  15. //
  16. // Unique include file for ActiveX MSMQ apps
  17. //
  18. #include <mqoai.h>
  19. //
  20. // Various defines
  21. //
  22. #define MAX_VAR 20
  23. #define MAX_BUFFER 500
  24. extern char g_ServerMachine[MAX_COMPUTERNAME_LENGTH*4 + 1];
  25. extern char g_FormatName[MAX_PATH];
  26. extern CHAR g_DumpPath[MAX_PATH + 1];
  27. extern BOOL g_SendMail;
  28. extern BOOL g_CreateQ;
  29. extern BOOL g_bSend;
  30. //
  31. // Prototypes
  32. //
  33. HRESULT Syntax();
  34. HRESULT Receiver();
  35. HRESULT
  36. LaunchDebugger(BOOL fWait);
  37. HRESULT
  38. SendMessageText(
  39. PWCHAR pwszMsmqFormat,
  40. PWCHAR pwszMesgLabel,
  41. PWCHAR pwszMesgText
  42. );
  43. BOOL
  44. GetArgs(int Argc, CHAR ** Argv);
  45. int __cdecl
  46. CheckForUnprocessedDumps()
  47. {
  48. // This check s if any dumps was left unprocessed when this
  49. // process exited (abnormally)
  50. if (g_DumpPath[0])
  51. {
  52. // we have an unprocessed dump.
  53. // try and launch debugger on it
  54. printf("Found unprocessed dump\n");
  55. if (LaunchDebugger(FALSE) == S_OK)
  56. {
  57. g_DumpPath[0] = 0;
  58. }
  59. }
  60. return 0;
  61. }
  62. void
  63. SendLoop()
  64. {
  65. WCHAR Msg[100]={0}, Label[100]={0}, Format[100]={0};
  66. CHAR Buffer[100]={0};
  67. DWORD MsgId = 0;
  68. _snwprintf(Format, sizeof(Format)/sizeof(Format[0]), L"%S", g_FormatName);
  69. Format[sizeof(Format)/sizeof(Format[0]) - 1] = 0;
  70. while (Buffer[0] != 'q')
  71. {
  72. printf("Enter label : ");
  73. if (!scanf("%50s", Buffer))
  74. {
  75. Buffer[0] =0;
  76. }
  77. _snwprintf(Label, sizeof(Label)/sizeof(Label[0]), L"%02ld: %S", MsgId, Buffer);
  78. Label[sizeof(Label)/sizeof(Label[0]) -1] = 0;
  79. printf("Message %02ld : ", MsgId++);
  80. if (!scanf("%50s", Buffer))
  81. {
  82. Buffer[0] =0;
  83. }
  84. _snwprintf(Msg, sizeof(Msg) / sizeof(Msg[0]), L"%S", Buffer);
  85. Msg[sizeof(Msg) / sizeof(Msg[0]) -1] = 0;
  86. SendMessageText(Format, Label, Msg );
  87. }
  88. }
  89. //-----------------------------------------------------
  90. //
  91. // MAIN
  92. //
  93. //-----------------------------------------------------
  94. int __cdecl main(int argc, char * * argv)
  95. {
  96. DWORD dwNumChars;
  97. HRESULT hresult = NOERROR;
  98. hresult = OleInitialize(NULL);
  99. if (FAILED(hresult))
  100. {
  101. printf("Cannot init OLE", hresult);
  102. goto Cleanup;
  103. }
  104. //
  105. // Retrieve machine name
  106. //
  107. dwNumChars = MAX_COMPUTERNAME_LENGTH + 1;
  108. GetComputerNameA(g_ServerMachine, &dwNumChars);
  109. if (GetArgs(argc, argv))
  110. {
  111. g_DumpPath[0] = 0;
  112. _onexit( CheckForUnprocessedDumps );
  113. if (!g_bSend)
  114. {
  115. hresult = Receiver();
  116. } else
  117. {
  118. SendLoop();
  119. }
  120. }
  121. else
  122. {
  123. hresult = Syntax();
  124. }
  125. printf("\nOK\n");
  126. // fall through...
  127. Cleanup:
  128. return(int)hresult;
  129. }
  130. HRESULT Syntax()
  131. {
  132. printf("\n");
  133. printf("Syntax: mqrcvr.exe -d <debugger> \n"
  134. " -f <formatname> \n"
  135. " -m <memoryusage> \n"
  136. " -mail\n"
  137. " -p <miliseconds>\n"
  138. " -q <queue>\n"
  139. " -retriage\n"
  140. " -s <server> \n"
  141. " -y <local symbol cache> \n");
  142. return E_INVALIDARG;
  143. }