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.

122 lines
2.8 KiB

  1. //-----------------------------------------------------------------------
  2. // @doc
  3. //
  4. // @module convert crash dump to triage dump for crash dump utilities
  5. //
  6. // Copyright 1999 Microsoft Corporation. All Rights Reserved
  7. //
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <time.h>
  12. #include <tchar.h>
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <dbgeng.h>
  18. BOOL
  19. DoConversion(
  20. LPSTR szInputDumpFile, // full or kernel dump
  21. HANDLE OutputDumpFile // triage dump file
  22. );
  23. void Usage()
  24. {
  25. fprintf(stderr, "dmpconv -i input_dump_file -o output_dump_file\n");
  26. fprintf(stderr, "\tinput dump file is full or kernel crash dump.\n");
  27. fprintf(stderr, "\toutput is triage crash dump.\n");
  28. }
  29. int
  30. WINAPIV
  31. main(
  32. int argc,
  33. PTSTR argv[ ],
  34. PTSTR envp[]
  35. )
  36. {
  37. IDebugClient *DebugClient;
  38. PDEBUG_CONTROL DebugControl;
  39. HRESULT Hr;
  40. char *szInputDumpFile = NULL;
  41. char *szOutputTriageDumpFile = NULL;
  42. int iarg;
  43. for(iarg = 1; iarg < argc; iarg++)
  44. {
  45. if (argv[iarg][0] == '/' ||
  46. argv[iarg][0] == '-')
  47. {
  48. if (_tcslen(argv[iarg]) < 2)
  49. {
  50. Usage();
  51. exit(-1);
  52. }
  53. switch(argv[iarg][1])
  54. {
  55. default:
  56. Usage();
  57. exit(-1);
  58. case 'i':
  59. case 'I':
  60. szInputDumpFile = argv[++iarg];
  61. break;
  62. case 'o':
  63. case 'O':
  64. szOutputTriageDumpFile = argv[++iarg];
  65. break;
  66. }
  67. }
  68. else
  69. {
  70. Usage();
  71. exit(-1);
  72. }
  73. }
  74. if (szInputDumpFile == NULL ||
  75. szOutputTriageDumpFile == NULL)
  76. {
  77. Usage();
  78. exit(-1);
  79. }
  80. if ((Hr = DebugCreate(__uuidof(IDebugClient),
  81. (void **)&DebugClient)) != S_OK)
  82. {
  83. return Hr;
  84. }
  85. if (DebugClient->QueryInterface(__uuidof(IDebugControl),
  86. (void **)&DebugControl) == S_OK)
  87. {
  88. if (DebugClient->OpenDumpFile(szInputDumpFile) == S_OK)
  89. {
  90. // Optional. Conversion does not require symbols
  91. //if (DebugSymbols->SetSymbolPath("C:\\") == S_OK)
  92. DebugControl->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
  93. if (DebugClient->WriteDumpFile(szOutputTriageDumpFile,
  94. DEBUG_DUMP_SMALL) == S_OK)
  95. {
  96. Hr = S_OK;
  97. }
  98. }
  99. DebugControl->Release();
  100. }
  101. DebugClient->Release();
  102. return 0;
  103. }