|
|
1.1 ! root 1: /*++ ! 2: ! 3: ! 4: Copyright (c) 1992 Microsoft Corporation ! 5: ! 6: Module Name: ! 7: ! 8: symcvt.c ! 9: ! 10: Abstract: ! 11: ! 12: This module is the shell for the SYMCVT DLL. The DLL's purpose is ! 13: to convert the symbols for the specified image. The resulting ! 14: debug data must conform to the CODEVIEW spec. ! 15: ! 16: Currently this DLL converts COFF symbols and C7/C8 MAPTOSYM SYM files. ! 17: ! 18: Author: ! 19: ! 20: Wesley A. Witt (wesw) 19-April-1993 ! 21: ! 22: Environment: ! 23: ! 24: Win32, User Mode ! 25: ! 26: --*/ ! 27: ! 28: #include <windows.h> ! 29: #include <stdlib.h> ! 30: #include <stdio.h> ! 31: #include <string.h> ! 32: ! 33: #include "symcvt.h" ! 34: #include "cofftocv.h" ! 35: #include "symtocv.h" ! 36: ! 37: ! 38: ! 39: PUCHAR ! 40: ConvertSymbolsForImage( ! 41: HANDLE hFile, ! 42: char * fname ! 43: ) ! 44: /*++ ! 45: ! 46: Routine Description: ! 47: ! 48: Calls the appropriate conversion routine based on the file contents. ! 49: ! 50: ! 51: Arguments: ! 52: ! 53: hFile - file handle for the image (may be NULL) ! 54: fname - file name for the image (may not have correct path) ! 55: ! 56: ! 57: Return Value: ! 58: ! 59: NULL - could not convert the symbols ! 60: Valid Pointer - a pointer to malloc'ed memory that contains the ! 61: CODEVIEW symbols ! 62: ! 63: --*/ ! 64: { ! 65: POINTERS p; ! 66: char szDrive [_MAX_DRIVE]; ! 67: char szDir [_MAX_DIR]; ! 68: char szFname [_MAX_FNAME]; ! 69: char szExt [_MAX_EXT]; ! 70: char szSymName [MAX_PATH]; ! 71: PUCHAR rVal; ! 72: ! 73: ! 74: if (!MapInputFile( &p, hFile, fname)) { ! 75: ! 76: rVal = NULL; ! 77: ! 78: } else if (CalculateNtImagePointers( &p.iptrs )) { ! 79: ! 80: // ! 81: // we were able to compute the nt image pointers so this must be ! 82: // a nt PE image. now we must decide if there are coff symbols ! 83: // if there are then we do the cofftocv conversion. ! 84: // ! 85: // btw, this is where someone would convert some other type of ! 86: // symbols that are in a nt PE image. (party on garth..) ! 87: // ! 88: ! 89: if (!COFF_DIR(&p.iptrs)) { ! 90: rVal = NULL; ! 91: } else { ! 92: ConvertCoffToCv( &p ); ! 93: rVal = p.pCvStart.ptr; ! 94: } ! 95: UnMapInputFile( &p ); ! 96: ! 97: } else { ! 98: ! 99: UnMapInputFile ( &p ); ! 100: ! 101: _splitpath( fname, szDrive, szDir, szFname, szExt ); ! 102: _makepath( szSymName, szDrive, szDir, szFname, "sym" ); ! 103: ! 104: if (!MapInputFile( &p, NULL, szSymName)) { ! 105: ! 106: rVal = NULL; ! 107: ! 108: } else { ! 109: ! 110: // ! 111: // must be a wow/dos app and there is a .sym file so lets to ! 112: // the symtocv conversion ! 113: // ! 114: ! 115: ConvertSymToCv( &p ); ! 116: UnMapInputFile( &p ); ! 117: ! 118: rVal = p.pCvStart.ptr; ! 119: } ! 120: ! 121: } ! 122: ! 123: return rVal; ! 124: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.