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.

76 lines
3.4 KiB

  1. // System includes come from SymbolCheckAPI.h
  2. #include <windows.h>
  3. #include <winnt.h>
  4. #include <dbghelp.h>
  5. #include <dbgimage.h>
  6. #include <stdio.h>
  7. #define PDB_LIBRARY
  8. #include <pdb.h>
  9. #include <Dia2.h>
  10. #include <stdlib.h>
  11. #include "cvinfo.h"
  12. #include "cvexefmt.h"
  13. //#ifdef __cplusplus
  14. //extern "C" {
  15. //#endif // __cplusplus
  16. ///////////////////////////////////////////////////////////////////////////////
  17. //
  18. // Error values for the mapping functions
  19. //
  20. //#define ERROR_SUCCESS 0x0000000 // completed successfully - defined by windows.h
  21. #define ERROR_OPEN_FAILURE 0x20000001 // couldn't open file
  22. #define ERROR_FILE_MAPPING_FAILED 0x20000002 // couldn't map file
  23. #define ERROR_MAPVIEWOFFILE_FAILED 0x20000003 // couldn't map
  24. #define ERROR_NO_DOS_HEADER 0x20000004 // not a DOS file
  25. #define ERROR_HEADER_NOT_ON_LONG_BOUNDARY 0x20000005 // bad header
  26. #define ERROR_IMAGE_BIGGER_THAN_FILE 0x20000006 // bad file mapping
  27. #define ERROR_NOT_NT_IMAGE 0x20000007 // not an NT image
  28. #define ERROR_GET_FILE_INFO_FAILED 0x20000008 // couldn't get file info
  29. BOOL SymCommonDBGPrivateStripped(PCHAR DebugData, ULONG DebugSize);
  30. PCVDD SymCommonDosHeaderToCVDD(PIMAGE_DOS_HEADER pDosHeader);
  31. IMAGE_DEBUG_DIRECTORY UNALIGNED* SymCommonGetDebugDirectoryInDbg(PIMAGE_SEPARATE_DEBUG_HEADER pDbgHeader, ULONG *NumberOfDebugDirectories);
  32. IMAGE_DEBUG_DIRECTORY UNALIGNED* SymCommonGetDebugDirectoryInExe(PIMAGE_DOS_HEADER pDosHeader, DWORD* NumberOfDebugDirectories);
  33. DWORD SymCommonGetFullPathName(LPCTSTR lpFilename, DWORD nBufferLength, LPTSTR lpBuffer, LPTSTR *lpFilePart);
  34. PIMAGE_SEPARATE_DEBUG_HEADER SymCommonMapDbgHeader( LPCTSTR szFileName, PHANDLE phFile);
  35. PIMAGE_DOS_HEADER SymCommonMapFileHeader(LPCTSTR szFileName, PHANDLE phFile, DWORD *dwError);
  36. BOOL SymCommonPDBLinesStripped( PDB *ppdb, DBI *pdbi);
  37. BOOL SymCommonPDBPrivateStripped(PDB *ppdb, DBI *pdbi);
  38. BOOL SymCommonPDBTypesStripped( PDB *ppdb, DBI *pdbi);
  39. BOOL SymCommonResourceOnlyDll( PVOID pImageBase);
  40. BOOL SymCommonTlbImpManagedDll(PVOID pImageBase, PIMAGE_NT_HEADERS pNtHeader);
  41. BOOL SymCommonUnmapFile(LPCVOID phFileMap, HANDLE hFile);
  42. __inline PIMAGE_NT_HEADERS SymCommonGetNtHeader (PIMAGE_DOS_HEADER pDosHeader, HANDLE hDosFile) {
  43. /*
  44. Returns the pointer the address of the NT Header. If there isn't
  45. an NT header, it returns NULL
  46. */
  47. PIMAGE_NT_HEADERS pNtHeader = NULL;
  48. BY_HANDLE_FILE_INFORMATION FileInfo;
  49. //
  50. // If the image header is not aligned on a long boundary.
  51. // Report this as an invalid protect mode image.
  52. //
  53. if ( ((ULONG)(pDosHeader->e_lfanew) & 3) == 0) {
  54. if (GetFileInformationByHandle( hDosFile, &FileInfo) &&
  55. ((ULONG)(pDosHeader->e_lfanew) <= FileInfo.nFileSizeLow)) {
  56. pNtHeader = (PIMAGE_NT_HEADERS)((PCHAR)pDosHeader +
  57. (ULONG)pDosHeader->e_lfanew);
  58. if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) {
  59. pNtHeader = NULL;
  60. }
  61. }
  62. }
  63. return pNtHeader;
  64. }
  65. //#ifdef __cplusplus
  66. //}
  67. //#endif // __cplusplus