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.

88 lines
2.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: dbghelpfunctions.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // DBGHelpFunctions.cpp: implementation of the CDBGHelpFunctions class.
  11. //
  12. //////////////////////////////////////////////////////////////////////
  13. #ifndef NO_STRICT
  14. #ifndef STRICT
  15. #define STRICT 1
  16. #endif
  17. #endif /* NO_STRICT */
  18. #include <WINDOWS.H>
  19. #include <TCHAR.H>
  20. #include <STDIO.H>
  21. #include <stdlib.h>
  22. #include "DBGHelpFunctions.h"
  23. #include "UtilityFunctions.h"
  24. //////////////////////////////////////////////////////////////////////
  25. // Construction/Destruction
  26. //////////////////////////////////////////////////////////////////////
  27. CDBGHelpFunctions::CDBGHelpFunctions()
  28. {
  29. m_hDBGHELP = NULL;
  30. m_lpfMakeSureDirectoryPathExists = NULL;
  31. }
  32. CDBGHelpFunctions::~CDBGHelpFunctions()
  33. {
  34. if (m_hDBGHELP)
  35. FreeLibrary(m_hDBGHELP);
  36. }
  37. BOOL CDBGHelpFunctions::MakeSureDirectoryPathExists(LPTSTR DirPath)
  38. {
  39. if (!m_lpfMakeSureDirectoryPathExists)
  40. return FALSE;
  41. char szDirPath[_MAX_PATH];
  42. CUtilityFunctions::CopyTSTRStringToAnsi(DirPath, szDirPath, _MAX_PATH);
  43. return m_lpfMakeSureDirectoryPathExists(szDirPath);
  44. }
  45. bool CDBGHelpFunctions::Initialize()
  46. {
  47. // Load library on DBGHELP.DLL and get the procedures explicitly.
  48. m_hDBGHELP = LoadLibrary( TEXT("DBGHELP.DLL") );
  49. if( m_hDBGHELP == NULL )
  50. {
  51. // This is fatal, since we need this for cases where we are searching
  52. // for DBG files, and creation of directories...
  53. _tprintf(TEXT("\nERROR: Unable to load DBGHELP.DLL, which is required for proper operation.\n"));
  54. _tprintf(TEXT("You should ensure that a copy of this DLL is on your system path, or in the\n"));
  55. _tprintf(TEXT("same directory as this utility.\n"));
  56. return false;
  57. } else
  58. {
  59. // Get procedure addresses.
  60. m_lpfMakeSureDirectoryPathExists = (PfnMakeSureDirectoryPathExists) GetProcAddress( m_hDBGHELP, "MakeSureDirectoryPathExists");
  61. if( (m_lpfMakeSureDirectoryPathExists == NULL) )
  62. {
  63. // Consider this fatal
  64. _tprintf(TEXT("\nWARNING: The version of DBGHELP.DLL being loaded doesn't have required\n"));
  65. _tprintf(TEXT("functions!. Please update this module with a newer version and try again.\n"));
  66. FreeLibrary( m_hDBGHELP ) ;
  67. m_hDBGHELP = NULL;
  68. }
  69. }
  70. return true;
  71. }