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.

121 lines
2.7 KiB

  1. /*++
  2. Copyright 1996 - 1997 Microsoft Corporation
  3. Module Name:
  4. symcvt.c
  5. Abstract:
  6. This module is the shell for the SYMCVT DLL. The DLL's purpose is
  7. to convert the symbols for the specified image. The resulting
  8. debug data must conform to the CODEVIEW spec.
  9. Currently this DLL converts COFF symbols and C7/C8 MAPTOSYM SYM files.
  10. Author:
  11. Wesley A. Witt (wesw) 19-April-1993
  12. Environment:
  13. Win32, User Mode
  14. --*/
  15. #include <windows.h>
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <string.h>
  19. #define _SYMCVT_SOURCE_
  20. #include "symcvt.h"
  21. PUCHAR
  22. ConvertSymbolsForImage(
  23. HANDLE hFile,
  24. char * fname
  25. )
  26. /*++
  27. Routine Description:
  28. Calls the appropriate conversion routine based on the file contents.
  29. Arguments:
  30. hFile - file handle for the image (may be NULL)
  31. fname - file name for the image (may not have correct path)
  32. Return Value:
  33. NULL - could not convert the symbols
  34. Valid Pointer - a pointer to malloc'ed memory that contains the
  35. CODEVIEW symbols
  36. --*/
  37. {
  38. POINTERS p;
  39. char szDrive [_MAX_DRIVE];
  40. char szDir [_MAX_DIR];
  41. char szFname [_MAX_FNAME];
  42. char szExt [_MAX_EXT];
  43. char szSymName [MAX_PATH];
  44. PUCHAR rVal;
  45. if (!MapInputFile( &p, hFile, fname)) {
  46. rVal = NULL;
  47. } else if (CalculateNtImagePointers( &p.iptrs )) {
  48. //
  49. // we were able to compute the nt image pointers so this must be
  50. // a nt PE image. now we must decide if there are coff symbols
  51. // if there are then we do the cofftocv conversion.
  52. //
  53. // btw, this is where someone would convert some other type of
  54. // symbols that are in a nt PE image. (party on garth..)
  55. //
  56. // if (!COFF_DIR(&p.iptrs)) {
  57. if (!p.iptrs.numberOfSymbols) {
  58. rVal = NULL;
  59. } else {
  60. ConvertCoffToCv( &p );
  61. rVal = p.pCvStart.ptr;
  62. }
  63. UnMapInputFile( &p );
  64. } else {
  65. UnMapInputFile ( &p );
  66. _splitpath( fname, szDrive, szDir, szFname, szExt );
  67. _makepath( szSymName, szDrive, szDir, szFname, "sym" );
  68. if (!MapInputFile( &p, NULL, szSymName)) {
  69. rVal = NULL;
  70. } else {
  71. //
  72. // must be a wow/dos app and there is a .sym file so lets to
  73. // the symtocv conversion
  74. //
  75. ConvertSymToCv( &p );
  76. UnMapInputFile( &p );
  77. rVal = p.pCvStart.ptr;
  78. }
  79. }
  80. return rVal;
  81. }