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.

144 lines
4.0 KiB

  1. //-----------------------------------------------------------------------------
  2. // RNAAPI class
  3. //
  4. // This class provides a series of cover function for the RNAPH/RASAPI32 dlls
  5. //
  6. // Created 1-29-96 ChrisK
  7. // ############################################################################
  8. // INCLUDES
  9. #include "pch.hpp"
  10. //#include "ras.h"
  11. #ifdef WIN16
  12. #include <win16def.h>
  13. #include <rasc.h>
  14. #include <raserr.h>
  15. #else
  16. #include <ras.h>
  17. #endif
  18. #pragma pack (4)
  19. //#if !defined(WIN16)
  20. //#include <rnaph.h>
  21. //#endif
  22. #pragma pack ()
  23. #include "rnaapi.h"
  24. #include "debug.h"
  25. // ############################################################################
  26. // RNAAPI class
  27. CRNAAPI::CRNAAPI()
  28. {
  29. #if defined WIN16
  30. m_hInst = LoadLibrary ("RAS16IE.DLL");
  31. m_hInst2 = NULL;
  32. #else
  33. m_hInst = LoadLibrary(TEXT("RASAPI32.DLL"));
  34. if (FALSE == IsNT ())
  35. {
  36. //
  37. // we only load RNAPH.DLL if it is not NT
  38. // MKarki (5/4/97) - Fix for Bug #3378
  39. //
  40. m_hInst2 = LoadLibrary(TEXT("RNAPH.DLL"));
  41. }
  42. else
  43. {
  44. m_hInst2 = NULL;
  45. }
  46. #endif
  47. m_fnRasEnumDeviecs = NULL;
  48. m_fnRasValidateEntryName = NULL;
  49. m_fnRasSetEntryProperties = NULL;
  50. m_fnRasGetEntryProperties = NULL;
  51. }
  52. // ############################################################################
  53. CRNAAPI::~CRNAAPI()
  54. {
  55. // Clean up
  56. if (m_hInst) FreeLibrary(m_hInst);
  57. if (m_hInst2) FreeLibrary(m_hInst2);
  58. }
  59. // ############################################################################
  60. DWORD CRNAAPI::RasEnumDevices(LPRASDEVINFO lpRasDevInfo, LPDWORD lpcb,
  61. LPDWORD lpcDevices)
  62. {
  63. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  64. // Look for the API if we haven't already found it
  65. LoadApi("RasEnumDevices",(FARPROC*)&m_fnRasEnumDeviecs);
  66. if (m_fnRasEnumDeviecs)
  67. dwRet = (*m_fnRasEnumDeviecs) (lpRasDevInfo, lpcb, lpcDevices);
  68. return dwRet;
  69. }
  70. // ############################################################################
  71. BOOL CRNAAPI::LoadApi(LPSTR pszFName, FARPROC* pfnProc)
  72. {
  73. if (*pfnProc == NULL)
  74. {
  75. // Look for the entry point in the first DLL
  76. if (m_hInst)
  77. *pfnProc = GetProcAddress(m_hInst,pszFName);
  78. // if that fails, look for the entry point in the second DLL
  79. if (m_hInst2 && !(*pfnProc))
  80. *pfnProc = GetProcAddress(m_hInst2,pszFName);
  81. }
  82. return (pfnProc != NULL);
  83. }
  84. // ############################################################################
  85. DWORD CRNAAPI::RasValidateEntryName(LPTSTR lpszPhonebook,LPTSTR lpszEntry)
  86. {
  87. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  88. // Look for the API if we haven't already found it
  89. LoadApi("RasValidateEntryName",(FARPROC*)&m_fnRasValidateEntryName);
  90. if (m_fnRasValidateEntryName)
  91. dwRet = (*m_fnRasValidateEntryName) (lpszPhonebook, lpszEntry);
  92. return dwRet;
  93. }
  94. // ############################################################################
  95. DWORD CRNAAPI::RasSetEntryProperties(LPTSTR lpszPhonebook, LPTSTR lpszEntry,
  96. LPBYTE lpbEntryInfo, DWORD dwEntryInfoSize,
  97. LPBYTE lpbDeviceInfo, DWORD dwDeviceInfoSize)
  98. {
  99. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  100. // Look for the API if we haven't already found it
  101. LoadApi("RasSetEntryProperties",(FARPROC*)&m_fnRasSetEntryProperties);
  102. if (m_fnRasSetEntryProperties)
  103. dwRet = (*m_fnRasSetEntryProperties) (lpszPhonebook, lpszEntry,
  104. lpbEntryInfo, dwEntryInfoSize,
  105. lpbDeviceInfo, dwDeviceInfoSize);
  106. return dwRet;
  107. }
  108. // ############################################################################
  109. DWORD CRNAAPI::RasGetEntryProperties(LPTSTR lpszPhonebook, LPTSTR lpszEntry,
  110. LPBYTE lpbEntryInfo, LPDWORD lpdwEntryInfoSize,
  111. LPBYTE lpbDeviceInfo, LPDWORD lpdwDeviceInfoSize)
  112. {
  113. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  114. // Look for the API if we haven't already found it
  115. LoadApi("RasGetEntryProperties",(FARPROC*)&m_fnRasGetEntryProperties);
  116. if (m_fnRasGetEntryProperties)
  117. dwRet = (*m_fnRasGetEntryProperties) (lpszPhonebook, lpszEntry,
  118. lpbEntryInfo, lpdwEntryInfoSize,
  119. lpbDeviceInfo, lpdwDeviceInfoSize);
  120. return dwRet;
  121. }