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.

249 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. assign.cpp
  5. Abstract:
  6. WinDbg Extension Api
  7. Environment:
  8. User Mode.
  9. Revision History:
  10. Andre Vachon (andreva)
  11. bugcheck analyzer.
  12. --*/
  13. #include "precomp.h"
  14. #include "mapistuff.h"
  15. DECLARE_API( assign )
  16. {
  17. ULONG Platform, MajorVer, MinorVer, SrvPack, StringUsed;
  18. CHAR BuildString[100];
  19. EXT_GET_FAILURE_ANALYSIS pfnGetAnalysis;
  20. PDEBUG_FAILURE_ANALYSIS pAnalysis = NULL;
  21. HANDLE hAssign;
  22. CHAR Text[4096];
  23. CHAR CorruptMods[1024];
  24. HRESULT hRes = S_FALSE;
  25. FA_ENTRY* Entry;
  26. INIT_API();
  27. g_ExtControl->GetSystemVersion(&Platform, &MajorVer, &MinorVer, NULL,
  28. 0, NULL, &SrvPack, &BuildString[0],
  29. sizeof(BuildString), &StringUsed);
  30. if (S_OK == g_ExtControl->GetExtensionFunction(0, "GetFailureAnalysis",
  31. (FARPROC*)&pfnGetAnalysis))
  32. {
  33. (*pfnGetAnalysis)(Client, 0, &pAnalysis);
  34. }
  35. if (pAnalysis)
  36. {
  37. //
  38. // If we are not doing assignment, just print the output
  39. //
  40. if (!*args)
  41. {
  42. ULONG i;
  43. g_ExtControl->Output(1, "Analysis data structure output\n");
  44. g_ExtControl->Output(1, "\n");
  45. g_ExtControl->Output(1, "Failure code %08lx\n", pAnalysis->GetFailureCode());
  46. Entry = pAnalysis->Get(DEBUG_FLR_FOLLOWUP_NAME);
  47. g_ExtControl->Output(1, "Followup Name : %s\n", Entry ?
  48. FA_ENTRY_DATA(PCHAR, Entry) : "<none>");
  49. Entry = pAnalysis->Get(DEBUG_FLR_BUCKET_ID);
  50. g_ExtControl->Output(1, "BucketId : %s\n", Entry ?
  51. FA_ENTRY_DATA(PCHAR, Entry) : "<none>");
  52. Entry = NULL;
  53. while (Entry = pAnalysis->NextEntry(Entry)) {
  54. g_ExtControl->Output(1,
  55. "Type = %08lx - Size = %08lx\n",
  56. Entry->Tag, Entry->DataSize);
  57. }
  58. hRes = S_OK;
  59. }
  60. if (!pAnalysis->Get(DEBUG_FLR_BUCKET_ID))
  61. {
  62. dprintf("missing bucket ID\n");
  63. sprintf(Text, "%s\n", args);
  64. //SendOffFailure("andreva",
  65. // "bugcheck assignment failed - no bucket",
  66. // Text);
  67. }
  68. else if (!pAnalysis->Get(DEBUG_FLR_FOLLOWUP_NAME))
  69. {
  70. dprintf("missing FollowUp\n");
  71. sprintf(Text, "%s\n", args);
  72. //SendOffFailure("andreva",
  73. // "bugcheck assignment failed - no followup",
  74. // Text);
  75. }
  76. else if (*args)
  77. {
  78. CHAR *rootDir;
  79. CHAR *dumpPath;
  80. CHAR *dumpFile;
  81. CHAR *parg;
  82. CHAR arg[MAX_PATH];
  83. CHAR dump[MAX_PATH];
  84. CHAR bucketDir[MAX_PATH];
  85. CHAR newfile[MAX_PATH];
  86. CHAR assignedTo[MAX_PATH];
  87. CHAR followupdir[MAX_PATH];
  88. strcpy(arg, args);
  89. parg = rootDir = arg;
  90. while (*parg && (*parg != ' ')) {parg++;}
  91. while (*parg && (*parg == ' ')) {*parg++ = 0;}
  92. dumpPath = parg;
  93. while (*parg && (*parg != ' ')) {parg++;}
  94. while (*parg && (*parg == ' ')) {*parg++ = 0;}
  95. dumpFile = parg;
  96. if (*rootDir && *dumpPath && *dumpFile)
  97. {
  98. sprintf(dump, "%s\\%s", dumpPath, dumpFile);
  99. CreateDirectory(rootDir, NULL);
  100. // create followup\bugcheck directory
  101. if ((Entry = pAnalysis->Get(DEBUG_FLR_POOL_CORRUPTOR)) ||
  102. (Entry = pAnalysis->Get(DEBUG_FLR_MEMORY_CORRUPTOR)))
  103. {
  104. sprintf(followupdir, "%s\\corruption-%s", rootDir,
  105. FA_ENTRY_DATA(PCHAR, Entry));
  106. }
  107. else
  108. {
  109. sprintf(followupdir, "%s\\%s", rootDir,
  110. FA_ENTRY_DATA(PCHAR,
  111. pAnalysis->Get(DEBUG_FLR_FOLLOWUP_NAME)));
  112. }
  113. CreateDirectory(followupdir, NULL);
  114. sprintf(bucketDir, "%s\\%s", followupdir,
  115. FA_ENTRY_DATA(PCHAR,
  116. pAnalysis->Get(DEBUG_FLR_BUCKET_ID)));
  117. CreateDirectory(bucketDir, NULL);
  118. sprintf(newfile, "%s\\%s", bucketDir, dumpFile);
  119. dprintf("%s\n", newfile);
  120. CopyFile(dump, newfile, 0);
  121. //
  122. // See if this succeeded correctly
  123. // put a marker in the root if it did
  124. //
  125. hAssign = CreateFile(newfile,
  126. GENERIC_READ | GENERIC_WRITE,
  127. 0,
  128. NULL,
  129. OPEN_EXISTING,
  130. FILE_ATTRIBUTE_NORMAL,
  131. NULL);
  132. if (hAssign != INVALID_HANDLE_VALUE)
  133. {
  134. CloseHandle(hAssign);
  135. hRes = S_OK;
  136. #if 0
  137. //
  138. // Check to see if this directory already has this failure
  139. // assigned to someone.
  140. //
  141. hAssign = CreateFile(assignedTo,
  142. GENERIC_READ | GENERIC_WRITE,
  143. 0,
  144. NULL,
  145. OPEN_EXISTING,
  146. FILE_ATTRIBUTE_NORMAL,
  147. NULL);
  148. if (hAssign == INVALID_HANDLE_VALUE)
  149. {
  150. hAssign = CreateFile(assignedTo,
  151. GENERIC_READ | GENERIC_WRITE,
  152. 0,
  153. NULL,
  154. CREATE_NEW,
  155. FILE_ATTRIBUTE_NORMAL,
  156. NULL);
  157. CHAR Title[1024];
  158. sprintf(Title,
  159. "Bugcheck %s",
  160. FA_ENTRY_DATA(PCHAR,
  161. pAnalysis->Get(DEBUG_FLR_BUCKET_ID)));
  162. sprintf(Text,
  163. "To debuger this dump file, run\n"
  164. "\n"
  165. "kd -z %s -y SRV*\\\\symbols\\symbols "
  166. "-i SRV*\\\\symbols\\symbols\n"
  167. "\n"
  168. "If this failure should not have been assigned to "
  169. "you, please send mail to \"dbg\"\n"
  170. "If you can not debug this dump file, "
  171. "please send mail to \"dbg\"\n"
  172. "If you have any other issues with this dump file"
  173. "please send mail to \"dbg\"\n"
  174. "\n"
  175. "We unfortunately do not know the origin of this "
  176. " dump file.\n",
  177. newfile);
  178. SendOffFailure(FA_ENTRY_DATA(PCHAR, pAnalysis->Get(DEBUG_FLR_FOLLOWUP_NAME)),
  179. Title,
  180. Text);
  181. }
  182. if (hAssign != INVALID_HANDLE_VALUE)
  183. {
  184. CloseHandle(hAssign);
  185. }
  186. #endif
  187. }
  188. }
  189. }
  190. pAnalysis->Release();
  191. }
  192. EXIT_API();
  193. return hRes;
  194. }