Source code of Windows XP (NT5)
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.

87 lines
2.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1997, Microsoft Corporation.
  4. //
  5. // File: snapimg.cxx
  6. //
  7. // Contents: runtime dynlink to imagehlp
  8. //
  9. // History: 23-jan-97 MarkZ Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. #include <imagehlp.h>
  15. #include "snapimg.hxx"
  16. #if CIDBG
  17. T_SymInitialize LocalSymInitialize = SymInitialize;
  18. #else // CIDBG
  19. T_SymInitialize LocalSymInitialize = 0;
  20. #endif // CIDBG
  21. T_SymSetOptions LocalSymSetOptions = 0;
  22. T_SymGetSymFromAddr LocalSymGetSymFromAddr = 0;
  23. T_SymUnDName LocalSymUnDName = 0;
  24. BOOL fLocalRoutinesInitialized = FALSE;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Function: SnapToImageHlp()
  28. //
  29. // Synopsis: snap a runtime link to ImageHlp
  30. //
  31. // Returns: TRUE if snap has been done
  32. //
  33. // History: 23-jan-97 MarkZ Created
  34. //
  35. //----------------------------------------------------------------------------
  36. BOOL
  37. SnapToImageHlp( void )
  38. {
  39. //
  40. // Make sure we don't have to do extra work
  41. //
  42. if (!fLocalRoutinesInitialized) {
  43. //
  44. // Load ImageHlp
  45. //
  46. HINSTANCE hInstance = LoadLibrary( L"DBGHELP.DLL" );
  47. if (hInstance == NULL) {
  48. return FALSE;
  49. }
  50. //
  51. // Load Routines
  52. //
  53. if ((LocalSymSetOptions =
  54. (T_SymSetOptions) GetProcAddress( hInstance, "SymSetOptions" )) == NULL ||
  55. (LocalSymGetSymFromAddr =
  56. (T_SymGetSymFromAddr) GetProcAddress( hInstance, "SymGetSymFromAddr" )) == NULL ||
  57. (LocalSymUnDName =
  58. (T_SymUnDName) GetProcAddress( hInstance, "SymUnDName" )) == NULL ||
  59. (LocalSymInitialize =
  60. (T_SymInitialize) GetProcAddress( hInstance, "SymInitialize" )) == NULL
  61. ) {
  62. return FALSE;
  63. }
  64. //
  65. // Signal that we are initialized
  66. //
  67. fLocalRoutinesInitialized = TRUE;
  68. }
  69. return TRUE;
  70. }