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.

73 lines
1.9 KiB

  1. /*
  2. This program prints the name of the .pdb corresponding to an image (.dll/.exe/etc.).
  3. foo.dll does not always map to foo.exe.
  4. for example:
  5. getpdbname %windir%\system32\msvcrt.dll %windir%\system32\ntoskrnl.exe %windir%\syswow64\kernel32.dll
  6. D:\WINDOWS\system32\msvcrt.dll MicrosoftWindowsCPlusPlusRuntime-7010-msvcrt.pdb
  7. D:\WINDOWS\system32\ntoskrnl.exe ntkrnlmp.pdb
  8. D:\WINDOWS\syswow64\kernel32.dll wkernel32.pdb
  9. */
  10. #include "lib.h"
  11. void Main(int argc, char ** argv)
  12. {
  13. PDB_INFO_EX PdbInfo = { 0 };
  14. HRESULT hr = 0;
  15. FILE * rf;
  16. char textFromFile[MAX_PATH];
  17. rf = NULL;
  18. while (*++argv)
  19. {
  20. if ( '@' == argv[0][0] )
  21. {
  22. rf = fopen( &(argv[0][1]), "rt" );
  23. if ( !rf )
  24. {
  25. printf( "Error opening file %s\n", &(argv[0][1]) );
  26. continue;
  27. }
  28. }
  29. else
  30. {
  31. rf = NULL;
  32. }
  33. if (rf && EOF == fscanf( rf, "%s", &textFromFile ) )
  34. {
  35. // apparently an empty file
  36. continue;
  37. }
  38. do
  39. {
  40. if (FAILED(hr = GetPdbInfoEx(&PdbInfo, (rf != NULL) ? textFromFile : *argv)))
  41. {
  42. printf("%s(%s) error 0x%lx|%lu|%s\n",
  43. __FUNCTION__,
  44. rf?textFromFile:*argv,
  45. hr,
  46. HRESULT_CODE(hr),
  47. GetErrorStringA(HRESULT_CODE(hr))
  48. );
  49. continue;
  50. }
  51. printf("%s %s\n", PdbInfo.ImageFilePathA, PdbInfo.PdbFilePathA);
  52. ClosePdbInfoEx(&PdbInfo);
  53. }
  54. while( rf && EOF != fscanf( rf, "%s", &textFromFile ) );
  55. if ( rf )
  56. {
  57. fclose( rf );
  58. }
  59. }
  60. }
  61. int __cdecl main(int argc, char ** argv)
  62. {
  63. Main(argc, argv);
  64. return 0;
  65. }